2 * ircd-ratbox: A slightly useful ircd.
3 * s_conf.c: Configuration file functions.
5 * Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
6 * Copyright (C) 1996-2002 Hybrid Development Team
7 * Copyright (C) 2002-2005 ircd-ratbox development team
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
26 #include "ircd_defs.h"
29 #include "s_newconf.h"
47 #include "privilege.h"
56 #include "supported.h"
58 struct config_server_hide ConfigServerHide
;
60 extern int yyparse(void); /* defined in y.tab.c */
61 extern char yy_linebuf
[16384]; /* defined in ircd_lexer.l */
63 static rb_bh
*confitem_heap
= NULL
;
65 rb_dlink_list temp_klines
[LAST_TEMP_TYPE
];
66 rb_dlink_list temp_dlines
[LAST_TEMP_TYPE
];
67 rb_dlink_list service_list
;
69 rb_dictionary
*prop_bans_dict
;
71 /* internally defined functions */
72 static void set_default_conf(void);
73 static void validate_conf(void);
74 static void read_conf(void);
75 static void clear_out_old_conf(void);
77 static void expire_prop_bans(void *);
78 static void expire_temp_kd(void *list
);
79 static void reorganise_temp_kd(void *list
);
81 static int cmp_prop_ban(const void *, const void *);
86 static int verify_access(struct Client
*client_p
, const char *username
);
87 static struct ConfItem
*find_address_conf_by_client(struct Client
*client_p
, const char *username
);
88 static int attach_iline(struct Client
*, struct ConfItem
*);
93 confitem_heap
= rb_bh_create(sizeof(struct ConfItem
), CONFITEM_HEAP_SIZE
, "confitem_heap");
94 prop_bans_dict
= rb_dictionary_create("prop_bans", cmp_prop_ban
);
96 rb_event_addish("expire_prop_bans", expire_prop_bans
, NULL
, 60);
98 rb_event_addish("expire_temp_klines", expire_temp_kd
, &temp_klines
[TEMP_MIN
], 60);
99 rb_event_addish("expire_temp_dlines", expire_temp_kd
, &temp_dlines
[TEMP_MIN
], 60);
101 rb_event_addish("expire_temp_klines_hour", reorganise_temp_kd
,
102 &temp_klines
[TEMP_HOUR
], 3600);
103 rb_event_addish("expire_temp_dlines_hour", reorganise_temp_kd
,
104 &temp_dlines
[TEMP_HOUR
], 3600);
105 rb_event_addish("expire_temp_klines_day", reorganise_temp_kd
,
106 &temp_klines
[TEMP_DAY
], 86400);
107 rb_event_addish("expire_temp_dlines_day", reorganise_temp_kd
,
108 &temp_dlines
[TEMP_DAY
], 86400);
109 rb_event_addish("expire_temp_klines_week", reorganise_temp_kd
,
110 &temp_klines
[TEMP_WEEK
], 604800);
111 rb_event_addish("expire_temp_dlines_week", reorganise_temp_kd
,
112 &temp_dlines
[TEMP_WEEK
], 604800);
119 * output - pointer to new conf entry
120 * side effects - none
125 struct ConfItem
*aconf
;
127 aconf
= rb_bh_alloc(confitem_heap
);
128 aconf
->status
= CONF_ILLEGAL
;
135 * inputs - pointer to conf to free
137 * side effects - crucial password fields are zeroed, conf is freed
140 free_conf(struct ConfItem
*aconf
)
142 s_assert(aconf
!= NULL
);
148 memset(aconf
->passwd
, 0, strlen(aconf
->passwd
));
150 memset(aconf
->spasswd
, 0, strlen(aconf
->spasswd
));
152 rb_free(aconf
->passwd
);
153 rb_free(aconf
->spasswd
);
154 rb_free(aconf
->className
);
155 rb_free(aconf
->user
);
156 rb_free(aconf
->host
);
157 rb_free(aconf
->desc
);
160 operhash_delete(aconf
->info
.oper
);
162 rb_free(aconf
->info
.name
);
164 rb_bh_free(confitem_heap
, aconf
);
170 * inputs - pointer to client
171 * output - 0 = Success
172 * NOT_AUTHORISED (-1) = Access denied (no I line match)
173 * I_SOCKET_ERROR (-2) = Bad socket.
174 * I_LINE_FULL (-3) = I-line is full
175 * TOO_MANY (-4) = Too many connections from hostname
176 * BANNED_CLIENT (-5) = K-lined
177 * side effects - Ordinary client access check.
178 * Look for conf lines which have the same
179 * status as the flags passed.
182 check_client(struct Client
*client_p
, struct Client
*source_p
, const char *username
)
186 if((i
= verify_access(source_p
, username
)))
188 ilog(L_FUSER
, "Access denied: %s[%s]",
189 source_p
->name
, source_p
->sockhost
);
195 exit_client(client_p
, source_p
, &me
, "Socket Error");
199 /* Note that these notices are sent to opers on other
200 * servers also, so even if local opers are allowed to
201 * see the IP, we still cannot send it.
203 sendto_realops_snomask(SNO_FULL
, L_NETWIDE
,
204 "Too many local connections for %s[%s%s@%s] [%s]",
205 source_p
->name
, IsGotId(source_p
) ? "" : "~",
206 source_p
->username
, source_p
->host
,
207 show_ip(NULL
, source_p
) && !IsIPSpoof(source_p
) ? source_p
->sockhost
: "0");
209 ilog(L_FUSER
, "Too many local connections from %s!%s%s@%s",
210 source_p
->name
, IsGotId(source_p
) ? "" : "~",
211 source_p
->username
, source_p
->sockhost
);
213 ServerStats
.is_ref
++;
214 exit_client(client_p
, source_p
, &me
, "Too many host connections (local)");
217 case TOO_MANY_GLOBAL
:
218 sendto_realops_snomask(SNO_FULL
, L_NETWIDE
,
219 "Too many global connections for %s[%s%s@%s] [%s]",
220 source_p
->name
, IsGotId(source_p
) ? "" : "~",
221 source_p
->username
, source_p
->host
,
222 show_ip(NULL
, source_p
) && !IsIPSpoof(source_p
) ? source_p
->sockhost
: "0");
223 ilog(L_FUSER
, "Too many global connections from %s!%s%s@%s",
224 source_p
->name
, IsGotId(source_p
) ? "" : "~",
225 source_p
->username
, source_p
->sockhost
);
227 ServerStats
.is_ref
++;
228 exit_client(client_p
, source_p
, &me
, "Too many host connections (global)");
232 sendto_realops_snomask(SNO_FULL
, L_NETWIDE
,
233 "Too many user connections for %s[%s%s@%s] [%s]",
234 source_p
->name
, IsGotId(source_p
) ? "" : "~",
235 source_p
->username
, source_p
->host
,
236 show_ip(NULL
, source_p
) && !IsIPSpoof(source_p
) ? source_p
->sockhost
: "0");
237 ilog(L_FUSER
, "Too many user connections from %s!%s%s@%s",
238 source_p
->name
, IsGotId(source_p
) ? "" : "~",
239 source_p
->username
, source_p
->sockhost
);
241 ServerStats
.is_ref
++;
242 exit_client(client_p
, source_p
, &me
, "Too many user connections (global)");
246 sendto_realops_snomask(SNO_FULL
, L_NETWIDE
,
247 "I-line is full for %s[%s%s@%s] [%s]",
248 source_p
->name
, IsGotId(source_p
) ? "" : "~",
249 source_p
->username
, source_p
->host
,
250 show_ip(NULL
, source_p
) && !IsIPSpoof(source_p
) ? source_p
->sockhost
: "0");
252 ilog(L_FUSER
, "Too many connections from %s!%s%s@%s.",
253 source_p
->name
, IsGotId(source_p
) ? "" : "~",
254 source_p
->username
, source_p
->sockhost
);
256 ServerStats
.is_ref
++;
257 exit_client(client_p
, source_p
, &me
,
258 "No more connections allowed in your connection class");
264 port
= ntohs(GET_SS_PORT(&source_p
->localClient
->listener
->addr
[0]));
266 ServerStats
.is_ref
++;
267 /* jdc - lists server name & port connections are on */
268 /* a purely cosmetical change */
269 /* why ipaddr, and not just source_p->sockhost? --fl */
271 static char ipaddr
[HOSTIPLEN
];
272 rb_inet_ntop_sock(&source_p
->localClient
->ip
, ipaddr
, sizeof(ipaddr
));
274 sendto_realops_snomask(SNO_UNAUTH
, L_NETWIDE
,
275 "Unauthorised client connection from "
276 "%s!%s%s@%s [%s] on [%s/%u].",
277 source_p
->name
, IsGotId(source_p
) ? "" : "~",
278 source_p
->username
, source_p
->host
,
280 source_p
->localClient
->listener
->name
, port
);
283 "Unauthorised client connection from %s!%s%s@%s on [%s/%u].",
284 source_p
->name
, IsGotId(source_p
) ? "" : "~",
285 source_p
->username
, source_p
->sockhost
,
286 source_p
->localClient
->listener
->name
, port
);
287 add_reject(client_p
, NULL
, NULL
, NULL
, "You are not authorised to use this server.");
288 exit_client(client_p
, source_p
, &me
, "You are not authorised to use this server.");
292 exit_client(client_p
, client_p
, &me
, "*** Banned ");
293 ServerStats
.is_ref
++;
306 * inputs - pointer to client to verify
307 * - pointer to proposed username
308 * output - 0 if success -'ve if not
309 * side effect - find the first (best) I line to attach.
312 verify_access(struct Client
*client_p
, const char *username
)
314 struct ConfItem
*aconf
;
316 aconf
= find_address_conf_by_client(client_p
, username
);
318 return NOT_AUTHORISED
;
320 if(aconf
->status
& CONF_CLIENT
)
322 if(aconf
->flags
& CONF_FLAGS_REDIR
)
324 sendto_one_numeric(client_p
, RPL_REDIR
, form_str(RPL_REDIR
),
325 aconf
->info
.name
? aconf
->info
.name
: "", aconf
->port
);
326 return (NOT_AUTHORISED
);
329 /* Thanks for spoof idea amm */
330 if(IsConfDoSpoofIp(aconf
))
334 /* show_ip() depends on this --fl */
335 SetIPSpoof(client_p
);
337 if(IsConfSpoofNotice(aconf
))
339 sendto_realops_snomask(SNO_GENERAL
, L_NETWIDE
,
340 "%s spoofing: %s as %s",
342 show_ip(NULL
, client_p
) ? client_p
->host
: aconf
->info
.name
,
346 /* user@host spoof */
347 if((p
= strchr(aconf
->info
.name
, '@')) != NULL
)
352 rb_strlcpy(client_p
->username
, aconf
->info
.name
,
353 sizeof(client_p
->username
));
354 rb_strlcpy(client_p
->host
, host
,
355 sizeof(client_p
->host
));
359 rb_strlcpy(client_p
->host
, aconf
->info
.name
, sizeof(client_p
->host
));
361 return (attach_iline(client_p
, aconf
));
363 else if(aconf
->status
& CONF_KILL
)
365 if(ConfigFileEntry
.kline_with_reason
)
367 form_str(ERR_YOUREBANNEDCREEP
),
368 me
.name
, client_p
->name
,
369 get_user_ban_reason(aconf
));
371 sendto_realops_snomask(SNO_BANNED
, L_NETWIDE
,
372 "Rejecting K-Lined user %s [%s] (%s@%s)", get_client_name(client_p
, HIDE_IP
),
373 show_ip(NULL
, client_p
) ? client_p
->sockhost
: "255.255.255.255", aconf
->user
, aconf
->host
);
374 add_reject(client_p
, aconf
->user
, aconf
->host
, aconf
, NULL
);
375 return (BANNED_CLIENT
);
378 return NOT_AUTHORISED
;
383 * find_address_conf_by_client
385 static struct ConfItem
*
386 find_address_conf_by_client(struct Client
*client_p
, const char *username
)
388 struct ConfItem
*aconf
;
389 char non_ident
[USERLEN
+ 1];
391 if(IsGotId(client_p
))
393 aconf
= find_address_conf(client_p
->host
, client_p
->sockhost
,
394 client_p
->username
, client_p
->username
,
395 (struct sockaddr
*) &client_p
->localClient
->ip
,
396 GET_SS_FAMILY(&client_p
->localClient
->ip
),
397 client_p
->localClient
->auth_user
);
401 rb_strlcpy(non_ident
, "~", sizeof(non_ident
));
402 rb_strlcat(non_ident
, username
, sizeof(non_ident
));
403 aconf
= find_address_conf(client_p
->host
, client_p
->sockhost
,
404 non_ident
, client_p
->username
,
405 (struct sockaddr
*) &client_p
->localClient
->ip
,
406 GET_SS_FAMILY(&client_p
->localClient
->ip
),
407 client_p
->localClient
->auth_user
);
416 * Returns 1 if successful 0 if not
418 * This checks if the user has exceed the limits for their class
419 * unless of course they are exempt..
423 add_ip_limit(struct Client
*client_p
, struct ConfItem
*aconf
)
425 rb_patricia_node_t
*pnode
;
428 /* If the limits are 0 don't do anything.. */
429 if(ConfCidrAmount(aconf
) == 0
430 || (ConfCidrIpv4Bitlen(aconf
) == 0 && ConfCidrIpv6Bitlen(aconf
) == 0))
433 pnode
= rb_match_ip(ConfIpLimits(aconf
), (struct sockaddr
*)&client_p
->localClient
->ip
);
435 if(GET_SS_FAMILY(&client_p
->localClient
->ip
) == AF_INET
)
436 bitlen
= ConfCidrIpv4Bitlen(aconf
);
438 bitlen
= ConfCidrIpv6Bitlen(aconf
);
441 pnode
= make_and_lookup_ip(ConfIpLimits(aconf
), (struct sockaddr
*)&client_p
->localClient
->ip
, bitlen
);
443 s_assert(pnode
!= NULL
);
447 if(((intptr_t)pnode
->data
) >= ConfCidrAmount(aconf
) && !IsConfExemptLimits(aconf
))
449 /* This should only happen if the limits are set to 0 */
450 if((intptr_t)pnode
->data
== 0)
452 rb_patricia_remove(ConfIpLimits(aconf
), pnode
);
457 pnode
->data
= (void *)(((intptr_t)pnode
->data
) + 1);
463 remove_ip_limit(struct Client
*client_p
, struct ConfItem
*aconf
)
465 rb_patricia_node_t
*pnode
;
467 /* If the limits are 0 don't do anything.. */
468 if(ConfCidrAmount(aconf
) == 0
469 || (ConfCidrIpv4Bitlen(aconf
) == 0 && ConfCidrIpv6Bitlen(aconf
) == 0))
472 pnode
= rb_match_ip(ConfIpLimits(aconf
), (struct sockaddr
*)&client_p
->localClient
->ip
);
476 pnode
->data
= (void *)(((intptr_t)pnode
->data
) - 1);
477 if(((intptr_t)pnode
->data
) == 0)
479 rb_patricia_remove(ConfIpLimits(aconf
), pnode
);
487 * inputs - client pointer
490 * side effects - do actual attach
493 attach_iline(struct Client
*client_p
, struct ConfItem
*aconf
)
495 struct Client
*target_p
;
498 int global_count
= 0;
502 if(IsConfExemptLimits(aconf
))
503 return (attach_conf(client_p
, aconf
));
505 unidented
= !IsGotId(client_p
) && !IsNoTilde(aconf
) &&
506 (!IsConfDoSpoofIp(aconf
) || !strchr(aconf
->info
.name
, '@'));
508 /* find_hostname() returns the head of the list to search */
509 RB_DLINK_FOREACH(ptr
, find_hostname(client_p
->host
))
511 target_p
= ptr
->data
;
513 if(irccmp(client_p
->host
, target_p
->orighost
) != 0)
516 if(MyConnect(target_p
))
523 if(*target_p
->username
== '~')
526 else if(irccmp(target_p
->username
, client_p
->username
) == 0)
529 if(ConfMaxLocal(aconf
) && local_count
>= ConfMaxLocal(aconf
))
530 return (TOO_MANY_LOCAL
);
531 else if(ConfMaxGlobal(aconf
) && global_count
>= ConfMaxGlobal(aconf
))
532 return (TOO_MANY_GLOBAL
);
533 else if(ConfMaxIdent(aconf
) && ident_count
>= ConfMaxIdent(aconf
))
534 return (TOO_MANY_IDENT
);
538 return (attach_conf(client_p
, aconf
));
544 * inputs - ConfItem that is referenced by something other than a client
545 * side effects - Decrement and free ConfItem if appropriate
548 deref_conf(struct ConfItem
*aconf
)
551 if(!aconf
->clients
&& IsIllegal(aconf
) && !lookup_prop_ban(aconf
))
558 * inputs - pointer to client to detach
559 * output - 0 for success, -1 for failure
560 * side effects - Disassociate configuration from the client.
561 * Also removes a class from the list if marked for deleting.
564 detach_conf(struct Client
*client_p
)
566 struct ConfItem
*aconf
;
568 aconf
= client_p
->localClient
->att_conf
;
574 remove_ip_limit(client_p
, aconf
);
576 if(ConfCurrUsers(aconf
) > 0)
577 --ConfCurrUsers(aconf
);
579 if(ConfMaxUsers(aconf
) == -1 && ConfCurrUsers(aconf
) == 0)
581 free_class(ClassPtr(aconf
));
582 ClassPtr(aconf
) = NULL
;
588 if(!aconf
->clients
&& IsIllegal(aconf
))
591 client_p
->localClient
->att_conf
= NULL
;
601 * inputs - client pointer
604 * side effects - Associate a specific configuration entry to a *local*
605 * client (this is the one which used in accepting the
606 * connection). Note, that this automatically changes the
607 * attachment if there was an old one...
610 attach_conf(struct Client
*client_p
, struct ConfItem
*aconf
)
613 return (NOT_AUTHORISED
);
615 if(s_assert(ClassPtr(aconf
)))
616 return (NOT_AUTHORISED
);
618 if(!add_ip_limit(client_p
, aconf
))
619 return (TOO_MANY_LOCAL
);
621 if((aconf
->status
& CONF_CLIENT
) &&
622 ConfCurrUsers(aconf
) >= ConfMaxUsers(aconf
) && ConfMaxUsers(aconf
) > 0)
624 if(!IsConfExemptLimits(aconf
))
626 return (I_LINE_FULL
);
630 sendto_one_notice(client_p
, ":*** I: line is full, but you have an >I: line!");
635 if(client_p
->localClient
->att_conf
!= NULL
)
636 detach_conf(client_p
);
638 client_p
->localClient
->att_conf
= aconf
;
641 ConfCurrUsers(aconf
)++;
648 * Actual REHASH service routine. Called with sig == 0 if it has been called
649 * as a result of an operator issuing this command, else assume it has been
650 * called as a result of the server receiving a HUP signal.
657 hook_data_rehash hdata
= { sig
};
660 sendto_realops_snomask(SNO_GENERAL
, L_NETWIDE
,
661 "Got signal SIGHUP, reloading ircd conf. file");
665 privilegeset_prepare_rehash();
667 /* don't close listeners until we know we can go ahead with the rehash */
668 read_conf_files(false);
670 if(ServerInfo
.description
!= NULL
)
671 rb_strlcpy(me
.info
, ServerInfo
.description
, sizeof(me
.info
));
673 rb_strlcpy(me
.info
, "unknown", sizeof(me
.info
));
677 RB_DLINK_FOREACH(n
, local_oper_list
.head
)
679 struct Client
*oper
= n
->data
;
680 struct PrivilegeSet
*privset
= oper
->user
->privset
;
681 report_priv_change(oper
, privset
? privset
->shadow
: NULL
, privset
);
684 privilegeset_cleanup_rehash();
686 call_hook(h_rehash
, &hdata
);
701 * side effects - Set default values here.
702 * This is called **PRIOR** to parsing the
703 * configuration file. If you want to do some validation
704 * of values later, put them in validate_conf().
708 set_default_conf(void)
710 /* ServerInfo.name is not rehashable */
711 /* ServerInfo.name = ServerInfo.name; */
712 ServerInfo
.description
= NULL
;
713 ServerInfo
.network_name
= NULL
;
715 memset(&ServerInfo
.bind4
, 0, sizeof(ServerInfo
.bind4
));
716 SET_SS_FAMILY(&ServerInfo
.bind4
, AF_UNSPEC
);
717 memset(&ServerInfo
.bind6
, 0, sizeof(ServerInfo
.bind6
));
718 SET_SS_FAMILY(&ServerInfo
.bind6
, AF_UNSPEC
);
720 AdminInfo
.name
= NULL
;
721 AdminInfo
.email
= NULL
;
722 AdminInfo
.description
= NULL
;
724 ConfigFileEntry
.default_operstring
= NULL
;
725 ConfigFileEntry
.default_adminstring
= NULL
;
726 ConfigFileEntry
.servicestring
= NULL
;
727 ConfigFileEntry
.sasl_service
= NULL
;
729 ConfigFileEntry
.default_umodes
= UMODE_INVISIBLE
;
730 ConfigFileEntry
.failed_oper_notice
= true;
731 ConfigFileEntry
.anti_nick_flood
= false;
732 ConfigFileEntry
.disable_fake_channels
= false;
733 ConfigFileEntry
.max_nick_time
= 20;
734 ConfigFileEntry
.max_nick_changes
= 5;
735 ConfigFileEntry
.max_accept
= 20;
736 ConfigFileEntry
.max_monitor
= 60;
737 ConfigFileEntry
.nick_delay
= 900; /* 15 minutes */
738 ConfigFileEntry
.target_change
= true;
739 ConfigFileEntry
.anti_spam_exit_message_time
= 0;
740 ConfigFileEntry
.ts_warn_delta
= TS_WARN_DELTA_DEFAULT
;
741 ConfigFileEntry
.ts_max_delta
= TS_MAX_DELTA_DEFAULT
;
742 ConfigFileEntry
.client_exit
= true;
743 ConfigFileEntry
.dline_with_reason
= true;
744 ConfigFileEntry
.kline_with_reason
= true;
745 ConfigFileEntry
.warn_no_nline
= true;
746 ConfigFileEntry
.non_redundant_klines
= true;
747 ConfigFileEntry
.stats_e_disabled
= false;
748 ConfigFileEntry
.stats_o_oper_only
= false;
749 ConfigFileEntry
.stats_k_oper_only
= 1; /* masked */
750 ConfigFileEntry
.stats_l_oper_only
= 1; /* self */
751 ConfigFileEntry
.stats_i_oper_only
= 1; /* masked */
752 ConfigFileEntry
.stats_P_oper_only
= false;
753 ConfigFileEntry
.stats_c_oper_only
= false;
754 ConfigFileEntry
.stats_y_oper_only
= false;
755 ConfigFileEntry
.map_oper_only
= true;
756 ConfigFileEntry
.operspy_admin_only
= false;
757 ConfigFileEntry
.pace_wait
= 10;
758 ConfigFileEntry
.caller_id_wait
= 60;
759 ConfigFileEntry
.pace_wait_simple
= 1;
760 ConfigFileEntry
.short_motd
= false;
761 ConfigFileEntry
.no_oper_flood
= false;
762 ConfigFileEntry
.fname_userlog
= NULL
;
763 ConfigFileEntry
.fname_fuserlog
= NULL
;
764 ConfigFileEntry
.fname_operlog
= NULL
;
765 ConfigFileEntry
.fname_foperlog
= NULL
;
766 ConfigFileEntry
.fname_serverlog
= NULL
;
767 ConfigFileEntry
.fname_killlog
= NULL
;
768 ConfigFileEntry
.fname_klinelog
= NULL
;
769 ConfigFileEntry
.fname_operspylog
= NULL
;
770 ConfigFileEntry
.fname_ioerrorlog
= NULL
;
771 ConfigFileEntry
.hide_spoof_ips
= true;
772 ConfigFileEntry
.hide_error_messages
= 1;
773 ConfigFileEntry
.dots_in_ident
= 0;
774 ConfigFileEntry
.max_targets
= MAX_TARGETS_DEFAULT
;
775 ConfigFileEntry
.use_whois_actually
= true;
776 ConfigFileEntry
.burst_away
= false;
777 ConfigFileEntry
.collision_fnc
= true;
778 ConfigFileEntry
.resv_fnc
= true;
779 ConfigFileEntry
.global_snotices
= true;
780 ConfigFileEntry
.operspy_dont_care_user_info
= false;
781 ConfigFileEntry
.use_propagated_bans
= true;
782 ConfigFileEntry
.max_ratelimit_tokens
= 30;
783 ConfigFileEntry
.away_interval
= 30;
784 ConfigFileEntry
.tls_ciphers_oper_only
= false;
785 ConfigFileEntry
.oper_secure_only
= false;
787 ConfigFileEntry
.oper_umodes
= UMODE_LOCOPS
| UMODE_SERVNOTICE
|
788 UMODE_OPERWALL
| UMODE_WALLOP
;
789 ConfigFileEntry
.oper_only_umodes
= UMODE_SERVNOTICE
;
790 ConfigFileEntry
.oper_snomask
= SNO_GENERAL
;
792 ConfigChannel
.use_except
= true;
793 ConfigChannel
.use_invex
= true;
794 ConfigChannel
.use_forward
= true;
795 ConfigChannel
.use_knock
= true;
796 ConfigChannel
.knock_delay
= 300;
797 ConfigChannel
.knock_delay_channel
= 60;
798 ConfigChannel
.max_chans_per_user
= 15;
799 ConfigChannel
.max_chans_per_user_large
= 60;
800 ConfigChannel
.max_bans
= 25;
801 ConfigChannel
.max_bans_large
= 500;
802 ConfigChannel
.only_ascii_channels
= false;
803 ConfigChannel
.burst_topicwho
= false;
804 ConfigChannel
.kick_on_split_riding
= false;
806 ConfigChannel
.default_split_user_count
= 15000;
807 ConfigChannel
.default_split_server_count
= 10;
808 ConfigChannel
.no_join_on_split
= false;
809 ConfigChannel
.no_create_on_split
= true;
810 ConfigChannel
.resv_forcepart
= true;
811 ConfigChannel
.channel_target_change
= true;
812 ConfigChannel
.disable_local_channels
= false;
813 ConfigChannel
.displayed_usercount
= 3;
814 ConfigChannel
.opmod_send_statusmsg
= false;
815 ConfigChannel
.ip_bans_through_vhost
= true;
817 ConfigChannel
.autochanmodes
= MODE_TOPICLIMIT
| MODE_NOPRIVMSGS
;
819 ConfigServerHide
.flatten_links
= 0;
820 ConfigServerHide
.links_delay
= 300;
821 ConfigServerHide
.hidden
= 0;
822 ConfigServerHide
.disable_hidden
= 0;
824 ConfigFileEntry
.min_nonwildcard
= 4;
825 ConfigFileEntry
.min_nonwildcard_simple
= 3;
826 ConfigFileEntry
.default_floodcount
= 8;
827 ConfigFileEntry
.default_ident_timeout
= IDENT_TIMEOUT_DEFAULT
;
828 ConfigFileEntry
.tkline_expire_notices
= 0;
830 ConfigFileEntry
.reject_after_count
= 5;
831 ConfigFileEntry
.reject_ban_time
= 300;
832 ConfigFileEntry
.reject_duration
= 120;
833 ConfigFileEntry
.throttle_count
= 4;
834 ConfigFileEntry
.throttle_duration
= 60;
836 ConfigFileEntry
.client_flood_max_lines
= CLIENT_FLOOD_DEFAULT
;
837 ConfigFileEntry
.client_flood_burst_rate
= 5;
838 ConfigFileEntry
.client_flood_burst_max
= 5;
839 ConfigFileEntry
.client_flood_message_time
= 1;
840 ConfigFileEntry
.client_flood_message_num
= 2;
842 ServerInfo
.default_max_clients
= MAXCONNECTIONS
;
844 ConfigFileEntry
.nicklen
= NICKLEN
;
845 ConfigFileEntry
.certfp_method
= RB_SSL_CERTFP_METH_CERT_SHA1
;
846 ConfigFileEntry
.hide_opers_in_whois
= 0;
847 ConfigFileEntry
.hide_opers
= 0;
850 alias_dict
= rb_dictionary_create("alias", rb_strcasecmp
);
859 * side effects - Read configuration file.
866 set_default_conf(); /* Set default values prior to conf parsing */
867 yyparse(); /* Load the values from the conf */
868 validate_conf(); /* Check to make sure some values are still okay. */
869 /* Some global values are also loaded here. */
870 check_class(); /* Make sure classes are valid */
871 construct_cflags_strings();
877 if(ConfigFileEntry
.default_ident_timeout
< 1)
878 ConfigFileEntry
.default_ident_timeout
= IDENT_TIMEOUT_DEFAULT
;
880 if(ConfigFileEntry
.ts_warn_delta
< TS_WARN_DELTA_MIN
)
881 ConfigFileEntry
.ts_warn_delta
= TS_WARN_DELTA_DEFAULT
;
883 if(ConfigFileEntry
.ts_max_delta
< TS_MAX_DELTA_MIN
)
884 ConfigFileEntry
.ts_max_delta
= TS_MAX_DELTA_DEFAULT
;
886 if(ServerInfo
.network_name
== NULL
)
887 ServerInfo
.network_name
= rb_strdup(NETWORK_NAME_DEFAULT
);
889 if(ServerInfo
.ssld_count
< 1)
890 ServerInfo
.ssld_count
= 1;
892 /* XXX: configurable? */
893 ServerInfo
.wsockd_count
= 1;
895 if(!rb_setup_ssl_server(ServerInfo
.ssl_cert
, ServerInfo
.ssl_private_key
, ServerInfo
.ssl_dh_params
, ServerInfo
.ssl_cipher_list
))
897 ilog(L_MAIN
, "WARNING: Unable to setup SSL.");
901 ssld_update_config();
904 if(ServerInfo
.ssld_count
> get_ssld_count())
906 int start
= ServerInfo
.ssld_count
- get_ssld_count();
907 /* start up additional ssld if needed */
908 start_ssldaemon(start
);
911 if(ServerInfo
.wsockd_count
> get_wsockd_count())
913 int start
= ServerInfo
.wsockd_count
- get_wsockd_count();
918 if (ConfigFileEntry
.default_operstring
== NULL
)
919 ConfigFileEntry
.default_operstring
= rb_strdup("is an IRC operator");
921 if (ConfigFileEntry
.default_adminstring
== NULL
)
922 ConfigFileEntry
.default_adminstring
= rb_strdup("is a Server Administrator");
924 if (ConfigFileEntry
.servicestring
== NULL
)
925 ConfigFileEntry
.servicestring
= rb_strdup("is a Network Service");
927 if (ConfigFileEntry
.sasl_service
== NULL
)
928 ConfigFileEntry
.sasl_service
= rb_strdup("SaslServ");
930 /* RFC 1459 says 1 message per 2 seconds on average and bursts of
931 * 5 messages are acceptable, so allow at least that.
933 if(ConfigFileEntry
.client_flood_burst_rate
< 5)
934 ConfigFileEntry
.client_flood_burst_rate
= 5;
935 if(ConfigFileEntry
.client_flood_burst_max
< 5)
936 ConfigFileEntry
.client_flood_burst_max
= 5;
937 if(ConfigFileEntry
.client_flood_message_time
>
938 ConfigFileEntry
.client_flood_message_num
* 2)
939 ConfigFileEntry
.client_flood_message_time
=
940 ConfigFileEntry
.client_flood_message_num
* 2;
942 if((ConfigFileEntry
.client_flood_max_lines
< CLIENT_FLOOD_MIN
) ||
943 (ConfigFileEntry
.client_flood_max_lines
> CLIENT_FLOOD_MAX
))
944 ConfigFileEntry
.client_flood_max_lines
= CLIENT_FLOOD_MAX
;
946 if(!split_users
|| !split_servers
||
947 (!ConfigChannel
.no_create_on_split
&& !ConfigChannel
.no_join_on_split
))
949 rb_event_delete(check_splitmode_ev
);
950 check_splitmode_ev
= NULL
;
955 CharAttrs
['&'] |= CHANPFX_C
;
956 if (ConfigChannel
.disable_local_channels
)
957 CharAttrs
['&'] &= ~CHANPFX_C
;
964 * inputs - pointer to struct ConfItem
966 * Side effects - links in given struct ConfItem into
967 * temporary kline link list
970 add_temp_kline(struct ConfItem
*aconf
)
972 if(aconf
->hold
>= rb_current_time() + (10080 * 60))
974 rb_dlinkAddAlloc(aconf
, &temp_klines
[TEMP_WEEK
]);
975 aconf
->port
= TEMP_WEEK
;
977 else if(aconf
->hold
>= rb_current_time() + (1440 * 60))
979 rb_dlinkAddAlloc(aconf
, &temp_klines
[TEMP_DAY
]);
980 aconf
->port
= TEMP_DAY
;
982 else if(aconf
->hold
>= rb_current_time() + (60 * 60))
984 rb_dlinkAddAlloc(aconf
, &temp_klines
[TEMP_HOUR
]);
985 aconf
->port
= TEMP_HOUR
;
989 rb_dlinkAddAlloc(aconf
, &temp_klines
[TEMP_MIN
]);
990 aconf
->port
= TEMP_MIN
;
993 aconf
->flags
|= CONF_FLAGS_TEMPORARY
;
994 add_conf_by_address(aconf
->host
, CONF_KILL
, aconf
->user
, NULL
, aconf
);
999 * input - pointer to struct ConfItem
1001 * side effects - added to tdline link list and address hash
1004 add_temp_dline(struct ConfItem
*aconf
)
1006 if(aconf
->hold
>= rb_current_time() + (10080 * 60))
1008 rb_dlinkAddAlloc(aconf
, &temp_dlines
[TEMP_WEEK
]);
1009 aconf
->port
= TEMP_WEEK
;
1011 else if(aconf
->hold
>= rb_current_time() + (1440 * 60))
1013 rb_dlinkAddAlloc(aconf
, &temp_dlines
[TEMP_DAY
]);
1014 aconf
->port
= TEMP_DAY
;
1016 else if(aconf
->hold
>= rb_current_time() + (60 * 60))
1018 rb_dlinkAddAlloc(aconf
, &temp_dlines
[TEMP_HOUR
]);
1019 aconf
->port
= TEMP_HOUR
;
1023 rb_dlinkAddAlloc(aconf
, &temp_dlines
[TEMP_MIN
]);
1024 aconf
->port
= TEMP_MIN
;
1027 aconf
->flags
|= CONF_FLAGS_TEMPORARY
;
1028 add_conf_by_address(aconf
->host
, CONF_DLINE
, aconf
->user
, NULL
, aconf
);
1031 /* valid_wild_card()
1033 * input - user buffer, host buffer
1034 * output - 0 if invalid, 1 if valid
1038 valid_wild_card(const char *luser
, const char *lhost
)
1045 /* user has no wildcards, always accept -- jilles */
1046 if(!strchr(luser
, '?') && !strchr(luser
, '*'))
1049 /* check there are enough non wildcard chars */
1051 while((tmpch
= *p
++))
1053 if(!IsKWildChar(tmpch
))
1055 /* found enough chars, return */
1056 if(++nonwild
>= ConfigFileEntry
.min_nonwildcard
)
1061 /* try host, as user didnt contain enough */
1062 /* special case for cidr masks -- jilles */
1063 if((p
= strrchr(lhost
, '/')) != NULL
&& IsDigit(p
[1]))
1065 bitlen
= atoi(p
+ 1);
1066 /* much like non-cidr for ipv6, rather arbitrary for ipv4 */
1069 (strchr(lhost
, ':') ? 4 * (ConfigFileEntry
.min_nonwildcard
- nonwild
) : 6 -
1076 while((tmpch
= *p
++))
1078 if(!IsKWildChar(tmpch
))
1079 if(++nonwild
>= ConfigFileEntry
.min_nonwildcard
)
1088 int cmp_prop_ban(const void *a_
, const void *b_
)
1090 const struct ConfItem
*a
= a_
, *b
= b_
;
1093 if ((a
->status
& ~CONF_ILLEGAL
) > (int)(b
->status
& ~CONF_ILLEGAL
)) return 1;
1094 if ((a
->status
& ~CONF_ILLEGAL
) < (int)(b
->status
& ~CONF_ILLEGAL
)) return -1;
1096 r
= irccmp(a
->host
, b
->host
);
1099 if (a
->user
&& b
->user
)
1100 return irccmp(a
->user
, b
->user
);
1106 add_prop_ban(struct ConfItem
*aconf
)
1108 rb_dictionary_add(prop_bans_dict
, aconf
, aconf
);
1112 find_prop_ban(unsigned status
, const char *user
, const char *host
)
1114 struct ConfItem key
= {.status
= status
, .user
= (char *)user
, .host
= (char *)host
};
1115 return rb_dictionary_retrieve(prop_bans_dict
, &key
);
1119 remove_prop_ban(struct ConfItem
*aconf
)
1121 rb_dictionary_delete(prop_bans_dict
, aconf
);
1124 bool lookup_prop_ban(struct ConfItem
*aconf
)
1126 return rb_dictionary_retrieve(prop_bans_dict
, aconf
) == aconf
;
1130 deactivate_conf(struct ConfItem
*aconf
, time_t now
)
1134 switch (aconf
->status
)
1137 if (aconf
->lifetime
== 0 &&
1138 aconf
->flags
& CONF_FLAGS_TEMPORARY
)
1139 for (i
= 0; i
< LAST_TEMP_TYPE
; i
++)
1140 rb_dlinkFindDestroy(aconf
, &temp_klines
[i
]);
1141 /* Make sure delete_one_address_conf() does not
1145 delete_one_address_conf(aconf
->host
, aconf
);
1149 if (aconf
->lifetime
== 0 &&
1150 aconf
->flags
& CONF_FLAGS_TEMPORARY
)
1151 for (i
= 0; i
< LAST_TEMP_TYPE
; i
++)
1152 rb_dlinkFindDestroy(aconf
, &temp_dlines
[i
]);
1154 delete_one_address_conf(aconf
->host
, aconf
);
1158 rb_dlinkFindDestroy(aconf
, &xline_conf_list
);
1160 case CONF_RESV_NICK
:
1161 rb_dlinkFindDestroy(aconf
, &resv_conf_list
);
1163 case CONF_RESV_CHANNEL
:
1164 del_from_resv_hash(aconf
->host
, aconf
);
1167 if (aconf
->lifetime
!= 0 && now
< aconf
->lifetime
)
1169 aconf
->status
|= CONF_ILLEGAL
;
1173 if (aconf
->lifetime
!= 0)
1174 remove_prop_ban(aconf
);
1175 if (aconf
->clients
== 0)
1178 aconf
->status
|= CONF_ILLEGAL
;
1182 /* Given a new ban ConfItem, look for any matching ban, update the lifetime
1183 * from it and delete it.
1186 replace_old_ban(struct ConfItem
*aconf
)
1188 struct ConfItem
*oldconf
;
1190 oldconf
= find_prop_ban(aconf
->status
, aconf
->user
, aconf
->host
);
1191 if (oldconf
!= NULL
)
1193 /* Remember at least as long as the old one. */
1194 if(oldconf
->lifetime
> aconf
->lifetime
)
1195 aconf
->lifetime
= oldconf
->lifetime
;
1196 /* Force creation time to increase. */
1197 if(oldconf
->created
>= aconf
->created
)
1198 aconf
->created
= oldconf
->created
+ 1;
1199 /* Leave at least one second of validity. */
1200 if(aconf
->hold
<= aconf
->created
)
1201 aconf
->hold
= aconf
->created
+ 1;
1202 if(aconf
->lifetime
< aconf
->hold
)
1203 aconf
->lifetime
= aconf
->hold
;
1204 /* Tell deactivate_conf() to destroy it. */
1205 oldconf
->lifetime
= rb_current_time();
1206 deactivate_conf(oldconf
, oldconf
->lifetime
);
1211 expire_prop_bans(void *unused
)
1213 struct ConfItem
*aconf
;
1215 rb_dictionary_iter state
;
1217 now
= rb_current_time();
1219 RB_DICTIONARY_FOREACH(aconf
, &state
, prop_bans_dict
)
1221 if(aconf
->lifetime
<= now
||
1222 (aconf
->hold
<= now
&&
1223 !(aconf
->status
& CONF_ILLEGAL
)))
1225 /* Alert opers that a TKline expired - Hwy */
1226 /* XXX show what type of ban it is */
1227 if(ConfigFileEntry
.tkline_expire_notices
&&
1228 !(aconf
->status
& CONF_ILLEGAL
))
1229 sendto_realops_snomask(SNO_GENERAL
, L_ALL
,
1230 "Propagated ban for [%s%s%s] expired",
1231 aconf
->user
? aconf
->user
: "",
1232 aconf
->user
? "@" : "",
1233 aconf
->host
? aconf
->host
: "*");
1235 /* will destroy or mark illegal */
1236 deactivate_conf(aconf
, now
);
1243 * inputs - list pointer
1246 * side effects - expire tklines and moves them between lists
1249 expire_temp_kd(void *list
)
1252 rb_dlink_node
*next_ptr
;
1253 struct ConfItem
*aconf
;
1255 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, ((rb_dlink_list
*) list
)->head
)
1259 if(aconf
->hold
<= rb_current_time())
1261 /* Alert opers that a TKline expired - Hwy */
1262 if(ConfigFileEntry
.tkline_expire_notices
)
1263 sendto_realops_snomask(SNO_GENERAL
, L_ALL
,
1264 "Temporary K-line for [%s@%s] expired",
1265 (aconf
->user
) ? aconf
->
1266 user
: "*", (aconf
->host
) ? aconf
->host
: "*");
1268 delete_one_address_conf(aconf
->host
, aconf
);
1269 rb_dlinkDestroy(ptr
, list
);
1275 reorganise_temp_kd(void *list
)
1277 struct ConfItem
*aconf
;
1278 rb_dlink_node
*ptr
, *next_ptr
;
1280 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, ((rb_dlink_list
*) list
)->head
)
1284 if(aconf
->hold
< (rb_current_time() + (60 * 60)))
1286 rb_dlinkMoveNode(ptr
, list
, (aconf
->status
== CONF_KILL
) ?
1287 &temp_klines
[TEMP_MIN
] : &temp_dlines
[TEMP_MIN
]);
1288 aconf
->port
= TEMP_MIN
;
1290 else if(aconf
->port
> TEMP_HOUR
)
1292 if(aconf
->hold
< (rb_current_time() + (1440 * 60)))
1294 rb_dlinkMoveNode(ptr
, list
, (aconf
->status
== CONF_KILL
) ?
1295 &temp_klines
[TEMP_HOUR
] : &temp_dlines
[TEMP_HOUR
]);
1296 aconf
->port
= TEMP_HOUR
;
1298 else if(aconf
->port
> TEMP_DAY
&&
1299 (aconf
->hold
< (rb_current_time() + (10080 * 60))))
1301 rb_dlinkMoveNode(ptr
, list
, (aconf
->status
== CONF_KILL
) ?
1302 &temp_klines
[TEMP_DAY
] : &temp_dlines
[TEMP_DAY
]);
1303 aconf
->port
= TEMP_DAY
;
1310 /* const char* get_oper_name(struct Client *client_p)
1311 * Input: A client to find the active oper{} name for.
1312 * Output: The nick!user@host{oper} of the oper.
1313 * "oper" is server name for unknown opers
1314 * Side effects: None.
1317 get_oper_name(struct Client
*client_p
)
1319 /* +5 for !,@,{,} and null */
1320 static char buffer
[NAMELEN
+ USERLEN
+ HOSTLEN
+ MAX(HOSTLEN
, OPERNICKLEN
) + 5];
1322 const char *opername
= EmptyString(client_p
->user
->opername
)
1323 ? client_p
->servptr
->name
1324 : client_p
->user
->opername
;
1326 snprintf(buffer
, sizeof buffer
, "%s!%s@%s{%s}",
1327 client_p
->name
, client_p
->username
,
1328 client_p
->host
, opername
);
1333 * get_printable_conf
1335 * inputs - struct ConfItem
1344 * Examine the struct struct ConfItem, setting the values
1345 * of name, host, pass, user to values either
1346 * in aconf, or "<NULL>" port is set to aconf->port in all cases.
1349 get_printable_conf(struct ConfItem
*aconf
, char **name
, char **host
,
1350 const char **pass
, char **user
, int *port
,
1351 char **classname
, char **desc
)
1353 static char null
[] = "<NULL>";
1354 static char zero
[] = "default";
1356 *name
= EmptyString(aconf
->info
.name
) ? null
: aconf
->info
.name
;
1357 *host
= EmptyString(aconf
->host
) ? null
: aconf
->host
;
1358 *pass
= EmptyString(aconf
->passwd
) ? null
: aconf
->passwd
;
1359 *user
= EmptyString(aconf
->user
) ? null
: aconf
->user
;
1360 *classname
= EmptyString(aconf
->className
) ? zero
: aconf
->className
;
1361 *desc
= CheckEmpty(aconf
->desc
);
1362 *port
= (int) aconf
->port
;
1366 get_user_ban_reason(struct ConfItem
*aconf
)
1368 static char reasonbuf
[BUFSIZE
];
1370 if (!ConfigFileEntry
.hide_tkdline_duration
&&
1371 aconf
->flags
& CONF_FLAGS_TEMPORARY
&&
1372 (aconf
->status
== CONF_KILL
|| aconf
->status
== CONF_DLINE
))
1373 snprintf(reasonbuf
, sizeof reasonbuf
,
1374 "Temporary %c-line %d min. - ",
1375 aconf
->status
== CONF_DLINE
? 'D' : 'K',
1376 (int)((aconf
->hold
- aconf
->created
) / 60));
1378 reasonbuf
[0] = '\0';
1380 rb_strlcat(reasonbuf
, aconf
->passwd
, sizeof reasonbuf
);
1382 rb_strlcat(reasonbuf
, "No Reason", sizeof reasonbuf
);
1385 rb_strlcat(reasonbuf
, " (", sizeof reasonbuf
);
1386 rb_strlcat(reasonbuf
, smalldate(aconf
->created
),
1388 rb_strlcat(reasonbuf
, ")", sizeof reasonbuf
);
1394 get_printable_kline(struct Client
*source_p
, struct ConfItem
*aconf
,
1395 char **host
, char **reason
,
1396 char **user
, char **oper_reason
)
1398 static char null
[] = "<NULL>";
1399 static char operreasonbuf
[BUFSIZE
];
1401 *host
= EmptyString(aconf
->host
) ? null
: aconf
->host
;
1402 *user
= EmptyString(aconf
->user
) ? null
: aconf
->user
;
1403 *reason
= get_user_ban_reason(aconf
);
1405 if(!IsOperGeneral(source_p
))
1406 *oper_reason
= NULL
;
1409 snprintf(operreasonbuf
, sizeof operreasonbuf
, "%s%s(%s)",
1410 EmptyString(aconf
->spasswd
) ? "" : aconf
->spasswd
,
1411 EmptyString(aconf
->spasswd
) ? "" : " ",
1413 *oper_reason
= operreasonbuf
;
1420 * inputs - cold start
1422 * side effects - read all conf files needed, ircd.conf kline.conf etc.
1425 read_conf_files(bool cold
)
1427 const char *filename
;
1429 conf_fbfile_in
= NULL
;
1431 filename
= ConfigFileEntry
.configfile
;
1433 /* We need to know the initial filename for the yyerror() to report
1434 FIXME: The full path is in conffilenamebuf first time since we
1435 dont know anything else
1441 rb_strlcpy(conffilebuf
, filename
, sizeof(conffilebuf
));
1443 if((conf_fbfile_in
= fopen(filename
, "r")) == NULL
)
1447 inotice("Failed in reading configuration file %s, aborting", filename
);
1448 ilog(L_MAIN
, "Failed in reading configuration file %s", filename
);
1453 inotice("FATAL: %s %s", strerror(e
), filename
);
1454 ilog(L_MAIN
, "FATAL: %s %s", strerror(e
), filename
);
1460 sendto_realops_snomask(SNO_GENERAL
, L_NETWIDE
,
1461 "Can't open file '%s' - aborting rehash!", filename
);
1468 clear_out_old_conf();
1471 call_hook(h_conf_read_start
, NULL
);
1473 call_hook(h_conf_read_end
, NULL
);
1475 fclose(conf_fbfile_in
);
1479 * free an alias{} entry.
1482 free_alias_cb(rb_dictionary_element
*ptr
, void *unused
)
1484 struct alias_entry
*aptr
= ptr
->data
;
1486 rb_free(aptr
->name
);
1487 rb_free(aptr
->target
);
1492 * clear_out_old_conf
1496 * side effects - Clear out the old configuration
1499 clear_out_old_conf(void)
1501 struct Class
*cltmp
;
1503 rb_dlink_node
*next_ptr
;
1506 * don't delete the class table, rather mark all entries
1507 * for deletion. The table is cleaned up by check_class. - avalon
1509 RB_DLINK_FOREACH(ptr
, class_list
.head
)
1512 MaxUsers(cltmp
) = -1;
1515 clear_out_address_conf(AC_CONFIG
);
1518 /* clean out module paths */
1520 mod_add_path(MODULE_DIR
);
1521 mod_add_path(MODULE_DIR
"/autoload");
1523 /* clean out ServerInfo */
1524 rb_free(ServerInfo
.description
);
1525 ServerInfo
.description
= NULL
;
1526 rb_free(ServerInfo
.network_name
);
1527 ServerInfo
.network_name
= NULL
;
1529 ServerInfo
.ssld_count
= 1;
1531 /* clean out AdminInfo */
1532 rb_free(AdminInfo
.name
);
1533 AdminInfo
.name
= NULL
;
1534 rb_free(AdminInfo
.email
);
1535 AdminInfo
.email
= NULL
;
1536 rb_free(AdminInfo
.description
);
1537 AdminInfo
.description
= NULL
;
1539 /* operator{} and class{} blocks are freed above */
1540 /* clean out listeners */
1543 /* auth{}, quarantine{}, shared{}, connect{}, kill{}, deny{}, exempt{}
1544 * and gecos{} blocks are freed above too
1547 /* clean out general */
1548 rb_free(ConfigFileEntry
.default_operstring
);
1549 ConfigFileEntry
.default_operstring
= NULL
;
1550 rb_free(ConfigFileEntry
.default_adminstring
);
1551 ConfigFileEntry
.default_adminstring
= NULL
;
1552 rb_free(ConfigFileEntry
.servicestring
);
1553 ConfigFileEntry
.servicestring
= NULL
;
1554 rb_free(ConfigFileEntry
.kline_reason
);
1555 ConfigFileEntry
.kline_reason
= NULL
;
1556 rb_free(ConfigFileEntry
.sasl_service
);
1557 ConfigFileEntry
.sasl_service
= NULL
;
1558 rb_free(ConfigFileEntry
.drain_reason
);
1559 ConfigFileEntry
.drain_reason
= NULL
;
1560 rb_free(ConfigFileEntry
.sasl_only_client_message
);
1561 ConfigFileEntry
.sasl_only_client_message
= NULL
;
1562 rb_free(ConfigFileEntry
.identd_only_client_message
);
1563 ConfigFileEntry
.identd_only_client_message
= NULL
;
1564 rb_free(ConfigFileEntry
.sctp_forbidden_client_message
);
1565 ConfigFileEntry
.sctp_forbidden_client_message
= NULL
;
1566 rb_free(ConfigFileEntry
.ssltls_only_client_message
);
1567 ConfigFileEntry
.ssltls_only_client_message
= NULL
;
1568 rb_free(ConfigFileEntry
.not_authorised_client_message
);
1569 ConfigFileEntry
.not_authorised_client_message
= NULL
;
1570 rb_free(ConfigFileEntry
.illegal_hostname_client_message
);
1571 ConfigFileEntry
.illegal_hostname_client_message
= NULL
;
1572 rb_free(ConfigFileEntry
.server_full_client_message
);
1573 ConfigFileEntry
.server_full_client_message
= NULL
;
1574 rb_free(ConfigFileEntry
.illegal_name_long_client_message
);
1575 ConfigFileEntry
.illegal_name_long_client_message
= NULL
;
1576 rb_free(ConfigFileEntry
.illegal_name_short_client_message
);
1577 ConfigFileEntry
.illegal_name_short_client_message
= NULL
;
1579 if (ConfigFileEntry
.hidden_caps
!= NULL
)
1581 for (size_t i
= 0; ConfigFileEntry
.hidden_caps
[i
] != NULL
; i
++)
1582 rb_free(ConfigFileEntry
.hidden_caps
[i
]);
1583 rb_free(ConfigFileEntry
.hidden_caps
);
1585 ConfigFileEntry
.hidden_caps
= NULL
;
1588 rb_free(ConfigFileEntry
.fname_userlog
);
1589 ConfigFileEntry
.fname_userlog
= NULL
;
1590 rb_free(ConfigFileEntry
.fname_fuserlog
);
1591 ConfigFileEntry
.fname_fuserlog
= NULL
;
1592 rb_free(ConfigFileEntry
.fname_operlog
);
1593 ConfigFileEntry
.fname_operlog
= NULL
;
1594 rb_free(ConfigFileEntry
.fname_foperlog
);
1595 ConfigFileEntry
.fname_foperlog
= NULL
;
1596 rb_free(ConfigFileEntry
.fname_serverlog
);
1597 ConfigFileEntry
.fname_serverlog
= NULL
;
1598 rb_free(ConfigFileEntry
.fname_killlog
);
1599 ConfigFileEntry
.fname_killlog
= NULL
;
1600 rb_free(ConfigFileEntry
.fname_klinelog
);
1601 ConfigFileEntry
.fname_klinelog
= NULL
;
1602 rb_free(ConfigFileEntry
.fname_operspylog
);
1603 ConfigFileEntry
.fname_operspylog
= NULL
;
1604 rb_free(ConfigFileEntry
.fname_ioerrorlog
);
1605 ConfigFileEntry
.fname_ioerrorlog
= NULL
;
1607 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, service_list
.head
)
1610 rb_dlinkDestroy(ptr
, &service_list
);
1613 /* remove any aliases... -- nenolod */
1614 if (alias_dict
!= NULL
)
1616 rb_dictionary_destroy(alias_dict
, free_alias_cb
, NULL
);
1620 del_dnsbl_entry_all();
1622 /* OK, that should be everything... */
1627 * conf_add_class_to_conf
1628 * inputs - pointer to config item
1630 * side effects - Add a class pointer to a conf
1634 conf_add_class_to_conf(struct ConfItem
*aconf
)
1636 if(aconf
->className
== NULL
)
1638 aconf
->className
= rb_strdup("default");
1639 ClassPtr(aconf
) = default_class
;
1643 ClassPtr(aconf
) = find_class(aconf
->className
);
1645 if(ClassPtr(aconf
) == default_class
)
1647 if(aconf
->status
== CONF_CLIENT
)
1650 "Using default class for missing class \"%s\" in auth{} for %s@%s",
1651 aconf
->className
, aconf
->user
, aconf
->host
);
1654 rb_free(aconf
->className
);
1655 aconf
->className
= rb_strdup("default");
1659 if(ConfMaxUsers(aconf
) < 0)
1661 ClassPtr(aconf
) = default_class
;
1662 rb_free(aconf
->className
);
1663 aconf
->className
= rb_strdup("default");
1670 * inputs - pointer to config item
1672 * side effects - Add a d/D line
1675 conf_add_d_conf(struct ConfItem
*aconf
)
1677 if(aconf
->host
== NULL
)
1682 /* XXX - Should 'd' ever be in the old conf? For new conf we don't
1683 * need this anyway, so I will disable it for now... -A1kmm
1686 if(parse_netmask(aconf
->host
, NULL
, NULL
) == HM_HOST
)
1688 ilog(L_MAIN
, "Invalid Dline %s ignored", aconf
->host
);
1693 add_conf_by_address(aconf
->host
, CONF_DLINE
, NULL
, NULL
, aconf
);
1698 strip_tabs(char *dest
, const char *src
, size_t size
)
1702 if(dest
== NULL
|| src
== NULL
)
1705 rb_strlcpy(dest
, src
, size
);
1718 * inputs - message from parser
1720 * side effects - message to opers and log file entry is made
1723 yyerror(const char *msg
)
1725 char newlinebuf
[BUFSIZE
];
1727 strip_tabs(newlinebuf
, yy_linebuf
, sizeof(newlinebuf
));
1729 ierror("\"%s\", line %d: %s at '%s'", conffilebuf
, lineno
+ 1, msg
, newlinebuf
);
1730 sendto_realops_snomask(SNO_GENERAL
, L_NETWIDE
, "\"%s\", line %d: %s at '%s'",
1731 conffilebuf
, lineno
+ 1, msg
, newlinebuf
);
1736 conf_fgets(char *lbuf
, int max_size
, FILE * fb
)
1738 if(fgets(lbuf
, max_size
, fb
) == NULL
)
1741 return (strlen(lbuf
));
1745 conf_yy_fatal_error(const char *msg
)