1 show usermode +h to clients (/mode +h spoof .. and /mode -h is allowed by clients)
3 diff -r 4c7b03099b6f include/client.h
7 #define FlagClr(set,flag) ((set)->bits[FLAGSET_INDEX(flag)] &= ~FLAGSET_MASK(flag))
9 /** String containing valid user modes, in no particular order. */
10 -#define infousermodes "dioOswkgxRXInPq"
11 +#define infousermodes "dioOswkghxRXInPq"
13 /** Character to indicate no oper name available */
14 #define NOOPERNAMECHARACTER '-'
15 diff -r 4c7b03099b6f include/s_user.h
16 --- a/include/s_user.h
17 +++ b/include/s_user.h
19 extern int set_nick_name(struct Client* cptr, struct Client* sptr,
20 const char* nick, int parc, char* parv[]);
21 extern void send_umode_out(struct Client* cptr, struct Client* sptr,
22 - struct Flags* old, int prop);
23 + struct Flags* old, int prop, int alreadyh);
24 extern int whisper(struct Client* source, const char* nick,
25 const char* channel, const char* text, int is_notice);
26 extern void send_user_info(struct Client* to, char* names, int rpl,
28 extern struct Client* next_client(struct Client* next, const char* ch);
29 extern char *umode_str(struct Client *cptr, int type);
30 extern void send_umode(struct Client *cptr, struct Client *sptr,
31 - struct Flags *old, int sendset, int opernames);
32 + struct Flags *old, int sendset, int opernames, int alreadyh);
33 extern void set_snomask(struct Client *, unsigned int, int);
34 extern int is_snomask(char *);
35 extern int check_target_limit(struct Client *sptr, void *target, const char *name,
36 diff -r 4c7b03099b6f ircd/m_oper.c
41 set_snomask(sptr, SNO_OPERDEFAULT, SNO_ADD);
42 cli_max_sendq(sptr) = 0; /* Get the sendq from the oper's class */
43 - send_umode_out(cptr, sptr, &old_mode, HasPriv(sptr, PRIV_PROPAGATE));
44 + send_umode_out(cptr, sptr, &old_mode, HasPriv(sptr, PRIV_PROPAGATE), 0);
45 send_reply(sptr, RPL_YOUREOPER);
47 sendto_opmask_butone(0, SNO_OLDSNO, "%s (%s@%s) is now operator (%c)",
48 diff -r 4c7b03099b6f ircd/m_sethost.c
49 --- a/ircd/m_sethost.c
50 +++ b/ircd/m_sethost.c
53 int m_sethost(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
56 char hostmask[USERLEN + HOSTLEN + 2];
57 char curhostmask[USERLEN + HOSTLEN + 2];
59 struct Flags setflags;
61 + /* user already +h, save */
62 + if (IsSetHost(sptr))
65 /* Back up the flags first */
66 setflags = cli_flags(sptr);
72 - send_umode_out(cptr, sptr, &setflags, 0);
73 + send_umode_out(cptr, sptr, &setflags, 0, alreadyh);
79 int ms_sethost(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
82 struct Client *target;
83 char hostmask[USERLEN + HOSTLEN + 2];
84 struct Membership *chan;
89 + /* target already +h, save */
90 + if (IsSetHost(target))
93 /* Back up the flags first */
94 setflags = cli_flags(target);
95 FlagClr(&setflags, FLAG_SETHOST);
100 - send_umode_out(target, target, &setflags, 0);
101 + send_umode_out(target, target, &setflags, 0, alreadyh);
104 diff -r 4c7b03099b6f ircd/s_user.c
109 FlagClr(&flags, FLAG_ACCOUNT);
110 client_set_privs(sptr, NULL);
111 - send_umode(cptr, sptr, &flags, ALL_UMODES, 0);
112 + send_umode(cptr, sptr, &flags, ALL_UMODES, 0, 0);
113 if ((cli_snomask(sptr) != SNO_DEFAULT) && HasFlag(sptr, FLAG_SERVNOTICE))
114 send_reply(sptr, RPL_SNOMASK, cli_snomask(sptr), cli_snomask(sptr));
116 @@ -880,14 +880,15 @@
117 * @param[in] sptr Client who sent us the mode change message.
118 * @param[in] old Prior set of user flags.
119 * @param[in] prop If non-zero, also include FLAG_OPER.
120 + * @param[in] alreadyh Client is already +h, do not show +h change
122 void send_umode_out(struct Client *cptr, struct Client *sptr,
123 - struct Flags *old, int prop)
124 + struct Flags *old, int prop, int alreadyh)
127 struct Client *acptr;
129 - send_umode(NULL, sptr, old, prop ? SEND_UMODES : SEND_UMODES_BUT_OPER, 0);
130 + send_umode(NULL, sptr, old, prop ? SEND_UMODES : SEND_UMODES_BUT_OPER, 0, 0);
132 for (i = HighestFd; i >= 0; i--)
135 sendcmdto_one(sptr, CMD_MODE, acptr, "%s %s", cli_name(sptr), umodeBuf);
138 - send_umode(NULL, sptr, old, prop ? SEND_UMODES : SEND_UMODES_BUT_OPER, 1);
139 + send_umode(NULL, sptr, old, prop ? SEND_UMODES : SEND_UMODES_BUT_OPER, 1, 0);
141 for (i = HighestFd; i >= 0; i--)
146 if (cptr && MyUser(cptr))
147 - send_umode(cptr, sptr, old, ALL_UMODES, 0);
148 + send_umode(cptr, sptr, old, ALL_UMODES, 0, alreadyh);
152 @@ -1212,6 +1213,7 @@
154 int do_host_hiding = 0;
159 char* account = NULL;
160 @@ -1226,8 +1228,7 @@
161 for (i = 0; i < USERMODELIST_SIZE; i++)
163 if (HasFlag(sptr, userModeList[i].flag) &&
164 - ((userModeList[i].flag != FLAG_ACCOUNT) &&
165 - (userModeList[i].flag != FLAG_SETHOST)))
166 + userModeList[i].flag != FLAG_ACCOUNT)
167 *m++ = userModeList[i].c;
170 @@ -1239,6 +1240,9 @@
174 + if (IsSetHost(sptr))
178 * find flags already set for user
179 * why not just copy them?
180 @@ -1569,7 +1573,7 @@
182 assert(UserStats.opers <= UserStats.clients + UserStats.unknowns);
183 assert(UserStats.inv_clients <= UserStats.clients + UserStats.unknowns);
184 - send_umode_out(cptr, sptr, &setflags, prop);
185 + send_umode_out(cptr, sptr, &setflags, prop, alreadyh);
189 @@ -1644,9 +1648,11 @@
190 * @param[in] old Pre-change set of modes for \a sptr.
191 * @param[in] sendset One of ALL_UMODES, SEND_UMODES_BUT_OPER,
192 * SEND_UMODES, to select which changed user modes to send.
193 + * @param[in] opernames Include opername parameter.
194 + * @param[in] alreadyh Client already has +h set, do not show +h change.
196 void send_umode(struct Client *cptr, struct Client *sptr, struct Flags *old,
197 - int sendset, int opernames)
198 + int sendset, int opernames, int alreadyh)
202 @@ -1689,12 +1695,15 @@
204 /* Special case for SETHOST.. */
205 if (flag == FLAG_SETHOST) {
206 - /* Don't send to users */
207 - if (cptr && MyUser(cptr))
210 - /* If we're setting +h, add the parameter later */
211 - if (!FlagHas(old, flag))
213 + /* do not show +h if client already had it */
214 + if (cptr && MyUser(cptr) && IsSetHost(cptr) && alreadyh)
217 + /* If we're setting +h, add the parameter later,
218 + * but not when showing to the user
220 + if (!FlagHas(old, flag) && (!cptr || !MyUser(cptr)))
223 if (FlagHas(old, flag))