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
)++;
650 service_rehash(void *data_
)
652 struct rehash_data
*data
= data_
;
653 bool sig
= data
->sig
;
659 hook_data_rehash hdata
= { sig
};
662 sendto_realops_snomask(SNO_GENERAL
, L_NETWIDE
,
663 "Got signal SIGHUP, reloading ircd conf. file");
667 privilegeset_prepare_rehash();
669 /* don't close listeners until we know we can go ahead with the rehash */
670 read_conf_files(false);
672 if(ServerInfo
.description
!= NULL
)
673 rb_strlcpy(me
.info
, ServerInfo
.description
, sizeof(me
.info
));
675 rb_strlcpy(me
.info
, "unknown", sizeof(me
.info
));
679 RB_DLINK_FOREACH(n
, local_oper_list
.head
)
681 struct Client
*oper
= n
->data
;
682 struct PrivilegeSet
*privset
= oper
->user
->privset
;
683 report_priv_change(oper
, privset
? privset
->shadow
: NULL
, privset
);
686 privilegeset_cleanup_rehash();
688 call_hook(h_rehash
, &hdata
);
694 * Called with sig == 0 if it has been called as a result of an operator
695 * issuing this command, else assume it has been called as a result of the
696 * server receiving a HUP signal.
701 struct rehash_data
*data
= rb_malloc(sizeof *data
);
703 rb_defer(service_rehash
, data
);
718 * side effects - Set default values here.
719 * This is called **PRIOR** to parsing the
720 * configuration file. If you want to do some validation
721 * of values later, put them in validate_conf().
725 set_default_conf(void)
727 /* ServerInfo.name is not rehashable */
728 /* ServerInfo.name = ServerInfo.name; */
729 ServerInfo
.description
= NULL
;
730 ServerInfo
.network_name
= NULL
;
732 memset(&ServerInfo
.bind4
, 0, sizeof(ServerInfo
.bind4
));
733 SET_SS_FAMILY(&ServerInfo
.bind4
, AF_UNSPEC
);
734 memset(&ServerInfo
.bind6
, 0, sizeof(ServerInfo
.bind6
));
735 SET_SS_FAMILY(&ServerInfo
.bind6
, AF_UNSPEC
);
737 AdminInfo
.name
= NULL
;
738 AdminInfo
.email
= NULL
;
739 AdminInfo
.description
= NULL
;
741 ConfigFileEntry
.default_operstring
= NULL
;
742 ConfigFileEntry
.default_adminstring
= NULL
;
743 ConfigFileEntry
.servicestring
= NULL
;
744 ConfigFileEntry
.sasl_service
= NULL
;
746 ConfigFileEntry
.default_umodes
= UMODE_INVISIBLE
;
747 ConfigFileEntry
.failed_oper_notice
= true;
748 ConfigFileEntry
.anti_nick_flood
= false;
749 ConfigFileEntry
.disable_fake_channels
= false;
750 ConfigFileEntry
.max_nick_time
= 20;
751 ConfigFileEntry
.max_nick_changes
= 5;
752 ConfigFileEntry
.max_accept
= 20;
753 ConfigFileEntry
.max_monitor
= 60;
754 ConfigFileEntry
.nick_delay
= 900; /* 15 minutes */
755 ConfigFileEntry
.target_change
= true;
756 ConfigFileEntry
.anti_spam_exit_message_time
= 0;
757 ConfigFileEntry
.ts_warn_delta
= TS_WARN_DELTA_DEFAULT
;
758 ConfigFileEntry
.ts_max_delta
= TS_MAX_DELTA_DEFAULT
;
759 ConfigFileEntry
.client_exit
= true;
760 ConfigFileEntry
.dline_with_reason
= true;
761 ConfigFileEntry
.kline_with_reason
= true;
762 ConfigFileEntry
.warn_no_nline
= true;
763 ConfigFileEntry
.non_redundant_klines
= true;
764 ConfigFileEntry
.stats_e_disabled
= false;
765 ConfigFileEntry
.stats_o_oper_only
= false;
766 ConfigFileEntry
.stats_k_oper_only
= 1; /* masked */
767 ConfigFileEntry
.stats_l_oper_only
= 1; /* self */
768 ConfigFileEntry
.stats_i_oper_only
= 1; /* masked */
769 ConfigFileEntry
.stats_P_oper_only
= false;
770 ConfigFileEntry
.stats_c_oper_only
= false;
771 ConfigFileEntry
.stats_y_oper_only
= false;
772 ConfigFileEntry
.map_oper_only
= true;
773 ConfigFileEntry
.operspy_admin_only
= false;
774 ConfigFileEntry
.pace_wait
= 10;
775 ConfigFileEntry
.caller_id_wait
= 60;
776 ConfigFileEntry
.pace_wait_simple
= 1;
777 ConfigFileEntry
.short_motd
= false;
778 ConfigFileEntry
.no_oper_flood
= false;
779 ConfigFileEntry
.fname_userlog
= NULL
;
780 ConfigFileEntry
.fname_fuserlog
= NULL
;
781 ConfigFileEntry
.fname_operlog
= NULL
;
782 ConfigFileEntry
.fname_foperlog
= NULL
;
783 ConfigFileEntry
.fname_serverlog
= NULL
;
784 ConfigFileEntry
.fname_killlog
= NULL
;
785 ConfigFileEntry
.fname_klinelog
= NULL
;
786 ConfigFileEntry
.fname_operspylog
= NULL
;
787 ConfigFileEntry
.fname_ioerrorlog
= NULL
;
788 ConfigFileEntry
.hide_spoof_ips
= true;
789 ConfigFileEntry
.hide_error_messages
= 1;
790 ConfigFileEntry
.dots_in_ident
= 0;
791 ConfigFileEntry
.max_targets
= MAX_TARGETS_DEFAULT
;
792 ConfigFileEntry
.use_whois_actually
= true;
793 ConfigFileEntry
.burst_away
= false;
794 ConfigFileEntry
.collision_fnc
= true;
795 ConfigFileEntry
.resv_fnc
= true;
796 ConfigFileEntry
.global_snotices
= true;
797 ConfigFileEntry
.operspy_dont_care_user_info
= false;
798 ConfigFileEntry
.use_propagated_bans
= true;
799 ConfigFileEntry
.max_ratelimit_tokens
= 30;
800 ConfigFileEntry
.away_interval
= 30;
801 ConfigFileEntry
.tls_ciphers_oper_only
= false;
802 ConfigFileEntry
.oper_secure_only
= false;
804 ConfigFileEntry
.oper_umodes
= UMODE_LOCOPS
| UMODE_SERVNOTICE
|
805 UMODE_OPERWALL
| UMODE_WALLOP
;
806 ConfigFileEntry
.oper_only_umodes
= UMODE_SERVNOTICE
;
807 ConfigFileEntry
.oper_snomask
= SNO_GENERAL
;
809 ConfigChannel
.use_except
= true;
810 ConfigChannel
.use_invex
= true;
811 ConfigChannel
.use_forward
= true;
812 ConfigChannel
.use_knock
= true;
813 ConfigChannel
.knock_delay
= 300;
814 ConfigChannel
.knock_delay_channel
= 60;
815 ConfigChannel
.max_chans_per_user
= 15;
816 ConfigChannel
.max_chans_per_user_large
= 60;
817 ConfigChannel
.max_bans
= 25;
818 ConfigChannel
.max_bans_large
= 500;
819 ConfigChannel
.only_ascii_channels
= false;
820 ConfigChannel
.burst_topicwho
= false;
821 ConfigChannel
.kick_on_split_riding
= false;
823 ConfigChannel
.default_split_user_count
= 15000;
824 ConfigChannel
.default_split_server_count
= 10;
825 ConfigChannel
.no_join_on_split
= false;
826 ConfigChannel
.no_create_on_split
= true;
827 ConfigChannel
.resv_forcepart
= true;
828 ConfigChannel
.channel_target_change
= true;
829 ConfigChannel
.disable_local_channels
= false;
830 ConfigChannel
.displayed_usercount
= 3;
831 ConfigChannel
.opmod_send_statusmsg
= false;
832 ConfigChannel
.ip_bans_through_vhost
= true;
833 ConfigChannel
.invite_notify_notice
= true;
835 ConfigChannel
.autochanmodes
= MODE_TOPICLIMIT
| MODE_NOPRIVMSGS
;
837 ConfigServerHide
.flatten_links
= 0;
838 ConfigServerHide
.links_delay
= 300;
839 ConfigServerHide
.hidden
= 0;
840 ConfigServerHide
.disable_hidden
= 0;
842 ConfigFileEntry
.min_nonwildcard
= 4;
843 ConfigFileEntry
.min_nonwildcard_simple
= 3;
844 ConfigFileEntry
.default_floodcount
= 8;
845 ConfigFileEntry
.default_ident_timeout
= IDENT_TIMEOUT_DEFAULT
;
846 ConfigFileEntry
.tkline_expire_notices
= 0;
848 ConfigFileEntry
.reject_after_count
= 5;
849 ConfigFileEntry
.reject_ban_time
= 300;
850 ConfigFileEntry
.reject_duration
= 120;
851 ConfigFileEntry
.throttle_count
= 4;
852 ConfigFileEntry
.throttle_duration
= 60;
854 ConfigFileEntry
.client_flood_max_lines
= CLIENT_FLOOD_DEFAULT
;
855 ConfigFileEntry
.client_flood_burst_rate
= 5;
856 ConfigFileEntry
.client_flood_burst_max
= 5;
857 ConfigFileEntry
.client_flood_message_time
= 1;
858 ConfigFileEntry
.client_flood_message_num
= 2;
860 ServerInfo
.default_max_clients
= MAXCONNECTIONS
;
862 ConfigFileEntry
.nicklen
= NICKLEN
;
863 ConfigFileEntry
.certfp_method
= RB_SSL_CERTFP_METH_CERT_SHA1
;
864 ConfigFileEntry
.hide_opers_in_whois
= 0;
865 ConfigFileEntry
.hide_opers
= 0;
868 alias_dict
= rb_dictionary_create("alias", rb_strcasecmp
);
877 * side effects - Read configuration file.
884 set_default_conf(); /* Set default values prior to conf parsing */
885 yyparse(); /* Load the values from the conf */
886 validate_conf(); /* Check to make sure some values are still okay. */
887 /* Some global values are also loaded here. */
888 check_class(); /* Make sure classes are valid */
889 construct_cflags_strings();
895 if(ConfigFileEntry
.default_ident_timeout
< 1)
896 ConfigFileEntry
.default_ident_timeout
= IDENT_TIMEOUT_DEFAULT
;
898 if(ConfigFileEntry
.ts_warn_delta
< TS_WARN_DELTA_MIN
)
899 ConfigFileEntry
.ts_warn_delta
= TS_WARN_DELTA_DEFAULT
;
901 if(ConfigFileEntry
.ts_max_delta
< TS_MAX_DELTA_MIN
)
902 ConfigFileEntry
.ts_max_delta
= TS_MAX_DELTA_DEFAULT
;
904 if(ServerInfo
.network_name
== NULL
)
905 ServerInfo
.network_name
= rb_strdup(NETWORK_NAME_DEFAULT
);
907 if(ServerInfo
.ssld_count
< 1)
908 ServerInfo
.ssld_count
= 1;
910 /* XXX: configurable? */
911 ServerInfo
.wsockd_count
= 1;
913 if(!rb_setup_ssl_server(ServerInfo
.ssl_cert
, ServerInfo
.ssl_private_key
, ServerInfo
.ssl_dh_params
, ServerInfo
.ssl_cipher_list
))
915 ilog(L_MAIN
, "WARNING: Unable to setup SSL.");
919 ssld_update_config();
922 if(ServerInfo
.ssld_count
> get_ssld_count())
924 int start
= ServerInfo
.ssld_count
- get_ssld_count();
925 /* start up additional ssld if needed */
926 start_ssldaemon(start
);
929 if(ServerInfo
.wsockd_count
> get_wsockd_count())
931 int start
= ServerInfo
.wsockd_count
- get_wsockd_count();
936 if (ConfigFileEntry
.default_operstring
== NULL
)
937 ConfigFileEntry
.default_operstring
= rb_strdup("is an IRC operator");
939 if (ConfigFileEntry
.default_adminstring
== NULL
)
940 ConfigFileEntry
.default_adminstring
= rb_strdup("is a Server Administrator");
942 if (ConfigFileEntry
.servicestring
== NULL
)
943 ConfigFileEntry
.servicestring
= rb_strdup("is a Network Service");
945 if (ConfigFileEntry
.sasl_service
== NULL
)
946 ConfigFileEntry
.sasl_service
= rb_strdup("SaslServ");
948 /* RFC 1459 says 1 message per 2 seconds on average and bursts of
949 * 5 messages are acceptable, so allow at least that.
951 if(ConfigFileEntry
.client_flood_burst_rate
< 5)
952 ConfigFileEntry
.client_flood_burst_rate
= 5;
953 if(ConfigFileEntry
.client_flood_burst_max
< 5)
954 ConfigFileEntry
.client_flood_burst_max
= 5;
955 if(ConfigFileEntry
.client_flood_message_time
>
956 ConfigFileEntry
.client_flood_message_num
* 2)
957 ConfigFileEntry
.client_flood_message_time
=
958 ConfigFileEntry
.client_flood_message_num
* 2;
960 if((ConfigFileEntry
.client_flood_max_lines
< CLIENT_FLOOD_MIN
) ||
961 (ConfigFileEntry
.client_flood_max_lines
> CLIENT_FLOOD_MAX
))
962 ConfigFileEntry
.client_flood_max_lines
= CLIENT_FLOOD_MAX
;
964 if(!split_users
|| !split_servers
||
965 (!ConfigChannel
.no_create_on_split
&& !ConfigChannel
.no_join_on_split
))
967 rb_event_delete(check_splitmode_ev
);
968 check_splitmode_ev
= NULL
;
973 CharAttrs
['&'] |= CHANPFX_C
;
974 if (ConfigChannel
.disable_local_channels
)
975 CharAttrs
['&'] &= ~CHANPFX_C
;
982 * inputs - pointer to struct ConfItem
984 * Side effects - links in given struct ConfItem into
985 * temporary kline link list
988 add_temp_kline(struct ConfItem
*aconf
)
990 if(aconf
->hold
>= rb_current_time() + (10080 * 60))
992 rb_dlinkAddAlloc(aconf
, &temp_klines
[TEMP_WEEK
]);
993 aconf
->port
= TEMP_WEEK
;
995 else if(aconf
->hold
>= rb_current_time() + (1440 * 60))
997 rb_dlinkAddAlloc(aconf
, &temp_klines
[TEMP_DAY
]);
998 aconf
->port
= TEMP_DAY
;
1000 else if(aconf
->hold
>= rb_current_time() + (60 * 60))
1002 rb_dlinkAddAlloc(aconf
, &temp_klines
[TEMP_HOUR
]);
1003 aconf
->port
= TEMP_HOUR
;
1007 rb_dlinkAddAlloc(aconf
, &temp_klines
[TEMP_MIN
]);
1008 aconf
->port
= TEMP_MIN
;
1011 aconf
->flags
|= CONF_FLAGS_TEMPORARY
;
1012 add_conf_by_address(aconf
->host
, CONF_KILL
, aconf
->user
, NULL
, aconf
);
1017 * input - pointer to struct ConfItem
1019 * side effects - added to tdline link list and address hash
1022 add_temp_dline(struct ConfItem
*aconf
)
1024 if(aconf
->hold
>= rb_current_time() + (10080 * 60))
1026 rb_dlinkAddAlloc(aconf
, &temp_dlines
[TEMP_WEEK
]);
1027 aconf
->port
= TEMP_WEEK
;
1029 else if(aconf
->hold
>= rb_current_time() + (1440 * 60))
1031 rb_dlinkAddAlloc(aconf
, &temp_dlines
[TEMP_DAY
]);
1032 aconf
->port
= TEMP_DAY
;
1034 else if(aconf
->hold
>= rb_current_time() + (60 * 60))
1036 rb_dlinkAddAlloc(aconf
, &temp_dlines
[TEMP_HOUR
]);
1037 aconf
->port
= TEMP_HOUR
;
1041 rb_dlinkAddAlloc(aconf
, &temp_dlines
[TEMP_MIN
]);
1042 aconf
->port
= TEMP_MIN
;
1045 aconf
->flags
|= CONF_FLAGS_TEMPORARY
;
1046 add_conf_by_address(aconf
->host
, CONF_DLINE
, aconf
->user
, NULL
, aconf
);
1049 /* valid_wild_card()
1051 * input - user buffer, host buffer
1052 * output - 0 if invalid, 1 if valid
1056 valid_wild_card(const char *luser
, const char *lhost
)
1063 /* user has no wildcards, always accept -- jilles */
1064 if(!strchr(luser
, '?') && !strchr(luser
, '*'))
1067 /* check there are enough non wildcard chars */
1069 while((tmpch
= *p
++))
1071 if(!IsKWildChar(tmpch
))
1073 /* found enough chars, return */
1074 if(++nonwild
>= ConfigFileEntry
.min_nonwildcard
)
1079 /* try host, as user didnt contain enough */
1080 /* special case for cidr masks -- jilles */
1081 if((p
= strrchr(lhost
, '/')) != NULL
&& IsDigit(p
[1]))
1083 bitlen
= atoi(p
+ 1);
1084 /* much like non-cidr for ipv6, rather arbitrary for ipv4 */
1087 (strchr(lhost
, ':') ? 4 * (ConfigFileEntry
.min_nonwildcard
- nonwild
) : 6 -
1094 while((tmpch
= *p
++))
1096 if(!IsKWildChar(tmpch
))
1097 if(++nonwild
>= ConfigFileEntry
.min_nonwildcard
)
1106 int cmp_prop_ban(const void *a_
, const void *b_
)
1108 const struct ConfItem
*a
= a_
, *b
= b_
;
1111 if ((a
->status
& ~CONF_ILLEGAL
) > (int)(b
->status
& ~CONF_ILLEGAL
)) return 1;
1112 if ((a
->status
& ~CONF_ILLEGAL
) < (int)(b
->status
& ~CONF_ILLEGAL
)) return -1;
1114 r
= irccmp(a
->host
, b
->host
);
1117 if (a
->user
&& b
->user
)
1118 return irccmp(a
->user
, b
->user
);
1124 add_prop_ban(struct ConfItem
*aconf
)
1126 rb_dictionary_add(prop_bans_dict
, aconf
, aconf
);
1130 find_prop_ban(unsigned status
, const char *user
, const char *host
)
1132 struct ConfItem key
= {.status
= status
, .user
= (char *)user
, .host
= (char *)host
};
1133 return rb_dictionary_retrieve(prop_bans_dict
, &key
);
1137 remove_prop_ban(struct ConfItem
*aconf
)
1139 rb_dictionary_delete(prop_bans_dict
, aconf
);
1142 bool lookup_prop_ban(struct ConfItem
*aconf
)
1144 return rb_dictionary_retrieve(prop_bans_dict
, aconf
) == aconf
;
1148 deactivate_conf(struct ConfItem
*aconf
, time_t now
)
1152 switch (aconf
->status
)
1155 if (aconf
->lifetime
== 0 &&
1156 aconf
->flags
& CONF_FLAGS_TEMPORARY
)
1157 for (i
= 0; i
< LAST_TEMP_TYPE
; i
++)
1158 rb_dlinkFindDestroy(aconf
, &temp_klines
[i
]);
1159 /* Make sure delete_one_address_conf() does not
1163 delete_one_address_conf(aconf
->host
, aconf
);
1167 if (aconf
->lifetime
== 0 &&
1168 aconf
->flags
& CONF_FLAGS_TEMPORARY
)
1169 for (i
= 0; i
< LAST_TEMP_TYPE
; i
++)
1170 rb_dlinkFindDestroy(aconf
, &temp_dlines
[i
]);
1172 delete_one_address_conf(aconf
->host
, aconf
);
1176 rb_dlinkFindDestroy(aconf
, &xline_conf_list
);
1178 case CONF_RESV_NICK
:
1179 rb_dlinkFindDestroy(aconf
, &resv_conf_list
);
1181 case CONF_RESV_CHANNEL
:
1182 del_from_resv_hash(aconf
->host
, aconf
);
1185 if (aconf
->lifetime
!= 0 && now
< aconf
->lifetime
)
1187 aconf
->status
|= CONF_ILLEGAL
;
1191 if (aconf
->lifetime
!= 0)
1192 remove_prop_ban(aconf
);
1193 if (aconf
->clients
== 0)
1196 aconf
->status
|= CONF_ILLEGAL
;
1200 /* Given a new ban ConfItem, look for any matching ban, update the lifetime
1201 * from it and delete it.
1204 replace_old_ban(struct ConfItem
*aconf
)
1206 struct ConfItem
*oldconf
;
1208 oldconf
= find_prop_ban(aconf
->status
, aconf
->user
, aconf
->host
);
1209 if (oldconf
!= NULL
)
1211 /* Remember at least as long as the old one. */
1212 if(oldconf
->lifetime
> aconf
->lifetime
)
1213 aconf
->lifetime
= oldconf
->lifetime
;
1214 /* Force creation time to increase. */
1215 if(oldconf
->created
>= aconf
->created
)
1216 aconf
->created
= oldconf
->created
+ 1;
1217 /* Leave at least one second of validity. */
1218 if(aconf
->hold
<= aconf
->created
)
1219 aconf
->hold
= aconf
->created
+ 1;
1220 if(aconf
->lifetime
< aconf
->hold
)
1221 aconf
->lifetime
= aconf
->hold
;
1222 /* Tell deactivate_conf() to destroy it. */
1223 oldconf
->lifetime
= rb_current_time();
1224 deactivate_conf(oldconf
, oldconf
->lifetime
);
1229 expire_prop_bans(void *unused
)
1231 struct ConfItem
*aconf
;
1233 rb_dictionary_iter state
;
1235 now
= rb_current_time();
1237 RB_DICTIONARY_FOREACH(aconf
, &state
, prop_bans_dict
)
1239 if(aconf
->lifetime
<= now
||
1240 (aconf
->hold
<= now
&&
1241 !(aconf
->status
& CONF_ILLEGAL
)))
1243 /* Alert opers that a TKline expired - Hwy */
1244 /* XXX show what type of ban it is */
1245 if(ConfigFileEntry
.tkline_expire_notices
&&
1246 !(aconf
->status
& CONF_ILLEGAL
))
1247 sendto_realops_snomask(SNO_GENERAL
, L_ALL
,
1248 "Propagated ban for [%s%s%s] expired",
1249 aconf
->user
? aconf
->user
: "",
1250 aconf
->user
? "@" : "",
1251 aconf
->host
? aconf
->host
: "*");
1253 /* will destroy or mark illegal */
1254 deactivate_conf(aconf
, now
);
1261 * inputs - list pointer
1264 * side effects - expire tklines and moves them between lists
1267 expire_temp_kd(void *list
)
1270 rb_dlink_node
*next_ptr
;
1271 struct ConfItem
*aconf
;
1273 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, ((rb_dlink_list
*) list
)->head
)
1277 if(aconf
->hold
<= rb_current_time())
1279 /* Alert opers that a TKline expired - Hwy */
1280 if(ConfigFileEntry
.tkline_expire_notices
)
1281 sendto_realops_snomask(SNO_GENERAL
, L_ALL
,
1282 "Temporary K-line for [%s@%s] expired",
1283 (aconf
->user
) ? aconf
->
1284 user
: "*", (aconf
->host
) ? aconf
->host
: "*");
1286 delete_one_address_conf(aconf
->host
, aconf
);
1287 rb_dlinkDestroy(ptr
, list
);
1293 reorganise_temp_kd(void *list
)
1295 struct ConfItem
*aconf
;
1296 rb_dlink_node
*ptr
, *next_ptr
;
1298 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, ((rb_dlink_list
*) list
)->head
)
1302 if(aconf
->hold
< (rb_current_time() + (60 * 60)))
1304 rb_dlinkMoveNode(ptr
, list
, (aconf
->status
== CONF_KILL
) ?
1305 &temp_klines
[TEMP_MIN
] : &temp_dlines
[TEMP_MIN
]);
1306 aconf
->port
= TEMP_MIN
;
1308 else if(aconf
->port
> TEMP_HOUR
)
1310 if(aconf
->hold
< (rb_current_time() + (1440 * 60)))
1312 rb_dlinkMoveNode(ptr
, list
, (aconf
->status
== CONF_KILL
) ?
1313 &temp_klines
[TEMP_HOUR
] : &temp_dlines
[TEMP_HOUR
]);
1314 aconf
->port
= TEMP_HOUR
;
1316 else if(aconf
->port
> TEMP_DAY
&&
1317 (aconf
->hold
< (rb_current_time() + (10080 * 60))))
1319 rb_dlinkMoveNode(ptr
, list
, (aconf
->status
== CONF_KILL
) ?
1320 &temp_klines
[TEMP_DAY
] : &temp_dlines
[TEMP_DAY
]);
1321 aconf
->port
= TEMP_DAY
;
1328 /* const char* get_oper_name(struct Client *client_p)
1329 * Input: A client to find the active oper{} name for.
1330 * Output: The nick!user@host{oper} of the oper.
1331 * "oper" is server name for unknown opers
1332 * Side effects: None.
1335 get_oper_name(struct Client
*client_p
)
1337 /* +5 for !,@,{,} and null */
1338 static char buffer
[NAMELEN
+ USERLEN
+ HOSTLEN
+ MAX(HOSTLEN
, OPERNICKLEN
) + 5];
1340 const char *opername
= EmptyString(client_p
->user
->opername
)
1341 ? client_p
->servptr
->name
1342 : client_p
->user
->opername
;
1344 snprintf(buffer
, sizeof buffer
, "%s!%s@%s{%s}",
1345 client_p
->name
, client_p
->username
,
1346 client_p
->host
, opername
);
1351 * get_printable_conf
1353 * inputs - struct ConfItem
1362 * Examine the struct struct ConfItem, setting the values
1363 * of name, host, pass, user to values either
1364 * in aconf, or "<NULL>" port is set to aconf->port in all cases.
1367 get_printable_conf(struct ConfItem
*aconf
, char **name
, char **host
,
1368 const char **pass
, char **user
, int *port
,
1369 char **classname
, char **desc
)
1371 static char null
[] = "<NULL>";
1372 static char zero
[] = "default";
1374 *name
= EmptyString(aconf
->info
.name
) ? null
: aconf
->info
.name
;
1375 *host
= EmptyString(aconf
->host
) ? null
: aconf
->host
;
1376 *pass
= EmptyString(aconf
->passwd
) ? null
: aconf
->passwd
;
1377 *user
= EmptyString(aconf
->user
) ? null
: aconf
->user
;
1378 *classname
= EmptyString(aconf
->className
) ? zero
: aconf
->className
;
1379 *desc
= CheckEmpty(aconf
->desc
);
1380 *port
= (int) aconf
->port
;
1384 get_user_ban_reason(struct ConfItem
*aconf
)
1386 static char reasonbuf
[BUFSIZE
];
1388 if (!ConfigFileEntry
.hide_tkdline_duration
&&
1389 aconf
->flags
& CONF_FLAGS_TEMPORARY
&&
1390 (aconf
->status
== CONF_KILL
|| aconf
->status
== CONF_DLINE
))
1391 snprintf(reasonbuf
, sizeof reasonbuf
,
1392 "Temporary %c-line %d min. - ",
1393 aconf
->status
== CONF_DLINE
? 'D' : 'K',
1394 (int)((aconf
->hold
- aconf
->created
) / 60));
1396 reasonbuf
[0] = '\0';
1398 rb_strlcat(reasonbuf
, aconf
->passwd
, sizeof reasonbuf
);
1400 rb_strlcat(reasonbuf
, "No Reason", sizeof reasonbuf
);
1403 rb_strlcat(reasonbuf
, " (", sizeof reasonbuf
);
1404 rb_strlcat(reasonbuf
, smalldate(aconf
->created
),
1406 rb_strlcat(reasonbuf
, ")", sizeof reasonbuf
);
1412 get_printable_kline(struct Client
*source_p
, struct ConfItem
*aconf
,
1413 char **host
, char **reason
,
1414 char **user
, char **oper_reason
)
1416 static char null
[] = "<NULL>";
1417 static char operreasonbuf
[BUFSIZE
];
1419 *host
= EmptyString(aconf
->host
) ? null
: aconf
->host
;
1420 *user
= EmptyString(aconf
->user
) ? null
: aconf
->user
;
1421 *reason
= get_user_ban_reason(aconf
);
1423 if(!IsOperGeneral(source_p
))
1424 *oper_reason
= NULL
;
1427 snprintf(operreasonbuf
, sizeof operreasonbuf
, "%s%s(%s)",
1428 EmptyString(aconf
->spasswd
) ? "" : aconf
->spasswd
,
1429 EmptyString(aconf
->spasswd
) ? "" : " ",
1431 *oper_reason
= operreasonbuf
;
1438 * inputs - cold start
1440 * side effects - read all conf files needed, ircd.conf kline.conf etc.
1443 read_conf_files(bool cold
)
1445 const char *filename
;
1447 conf_fbfile_in
= NULL
;
1449 filename
= ConfigFileEntry
.configfile
;
1451 /* We need to know the initial filename for the yyerror() to report
1452 FIXME: The full path is in conffilenamebuf first time since we
1453 dont know anything else
1459 rb_strlcpy(conffilebuf
, filename
, sizeof(conffilebuf
));
1461 if((conf_fbfile_in
= fopen(filename
, "r")) == NULL
)
1465 inotice("Failed in reading configuration file %s, aborting", filename
);
1466 ilog(L_MAIN
, "Failed in reading configuration file %s", filename
);
1471 inotice("FATAL: %s %s", strerror(e
), filename
);
1472 ilog(L_MAIN
, "FATAL: %s %s", strerror(e
), filename
);
1478 sendto_realops_snomask(SNO_GENERAL
, L_NETWIDE
,
1479 "Can't open file '%s' - aborting rehash!", filename
);
1486 clear_out_old_conf();
1489 call_hook(h_conf_read_start
, NULL
);
1491 call_hook(h_conf_read_end
, NULL
);
1493 fclose(conf_fbfile_in
);
1497 * free an alias{} entry.
1500 free_alias_cb(rb_dictionary_element
*ptr
, void *unused
)
1502 struct alias_entry
*aptr
= ptr
->data
;
1504 rb_free(aptr
->name
);
1505 rb_free(aptr
->target
);
1510 * clear_out_old_conf
1514 * side effects - Clear out the old configuration
1517 clear_out_old_conf(void)
1519 struct Class
*cltmp
;
1521 rb_dlink_node
*next_ptr
;
1524 * don't delete the class table, rather mark all entries
1525 * for deletion. The table is cleaned up by check_class. - avalon
1527 RB_DLINK_FOREACH(ptr
, class_list
.head
)
1530 MaxUsers(cltmp
) = -1;
1533 clear_out_address_conf(AC_CONFIG
);
1536 /* clean out module paths */
1538 mod_add_path(MODULE_DIR
);
1539 mod_add_path(MODULE_DIR
"/autoload");
1541 /* clean out ServerInfo */
1542 rb_free(ServerInfo
.description
);
1543 ServerInfo
.description
= NULL
;
1544 rb_free(ServerInfo
.network_name
);
1545 ServerInfo
.network_name
= NULL
;
1547 ServerInfo
.ssld_count
= 1;
1549 /* clean out AdminInfo */
1550 rb_free(AdminInfo
.name
);
1551 AdminInfo
.name
= NULL
;
1552 rb_free(AdminInfo
.email
);
1553 AdminInfo
.email
= NULL
;
1554 rb_free(AdminInfo
.description
);
1555 AdminInfo
.description
= NULL
;
1557 /* operator{} and class{} blocks are freed above */
1558 /* clean out listeners */
1561 /* auth{}, quarantine{}, shared{}, connect{}, kill{}, deny{}, exempt{}
1562 * and gecos{} blocks are freed above too
1565 /* clean out general */
1566 rb_free(ConfigFileEntry
.default_operstring
);
1567 ConfigFileEntry
.default_operstring
= NULL
;
1568 rb_free(ConfigFileEntry
.default_adminstring
);
1569 ConfigFileEntry
.default_adminstring
= NULL
;
1570 rb_free(ConfigFileEntry
.servicestring
);
1571 ConfigFileEntry
.servicestring
= NULL
;
1572 rb_free(ConfigFileEntry
.kline_reason
);
1573 ConfigFileEntry
.kline_reason
= NULL
;
1574 rb_free(ConfigFileEntry
.sasl_service
);
1575 ConfigFileEntry
.sasl_service
= NULL
;
1576 rb_free(ConfigFileEntry
.drain_reason
);
1577 ConfigFileEntry
.drain_reason
= NULL
;
1578 rb_free(ConfigFileEntry
.sasl_only_client_message
);
1579 ConfigFileEntry
.sasl_only_client_message
= NULL
;
1580 rb_free(ConfigFileEntry
.identd_only_client_message
);
1581 ConfigFileEntry
.identd_only_client_message
= NULL
;
1582 rb_free(ConfigFileEntry
.sctp_forbidden_client_message
);
1583 ConfigFileEntry
.sctp_forbidden_client_message
= NULL
;
1584 rb_free(ConfigFileEntry
.ssltls_only_client_message
);
1585 ConfigFileEntry
.ssltls_only_client_message
= NULL
;
1586 rb_free(ConfigFileEntry
.not_authorised_client_message
);
1587 ConfigFileEntry
.not_authorised_client_message
= NULL
;
1588 rb_free(ConfigFileEntry
.illegal_hostname_client_message
);
1589 ConfigFileEntry
.illegal_hostname_client_message
= NULL
;
1590 rb_free(ConfigFileEntry
.server_full_client_message
);
1591 ConfigFileEntry
.server_full_client_message
= NULL
;
1592 rb_free(ConfigFileEntry
.illegal_name_long_client_message
);
1593 ConfigFileEntry
.illegal_name_long_client_message
= NULL
;
1594 rb_free(ConfigFileEntry
.illegal_name_short_client_message
);
1595 ConfigFileEntry
.illegal_name_short_client_message
= NULL
;
1597 if (ConfigFileEntry
.hidden_caps
!= NULL
)
1599 for (size_t i
= 0; ConfigFileEntry
.hidden_caps
[i
] != NULL
; i
++)
1600 rb_free(ConfigFileEntry
.hidden_caps
[i
]);
1601 rb_free(ConfigFileEntry
.hidden_caps
);
1603 ConfigFileEntry
.hidden_caps
= NULL
;
1606 rb_free(ConfigFileEntry
.fname_userlog
);
1607 ConfigFileEntry
.fname_userlog
= NULL
;
1608 rb_free(ConfigFileEntry
.fname_fuserlog
);
1609 ConfigFileEntry
.fname_fuserlog
= NULL
;
1610 rb_free(ConfigFileEntry
.fname_operlog
);
1611 ConfigFileEntry
.fname_operlog
= NULL
;
1612 rb_free(ConfigFileEntry
.fname_foperlog
);
1613 ConfigFileEntry
.fname_foperlog
= NULL
;
1614 rb_free(ConfigFileEntry
.fname_serverlog
);
1615 ConfigFileEntry
.fname_serverlog
= NULL
;
1616 rb_free(ConfigFileEntry
.fname_killlog
);
1617 ConfigFileEntry
.fname_killlog
= NULL
;
1618 rb_free(ConfigFileEntry
.fname_klinelog
);
1619 ConfigFileEntry
.fname_klinelog
= NULL
;
1620 rb_free(ConfigFileEntry
.fname_operspylog
);
1621 ConfigFileEntry
.fname_operspylog
= NULL
;
1622 rb_free(ConfigFileEntry
.fname_ioerrorlog
);
1623 ConfigFileEntry
.fname_ioerrorlog
= NULL
;
1625 RB_DLINK_FOREACH_SAFE(ptr
, next_ptr
, service_list
.head
)
1628 rb_dlinkDestroy(ptr
, &service_list
);
1631 /* remove any aliases... -- nenolod */
1632 if (alias_dict
!= NULL
)
1634 rb_dictionary_destroy(alias_dict
, free_alias_cb
, NULL
);
1638 del_dnsbl_entry_all();
1640 /* OK, that should be everything... */
1645 * conf_add_class_to_conf
1646 * inputs - pointer to config item
1648 * side effects - Add a class pointer to a conf
1652 conf_add_class_to_conf(struct ConfItem
*aconf
)
1654 if(aconf
->className
== NULL
)
1656 aconf
->className
= rb_strdup("default");
1657 ClassPtr(aconf
) = default_class
;
1661 ClassPtr(aconf
) = find_class(aconf
->className
);
1663 if(ClassPtr(aconf
) == default_class
)
1665 if(aconf
->status
== CONF_CLIENT
)
1668 "Using default class for missing class \"%s\" in auth{} for %s@%s",
1669 aconf
->className
, aconf
->user
, aconf
->host
);
1672 rb_free(aconf
->className
);
1673 aconf
->className
= rb_strdup("default");
1677 if(ConfMaxUsers(aconf
) < 0)
1679 ClassPtr(aconf
) = default_class
;
1680 rb_free(aconf
->className
);
1681 aconf
->className
= rb_strdup("default");
1688 * inputs - pointer to config item
1690 * side effects - Add a d/D line
1693 conf_add_d_conf(struct ConfItem
*aconf
)
1695 if(aconf
->host
== NULL
)
1700 /* XXX - Should 'd' ever be in the old conf? For new conf we don't
1701 * need this anyway, so I will disable it for now... -A1kmm
1704 if(parse_netmask(aconf
->host
, NULL
, NULL
) == HM_HOST
)
1706 ilog(L_MAIN
, "Invalid Dline %s ignored", aconf
->host
);
1711 add_conf_by_address(aconf
->host
, CONF_DLINE
, NULL
, NULL
, aconf
);
1716 strip_tabs(char *dest
, const char *src
, size_t size
)
1720 if(dest
== NULL
|| src
== NULL
)
1723 rb_strlcpy(dest
, src
, size
);
1736 * inputs - message from parser
1738 * side effects - message to opers and log file entry is made
1741 yyerror(const char *msg
)
1743 char newlinebuf
[BUFSIZE
];
1745 strip_tabs(newlinebuf
, yy_linebuf
, sizeof(newlinebuf
));
1747 ierror("\"%s\", line %d: %s at '%s'", conffilebuf
, lineno
+ 1, msg
, newlinebuf
);
1748 sendto_realops_snomask(SNO_GENERAL
, L_NETWIDE
, "\"%s\", line %d: %s at '%s'",
1749 conffilebuf
, lineno
+ 1, msg
, newlinebuf
);
1754 conf_fgets(char *lbuf
, int max_size
, FILE * fb
)
1756 if(fgets(lbuf
, max_size
, fb
) == NULL
)
1759 return (strlen(lbuf
));
1763 conf_yy_fatal_error(const char *msg
)