]> jfr.im git - irc/quakenet/snircd-patchqueue.git/blob - showumodehtoclients.patch
opernotify: do check user was indeed a local oper when -o or -O is set, use cli_sockh...
[irc/quakenet/snircd-patchqueue.git] / showumodehtoclients.patch
1 show usermode +h to clients (/mode +h spoof .. and /mode -h is allowed by clients)
2
3 diff -r 4c7b03099b6f include/client.h
4 --- a/include/client.h
5 +++ b/include/client.h
6 @@ -90,7 +90,7 @@
7 #define FlagClr(set,flag) ((set)->bits[FLAGSET_INDEX(flag)] &= ~FLAGSET_MASK(flag))
8
9 /** String containing valid user modes, in no particular order. */
10 -#define infousermodes "dioOswkgxRXInPq"
11 +#define infousermodes "dioOswkghxRXInPq"
12
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
18 @@ -79,7 +79,7 @@
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,
27 @@ -102,7 +102,7 @@
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
37 --- a/ircd/m_oper.c
38 +++ b/ircd/m_oper.c
39 @@ -189,7 +189,7 @@
40
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);
46
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
51 @@ -114,11 +114,16 @@
52 */
53 int m_sethost(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
54 {
55 + int alreadyh = 0;
56 char hostmask[USERLEN + HOSTLEN + 2];
57 char curhostmask[USERLEN + HOSTLEN + 2];
58
59 struct Flags setflags;
60
61 + /* user already +h, save */
62 + if (IsSetHost(sptr))
63 + alreadyh = 1;
64 +
65 /* Back up the flags first */
66 setflags = cli_flags(sptr);
67
68 @@ -161,7 +166,7 @@
69 }
70 }
71
72 - send_umode_out(cptr, sptr, &setflags, 0);
73 + send_umode_out(cptr, sptr, &setflags, 0, alreadyh);
74 return 0;
75 }
76
77 @@ -176,6 +181,7 @@
78 */
79 int ms_sethost(struct Client* cptr, struct Client* sptr, int parc, char* parv[])
80 {
81 + int alreadyh = 0;
82 struct Client *target;
83 char hostmask[USERLEN + HOSTLEN + 2];
84 struct Membership *chan;
85 @@ -204,6 +210,10 @@
86 return 0;
87 }
88
89 + /* target already +h, save */
90 + if (IsSetHost(target))
91 + alreadyh = 1;
92 +
93 /* Back up the flags first */
94 setflags = cli_flags(target);
95 FlagClr(&setflags, FLAG_SETHOST);
96 @@ -256,6 +266,6 @@
97 }
98 }
99
100 - send_umode_out(target, target, &setflags, 0);
101 + send_umode_out(target, target, &setflags, 0, alreadyh);
102 return 0;
103 }
104 diff -r 4c7b03099b6f ircd/s_user.c
105 --- a/ircd/s_user.c
106 +++ b/ircd/s_user.c
107 @@ -521,7 +521,7 @@
108 else
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));
115 }
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
121 */
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)
125 {
126 int i;
127 struct Client *acptr;
128
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);
131
132 for (i = HighestFd; i >= 0; i--)
133 {
134 @@ -896,7 +897,7 @@
135 sendcmdto_one(sptr, CMD_MODE, acptr, "%s %s", cli_name(sptr), umodeBuf);
136 }
137
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);
140
141 for (i = HighestFd; i >= 0; i--)
142 {
143 @@ -906,7 +907,7 @@
144 }
145
146 if (cptr && MyUser(cptr))
147 - send_umode(cptr, sptr, old, ALL_UMODES, 0);
148 + send_umode(cptr, sptr, old, ALL_UMODES, 0, alreadyh);
149 }
150
151
152 @@ -1212,6 +1213,7 @@
153 int prop = 0;
154 int do_host_hiding = 0;
155 int do_set_host = 0;
156 + int alreadyh = 0;
157 size_t opernamelen;
158 char *opername = 0;
159 char* account = NULL;
160 @@ -1226,8 +1228,7 @@
161 for (i = 0; i < USERMODELIST_SIZE; i++)
162 {
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;
168 }
169 *m = '\0';
170 @@ -1239,6 +1240,9 @@
171 return 0;
172 }
173
174 + if (IsSetHost(sptr))
175 + alreadyh = 1;
176 +
177 /*
178 * find flags already set for user
179 * why not just copy them?
180 @@ -1569,7 +1573,7 @@
181 }
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);
186 }
187
188 return 0;
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.
195 */
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)
199 {
200 int i;
201 int flag;
202 @@ -1689,12 +1695,15 @@
203 }
204 /* Special case for SETHOST.. */
205 if (flag == FLAG_SETHOST) {
206 - /* Don't send to users */
207 - if (cptr && MyUser(cptr))
208 - continue;
209 -
210 - /* If we're setting +h, add the parameter later */
211 - if (!FlagHas(old, flag))
212 +
213 + /* do not show +h if client already had it */
214 + if (cptr && MyUser(cptr) && IsSetHost(cptr) && alreadyh)
215 + continue;
216 +
217 + /* If we're setting +h, add the parameter later,
218 + * but not when showing to the user
219 + */
220 + if (!FlagHas(old, flag) && (!cptr || !MyUser(cptr)))
221 needhost++;
222 }
223 if (FlagHas(old, flag))