diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-12-11 15:09:47 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-12-11 15:09:47 +0000 |
commit | d60e6271eff47f8665b869b9a248f7a62afbfa4f (patch) | |
tree | b2865cdcbf8242aea7e48878b3efa007f0f20589 | |
parent | 1b2350e50f3f39fbc40811da4b942a71fd1dab8d (diff) | |
download | mailutils-d60e6271eff47f8665b869b9a248f7a62afbfa4f.tar.gz mailutils-d60e6271eff47f8665b869b9a248f7a62afbfa4f.tar.bz2 |
* comsat/comsat.c, imap4d/imap4d.c, maidag/maidag.c,
pop3d/pop3d.c: Call mu_tcpwrapper_cfg_init.
* include/mailutils/cfg.h (mu_cfg_section_add_container)
(mu_cfg_section_add_params, mu_create_canned_section)
(mu_create_canned_param, mu_get_canned_container): New functions.
* lib/tcpwrap.c (mu_tcpwrapper_cfg_init): New function.
* lib/tcpwrap.h (TCP_WRAPPERS_CONFIG): Change definition.
* mailbox/cfg_driver.c (mu_create_canned_section)
(mu_create_canned_param): Change prototypes.
(add_parameters): Rename to mu_cfg_section_add_params, make
extern. All callers changed.
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | comsat/comsat.c | 1 | ||||
-rw-r--r-- | imap4d/imap4d.c | 1 | ||||
-rw-r--r-- | include/mailutils/cfg.h | 10 | ||||
-rw-r--r-- | lib/tcpwrap.c | 42 | ||||
-rw-r--r-- | lib/tcpwrap.h | 29 | ||||
-rw-r--r-- | maidag/maidag.c | 4 | ||||
-rw-r--r-- | mailbox/cfg_driver.c | 57 | ||||
-rw-r--r-- | pop3d/pop3d.c | 2 |
9 files changed, 116 insertions, 44 deletions
@@ -1,5 +1,19 @@ 2007-12-11 Sergey Poznyakoff <gray@gnu.org.ua> + * comsat/comsat.c, imap4d/imap4d.c, maidag/maidag.c, + pop3d/pop3d.c: Call mu_tcpwrapper_cfg_init. + + * include/mailutils/cfg.h (mu_cfg_section_add_container) + (mu_cfg_section_add_params, mu_create_canned_section) + (mu_create_canned_param, mu_get_canned_container): New functions. + * lib/tcpwrap.c (mu_tcpwrapper_cfg_init): New function. + * lib/tcpwrap.h (TCP_WRAPPERS_CONFIG): Change definition. + * mailbox/cfg_driver.c (mu_create_canned_section) + (mu_create_canned_param): Change prototypes. + (add_parameters): Rename to mu_cfg_section_add_params, make + extern. All callers changed. + + * include/mailutils/cfg.h (mu_cfg_section): New type. (struct mu_cfg_param.offset): New member (mu_offsetof): New define diff --git a/comsat/comsat.c b/comsat/comsat.c index 0f4ff9564..099866302 100644 --- a/comsat/comsat.c +++ b/comsat/comsat.c @@ -150,6 +150,7 @@ main (int argc, char **argv) mu_argp_init (program_version, NULL); mu_gocs_daemon = default_gocs_daemon; + if (mu_app_init (&argp, comsat_argp_capa, NULL, argc, argv, 0, &ind, NULL)) exit (1); diff --git a/imap4d/imap4d.c b/imap4d/imap4d.c index f6c6d4fc5..6ea361076 100644 --- a/imap4d/imap4d.c +++ b/imap4d/imap4d.c @@ -324,6 +324,7 @@ main (int argc, char **argv) #ifdef WITH_GSASL mu_gocs_register ("gsasl", mu_gsasl_module_init); #endif + mu_tcpwrapper_cfg_init (); mu_argp_init (program_version, NULL); if (mu_app_init (&argp, imap4d_capa, imap4d_cfg_param, argc, argv, 0, NULL, NULL)) diff --git a/include/mailutils/cfg.h b/include/mailutils/cfg.h index 7ff55d10e..72b5ec65c 100644 --- a/include/mailutils/cfg.h +++ b/include/mailutils/cfg.h @@ -194,6 +194,16 @@ int mu_config_create_container (struct mu_cfg_cont **pcont, int mu_config_clone_container (struct mu_cfg_cont *cont); void mu_config_destroy_container (struct mu_cfg_cont **pcont); +int mu_cfg_section_add_container (struct mu_cfg_section *sect, + struct mu_cfg_cont *cont); +int mu_cfg_section_add_params (struct mu_cfg_section *sect, + struct mu_cfg_param *param); + + +int mu_create_canned_section (char *name, struct mu_cfg_section **psection); +int mu_create_canned_param (char *name, struct mu_cfg_param **pparam); +struct mu_cfg_cont *mu_get_canned_container (const char *name); + int mu_cfg_scan_tree (mu_cfg_tree_t *tree, struct mu_cfg_section *sections, void *target, void *call_data); diff --git a/lib/tcpwrap.c b/lib/tcpwrap.c index ea85d5c6d..a88fe74a2 100644 --- a/lib/tcpwrap.c +++ b/lib/tcpwrap.c @@ -87,8 +87,50 @@ mu_tcpwrapper_access (int fd) return hosts_access (&req); } +struct mu_cfg_param tcpwrapper_param[] = { + { "enable", mu_cfg_bool, &mu_tcp_wrapper_enable, 0, NULL, + N_("Enable TCP wrapper access control. Default is \"yes\".") }, + { "daemon", mu_cfg_string, &mu_tcp_wrapper_daemon, 0, NULL, + N_("Set daemon name for TCP wrapper lookups. Default is program name."), + N_("name") }, + { "allow-table", mu_cfg_callback, NULL, 0, + mu_tcp_wrapper_cb_hosts_allow, + N_("Use file for positive client address access control " + "(default: /etc/hosts.allow)."), + N_("file") }, + { "deny-table", mu_cfg_callback, NULL, 0, + mu_tcp_wrapper_cb_hosts_deny, + N_("Use file for negative client address access control " + "(default: /etc/hosts.deny)."), + N_("file") }, + { "allow-syslog-level", mu_cfg_callback, NULL, 0, + mu_tcp_wrapper_cb_hosts_allow_syslog, + N_("Log host allows at this syslog level. See logging { facility } for " + "a description of argument syntax."), + N_("level") }, + { "allow-deny-level", mu_cfg_callback, NULL, 0, + mu_tcp_wrapper_cb_hosts_deny_syslog, + N_("Log host denies at this syslog level. See logging { facility } for " + "a description of argument syntax."), + N_("level") }, + { NULL } +}; + +void +mu_tcpwrapper_cfg_init () +{ + struct mu_cfg_section *section; + mu_create_canned_section ("tcp-wrappers", §ion); + mu_cfg_section_add_params (section, tcpwrapper_param); +} + #else +void +mu_tcpwrapper_cfg_init () +{ +} + int mu_tcpwrapper_access (int fd) { diff --git a/lib/tcpwrap.h b/lib/tcpwrap.h index 22142edf3..4d461c312 100644 --- a/lib/tcpwrap.h +++ b/lib/tcpwrap.h @@ -31,33 +31,10 @@ extern int mu_tcp_wrapper_cb_hosts_deny_syslog (mu_debug_t debug, void *data, char *arg); extern int mu_tcpwrapper_access (int fd); +extern void mu_tcpwrapper_cfg_init (void); + #ifdef WITH_LIBWRAP -# define TCP_WRAPPERS_CONFIG \ - { "tcp-wrapper-enable", mu_cfg_bool, &mu_tcp_wrapper_enable, 0, NULL, \ - N_("Enable TCP wrapper access control. Default is \"yes\".") }, \ - { "tcp-wrapper-daemon", mu_cfg_string, &mu_tcp_wrapper_daemon, 0, NULL, \ - N_("Set daemon name for TCP wrapper lookups. Default is program name."), \ - N_("name") }, \ - { "hosts-allow-table", mu_cfg_callback, NULL, 0, \ - mu_tcp_wrapper_cb_hosts_allow, \ - N_("Use file for positive client address access control " \ - "(default: /etc/hosts.allow)."), \ - N_("file") }, \ - { "hosts-deny-table", mu_cfg_callback, NULL, 0, \ - mu_tcp_wrapper_cb_hosts_deny, \ - N_("Use file for negative client address access control " \ - "(default: /etc/hosts.deny)."), \ - N_("file") }, \ - { "hosts-allow-syslog-level", mu_cfg_callback, NULL, 0, \ - mu_tcp_wrapper_cb_hosts_allow_syslog, \ - N_("Log host allows at this syslog level. See logging { facility } for " \ - "a description of argument syntax."), \ - N_("level") }, \ - { "hosts-allow-deny-level", mu_cfg_callback, NULL, 0, \ - mu_tcp_wrapper_cb_hosts_deny_syslog, \ - N_("Log host denies at this syslog level. See logging { facility } for " \ - "a description of argument syntax."), \ - N_("level") }, +# define TCP_WRAPPERS_CONFIG { "tcp-wrappers", mu_cfg_section }, #else # define TCP_WRAPPERS_CONFIG #endif diff --git a/maidag/maidag.c b/maidag/maidag.c index eb3021a35..a5766161e 100644 --- a/maidag/maidag.c +++ b/maidag/maidag.c @@ -457,7 +457,9 @@ main (int argc, char *argv[]) mu_gocs_register ("sieve", mu_sieve_module_init); mu_gocs_daemon = daemon_param; - + + mu_tcpwrapper_cfg_init (); + /* Parse command line */ mu_argp_init (program_version, NULL); if (mu_app_init (&argp, maidag_argp_capa, maidag_cfg_param, diff --git a/mailbox/cfg_driver.c b/mailbox/cfg_driver.c index 9260a6444..dcee940e0 100644 --- a/mailbox/cfg_driver.c +++ b/mailbox/cfg_driver.c @@ -45,28 +45,40 @@ static void alloc_section_tab () { if (!section_tab) - mu_assoc_create (§ion_tab, sizeof (struct mu_cfg_cont *), + mu_assoc_create (§ion_tab, sizeof (struct mu_cfg_cont **), MU_ASSOC_COPY_KEY); } int -mu_create_canned_section (struct mu_cfg_section *section) +mu_create_canned_section (char *name, struct mu_cfg_section **psection) { - struct mu_cfg_cont *cont; + int rc; + struct mu_cfg_cont **pcont; alloc_section_tab (); - mu_config_create_container (&cont, mu_cfg_cont_section); - cont->v.section = *section; - return mu_assoc_install (section_tab, cont->v.section.ident, &cont); + rc = mu_assoc_ref_install (section_tab, name, (void **)&pcont); + if (rc == 0 || rc == MU_ERR_EXISTS) + { + mu_config_create_container (pcont, mu_cfg_cont_section); + *psection = &(*pcont)->v.section; + (*psection)->ident = name; + } + return rc; } int -mu_create_canned_param (struct mu_cfg_param *param) +mu_create_canned_param (char *name, struct mu_cfg_param **pparam) { - struct mu_cfg_cont *cont; + int rc; + struct mu_cfg_cont **pcont; alloc_section_tab (); - mu_config_create_container (&cont, mu_cfg_cont_param); - cont->v.param = *param; - return mu_assoc_install (section_tab, cont->v.param.ident, &cont); + rc = mu_assoc_ref_install (section_tab, name, (void **)&pcont); + if (rc == 0 || rc == MU_ERR_EXISTS) + { + mu_config_create_container (pcont, mu_cfg_cont_param); + *pparam = &(*pcont)->v.param; + (*pparam)->ident = name; + } + return rc; } struct mu_cfg_cont * @@ -210,13 +222,24 @@ mu_config_destroy_container (struct mu_cfg_cont **pcont) } -static int -add_parameters (struct mu_cfg_section *sect, struct mu_cfg_param *param) +int +mu_cfg_section_add_container (struct mu_cfg_section *sect, + struct mu_cfg_cont *cont) { - if (!param) + if (!cont) return 0; if (!sect->children) mu_list_create (§->children); + return mu_list_append (sect->children, cont); +} + +int +mu_cfg_section_add_params (struct mu_cfg_section *sect, + struct mu_cfg_param *param) +{ + if (!param) + return 0; + for (; param->ident; param++) { int rc; @@ -241,7 +264,7 @@ add_parameters (struct mu_cfg_section *sect, struct mu_cfg_param *param) return rc; container->v.param = *param; } - mu_list_append (sect->children, container); + mu_cfg_section_add_container (sect, container); } return 0; } @@ -335,13 +358,13 @@ _mu_config_register_section (struct mu_cfg_cont **proot, s->label = label ? strdup (label) : NULL; s->parser = parser; s->children = NULL; - add_parameters (s, param); + mu_cfg_section_add_params (s, param); if (psection) *psection = s; } else { - add_parameters (parent, param); + mu_cfg_section_add_params (parent, param); /* FIXME: */ if (!parent->parser) parent->parser = parser; diff --git a/pop3d/pop3d.c b/pop3d/pop3d.c index 4c80845a9..7eeec35bc 100644 --- a/pop3d/pop3d.c +++ b/pop3d/pop3d.c @@ -260,6 +260,8 @@ main (int argc, char **argv) #ifdef WITH_TLS mu_gocs_register ("tls", mu_tls_module_init); #endif /* WITH_TLS */ + mu_tcpwrapper_cfg_init (); + mu_gocs_daemon = default_gocs_daemon; mu_argp_init (program_version, NULL); if (mu_app_init (&argp, pop3d_argp_capa, pop3d_cfg_param, |