1 |
|
/* |
2 |
|
* ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd) |
3 |
|
* |
4 |
< |
* Copyright (c) 1997-2014 ircd-hybrid development team |
4 |
> |
* Copyright (c) 1997-2015 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 |
55 |
|
#include "conf_class.h" |
56 |
|
#include "motd.h" |
57 |
|
#include "ipcache.h" |
58 |
+ |
#include "isupport.h" |
59 |
|
|
60 |
|
|
61 |
+ |
struct config_channel_entry ConfigChannel; |
62 |
+ |
struct config_serverhide_entry ConfigServerHide; |
63 |
+ |
struct config_general_entry ConfigGeneral; |
64 |
+ |
struct config_log_entry ConfigLog = { .use_logging = 1 }; |
65 |
+ |
struct config_serverinfo_entry ConfigServerInfo; |
66 |
+ |
struct config_admin_entry ConfigAdminInfo; |
67 |
+ |
struct conf_parser_context conf_parser_ctx; |
68 |
+ |
|
69 |
|
/* general conf items link list root, other than k lines etc. */ |
70 |
|
dlink_list service_items; |
71 |
|
dlink_list server_items; |
204 |
|
MyFree(conf->spasswd); |
205 |
|
MyFree(conf->reason); |
206 |
|
MyFree(conf->certfp); |
207 |
+ |
MyFree(conf->whois); |
208 |
|
MyFree(conf->user); |
209 |
|
MyFree(conf->host); |
210 |
|
#ifdef HAVE_LIBCRYPTO |
301 |
|
verify_access(struct Client *client_p) |
302 |
|
{ |
303 |
|
struct MaskItem *conf = NULL; |
294 |
– |
char non_ident[USERLEN + 1] = "~"; |
304 |
|
|
305 |
< |
if (IsGotId(client_p)) |
305 |
> |
if (HasFlag(client_p, FLAGS_GOTID)) |
306 |
|
{ |
307 |
|
conf = find_address_conf(client_p->host, client_p->username, |
308 |
|
&client_p->connection->ip, |
311 |
|
} |
312 |
|
else |
313 |
|
{ |
314 |
+ |
char non_ident[USERLEN + 1] = "~"; |
315 |
+ |
|
316 |
|
strlcpy(non_ident + 1, client_p->username, sizeof(non_ident) - 1); |
317 |
|
conf = find_address_conf(client_p->host, non_ident, |
318 |
|
&client_p->connection->ip, |
320 |
|
client_p->connection->password); |
321 |
|
} |
322 |
|
|
323 |
< |
if (conf) |
324 |
< |
{ |
314 |
< |
if (IsConfClient(conf)) |
315 |
< |
{ |
316 |
< |
if (IsConfRedir(conf)) |
317 |
< |
{ |
318 |
< |
sendto_one_numeric(client_p, &me, RPL_REDIR, |
319 |
< |
conf->name ? conf->name : "", |
320 |
< |
conf->port); |
321 |
< |
return NOT_AUTHORIZED; |
322 |
< |
} |
323 |
> |
if (!conf) |
324 |
> |
return NOT_AUTHORIZED; |
325 |
|
|
326 |
< |
/* Thanks for spoof idea amm */ |
325 |
< |
if (IsConfDoSpoofIp(conf)) |
326 |
< |
{ |
327 |
< |
if (IsConfSpoofNotice(conf)) |
328 |
< |
sendto_realops_flags(UMODE_ALL, L_ADMIN, SEND_NOTICE, "%s spoofing: %s as %s", |
329 |
< |
client_p->name, client_p->host, conf->name); |
326 |
> |
assert(IsConfClient(conf) || IsConfKill(conf)); |
327 |
|
|
328 |
< |
strlcpy(client_p->host, conf->name, sizeof(client_p->host)); |
329 |
< |
} |
330 |
< |
|
331 |
< |
return attach_iline(client_p, conf); |
328 |
> |
if (IsConfClient(conf)) |
329 |
> |
{ |
330 |
> |
if (IsConfRedir(conf)) |
331 |
> |
{ |
332 |
> |
sendto_one_numeric(client_p, &me, RPL_REDIR, |
333 |
> |
conf->name ? conf->name : "", |
334 |
> |
conf->port); |
335 |
> |
return NOT_AUTHORIZED; |
336 |
|
} |
337 |
< |
else if (IsConfKill(conf) || (ConfigGeneral.glines && IsConfGline(conf))) |
337 |
> |
|
338 |
> |
if (IsConfDoSpoofIp(conf)) |
339 |
|
{ |
340 |
< |
if (IsConfGline(conf)) |
341 |
< |
sendto_one_notice(client_p, &me, ":*** G-lined"); |
340 |
> |
if (IsConfSpoofNotice(conf)) |
341 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, "%s spoofing: %s as %s", |
342 |
> |
client_p->name, client_p->host, conf->name); |
343 |
|
|
344 |
< |
sendto_one_notice(client_p, &me, ":*** Banned: %s", conf->reason); |
342 |
< |
return BANNED_CLIENT; |
344 |
> |
strlcpy(client_p->host, conf->name, sizeof(client_p->host)); |
345 |
|
} |
346 |
+ |
|
347 |
+ |
return attach_iline(client_p, conf); |
348 |
|
} |
349 |
|
|
350 |
< |
return NOT_AUTHORIZED; |
350 |
> |
sendto_one_notice(client_p, &me, ":*** Banned: %s", conf->reason); |
351 |
> |
return BANNED_CLIENT; |
352 |
|
} |
353 |
|
|
354 |
|
/* check_client() |
522 |
|
continue; |
523 |
|
|
524 |
|
attach_conf(client_p, conf); |
525 |
< |
return -1; |
525 |
> |
return 1; |
526 |
|
} |
527 |
|
|
528 |
|
return 0; |
794 |
|
memset(&ConfigServerInfo.ip6, 0, sizeof(ConfigServerInfo.ip6)); |
795 |
|
ConfigServerInfo.specific_ipv6_vhost = 0; |
796 |
|
|
797 |
< |
ConfigServerInfo.max_clients = MAXCLIENTS_MAX; |
797 |
> |
ConfigServerInfo.default_max_clients = MAXCLIENTS_MAX; |
798 |
|
ConfigServerInfo.max_nick_length = 9; |
799 |
|
ConfigServerInfo.max_topic_length = 80; |
800 |
|
ConfigServerInfo.hub = 0; |
815 |
|
ConfigChannel.knock_delay_channel = 60; |
816 |
|
ConfigChannel.max_channels = 25; |
817 |
|
ConfigChannel.max_bans = 25; |
818 |
+ |
ConfigChannel.default_join_flood_count = 18; |
819 |
+ |
ConfigChannel.default_join_flood_time = 6; |
820 |
|
ConfigChannel.default_split_user_count = 0; |
821 |
|
ConfigChannel.default_split_server_count = 0; |
822 |
|
ConfigChannel.no_join_on_split = 0; |
835 |
|
ConfigGeneral.away_time = 10; |
836 |
|
ConfigGeneral.max_watch = WATCHSIZE_DEFAULT; |
837 |
|
ConfigGeneral.cycle_on_host_change = 1; |
838 |
< |
ConfigGeneral.glines = 0; |
839 |
< |
ConfigGeneral.gline_time = 12 * 3600; |
840 |
< |
ConfigGeneral.gline_request_time = GLINE_REQUEST_EXPIRE_DEFAULT; |
841 |
< |
ConfigGeneral.gline_min_cidr = 16; |
835 |
< |
ConfigGeneral.gline_min_cidr6 = 48; |
838 |
> |
ConfigGeneral.dline_min_cidr = 16; |
839 |
> |
ConfigGeneral.dline_min_cidr6 = 48; |
840 |
> |
ConfigGeneral.kline_min_cidr = 16; |
841 |
> |
ConfigGeneral.kline_min_cidr6 = 48; |
842 |
|
ConfigGeneral.invisible_on_connect = 1; |
843 |
|
ConfigGeneral.tkline_expire_notices = 1; |
844 |
|
ConfigGeneral.ignore_bogus_ts = 0; |
873 |
|
ConfigGeneral.no_oper_flood = 0; |
874 |
|
ConfigGeneral.oper_pass_resv = 1; |
875 |
|
ConfigGeneral.max_targets = MAX_TARGETS_DEFAULT; |
876 |
< |
ConfigGeneral.oper_only_umodes = UMODE_DEBUG; |
876 |
> |
ConfigGeneral.oper_only_umodes = UMODE_DEBUG | UMODE_LOCOPS | UMODE_HIDDEN | UMODE_FARCONNECT | |
877 |
> |
UMODE_UNAUTH | UMODE_EXTERNAL | UMODE_BOTS | UMODE_NCHANGE | |
878 |
> |
UMODE_SPY | UMODE_FULL | UMODE_SKILL | UMODE_REJ | UMODE_CCONN; |
879 |
|
ConfigGeneral.oper_umodes = UMODE_BOTS | UMODE_LOCOPS | UMODE_SERVNOTICE | UMODE_WALLOP; |
880 |
|
ConfigGeneral.throttle_count = 1; |
881 |
|
ConfigGeneral.throttle_time = 1; |
929 |
|
* as a result of an operator issuing this command, else assume it has been |
930 |
|
* called as a result of the server receiving a HUP signal. |
931 |
|
*/ |
932 |
< |
int |
932 |
> |
void |
933 |
|
conf_rehash(int sig) |
934 |
|
{ |
935 |
|
if (sig) |
936 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
936 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, |
937 |
|
"Got signal SIGHUP, reloading configuration file(s)"); |
938 |
|
|
939 |
|
restart_resolver(); |
944 |
|
|
945 |
|
load_conf_modules(); |
946 |
|
check_conf_klines(); |
939 |
– |
|
940 |
– |
return 0; |
947 |
|
} |
948 |
|
|
949 |
|
/* lookup_confhost() |
1037 |
|
if (!conf->until || conf->until > CurrentTime) |
1038 |
|
continue; |
1039 |
|
|
1040 |
< |
if (conf->type == CONF_XLINE) |
1041 |
< |
{ |
1042 |
< |
if (ConfigGeneral.tkline_expire_notices) |
1043 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1038 |
< |
"Temporary X-line for [%s] expired", conf->name); |
1039 |
< |
conf_free(conf); |
1040 |
< |
} |
1041 |
< |
else if (conf->type == CONF_NRESV || conf->type == CONF_CRESV) |
1042 |
< |
{ |
1043 |
< |
if (ConfigGeneral.tkline_expire_notices) |
1044 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1045 |
< |
"Temporary RESV for [%s] expired", conf->name); |
1046 |
< |
conf_free(conf); |
1047 |
< |
} |
1040 |
> |
if (ConfigGeneral.tkline_expire_notices) |
1041 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ALL, SEND_NOTICE, "Temporary %s for [%s] expired", |
1042 |
> |
(conf->type == CONF_XLINE) ? "X-line" : "RESV", conf->name); |
1043 |
> |
conf_free(conf); |
1044 |
|
} |
1045 |
|
} |
1046 |
|
|
1074 |
|
{ OPER_FLAG_ADMIN, 'A' }, |
1075 |
|
{ OPER_FLAG_REMOTEBAN, 'B' }, |
1076 |
|
{ OPER_FLAG_DIE, 'D' }, |
1081 |
– |
{ OPER_FLAG_GLINE, 'G' }, |
1077 |
|
{ OPER_FLAG_REHASH, 'H' }, |
1078 |
|
{ OPER_FLAG_KLINE, 'K' }, |
1079 |
|
{ OPER_FLAG_KILL, 'N' }, |
1087 |
|
{ 0, '\0' } |
1088 |
|
}; |
1089 |
|
|
1090 |
< |
char * |
1090 |
> |
const char * |
1091 |
|
oper_privs_as_string(const unsigned int port) |
1092 |
|
{ |
1093 |
|
static char privs_out[IRCD_BUFSIZE]; |
1115 |
|
const char * |
1116 |
|
get_oper_name(const struct Client *client_p) |
1117 |
|
{ |
1118 |
< |
/* +5 for !,@,{,} and null */ |
1124 |
< |
static char buffer[NICKLEN + USERLEN + HOSTLEN + HOSTLEN + 5]; |
1118 |
> |
static char buffer[IRCD_BUFSIZE]; |
1119 |
|
|
1120 |
|
if (IsServer(client_p)) |
1121 |
|
return client_p->name; |
1177 |
|
struct MaskItem *conf = node->data; |
1178 |
|
|
1179 |
|
conf->active = 0; |
1186 |
– |
dlinkDelete(&conf->node, *iterator); |
1180 |
|
|
1181 |
< |
/* XXX This is less than pretty */ |
1189 |
< |
if (conf->type == CONF_SERVER || conf->type == CONF_OPER) |
1181 |
> |
if (!IsConfDatabase(conf)) |
1182 |
|
{ |
1183 |
+ |
dlinkDelete(&conf->node, *iterator); |
1184 |
+ |
|
1185 |
|
if (!conf->ref_count) |
1186 |
|
conf_free(conf); |
1187 |
|
} |
1194 |
– |
else if (conf->type == CONF_XLINE) |
1195 |
– |
{ |
1196 |
– |
if (!conf->until) |
1197 |
– |
conf_free(conf); |
1198 |
– |
} |
1199 |
– |
else |
1200 |
– |
conf_free(conf); |
1188 |
|
} |
1189 |
|
} |
1190 |
|
|
1191 |
|
motd_clear(); |
1192 |
|
|
1193 |
|
/* |
1194 |
< |
* don't delete the class table, rather mark all entries |
1195 |
< |
* for deletion. The table is cleaned up by class_delete_marked. - avalon |
1194 |
> |
* Don't delete the class table, rather mark all entries for deletion. |
1195 |
> |
* The table is cleaned up by class_delete_marked. - avalon |
1196 |
|
*/ |
1197 |
|
class_mark_for_deletion(); |
1198 |
|
|
1199 |
|
clear_out_address_conf(); |
1200 |
|
|
1201 |
< |
/* clean out module paths */ |
1201 |
> |
/* Clean out module paths */ |
1202 |
|
mod_clear_paths(); |
1203 |
|
|
1204 |
|
pseudo_clear(); |
1205 |
|
|
1206 |
< |
/* clean out ConfigServerInfo */ |
1206 |
> |
/* Clean out ConfigServerInfo */ |
1207 |
|
MyFree(ConfigServerInfo.description); |
1208 |
|
ConfigServerInfo.description = NULL; |
1209 |
|
MyFree(ConfigServerInfo.network_name); |
1221 |
|
ConfigServerInfo.rsa_private_key_file = NULL; |
1222 |
|
#endif |
1223 |
|
|
1224 |
< |
/* clean out ConfigAdminInfo */ |
1224 |
> |
/* Clean out ConfigAdminInfo */ |
1225 |
|
MyFree(ConfigAdminInfo.name); |
1226 |
|
ConfigAdminInfo.name = NULL; |
1227 |
|
MyFree(ConfigAdminInfo.email); |
1229 |
|
MyFree(ConfigAdminInfo.description); |
1230 |
|
ConfigAdminInfo.description = NULL; |
1231 |
|
|
1232 |
< |
/* clean out listeners */ |
1232 |
> |
/* Clean out listeners */ |
1233 |
|
close_listeners(); |
1234 |
|
} |
1235 |
|
|
1267 |
|
} |
1268 |
|
else |
1269 |
|
{ |
1270 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1270 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
1271 |
|
"Unable to read configuration file '%s': %s", |
1272 |
|
filename, strerror(errno)); |
1273 |
|
return; |
1282 |
|
|
1283 |
|
log_reopen_all(); |
1284 |
|
|
1285 |
< |
add_isupport("NICKLEN", NULL, ConfigServerInfo.max_nick_length); |
1286 |
< |
add_isupport("NETWORK", ConfigServerInfo.network_name, -1); |
1285 |
> |
isupport_add("NICKLEN", NULL, ConfigServerInfo.max_nick_length); |
1286 |
> |
isupport_add("NETWORK", ConfigServerInfo.network_name, -1); |
1287 |
|
|
1288 |
|
snprintf(chanmodes, sizeof(chanmodes), "beI:%d", ConfigChannel.max_bans); |
1289 |
< |
add_isupport("MAXLIST", chanmodes, -1); |
1290 |
< |
add_isupport("MAXTARGETS", NULL, ConfigGeneral.max_targets); |
1291 |
< |
add_isupport("CHANTYPES", "#", -1); |
1289 |
> |
isupport_add("MAXLIST", chanmodes, -1); |
1290 |
> |
isupport_add("MAXTARGETS", NULL, ConfigGeneral.max_targets); |
1291 |
> |
isupport_add("CHANTYPES", "#", -1); |
1292 |
|
|
1293 |
|
snprintf(chanlimit, sizeof(chanlimit), "#:%d", |
1294 |
|
ConfigChannel.max_channels); |
1295 |
< |
add_isupport("CHANLIMIT", chanlimit, -1); |
1296 |
< |
snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstMORS"); |
1297 |
< |
add_isupport("CHANNELLEN", NULL, CHANNELLEN); |
1298 |
< |
add_isupport("TOPICLEN", NULL, ConfigServerInfo.max_topic_length); |
1299 |
< |
add_isupport("CHANMODES", chanmodes, -1); |
1295 |
> |
isupport_add("CHANLIMIT", chanlimit, -1); |
1296 |
> |
snprintf(chanmodes, sizeof(chanmodes), "%s", "beI,k,l,cimnprstCMORS"); |
1297 |
> |
isupport_add("CHANNELLEN", NULL, CHANNELLEN); |
1298 |
> |
isupport_add("TOPICLEN", NULL, ConfigServerInfo.max_topic_length); |
1299 |
> |
isupport_add("CHANMODES", chanmodes, -1); |
1300 |
|
|
1301 |
|
/* |
1302 |
|
* message_locale may have changed. rebuild isupport since it relies |
1303 |
|
* on strlen(form_str(RPL_ISUPPORT)) |
1304 |
|
*/ |
1305 |
< |
rebuild_isupport_message_line(); |
1305 |
> |
isupport_rebuild(); |
1306 |
|
} |
1307 |
|
|
1308 |
|
/* conf_add_class_to_conf() |
1312 |
|
* side effects - Add a class pointer to a conf |
1313 |
|
*/ |
1314 |
|
void |
1315 |
< |
conf_add_class_to_conf(struct MaskItem *conf, const char *class_name) |
1315 |
> |
conf_add_class_to_conf(struct MaskItem *conf, const char *name) |
1316 |
|
{ |
1317 |
< |
if (class_name == NULL) |
1317 |
> |
if (EmptyString(name) || (conf->class = class_find(name, 1)) == NULL) |
1318 |
|
{ |
1319 |
|
conf->class = class_default; |
1320 |
|
|
1321 |
|
if (conf->type == CONF_CLIENT || conf->type == CONF_OPER) |
1322 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1336 |
< |
"Warning *** Defaulting to default class for %s@%s", |
1337 |
< |
conf->user, conf->host); |
1338 |
< |
else |
1339 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1340 |
< |
"Warning *** Defaulting to default class for %s", |
1341 |
< |
conf->name); |
1342 |
< |
} |
1343 |
< |
else |
1344 |
< |
conf->class = class_find(class_name, 1); |
1345 |
< |
|
1346 |
< |
if (conf->class == NULL) |
1347 |
< |
{ |
1348 |
< |
if (conf->type == CONF_CLIENT || conf->type == CONF_OPER) |
1349 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1322 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
1323 |
|
"Warning *** Defaulting to default class for %s@%s", |
1324 |
|
conf->user, conf->host); |
1325 |
|
else |
1326 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1326 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
1327 |
|
"Warning *** Defaulting to default class for %s", |
1328 |
|
conf->name); |
1356 |
– |
conf->class = class_default; |
1329 |
|
} |
1330 |
|
} |
1331 |
|
|
1344 |
|
return; |
1345 |
|
|
1346 |
|
strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf)); |
1347 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1347 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
1348 |
|
"\"%s\", line %u: %s: %s", |
1349 |
|
conffilebuf, lineno + 1, msg, newlinebuf); |
1350 |
|
ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s", |
1357 |
|
char newlinebuf[IRCD_BUFSIZE]; |
1358 |
|
|
1359 |
|
strip_tabs(newlinebuf, linebuf, sizeof(newlinebuf)); |
1360 |
< |
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, |
1360 |
> |
sendto_realops_flags(UMODE_SERVNOTICE, L_ADMIN, SEND_NOTICE, |
1361 |
|
"\"%s\", line %u: %s: %s", |
1362 |
|
conffilebuf, lineno + 1, msg, newlinebuf); |
1363 |
|
ilog(LOG_TYPE_IRCD, "\"%s\", line %u: %s: %s", |
1392 |
|
|
1393 |
|
/* |
1394 |
|
* In the degenerate case where oper does a /quote kline 0 user@host :reason |
1395 |
< |
* i.e. they specifically use 0, I am going to return 1 instead |
1396 |
< |
* as a return value of non-zero is used to flag it as a temporary kline |
1395 |
> |
* i.e. they specifically use 0, I am going to return 1 instead as a return |
1396 |
> |
* value of non-zero is used to flag it as a temporary kline |
1397 |
|
*/ |
1398 |
|
if (result == 0) |
1399 |
|
result = 1; |
1408 |
|
if (result > MAX_TDKLINE_TIME) |
1409 |
|
result = MAX_TDKLINE_TIME; |
1410 |
|
|
1411 |
< |
result = result * 60; /* turn it into seconds */ |
1411 |
> |
result = result * 60; /* Turn it into seconds */ |
1412 |
|
|
1413 |
|
return result; |
1414 |
|
} |
1424 |
|
{ |
1425 |
|
const unsigned char *p = (const unsigned char *)data; |
1426 |
|
unsigned char tmpch = '\0'; |
1427 |
< |
unsigned int nonwild = 0; |
1427 |
> |
unsigned int nonwild = 0, wild = 0; |
1428 |
|
|
1429 |
|
while ((tmpch = *p++)) |
1430 |
|
{ |
1439 |
|
if (++nonwild >= ConfigGeneral.min_nonwildcard_simple) |
1440 |
|
return 1; |
1441 |
|
} |
1442 |
+ |
else |
1443 |
+ |
++wild; |
1444 |
|
} |
1445 |
|
|
1446 |
< |
return 0; |
1446 |
> |
return !wild; |
1447 |
|
} |
1448 |
|
|
1449 |
|
/* valid_wild_card() |
1455 |
|
* side effects - NOTICE is given to source_p if warn is 1 |
1456 |
|
*/ |
1457 |
|
int |
1458 |
< |
valid_wild_card(struct Client *source_p, int warn, int count, ...) |
1458 |
> |
valid_wild_card(struct Client *source_p, int count, ...) |
1459 |
|
{ |
1460 |
|
unsigned char tmpch = '\0'; |
1461 |
|
unsigned int nonwild = 0; |
1498 |
|
} |
1499 |
|
} |
1500 |
|
|
1501 |
< |
if (warn) |
1501 |
> |
if (IsClient(source_p)) |
1502 |
|
sendto_one_notice(source_p, &me, |
1503 |
|
":Please include at least %u non-wildcard characters with the mask", |
1504 |
|
ConfigGeneral.min_nonwildcard); |
1517 |
|
*/ |
1518 |
|
static int |
1519 |
|
find_user_host(struct Client *source_p, char *user_host_or_nick, |
1520 |
< |
char *luser, char *lhost, unsigned int flags) |
1520 |
> |
char *luser, char *lhost) |
1521 |
|
{ |
1522 |
|
struct Client *target_p = NULL; |
1523 |
|
char *hostp = NULL; |
1562 |
|
find_chasing(source_p, user_host_or_nick)) == NULL) |
1563 |
|
return 0; /* find_chasing sends ERR_NOSUCHNICK */ |
1564 |
|
|
1565 |
< |
if (IsExemptKline(target_p)) |
1565 |
> |
if (HasFlag(target_p, FLAGS_EXEMPTKLINE)) |
1566 |
|
{ |
1567 |
|
if (IsClient(source_p)) |
1568 |
|
sendto_one_notice(source_p, &me, ":%s is E-lined", target_p->name); |
1570 |
|
} |
1571 |
|
|
1572 |
|
/* |
1573 |
< |
* turn the "user" bit into "*user", blow away '~' |
1573 |
> |
* Turn the "user" bit into "*user", blow away '~' |
1574 |
|
* if found in original user name (non-idented) |
1575 |
|
*/ |
1576 |
|
strlcpy(luser, target_p->username, USERLEN*4 + 1); |
1602 |
|
* - pointer to target_server to parse into if non NULL |
1603 |
|
* - pointer to reason to parse into |
1604 |
|
* |
1605 |
< |
* output - 1 if valid, -1 if not valid |
1605 |
> |
* output - 1 if valid, 0 if not valid |
1606 |
|
* side effects - A generalised k/d/x etc. line parser, |
1607 |
|
* "ALINE [time] user@host|string [ON] target :reason" |
1608 |
|
* will parse returning a parsed user, host if |
1625 |
|
char **target_server, char **reason) |
1626 |
|
{ |
1627 |
|
int found_tkline_time=0; |
1628 |
< |
static char def_reason[] = CONF_NOREASON; |
1628 |
> |
static char default_reason[] = CONF_NOREASON; |
1629 |
|
static char user[USERLEN*4+1]; |
1630 |
|
static char host[HOSTLEN*4+1]; |
1631 |
|
|
1644 |
|
else |
1645 |
|
{ |
1646 |
|
sendto_one_notice(source_p, &me, ":temp_line not supported by %s", cmd); |
1647 |
< |
return -1; |
1647 |
> |
return 0; |
1648 |
|
} |
1649 |
|
} |
1650 |
|
|
1651 |
|
if (parc == 0) |
1652 |
|
{ |
1653 |
|
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd); |
1654 |
< |
return -1; |
1654 |
> |
return 0; |
1655 |
|
} |
1656 |
|
|
1657 |
|
if (h_p == NULL) |
1658 |
|
*up_p = *parv; |
1659 |
|
else |
1660 |
|
{ |
1661 |
< |
if (find_user_host(source_p, *parv, user, host, parse_flags) == 0) |
1662 |
< |
return -1; |
1661 |
> |
if (find_user_host(source_p, *parv, user, host) == 0) |
1662 |
> |
return 0; |
1663 |
|
|
1664 |
|
*up_p = user; |
1665 |
|
*h_p = host; |
1675 |
|
parc--; |
1676 |
|
parv++; |
1677 |
|
|
1704 |
– |
if (target_server == NULL) |
1705 |
– |
{ |
1706 |
– |
sendto_one_notice(source_p, &me, ":ON server not supported by %s", cmd); |
1707 |
– |
return -1; |
1708 |
– |
} |
1709 |
– |
|
1678 |
|
if (!HasOFlag(source_p, OPER_FLAG_REMOTEBAN)) |
1679 |
|
{ |
1680 |
|
sendto_one_numeric(source_p, &me, ERR_NOPRIVS, "remoteban"); |
1681 |
< |
return -1; |
1681 |
> |
return 0; |
1682 |
|
} |
1683 |
|
|
1684 |
|
if (parc == 0 || EmptyString(*parv)) |
1685 |
|
{ |
1686 |
|
sendto_one_numeric(source_p, &me, ERR_NEEDMOREPARAMS, cmd); |
1687 |
< |
return -1; |
1687 |
> |
return 0; |
1688 |
|
} |
1689 |
|
|
1690 |
|
*target_server = *parv; |
1706 |
|
if (strchr(user, '!')) |
1707 |
|
{ |
1708 |
|
sendto_one_notice(source_p, &me, ":Invalid character '!' in kline"); |
1709 |
< |
return -1; |
1709 |
> |
return 0; |
1710 |
|
} |
1711 |
|
|
1712 |
< |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 2, *up_p, *h_p)) |
1713 |
< |
return -1; |
1712 |
> |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, 2, *up_p, *h_p)) |
1713 |
> |
return 0; |
1714 |
|
} |
1715 |
|
else |
1716 |
< |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, 1, *up_p)) |
1717 |
< |
return -1; |
1716 |
> |
if ((parse_flags & AWILD) && !valid_wild_card(source_p, 1, *up_p)) |
1717 |
> |
return 0; |
1718 |
|
|
1719 |
|
if (reason) |
1720 |
|
{ |
1721 |
|
if (parc && !EmptyString(*parv)) |
1754 |
– |
{ |
1722 |
|
*reason = *parv; |
1756 |
– |
|
1757 |
– |
if (!valid_comment(source_p, *reason, 1)) |
1758 |
– |
return -1; |
1759 |
– |
} |
1723 |
|
else |
1724 |
< |
*reason = def_reason; |
1724 |
> |
*reason = default_reason; |
1725 |
|
} |
1726 |
|
|
1727 |
|
return 1; |
1728 |
|
} |
1729 |
|
|
1767 |
– |
/* valid_comment() |
1768 |
– |
* |
1769 |
– |
* inputs - pointer to client |
1770 |
– |
* - pointer to comment |
1771 |
– |
* output - 0 if no valid comment, |
1772 |
– |
* - 1 if valid |
1773 |
– |
* side effects - truncates reason where necessary |
1774 |
– |
*/ |
1775 |
– |
int |
1776 |
– |
valid_comment(struct Client *source_p, char *comment, int warn) |
1777 |
– |
{ |
1778 |
– |
if (strlen(comment) > REASONLEN) |
1779 |
– |
comment[REASONLEN-1] = '\0'; |
1780 |
– |
|
1781 |
– |
return 1; |
1782 |
– |
} |
1783 |
– |
|
1730 |
|
/* match_conf_password() |
1731 |
|
* |
1732 |
|
* inputs - pointer to given password |
1755 |
|
* |
1756 |
|
* inputs - client sending the cluster |
1757 |
|
* - command name "KLINE" "XLINE" etc. |
1758 |
< |
* - capab -- CAP_KLN etc. from server.h |
1758 |
> |
* - capab -- CAPAB_KLN etc. from server.h |
1759 |
|
* - cluster type -- CLUSTER_KLINE etc. from conf.h |
1760 |
|
* - pattern and args to send along |
1761 |
|
* output - none |
1763 |
|
* along to all servers that match capab and cluster type |
1764 |
|
*/ |
1765 |
|
void |
1766 |
< |
cluster_a_line(struct Client *source_p, const char *command, |
1767 |
< |
int capab, int cluster_type, const char *pattern, ...) |
1766 |
> |
cluster_a_line(struct Client *source_p, const char *command, unsigned int capab, |
1767 |
> |
unsigned int cluster_type, const char *pattern, ...) |
1768 |
|
{ |
1769 |
|
va_list args; |
1770 |
|
char buffer[IRCD_BUFSIZE] = ""; |
1779 |
|
const struct MaskItem *conf = node->data; |
1780 |
|
|
1781 |
|
if (conf->flags & cluster_type) |
1782 |
< |
sendto_match_servs(source_p, conf->name, CAP_CLUSTER|capab, |
1782 |
> |
sendto_match_servs(source_p, conf->name, CAPAB_CLUSTER | capab, |
1783 |
|
"%s %s %s", command, conf->name, buffer); |
1784 |
|
} |
1785 |
|
} |
1865 |
|
} |
1866 |
|
else |
1867 |
|
{ |
1868 |
< |
/* no @ found */ |
1868 |
> |
/* No @ found */ |
1869 |
|
if (!iptr->nickptr || strpbrk(iptr->nuhmask, ".:")) |
1870 |
|
strlcpy(iptr->hostptr, iptr->nuhmask, iptr->hostsize); |
1871 |
|
else |