diff options
99 files changed, 1147 insertions, 4921 deletions
diff --git a/Makefile.am b/Makefile.am index 941eb3a5c..3f1b6d592 100644 --- a/Makefile.am +++ b/Makefile.am @@ -97,8 +97,6 @@ SUBDIRS = . \ libmu_compat\ testsuite\ lib\ - libmu_argp\ - libmu_cfg\ $(LIBMU_CPP_DIR)\ $(GINT_DIR)\ $(LIBMU_SCM_DIR)\ diff --git a/configure.ac b/configure.ac index d9f1b588f..089419ae6 100644 --- a/configure.ac +++ b/configure.ac @@ -1480,9 +1480,7 @@ AC_CONFIG_FILES([ include/mailutils/cpp/Makefile lib/Makefile lib/gnu/Makefile - libmu_argp/Makefile libmu_auth/Makefile - libmu_cfg/Makefile libmu_cpp/Makefile libmu_scm/Makefile libmu_scm/mailutils/Makefile @@ -181,7 +181,6 @@ static char *frm_argp_capa[] = { "debug", "mailbox", "locking", - "tls", NULL }; @@ -328,7 +327,7 @@ main (int argc, char **argv) /* register the formats. */ mu_register_all_mbox_formats (); - mu_cli_capa_register (&mu_cli_capa_tls); + mu_auth_register_module (&mu_auth_tls_module); mu_cli (argc, argv, &cli, frm_argp_capa, NULL, &argc, &argv); if (align && (s = util_getcols ())) @@ -63,6 +63,7 @@ #include <mailutils/error.h> #include <mailutils/util.h> #include <mailutils/mime.h> +#include <mailutils/mu_auth.h> #include "mailutils/cli.h" diff --git a/frm/from.c b/frm/from.c index 7995bb472..588f76679 100644 --- a/frm/from.c +++ b/frm/from.c @@ -48,7 +48,6 @@ static char *capa[] = { "debug", "mailbox", "locking", - "tls", NULL }; @@ -89,7 +88,7 @@ main (int argc, char **argv) /* register the formats. */ mu_register_all_mbox_formats (); - mu_cli_capa_register (&mu_cli_capa_tls); + mu_auth_register_module (&mu_auth_tls_module); mu_cli (argc, argv, &cli, capa, NULL, &argc, &argv); if (argc > 1) diff --git a/imap4d/Makefile.am b/imap4d/Makefile.am index d0f0e81a6..ab421cc73 100644 --- a/imap4d/Makefile.am +++ b/imap4d/Makefile.am @@ -72,7 +72,7 @@ imap4d_SOURCES = \ util.c imap4d_LDADD = \ - ${MU_APP_LIBRARIES}\ + ${MU_APP_NEW_LIBRARIES}\ ${MU_LIB_MBOX}\ ${MU_LIB_MH}\ ${MU_LIB_MAILDIR}\ diff --git a/imap4d/imap4d.c b/imap4d/imap4d.c index a256dd46a..2c975056e 100644 --- a/imap4d/imap4d.c +++ b/imap4d/imap4d.c @@ -17,7 +17,7 @@ #include "imap4d.h" #include <mailutils/gsasl.h> -#include "mailutils/libargp.h" +#include "mailutils/cli.h" #include "mailutils/kwd.h" #include "tcpwrap.h" @@ -56,93 +56,79 @@ int ident_encrypt_only; int test_mode; const char *program_version = "imap4d (" PACKAGE_STRING ")"; -static char doc[] = N_("GNU imap4d -- the IMAP4D daemon."); - -#define OPT_PREAUTH 259 -#define OPT_FOREGROUND 260 -#define OPT_TEST_MODE 261 - -static struct argp_option options[] = { - { "foreground", OPT_FOREGROUND, 0, 0, N_("remain in foreground"), 0}, - { "inetd", 'i', 0, 0, N_("run in inetd mode"), 0}, - { "daemon", 'd', N_("NUMBER"), OPTION_ARG_OPTIONAL, - N_("runs in daemon mode with a maximum of NUMBER children"), 0 }, - { "test", OPT_TEST_MODE, 0, 0, - N_("run in test mode"), 0 }, - { "preauth", OPT_PREAUTH, NULL, 0, - N_("start in preauth mode") }, + + +static void +set_foreground (struct mu_parseopt *po, struct mu_option *opt, + char const *arg) +{ + mu_m_server_set_foreground (server, 1); +} + +static void +set_inetd_mode (struct mu_parseopt *po, struct mu_option *opt, + char const *arg) +{ + mu_m_server_set_mode (server, MODE_INTERACTIVE); +} - {NULL, 0, NULL, 0, NULL, 0} -}; +static void +set_daemon_mode (struct mu_parseopt *po, struct mu_option *opt, + char const *arg) +{ + mu_m_server_set_mode (server, MODE_DAEMON); + if (arg) + { + size_t max_children; + char *errmsg; + int rc = mu_str_to_c (arg, mu_c_size, &max_children, &errmsg); + if (rc) + { + mu_parseopt_error (po, _("%s: bad argument"), arg); + exit (po->po_exit_error); + } + mu_m_server_set_max_children (server, max_children); + } +} +static void +set_preauth (struct mu_parseopt *po, struct mu_option *opt, char const *arg) +{ + preauth_mode = preauth_stdio; +} -static error_t imap4d_parse_opt (int key, char *arg, - struct argp_state *state); +static struct mu_option imap4d_options[] = { + { "foreground", 0, NULL, MU_OPTION_DEFAULT, + N_("remain in foreground"), + mu_c_bool, NULL, set_foreground }, + { "inetd", 'i', NULL, MU_OPTION_DEFAULT, + N_("run in inetd mode"), + mu_c_bool, NULL, set_inetd_mode }, + { "daemon", 'd', N_("NUMBER"), MU_OPTION_ARG_OPTIONAL, + N_("runs in daemon mode with a maximum of NUMBER children"), + mu_c_string, NULL, set_daemon_mode }, -static struct argp argp = { - options, - imap4d_parse_opt, - NULL, - doc, - NULL, - NULL, NULL -}; + { "test", 0, NULL, MU_OPTION_DEFAULT, + N_("run in test mode"), + mu_c_bool, &test_mode }, -static const char *imap4d_capa[] = { - "mailutils", + { "preauth", 0, NULL, MU_OPTION_DEFAULT, + N_("start in preauth mode"), + mu_c_string, NULL, set_preauth }, + + MU_OPTION_END +}, *options[] = { imap4d_options, NULL }; + + +static char *capa[] = { "auth", - "common", "debug", "mailbox", "locking", "logging", NULL }; - -static error_t -imap4d_parse_opt (int key, char *arg, struct argp_state *state) -{ - static mu_list_t lst; - - switch (key) - { - case 'd': - mu_argp_node_list_new (lst, "mode", "daemon"); - if (arg) - mu_argp_node_list_new (lst, "max-children", arg); - break; - - case 'i': - mu_argp_node_list_new (lst, "mode", "inetd"); - break; - - case OPT_FOREGROUND: - mu_argp_node_list_new (lst, "foreground", "yes"); - break; - - case OPT_PREAUTH: - preauth_mode = preauth_stdio; - break; - - case OPT_TEST_MODE: - mu_argp_node_list_new (lst, "mode", "inetd"); - test_mode = 1; - break; - - case ARGP_KEY_INIT: - mu_argp_node_list_init (&lst); - break; - - case ARGP_KEY_FINI: - mu_argp_node_list_finish (lst, NULL, NULL); - break; - - default: - return ARGP_ERR_UNKNOWN; - } - return 0; -} - + static int cb_mode (void *data, mu_config_value_t *val) { @@ -455,6 +441,12 @@ static struct mu_cfg_param imap4d_cfg_param[] = { { NULL } }; +struct mu_cli_setup cli = { + options, + imap4d_cfg_param, + N_("GNU imap4d -- the IMAP4D daemon.") +}; + int mu_get_user_groups (const char *user, mu_list_t retain, mu_list_t *pgrouplist) { @@ -933,18 +925,10 @@ main (int argc, char **argv) mu_register_local_mbox_formats (); imap4d_capability_init (); -#ifdef WITH_TLS - mu_gocs_register ("tls", mu_tls_module_init); -#endif /* WITH_TLS */ -#ifdef WITH_GSASL - mu_gocs_register ("gsasl", mu_gsasl_module_init); -#endif mu_tcpwrapper_cfg_init (); manlock_cfg_init (); mu_acl_cfg_init (); - mu_argp_init (NULL, NULL); - mu_m_server_create (&server, program_version); mu_m_server_set_config_size (server, sizeof (struct imap4d_srv_config)); mu_m_server_set_conn (server, imap4d_connection); @@ -961,10 +945,16 @@ main (int argc, char **argv) mu_log_syslog = 1; - if (mu_app_init (&argp, imap4d_capa, imap4d_cfg_param, - argc, argv, 0, NULL, server)) - exit (EX_CONFIG); /* FIXME: No way to discern from EX_USAGE? */ - + mu_cli (argc, argv, &cli, capa, server, &argc, &argv); + if (argc) + { + mu_error (_("too many arguments")); + exit (EX_USAGE); + } + + if (test_mode) + mu_m_server_set_mode (server, MODE_INTERACTIVE); + if (login_disabled) imap4d_capability_add (IMAP_CAPA_LOGINDISABLED); diff --git a/imap4d/imap4d.h b/imap4d/imap4d.h index c1182f429..d5472873c 100644 --- a/imap4d/imap4d.h +++ b/imap4d/imap4d.h @@ -106,6 +106,7 @@ #include <mailutils/imapio.h> #include <mailutils/imaputil.h> #include <mailutils/msgset.h> +#include <mailutils/syslog.h> #include <mu_umaxtostr.h> #include <muaux.h> diff --git a/include/mailutils/Makefile.am b/include/mailutils/Makefile.am index 9ae3929af..d1e001904 100644 --- a/include/mailutils/Makefile.am +++ b/include/mailutils/Makefile.am @@ -48,7 +48,6 @@ pkginclude_HEADERS = \ error.h\ filter.h\ folder.h\ - gocs.h\ gsasl.h\ guile.h\ header.h\ @@ -59,8 +58,6 @@ pkginclude_HEADERS = \ iterator.h\ kwd.h\ ldap.h\ - libargp.h\ - libcfg.h\ list.h\ locker.h\ log.h\ diff --git a/include/mailutils/cli.h b/include/mailutils/cli.h index 7067f213c..d2964ff1d 100644 --- a/include/mailutils/cli.h +++ b/include/mailutils/cli.h @@ -35,7 +35,8 @@ struct mu_cli_capa void mu_cli_capa_init (void); void mu_cli_capa_register (struct mu_cli_capa *capa); -void mu_cli_capa_apply (char const *name, mu_list_t opts, mu_list_t commits); +void mu_cli_capa_extend_settings (char const *name, mu_list_t opts, + mu_list_t commits); struct mu_cli_setup { @@ -49,6 +50,8 @@ struct mu_cli_setup int ex_usage; /* If not 0, exit code on usage errors */ int ex_config; /* If not 0, exit code on configuration errors */ + int inorder; + void (*prog_doc_hook) (mu_stream_t); }; void mu_version_func (struct mu_parseopt *po, mu_stream_t stream); diff --git a/include/mailutils/daemon.h b/include/mailutils/daemon.h index fa29b41c7..2fa699e20 100644 --- a/include/mailutils/daemon.h +++ b/include/mailutils/daemon.h @@ -20,7 +20,6 @@ #define _MAILUTILS_DAEMON_H #include <mailutils/types.h> -#include <mailutils/gocs.h> #ifdef __cplusplus extern "C" { @@ -33,8 +32,6 @@ extern "C" { extern int mu_daemon_create_pidfile (const char *); extern void mu_daemon_remove_pidfile (void); -extern struct mu_gocs_daemon mu_gocs_daemon; - #ifdef __cplusplus } #endif diff --git a/include/mailutils/gocs.h b/include/mailutils/gocs.h deleted file mode 100644 index be3de555f..000000000 --- a/include/mailutils/gocs.h +++ /dev/null @@ -1,98 +0,0 @@ -/* GNU Mailutils -- a suite of utilities for electronic mail - Copyright (C) 2007-2008, 2010-2012, 2014-2016 Free Software - Foundation, Inc. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 3 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be u |