… | |
… | |
8 | * Portions of this file were derived from sources bearing the following license: |
8 | * Portions of this file were derived from sources bearing the following license: |
9 | * Rights to this code are documented in doc/pod/license.pod. |
9 | * Rights to this code are documented in doc/pod/license.pod. |
10 | * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) |
10 | * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) |
11 | */ |
11 | */ |
12 | |
12 | |
13 | static char const rcsid[] = "$Id: conf.C,v 1.9 2007/09/16 18:54:44 pippijn Exp $"; |
13 | static char const rcsid[] = "$Id: conf.C,v 1.10 2007/09/22 14:27:30 pippijn Exp $"; |
14 | |
14 | |
15 | #include "atheme.h" |
15 | #include "atheme.h" |
16 | #include "confparse.h" |
16 | #include "confparse.h" |
17 | #include <ermyth/crypto.h> |
17 | #include <ermyth/crypto.h> |
18 | #include <ermyth/database.h> |
18 | #include <ermyth/database.h> |
… | |
… | |
23 | #include "uplink.h" |
23 | #include "uplink.h" |
24 | #include "pmodule.h" |
24 | #include "pmodule.h" |
25 | #include "privs.h" |
25 | #include "privs.h" |
26 | |
26 | |
27 | ConfTable::callbacks ConfTable::callback; |
27 | ConfTable::callbacks ConfTable::callback; |
|
|
28 | |
|
|
29 | static void deinit_conf (void); |
28 | |
30 | |
29 | enum config_error |
31 | enum config_error |
30 | { |
32 | { |
31 | no_param, |
33 | no_param, |
32 | wrong_param |
34 | wrong_param |
… | |
… | |
299 | ConfTable::callback.ready (); |
301 | ConfTable::callback.ready (); |
300 | return true; |
302 | return true; |
301 | } |
303 | } |
302 | |
304 | |
303 | void |
305 | void |
|
|
306 | conf_cleanup () |
|
|
307 | { |
|
|
308 | me.cleanup (); |
|
|
309 | |
|
|
310 | if (config_options.chan) |
|
|
311 | sfree (config_options.chan); |
|
|
312 | if (config_options.global) |
|
|
313 | sfree (config_options.global); |
|
|
314 | |
|
|
315 | if (chansvs.trigger != NULL) |
|
|
316 | sfree (chansvs.trigger); |
|
|
317 | |
|
|
318 | deinit_conf (); |
|
|
319 | } |
|
|
320 | |
|
|
321 | void |
304 | conf_init (void) |
322 | conf_init (void) |
305 | { |
323 | { |
306 | me.init (); |
324 | me.init (); |
307 | if (chansvs.nick) |
325 | if (chansvs.nick) |
308 | sfree (chansvs.nick); |
326 | sfree (chansvs.nick); |
309 | if (config_options.chan) |
327 | if (config_options.chan) |
310 | sfree (config_options.chan); |
328 | sfree (config_options.chan); |
311 | if (config_options.global) |
329 | if (config_options.global) |
312 | sfree (config_options.global); |
330 | sfree (config_options.global); |
313 | if (config_options.languagefile) |
|
|
314 | sfree (config_options.languagefile); |
|
|
315 | |
331 | |
316 | chansvs.nick = config_options.chan = config_options.global = config_options.languagefile = NULL; |
332 | chansvs.nick = config_options.chan = config_options.global = config_options.languagefile = NULL; |
317 | |
333 | |
318 | config_options.flood_msgs = config_options.flood_time = config_options.kline_time = config_options.commit_interval = 0; |
334 | config_options.flood_msgs = config_options.flood_time = config_options.kline_time = config_options.commit_interval = 0; |
319 | |
335 | |
… | |
… | |
326 | me.auth = AUTH_NONE; |
342 | me.auth = AUTH_NONE; |
327 | |
343 | |
328 | me.mdlimit = 30; |
344 | me.mdlimit = 30; |
329 | |
345 | |
330 | chansvs.fantasy = false; |
346 | chansvs.fantasy = false; |
331 | if (chansvs.me != NULL && fcmd_agent == chansvs.me) |
|
|
332 | fcmd_agent = NULL; |
|
|
333 | chansvs.ca_vop = CA_VOP_DEF & ca_all; |
347 | chansvs.ca_vop = CA_VOP_DEF & ca_all; |
334 | chansvs.ca_hop = CA_HOP_DEF & ca_all; |
348 | chansvs.ca_hop = CA_HOP_DEF & ca_all; |
335 | chansvs.ca_aop = CA_AOP_DEF & ca_all; |
349 | chansvs.ca_aop = CA_AOP_DEF & ca_all; |
336 | chansvs.ca_sop = CA_SOP_DEF & ca_all; |
350 | chansvs.ca_sop = CA_SOP_DEF & ca_all; |
337 | chansvs.changets = false; |
351 | chansvs.changets = false; |
… | |
… | |
622 | add_conf_item ("PASSWORD", conf_db_table, c_db_password); |
636 | add_conf_item ("PASSWORD", conf_db_table, c_db_password); |
623 | add_conf_item ("DATABASE", conf_db_table, c_db_database); |
637 | add_conf_item ("DATABASE", conf_db_table, c_db_database); |
624 | add_conf_item ("PORT", conf_db_table, c_db_port); |
638 | add_conf_item ("PORT", conf_db_table, c_db_port); |
625 | } |
639 | } |
626 | |
640 | |
627 | void |
641 | static void |
628 | deinit_conf (void) |
642 | deinit_conf (void) |
629 | { |
643 | { |
630 | #if 0 |
644 | #if 0 |
631 | conftable_heap = BlockHeapCreate (sizeof (ConfTable), 32); |
645 | conftable_heap = BlockHeapCreate (sizeof (ConfTable), 32); |
632 | #endif |
646 | #endif |
… | |
… | |
918 | else if (!strchr (ce->vardata<char *> (), '.')) |
932 | else if (!strchr (ce->vardata<char *> (), '.')) |
919 | slog (LG_ERROR, "%s:%d: uplink's server name %s is invalid, continuing anyway", ce->ce_fileptr->cf_filename, ce->ce_varlinenum, ce->vardata<char *> ()); |
933 | slog (LG_ERROR, "%s:%d: uplink's server name %s is invalid, continuing anyway", ce->ce_fileptr->cf_filename, ce->ce_varlinenum, ce->vardata<char *> ()); |
920 | else if (isdigit (ce->vardata<char *> ()[0])) |
934 | else if (isdigit (ce->vardata<char *> ()[0])) |
921 | slog (LG_ERROR, "%s:%d: uplink's server name %s starts with a digit, probably invalid (continuing anyway)", ce->ce_fileptr->cf_filename, ce->ce_varlinenum, ce->vardata<char *> ()); |
935 | slog (LG_ERROR, "%s:%d: uplink's server name %s starts with a digit, probably invalid (continuing anyway)", ce->ce_fileptr->cf_filename, ce->ce_varlinenum, ce->vardata<char *> ()); |
922 | |
936 | |
923 | name = sstrdup (ce->vardata<char *> ()); |
937 | name = ce->vardata<char *> (); |
924 | |
938 | |
925 | for (ce = ce->ce_entries; ce; ce = ce->ce_next) |
939 | for (ce = ce->ce_entries; ce; ce = ce->ce_next) |
926 | { |
940 | { |
927 | if (!strcasecmp ("HOST", ce->ce_varname)) |
941 | if (!strcasecmp ("HOST", ce->ce_varname)) |
928 | { |
942 | { |
929 | if (ce->vardata<char *> () == NULL) |
943 | if (ce->vardata<char *> () == NULL) |
930 | return param_error<no_param> (ce); |
944 | return param_error<no_param> (ce); |
931 | |
945 | |
932 | host = sstrdup (ce->vardata<char *> ()); |
946 | host = ce->vardata<char *> (); |
933 | } |
947 | } |
934 | else if (!strcasecmp ("VHOST", ce->ce_varname)) |
948 | else if (!strcasecmp ("VHOST", ce->ce_varname)) |
935 | { |
949 | { |
936 | if (ce->vardata<char *> () == NULL) |
950 | if (ce->vardata<char *> () == NULL) |
937 | return param_error<no_param> (ce); |
951 | return param_error<no_param> (ce); |
938 | |
952 | |
939 | vhost = sstrdup (ce->vardata<char *> ()); |
953 | vhost = ce->vardata<char *> (); |
940 | } |
954 | } |
941 | else if (!strcasecmp ("PASSWORD", ce->ce_varname)) |
955 | else if (!strcasecmp ("PASSWORD", ce->ce_varname)) |
942 | { |
956 | { |
943 | if (ce->vardata<char *> () == NULL) |
957 | if (ce->vardata<char *> () == NULL) |
944 | return param_error<no_param> (ce); |
958 | return param_error<no_param> (ce); |
945 | |
959 | |
946 | password = sstrdup (ce->vardata<char *> ()); |
960 | password = ce->vardata<char *> (); |
947 | } |
961 | } |
948 | else if (!strcasecmp ("PORT", ce->ce_varname)) |
962 | else if (!strcasecmp ("PORT", ce->ce_varname)) |
949 | { |
963 | { |
950 | if (ce->vardata<char *> () == NULL) |
964 | if (ce->vardata<char *> () == NULL) |
951 | return param_error<no_param> (ce); |
965 | return param_error<no_param> (ce); |
… | |
… | |
958 | continue; |
972 | continue; |
959 | } |
973 | } |
960 | } |
974 | } |
961 | |
975 | |
962 | uplink_add (name, host, password, vhost, port); |
976 | uplink_add (name, host, password, vhost, port); |
963 | |
|
|
964 | sfree (name); |
|
|
965 | sfree (host); |
|
|
966 | sfree (password); |
|
|
967 | sfree (vhost); |
|
|
968 | |
977 | |
969 | return 0; |
978 | return 0; |
970 | } |
979 | } |
971 | |
980 | |
972 | static int |
981 | static int |
… | |
… | |
1412 | static int |
1421 | static int |
1413 | c_ci_fantasy (config_entry_t *ce) |
1422 | c_ci_fantasy (config_entry_t *ce) |
1414 | { |
1423 | { |
1415 | chansvs.fantasy = true; |
1424 | chansvs.fantasy = true; |
1416 | |
1425 | |
1417 | if (chansvs.me != NULL) |
|
|
1418 | fcmd_agent = chansvs.me; |
|
|
1419 | |
|
|
1420 | return 0; |
1426 | return 0; |
1421 | } |
1427 | } |
1422 | |
1428 | |
1423 | static int |
1429 | static int |
1424 | c_ci_vop (config_entry_t *ce) |
1430 | c_ci_vop (config_entry_t *ce) |
… | |
… | |
2163 | { |
2169 | { |
2164 | slog (LG_ERROR, "conf_rehash(): conf file was malformed, aborting rehash"); |
2170 | slog (LG_ERROR, "conf_rehash(): conf file was malformed, aborting rehash"); |
2165 | |
2171 | |
2166 | /* freeing the new conf strings */ |
2172 | /* freeing the new conf strings */ |
2167 | sfree (chansvs.nick); |
2173 | sfree (chansvs.nick); |
2168 | me.fini (); |
2174 | me.cleanup (); |
2169 | |
2175 | |
2170 | /* return everything to the way it was before */ |
2176 | /* return everything to the way it was before */ |
2171 | me = hold_me; |
2177 | me = hold_me; |
2172 | |
2178 | |
2173 | /* not fully ok, oh well */ |
2179 | /* not fully ok, oh well */ |