1 |
|
/* |
2 |
< |
* ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd). |
3 |
< |
* s_user.c: User related functions. |
2 |
> |
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
|
* |
4 |
< |
* Copyright (C) 2002 by the past and present ircd coders, and others. |
4 |
> |
* Copyright (c) 1997-2014 ircd-hybrid development team |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
17 |
|
* along with this program; if not, write to the Free Software |
18 |
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
19 |
|
* USA |
20 |
< |
* |
21 |
< |
* $Id$ |
20 |
> |
*/ |
21 |
> |
|
22 |
> |
/*! \file s_user.c |
23 |
> |
* \brief User related functions. |
24 |
> |
* \version $Id$ |
25 |
|
*/ |
26 |
|
|
27 |
|
#include "stdinc.h" |
31 |
|
#include "channel.h" |
32 |
|
#include "channel_mode.h" |
33 |
|
#include "client.h" |
32 |
– |
#include "common.h" |
33 |
– |
#include "fdlist.h" |
34 |
|
#include "hash.h" |
35 |
|
#include "irc_string.h" |
36 |
– |
#include "sprintf_irc.h" |
37 |
– |
#include "s_bsd.h" |
36 |
|
#include "ircd.h" |
37 |
|
#include "listener.h" |
38 |
|
#include "motd.h" |
39 |
|
#include "numeric.h" |
40 |
< |
#include "s_conf.h" |
41 |
< |
#include "s_log.h" |
40 |
> |
#include "conf.h" |
41 |
> |
#include "log.h" |
42 |
|
#include "s_serv.h" |
43 |
|
#include "send.h" |
44 |
|
#include "supported.h" |
47 |
– |
#include "whowas.h" |
45 |
|
#include "memory.h" |
46 |
|
#include "packet.h" |
47 |
|
#include "rng_mt.h" |
48 |
|
#include "userhost.h" |
52 |
– |
#include "hook.h" |
49 |
|
#include "s_misc.h" |
50 |
< |
#include "msg.h" |
50 |
> |
#include "parse.h" |
51 |
|
#include "watch.h" |
52 |
|
|
57 |
– |
|
58 |
– |
struct Callback *entering_umode_cb = NULL; |
59 |
– |
struct Callback *umode_cb = NULL; |
60 |
– |
|
53 |
|
static char umode_buffer[IRCD_BUFSIZE]; |
62 |
– |
|
63 |
– |
static void user_welcome(struct Client *); |
64 |
– |
static void report_and_set_user_flags(struct Client *, const struct AccessItem *); |
65 |
– |
static int check_xline(struct Client *); |
66 |
– |
static void introduce_client(struct Client *); |
54 |
|
static const char *uid_get(void); |
55 |
|
|
56 |
|
/* Used for building up the isupport string, |
57 |
|
* used with init_isupport, add_isupport, delete_isupport |
58 |
|
*/ |
59 |
< |
|
73 |
< |
struct Isupport |
59 |
> |
struct Isupport |
60 |
|
{ |
61 |
|
dlink_node node; |
62 |
|
char *name; |
64 |
|
int number; |
65 |
|
}; |
66 |
|
|
67 |
< |
static dlink_list support_list = { NULL, NULL, 0 }; |
68 |
< |
MessageFile *isupportFile; |
67 |
> |
static dlink_list support_list; |
68 |
> |
static dlink_list support_list_lines; |
69 |
|
|
70 |
|
/* memory is cheap. map 0-255 to equivalent mode */ |
71 |
< |
unsigned int user_modes[256] = |
71 |
> |
const unsigned int user_modes[256] = |
72 |
|
{ |
73 |
|
/* 0x00 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x0F */ |
74 |
|
/* 0x10 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x1F */ |
77 |
|
0, /* @ */ |
78 |
|
0, /* A */ |
79 |
|
0, /* B */ |
80 |
< |
UMODE_CCONN_FULL, /* C */ |
80 |
> |
0, /* C */ |
81 |
|
UMODE_DEAF, /* D */ |
82 |
|
0, /* E */ |
83 |
< |
0, /* F */ |
83 |
> |
UMODE_FARCONNECT, /* F */ |
84 |
|
UMODE_SOFTCALLERID, /* G */ |
85 |
< |
0, /* H */ |
85 |
> |
UMODE_HIDDEN, /* H */ |
86 |
|
0, /* I */ |
87 |
|
0, /* J */ |
88 |
|
0, /* K */ |
93 |
|
0, /* P */ |
94 |
|
0, /* Q */ |
95 |
|
UMODE_REGONLY, /* R */ |
96 |
< |
0, /* S */ |
96 |
> |
UMODE_SSL, /* S */ |
97 |
|
0, /* T */ |
98 |
|
0, /* U */ |
99 |
|
0, /* V */ |
100 |
< |
0, /* W */ |
100 |
> |
UMODE_WEBIRC, /* W */ |
101 |
|
0, /* X */ |
102 |
|
0, /* Y */ |
103 |
|
0, /* Z 0x5A */ |
104 |
< |
0, 0, 0, 0, 0, /* 0x5F */ |
104 |
> |
0, 0, 0, 0, 0, /* 0x5F */ |
105 |
|
0, /* 0x60 */ |
106 |
|
UMODE_ADMIN, /* a */ |
107 |
|
UMODE_BOTS, /* b */ |
108 |
|
UMODE_CCONN, /* c */ |
109 |
|
UMODE_DEBUG, /* d */ |
110 |
< |
0, /* e */ |
110 |
> |
UMODE_EXTERNAL, /* e */ |
111 |
|
UMODE_FULL, /* f */ |
112 |
|
UMODE_CALLERID, /* g */ |
113 |
|
0, /* h */ |
126 |
|
UMODE_UNAUTH, /* u */ |
127 |
|
0, /* v */ |
128 |
|
UMODE_WALLOP, /* w */ |
129 |
< |
UMODE_EXTERNAL, /* x */ |
129 |
> |
UMODE_HIDDENHOST, /* x */ |
130 |
|
UMODE_SPY, /* y */ |
131 |
|
UMODE_OPERWALL, /* z 0x7A */ |
132 |
|
0,0,0,0,0, /* 0x7B - 0x7F */ |
161 |
|
* side effects - display to client user counts etc. |
162 |
|
*/ |
163 |
|
void |
164 |
< |
show_lusers(struct Client *source_p) |
164 |
> |
show_lusers(struct Client *source_p) |
165 |
|
{ |
166 |
< |
const char *from, *to; |
167 |
< |
|
168 |
< |
if (!MyConnect(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p)) |
183 |
< |
{ |
184 |
< |
from = me.id; |
185 |
< |
to = source_p->id; |
186 |
< |
} |
187 |
< |
else |
188 |
< |
{ |
189 |
< |
from = me.name; |
190 |
< |
to = source_p->name; |
191 |
< |
} |
192 |
< |
|
193 |
< |
if (!ConfigServerHide.hide_servers || IsOper(source_p)) |
194 |
< |
sendto_one(source_p, form_str(RPL_LUSERCLIENT), |
195 |
< |
from, to, (Count.total-Count.invisi), |
196 |
< |
Count.invisi, dlink_list_length(&global_serv_list)); |
166 |
> |
if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER)) |
167 |
> |
sendto_one_numeric(source_p, &me, RPL_LUSERCLIENT, (Count.total-Count.invisi), |
168 |
> |
Count.invisi, dlink_list_length(&global_serv_list)); |
169 |
|
else |
170 |
< |
sendto_one(source_p, form_str(RPL_LUSERCLIENT), from, to, |
171 |
< |
(Count.total-Count.invisi), Count.invisi, 1); |
170 |
> |
sendto_one_numeric(source_p, &me, RPL_LUSERCLIENT, |
171 |
> |
(Count.total-Count.invisi), Count.invisi, 1); |
172 |
|
|
173 |
|
if (Count.oper > 0) |
174 |
< |
sendto_one(source_p, form_str(RPL_LUSEROP), |
203 |
< |
from, to, Count.oper); |
174 |
> |
sendto_one_numeric(source_p, &me, RPL_LUSEROP, Count.oper); |
175 |
|
|
176 |
|
if (dlink_list_length(&unknown_list) > 0) |
177 |
< |
sendto_one(source_p, form_str(RPL_LUSERUNKNOWN), |
207 |
< |
from, to, dlink_list_length(&unknown_list)); |
177 |
> |
sendto_one_numeric(source_p, &me, RPL_LUSERUNKNOWN, dlink_list_length(&unknown_list)); |
178 |
|
|
179 |
|
if (dlink_list_length(&global_channel_list) > 0) |
180 |
< |
sendto_one(source_p, form_str(RPL_LUSERCHANNELS), |
211 |
< |
from, to, dlink_list_length(&global_channel_list)); |
180 |
> |
sendto_one_numeric(source_p, &me, RPL_LUSERCHANNELS, dlink_list_length(&global_channel_list)); |
181 |
|
|
182 |
< |
if (!ConfigServerHide.hide_servers || IsOper(source_p)) |
182 |
> |
if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER)) |
183 |
|
{ |
184 |
< |
sendto_one(source_p, form_str(RPL_LUSERME), |
185 |
< |
from, to, Count.local, Count.myserver); |
217 |
< |
sendto_one(source_p, form_str(RPL_LOCALUSERS), |
218 |
< |
from, to, Count.local, Count.max_loc, |
219 |
< |
Count.local, Count.max_loc); |
184 |
> |
sendto_one_numeric(source_p, &me, RPL_LUSERME, Count.local, Count.myserver); |
185 |
> |
sendto_one_numeric(source_p, &me, RPL_LOCALUSERS, Count.local, Count.max_loc); |
186 |
|
} |
187 |
|
else |
188 |
|
{ |
189 |
< |
sendto_one(source_p, form_str(RPL_LUSERME), |
190 |
< |
from, to, Count.total, 0); |
225 |
< |
sendto_one(source_p, form_str(RPL_LOCALUSERS), |
226 |
< |
from, to, Count.total, Count.max_tot, |
227 |
< |
Count.total, Count.max_tot); |
189 |
> |
sendto_one_numeric(source_p, &me, RPL_LUSERME, Count.total, 0); |
190 |
> |
sendto_one_numeric(source_p, &me, RPL_LOCALUSERS, Count.total, Count.max_tot); |
191 |
|
} |
192 |
|
|
193 |
< |
sendto_one(source_p, form_str(RPL_GLOBALUSERS), |
194 |
< |
from, to, Count.total, Count.max_tot, |
195 |
< |
Count.total, Count.max_tot); |
196 |
< |
|
197 |
< |
if (!ConfigServerHide.hide_servers || IsOper(source_p)) |
235 |
< |
sendto_one(source_p, form_str(RPL_STATSCONN), from, to, |
236 |
< |
Count.max_loc_con, Count.max_loc_cli, Count.totalrestartcount); |
193 |
> |
sendto_one_numeric(source_p, &me, RPL_GLOBALUSERS, Count.total, Count.max_tot); |
194 |
> |
|
195 |
> |
if (!ConfigServerHide.hide_servers || HasUMode(source_p, UMODE_OPER)) |
196 |
> |
sendto_one_numeric(source_p, &me, RPL_STATSCONN, Count.max_loc_con, |
197 |
> |
Count.max_loc_cli, Count.totalrestartcount); |
198 |
|
|
199 |
|
if (Count.local > Count.max_loc_cli) |
200 |
|
Count.max_loc_cli = Count.local; |
201 |
|
|
202 |
|
if ((Count.local + Count.myserver) > Count.max_loc_con) |
203 |
< |
Count.max_loc_con = Count.local + Count.myserver; |
203 |
> |
Count.max_loc_con = Count.local + Count.myserver; |
204 |
|
} |
205 |
|
|
206 |
|
/* show_isupport() |
210 |
|
* side effects - display to client what we support (for them) |
211 |
|
*/ |
212 |
|
void |
213 |
< |
show_isupport(struct Client *source_p) |
213 |
> |
show_isupport(struct Client *source_p) |
214 |
> |
{ |
215 |
> |
const dlink_node *ptr = NULL; |
216 |
> |
|
217 |
> |
DLINK_FOREACH(ptr, support_list_lines.head) |
218 |
> |
sendto_one_numeric(source_p, &me, RPL_ISUPPORT, ptr->data); |
219 |
> |
} |
220 |
> |
|
221 |
> |
|
222 |
> |
/* report_and_set_user_flags() |
223 |
> |
* |
224 |
> |
* inputs - pointer to source_p |
225 |
> |
* - pointer to conf for this user |
226 |
> |
* output - NONE |
227 |
> |
* side effects - Report to user any special flags |
228 |
> |
* they are getting, and set them. |
229 |
> |
*/ |
230 |
> |
static void |
231 |
> |
report_and_set_user_flags(struct Client *source_p, const struct MaskItem *conf) |
232 |
> |
{ |
233 |
> |
/* If this user is being spoofed, tell them so */ |
234 |
> |
if (IsConfDoSpoofIp(conf)) |
235 |
> |
sendto_one_notice(source_p, &me, ":*** Spoofing your IP. Congrats."); |
236 |
> |
|
237 |
> |
/* If this user is in the exception class, Set it "E lined" */ |
238 |
> |
if (IsConfExemptKline(conf)) |
239 |
> |
{ |
240 |
> |
SetExemptKline(source_p); |
241 |
> |
sendto_one_notice(source_p, &me, ":*** You are exempt from K/D/G lines. Congrats."); |
242 |
> |
} |
243 |
> |
|
244 |
> |
/* |
245 |
> |
* The else here is to make sure that G line exempt users |
246 |
> |
* do not get noticed twice. |
247 |
> |
*/ |
248 |
> |
else if (IsConfExemptGline(conf)) |
249 |
> |
{ |
250 |
> |
SetExemptGline(source_p); |
251 |
> |
sendto_one_notice(source_p, &me, ":*** You are exempt from G lines. Congrats."); |
252 |
> |
} |
253 |
> |
|
254 |
> |
if (IsConfExemptResv(conf)) |
255 |
> |
{ |
256 |
> |
SetExemptResv(source_p); |
257 |
> |
sendto_one_notice(source_p, &me, ":*** You are exempt from resvs. Congrats."); |
258 |
> |
} |
259 |
> |
|
260 |
> |
/* If this user is exempt from user limits set it "F lined" */ |
261 |
> |
if (IsConfExemptLimits(conf)) |
262 |
> |
{ |
263 |
> |
SetExemptLimits(source_p); |
264 |
> |
sendto_one_notice(source_p, &me, ":*** You are exempt from user limits. Congrats."); |
265 |
> |
} |
266 |
> |
|
267 |
> |
if (IsConfCanFlood(conf)) |
268 |
> |
{ |
269 |
> |
SetCanFlood(source_p); |
270 |
> |
sendto_one_notice(source_p, &me, ":*** You are exempt from flood " |
271 |
> |
"protection, aren't you fearsome."); |
272 |
> |
} |
273 |
> |
} |
274 |
> |
|
275 |
> |
/* introduce_client() |
276 |
> |
* |
277 |
> |
* inputs - source_p |
278 |
> |
* output - NONE |
279 |
> |
* side effects - This common function introduces a client to the rest |
280 |
> |
* of the net, either from a local client connect or |
281 |
> |
* from a remote connect. |
282 |
> |
*/ |
283 |
> |
static void |
284 |
> |
introduce_client(struct Client *source_p) |
285 |
> |
{ |
286 |
> |
dlink_node *ptr = NULL; |
287 |
> |
char ubuf[IRCD_BUFSIZE] = ""; |
288 |
> |
|
289 |
> |
if (MyClient(source_p)) |
290 |
> |
send_umode(source_p, source_p, 0, SEND_UMODES, ubuf); |
291 |
> |
else |
292 |
> |
send_umode(NULL, source_p, 0, SEND_UMODES, ubuf); |
293 |
> |
|
294 |
> |
watch_check_hash(source_p, RPL_LOGON); |
295 |
> |
|
296 |
> |
if (ubuf[0] == '\0') |
297 |
> |
{ |
298 |
> |
ubuf[0] = '+'; |
299 |
> |
ubuf[1] = '\0'; |
300 |
> |
} |
301 |
> |
|
302 |
> |
DLINK_FOREACH(ptr, serv_list.head) |
303 |
> |
{ |
304 |
> |
struct Client *server = ptr->data; |
305 |
> |
|
306 |
> |
if (server == source_p->from) |
307 |
> |
continue; |
308 |
> |
|
309 |
> |
if (IsCapable(server, CAP_SVS)) |
310 |
> |
sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s %s :%s", |
311 |
> |
source_p->servptr->id, |
312 |
> |
source_p->name, source_p->hopcount+1, |
313 |
> |
(unsigned long)source_p->tsinfo, |
314 |
> |
ubuf, source_p->username, source_p->host, |
315 |
> |
(MyClient(source_p) && IsIPSpoof(source_p)) ? |
316 |
> |
"0" : source_p->sockhost, source_p->id, |
317 |
> |
source_p->svid, |
318 |
> |
source_p->info); |
319 |
> |
else |
320 |
> |
sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s", |
321 |
> |
source_p->servptr->id, |
322 |
> |
source_p->name, source_p->hopcount+1, |
323 |
> |
(unsigned long)source_p->tsinfo, |
324 |
> |
ubuf, source_p->username, source_p->host, |
325 |
> |
(MyClient(source_p) && IsIPSpoof(source_p)) ? |
326 |
> |
"0" : source_p->sockhost, source_p->id, source_p->info); |
327 |
> |
|
328 |
> |
if (!EmptyString(source_p->certfp)) |
329 |
> |
sendto_one(server, ":%s CERTFP %s", source_p->id, source_p->certfp); |
330 |
> |
} |
331 |
> |
} |
332 |
> |
|
333 |
> |
/* user_welcome() |
334 |
> |
* |
335 |
> |
* inputs - client pointer to client to welcome |
336 |
> |
* output - NONE |
337 |
> |
* side effects - |
338 |
> |
*/ |
339 |
> |
static void |
340 |
> |
user_welcome(struct Client *source_p) |
341 |
|
{ |
342 |
< |
send_message_file(source_p, isupportFile); |
342 |
> |
#if defined(__TIME__) && defined(__DATE__) |
343 |
> |
static const char built_date[] = __DATE__ " at " __TIME__; |
344 |
> |
#else |
345 |
> |
static const char built_date[] = "unknown"; |
346 |
> |
#endif |
347 |
> |
|
348 |
> |
#ifdef HAVE_LIBCRYPTO |
349 |
> |
if (HasFlag(source_p, FLAGS_SSL)) |
350 |
> |
{ |
351 |
> |
AddUMode(source_p, UMODE_SSL); |
352 |
> |
sendto_one_notice(source_p, &me, ":*** Connected securely via %s", |
353 |
> |
ssl_get_cipher(source_p->localClient->fd.ssl)); |
354 |
> |
} |
355 |
> |
#endif |
356 |
> |
|
357 |
> |
sendto_one_numeric(source_p, &me, RPL_WELCOME, ServerInfo.network_name, |
358 |
> |
source_p->name); |
359 |
> |
sendto_one_numeric(source_p, &me, RPL_YOURHOST, |
360 |
> |
get_listener_name(source_p->localClient->listener), ircd_version); |
361 |
> |
sendto_one_numeric(source_p, &me, RPL_CREATED, built_date); |
362 |
> |
sendto_one_numeric(source_p, &me, RPL_MYINFO, me.name, ircd_version, umode_buffer); |
363 |
> |
show_isupport(source_p); |
364 |
> |
|
365 |
> |
if (source_p->id[0]) |
366 |
> |
sendto_one_numeric(source_p, &me, RPL_YOURID, source_p->id); |
367 |
> |
|
368 |
> |
show_lusers(source_p); |
369 |
> |
motd_signon(source_p); |
370 |
> |
} |
371 |
> |
|
372 |
> |
/* check_xline() |
373 |
> |
* |
374 |
> |
* inputs - pointer to client to test |
375 |
> |
* outupt - 1 if exiting 0 if ok |
376 |
> |
* side effects - |
377 |
> |
*/ |
378 |
> |
static int |
379 |
> |
check_xline(struct Client *source_p) |
380 |
> |
{ |
381 |
> |
struct MaskItem *conf = NULL; |
382 |
> |
const char *reason = NULL; |
383 |
> |
|
384 |
> |
if ((conf = find_matching_name_conf(CONF_XLINE, source_p->info, NULL, NULL, 0))) |
385 |
> |
{ |
386 |
> |
++conf->count; |
387 |
> |
|
388 |
> |
if (conf->reason) |
389 |
> |
reason = conf->reason; |
390 |
> |
else |
391 |
> |
reason = CONF_NOREASON; |
392 |
> |
|
393 |
> |
sendto_realops_flags(UMODE_REJ, L_ALL, SEND_NOTICE, |
394 |
> |
"X-line Rejecting [%s] [%s], user %s [%s]", |
395 |
> |
source_p->info, reason, |
396 |
> |
get_client_name(source_p, HIDE_IP), |
397 |
> |
source_p->sockhost); |
398 |
> |
|
399 |
> |
++ServerStats.is_ref; |
400 |
> |
exit_client(source_p, "Bad user info"); |
401 |
> |
return 1; |
402 |
> |
} |
403 |
> |
|
404 |
> |
return 0; |
405 |
|
} |
406 |
|
|
407 |
|
/* |
431 |
|
register_local_user(struct Client *source_p) |
432 |
|
{ |
433 |
|
const char *id = NULL; |
434 |
< |
const struct AccessItem *aconf = NULL; |
285 |
< |
dlink_node *ptr = NULL; |
434 |
> |
const struct MaskItem *conf = NULL; |
435 |
|
|
287 |
– |
assert(source_p != NULL); |
436 |
|
assert(source_p == source_p->from); |
437 |
|
assert(MyConnect(source_p)); |
438 |
|
assert(!source_p->localClient->registration); |
441 |
|
|
442 |
|
if (ConfigFileEntry.ping_cookie) |
443 |
|
{ |
444 |
< |
if (!IsPingSent(source_p) && source_p->localClient->random_ping == 0) |
444 |
> |
if (!IsPingSent(source_p) && !source_p->localClient->random_ping) |
445 |
|
{ |
446 |
|
do |
447 |
|
source_p->localClient->random_ping = genrand_int32(); |
461 |
|
/* Straight up the maximum rate of flooding... */ |
462 |
|
source_p->localClient->allow_read = MAX_FLOOD_BURST; |
463 |
|
|
464 |
< |
if (!execute_callback(client_check_cb, source_p, source_p->username)) |
464 |
> |
if (!check_client(source_p)) |
465 |
|
return; |
466 |
|
|
467 |
< |
if (valid_hostname(source_p->host) == 0) |
467 |
> |
if (!valid_hostname(source_p->host)) |
468 |
|
{ |
469 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** Notice -- You have an illegal " |
470 |
< |
"character in your hostname", me.name, source_p->name); |
469 |
> |
sendto_one_notice(source_p, &me, ":*** Notice -- You have an illegal " |
470 |
> |
"character in your hostname"); |
471 |
|
strlcpy(source_p->host, source_p->sockhost, |
472 |
|
sizeof(source_p->host)); |
473 |
|
} |
474 |
|
|
475 |
< |
ptr = source_p->localClient->confs.head; |
328 |
< |
aconf = map_to_conf(ptr->data); |
475 |
> |
conf = source_p->localClient->confs.head->data; |
476 |
|
|
477 |
|
if (!IsGotId(source_p)) |
478 |
|
{ |
479 |
< |
char username[USERLEN + 1]; |
479 |
> |
char username[USERLEN + 1] = ""; |
480 |
|
const char *p = username; |
481 |
|
unsigned int i = 0; |
482 |
|
|
483 |
< |
if (IsNeedIdentd(aconf)) |
483 |
> |
if (IsNeedIdentd(conf)) |
484 |
|
{ |
485 |
|
++ServerStats.is_ref; |
486 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** Notice -- You need to install " |
487 |
< |
"identd to use this server", me.name, source_p->name); |
488 |
< |
exit_client(source_p, &me, "Install identd"); |
486 |
> |
sendto_one_notice(source_p, &me, ":*** Notice -- You need to install " |
487 |
> |
"identd to use this server"); |
488 |
> |
exit_client(source_p, "Install identd"); |
489 |
|
return; |
490 |
|
} |
491 |
|
|
492 |
|
strlcpy(username, source_p->username, sizeof(username)); |
493 |
|
|
494 |
< |
if (!IsNoTilde(aconf)) |
494 |
> |
if (!IsNoTilde(conf)) |
495 |
|
source_p->username[i++] = '~'; |
496 |
|
|
497 |
|
for (; *p && i < USERLEN; ++p) |
502 |
|
} |
503 |
|
|
504 |
|
/* password check */ |
505 |
< |
if (!EmptyString(aconf->passwd)) |
505 |
> |
if (!EmptyString(conf->passwd)) |
506 |
|
{ |
507 |
|
const char *pass = source_p->localClient->passwd; |
508 |
|
|
509 |
< |
if (!match_conf_password(pass, aconf)) |
509 |
> |
if (!match_conf_password(pass, conf)) |
510 |
|
{ |
511 |
|
++ServerStats.is_ref; |
512 |
< |
sendto_one(source_p, form_str(ERR_PASSWDMISMATCH), |
513 |
< |
me.name, source_p->name); |
514 |
< |
exit_client(source_p, &me, "Bad Password"); |
512 |
> |
|
513 |
> |
sendto_one_numeric(source_p, &me, ERR_PASSWDMISMATCH); |
514 |
> |
exit_client(source_p, "Bad Password"); |
515 |
|
return; |
516 |
|
} |
517 |
|
} |
522 |
|
*/ |
523 |
|
|
524 |
|
/* report if user has &^>= etc. and set flags as needed in source_p */ |
525 |
< |
report_and_set_user_flags(source_p, aconf); |
525 |
> |
report_and_set_user_flags(source_p, conf); |
526 |
|
|
527 |
|
if (IsDead(source_p)) |
528 |
|
return; |
538 |
|
if ((Count.local >= ServerInfo.max_clients + MAX_BUFFER) || |
539 |
|
(Count.local >= ServerInfo.max_clients && !IsExemptLimits(source_p))) |
540 |
|
{ |
541 |
< |
sendto_realops_flags(UMODE_FULL, L_ALL, |
541 |
> |
sendto_realops_flags(UMODE_FULL, L_ALL, SEND_NOTICE, |
542 |
|
"Too many clients, rejecting %s[%s].", |
543 |
|
source_p->name, source_p->host); |
544 |
|
++ServerStats.is_ref; |
545 |
< |
exit_client(source_p, &me, "Sorry, server is full - try later"); |
545 |
> |
exit_client(source_p, "Sorry, server is full - try later"); |
546 |
|
return; |
547 |
|
} |
548 |
|
|
549 |
|
/* valid user name check */ |
550 |
< |
if (valid_username(source_p->username) == 0) |
550 |
> |
if (!valid_username(source_p->username, 1)) |
551 |
|
{ |
552 |
< |
char tmpstr2[IRCD_BUFSIZE]; |
552 |
> |
char tmpstr2[IRCD_BUFSIZE] = ""; |
553 |
|
|
554 |
< |
sendto_realops_flags(UMODE_REJ, L_ALL, "Invalid username: %s (%s@%s)", |
554 |
> |
sendto_realops_flags(UMODE_REJ, L_ALL, SEND_NOTICE, |
555 |
> |
"Invalid username: %s (%s@%s)", |
556 |
|
source_p->name, source_p->username, source_p->host); |
557 |
|
++ServerStats.is_ref; |
558 |
|
snprintf(tmpstr2, sizeof(tmpstr2), "Invalid username [%s]", |
559 |
|
source_p->username); |
560 |
< |
exit_client(source_p, &me, tmpstr2); |
560 |
> |
exit_client(source_p, tmpstr2); |
561 |
|
return; |
562 |
|
} |
563 |
|
|
564 |
|
if (check_xline(source_p)) |
565 |
|
return; |
566 |
|
|
567 |
< |
while (hash_find_id((id = uid_get())) != NULL) |
567 |
> |
while (hash_find_id((id = uid_get()))) |
568 |
|
; |
569 |
|
|
570 |
|
strlcpy(source_p->id, id, sizeof(source_p->id)); |
571 |
|
hash_add_id(source_p); |
572 |
|
|
573 |
< |
sendto_realops_flags(UMODE_CCONN, L_ALL, |
573 |
> |
sendto_realops_flags(UMODE_CCONN, L_ALL, SEND_NOTICE, |
574 |
|
"Client connecting: %s (%s@%s) [%s] {%s} [%s] <%s>", |
575 |
|
source_p->name, source_p->username, source_p->host, |
576 |
|
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
577 |
|
"255.255.255.255" : source_p->sockhost, |
578 |
< |
get_client_class(source_p), |
578 |
> |
get_client_class(&source_p->localClient->confs), |
579 |
|
source_p->info, source_p->id); |
580 |
|
|
433 |
– |
sendto_realops_flags(UMODE_CCONN_FULL, L_ALL, |
434 |
– |
"CLICONN %s %s %s %s %s %s %s 0 %s", |
435 |
– |
source_p->name, source_p->username, source_p->host, |
436 |
– |
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
437 |
– |
"255.255.255.255" : source_p->sockhost, |
438 |
– |
get_client_class(source_p), |
439 |
– |
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
440 |
– |
"<hidden>" : source_p->localClient->client_host, |
441 |
– |
ConfigFileEntry.hide_spoof_ips && IsIPSpoof(source_p) ? |
442 |
– |
"<hidden>" : source_p->localClient->client_server, |
443 |
– |
source_p->info); |
444 |
– |
|
445 |
– |
|
581 |
|
if (ConfigFileEntry.invisible_on_connect) |
582 |
|
{ |
583 |
< |
source_p->umodes |= UMODE_INVISIBLE; |
583 |
> |
AddUMode(source_p, UMODE_INVISIBLE); |
584 |
|
++Count.invisi; |
585 |
|
} |
586 |
|
|
587 |
< |
if ((++Count.local) > Count.max_loc) |
587 |
> |
if (++Count.local > Count.max_loc) |
588 |
|
{ |
589 |
|
Count.max_loc = Count.local; |
590 |
|
|
591 |
|
if (!(Count.max_loc % 10)) |
592 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, "New Max Local Clients: %d", |
592 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
593 |
> |
"New Max Local Clients: %d", |
594 |
|
Count.max_loc); |
595 |
|
} |
596 |
|
|
623 |
|
* - username to register as |
624 |
|
* - host name to register as |
625 |
|
* - server name |
490 |
– |
* - realname (gecos) |
626 |
|
* output - NONE |
627 |
|
* side effects - This function is called when a remote client |
628 |
|
* is introduced by a server. |
629 |
|
*/ |
630 |
|
void |
631 |
< |
register_remote_user(struct Client *source_p, |
632 |
< |
const char *username, const char *host, const char *server, |
498 |
< |
const char *realname) |
631 |
> |
register_remote_user(struct Client *source_p, const char *username, |
632 |
> |
const char *host, const char *server) |
633 |
|
{ |
634 |
|
struct Client *target_p = NULL; |
635 |
|
|
502 |
– |
assert(source_p != NULL); |
636 |
|
assert(source_p->username != username); |
637 |
|
|
638 |
< |
strlcpy(source_p->host, host, sizeof(source_p->host)); |
638 |
> |
strlcpy(source_p->host, host, sizeof(source_p->host)); |
639 |
|
strlcpy(source_p->username, username, sizeof(source_p->username)); |
640 |
|
|
641 |
|
/* |
643 |
|
*/ |
644 |
|
source_p->servptr = hash_find_server(server); |
645 |
|
|
646 |
< |
/* Super GhostDetect: |
646 |
> |
/* |
647 |
> |
* Super GhostDetect: |
648 |
|
* If we can't find the server the user is supposed to be on, |
649 |
|
* then simply blow the user away. -Taner |
650 |
|
*/ |
651 |
|
if (source_p->servptr == NULL) |
652 |
|
{ |
653 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, |
653 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
654 |
|
"No server %s for user %s[%s@%s] from %s", |
655 |
|
server, source_p->name, source_p->username, |
656 |
|
source_p->host, source_p->from->name); |
657 |
< |
kill_client(source_p->from, source_p, "%s (Server doesn't exist)", me.name); |
657 |
> |
sendto_one(source_p->from, |
658 |
> |
":%s KILL %s :%s (Ghosted, server %s doesn't exist)", |
659 |
> |
me.id, source_p->id, me.name, server); |
660 |
|
|
661 |
< |
SetKilled(source_p); |
662 |
< |
exit_client(source_p, &me, "Ghosted Client"); |
661 |
> |
AddFlag(source_p, FLAGS_KILLED); |
662 |
> |
exit_client(source_p, "Ghosted Client"); |
663 |
|
return; |
664 |
|
} |
665 |
|
|
666 |
|
if ((target_p = source_p->servptr) && target_p->from != source_p->from) |
667 |
|
{ |
668 |
< |
sendto_realops_flags(UMODE_DEBUG, L_ALL, |
668 |
> |
sendto_realops_flags(UMODE_DEBUG, L_ALL, SEND_NOTICE, |
669 |
|
"Bad User [%s] :%s USER %s@%s %s, != %s[%s]", |
670 |
|
source_p->from->name, source_p->name, source_p->username, |
671 |
|
source_p->host, source_p->servptr->name, |
672 |
|
target_p->name, target_p->from->name); |
673 |
< |
kill_client(source_p->from, source_p, |
674 |
< |
"%s (NICK from wrong direction (%s != %s))", |
675 |
< |
me.name, source_p->servptr->name, target_p->from->name); |
676 |
< |
SetKilled(source_p); |
677 |
< |
exit_client(source_p, &me, "USER server wrong direction"); |
673 |
> |
sendto_one(source_p->from, |
674 |
> |
":%s KILL %s :%s (NICK from wrong direction (%s != %s))", |
675 |
> |
me.id, source_p->id, me.name, source_p->servptr->name, |
676 |
> |
target_p->from->name); |
677 |
> |
|
678 |
> |
AddFlag(source_p, FLAGS_KILLED); |
679 |
> |
exit_client(source_p, "USER server wrong direction"); |
680 |
|
return; |
681 |
|
} |
682 |
|
|
684 |
|
* If the nick has been introduced by a services server, |
685 |
|
* make it a service as well. |
686 |
|
*/ |
687 |
< |
if (IsService(source_p->servptr)) |
688 |
< |
SetService(source_p); |
687 |
> |
if (HasFlag(source_p->servptr, FLAGS_SERVICE)) |
688 |
> |
AddFlag(source_p, FLAGS_SERVICE); |
689 |
|
|
690 |
|
/* Increment our total user count here */ |
691 |
|
if (++Count.total > Count.max_tot) |
696 |
|
add_user_host(source_p->username, source_p->host, 1); |
697 |
|
SetUserHost(source_p); |
698 |
|
|
699 |
< |
introduce_client(source_p); |
700 |
< |
} |
699 |
> |
if (HasFlag(source_p->servptr, FLAGS_EOB)) |
700 |
> |
sendto_realops_flags(UMODE_FARCONNECT, L_ALL, SEND_NOTICE, |
701 |
> |
"Client connecting at %s: %s (%s@%s) [%s] <%s>", |
702 |
> |
source_p->servptr->name, |
703 |
> |
source_p->name, source_p->username, source_p->host, |
704 |
> |
source_p->info, source_p->id); |
705 |
|
|
706 |
< |
/* introduce_client() |
565 |
< |
* |
566 |
< |
* inputs - source_p |
567 |
< |
* output - NONE |
568 |
< |
* side effects - This common function introduces a client to the rest |
569 |
< |
* of the net, either from a local client connect or |
570 |
< |
* from a remote connect. |
571 |
< |
*/ |
572 |
< |
static void |
573 |
< |
introduce_client(struct Client *source_p) |
574 |
< |
{ |
575 |
< |
dlink_node *server_node = NULL; |
576 |
< |
static char ubuf[12]; |
577 |
< |
|
578 |
< |
if (MyClient(source_p)) |
579 |
< |
send_umode(source_p, source_p, 0, SEND_UMODES, ubuf); |
580 |
< |
else |
581 |
< |
send_umode(NULL, source_p, 0, SEND_UMODES, ubuf); |
582 |
< |
|
583 |
< |
watch_check_hash(source_p, RPL_LOGON); |
584 |
< |
|
585 |
< |
if (*ubuf == '\0') |
586 |
< |
{ |
587 |
< |
ubuf[0] = '+'; |
588 |
< |
ubuf[1] = '\0'; |
589 |
< |
} |
590 |
< |
|
591 |
< |
DLINK_FOREACH(server_node, serv_list.head) |
592 |
< |
{ |
593 |
< |
struct Client *server = server_node->data; |
594 |
< |
|
595 |
< |
if (server == source_p->from) |
596 |
< |
continue; |
597 |
< |
|
598 |
< |
if (IsCapable(server, CAP_TS6) && HasID(source_p)) |
599 |
< |
sendto_one(server, ":%s UID %s %d %lu %s %s %s %s %s :%s", |
600 |
< |
source_p->servptr->id, |
601 |
< |
source_p->name, source_p->hopcount+1, |
602 |
< |
(unsigned long)source_p->tsinfo, |
603 |
< |
ubuf, source_p->username, source_p->host, |
604 |
< |
(MyClient(source_p) && IsIPSpoof(source_p)) ? |
605 |
< |
"0" : source_p->sockhost, source_p->id, source_p->info); |
606 |
< |
else |
607 |
< |
sendto_one(server, "NICK %s %d %lu %s %s %s %s :%s", |
608 |
< |
source_p->name, source_p->hopcount+1, |
609 |
< |
(unsigned long)source_p->tsinfo, |
610 |
< |
ubuf, source_p->username, source_p->host, |
611 |
< |
source_p->servptr->name, source_p->info); |
612 |
< |
} |
706 |
> |
introduce_client(source_p); |
707 |
|
} |
708 |
|
|
709 |
|
/* valid_hostname() |
720 |
|
{ |
721 |
|
const char *p = hostname; |
722 |
|
|
723 |
< |
assert(p != NULL); |
723 |
> |
assert(p); |
724 |
|
|
725 |
< |
if (*p == '.' || *p == ':') |
725 |
> |
if (EmptyString(p) || *p == '.' || *p == ':') |
726 |
|
return 0; |
727 |
|
|
728 |
|
for (; *p; ++p) |
729 |
|
if (!IsHostChar(*p)) |
730 |
|
return 0; |
731 |
|
|
732 |
< |
return 1; |
732 |
> |
return p - hostname <= HOSTLEN; |
733 |
|
} |
734 |
|
|
735 |
|
/* valid_username() |
744 |
|
* style of username |
745 |
|
*/ |
746 |
|
int |
747 |
< |
valid_username(const char *username) |
747 |
> |
valid_username(const char *username, const int local) |
748 |
|
{ |
749 |
|
int dots = 0; |
750 |
|
const char *p = username; |
751 |
|
|
752 |
< |
assert(p != NULL); |
752 |
> |
assert(p); |
753 |
|
|
754 |
|
if (*p == '~') |
755 |
|
++p; |
756 |
|
|
757 |
< |
/* reject usernames that don't start with an alphanum |
757 |
> |
/* |
758 |
> |
* Reject usernames that don't start with an alphanum |
759 |
|
* i.e. reject jokers who have '-@somehost' or '.@somehost' |
760 |
|
* or "-hi-@somehost", "h-----@somehost" would still be accepted. |
761 |
|
*/ |
762 |
|
if (!IsAlNum(*p)) |
763 |
|
return 0; |
764 |
|
|
765 |
< |
while (*++p) |
765 |
> |
if (local) |
766 |
|
{ |
767 |
< |
if ((*p == '.') && ConfigFileEntry.dots_in_ident) |
767 |
> |
while (*++p) |
768 |
|
{ |
769 |
< |
if (++dots > ConfigFileEntry.dots_in_ident) |
770 |
< |
return 0; |
771 |
< |
if (!IsUserChar(*(p + 1))) |
769 |
> |
if ((*p == '.') && ConfigFileEntry.dots_in_ident) |
770 |
> |
{ |
771 |
> |
if (++dots > ConfigFileEntry.dots_in_ident) |
772 |
> |
return 0; |
773 |
> |
if (!IsUserChar(*(p + 1))) |
774 |
> |
return 0; |
775 |
> |
} |
776 |
> |
else if (!IsUserChar(*p)) |
777 |
|
return 0; |
778 |
|
} |
779 |
< |
else if (!IsUserChar(*p)) |
780 |
< |
return 0; |
779 |
> |
} |
780 |
> |
else |
781 |
> |
{ |
782 |
> |
while (*++p) |
783 |
> |
if (!IsUserChar(*p)) |
784 |
> |
return 0; |
785 |
|
} |
786 |
|
|
787 |
< |
return 1; |
787 |
> |
return p - username <= USERLEN;; |
788 |
|
} |
789 |
|
|
790 |
|
/* clean_nick_name() |
800 |
|
const char *p = nickname; |
801 |
|
assert(nickname && *nickname); |
802 |
|
|
803 |
+ |
assert(p); |
804 |
+ |
|
805 |
|
/* nicks can't start with a digit or - or be 0 length */ |
806 |
|
/* This closer duplicates behaviour of hybrid-6 */ |
807 |
|
if (*p == '-' || (IsDigit(*p) && local) || *p == '\0') |
811 |
|
if (!IsNickChar(*p)) |
812 |
|
return 0; |
813 |
|
|
814 |
< |
return p - nickname <= (NICKLEN - 1); |
709 |
< |
} |
710 |
< |
|
711 |
< |
/* report_and_set_user_flags() |
712 |
< |
* |
713 |
< |
* inputs - pointer to source_p |
714 |
< |
* - pointer to aconf for this user |
715 |
< |
* output - NONE |
716 |
< |
* side effects - Report to user any special flags |
717 |
< |
* they are getting, and set them. |
718 |
< |
*/ |
719 |
< |
static void |
720 |
< |
report_and_set_user_flags(struct Client *source_p, const struct AccessItem *aconf) |
721 |
< |
{ |
722 |
< |
/* If this user is being spoofed, tell them so */ |
723 |
< |
if (IsConfDoSpoofIp(aconf)) |
724 |
< |
{ |
725 |
< |
sendto_one(source_p, |
726 |
< |
":%s NOTICE %s :*** Spoofing your IP. congrats.", |
727 |
< |
me.name, source_p->name); |
728 |
< |
} |
729 |
< |
|
730 |
< |
/* If this user is in the exception class, Set it "E lined" */ |
731 |
< |
if (IsConfExemptKline(aconf)) |
732 |
< |
{ |
733 |
< |
SetExemptKline(source_p); |
734 |
< |
sendto_one(source_p, |
735 |
< |
":%s NOTICE %s :*** You are exempt from K/D/G lines. congrats.", |
736 |
< |
me.name, source_p->name); |
737 |
< |
} |
738 |
< |
|
739 |
< |
/* The else here is to make sure that G line exempt users |
740 |
< |
* do not get noticed twice. |
741 |
< |
*/ |
742 |
< |
else if (IsConfExemptGline(aconf)) |
743 |
< |
{ |
744 |
< |
SetExemptGline(source_p); |
745 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from G lines.", |
746 |
< |
me.name, source_p->name); |
747 |
< |
} |
748 |
< |
|
749 |
< |
if (IsConfExemptResv(aconf)) |
750 |
< |
{ |
751 |
< |
SetExemptResv(source_p); |
752 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from resvs.", |
753 |
< |
me.name, source_p->name); |
754 |
< |
} |
755 |
< |
|
756 |
< |
/* If this user is exempt from user limits set it "F lined" */ |
757 |
< |
if (IsConfExemptLimits(aconf)) |
758 |
< |
{ |
759 |
< |
SetExemptLimits(source_p); |
760 |
< |
sendto_one(source_p, |
761 |
< |
":%s NOTICE %s :*** You are exempt from user limits. congrats.", |
762 |
< |
me.name,source_p->name); |
763 |
< |
} |
764 |
< |
|
765 |
< |
if (IsConfCanFlood(aconf)) |
766 |
< |
{ |
767 |
< |
SetCanFlood(source_p); |
768 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** You are exempt from flood " |
769 |
< |
"protection, aren't you fearsome.", |
770 |
< |
me.name, source_p->name); |
771 |
< |
} |
772 |
< |
} |
773 |
< |
|
774 |
< |
/* change_simple_umode() |
775 |
< |
* |
776 |
< |
* this callback can be hooked to allow special handling of |
777 |
< |
* certain usermodes |
778 |
< |
*/ |
779 |
< |
static void * |
780 |
< |
change_simple_umode(va_list args) |
781 |
< |
{ |
782 |
< |
struct Client *client_p; |
783 |
< |
struct Client *source_p; |
784 |
< |
int what; |
785 |
< |
unsigned int flag; |
786 |
< |
|
787 |
< |
client_p = va_arg(args, struct Client *); |
788 |
< |
source_p = va_arg(args, struct Client *); |
789 |
< |
what = va_arg(args, int); |
790 |
< |
flag = va_arg(args, unsigned int); |
791 |
< |
|
792 |
< |
if (what == MODE_ADD) |
793 |
< |
source_p->umodes |= flag; |
794 |
< |
else |
795 |
< |
source_p->umodes &= ~flag; |
796 |
< |
|
797 |
< |
return NULL; |
798 |
< |
} |
799 |
< |
|
800 |
< |
/* set_user_mode() |
801 |
< |
* |
802 |
< |
* added 15/10/91 By Darren Reed. |
803 |
< |
* parv[0] - sender |
804 |
< |
* parv[1] - username to change mode for |
805 |
< |
* parv[2] - modes to change |
806 |
< |
*/ |
807 |
< |
void |
808 |
< |
set_user_mode(struct Client *client_p, struct Client *source_p, |
809 |
< |
int parc, char *parv[]) |
810 |
< |
{ |
811 |
< |
unsigned int flag, setflags; |
812 |
< |
char **p, *m, buf[IRCD_BUFSIZE]; |
813 |
< |
struct Client *target_p; |
814 |
< |
int what = MODE_ADD, badflag = 0, i; |
815 |
< |
|
816 |
< |
assert(!(parc < 2)); |
817 |
< |
|
818 |
< |
if ((target_p = find_person(client_p, parv[1])) == NULL) |
819 |
< |
{ |
820 |
< |
if (MyConnect(source_p)) |
821 |
< |
sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL), |
822 |
< |
me.name, source_p->name, parv[1]); |
823 |
< |
return; |
824 |
< |
} |
825 |
< |
|
826 |
< |
if (IsServer(source_p)) |
827 |
< |
{ |
828 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, "*** Mode for User %s from %s", |
829 |
< |
parv[1], source_p->name); |
830 |
< |
return; |
831 |
< |
} |
832 |
< |
|
833 |
< |
if (source_p != target_p) |
834 |
< |
{ |
835 |
< |
sendto_one(source_p, form_str(ERR_USERSDONTMATCH), |
836 |
< |
me.name, source_p->name); |
837 |
< |
return; |
838 |
< |
} |
839 |
< |
|
840 |
< |
if (parc < 3) |
841 |
< |
{ |
842 |
< |
m = buf; |
843 |
< |
*m++ = '+'; |
844 |
< |
|
845 |
< |
for (i = 0; i < 128; i++) |
846 |
< |
if (source_p->umodes & user_modes[i]) |
847 |
< |
*m++ = (char)i; |
848 |
< |
*m = '\0'; |
849 |
< |
|
850 |
< |
sendto_one(source_p, form_str(RPL_UMODEIS), |
851 |
< |
me.name, source_p->name, buf); |
852 |
< |
return; |
853 |
< |
} |
854 |
< |
|
855 |
< |
execute_callback(entering_umode_cb, client_p, source_p); |
856 |
< |
|
857 |
< |
/* find flags already set for user */ |
858 |
< |
setflags = source_p->umodes; |
859 |
< |
|
860 |
< |
/* parse mode change string(s) */ |
861 |
< |
for (p = &parv[2]; p && *p; p++) |
862 |
< |
{ |
863 |
< |
for (m = *p; *m; m++) |
864 |
< |
{ |
865 |
< |
switch (*m) |
866 |
< |
{ |
867 |
< |
case '+': |
868 |
< |
what = MODE_ADD; |
869 |
< |
break; |
870 |
< |
case '-': |
871 |
< |
what = MODE_DEL; |
872 |
< |
break; |
873 |
< |
case 'o': |
874 |
< |
if (what == MODE_ADD) |
875 |
< |
{ |
876 |
< |
if (IsServer(client_p) && !IsOper(source_p)) |
877 |
< |
{ |
878 |
< |
++Count.oper; |
879 |
< |
SetOper(source_p); |
880 |
< |
} |
881 |
< |
} |
882 |
< |
else |
883 |
< |
{ |
884 |
< |
/* Only decrement the oper counts if an oper to begin with |
885 |
< |
* found by Pat Szuta, Perly , perly@xnet.com |
886 |
< |
*/ |
887 |
< |
if (!IsOper(source_p)) |
888 |
< |
break; |
889 |
< |
|
890 |
< |
ClearOper(source_p); |
891 |
< |
Count.oper--; |
892 |
< |
|
893 |
< |
if (MyConnect(source_p)) |
894 |
< |
{ |
895 |
< |
dlink_node *dm; |
896 |
< |
|
897 |
< |
detach_conf(source_p, OPER_TYPE); |
898 |
< |
ClearOperFlags(source_p); |
899 |
< |
source_p->umodes &= ~ConfigFileEntry.oper_only_umodes; |
900 |
< |
|
901 |
< |
if ((dm = dlinkFindDelete(&oper_list, source_p)) != NULL) |
902 |
< |
free_dlink_node(dm); |
903 |
< |
} |
904 |
< |
} |
905 |
< |
|
906 |
< |
break; |
907 |
< |
|
908 |
< |
/* we may not get these, |
909 |
< |
* but they shouldnt be in default |
910 |
< |
*/ |
911 |
< |
case 'r': |
912 |
< |
case ' ' : |
913 |
< |
case '\n': |
914 |
< |
case '\r': |
915 |
< |
case '\t': |
916 |
< |
break; |
917 |
< |
|
918 |
< |
default: |
919 |
< |
if ((flag = user_modes[(unsigned char)*m])) |
920 |
< |
{ |
921 |
< |
if (MyConnect(source_p) && !IsOper(source_p) && |
922 |
< |
(ConfigFileEntry.oper_only_umodes & flag)) |
923 |
< |
{ |
924 |
< |
badflag = 1; |
925 |
< |
} |
926 |
< |
else |
927 |
< |
execute_callback(umode_cb, client_p, source_p, what, flag); |
928 |
< |
} |
929 |
< |
else |
930 |
< |
{ |
931 |
< |
if (MyConnect(source_p)) |
932 |
< |
badflag = 1; |
933 |
< |
} |
934 |
< |
|
935 |
< |
break; |
936 |
< |
} |
937 |
< |
} |
938 |
< |
} |
939 |
< |
|
940 |
< |
if (badflag) |
941 |
< |
sendto_one(source_p, form_str(ERR_UMODEUNKNOWNFLAG), |
942 |
< |
me.name, source_p->name); |
943 |
< |
|
944 |
< |
if (HasUMode(source_p, UMODE_NCHANGE) && !IsOperN(source_p)) |
945 |
< |
{ |
946 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** You have no admin flag;", |
947 |
< |
me.name, source_p->name); |
948 |
< |
DelUMode(source_p, UMODE_NCHANGE); /* only tcm's really need this */ |
949 |
< |
} |
950 |
< |
|
951 |
< |
if (MyConnect(source_p) && (source_p->umodes & UMODE_ADMIN) && |
952 |
< |
!IsOperAdmin(source_p) && !IsOperHiddenAdmin(source_p)) |
953 |
< |
{ |
954 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** You have no admin flag;", |
955 |
< |
me.name, source_p->name); |
956 |
< |
source_p->umodes &= ~UMODE_ADMIN; |
957 |
< |
} |
958 |
< |
|
959 |
< |
if (!(setflags & UMODE_INVISIBLE) && IsInvisible(source_p)) |
960 |
< |
++Count.invisi; |
961 |
< |
if ((setflags & UMODE_INVISIBLE) && !IsInvisible(source_p)) |
962 |
< |
--Count.invisi; |
963 |
< |
|
964 |
< |
/* |
965 |
< |
* compare new flags with old flags and send string which |
966 |
< |
* will cause servers to update correctly. |
967 |
< |
*/ |
968 |
< |
send_umode_out(client_p, source_p, setflags); |
814 |
> |
return p - nickname <= NICKLEN; |
815 |
|
} |
816 |
|
|
817 |
|
/* send_umode() |
838 |
|
* build a string in umode_buf to represent the change in the user's |
839 |
|
* mode between the new (source_p->umodes) and 'old'. |
840 |
|
*/ |
841 |
< |
for (i = 0; i < 128; i++) |
841 |
> |
for (i = 0; i < 128; ++i) |
842 |
|
{ |
843 |
|
flag = user_modes[i]; |
844 |
|
if (!flag) |
847 |
|
if (MyClient(source_p) && !(flag & sendmask)) |
848 |
|
continue; |
849 |
|
|
850 |
< |
if ((flag & old) && !(source_p->umodes & flag)) |
850 |
> |
if ((flag & old) && !HasUMode(source_p, flag)) |
851 |
|
{ |
852 |
|
if (what == MODE_DEL) |
853 |
|
*m++ = (char)i; |
858 |
|
*m++ = (char)i; |
859 |
|
} |
860 |
|
} |
861 |
< |
else if (!(flag & old) && (source_p->umodes & flag)) |
861 |
> |
else if (!(flag & old) && HasUMode(source_p, flag)) |
862 |
|
{ |
863 |
|
if (what == MODE_ADD) |
864 |
|
*m++ = (char)i; |
889 |
|
send_umode_out(struct Client *client_p, struct Client *source_p, |
890 |
|
unsigned int old) |
891 |
|
{ |
892 |
< |
char buf[IRCD_BUFSIZE] = { '\0' }; |
1047 |
< |
dlink_node *ptr = NULL; |
892 |
> |
char buf[IRCD_BUFSIZE] = ""; |
893 |
|
|
894 |
< |
send_umode(NULL, source_p, old, IsOperHiddenAdmin(source_p) ? |
1050 |
< |
SEND_UMODES & ~UMODE_ADMIN : SEND_UMODES, buf); |
894 |
> |
send_umode(NULL, source_p, old, SEND_UMODES, buf); |
895 |
|
|
896 |
|
if (buf[0]) |
897 |
< |
{ |
898 |
< |
DLINK_FOREACH(ptr, serv_list.head) |
1055 |
< |
{ |
1056 |
< |
struct Client *target_p = ptr->data; |
1057 |
< |
|
1058 |
< |
if ((target_p != client_p) && (target_p != source_p)) |
1059 |
< |
sendto_one(target_p, ":%s MODE %s :%s", |
1060 |
< |
ID_or_name(source_p, target_p), |
1061 |
< |
ID_or_name(source_p, target_p), buf); |
1062 |
< |
} |
1063 |
< |
} |
897 |
> |
sendto_server(source_p, NOCAPS, NOCAPS, ":%s MODE %s :%s", |
898 |
> |
source_p->id, source_p->id, buf); |
899 |
|
|
900 |
|
if (client_p && MyClient(client_p)) |
901 |
|
send_umode(client_p, source_p, old, 0xffffffff, buf); |
902 |
|
} |
903 |
|
|
904 |
< |
/* user_welcome() |
905 |
< |
* |
1071 |
< |
* inputs - client pointer to client to welcome |
1072 |
< |
* output - NONE |
1073 |
< |
* side effects - |
1074 |
< |
*/ |
1075 |
< |
static void |
1076 |
< |
user_welcome(struct Client *source_p) |
904 |
> |
void |
905 |
> |
user_set_hostmask(struct Client *target_p, const char *hostname, const int what) |
906 |
|
{ |
907 |
< |
#if defined(__TIME__) && defined(__DATE__) |
1079 |
< |
static const char built_date[] = __DATE__ " at " __TIME__; |
1080 |
< |
#else |
1081 |
< |
static const char built_date[] = "unknown"; |
1082 |
< |
#endif |
907 |
> |
dlink_node *ptr = NULL; |
908 |
|
|
909 |
< |
#ifdef HAVE_LIBCRYPTO |
910 |
< |
if (source_p->localClient->fd.ssl != NULL) |
1086 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** Connected securely via %s", |
1087 |
< |
me.name, source_p->name, |
1088 |
< |
ssl_get_cipher(source_p->localClient->fd.ssl)); |
1089 |
< |
#endif |
909 |
> |
if (!strcmp(target_p->host, hostname)) |
910 |
> |
return; |
911 |
|
|
912 |
< |
sendto_one(source_p, form_str(RPL_WELCOME), me.name, source_p->name, |
913 |
< |
ServerInfo.network_name, source_p->name); |
914 |
< |
sendto_one(source_p, form_str(RPL_YOURHOST), me.name, source_p->name, |
915 |
< |
get_listener_name(source_p->localClient->listener), ircd_version); |
916 |
< |
sendto_one(source_p, form_str(RPL_CREATED), |
917 |
< |
me.name, source_p->name, built_date); |
918 |
< |
sendto_one(source_p, form_str(RPL_MYINFO), |
919 |
< |
me.name, source_p->name, me.name, ircd_version, umode_buffer); |
1099 |
< |
show_isupport(source_p); |
912 |
> |
switch (what) |
913 |
> |
{ |
914 |
> |
case MODE_ADD: |
915 |
> |
AddUMode(target_p, UMODE_HIDDENHOST); |
916 |
> |
AddFlag(target_p, FLAGS_IP_SPOOFING); |
917 |
> |
break; |
918 |
> |
case MODE_DEL: |
919 |
> |
DelUMode(target_p, UMODE_HIDDENHOST); |
920 |
|
|
921 |
< |
if (source_p->id[0] != '\0') |
922 |
< |
sendto_one(source_p, form_str(RPL_YOURID), me.name, |
923 |
< |
source_p->name, source_p->id); |
921 |
> |
if (!HasFlag(target_p, FLAGS_AUTH_SPOOF)) |
922 |
> |
DelFlag(target_p, FLAGS_IP_SPOOFING); |
923 |
> |
break; |
924 |
> |
default: return; |
925 |
> |
} |
926 |
|
|
927 |
< |
show_lusers(source_p); |
927 |
> |
if (ConfigFileEntry.cycle_on_host_change) |
928 |
> |
sendto_common_channels_local(target_p, 0, 0, ":%s!%s@%s QUIT :Changing hostname", |
929 |
> |
target_p->name, target_p->username, target_p->host); |
930 |
> |
|
931 |
> |
if (IsUserHostIp(target_p)) |
932 |
> |
delete_user_host(target_p->username, target_p->host, !MyConnect(target_p)); |
933 |
> |
|
934 |
> |
strlcpy(target_p->host, hostname, sizeof(target_p->host)); |
935 |
> |
|
936 |
> |
add_user_host(target_p->username, target_p->host, !MyConnect(target_p)); |
937 |
> |
SetUserHost(target_p); |
938 |
|
|
939 |
< |
if (ConfigFileEntry.short_motd) |
939 |
> |
if (MyClient(target_p)) |
940 |
|
{ |
941 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** Notice -- motd was last changed at %s", |
942 |
< |
me.name, source_p->name, ConfigFileEntry.motd.lastChangedDate); |
1111 |
< |
sendto_one(source_p, |
1112 |
< |
":%s NOTICE %s :*** Notice -- Please read the motd if you haven't " |
1113 |
< |
"read it", me.name, source_p->name); |
1114 |
< |
sendto_one(source_p, form_str(RPL_MOTDSTART), |
1115 |
< |
me.name, source_p->name, me.name); |
1116 |
< |
sendto_one(source_p, form_str(RPL_MOTD), |
1117 |
< |
me.name, source_p->name, |
1118 |
< |
"*** This is the short motd ***"); |
1119 |
< |
sendto_one(source_p, form_str(RPL_ENDOFMOTD), |
1120 |
< |
me.name, source_p->name); |
941 |
> |
sendto_one_numeric(target_p, &me, RPL_NEWHOSTIS, target_p->host); |
942 |
> |
clear_ban_cache_client(target_p); |
943 |
|
} |
1122 |
– |
else |
1123 |
– |
send_message_file(source_p, &ConfigFileEntry.motd); |
1124 |
– |
} |
944 |
|
|
945 |
< |
/* check_xline() |
946 |
< |
* |
1128 |
< |
* inputs - pointer to client to test |
1129 |
< |
* outupt - 1 if exiting 0 if ok |
1130 |
< |
* side effects - |
1131 |
< |
*/ |
1132 |
< |
static int |
1133 |
< |
check_xline(struct Client *source_p) |
1134 |
< |
{ |
1135 |
< |
struct ConfItem *conf = NULL; |
1136 |
< |
const char *reason = NULL; |
945 |
> |
if (!ConfigFileEntry.cycle_on_host_change) |
946 |
> |
return; |
947 |
|
|
948 |
< |
if ((conf = find_matching_name_conf(XLINE_TYPE, source_p->info, NULL, NULL, 0)) || |
1139 |
< |
(conf = find_matching_name_conf(RXLINE_TYPE, source_p->info, NULL, NULL, 0))) |
948 |
> |
DLINK_FOREACH(ptr, target_p->channel.head) |
949 |
|
{ |
950 |
< |
struct MatchItem *reg = map_to_conf(conf); |
950 |
> |
char modebuf[4], nickbuf[NICKLEN * 3 + 3] = ""; |
951 |
> |
char *p = modebuf; |
952 |
> |
int len = 0; |
953 |
> |
const struct Membership *ms = ptr->data; |
954 |
|
|
955 |
< |
++reg->count; |
956 |
< |
|
957 |
< |
if (reg->reason != NULL) |
958 |
< |
reason = reg->reason; |
959 |
< |
else |
1148 |
< |
reason = "No Reason"; |
955 |
> |
if (has_member_flags(ms, CHFL_CHANOP)) |
956 |
> |
{ |
957 |
> |
*p++ = 'o'; |
958 |
> |
len += snprintf(nickbuf + len, sizeof(nickbuf) - len, len ? " %s" : "%s", target_p->name); |
959 |
> |
} |
960 |
|
|
961 |
< |
sendto_realops_flags(UMODE_REJ, L_ALL, |
962 |
< |
"X-line Rejecting [%s] [%s], user %s [%s]", |
963 |
< |
source_p->info, reason, |
964 |
< |
get_client_name(source_p, HIDE_IP), |
965 |
< |
source_p->sockhost); |
961 |
> |
if (has_member_flags(ms, CHFL_HALFOP)) |
962 |
> |
{ |
963 |
> |
*p++ = 'h'; |
964 |
> |
len += snprintf(nickbuf + len, sizeof(nickbuf) - len, len ? " %s" : "%s", target_p->name); |
965 |
> |
} |
966 |
|
|
967 |
< |
++ServerStats.is_ref; |
1157 |
< |
if (REJECT_HOLD_TIME > 0) |
967 |
> |
if (has_member_flags(ms, CHFL_VOICE)) |
968 |
|
{ |
969 |
< |
sendto_one(source_p, ":%s NOTICE %s :Bad user info", |
970 |
< |
me.name, source_p->name); |
1161 |
< |
source_p->localClient->reject_delay = CurrentTime + REJECT_HOLD_TIME; |
1162 |
< |
SetCaptured(source_p); |
969 |
> |
*p++ = 'v'; |
970 |
> |
len += snprintf(nickbuf + len, sizeof(nickbuf) - len, len ? " %s" : "%s", target_p->name); |
971 |
|
} |
972 |
< |
else |
973 |
< |
exit_client(source_p, &me, "Bad user info"); |
974 |
< |
return 1; |
972 |
> |
|
973 |
> |
*p = '\0'; |
974 |
> |
|
975 |
> |
sendto_channel_local_butone(target_p, 0, 0, ms->chptr, ":%s!%s@%s JOIN :%s", |
976 |
> |
target_p->name, target_p->username, target_p->host, |
977 |
> |
ms->chptr->chname); |
978 |
> |
if (nickbuf[0]) |
979 |
> |
sendto_channel_local_butone(target_p, 0, 0, ms->chptr, ":%s MODE %s +%s %s", |
980 |
> |
target_p->servptr->name, ms->chptr->chname, |
981 |
> |
modebuf, nickbuf); |
982 |
> |
|
983 |
|
} |
984 |
|
|
985 |
< |
return 0; |
985 |
> |
if (target_p->away[0]) |
986 |
> |
sendto_common_channels_local(target_p, 0, CAP_AWAY_NOTIFY, |
987 |
> |
":%s!%s@%s AWAY :%s", |
988 |
> |
target_p->name, target_p->username, |
989 |
> |
target_p->host, target_p->away); |
990 |
|
} |
991 |
|
|
992 |
|
/* oper_up() |
993 |
|
* |
994 |
|
* inputs - pointer to given client to oper |
995 |
|
* output - NONE |
996 |
< |
* side effects - Blindly opers up given source_p, using aconf info |
996 |
> |
* side effects - Blindly opers up given source_p, using conf info |
997 |
|
* all checks on passwords have already been done. |
998 |
< |
* This could also be used by rsa oper routines. |
998 |
> |
* This could also be used by rsa oper routines. |
999 |
|
*/ |
1000 |
|
void |
1001 |
|
oper_up(struct Client *source_p) |
1002 |
|
{ |
1003 |
< |
unsigned int old = source_p->umodes; |
1004 |
< |
const char *operprivs = ""; |
1185 |
< |
const struct AccessItem *oconf = NULL; |
1003 |
> |
const unsigned int old = source_p->umodes; |
1004 |
> |
const struct MaskItem *conf = source_p->localClient->confs.head->data; |
1005 |
|
|
1006 |
|
assert(source_p->localClient->confs.head); |
1188 |
– |
oconf = map_to_conf((source_p->localClient->confs.head)->data); |
1007 |
|
|
1008 |
|
++Count.oper; |
1009 |
|
SetOper(source_p); |
1010 |
|
|
1011 |
< |
if (oconf->modes) |
1012 |
< |
source_p->umodes |= oconf->modes; |
1011 |
> |
if (conf->modes) |
1012 |
> |
AddUMode(source_p, conf->modes); |
1013 |
|
else if (ConfigFileEntry.oper_umodes) |
1014 |
< |
source_p->umodes |= ConfigFileEntry.oper_umodes; |
1197 |
< |
else |
1198 |
< |
source_p->umodes |= (UMODE_SERVNOTICE|UMODE_OPERWALL| |
1199 |
< |
UMODE_WALLOP|UMODE_LOCOPS); |
1014 |
> |
AddUMode(source_p, ConfigFileEntry.oper_umodes); |
1015 |
|
|
1016 |
< |
if (!(old & UMODE_INVISIBLE) && IsInvisible(source_p)) |
1016 |
> |
if (!(old & UMODE_INVISIBLE) && HasUMode(source_p, UMODE_INVISIBLE)) |
1017 |
|
++Count.invisi; |
1018 |
< |
if ((old & UMODE_INVISIBLE) && !IsInvisible(source_p)) |
1018 |
> |
if ((old & UMODE_INVISIBLE) && !HasUMode(source_p, UMODE_INVISIBLE)) |
1019 |
|
--Count.invisi; |
1020 |
|
|
1021 |
|
assert(dlinkFind(&oper_list, source_p) == NULL); |
1022 |
|
dlinkAdd(source_p, make_dlink_node(), &oper_list); |
1023 |
|
|
1024 |
< |
operprivs = oper_privs_as_string(oconf->port); |
1210 |
< |
|
1211 |
< |
SetOFlag(source_p, oconf->port); |
1024 |
> |
AddOFlag(source_p, conf->port); |
1025 |
|
|
1026 |
< |
if (IsOperAdmin(source_p) || IsOperHiddenAdmin(source_p)) |
1026 |
> |
if (HasOFlag(source_p, OPER_FLAG_ADMIN)) |
1027 |
|
AddUMode(source_p, UMODE_ADMIN); |
1215 |
– |
if (!IsOperN(source_p)) |
1216 |
– |
DelUMode(source_p, UMODE_NCHANGE); |
1028 |
|
|
1029 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, "%s (%s@%s) is now an operator", |
1030 |
< |
source_p->name, source_p->username, source_p->host); |
1029 |
> |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "%s is now an operator", |
1030 |
> |
get_oper_name(source_p)); |
1031 |
|
send_umode_out(source_p, source_p, old); |
1032 |
< |
sendto_one(source_p, form_str(RPL_YOUREOPER), me.name, source_p->name); |
1222 |
< |
sendto_one(source_p, ":%s NOTICE %s :*** Oper privs are %s", |
1223 |
< |
me.name, source_p->name, operprivs); |
1224 |
< |
send_message_file(source_p, &ConfigFileEntry.opermotd); |
1032 |
> |
sendto_one_numeric(source_p, &me, RPL_YOUREOPER); |
1033 |
|
} |
1034 |
|
|
1035 |
|
static char new_uid[TOTALSIDUID + 1]; /* allow for \0 */ |
1047 |
|
|
1048 |
|
/* |
1049 |
|
* init_uid() |
1050 |
< |
* |
1050 |
> |
* |
1051 |
|
* inputs - NONE |
1052 |
|
* output - NONE |
1053 |
|
* side effects - new_uid is filled in with server id portion (sid) |
1057 |
|
void |
1058 |
|
init_uid(void) |
1059 |
|
{ |
1252 |
– |
int i; |
1253 |
– |
|
1060 |
|
memset(new_uid, 0, sizeof(new_uid)); |
1061 |
|
|
1062 |
|
if (!EmptyString(ServerInfo.sid)) |
1063 |
|
strlcpy(new_uid, ServerInfo.sid, sizeof(new_uid)); |
1064 |
|
|
1065 |
< |
for (i = 0; i < IRC_MAXSID; ++i) |
1066 |
< |
if (new_uid[i] == '\0') |
1065 |
> |
for (unsigned int i = 0; i < IRC_MAXSID; ++i) |
1066 |
> |
if (new_uid[i] == '\0') |
1067 |
|
new_uid[i] = 'A'; |
1068 |
|
|
1069 |
|
/* NOTE: if IRC_MAXUID != 6, this will have to be rewritten */ |
1264 |
– |
/* Yes nenolod, I have known it was off by one ever since I wrote it |
1265 |
– |
* But *JUST* for you, though, it really doesn't look as *pretty* |
1266 |
– |
* -Dianora |
1267 |
– |
*/ |
1070 |
|
memcpy(new_uid + IRC_MAXSID, "AAAAA@", IRC_MAXUID); |
1269 |
– |
|
1270 |
– |
entering_umode_cb = register_callback("entering_umode", NULL); |
1271 |
– |
umode_cb = register_callback("changing_umode", change_simple_umode); |
1071 |
|
} |
1072 |
|
|
1073 |
|
/* |
1127 |
|
void |
1128 |
|
init_isupport(void) |
1129 |
|
{ |
1331 |
– |
isupportFile = init_MessageLine(); |
1332 |
– |
|
1130 |
|
add_isupport("CALLERID", NULL, -1); |
1131 |
|
add_isupport("CASEMAPPING", CASEMAP, -1); |
1132 |
|
add_isupport("DEAF", "D", -1); |
1133 |
|
add_isupport("KICKLEN", NULL, KICKLEN); |
1134 |
|
add_isupport("MODES", NULL, MAXMODEPARAMS); |
1338 |
– |
add_isupport("NICKLEN", NULL, NICKLEN-1); |
1135 |
|
#ifdef HALFOPS |
1136 |
|
add_isupport("PREFIX", "(ohv)@%+", -1); |
1137 |
|
add_isupport("STATUSMSG", "@%+", -1); |
1139 |
|
add_isupport("PREFIX", "(ov)@+", -1); |
1140 |
|
add_isupport("STATUSMSG", "@+", -1); |
1141 |
|
#endif |
1142 |
< |
add_isupport("TOPICLEN", NULL, TOPICLEN); |
1142 |
> |
add_isupport("EXCEPTS", "e", -1); |
1143 |
> |
add_isupport("INVEX", "I", -1); |
1144 |
|
} |
1145 |
|
|
1146 |
|
/* |
1175 |
|
dlinkAddTail(support, &support->node, &support_list); |
1176 |
|
} |
1177 |
|
|
1178 |
< |
DupString(support->name, name); |
1178 |
> |
support->name = xstrdup(name); |
1179 |
|
if (options != NULL) |
1180 |
< |
DupString(support->options, options); |
1180 |
> |
support->options = xstrdup(options); |
1181 |
|
support->number = n; |
1182 |
|
|
1183 |
|
rebuild_isupport_message_line(); |
1224 |
|
{ |
1225 |
|
char isupportbuffer[IRCD_BUFSIZE]; |
1226 |
|
char *p = isupportbuffer; |
1227 |
< |
dlink_node *ptr = NULL; |
1227 |
> |
dlink_node *ptr = NULL, *ptr_next = NULL; |
1228 |
|
int n = 0; |
1229 |
|
int tokens = 0; |
1230 |
|
size_t len = 0; |
1231 |
< |
size_t reserve = strlen(me.name) + HOSTLEN + strlen(form_str(RPL_ISUPPORT)); |
1231 |
> |
size_t reserve = strlen(me.name) + HOSTLEN + strlen(numeric_form(RPL_ISUPPORT)); |
1232 |
|
|
1233 |
< |
destroy_MessageLine(isupportFile); |
1233 |
> |
DLINK_FOREACH_SAFE(ptr, ptr_next, support_list_lines.head) |
1234 |
> |
{ |
1235 |
> |
dlinkDelete(ptr, &support_list_lines); |
1236 |
> |
MyFree(ptr->data); |
1237 |
> |
free_dlink_node(ptr); |
1238 |
> |
} |
1239 |
|
|
1240 |
|
DLINK_FOREACH(ptr, support_list.head) |
1241 |
|
{ |
1242 |
|
struct Isupport *support = ptr->data; |
1243 |
|
|
1244 |
< |
p += (n = ircsprintf(p, "%s", support->name)); |
1244 |
> |
p += (n = sprintf(p, "%s", support->name)); |
1245 |
|
len += n; |
1246 |
|
|
1247 |
|
if (support->options != NULL) |
1248 |
|
{ |
1249 |
< |
p += (n = ircsprintf(p, "=%s", support->options)); |
1249 |
> |
p += (n = sprintf(p, "=%s", support->options)); |
1250 |
|
len += n; |
1251 |
|
} |
1252 |
|
|
1253 |
|
if (support->number > 0) |
1254 |
|
{ |
1255 |
< |
p += (n = ircsprintf(p, "=%d", support->number)); |
1255 |
> |
p += (n = sprintf(p, "=%d", support->number)); |
1256 |
|
len += n; |
1257 |
|
} |
1258 |
|
|
1265 |
|
if (*--p == ' ') |
1266 |
|
*p = '\0'; |
1267 |
|
|
1268 |
< |
addto_MessageLine(isupportFile, isupportbuffer); |
1268 |
> |
dlinkAddTail(xstrdup(isupportbuffer), make_dlink_node(), &support_list_lines); |
1269 |
|
p = isupportbuffer; |
1270 |
|
len = 0; |
1271 |
|
n = tokens = 0; |
1276 |
|
{ |
1277 |
|
if (*--p == ' ') |
1278 |
|
*p = '\0'; |
1279 |
< |
addto_MessageLine(isupportFile, isupportbuffer); |
1279 |
> |
dlinkAddTail(xstrdup(isupportbuffer), make_dlink_node(), &support_list_lines); |
1280 |
|
} |
1281 |
|
} |