Commit d60e6271 d60e6271eff47f8665b869b9a248f7a62afbfa4f by Sergey Poznyakoff

* 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.
1 parent 1b2350e5
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
......
......@@ -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);
......
......@@ -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))
......
......@@ -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);
......
......@@ -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", &section);
mu_cfg_section_add_params (section, tcpwrapper_param);
}
#else
void
mu_tcpwrapper_cfg_init ()
{
}
int
mu_tcpwrapper_access (int fd)
{
......
......@@ -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
......
......@@ -458,6 +458,8 @@ main (int argc, char *argv[])
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,
......
......@@ -45,28 +45,40 @@ static void
alloc_section_tab ()
{
if (!section_tab)
mu_assoc_create (&section_tab, sizeof (struct mu_cfg_cont *),
mu_assoc_create (&section_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 (&sect->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;
......
......@@ -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,
......