Commit cd6f3aa2 cd6f3aa2be6ee19afc67b2d187542418f8b5a609 by Sergey Poznyakoff

Move rc file and argp parsing into separate abstract layers.

* include/mailutils/gocs.h, include/mailutils/pam.h,
include/mailutils/radius.h, include/mailutils/syslog.h: New files
* lib/argpinit.c, lib/muinit.c, lib/muinit.h: New files.
* libsieve/conf.c: New file.

* libcfg: New directory
* libcfg/libcfg.h, libcfg/auth.c, libcfg/common.c, libcfg/init.c,
libcfg/gsasl.c, libcfg/pam.c, libcfg/radius.c, libcfg/sieve.c,
libcfg/sql.c, libcfg/tls.c, libcfg/virtdomain.c,
libcfg/.cvsignore: New files.

* libargp: New directory
* libargp/auth.c, libargp/cmdline.h, libargp/common.c,
libargp/gsasl.c, libargp/mu_argp.h, libargp/mu_argp.c,
libargp/pam.c, libargp/radius.c, libargp/sieve.c, libargp/sql.c,
libargp/tls.c, libargp/virtdomain.c, libargp/.cvsignore: New
files.

* mailbox/.cvsignore: Add cfg_parser.c and cfg_parser.h.
* Makefile.am (SUBDIRS): Add libargp and libcfg.
* configure.ac (MU_APP_LIBRARIES): New variable
(MU_COMMON_INCLUDES): add libargp and libcfg
(AC_CONFIG_FILES): Add libargp and libcfg.

* auth/gsasl.c, auth/pam.c, auth/radius.c, auth/sql.c, auth/sql.h,
auth/tls.c, auth/virtual.c, comsat/comsat.h, frm/frm.h,
guimb/guimb.h, imap4d/imap4d.h, include/mailutils/gsasl.h,
include/mailutils/libsieve.h, include/mailutils/mailutils.h,
include/mailutils/mu_auth.h, include/mailutils/tls.h,
include/mailutils/sql.h, maidag/maidag.h, mail/mail.h,
mail.local/mail.local.h, mailbox/daemon.c, mailbox/system.c,
mh/mh_argp.c, mh/mh_getopt.h, pop3d/pop3d.h,
readmsg/readmsg.h: Remove argp stuff

* comsat/comsat.c, config/mailutils-config.c, dotlock/dotlock.c,
examples/muauth.c, examples/muemail.c, frm/frm.c, frm/from.c,
guimb/main.c, imap4d/idle.c, imap4d/imap4d.c, imap4d/util.c,
imap4d/version.c, maidag/lmtp.c, maidag/maidag.c,
maidag/mailquota.c, mail/mail.c, mail/send.c, mail/version.c,
mail.local/mailquota.c, mail.local/main.c,
mail.remote/mail.remote.c, mailbox/mu_auth.c, messages/messages.c,
mimeview/mimeview.c, movemail/movemail.c, pop3d/extra.c,
pop3d/pop3d.c, pop3d/popauth.c, readmsg/readmsg.c, sieve/sieve.c:
Use mu_app_init for parsing command line and
configuration files.
* comsat/Makefile.am, config/Makefile.am, dotlock/Makefile.am,
examples/Makefile.am, frm/Makefile.am, guimb/Makefile.am,
imap4d/Makefile.am, maidag/Makefile.am, mail/Makefile.am,
mail.local/Makefile.am, mail.remote/Makefile.am,
mailbox/Makefile.am, messages/Makefile.am, mimeview/Makefile.am,
movemail/Makefile.am, pop3d/Makefile.am, readmsg/Makefile.am,
sieve/Makefile.am: Use MU_APP_LIBRARIES.

* include/mailutils/Makefile.am: Add new files.
* include/mailutils/argp.h: Remove.
* include/mailutils/cfg.h: New file.
* include/mailutils/daemon.h (MODE_INTERACTIVE,MODE_DAEMON): New
defines (from removed argp.h).
(mu_gocs_daemon): New decl.
* include/mailutils/error.h (mu_program_name): New variable
(mu_set_program_name): New function.
* lib/Makefile.am (libmuaux_la_SOURCES): Add new files.
* libsieve/Makefile.am (libsieve_la_SOURCES): Remove argp.c, add
conf.c instead.
* libsieve/argp.c: Remove.

* mailbox/cfg_parser.y (mu_cfg_parse_boolean): New function.
* mailbox/mu_argp.c: Remove.

* mailbox/muerror.c (mu_program_name): New variable
(mu_set_program_name): New function
(mu_default_error_printer): Print program name before diagnostic
string.
* mailbox/mutil.c (mu_sql_decode_password_type): New function.
* mh/mh_whom.c (mh_alias_expand): Bugfix
* po/POTFILES.in: Update
* testsuite/lib/mailutils.exp (mu_init): Pass --no-site-rcfile
--no-user-rcfile to all programs.
1 parent 7e7a878f
Showing 126 changed files with 2783 additions and 838 deletions
2007-11-17 Sergey Poznyakoff <gray@gnu.org.ua>
Move rc file and argp parsing into separate abstract layers.
* include/mailutils/gocs.h, include/mailutils/pam.h,
include/mailutils/radius.h, include/mailutils/syslog.h: New files
* lib/argpinit.c, lib/muinit.c, lib/muinit.h: New files.
* libsieve/conf.c: New file.
* libcfg: New directory
* libcfg/libcfg.h, libcfg/auth.c, libcfg/common.c, libcfg/init.c,
libcfg/gsasl.c, libcfg/pam.c, libcfg/radius.c, libcfg/sieve.c,
libcfg/sql.c, libcfg/tls.c, libcfg/virtdomain.c,
libcfg/.cvsignore: New files.
* libargp: New directory
* libargp/auth.c, libargp/cmdline.h, libargp/common.c,
libargp/gsasl.c, libargp/mu_argp.h, libargp/mu_argp.c,
libargp/pam.c, libargp/radius.c, libargp/sieve.c, libargp/sql.c,
libargp/tls.c, libargp/virtdomain.c, libargp/.cvsignore: New
files.
* mailbox/.cvsignore: Add cfg_parser.c and cfg_parser.h.
* Makefile.am (SUBDIRS): Add libargp and libcfg.
* configure.ac (MU_APP_LIBRARIES): New variable
(MU_COMMON_INCLUDES): add libargp and libcfg
(AC_CONFIG_FILES): Add libargp and libcfg.
* auth/gsasl.c, auth/pam.c, auth/radius.c, auth/sql.c, auth/sql.h,
auth/tls.c, auth/virtual.c, comsat/comsat.h, frm/frm.h,
guimb/guimb.h, imap4d/imap4d.h, include/mailutils/gsasl.h,
include/mailutils/libsieve.h, include/mailutils/mailutils.h,
include/mailutils/mu_auth.h, include/mailutils/tls.h,
include/mailutils/sql.h, maidag/maidag.h, mail/mail.h,
mail.local/mail.local.h, mailbox/daemon.c, mailbox/system.c,
mh/mh_argp.c, mh/mh_getopt.h, pop3d/pop3d.h,
readmsg/readmsg.h: Remove argp stuff
* comsat/comsat.c, config/mailutils-config.c, dotlock/dotlock.c,
examples/muauth.c, examples/muemail.c, frm/frm.c, frm/from.c,
guimb/main.c, imap4d/idle.c, imap4d/imap4d.c, imap4d/util.c,
imap4d/version.c, maidag/lmtp.c, maidag/maidag.c,
maidag/mailquota.c, mail/mail.c, mail/send.c, mail/version.c,
mail.local/mailquota.c, mail.local/main.c,
mail.remote/mail.remote.c, mailbox/mu_auth.c, messages/messages.c,
mimeview/mimeview.c, movemail/movemail.c, pop3d/extra.c,
pop3d/pop3d.c, pop3d/popauth.c, readmsg/readmsg.c, sieve/sieve.c:
Use mu_app_init for parsing command line and
configuration files.
* comsat/Makefile.am, config/Makefile.am, dotlock/Makefile.am,
examples/Makefile.am, frm/Makefile.am, guimb/Makefile.am,
imap4d/Makefile.am, maidag/Makefile.am, mail/Makefile.am,
mail.local/Makefile.am, mail.remote/Makefile.am,
mailbox/Makefile.am, messages/Makefile.am, mimeview/Makefile.am,
movemail/Makefile.am, pop3d/Makefile.am, readmsg/Makefile.am,
sieve/Makefile.am: Use MU_APP_LIBRARIES.
* include/mailutils/Makefile.am: Add new files.
* include/mailutils/argp.h: Remove.
* include/mailutils/cfg.h: New file.
* include/mailutils/daemon.h (MODE_INTERACTIVE,MODE_DAEMON): New
defines (from removed argp.h).
(mu_gocs_daemon): New decl.
* include/mailutils/error.h (mu_program_name): New variable
(mu_set_program_name): New function.
* lib/Makefile.am (libmuaux_la_SOURCES): Add new files.
* libsieve/Makefile.am (libsieve_la_SOURCES): Remove argp.c, add
conf.c instead.
* libsieve/argp.c: Remove.
* mailbox/cfg_parser.y (mu_cfg_parse_boolean): New function.
* mailbox/mu_argp.c: Remove.
* mailbox/muerror.c (mu_program_name): New variable
(mu_set_program_name): New function
(mu_default_error_printer): Print program name before diagnostic
string.
* mailbox/mutil.c (mu_sql_decode_password_type): New function.
* mh/mh_whom.c (mh_alias_expand): Bugfix
* po/POTFILES.in: Update
* testsuite/lib/mailutils.exp (mu_init): Pass --no-site-rcfile
--no-user-rcfile to all programs.
2007-11-12 Sergey Poznyakoff <gray@gnu.org.ua>
* maidag/lmtp.c: Use English reply texts.
......
......@@ -33,6 +33,8 @@ SUBDIRS = \
libsieve\
libmu_cpp\
libmu_scm\
libargp\
libcfg\
doc\
config\
examples\
......
......@@ -26,7 +26,6 @@
#include <string.h>
#include <limits.h>
#include <unistd.h>
#include <mailutils/argp.h>
#include <mailutils/error.h>
#include <mailutils/errno.h>
#include <mailutils/mu_auth.h>
......@@ -36,54 +35,21 @@
#include <gsasl.h>
#include <lbuf.h>
char *mu_gsasl_cram_md5_pwd = SITE_CRAM_MD5_PWD;
struct mu_gsasl_module_data mu_gsasl_module_data;
#define ARG_CRAM_PASSWD 1
static struct argp_option _gsasl_argp_options[] = {
{"cram-passwd", ARG_CRAM_PASSWD, N_("FILE"), OPTION_HIDDEN,
N_("Specify password file for CRAM-MD5 authentication"), 0},
{ NULL, 0, NULL, 0, NULL, 0 }
};
static error_t
_gsasl_argp_parser (int key, char *arg, struct argp_state *state)
int
mu_gsasl_module_init (void *data)
{
switch (key)
{
case ARG_CRAM_PASSWD:
mu_gsasl_cram_md5_pwd = arg;
break;
static struct mu_gsasl_module_data _default_module_data = {
SITE_CRAM_MD5_PWD
};
default:
return ARGP_ERR_UNKNOWN;
}
if (!data)
mu_gsasl_module_data = _default_module_data;
memcpy (&mu_gsasl_module_data, data, sizeof (mu_gsasl_module_data));
return 0;
}
static struct argp _gsasl_argp = {
_gsasl_argp_options,
_gsasl_argp_parser
};
static struct argp_child _gsasl_argp_child = {
&_gsasl_argp,
0,
NULL,
0
};
void
mu_gsasl_init_argp ()
{
if (mu_register_capa ("gsasl", &_gsasl_argp_child, NULL))
{
mu_error (_("INTERNAL ERROR: cannot register argp capability gsasl"));
abort ();
}
}
struct _gsasl_stream {
Gsasl_session_ctx *sess_ctx; /* Context */
int last_err; /* Last Gsasl error code */
......
......@@ -43,11 +43,10 @@
#include <mailutils/list.h>
#include <mailutils/iterator.h>
#include <mailutils/mailbox.h>
#include <mailutils/argp.h>
#include <mailutils/mu_auth.h>
#include <mailutils/nls.h>
char *pam_service = NULL;
char *mu_pam_service = NULL;
#ifdef USE_LIBPAM
#define COPY_STRING(s) (s) ? strdup(s) : NULL
......@@ -120,7 +119,7 @@ mu_authenticate_pam (struct mu_auth_data **return_data MU_ARG_UNUSED,
_user = (char *) auth_data->name;
_pwd = pass;
pamerror = pam_start (pam_service, _user, &PAM_conversation, &pamh);
pamerror = pam_start (mu_pam_service, _user, &PAM_conversation, &pamh);
PAM_ERROR;
pamerror = pam_authenticate (pamh, 0);
PAM_ERROR;
......@@ -132,39 +131,6 @@ mu_authenticate_pam (struct mu_auth_data **return_data MU_ARG_UNUSED,
return pamerror != PAM_SUCCESS;
}
#define ARG_PAM_SERVICE 1
static error_t
mu_pam_argp_parser (int key, char *arg, struct argp_state *state)
{
switch (key)
{
case ARG_PAM_SERVICE:
pam_service = arg;
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
static struct argp_option mu_pam_argp_option[] = {
{ "pam-service", ARG_PAM_SERVICE, N_("STRING"), OPTION_HIDDEN,
N_("Use STRING as PAM service name"), 0},
{ NULL, 0, NULL, 0, NULL, 0 }
};
struct argp mu_pam_argp = {
mu_pam_argp_option,
mu_pam_argp_parser,
};
static struct mu_cfg_param pam_cfg_param[] = {
{ "service", mu_cfg_string, &pam_service },
{ NULL }
};
#else
int
......@@ -179,15 +145,17 @@ mu_authenticate_pam (struct mu_auth_data **return_data MU_ARG_UNUSED,
#endif
int
mu_pam_module_init (void *data)
{
if (data)
mu_pam_service = strdup (data);
return 0;
}
struct mu_auth_module mu_auth_pam_module = {
"pam",
#ifdef USE_LIBPAM
&mu_pam_argp,
pam_cfg_param,
#else
NULL,
NULL,
#endif
mu_pam_module_init,
mu_authenticate_pam,
NULL,
mu_auth_nosupport,
......
......@@ -34,7 +34,7 @@
#include <mailutils/list.h>
#include <mailutils/iterator.h>
#include <mailutils/mailbox.h>
#include <mailutils/argp.h>
#include <mailutils/radius.h>
#include <mailutils/argcv.h>
#include <mailutils/mu_auth.h>
#include <mailutils/error.h>
......@@ -45,39 +45,6 @@
#include <radius/radius.h>
#define ARG_AUTH_REQUEST 256
#define ARG_GETPWNAM_REQUEST 257
#define ARG_GETPWUID_REQUEST 258
#define ARG_RADIUS_DIR 259
static struct argp_option mu_radius_argp_option[] = {
{ "radius-auth-request", ARG_AUTH_REQUEST, N_("REQUEST"), OPTION_HIDDEN,
N_("Radius request to authenitcate the user"), 0 },
{ "radius-getpwnam-request", ARG_GETPWNAM_REQUEST, N_("REQUEST"), OPTION_HIDDEN,
N_("Radius request to retrieve a passwd entry based on username"), 0 },
{ "radius-getpwuid-request", ARG_GETPWUID_REQUEST, N_("REQUEST"), OPTION_HIDDEN,
N_("Radius request to retrieve a passwd entry based on UID"), 0 },
{ "radius-directory", ARG_RADIUS_DIR, N_("DIR"), OPTION_HIDDEN,
N_("Set path to the radius configuration directory"), 0 },
{ NULL }
};
static char *auth_request_str;
static grad_avp_t *auth_request;
static char *getpwnam_request_str;
static grad_avp_t *getpwnam_request;
static char *getpwuid_request_str;
static grad_avp_t *getpwuid_request;
/* Assume radius support is needed if any of the above requests is
defined. Actually, all of them should be, but it is the responsibility
of init to check for consistency of the configuration */
#define NEED_RADIUS_P() \
(auth_request_str||getpwnam_request_str||getpwuid_request_str)
static int radius_auth_enabled;
static int MU_User_Name;
......@@ -88,13 +55,22 @@ static int MU_Dir;
static int MU_Shell;
static int MU_Mailbox;
void
get_attribute (int *pattr, char *name, struct argp_state *state)
static grad_avp_t *auth_request;
static grad_avp_t *getpwnam_request;
static grad_avp_t *getpwuid_request;
int
get_attribute (int *pattr, char *name)
{
grad_dict_attr_t *attr = grad_attr_name_to_dict (name);
if (!attr)
argp_error (state, _("Radius attribute %s not defined"), name);
{
mu_error (_("Radius attribute %s not defined"), name);
return 1;
}
*pattr = attr->value;
return 0;
}
enum parse_state
......@@ -106,8 +82,7 @@ enum parse_state
};
int
parse_pairlist (grad_avp_t **plist, const char *input,
struct argp_state *argp_state)
parse_pairlist (grad_avp_t **plist, char *input)
{
int rc;
int i, argc;
......@@ -121,10 +96,12 @@ parse_pairlist (grad_avp_t **plist, const char *input,
return 1;
if ((rc = mu_argcv_get (input, ",", NULL, &argc, &argv)))
argp_error (argp_state, _("Cannot parse input `%s': %s"),
input, mu_strerror (rc));
{
mu_error (_("Cannot parse input `%s': %s"), input, mu_strerror (rc));
return 1;
}
loc.file = "<command line>"; /* FIXME */
loc.file = "<configuration>"; /*FIXME*/
loc.line = 0;
for (i = 0, state = state_lhs; i < argc; i++)
......@@ -147,81 +124,78 @@ parse_pairlist (grad_avp_t **plist, const char *input,
loc.line = i; /* Just to keep track of error location */
pair = grad_create_pair (&loc, name, grad_operator_equal, argv[i]);
if (!pair)
argp_error (argp_state, _("cannot create radius A/V pair `%s'"),
name);
{
mu_error (_("cannot create radius A/V pair `%s'"), name);
return 1;
}
grad_avl_merge (plist, &pair);
state = state_delim;
break;
case state_delim:
if (strcmp (argv[i], ","))
argp_error (argp_state, _("expected `,' but found `%s'"), argv[i]);
{
mu_error (_("expected `,' but found `%s'"), argv[i]);
return 1;
}
state = state_lhs;
}
}
if (state != state_delim && state != state_delim)
argp_error (argp_state, _("malformed radius A/V list"));
{
mu_error (_("malformed radius A/V list"));
return 1;
}
mu_argcv_free (argc, argv);
return 0;
}
static void
init (struct argp_state *state)
/* Assume radius support is needed if any of the above requests is
defined. Actually, all of them should be, but it is the responsibility
of init to check for consistency of the configuration */
#define NEED_RADIUS_P(cfg) \
((cfg) && \
((cfg)->auth_request || (cfg)->getpwnam_request || (cfg)->getpwuid_request))
int
mu_radius_module_init (void *data)
{
struct mu_radius_module_data *cfg = data;
if (!NEED_RADIUS_P (cfg))
return 0;
grad_config_dir = grad_estrdup (cfg->config_dir);
grad_path_init ();
srand (time (NULL) + getpid ());
if (grad_dict_init ())
argp_error (state, _("Cannot read radius dictionaries"));
{
mu_error (_("Cannot read radius dictionaries"));
return 1;
}
/* Check whether mailutils attributes are defined */
get_attribute (&MU_User_Name, "MU-User-Name", state);
get_attribute (&MU_UID, "MU-UID", state);
get_attribute (&MU_GID, "MU-GID", state);
get_attribute (&MU_GECOS, "MU-GECOS", state);
get_attribute (&MU_Dir, "MU-Dir", state);
get_attribute (&MU_Shell, "MU-Shell", state);
get_attribute (&MU_Mailbox, "MU-Mailbox", state);
if (get_attribute (&MU_User_Name, "MU-User-Name")
|| get_attribute (&MU_UID, "MU-UID")
|| get_attribute (&MU_GID, "MU-GID")
|| get_attribute (&MU_GECOS, "MU-GECOS")
|| get_attribute (&MU_Dir, "MU-Dir")
|| get_attribute (&MU_Shell, "MU-Shell")
|| get_attribute (&MU_Mailbox, "MU-Mailbox"))
return 1;
/* Parse saved requests */
parse_pairlist (&auth_request, auth_request_str, state);
parse_pairlist (&getpwnam_request, getpwnam_request_str, state);
parse_pairlist (&getpwuid_request, getpwuid_request_str, state);
if (parse_pairlist (&auth_request, cfg->auth_request)
|| parse_pairlist (&getpwnam_request, cfg->getpwnam_request)
|| parse_pairlist (&getpwuid_request, cfg->getpwuid_request))
return 1;
radius_auth_enabled = 1;
}
static error_t
mu_radius_argp_parser (int key, char *arg, struct argp_state *state)
{
switch (key)
{
case ARG_AUTH_REQUEST:
auth_request_str = arg;
break;
case ARG_GETPWNAM_REQUEST:
getpwnam_request_str = arg;
break;
case ARG_GETPWUID_REQUEST:
getpwuid_request_str = arg;
break;
case ARG_RADIUS_DIR:
grad_config_dir = grad_estrdup (arg);
break;
case ARGP_KEY_FINI:
if (NEED_RADIUS_P())
init (state);
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
......@@ -320,20 +294,6 @@ _expand_query (const char *query, const char *ustr, const char *passwd)
return res;
}
static int
cb_directory (mu_cfg_locus_t *locus, void *data, char *arg)
{
grad_config_dir = grad_estrdup (arg);
return 0;
}
static struct mu_cfg_param mu_radius_cfg_param[] = {
{ "auth-request", mu_cfg_string, &auth_request_str },
{ "getpwnam-request", mu_cfg_string, &getpwnam_request_str },
{ "getpwuid-request", mu_cfg_string, &getpwuid_request_str },
{ "directory", mu_cfg_callback, NULL, cb_directory },
{ NULL }
};
static grad_avp_t *
......@@ -577,11 +537,6 @@ mu_auth_radius_user_by_uid (struct mu_auth_data **return_data,
return rc;
}
struct argp mu_radius_argp = {
mu_radius_argp_option,
mu_radius_argp_parser,
};
#else
static int
mu_radius_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED,
......@@ -612,11 +567,9 @@ mu_auth_radius_user_by_uid (struct mu_auth_data **return_data,
struct mu_auth_module mu_auth_radius_module = {
"radius",
#ifdef ENABLE_RADIUS
&mu_radius_argp,
mu_radius_cfg_param,
mu_radius_module_init,
#else
NULL,
NULL,
#endif
mu_radius_authenticate,
NULL,
......
......@@ -44,32 +44,18 @@
#include <mailutils/list.h>
#include <mailutils/iterator.h>
#include <mailutils/mailbox.h>
#include <mailutils/argp.h>
#include <mailutils/sql.h>
#include <mailutils/mu_auth.h>
#include <mailutils/error.h>
#include <mailutils/errno.h>
#include <mailutils/nls.h>
#include <mailutils/mutil.h>
#include <mailutils/sql.h>
#include "sql.h"
#ifdef USE_SQL
int sql_interface = 0;
char *mu_sql_getpwnam_query;
char *mu_sql_getpass_query;
char *mu_sql_getpwuid_query;
char *mu_sql_host = NULL; /* Hostname to connect to. NULL for UNIX
socket connection */
char *mu_sql_user = "accounts"; /* Username for mysql access */
char *mu_sql_passwd = "yurpass"; /* Password for mysql access */
char *mu_sql_db = "accounts"; /* Database Name */
int mu_sql_port = 0; /* Port number to connect to.
0 means default port */
enum mu_password_type mu_sql_password_type = password_hash;
static mu_assoc_t sql_field_map;
struct mu_internal_sql_config mu_sql_module_config;
static char *
sql_escape_string (const char *ustr)
......@@ -175,176 +161,6 @@ mu_sql_expand_query (const char *query, const char *ustr)
return res;
}
static int
set_sql_password_type (const char *arg)
{
if (strcmp (arg, "plain") == 0)
mu_sql_password_type = password_plaintext;
else if (strcmp (arg, "hash") == 0)
mu_sql_password_type = password_hash;
else if (strcmp (arg, "scrambled") == 0)
mu_sql_password_type = password_scrambled;
else
return 1;
return 0;
}
/* Command-line configuration */
# define ARG_SQL_INTERFACE 256
# define ARG_SQL_GETPWNAM 257
# define ARG_SQL_GETPWUID 258
# define ARG_SQL_GETPASS 259
# define ARG_SQL_HOST 260
# define ARG_SQL_USER 261
# define ARG_SQL_PASSWD 262
# define ARG_SQL_DB 263
# define ARG_SQL_PORT 264
# define ARG_SQL_MU_PASSWORD_TYPE 265
# define ARG_SQL_FIELD_MAP 266
static struct argp_option mu_sql_argp_option[] = {
{"sql-interface", ARG_SQL_INTERFACE, N_("NAME"), OPTION_HIDDEN,
N_("Type of SQL interface to use"), },
{"sql-getpwnam", ARG_SQL_GETPWNAM, N_("QUERY"), OPTION_HIDDEN,
N_("SQL query to retrieve a passwd entry based on username"), 0},
{"sql-getpwuid", ARG_SQL_GETPWUID, N_("QUERY"), OPTION_HIDDEN,
N_("SQL query to retrieve a passwd entry based on UID"), 0},
{"sql-getpass", ARG_SQL_GETPASS, N_("QUERY"), OPTION_HIDDEN,
N_("SQL query to retrieve a password from the database"), 0},
{"sql-host", ARG_SQL_HOST, N_("HOSTNAME"), OPTION_HIDDEN,
N_("Name or IP of MySQL server to connect to"), 0},
{"sql-user", ARG_SQL_USER, N_("NAME"), OPTION_HIDDEN,
N_("SQL user name"), 0},
{"sql-passwd", ARG_SQL_PASSWD, N_("STRING"), OPTION_HIDDEN,
N_("SQL connection password"), 0},
{"sql-db", ARG_SQL_DB, N_("STRING"), OPTION_HIDDEN,
N_("Name of the database to connect to"), 0},
{"sql-port", ARG_SQL_PORT, N_("NUMBER"), OPTION_HIDDEN,
N_("Port to use"), 0},
{"sql-password-type", ARG_SQL_MU_PASSWORD_TYPE, N_("STRING"), OPTION_HIDDEN,
N_("Type of password returned by --sql-getpass query. STRING is one of: plain, hash, scrambled"), 0},
{"sql-field-map", ARG_SQL_FIELD_MAP, N_("MAP"), OPTION_HIDDEN,
N_("Declare a name translation map for SQL fields in results of sql-getpwnam and "
"sql-getpwuid queries"), 0},
{ NULL, 0, NULL, 0, NULL, 0 }
};
static error_t
mu_sql_argp_parser (int key, char *arg, struct argp_state *state)
{
int rc, err;
switch (key)
{
case ARG_SQL_INTERFACE:
sql_interface = mu_sql_interface_index (arg);
if (sql_interface == 0)
argp_error (state, _("Unknown SQL interface `%s'"), arg);
break;
case ARG_SQL_GETPWNAM:
mu_sql_getpwnam_query = arg;
break;
case ARG_SQL_GETPWUID:
mu_sql_getpwuid_query = arg;
break;
case ARG_SQL_GETPASS:
mu_sql_getpass_query = arg;
break;
case ARG_SQL_HOST:
mu_sql_host = arg;
break;
case ARG_SQL_USER:
mu_sql_user = arg;
break;
case ARG_SQL_PASSWD:
mu_sql_passwd = arg;
break;
case ARG_SQL_DB:
mu_sql_db = arg;
break;
case ARG_SQL_PORT:
mu_sql_port = strtoul (arg, NULL, 0);
break;
case ARG_SQL_MU_PASSWORD_TYPE:
if (set_sql_password_type (arg))
argp_error (state, _("Unknown password type `%s'"), arg);
break;
case ARG_SQL_FIELD_MAP:
rc = mutil_parse_field_map (arg, &sql_field_map, &err);
if (rc)
argp_error (state, _("Error near element %d: %s"),
err, mu_strerror (rc));
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
static struct argp mu_sql_argp = {
mu_sql_argp_option,
mu_sql_argp_parser,
};
/* Resource file configuration */
static int
cb_iface (mu_cfg_locus_t *locus, void *data, char *arg)
{
sql_interface = mu_sql_interface_index (arg);
if (sql_interface == 0)
mu_error (_("%s:%d: Unknown SQL interface `%s'"),
locus->file, locus->line, arg);
return 0;
}
static int
cb_password_type (mu_cfg_locus_t *locus, void *data, char *arg)
{
if (set_sql_password_type (arg))
mu_error (_("%s:%d: Unknown password type `%s'"),
locus->file, locus->line, arg);
return 0;
}
static int
cb_field_map (mu_cfg_locus_t *locus, void *data, char *arg)
{
int err;
int rc = mutil_parse_field_map (arg, &sql_field_map, &err);
if (rc)
mu_error (_("%s:%d: Error near element %d: %s"),
locus->file, locus->line, err, mu_strerror (rc));
return 0;
}
static struct mu_cfg_param mu_sql_param[] = {
{ "interface", mu_cfg_callback, NULL, cb_iface },
{ "getwpnam", mu_cfg_string, &mu_sql_getpwnam_query },
{ "getpwuid", mu_cfg_string, &mu_sql_getpwuid_query },
{ "getpass", mu_cfg_string, &mu_sql_getpass_query },
{ "host", mu_cfg_string, &mu_sql_host },
{ "user", mu_cfg_string, &mu_sql_user },
{ "passwd", mu_cfg_string, &mu_sql_passwd },
{ "db", mu_cfg_string, &mu_sql_db },
{ "port", mu_cfg_int, &mu_sql_port },
{ "password-type", mu_cfg_callback, NULL, cb_password_type },
{ "field-map", mu_cfg_callback, NULL, cb_field_map },
{ NULL }
};
static int
decode_tuple_v1_0 (mu_sql_connection_t conn, int n,
......@@ -405,7 +221,7 @@ decode_tuple_v1_0 (mu_sql_connection_t conn, int n,
static int
get_field (mu_sql_connection_t conn, const char *id, char **ret, int mandatory)
{
const char **name = mu_assoc_ref (sql_field_map, id);
const char **name = mu_assoc_ref (mu_sql_module_config.field_map, id);
int rc = mu_sql_get_field (conn, 0, name ? *name : id, ret);
if (rc)
{
......@@ -536,7 +352,7 @@ static int
decode_tuple (mu_sql_connection_t conn, int n,
struct mu_auth_data **return_data)
{
if (sql_field_map)
if (mu_sql_module_config.field_map)
return decode_tuple_new (conn, n, return_data);
else
return decode_tuple_v1_0 (conn, n, return_data);
......@@ -556,17 +372,18 @@ mu_auth_sql_by_name (struct mu_auth_data **return_data,
if (!key)
return EINVAL;
query_str = mu_sql_expand_query (mu_sql_getpwnam_query, key);
query_str = mu_sql_expand_query (mu_sql_module_config.getpwnam_query, key);
if (!query_str)
return MU_ERR_FAILURE;
status = mu_sql_connection_init (&conn,
sql_interface,
mu_sql_host,
mu_sql_port,
mu_sql_user, mu_sql_passwd,
mu_sql_db);
mu_sql_module_config.interface,
mu_sql_module_config.host,
mu_sql_module_config.port,
mu_sql_module_config.user,
mu_sql_module_config.passwd,
mu_sql_module_config.db);
if (status)
{
......@@ -638,17 +455,19 @@ mu_auth_sql_by_uid (struct mu_auth_data **return_data,
return EINVAL;
snprintf (uidstr, sizeof (uidstr), "%u", *(uid_t*)key);
query_str = mu_sql_expand_query (mu_sql_getpwuid_query, uidstr);
query_str = mu_sql_expand_query (mu_sql_module_config.getpwuid_query,
uidstr);
if (!query_str)
return ENOMEM;
status = mu_sql_connection_init (&conn,
sql_interface,
mu_sql_host,
mu_sql_port,
mu_sql_user, mu_sql_passwd,
mu_sql_db);
mu_sql_module_config.interface,
mu_sql_module_config.host,
mu_sql_module_config.port,
mu_sql_module_config.user,
mu_sql_module_config.passwd,
mu_sql_module_config.db);
if (status)
{
......@@ -713,17 +532,18 @@ mu_sql_getpass (const char *username, char **passwd)
int status;
char *sql_pass;
query_str = mu_sql_expand_query (mu_sql_getpass_query, username);
query_str = mu_sql_expand_query (mu_sql_module_config.getpass_query, username);
if (!query_str)
return MU_ERR_FAILURE;
status = mu_sql_connection_init (&conn,
sql_interface,
mu_sql_host,
mu_sql_port,
mu_sql_user, mu_sql_passwd,
mu_sql_db);
mu_sql_module_config.interface,
mu_sql_module_config.host,
mu_sql_module_config.port,
mu_sql_module_config.user,
mu_sql_module_config.passwd,
mu_sql_module_config.db);
if (status)
{
......@@ -804,7 +624,7 @@ mu_sql_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED,
if ((rc = mu_sql_getpass (auth_data->name, &sql_pass)))
return rc;
switch (mu_sql_password_type)
switch (mu_sql_module_config.password_type)
{
case password_hash:
rc = strcmp (sql_pass, crypt (pass, sql_pass));
......@@ -832,6 +652,32 @@ mu_sql_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED,
return rc == 0 ? 0 : MU_ERR_AUTH_FAILURE;
}
int
mu_sql_module_init (void *data)
{
struct mu_sql_module_config *cfg = data;
mu_sql_module_config.interface = mu_sql_interface_index (cfg->interface);
if (mu_sql_module_config.interface == 0)
{
mu_error (_("Unknown SQL interface `%s'"), cfg->interface);
return 1;
}
mu_sql_module_config.getpwnam_query = cfg->getpwnam_query;
mu_sql_module_config.getpass_query = cfg->getpass_query;
mu_sql_module_config.getpwuid_query = cfg->getpwuid_query;
mu_sql_module_config.host = cfg->host;
mu_sql_module_config.user = cfg->user;
mu_sql_module_config.passwd = cfg->passwd;
mu_sql_module_config.db = cfg->db;
mu_sql_module_config.port = cfg->port;
mu_sql_module_config.password_type = cfg->password_type;
mu_sql_module_config.field_map = cfg->field_map;
return 0;
}
#else
# define mu_sql_authenticate mu_auth_nosupport
......@@ -844,11 +690,9 @@ mu_sql_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED,
struct mu_auth_module mu_auth_sql_module = {
"sql",
#ifdef USE_SQL
&mu_sql_argp,
mu_sql_param,
mu_sql_module_init,
#else
NULL,
NULL,
#endif
mu_sql_authenticate,
NULL,
......
......@@ -40,15 +40,20 @@
#include <mailutils/nls.h>
#include <mailutils/mailbox.h>
extern int sql_interface;
extern char *mu_sql_getpwnam_query;
extern char *mu_sql_getpass_query;
extern char *mu_sql_getpwuid_query;
extern char *mu_sql_host;
extern char *mu_sql_user;
extern char *mu_sql_passwd;
extern char *mu_sql_db;
extern char *mu_sql_socket;
extern int mu_sql_port;
struct mu_internal_sql_config
{
int interface;
char *getpwnam_query;
char *getpass_query;
char *getpwuid_query;
char *host;
char *user;
char *passwd;
char *db;
int port;
enum mu_password_type password_type;
mu_assoc_t field_map;
};
extern struct mu_internal_sql_config mu_sql_module_config;
......
......@@ -27,7 +27,6 @@
#include <sys/stat.h>
#include <string.h>
#include <mailutils/argp.h>
#include <mailutils/error.h>
#include <mailutils/mu_auth.h>
#include <mailutils/tls.h>
......@@ -37,155 +36,69 @@
#include <lbuf.h>
#ifdef WITH_TLS
#include <gnutls/gnutls.h>
#define DH_BITS 768
static gnutls_dh_params dh_params;
static gnutls_certificate_server_credentials x509_cred;
static char *ssl_cert = NULL;
static char *ssl_key = NULL;
static char *ssl_cafile = NULL;
#define ARG_TLS 1
#define ARG_SSL_CERT 2
#define ARG_SSL_KEY 3
#define ARG_SSL_CAFILE 4
static struct argp_option _tls_argp_options[] = {
{"ssl-cert", ARG_SSL_CERT, N_("FILE"), OPTION_HIDDEN,
N_("Specify SSL certificate file"), 0},
{"ssl-key", ARG_SSL_KEY, N_("FILE"), OPTION_HIDDEN,
N_("Specify SSL certificate key"), },
{"ssl-cafile", ARG_SSL_CAFILE, N_("FILE"), OPTION_HIDDEN,
N_("Specify trusted CAs file"), 0},
{NULL, 0, NULL, 0, NULL, 0}
};
struct mu_tls_module_config mu_tls_module_config;
static error_t
_tls_argp_parser (int key, char *arg, struct argp_state *state)
int
mu_tls_module_init (void *data)
{
static int tls_enable = 1;
switch (key)
if (data)
{
case ARG_TLS:
if (!arg || strcasecmp (arg, "yes") == 0)
tls_enable = 1;
else if (strcasecmp (arg, "no") == 0)
tls_enable = 0;
break;
case ARG_SSL_CERT:
ssl_cert = arg;
break;
case ARG_SSL_KEY:
ssl_key = arg;
break;
case ARG_SSL_CAFILE:
ssl_cafile = arg;
break;
case ARGP_KEY_FINI:
if (tls_enable)
memcpy (&mu_tls_module_config, data, sizeof mu_tls_module_config);
#ifdef WITH_TLS
if (mu_tls_module_config.client_enable)
mu_init_tls_libs ();
break;
default:
return ARGP_ERR_UNKNOWN;
#endif
}
return 0;
}
static struct argp _tls_argp = {
_tls_argp_options,
_tls_argp_parser
};
static struct argp_child _tls_argp_child = {
&_tls_argp,
0,
NULL,
0
};
void
mu_tls_init_argp ()
{
if (mu_register_capa ("tls", &_tls_argp_child, NULL))
{
mu_error (_("INTERNAL ERROR: cannot register argp capability tls"));
abort ();
}
}
static struct argp_option _tls_argp_client_options[] = {
{"tls", ARG_TLS, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("Enable TLS support") },
{NULL, 0, NULL, 0, NULL, 0}
};
#ifdef WITH_TLS
static struct argp _tls_client_argp = {
_tls_argp_client_options,
_tls_argp_parser
};
#include <gnutls/gnutls.h>
static struct argp_child _tls_argp_client_child = {
&_tls_client_argp,
0,
NULL,
0
};
#define DH_BITS 768
void
mu_tls_init_client_argp ()
{
if (mu_register_capa ("tls", &_tls_argp_client_child, NULL))
{
mu_error (_("INTERNAL ERROR: cannot register argp capability tls"));
abort ();
}
}
static gnutls_dh_params dh_params;
static gnutls_certificate_server_credentials x509_cred;
int
mu_check_tls_environment (void)
{
/* Return: zero means NOT READY, one means READY */
if (ssl_cert && ssl_key)
if (mu_tls_module_config.ssl_cert && mu_tls_module_config.ssl_key)
{
struct stat st;
if (stat (ssl_cert, &st) == -1)
if (stat (mu_tls_module_config.ssl_cert, &st) == -1)
{
mu_error ("%s: %s.", ssl_cert, mu_strerror (errno));
mu_error ("%s: %s.", mu_tls_module_config.ssl_cert,
mu_strerror (errno));
return 0;
}
if (!(st.st_mode & S_IFREG) || !(st.st_mode & S_IFLNK))
{
mu_error (_("%s is not a regular file or a symbolic link."),
ssl_cert);
mu_tls_module_config.ssl_cert);
return 0;
}
if (stat (ssl_key, &st) == -1)
if (stat (mu_tls_module_config.ssl_key, &st) == -1)
{
mu_error ("%s: %s.", ssl_key, mu_strerror(errno));
mu_error ("%s: %s.", mu_tls_module_config.ssl_key,
mu_strerror(errno));
return 0;
}
if (!(st.st_mode & S_IFREG) || !(st.st_mode & S_IFLNK))
{
mu_error (_("%s is not a regular file or a symbolic link."),
ssl_key);
mu_tls_module_config.ssl_key);
return 0;
}
if ((st.st_mode & S_IRWXG) || (st.st_mode & S_IRWXO))
{
mu_error (_("Wrong permissions on %s. Set 0600"), ssl_key);
mu_error (_("Wrong permissions on %s. Set 0600"),
mu_tls_module_config.ssl_key);
return 0;
}
}
......@@ -507,12 +420,14 @@ _tls_open (mu_stream_t stream)
gnutls_certificate_allocate_credentials (&x509_cred);
if (ssl_cafile)
gnutls_certificate_set_x509_trust_file (x509_cred, ssl_cafile,
if (mu_tls_module_config.ssl_cafile)
gnutls_certificate_set_x509_trust_file (x509_cred,
mu_tls_module_config.ssl_cafile,
GNUTLS_X509_FMT_PEM);
rc = gnutls_certificate_set_x509_key_file (x509_cred,
ssl_cert, ssl_key,
mu_tls_module_config.ssl_cert,
mu_tls_module_config.ssl_key,
GNUTLS_X509_FMT_PEM);
if (rc < 0)
{
......@@ -561,10 +476,10 @@ prepare_client_session (struct _tls_stream *s)
gnutls_mac_set_priority (s->session, mac_priority);
gnutls_certificate_allocate_credentials (&x509_cred);
if (ssl_cafile)
if (mu_tls_module_config.ssl_cafile)
{
rc = gnutls_certificate_set_x509_trust_file (x509_cred,
ssl_cafile,
mu_tls_module_config.ssl_cafile,
GNUTLS_X509_FMT_PEM);
if (rc < 0)
{
......
......@@ -49,15 +49,27 @@
#include <mailutils/list.h>
#include <mailutils/iterator.h>
#include <mailutils/mailbox.h>
#include <mailutils/argp.h>
#include <mailutils/mu_auth.h>
#include <mailutils/nls.h>
#include <mailutils/errno.h>
#ifdef ENABLE_VIRTUAL_DOMAINS
/* FIXME: Make global, prefix with mu_ */
static char *site_virtual_pwddir = SITE_VIRTUAL_PWDDIR;
int
mu_virtual_module_init (void *data)
{
if (data)
{
site_virtual_pwddir = strdup (data);
if (!site_virtual_pwddir)
return 1;
}
return 0;
}
static struct passwd *
getpwnam_virtual (const char *u)
{
......@@ -173,34 +185,6 @@ mu_auth_virt_domain_by_name (struct mu_auth_data **return_data,
return rc;
}
#define ARG_PWDDIR 1
static error_t
mu_virt_argp_parser (int key, char *arg, struct argp_state *state)
{
switch (key)
{
case ARG_PWDDIR:
site_virtual_pwddir = arg;
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
static struct argp_option mu_virt_argp_option[] = {
{ "virtual-passwd-dir", ARG_PWDDIR, N_("DIR"), OPTION_HIDDEN,
N_("Search for virtual passwd file in DIR"), 0},
{ NULL, 0, NULL, 0, NULL, 0 }
};
struct argp mu_virt_argp = {
mu_virt_argp_option,
mu_virt_argp_parser,
};
#else
static int
mu_auth_virt_domain_by_name (struct mu_auth_data **return_data MU_ARG_UNUSED,
......@@ -215,11 +199,9 @@ mu_auth_virt_domain_by_name (struct mu_auth_data **return_data MU_ARG_UNUSED,
struct mu_auth_module mu_auth_virtual_module = {
"virtdomain",
#ifdef ENABLE_VIRTUAL_DOMAINS
&mu_virt_argp,
NULL,
mu_virtual_module_init,
#else
NULL,
NULL,
#endif
mu_auth_nosupport,
NULL,
......
......@@ -24,7 +24,7 @@ sbin_PROGRAMS = comsatd
comsatd_SOURCES = action.c cfg.c comsat.c comsat.h
comsatd_LDADD = \
../lib/libmuaux.la\
${MU_APP_LIBRARIES}\
${MU_LIB_MBOX}\
${MU_LIB_IMAP}\
${MU_LIB_POP}\
......
......@@ -18,6 +18,7 @@
MA 02110-1301 USA */
#include "comsat.h"
#include "muinit.h"
#ifndef PATH_DEV
# define PATH_DEV "/dev"
......@@ -90,7 +91,7 @@ static const char *comsat_argp_capa[] = {
# define MAXHOSTNAMELEN 64
#endif
struct daemon_param daemon_param = {
struct mu_gocs_daemon default_gocs_daemon = {
MODE_INTERACTIVE, /* Start in interactive (inetd) mode */
20, /* Default maximum number of children.
Currently unused */
......@@ -121,10 +122,6 @@ comsatd_parse_opt (int key, char *arg, struct argp_state *state)
{
switch (key)
{
case ARGP_KEY_INIT:
state->child_inputs[0] = state->input;
break;
case 'c':
config_file = arg;
break;
......@@ -150,8 +147,9 @@ main (int argc, char **argv)
mu_init_nls ();
mu_argp_init (program_version, NULL);
mu_argp_parse (&argp, &argc, &argv, 0, comsat_argp_capa,
&ind, &daemon_param);
mu_gocs_daemon = default_gocs_daemon;
if (mu_app_init (&argp, comsat_argp_capa, NULL, argc, argv, 0, &ind, NULL))
exit (1);
argc -= ind;
argv += ind;
......@@ -191,7 +189,7 @@ main (int argc, char **argv)
exit (0);
}
if (daemon_param.timeout > 0 && daemon_param.mode == MODE_DAEMON)
if (mu_gocs_daemon.timeout > 0 && mu_gocs_daemon.mode == MODE_DAEMON)
{
mu_error (_("--timeout and --daemon are incompatible"));
exit (EXIT_FAILURE);
......@@ -199,7 +197,7 @@ main (int argc, char **argv)
comsat_init ();
if (daemon_param.mode == MODE_DAEMON)
if (mu_gocs_daemon.mode == MODE_DAEMON)
{
/* Preserve invocation arguments */
xargc = argc;
......@@ -216,8 +214,8 @@ main (int argc, char **argv)
chdir ("/");
if (daemon_param.mode == MODE_DAEMON)
comsat_daemon (daemon_param.port);
if (mu_gocs_daemon.mode == MODE_DAEMON)
comsat_daemon (mu_gocs_daemon.port);
else
c = comsat_main (0);
......
......@@ -46,7 +46,6 @@
# include <strings.h>
#endif
#include <mailutils/argp.h>
#include <mailutils/body.h>
#include <mailutils/errno.h>
#include <mailutils/error.h>
......@@ -60,6 +59,7 @@
#include <mailutils/mu_auth.h>
#include <mailutils/argcv.h>
#include <mailutils/nls.h>
#include <mailutils/daemon.h>
#ifndef INADDR_NONE
# define INADDR_NONE -1
......
......@@ -23,8 +23,8 @@ bin_PROGRAMS = mailutils-config
mailutils_config_SOURCES = mailutils-config.c
mailutils_config_LDADD = \
../lib/libmuaux.la \
${MU_LIB_MAILUTILS} \
${MU_APP_LIBRARIES}\
${MU_LIB_MAILUTILS}\
@MU_COMMON_LIBRARIES@
mailutils_config_CFLAGS = -DCOMPILE_FLAGS="\"-I$(includedir)\"" \
......
......@@ -21,8 +21,8 @@
#endif
#include <string.h>
#include <mailutils/mailutils.h>
#include <mailutils/argp.h>
#include <mu_asprintf.h>
#include "muinit.h"
const char *program_version = "mailutils-config (" PACKAGE_STRING ")";
static char doc[] = N_("GNU mailutils-config -- Display compiler and loader options needed for building a program with mailutils");
......@@ -166,7 +166,7 @@ main (int argc, char **argv)
int index;
mu_argp_init (program_version, NULL);
if (mu_argp_parse (&argp, &argc, &argv, 0, argp_capa, &index, NULL))
if (mu_app_init (&argp, argp_capa, NULL, argc, argv, 0, &index, NULL))
{
argp_help (&argp, stdout, ARGP_HELP_SEE, program_invocation_short_name);
return 1;
......
......@@ -46,13 +46,15 @@ AC_SUBST(MU_LIB_POP,'${top_builddir}/libproto/pop/libmu_pop.la')
AC_SUBST(MU_LIB_SIEVE,'${top_builddir}/libsieve/libsieve.la')
AC_SUBST(MU_LIB_SCM,'${top_builddir}/libmu_scm/libmu_scm.la')
AC_SUBST(MU_LIB_CPP,'${top_builddir}/libmu_cpp/libmu_cpp.la')
AC_SUBST(MU_LIB_ARGP,'${top_builddir}/libargp/libargp.la')
dnl Other variables
AC_SUBST(SIEVE_MODDIR,'$(libdir)/$(PACKAGE)')
AC_SUBST(MU_COMMON_LIBRARIES,'$(LTLIBINTL) $(LTLIBICONV)')
AC_SUBST(MU_APP_LIBRARIES,'../lib/libmuaux.la ../libargp/libargp.a -L${top_builddir}/libcfg -lmucfg')
AC_SUBST(MU_COMMON_INCLUDES,'-I${srcdir} -I${top_srcdir}/include -I${top_srcdir}/lib -I${top_builddir} -I${top_builddir}/include -I${top_builddir}/include/mailutils/gnu -I${top_srcdir}/mailbox')
AC_SUBST(MU_COMMON_INCLUDES,'-I${srcdir} -I${top_srcdir}/include -I${top_srcdir}/lib -I${top_builddir} -I${top_builddir}/include -I${top_builddir}/include/mailutils/gnu -I${top_srcdir}/mailbox -I${top_srcdir}/libargp -I${top_srcdir}/libcfg')
dnl Check for programs
AC_PROG_CC
......@@ -1169,6 +1171,8 @@ AC_CONFIG_FILES([Makefile
libproto/include/Makefile
libsieve/Makefile
libsieve/extensions/Makefile
libargp/Makefile
libcfg/Makefile
maidag/Makefile
mail/Makefile
mail/testsuite/Makefile
......
......@@ -22,7 +22,7 @@ INCLUDES = @MU_COMMON_INCLUDES@
bin_PROGRAMS = dotlock
dotlock_LDADD = \
../lib/libmuaux.la\
${MU_APP_LIBRARIES}\
${MU_LIB_MAILUTILS}\
@MU_COMMON_LIBRARIES@
......
......@@ -27,11 +27,12 @@
#endif
#include <unistd.h>
#include <mailutils/argp.h>
#include <mailutils/errno.h>
#include <mailutils/locker.h>
#include <mailutils/nls.h>
#include "muinit.h"
const char *program_version = "GNU dotlock (" PACKAGE_STRING ")";
static char doc[] =
N_("GNU dotlock -- lock mail spool files")
......@@ -132,6 +133,7 @@ struct mu_cfg_param dotlock_cfg_param[] = {
const char *dotlock_capa[] = {
"license",
"common",
NULL
};
......@@ -151,11 +153,13 @@ main (int argc, char *argv[])
if (setegid (usergid) < 0)
return MU_DL_EX_ERROR;
mu_argp_init (program_version, NULL);
argp_err_exit_status = MU_DL_EX_ERROR;
mu_argp_set_config_param (dotlock_cfg_param);
mu_argp_parse (&argp, &argc, &argv, 0, dotlock_capa, NULL, NULL);
mu_argp_init (program_version, NULL);
if (mu_app_init (&argp, dotlock_capa, dotlock_cfg_param,
argc, argv, 0, NULL, NULL))
exit (1);
if (force)
{
force *= 60;
......
......@@ -125,6 +125,9 @@ lsf_LDADD = \
${MU_LIB_MAILUTILS}
muauth_LDADD = \
${MU_APP_LIBRARIES}\
${MU_LIB_AUTH}\
@MU_AUTHLIBS@ \
${MU_LIB_MAILUTILS}
muemail_LDADD = ${MU_APP_LIBRARIES}
\ No newline at end of file
......
......@@ -25,6 +25,7 @@
#include <ctype.h>
#include <string.h>
#include <mailutils/mailutils.h>
#include "muinit.h"
const char *program_version = "muauth (" PACKAGE_STRING ")";
static char doc[] =
......@@ -90,7 +91,9 @@ main (int argc, char * argv [])
MU_AUTH_REGISTER_ALL_MODULES ();
mu_argp_init (program_version, NULL);
mu_argp_parse (&argp, &argc, &argv, 0, capa, &index, NULL);
if (mu_app_init (&argp, capa, NULL, argc, argv, 0, &index, NULL))
exit (1);
if (index == argc)
{
mu_error ("not enough arguments, try `%s --help' for more info",
......
......@@ -17,10 +17,9 @@
MA 02110-1301 USA */
#include <stdlib.h>
#include <mailutils/mutil.h>
#include <mailutils/argp.h>
#include <stdio.h>
#include <mailutils/mutil.h>
#include "muinit.h"
const char *capa[] = {
"address",
......@@ -32,8 +31,8 @@ main (int argc, char *argv[])
{
int arg = 1;
if (mu_argp_parse (NULL, &argc, &argv, 0, capa, &arg, NULL))
abort ();
if (mu_app_init (NULL, capa, NULL, argc, argv, 0, &arg, NULL))
exit (1);
if (!argv[arg])
printf ("current user -> %s\n", mu_get_user_email (0));
......
......@@ -30,7 +30,7 @@ frm_LDADD = $(common_ldadd)
from_LDADD = $(common_ldadd)
common_ldadd = \
../lib/libmuaux.la\
${MU_APP_LIBRARIES}\
${MU_LIB_MBOX}\
${MU_LIB_IMAP}\
${MU_LIB_POP}\
......
......@@ -218,9 +218,6 @@ static const char *frm_argp_capa[] = {
"common",
"license",
"mailbox",
#ifdef WITH_TLS
"tls",
#endif
NULL
};
......@@ -366,12 +363,13 @@ main (int argc, char **argv)
/* register the formats. */
mu_register_all_mbox_formats ();
mu_argp_init (program_version, NULL);
#ifdef WITH_TLS
mu_tls_init_client_argp ();
mu_gocs_register ("tls", mu_tls_module_init);
#endif
mu_argp_parse (&argp, &argc, &argv, 0, frm_argp_capa, &c, NULL);
mu_argp_init (program_version, NULL);
if (mu_app_init (&argp, frm_argp_capa, NULL, argc, argv, 0, &c, NULL))
exit (1);
/* have an argument */
if (c == argc)
......
......@@ -47,7 +47,6 @@
#endif
#include <mailutils/address.h>
#include <mailutils/argp.h>
#include <mailutils/attribute.h>
#include <mailutils/debug.h>
#include <mailutils/errno.h>
......@@ -65,6 +64,8 @@
#include <mailutils/mutil.h>
#include <mailutils/mime.h>
#include "muinit.h"
typedef int (*frm_select_t) (size_t index, mu_message_t msg);
extern char *show_field; /* Show this header field instead of the default
......
......@@ -118,10 +118,8 @@ main (int argc, char **argv)
mu_register_all_mbox_formats ();
mu_argp_init (program_version, NULL);
#ifdef WITH_TLS
mu_tls_init_client_argp ();
#endif
mu_argp_parse (&argp, &argc, &argv, 0, capa, &c, NULL);
if (mu_app_init (&argp, capa, NULL, argc, argv, 0, &c, NULL))
exit (1);
if (argc - c > 1)
{
......
......@@ -25,7 +25,7 @@ bin_PROGRAMS=@GUIMB@
EXTRA_PROGRAMS=guimb
guimb_SOURCES=main.c collect.c util.c guimb.h
guimb_LDADD = \
../lib/libmuaux.la\
${MU_APP_LIBRARIES}\
../libmu_scm/libmu_scm.la\
${MU_LIB_MBOX}\
${MU_LIB_IMAP}\
......
......@@ -41,7 +41,6 @@
#include <mailutils/stream.h>
#include <mailutils/guile.h>
#include <mailutils/nls.h>
#include <mailutils/argp.h>
#include <mailutils/list.h>
#include <mailutils/mutil.h>
#include <mailutils/attribute.h>
......
......@@ -18,6 +18,7 @@
MA 02110-1301 USA */
#include "guimb.h"
#include "muinit.h"
char *program_file;
char *program_expr;
......@@ -155,8 +156,10 @@ main (int argc, char *argv[])
mu_init_nls ();
append_arg ("");
mu_argp_init (program_version, NULL);
mu_argp_parse (&argp, &argc, &argv, 0, guimb_argp_capa, &index, &c);
if (mu_app_init (&argp, guimb_argp_capa, NULL, argc, argv, 0, &index, &c))
exit (1);
for (; c < argc; c++)
append_arg (argv[c]);
......
......@@ -62,7 +62,7 @@ imap4d_SOURCES = \
imap4d_LDADD = \
@IMAP_AUTHOBJS@\
../lib/libmuaux.la\
${MU_APP_LIBRARIES}\
${MU_LIB_MBOX}\
${MU_LIB_MH}\
${MU_LIB_MAILDIR}\
......
......@@ -49,7 +49,7 @@ imap4d_idle (struct imap4d_command *command, char *arg)
if (rc)
break;
}
else if (time (NULL) - start > daemon_param.timeout)
else if (time (NULL) - start > mu_gocs_daemon.timeout)
imap4d_bye (ERR_TIMEOUT);
imap4d_sync ();
......
......@@ -21,6 +21,7 @@
#ifdef WITH_GSASL
# include <mailutils/gsasl.h>
#endif
#include "muinit.h"
mu_mailbox_t mbox;
char *homedir;
......@@ -28,7 +29,7 @@ int state = STATE_NONAUTH;
int debug_mode = 0;
struct mu_auth_data *auth_data;
struct daemon_param daemon_param = {
struct mu_gocs_daemon default_gocs_daemon = {
MODE_INTERACTIVE, /* Start in interactive (inetd) mode */
20, /* Default maximum number of children */
143, /* Standard IMAP4 port */
......@@ -87,12 +88,6 @@ static struct argp argp = {
static const char *imap4d_capa[] = {
"daemon",
"auth",
#ifdef WITH_TLS
"tls",
#endif /* WITH_TLS */
#ifdef WITH_GSASL
"gsasl",
#endif
"common",
"mailbox",
"logging",
......@@ -196,16 +191,17 @@ main (int argc, char **argv)
MU_AUTH_REGISTER_ALL_MODULES ();
imap4d_capability_init ();
mu_argp_init (program_version, NULL);
mu_gocs_daemon = default_gocs_daemon;
#ifdef WITH_TLS
mu_tls_init_argp ();
mu_gocs_register ("tls", mu_tls_module_init);
#endif /* WITH_TLS */
#ifdef WITH_GSASL
mu_gsasl_init_argp ();
mu_gocs_register ("gsasl", mu_gsasl_module_init);
#endif
mu_argp_set_config_param (imap4d_cfg_param);
mu_argp_parse (&argp, &argc, &argv, 0, imap4d_capa, NULL, &daemon_param);
mu_argp_init (program_version, NULL);
if (mu_app_init (&argp, imap4d_capa, imap4d_cfg_param,
argc, argv, 0, NULL, NULL))
exit (1);
if (login_disabled)
imap4d_capability_add (IMAP_CAPA_LOGINDISABLED);
......@@ -218,11 +214,11 @@ main (int argc, char **argv)
auth_gsasl_init ();
#ifdef USE_LIBPAM
if (!pam_service)
pam_service = "gnu-imap4d";
if (!mu_pam_service)
mu_pam_service = "gnu-imap4d";
#endif
if (daemon_param.mode == MODE_INTERACTIVE && isatty (0))
if (mu_gocs_daemon.mode == MODE_INTERACTIVE && isatty (0))
{
/* If input is a tty, switch to debug mode */
debug_mode = 1;
......@@ -261,7 +257,7 @@ main (int argc, char **argv)
/*signal (SIGPIPE, SIG_IGN); */
signal (SIGABRT, imap4d_signal);
if (daemon_param.mode == MODE_DAEMON)
if (mu_gocs_daemon.mode == MODE_DAEMON)
imap4d_daemon_init ();
else
{
......@@ -278,9 +274,9 @@ main (int argc, char **argv)
umask (S_IROTH | S_IWOTH | S_IXOTH); /* 007 */
if (daemon_param.pidfile)
if (mu_gocs_daemon.pidfile)
{
mu_daemon_create_pidfile (daemon_param.pidfile);
mu_daemon_create_pidfile (mu_gocs_daemon.pidfile);
}
/* Check TLS environment, i.e. cert and key files */
......@@ -289,8 +285,8 @@ main (int argc, char **argv)
#endif /* WITH_TLS */
/* Actually run the daemon. */
if (daemon_param.mode == MODE_DAEMON)
imap4d_daemon (daemon_param.maxchildren, daemon_param.port);
if (mu_gocs_daemon.mode == MODE_DAEMON)
imap4d_daemon (mu_gocs_daemon.maxchildren, mu_gocs_daemon.port);
/* exit (0) -- no way out of daemon except a signal. */
else
status = imap4d_mainloop (fileno (stdin), stdin, stdout);
......
......@@ -71,7 +71,6 @@
#endif
#include <mailutils/address.h>
#include <mailutils/argp.h>
#include <mailutils/attribute.h>
#include <mailutils/body.h>
#include <mailutils/daemon.h>
......@@ -93,6 +92,8 @@
#include <mailutils/stream.h>
#include <mailutils/tls.h>
#include <mailutils/url.h>
#include <mailutils/daemon.h>
#include <mailutils/pam.h>
#include <mu_asprintf.h>
#include <mu_umaxtostr.h>
......@@ -161,8 +162,8 @@ extern char *rootdir;
extern int state;
extern size_t children;
extern int is_virtual;
extern struct daemon_param daemon_param;
extern struct mu_auth_data *auth_data;
extern const char *program_version;
extern int login_disabled;
extern int tls_required;
......
......@@ -360,7 +360,7 @@ util_send (const char *format, ...)
if (!buf)
imap4d_bye (ERR_NO_MEM);
if (daemon_param.transcript)
if (mu_gocs_daemon.transcript)
syslog (LOG_DEBUG, "sent: %s", buf);
status = mu_stream_sequential_write (ostream, buf, strlen (buf));
......@@ -414,7 +414,7 @@ util_out (int rc, const char *format, ...)
if (!buf)
imap4d_bye (ERR_NO_MEM);
if (daemon_param.transcript)
if (mu_gocs_daemon.transcript)
syslog (LOG_DEBUG, "sent: %s", buf);
status = mu_stream_sequential_write (ostream, buf, strlen (buf));
......@@ -455,7 +455,7 @@ util_finish (struct imap4d_command *command, int rc, const char *format, ...)
strcat (buf, tempbuf);
free (tempbuf);
if (daemon_param.transcript)
if (mu_gocs_daemon.transcript)
syslog (LOG_DEBUG, "sent: %s\r\n", buf);
mu_stream_sequential_write (ostream, buf, strlen (buf));
......@@ -503,7 +503,7 @@ imap4d_readline (void)
size_t sz;
int rc;
alarm (daemon_param.timeout);
alarm (mu_gocs_daemon.timeout);
rc = mu_stream_sequential_readline (istream, buffer, sizeof (buffer), &sz);
if (sz == 0)
{
......@@ -577,7 +577,7 @@ imap4d_readline (void)
}
}
while (number > 0 || (total && line[total - 1] != '\n'));
if (daemon_param.transcript)
if (mu_gocs_daemon.transcript)
syslog (LOG_DEBUG, "recv: %s", line);
return line;
}
......
......@@ -21,6 +21,6 @@
int
imap4d_version (struct imap4d_command *command, char *arg)
{
util_send ("* %s GNU %s\r\n", command->name, argp_program_version);
util_send ("* %s GNU %s\r\n", command->name, program_version);
return util_finish (command, RESP_OK, "Completed");
}
......
......@@ -29,53 +29,56 @@ DISTCLEANFILES = types.h
pkginclude_DATA = types.h
pkginclude_HEADERS = \
address.h \
argcv.h \
argp.h \
assoc.h \
attribute.h \
auth.h \
body.h \
cfg.h \
compat.h \
daemon.h \
debug.h \
envelope.h \
errno.h \
error.h \
filter.h \
folder.h \
gsasl.h \
guile.h \
header.h \
iterator.h \
libsieve.h \
list.h \
locker.h \
mailbox.h \
mailcap.h \
mailer.h \
mailutils.h \
message.h \
mime.h \
monitor.h \
mu_auth.h \
mutil.h \
nls.h \
nntp.h \
observer.h \
parse822.h \
pop3.h \
property.h \
refcount.h \
registrar.h \
stream.h \
sql.h \
tls.h \
address.h\
argcv.h\
assoc.h\
attribute.h\
auth.h\
body.h\
cfg.h\
compat.h\
daemon.h\
debug.h\
envelope.h\
errno.h\
error.h\
filter.h\
folder.h\
gocs.h\
gsasl.h\
guile.h\
header.h\
iterator.h\
libsieve.h\
list.h\
locker.h\
mailbox.h\
mailcap.h\
mailer.h\
mailutils.h\
message.h\
mime.h\
monitor.h\
mu_auth.h\
mutil.h\
nls.h\
nntp.h\
observer.h\
pam.h\
parse822.h\
pop3.h\
property.h\
radius.h\
refcount.h\
registrar.h\
stream.h\
syslog.h\
sql.h\
tls.h\
url.h
nobase_pkginclude_HEADERS = \
sys/nntp.h \
sys/nntp.h\
sys/pop3.h
SUBDIRS = gnu sys
......
......@@ -18,6 +18,7 @@
#ifndef _MAILUTILS_CFG_H
#define _MAILUTILS_CFG_H
#include <mailutils/list.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
......@@ -186,4 +187,6 @@ int mu_config_register_plain_section (const char *parent_path,
int mu_parse_config (char *file, char *progname,
struct mu_cfg_param *progparam, int global);
int mu_cfg_parse_boolean (const char *str, int *res);
#endif
......
......@@ -20,14 +20,21 @@
#define _MAILUTILS_DAEMON_H
#include <mailutils/types.h>
#include <mailutils/gocs.h>
#ifdef __cplusplus
extern "C" {
#endif
/* FIXME: Namespace */
#define MODE_INTERACTIVE 0
#define MODE_DAEMON 1
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
......
......@@ -29,6 +29,9 @@ extern "C" {
typedef int (*mu_error_pfn_t) (const char *fmt, va_list ap);
extern const char *mu_program_name;
extern void mu_set_program_name (const char *name);
extern int mu_verror (const char *fmt, va_list ap);
extern int mu_error (const char *fmt, ...) MU_PRINTFLIKE(1,2);
extern void mu_error_set_print (mu_error_pfn_t);
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2007 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 useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifndef _MAILUTILS_GOCS_H
#define _MAILUTILS_GOCS_H
#include <mailutils/types.h>
#include <mailutils/list.h>
#ifdef __cplusplus
extern "C" {
#endif
struct mu_gocs_daemon
{
int mode;
size_t maxchildren;
unsigned int port;
unsigned int timeout;
int transcript;
char *pidfile;
};
struct mu_gocs_logging
{
int facility;
char *tag;
};
struct mu_gocs_mailbox
{
char *mail_spool;
char *mailbox_type;
};
struct mu_gocs_locking
{
char *lock_flags;
unsigned long lock_retry_timeout;
unsigned long lock_retry_count;
unsigned long lock_expire_timeout;
char *external_locker;
};
struct mu_gocs_source_email
{
char *address;
char *domain;
};
struct mu_gocs_mailer
{
char *mailer;
};
/* Auxiliary variables for use by libargp/libcfg */
extern int mu_load_user_rcfile;
extern int mu_load_site_rcfile;
extern char *mu_load_rcfile;
extern int log_facility; /* FIXME: 1. Belongs elsewhere;
2. Does not begin with `mu_' */
typedef int (*gocs_init_fp) (void *data);
void mu_gocs_register (char *capa, gocs_init_fp init);
void mu_gocs_register_std (char *name);
void mu_gocs_store (char *capa, void *data);
void mu_gocs_flush (void);
int mu_gocs_enumerate (mu_list_action_t action, void *data);
int mu_gocs_mailbox_init (void *data);
int mu_gocs_locking_init (void *data);
int mu_gocs_daemon_init (void *data);
int mu_gocs_source_email_init (void *data);
int mu_gocs_mailer_init (void *data);
int mu_gocs_logging_init (void *data);
#ifdef __cplusplus
}
#endif
#endif
......@@ -19,14 +19,22 @@
#ifndef _MAILUTILS_GSASL_H
#define _MAILUTILS_GSASL_H
struct mu_gsasl_module_data
{
char *cram_md5_pwd;
};
int mu_gsasl_module_init (void *data);
struct mu_gsasl_module_data mu_gsasl_module_data;
#ifdef USE_GSASL
#include <gsasl.h>
int mu_gsasl_stream_create (mu_stream_t *stream, mu_stream_t transport,
Gsasl_session_ctx *ctx,
int flags);
void mu_gsasl_init_argp (void);
extern char *mu_gsasl_cram_md5_pwd;
#endif
#endif /* not _MAILUTILS_GSASL_H */
......
......@@ -259,9 +259,19 @@ int mu_sieve_mailbox (mu_sieve_machine_t mach, mu_mailbox_t mbox);
int mu_sieve_message (mu_sieve_machine_t mach, mu_message_t message);
int mu_sieve_disass (mu_sieve_machine_t mach);
/* Command line handling */
/* Configuration functions */
extern void mu_sieve_argp_init (void);
#define MU_SIEVE_CLEAR_INCLUDE_PATH 0x1
#define MU_SIEVE_CLEAR_LIBRARY_PATH 0x2
struct mu_gocs_sieve
{
int clearflags;
mu_list_t include_path;
mu_list_t library_path;
};
int mu_sieve_module_init (void *);
#ifdef __cplusplus
}
......
......@@ -19,7 +19,6 @@
#include <mailutils/address.h>
#include <mailutils/argcv.h>
#include <mailutils/argp.h>
#include <mailutils/attribute.h>
#include <mailutils/auth.h>
#include <mailutils/body.h>
......@@ -53,6 +52,7 @@
#include <mailutils/tls.h>
#include <mailutils/types.h>
#include <mailutils/url.h>
#include <mailutils/gocs.h>
#ifdef MU_COMPAT
# include <mailutils/compat.h>
......
......@@ -20,6 +20,7 @@
#define _MAILUTILS_MU_AUTH_H
#include <mailutils/types.h>
#include <mailutils/gocs.h>
#define MU_AUTH_NAME "name"
#define MU_AUTH_PASSWD "passwd"
......@@ -61,8 +62,7 @@ typedef int (*mu_auth_fp) (struct mu_auth_data **data,
struct mu_auth_module
{
char *name;
struct argp *argp;
struct mu_cfg_param *cfg;
gocs_init_fp init;
mu_auth_fp authenticate;
void *authenticate_data;
mu_auth_fp auth_by_name;
......@@ -130,7 +130,6 @@ extern struct mu_auth_module mu_auth_virtual_module;
extern struct mu_auth_module mu_auth_radius_module;
#define MU_AUTH_REGISTER_ALL_MODULES() do {\
mu_auth_init (); \
mu_auth_register_module (&mu_auth_generic_module); \
mu_auth_register_module (&mu_auth_system_module); \
mu_auth_register_module (&mu_auth_pam_module);\
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2004, 2005,
2007 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 useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifndef _MAILUTILS_PAM_H
#define _MAILUTILS_PAM_H
#include <mailutils/types.h>
extern char *mu_pam_service;
#endif
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2004, 2005,
2007 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 useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifndef _MAILUTILS_RADIUS_H
#define _MAILUTILS_RADIUS_H
#include <mailutils/types.h>
struct mu_radius_module_data
{
char *config_dir;
char *auth_request;
char *getpwnam_request;
char *getpwuid_request;
};
extern int mu_radius_module_init (void *data);
#endif
......@@ -19,7 +19,30 @@
#ifndef _MAILUTILS_SQL_H
#define _MAILUTILS_SQL_H
/* Loadable Modules Suppert */
/* Configuration */
enum mu_password_type
{
password_plaintext, /* Plaintext passwords */
password_scrambled, /* Scrambled MySQL (>=3.21) password */
password_hash, /* MD5 (or DES or whatever) hash */
};
struct mu_sql_module_config
{
char *interface;
char *getpwnam_query;
char *getpass_query;
char *getpwuid_query;
char *host;
char *user;
char *passwd;
char *db;
int port;
enum mu_password_type password_type;
mu_assoc_t field_map;
};
/* Loadable Modules Support */
#define __s_cat2__(a,b) a ## b
#define __s_cat3__(a,b,c) a ## b ## c
#define RDL_EXPORT(module,name) __s_cat3__(module,_LTX_,name)
......@@ -27,7 +50,7 @@
typedef int (*mu_rdl_init_t) (void);
typedef void (*mu_rdl_done_t) (void);
#ifdef _HAVE_LIBLTDL //FIXME: Remove leading _ when SQL + ltdl works
#ifdef _HAVE_LIBLTDL /*FIXME: Remove leading _ when SQL + ltdl works*/
# define MU_DECL_SQL_DISPATCH_T(mod) \
mu_sql_dispatch_t RDL_EXPORT(mod,dispatch_tab)
#else
......@@ -112,18 +135,11 @@ int mu_sql_get_field (mu_sql_connection_t conn, size_t nrow, char *fname,
const char *mu_sql_strerror (mu_sql_connection_t conn);
enum mu_password_type
{
password_plaintext, /* Plaintext passwords */
password_scrambled, /* Scrambled MySQL (>=3.21) password */
password_hash, /* MD5 (or DES or whatever) hash */
};
extern enum mu_password_type mu_sql_password_type;
extern char *mu_sql_expand_query (const char *query, const char *ustr);
extern int mu_sql_getpass (const char *username, char **passwd);
extern int mu_check_mysql_scrambled_password (const char *scrambled,
const char *message);
int mu_sql_decode_password_type (const char *arg, enum mu_password_type *t);
#endif
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2007 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 useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifndef _MAILUTILS_SYSLOG_H
#define _MAILUTILS_SYSLOG_H
#include <syslog.h>
#ifdef __cplusplus
extern "C" {
#endif
int mu_string_to_syslog_facility (char *str, int *pfacility);
const char *mu_syslog_facility_to_string (int n);
int mu_string_to_syslog_priority (char *str, int *pprio);
const char *mu_syslog_priority_to_string (int n);
#ifdef __cplusplus
}
#endif
#endif
......@@ -19,16 +19,25 @@
#ifndef _MAILUTILS_TLS_H
#define _MAILUTILS_TLS_H
#ifdef WITH_TLS
#include <mailutils/types.h>
#ifdef __cplusplus
extern "C" {
#endif
struct mu_tls_module_config
{
int client_enable;
char *ssl_cert;
char *ssl_key;
char *ssl_cafile;
};
extern int mu_tls_module_init (void *data);
extern int mu_tls_stream_create (mu_stream_t *stream,
mu_stream_t strin, mu_stream_t strout, int flags);
mu_stream_t strin, mu_stream_t strout,
int flags);
extern int mu_tls_stream_create_client (mu_stream_t *stream,
mu_stream_t strin, mu_stream_t strout,
int flags);
......@@ -39,8 +48,6 @@ extern int mu_tls_stream_create_client_from_tcp (mu_stream_t *stream,
extern int mu_check_tls_environment (void);
extern int mu_init_tls_libs (void);
extern void mu_deinit_tls_libs (void);
extern void mu_tls_init_argp (void);
extern void mu_tls_init_client_argp (void);
typedef int (*mu_tls_readline_fn) (void *iodata);
typedef int (*mu_tls_writeline_fn) (void *iodata, char *buf);
......@@ -58,6 +65,5 @@ extern int mu_tls_enable;
}
#endif
#endif /* WITH_TLS */
#endif /* _MAILUTILS_TLS_H */
......
......@@ -23,8 +23,11 @@ noinst_LTLIBRARIES = libmuaux.la
INCLUDES = @MU_COMMON_INCLUDES@
libmuaux_la_SOURCES = \
argpinit.c\
daemon.c\
mailcap.c\
muinit.h\
muinit.c\
mu_dbm.c
EXTRA_DIST = utmp.c
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2007 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 useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "muinit.h"
void
mu_argp_init (const char *vers, const char *bugaddr)
{
argp_program_version = vers ? vers : PACKAGE_STRING;
argp_program_bug_address = bugaddr ? bugaddr : "<" PACKAGE_BUGREPORT ">";
}
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2007 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 useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "muinit.h"
int
mu_app_init (struct argp *myargp, const char **capa,
struct mu_cfg_param *cfg_param,
int argc, char **argv, int flags, int *pindex, void *data)
{
int rc, i;
struct argp *argp;
const struct argp argpnull = { 0 };
mu_set_program_name (argv[0]);
mu_libargp_init ();
for (i = 0; capa[i]; i++)
mu_gocs_register_std (capa[i]); /*FIXME*/
if (!myargp)
myargp = &argpnull;
argp = mu_argp_build (myargp);
rc = argp_parse (argp, argc, argv, flags, pindex, data);
mu_argp_done (argp);
if (rc)
return rc;
mu_libcfg_init (capa);
mu_parse_config_files (cfg_param);
mu_gocs_flush ();
return 0;
}
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2007 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 useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#include "cmdline.h"
#include "libcfg.h"
void mu_argp_init (const char *vers, const char *bugaddr);
int mu_app_init (struct argp *myargp, const char **capa,
struct mu_cfg_param *cfg_param,
int argc, char **argv, int flags, int *pindex, void *data);
*.la
*.lo
.deps
.libs
Makefile
Makefile.in
.gdbinit
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2007 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 useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "cmdline.h"
/* ************************************************************************* */
/* Traditional configuration */
/* ************************************************************************* */
static error_t mu_auth_argp_parser (int key, char *arg,
struct argp_state *state);
/* Options used by programs that use extended authentication mechanisms. */
static struct argp_option mu_auth_argp_option[] = {
{ "authentication", OPT_AUTHENTICATION, N_("MODLIST"), OPTION_HIDDEN,
N_("Set the list of modules to be used for authentication"), 0 },
{ "authorization", OPT_AUTHORIZATION, N_("MODLIST"), OPTION_HIDDEN,
N_("Set list of modules to be used for authorization"), 0 },
{ "clear-authorization", OPT_CLEAR_AUTHORIZATION, NULL, OPTION_HIDDEN,
N_("Clear the list of authorization modules"), 0 },
{ "clear-authentication", OPT_CLEAR_AUTHENTICATION, NULL, OPTION_HIDDEN,
N_("Clear the list of authentication modules"), 0 },
{ NULL, 0, NULL, 0, NULL, 0 }
};
static struct argp mu_auth_argp = {
mu_auth_argp_option,
mu_auth_argp_parser,
};
static struct argp_child mu_auth_argp_child = {
&mu_auth_argp,
0,
NULL,
0
};
static error_t
mu_auth_argp_parser (int key, char *arg, struct argp_state *state)
{
switch (key)
{
case ARGP_KEY_FINI:
mu_auth_finish_setup ();
break;
/* authentication */
case OPT_AUTHORIZATION:
mu_authorization_add_module_list (arg);
break;
case OPT_AUTHENTICATION:
mu_authentication_add_module_list (arg);
break;
case OPT_CLEAR_AUTHENTICATION:
mu_authentication_clear_list ();
break;
case OPT_CLEAR_AUTHORIZATION:
mu_authorization_clear_list ();
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
struct mu_cmdline_capa mu_auth_cmdline = {
"auth", &mu_auth_argp_child
};
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2004, 2005,
2007 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 useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifndef _MAILUTILS_CMDLINE_H
#define _MAILUTILS_CMDLINE_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "mailutils/types.h"
#include "mailutils/gocs.h"
#include "mailutils/nls.h"
#include "mailutils/error.h"
#include "mailutils/errno.h"
#include "argp.h"
#include <errno.h> /* May declare program_invocation_name */
#ifdef __cplusplus
extern "C" {
#endif
enum {
OPT_LOG_FACILITY = 256,
OPT_LOCK_FLAGS,
OPT_LOCK_RETRY_COUNT,
OPT_LOCK_RETRY_TIMEOUT,
OPT_LOCK_EXPIRE_TIMEOUT,
OPT_LOCK_EXTERNAL_PROGRAM,
OPT_SHOW_OPTIONS,
OPT_LICENSE,
OPT_MAILBOX_TYPE,
OPT_CRAM_PASSWD,
OPT_PAM_SERVICE,
OPT_AUTH_REQUEST,
OPT_GETPWNAM_REQUEST,
OPT_GETPWUID_REQUEST,
OPT_RADIUS_DIR,
OPT_SQL_INTERFACE,
OPT_SQL_GETPWNAM,
OPT_SQL_GETPWUID,
OPT_SQL_GETPASS,
OPT_SQL_HOST,
OPT_SQL_USER,
OPT_SQL_PASSWD,
OPT_SQL_DB,
OPT_SQL_PORT,
OPT_SQL_MU_PASSWORD_TYPE,
OPT_SQL_FIELD_MAP,
OPT_TLS,
OPT_SSL_CERT,
OPT_SSL_KEY,
OPT_SSL_CAFILE,
OPT_PWDDIR,
OPT_AUTHORIZATION,
OPT_AUTHENTICATION,
OPT_CLEAR_AUTHORIZATION,
OPT_CLEAR_AUTHENTICATION,
OPT_NO_USER_RCFILE,
OPT_NO_SITE_RCFILE,
OPT_RCFILE,
OPT_CLEAR_INCLUDE_PATH,
OPT_CLEAR_LIBRARY_PATH
};
struct mu_cmdline_capa
{
char *name;
struct argp_child *child;
};
extern struct mu_cmdline_capa mu_common_cmdline;
extern struct mu_cmdline_capa mu_logging_cmdline;
extern struct mu_cmdline_capa mu_license_cmdline;
extern struct mu_cmdline_capa mu_mailbox_cmdline;
extern struct mu_cmdline_capa mu_locking_cmdline;
extern struct mu_cmdline_capa mu_address_cmdline;
extern struct mu_cmdline_capa mu_mailer_cmdline;
extern struct mu_cmdline_capa mu_daemon_cmdline;
extern struct mu_cmdline_capa mu_sieve_cmdline;
extern struct mu_cmdline_capa mu_pam_cmdline;
extern struct mu_cmdline_capa mu_gsasl_cmdline;
extern struct mu_cmdline_capa mu_tls_cmdline;
extern struct mu_cmdline_capa mu_radius_cmdline;
extern struct mu_cmdline_capa mu_sql_cmdline;
extern struct mu_cmdline_capa mu_virtdomain_cmdline;
extern struct mu_cmdline_capa mu_auth_cmdline;
extern char *mu_license_text;
extern void mu_libargp_init (void);
extern struct argp *mu_argp_build (const struct argp *argp);
extern void mu_argp_done (struct argp *argp);
extern int mu_register_argp_capa (const char *name, struct argp_child *child);
extern void mu_print_options (void);
extern const char *mu_check_option (char *name);
#ifdef __cplusplus
}
#endif
#endif
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2007 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 useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "cmdline.h"
#include <mailutils/gsasl.h>
static struct argp_option _gsasl_argp_options[] = {
{"cram-passwd", OPT_CRAM_PASSWD, N_("FILE"), OPTION_HIDDEN,
N_("Specify password file for CRAM-MD5 authentication"), 0},
{ NULL, 0, NULL, 0, NULL, 0 }
};
static struct mu_gsasl_module_data gsasl_data = {
SITE_CRAM_MD5_PWD
};
static error_t
_gsasl_argp_parser (int key, char *arg, struct argp_state *state)
{
switch (key)
{
case OPT_CRAM_PASSWD:
gsasl_data.cram_md5_pwd = arg;
break;
case ARGP_KEY_FINI:
mu_gocs_store ("gsasl", &gsasl_data);
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
static struct argp _gsasl_argp = {
_gsasl_argp_options,
_gsasl_argp_parser
};
struct argp_child mu_gsasl_argp_child = {
&_gsasl_argp,
0,
NULL,
0
};
struct mu_cmdline_capa mu_gsasl_cmdline = {
"gsasl", &mu_gsasl_argp_child
};
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006,
2007 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 useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <getline.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "cmdline.h"
char *mu_license_text =
N_(" GNU Mailutils is free software; you can redistribute it and/or modify\n"
" it under the terms of the GNU General Public License as published by\n"
" the Free Software Foundation; either version 3 of the License, or\n"
" (at your option) any later version.\n"
"\n"
" GNU Mailutils is distributed in the hope that it will be useful,\n"
" but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
" GNU General Public License for more details.\n"
"\n"
" You should have received a copy of the GNU General Public License along\n"
" with GNU Mailutils; if not, write to the Free Software Foundation,\n"
" Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n"
"\n"
"\n"
);
static char *mu_conf_option[] = {
"VERSION=" VERSION,
#ifdef USE_LIBPAM
"USE_LIBPAM",
#endif
#ifdef HAVE_LIBLTDL
"HAVE_LIBLTDL",
#endif
#ifdef WITH_BDB2
"WITH_BDB2",
#endif
#ifdef WITH_NDBM
"WITH_NDBM",
#endif
#ifdef WITH_OLD_DBM
"WITH_OLD_DBM",
#endif
#ifdef WITH_GDBM
"WITH_GDBM",
#endif
#ifdef WITH_GNUTLS
"WITH_GNUTLS",
#endif
#ifdef WITH_GSASL
"WITH_GSASL",
#endif
#ifdef WITH_GSSAPI
"WITH_GSSAPI",
#endif
#ifdef WITH_GUILE
"WITH_GUILE",
#endif
#ifdef WITH_PTHREAD
"WITH_PTHREAD",
#endif
#ifdef WITH_READLINE
"WITH_READLINE",
#endif
#ifdef HAVE_MYSQL
"HAVE_MYSQL",
#endif
#ifdef HAVE_PGSQL
"HAVE_PGSQL",
#endif
#ifdef ENABLE_VIRTUAL_DOMAINS
"ENABLE_VIRTUAL_DOMAINS",
#endif
#ifdef ENABLE_IMAP
"ENABLE_IMAP",
#endif
#ifdef ENABLE_POP
"ENABLE_POP",
#endif
#ifdef ENABLE_MH
"ENABLE_MH",
#endif
#ifdef ENABLE_MAILDIR
"ENABLE_MAILDIR",
#endif
#ifdef ENABLE_SMTP
"ENABLE_SMTP",
#endif
#ifdef ENABLE_SENDMAIL
"ENABLE_SENDMAIL",
#endif
#ifdef ENABLE_NNTP
"ENABLE_NNTP",
#endif
#ifdef ENABLE_RADIUS
"ENABLE_RADIUS",
#endif
#ifdef WITH_INCLUDED_LIBINTL
"WITH_INCLUDED_LIBINTL",
#endif
NULL
};
void
mu_print_options ()
{
int i;
for (i = 0; mu_conf_option[i]; i++)
printf ("%s\n", mu_conf_option[i]);
}
const char *
mu_check_option (char *name)
{
int i;
for (i = 0; mu_conf_option[i]; i++)
{
int len;
char *q, *p = strchr (mu_conf_option[i], '=');
if (p)
len = p - mu_conf_option[i];
else
len = strlen (mu_conf_option[i]);
if (strncasecmp (mu_conf_option[i], name, len) == 0)
return mu_conf_option[i];
else if ((q = strchr (mu_conf_option[i], '_')) != NULL
&& strncasecmp (q + 1, name,
len - (q - mu_conf_option[i]) - 1) == 0)
return mu_conf_option[i];
}
return NULL;
}
/* ************************************************************************* */
/* Capability array and auxiliary functions. */
/* ************************************************************************* */
#define MU_MAX_CAPA 24
struct argp_capa {
char *capability;
struct argp_child *child;
} mu_argp_capa[MU_MAX_CAPA] = {
{NULL,}
};
int
mu_register_argp_capa (const char *name, struct argp_child *child)
{
int i;
for (i = 0; i < MU_MAX_CAPA; i++)
if (mu_argp_capa[i].capability == NULL)
{
mu_argp_capa[i].capability = strdup (name);
mu_argp_capa[i].child = child;
return 0;
}
return 1;
}
static struct argp_capa *
find_capa (const char *name)
{
int i;
for (i = 0; mu_argp_capa[i].capability; i++)
if (strcmp (mu_argp_capa[i].capability, name) == 0)
return &mu_argp_capa[i];
return NULL;
}
static struct argp *
mu_build_argp (const struct argp *template, const char *capa[])
{
int n;
int nchild;
struct argp_child *ap;
const struct argp_option *opt;
struct argp *argp;
int group = 0;
/* Count the capabilities. */
for (n = 0; capa && capa[n]; n++)
;
if (template->children)
for (; template->children[n].argp; n++)
;
ap = calloc (n + 1, sizeof (*ap));
if (!ap)
{
mu_error (_("Out of memory"));
abort ();
}
/* Copy the template's children. */
nchild = 0;
if (template->children)
for (n = 0; template->children[n].argp; n++, nchild++)
ap[nchild] = template->children[n];
/* Find next group number */
for (opt = template->options;
opt && ((opt->name && opt->key) || opt->doc); opt++)
if (opt->group > group)
group = opt->group;
group++;
/* Append any capabilities to the children or options, as appropriate. */
for (n = 0; capa && capa[n]; n++)
{
struct argp_capa *cp = find_capa (capa[n]);
if (!cp)
{
mu_error (_("INTERNAL ERROR: requested unknown argp "
"capability %s (please report)"),
capa[n]);
abort ();
}
ap[nchild] = *cp->child;
ap[nchild].group = group++;
nchild++;
}
ap[nchild].argp = NULL;
/* Copy the template, and give it the expanded children. */
argp = malloc (sizeof (*argp));
if (!argp)
{
mu_error (_("Out of memory"));
abort ();
}
memcpy (argp, template, sizeof (*argp));
argp->children = ap;
return argp;
}
struct cap_buf
{
const char **capa;
size_t numcapa;
size_t maxcapa;
};
static void
cap_buf_init (struct cap_buf *bp)
{
bp->numcapa = 0;
bp->maxcapa = 2;
bp->capa = calloc (bp->maxcapa, sizeof bp->capa[0]);
if (!bp->capa)
{
mu_error ("%s", mu_strerror (errno));
abort ();
}
bp->capa[0] = NULL;
}
static void
cap_buf_add (struct cap_buf *bp, const char *str)
{
if (bp->numcapa == bp->maxcapa)
{
bp->maxcapa *= 2;
bp->capa = realloc (bp->capa, bp->maxcapa * sizeof bp->capa[0]);
if (!bp->capa)
{
mu_error ("%s", mu_strerror (errno));
abort ();
}
}
bp->capa[bp->numcapa] = str;
if (str)
bp->numcapa++;
}
static void
cap_buf_free (struct cap_buf *bp)
{
free (bp->capa);
}
static int
argp_reg_action (void *item, void *data)
{
struct cap_buf *bp = data;
cap_buf_add (bp, item);
return 0;
}
struct argp *
mu_argp_build (const struct argp *init_argp)
{
struct cap_buf cb;
struct argp *argp;
cap_buf_init (&cb);
mu_gocs_enumerate (argp_reg_action, &cb);
cap_buf_add (&cb, NULL);
mu_libargp_init ();
argp = mu_build_argp (init_argp, cb.capa);
cap_buf_free (&cb);
return argp;
}
void
mu_argp_done (struct argp *argp)
{
free ((void*) argp->children);
free ((void*) argp);
}
......@@ -21,46 +21,23 @@
#define _MAILUTILS_ARGP_H
#include <mailutils/types.h>
#include <mailutils/cfg.h>
#include <argp.h>
#include <errno.h> /* May declare program_invocation_name */
#define MODE_INTERACTIVE 0
#define MODE_DAEMON 1
struct daemon_param {
int mode;
size_t maxchildren;
unsigned int port;
unsigned int timeout;
int transcript;
char *pidfile;
};
#ifdef USE_LIBPAM
extern char *pam_service;
#endif
extern int log_facility;
extern int mu_argp_error_code;
extern char *mu_license_text;
#ifdef __cplusplus
extern "C" {
#endif
extern void mu_argp_init (const char *vers, const char *bugaddr);
extern void mu_argp_init (struct argp *argp, const char *vers,
const char *bugaddr, const char *capa[]);
extern void mu_argp_done (struct argp *argp);
extern error_t mu_argp_parse (const struct argp * argp,
int *p_argc, char ***p_argv,
unsigned flags,
const char *capa[],
int *arg_index, void *input);
extern int mu_register_capa (const char *name, struct argp_child *child,
struct mu_cfg_param *param);
extern int mu_register_argp_capa (const char *name, struct argp_child *child);
extern void mu_print_options (void);
extern const char *mu_check_option (char *name);
extern void mu_argp_set_config_param (struct mu_cfg_param *);
#ifdef __cplusplus
}
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2007 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 useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "cmdline.h"
#include <mailutils/pam.h>
static char *service_name;
static error_t
mu_pam_argp_parser (int key, char *arg, struct argp_state *state)
{
switch (key)
{
case OPT_PAM_SERVICE:
service_name = arg;
break;
case ARGP_KEY_FINI:
mu_gocs_store ("pam", service_name);
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
static struct argp_option mu_pam_argp_option[] = {
{ "pam-service", OPT_PAM_SERVICE, N_("STRING"), OPTION_HIDDEN,
N_("Use STRING as PAM service name"), 0},
{ NULL, 0, NULL, 0, NULL, 0 }
};
static struct argp mu_pam_argp = {
mu_pam_argp_option,
mu_pam_argp_parser,
};
struct argp_child mu_pam_argp_child = {
&mu_pam_argp,
0,
NULL,
0
};
struct mu_cmdline_capa mu_pam_cmdline = {
"pam", &mu_pam_argp_child
};
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2007 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 useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "cmdline.h"
#include <mailutils/radius.h>
static struct argp_option mu_radius_argp_option[] = {
{ "radius-auth-request", OPT_AUTH_REQUEST, N_("REQUEST"), OPTION_HIDDEN,
N_("Radius request to authenitcate the user"), 0 },
{ "radius-getpwnam-request", OPT_GETPWNAM_REQUEST, N_("REQUEST"), OPTION_HIDDEN,
N_("Radius request to retrieve a passwd entry based on username"), 0 },
{ "radius-getpwuid-request", OPT_GETPWUID_REQUEST, N_("REQUEST"), OPTION_HIDDEN,
N_("Radius request to retrieve a passwd entry based on UID"), 0 },
{ "radius-directory", OPT_RADIUS_DIR, N_("DIR"), OPTION_HIDDEN,
N_("Set path to the radius configuration directory"), 0 },
{ NULL }
};
static struct mu_radius_module_data radius_data;
static error_t
mu_radius_argp_parser (int key, char *arg, struct argp_state *state)
{
switch (key)
{
case OPT_AUTH_REQUEST:
radius_data.auth_request = arg;
break;
case OPT_GETPWNAM_REQUEST:
radius_data.getpwnam_request = arg;
break;
case OPT_GETPWUID_REQUEST:
radius_data.getpwuid_request = arg;
break;
case OPT_RADIUS_DIR:
radius_data.config_dir = arg;
break;
case ARGP_KEY_FINI:
mu_gocs_store ("radius", &radius_data);
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
static struct argp mu_radius_argp = {
mu_radius_argp_option,
mu_radius_argp_parser,
};
struct argp_child mu_radius_argp_child = {
&mu_radius_argp,
0,
NULL,
0
};
struct mu_cmdline_capa mu_radius_cmdline = {
"radius", &mu_radius_argp_child
};
......@@ -20,74 +20,53 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sieve.h>
#include <mailutils/argp.h>
#include <string.h>
#include "cmdline.h"
#include "mailutils/libsieve.h"
mu_list_t mu_sieve_include_path = NULL;
mu_list_t mu_sieve_library_path = NULL;
static error_t sieve_argp_parser (int key, char *arg, struct argp_state *state);
#define CLEARPATH_OPTION 256
/* Options used by programs that use extended authentication mechanisms. */
static struct argp_option sieve_argp_option[] = {
{ "includedir", 'I', N_("DIR"), 0,
N_("Append directory DIR to the list of directories searched for include files"), 0 },
{ "libdir", 'L', N_("DIR"), 0,
N_("Append directory DIR to the list of directories searched for library files"), 0 },
{ "clearpath", CLEARPATH_OPTION, NULL, 0,
N_("Clear Sieve load path"), 0 },
{ "clear-include-path", OPT_CLEAR_INCLUDE_PATH, NULL, 0,
N_("Clear Sieve include path"), 0 },
{ "clear-library-path", OPT_CLEAR_LIBRARY_PATH, NULL, 0,
N_("Clear Sieve lobrary path"), 0 },
{ "clearpath", 0, NULL, OPTION_ALIAS, NULL },
{ NULL, 0, NULL, 0, NULL, 0 }
};
static struct argp sieve_argp = {
sieve_argp_option,
sieve_argp_parser,
};
static struct argp_child sieve_argp_child = {
&sieve_argp,
0,
"Sieve options",
0
};
static void
destroy_string (void *str)
{
free (str);
}
static error_t
sieve_argp_parser (int key, char *arg, struct argp_state *state)
{
static struct mu_gocs_sieve gocs_data;
mu_list_t *plist = NULL;
switch (key)
{
case 'I':
plist = &mu_sieve_include_path;
plist = &gocs_data.include_path;
break;
case 'L':
plist = &mu_sieve_library_path;
plist = &gocs_data.library_path;
break;
case OPT_CLEAR_INCLUDE_PATH:
gocs_data.clearflags |= MU_SIEVE_CLEAR_INCLUDE_PATH;
break;
case CLEARPATH_OPTION:
mu_list_destroy (&mu_sieve_library_path);
case OPT_CLEAR_LIBRARY_PATH:
gocs_data.clearflags |= MU_SIEVE_CLEAR_LIBRARY_PATH;
break;
case ARGP_KEY_INIT:
#ifdef SIEVE_MODDIR
plist = &mu_sieve_library_path;
arg = SIEVE_MODDIR;
#endif
memset (&gocs_data, 0, sizeof gocs_data);
break;
case ARGP_KEY_FINI:
sieve_load_add_path (mu_sieve_library_path);
mu_gocs_store ("sieve", &gocs_data);
break;
default:
......@@ -101,24 +80,30 @@ sieve_argp_parser (int key, char *arg, struct argp_state *state)
int rc = mu_list_create (plist);
if (rc)
{
argp_error (state, "can't create list: %s",
argp_error (state, _("cannot create list: %s"),
mu_strerror (rc));
exit (1);
}
mu_list_set_destroy_item (*plist, destroy_string);
}
mu_list_append (*plist, strdup (arg));
mu_list_append (*plist, arg);
}
return 0;
}
void
mu_sieve_argp_init ()
{
if (mu_register_capa ("sieve", &sieve_argp_child, NULL))
{
mu_error ("INTERNAL ERROR: cannot register argp capability sieve");
abort ();
}
}
static struct argp sieve_argp = {
sieve_argp_option,
sieve_argp_parser,
};
static struct argp_child sieve_argp_child = {
&sieve_argp,
0,
N_("Sieve options"),
0
};
struct mu_cmdline_capa mu_sieve_cmdline = {
"sieve", &sieve_argp_child
};
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2007 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 useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "cmdline.h"
#include "mailutils/sql.h"
#include "mailutils/mutil.h"
static int sql_requested;
static struct mu_sql_module_config sql_config;
/* Command-line configuration */
static struct argp_option mu_sql_argp_option[] = {
{"sql-interface", OPT_SQL_INTERFACE, N_("NAME"), OPTION_HIDDEN,
N_("Type of SQL interface to use"), },
{"sql-getpwnam", OPT_SQL_GETPWNAM, N_("QUERY"), OPTION_HIDDEN,
N_("SQL query to retrieve a passwd entry based on username"), 0},
{"sql-getpwuid", OPT_SQL_GETPWUID, N_("QUERY"), OPTION_HIDDEN,
N_("SQL query to retrieve a passwd entry based on UID"), 0},
{"sql-getpass", OPT_SQL_GETPASS, N_("QUERY"), OPTION_HIDDEN,
N_("SQL query to retrieve a password from the database"), 0},
{"sql-host", OPT_SQL_HOST, N_("HOSTNAME"), OPTION_HIDDEN,
N_("Name or IP of MySQL server to connect to"), 0},
{"sql-user", OPT_SQL_USER, N_("NAME"), OPTION_HIDDEN,
N_("SQL user name"), 0},
{"sql-passwd", OPT_SQL_PASSWD, N_("STRING"), OPTION_HIDDEN,
N_("SQL connection password"), 0},
{"sql-db", OPT_SQL_DB, N_("STRING"), OPTION_HIDDEN,
N_("Name of the database to connect to"), 0},
{"sql-port", OPT_SQL_PORT, N_("NUMBER"), OPTION_HIDDEN,
N_("Port to use"), 0},
{"sql-password-type", OPT_SQL_MU_PASSWORD_TYPE, N_("STRING"), OPTION_HIDDEN,
N_("Type of password returned by --sql-getpass query. STRING is one of: plain, hash, scrambled"), 0},
{"sql-field-map", OPT_SQL_FIELD_MAP, N_("MAP"), OPTION_HIDDEN,
N_("Declare a name translation map for SQL fields in results of sql-getpwnam and "
"sql-getpwuid queries"), 0},
{ NULL, 0, NULL, 0, NULL, 0 }
};
static error_t
mu_sql_argp_parser (int key, char *arg, struct argp_state *state)
{
int rc, err;
switch (key)
{
case OPT_SQL_INTERFACE:
sql_config.interface = arg;
sql_requested = 1;
break;
case OPT_SQL_GETPWNAM:
sql_requested = 1;
sql_config.getpwnam_query = arg;
break;
case OPT_SQL_GETPWUID:
sql_requested = 1;
sql_config.getpwuid_query = arg;
break;
case OPT_SQL_GETPASS:
sql_requested = 1;
sql_config.getpass_query = arg;
break;
case OPT_SQL_HOST:
sql_requested = 1;
sql_config.host = arg;
break;
case OPT_SQL_USER:
sql_requested = 1;
sql_config.user = arg;
break;
case OPT_SQL_PASSWD:
sql_requested = 1;
sql_config.passwd = arg;
break;
case OPT_SQL_DB:
sql_requested = 1;
sql_config.db = arg;
break;
case OPT_SQL_PORT:
sql_requested = 1;
sql_config.port = strtoul (arg, NULL, 0);
break;
case OPT_SQL_MU_PASSWORD_TYPE:
if (mu_sql_decode_password_type (arg, &sql_config.password_type))
argp_error (state, _("Unknown password type `%s'"), arg);
sql_requested = 1;
break;
case OPT_SQL_FIELD_MAP:
rc = mutil_parse_field_map (arg, &sql_config.field_map, &err);
if (rc)
argp_error (state, _("Error near element %d: %s"),
err, mu_strerror (rc));
sql_requested = 1;
break;
case ARGP_KEY_FINI:
if (sql_requested)
mu_gocs_store ("sql", &sql_config);
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
static struct argp mu_sql_argp = {
mu_sql_argp_option,
mu_sql_argp_parser,
};
struct argp_child mu_sql_argp_child = {
&mu_sql_argp,
0,
NULL,
0
};
struct mu_cmdline_capa mu_sql_cmdline = {
"sql", &mu_sql_argp_child
};
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2007 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 useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "cmdline.h"
#include <mailutils/tls.h>
#include "strcase.h" /* FIXME */
static struct argp_option _tls_argp_options[] = {
{"ssl-cert", OPT_SSL_CERT, N_("FILE"), OPTION_HIDDEN,
N_("Specify SSL certificate file"), 0},
{"ssl-key", OPT_SSL_KEY, N_("FILE"), OPTION_HIDDEN,
N_("Specify SSL certificate key"), },
{"ssl-cafile", OPT_SSL_CAFILE, N_("FILE"), OPTION_HIDDEN,
N_("Specify trusted CAs file"), 0},
{"tls", OPT_TLS, N_("BOOL"), OPTION_ARG_OPTIONAL,
N_("Enable TLS support") },
{NULL, 0, NULL, 0, NULL, 0}
};
static struct mu_tls_module_config tls_data = { 1, };
static error_t
_tls_argp_parser (int key, char *arg, struct argp_state *state)
{
switch (key)
{
case OPT_TLS:
if (!arg || strcasecmp (arg, "yes") == 0)
tls_data.client_enable = 1;
else if (strcasecmp (arg, "no") == 0)
tls_data.client_enable = 0;
break;
case OPT_SSL_CERT:
tls_data.ssl_cert = arg;
break;
case OPT_SSL_KEY:
tls_data.ssl_key = arg;
break;
case OPT_SSL_CAFILE:
tls_data.ssl_cafile = arg;
break;
case ARGP_KEY_FINI:
mu_gocs_store ("tls", &tls_data);
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
static struct argp _tls_argp = {
_tls_argp_options,
_tls_argp_parser
};
static struct argp_child _tls_argp_child = {
&_tls_argp,
0,
NULL,
0
};
struct mu_cmdline_capa mu_tls_cmdline = {
"tls", &_tls_argp_child
};
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2007 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 useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "cmdline.h"
static char *virtdir;
static error_t
mu_virt_argp_parser (int key, char *arg, struct argp_state *state)
{
switch (key)
{
case OPT_PWDDIR:
virtdir = arg;
break;
case ARGP_KEY_FINI:
mu_gocs_store ("virtdomain", virtdir);
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
static struct argp_option mu_virt_argp_option[] = {
{ "virtual-passwd-dir", OPT_PWDDIR, N_("DIR"), OPTION_HIDDEN,
N_("Search for virtual passwd file in DIR"), 0},
{ NULL, 0, NULL, 0, NULL, 0 }
};
static struct argp mu_virt_argp = {
mu_virt_argp_option,
mu_virt_argp_parser,
};
struct argp_child mu_virt_argp_child = {
&mu_virt_argp,
0,
NULL,
0
};
struct mu_cmdline_capa mu_virtdomain_cmdline = {
"virtdomain", &mu_virt_argp_child
};
*.la
*.lo
.deps
.libs
Makefile
Makefile.in
.gdbinit
# This file is part of GNU Mailutils
# Copyright (C) 2007 Free Software Foundation, Inc.
#
# GNU Mailutils is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3, or (at
# your option) any later version.
#
# GNU Mailutils is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Mailutils; if not, write to the Free Software
# Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA
INCLUDES = @MU_COMMON_INCLUDES@
AM_CFLAGS = -DSITE_VIRTUAL_PWDDIR=\"@SITE_VIRTUAL_PWDDIR@\" \
-DSITE_CRAM_MD5_PWD=\"@SITE_CRAM_MD5_PWD@\"
lib_LTLIBRARIES = libmucfg.la
noinst_HEADERS = libcfg.h
libmucfg_la_SOURCES=\
auth.c\
common.c\
init.c\
gsasl.c\
pam.c\
radius.c\
sieve.c\
sql.c\
tls.c\
virtdomain.c
/* This file is part of GNU Mailutils
Copyright (C) 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "libcfg.h"
#include <mailutils/mu_auth.h>
#include <string.h>
/* FIXME: mu_auth.c should be reviewed */
/* ************************************************************************* */
/* Resource-style configuration */
/* ************************************************************************* */
static int
cb_authentication (mu_cfg_locus_t *locus, void *data, char *arg)
{
if (strcmp (arg, "clear") == 0)
mu_authentication_clear_list ();
else
mu_authentication_add_module_list (arg);/*FIXME: error reporting*/
return 0;
}
static int
cb_authorization (mu_cfg_locus_t *locus, void *data, char *arg)
{
if (strcmp (arg, "clear") == 0)
mu_authorization_clear_list ();
else
mu_authorization_add_module_list (arg);
return 0;
}
static struct mu_cfg_param mu_auth_param[] = {
{ "authentication", mu_cfg_callback, NULL, cb_authentication },
{ "authorization", mu_cfg_callback, NULL, cb_authorization },
{ NULL }
};
/* FIXME: init? */
/* This file is part of GNU Mailutils
Copyright (C) 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "libcfg.h"
#include <string.h>
#include <mailutils/daemon.h>
static struct mu_gocs_daemon daemon_settings;
static struct mu_gocs_locking locking_settings;
static struct mu_gocs_logging logging_settings;
static struct mu_gocs_mailbox mailbox_settings;
static struct mu_gocs_source_email address_settings;
static struct mu_gocs_mailer mailer_settings;
/* ************************************************************************* */
/* Mailbox */
/* ************************************************************************* */
static struct mu_cfg_param mu_mailbox_param[] = {
{ "mail-spool", mu_cfg_string, &mailbox_settings.mail_spool },
{ "mailbox-type", mu_cfg_string, &mailbox_settings.mailbox_type },
{ NULL }
};
DCL_CFG_CAPA (mailbox);
/* ************************************************************************* */
/* Locking */
/* ************************************************************************* */
static struct mu_cfg_param mu_locking_param[] = {
{ "lock-flags", mu_cfg_string, &locking_settings.lock_flags },
{ "lock-retry-timeout", mu_cfg_ulong, &locking_settings.lock_retry_timeout },
{ "lock-retry-count", mu_cfg_ulong, &locking_settings.lock_retry_count },
{ "lock-expire-timeout", mu_cfg_ulong,
&locking_settings.lock_expire_timeout },
{ "external-locker", mu_cfg_string, &locking_settings.external_locker },
{ NULL, }
};
DCL_CFG_CAPA (locking);
/* ************************************************************************* */
/* Address */
/* ************************************************************************* */
static struct mu_cfg_param mu_address_param[] = {
{ "email-addr", mu_cfg_string, &address_settings.address },
{ "email-domain", mu_cfg_string, &address_settings.domain },
{ NULL }
};
DCL_CFG_CAPA (address);
/* ************************************************************************* */
/* Mailer */
/* ************************************************************************* */
static struct mu_cfg_param mu_mailer_param[] = {
{ "url", mu_cfg_string, &mailer_settings.mailer },
{ NULL }
};
DCL_CFG_CAPA (mailer);
/* ************************************************************************* */
/* Logging */
/* ************************************************************************* */
static struct mu_cfg_param mu_logging_param[] = {
{ "facility", mu_cfg_string, &logging_settings.facility },
{ NULL }
};
DCL_CFG_CAPA (logging);
/* ************************************************************************* */
/* Daemon */
/* ************************************************************************* */
static int
_cb_daemon_mode (mu_cfg_locus_t *locus, void *data, char *arg)
{
if (strcmp (arg, "inetd") == 0
|| strcmp (arg, "interactive") == 0)
daemon_settings.mode = MODE_INTERACTIVE;
else if (strcmp (arg, "daemon") == 0)
daemon_settings.mode = MODE_DAEMON;
else
{
mu_error ("%s:%d: unknown daemon mode", locus->file, locus->line);
return 1;
}
return 0;
}
static struct mu_cfg_param mu_daemon_param[] = {
{ "max-children", mu_cfg_ulong, &daemon_settings.maxchildren },
{ "mode", mu_cfg_callback, NULL, _cb_daemon_mode },
{ "transcript", mu_cfg_bool, &daemon_settings.transcript },
{ "pidfile", mu_cfg_string, &daemon_settings.pidfile },
{ "port", mu_cfg_ushort, &daemon_settings.port },
{ "timeout", mu_cfg_ulong, &daemon_settings.timeout },
{ NULL }
};
/* This file is part of GNU Mailutils
Copyright (C) 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "libcfg.h"
#include <mailutils/gsasl.h>
static struct mu_gsasl_module_data gsasl_settings;
static struct mu_cfg_param mu_gsasl_param[] = {
{ "cram-passwd", mu_cfg_string, &gsasl_settings.cram_md5_pwd },
{ NULL }
};
DCL_CFG_CAPA (gsasl);
/* This file is part of GNU Mailutils
Copyright (C) 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "libcfg.h"
#include <string.h>
#include <stdlib.h>
struct mu_cfg_capa *cfg_capa_table[] = {
#define S(c) &__mu_common_cat3__(mu_,c,_cfg_capa)
S (mailbox),
S (locking),
S (address),
S (mailer),
S (logging),
S (gsasl),
S (pam),
S (radius),
S (sql),
S (tls),
S (virtdomain),
NULL
};
struct mu_cfg_capa *
find_cfg_capa (const char *name)
{
int i;
for (i = 0; cfg_capa_table[i]; i++)
if (strcmp (cfg_capa_table[i]->name, name) == 0)
return cfg_capa_table[i];
return NULL;
}
static int
reserved_name (const char *name)
{
static char *reserved[] = { "auth", "common", "daemon", "license", NULL };
char **p;
for (p = reserved; *p; p++)
if (strcmp (name, *p) == 0)
return 1;
return 0;
}
void
mu_libcfg_init (const char **cnames)
{
int i;
for (i = 0; cnames[i]; i++)
{
if (!reserved_name (cnames[i]))
{
struct mu_cfg_capa *cp = find_cfg_capa (cnames[i]);
if (!cp)
mu_error (_("Requested unknown configuration group `%s'"),
cnames[i]);
else
mu_config_register_section (NULL, cp->name, cp->parser, NULL,
cp->cfgparam);
}
}
}
int
mu_parse_config_files (struct mu_cfg_param *param)
{
if (mu_load_site_rcfile)
mu_parse_config (MU_CONFIG_FILE, mu_program_name, param, 1);
if (mu_load_user_rcfile && mu_program_name)
{
size_t size = 3 + strlen (mu_program_name) + 1;
char *file_name = malloc (size);
if (file_name)
{
strcpy (file_name, "~/.");
strcat (file_name, mu_program_name);
mu_parse_config (file_name, mu_program_name, param, 0);
free (file_name);
}
}
if (mu_load_rcfile)
mu_parse_config (mu_load_rcfile, mu_program_name, param, 0);
return 0;
}
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2007 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 useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <mailutils/cfg.h>
#include <mailutils/gocs.h>
#include <mailutils/nls.h>
#include <mailutils/error.h>
#include <mailutils/errno.h>
#ifndef MU_CONFIG_FILE
# define MU_CONFIG_FILE SYSCONFDIR "/mailutils.rc"
#endif
#ifndef MU_USER_CONFIG_FILE
# define MU_USER_CONFIG_FILE "~/.mailutils"
#endif
struct mu_cfg_capa
{
char *name;
struct mu_cfg_param *cfgparam;
mu_cfg_section_fp parser;
};
extern int mu_register_cfg_capa (const char *name,
struct mu_cfg_param *cfgparam,
mu_cfg_section_fp *parser);
extern void mu_libcfg_init (const char **cnames);
extern int mu_parse_config_files (struct mu_cfg_param *param);
#define __mu_common_cat2__(a,b) a ## b
#define __mu_common_cat3__(a,b,c) a ## b ## c
#define DCL_PARSER(capa) \
int \
__mu_common_cat3__(mu_,capa,_section_parser) \
(enum mu_cfg_section_stage stage, const mu_cfg_node_t *node, \
void *section_data, void *call_data) \
{ \
switch (stage) \
{ \
case mu_cfg_section_start: \
break; \
\
case mu_cfg_section_end: \
mu_gocs_store (#capa, &__mu_common_cat2__(capa, _settings)); \
} \
return 0; \
}
#define DCL_DEFAULT_CFG_CAPA(capa) \
struct mu_cfg_capa __mu_common_cat3__(mu_,capa,_cfg_capa) = { \
#capa, \
__mu_common_cat3__(mu_,capa,_param), \
__mu_common_cat3__(mu_,capa,_section_parser) \
}
#define DCL_CFG_CAPA(capa) \
DCL_PARSER (capa) \
DCL_DEFAULT_CFG_CAPA (capa)
extern struct mu_cfg_capa mu_mailbox_cfg_capa;
extern struct mu_cfg_capa mu_locking_cfg_capa;
extern struct mu_cfg_capa mu_address_cfg_capa;
extern struct mu_cfg_capa mu_mailer_cfg_capa;
extern struct mu_cfg_capa mu_logging_cfg_capa;
extern struct mu_cfg_capa mu_gsasl_cfg_capa;
extern struct mu_cfg_capa mu_pam_cfg_capa;
extern struct mu_cfg_capa mu_radius_cfg_capa;
extern struct mu_cfg_capa mu_sql_cfg_capa;
extern struct mu_cfg_capa mu_tls_cfg_capa;
extern struct mu_cfg_capa mu_virtdomain_cfg_capa;
/* This file is part of GNU Mailutils
Copyright (C) 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "libcfg.h"
static char *pam_settings;
static struct mu_cfg_param mu_pam_param[] = {
{ "service", mu_cfg_string, &pam_settings },
{ NULL }
};
DCL_CFG_CAPA (pam);
/* This file is part of GNU Mailutils
Copyright (C) 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "libcfg.h"
#include <mailutils/radius.h>
static struct mu_radius_module_data radius_settings;
static struct mu_cfg_param mu_radius_param[] = {
{ "auth-request", mu_cfg_string, &radius_settings.auth_request },
{ "getpwnam-request", mu_cfg_string, &radius_settings.getpwnam_request },
{ "getpwuid-request", mu_cfg_string, &radius_settings.getpwuid_request },
{ "directory", mu_cfg_string, &radius_settings.config_dir },
{ NULL }
};
DCL_CFG_CAPA (radius);
/* This file is part of GNU Mailutils
Copyright (C) 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "libcfg.h"
#include <mailutils/libsieve.h>
static struct mu_gocs_sieve sieve_settings;
static int
cb_clear_library_path (mu_cfg_locus_t *locus, void *data, char *arg)
{
int flag;
if (mu_cfg_parse_boolean (arg, &flag))
{
mu_error ("%s:%u: %s", locus->file, locus->line, _("not a boolean"));
return 1;
}
if (flag)
sieve_settings.clearflags |= MU_SIEVE_CLEAR_LIBRARY_PATH;
return 0;
}
static int
cb_clear_include_path (mu_cfg_locus_t *locus, void *data, char *arg)
{
int flag;
if (mu_cfg_parse_boolean (arg, &flag))
{
mu_error ("%s:%u: %s", locus->file, locus->line, _("not a boolean"));
return 1;
}
if (flag)
sieve_settings.clearflags |= MU_SIEVE_CLEAR_INCLUDE_PATH;
return 0;
}
static void
destroy_string (void *str)
{
free (str);
}
static int
_add_path (mu_list_t *plist, mu_cfg_locus_t *locus, void *data, char *arg)
{
char *p;
if (!*plist)
{
int rc = mu_list_create (plist);
if (rc)
{
mu_error (_("cannot create list: %s"), mu_strerror (rc));
exit (1);
}
mu_list_set_destroy_item (*plist, destroy_string);
}
for (p = strtok (arg, ":"); p; p = strtok (NULL, ":"))
mu_list_append (*plist, strdup (p));
return 0;
}
static int
cb_include_path (mu_cfg_locus_t *locus, void *data, char *arg)
{
return _add_path (&sieve_settings.include_path, locus, data, arg);
}
static int
cb_library_path (mu_cfg_locus_t *locus, void *data, char *arg)
{
return _add_path (&sieve_settings.library_path, locus, data, arg);
}
static struct mu_cfg_param mu_sieve_param[] = {
{ "clear-library-path", mu_cfg_callback, NULL, cb_clear_library_path },
{ "clear-include-path", mu_cfg_callback, NULL, cb_clear_include_path },
{ "library-path", mu_cfg_callback, NULL, cb_library_path },
{ "include-path", mu_cfg_callback, NULL, cb_include_path },
{ NULL }
};
DCL_CFG_CAPA (sieve);
/* This file is part of GNU Mailutils
Copyright (C) 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "libcfg.h"
#include <mailutils/sql.h>
#include <mailutils/mutil.h>
static struct mu_sql_module_config sql_settings;
/* Resource file configuration */
static int
cb_password_type (mu_cfg_locus_t *locus, void *data, char *arg)
{
if (mu_sql_decode_password_type (arg, &sql_settings.password_type))
mu_error (_("%s:%d: Unknown password type `%s'"),
locus->file, locus->line, arg);
return 0;
}
static int
cb_field_map (mu_cfg_locus_t *locus, void *data, char *arg)
{
int err;
int rc = mutil_parse_field_map (arg, &sql_settings.field_map, &err);
if (rc)
mu_error (_("%s:%d: Error near element %d: %s"),
locus->file, locus->line, err, mu_strerror (rc));
return 0;
}
static struct mu_cfg_param mu_sql_param[] = {
{ "interface", mu_cfg_string, &sql_settings.interface },
{ "getwpnam", mu_cfg_string, &sql_settings.getpwnam_query },
{ "getpwuid", mu_cfg_string, &sql_settings.getpwuid_query },
{ "getpass", mu_cfg_string, &sql_settings.getpass_query },
{ "host", mu_cfg_string, &sql_settings.host },
{ "user", mu_cfg_string, &sql_settings.user },
{ "passwd", mu_cfg_string, &sql_settings.passwd },
{ "db", mu_cfg_string, &sql_settings.db },
{ "port", mu_cfg_int, &sql_settings.port },
{ "password-type", mu_cfg_callback, NULL, cb_password_type },
{ "field-map", mu_cfg_callback, NULL, cb_field_map },
{ NULL }
};
DCL_CFG_CAPA (sql);
/* This file is part of GNU Mailutils
Copyright (C) 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "libcfg.h"
#include <mailutils/tls.h>
static struct mu_tls_module_config tls_settings;
static struct mu_cfg_param mu_tls_param[] = {
{ "tls", mu_cfg_bool, &tls_settings.client_enable },
{ "ssl-cert", mu_cfg_string, &tls_settings.ssl_cert },
{ "ssl-key", mu_cfg_string, &tls_settings.ssl_key },
{ "ssl-cafile", mu_cfg_string, &tls_settings.ssl_cafile },
{ NULL }
};
DCL_CFG_CAPA (tls);
/* This file is part of GNU Mailutils
Copyright (C) 2007 Free Software Foundation, Inc.
GNU Mailutils is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "libcfg.h"
static char *virtdomain_settings;
static struct mu_cfg_param mu_virtdomain_param[] = {
{ "passwd-dir", mu_cfg_string, &virtdomain_settings },
{ NULL }
};
DCL_CFG_CAPA (virtdomain);
......@@ -29,7 +29,7 @@ lib_LTLIBRARIES = libsieve.la
libsieve_la_SOURCES = \
actions.c\
argp.c\
conf.c\
comparator.c\
load.c\
prog.c\
......
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 1999, 2000, 2001, 2002, 2005,
2007 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 useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sieve.h>
#include <string.h>
mu_list_t mu_sieve_include_path = NULL;
mu_list_t mu_sieve_library_path = NULL;
static void
destroy_string (void *str)
{
free (str);
}
static int
_path_append (void *item, void *data)
{
mu_list_t *plist = data;
if (!*plist)
{
int rc = mu_list_create (plist);
if (rc)
{
mu_error (_("cannot create list: %s"), mu_strerror (rc));
exit (1);
}
mu_list_set_destroy_item (*plist, destroy_string);
}
return mu_list_append (*plist, strdup (item));
}
int
mu_sieve_module_init (void *data)
{
struct mu_gocs_sieve *p;
if (!data)
return 0;
p = data;
if (p->clearflags & MU_SIEVE_CLEAR_INCLUDE_PATH)
mu_list_destroy (&mu_sieve_include_path);
mu_list_do (p->include_path, _path_append, &mu_sieve_include_path);
if (p->clearflags & MU_SIEVE_CLEAR_LIBRARY_PATH)
mu_list_destroy (&mu_sieve_library_path);
mu_list_do (p->library_path, _path_append, &mu_sieve_library_path);
sieve_load_add_path (mu_sieve_library_path);
mu_list_destroy (&p->library_path);
mu_list_destroy (&p->include_path);
return 0;
}
......@@ -31,7 +31,7 @@ maidag_SOURCES=\
maidag_LDADD = \
@LIBMU_SCM@ @GUILE_LIBS@\
@LIBMU_SCM_DEPS@\
../lib/libmuaux.la \
${MU_APP_LIBRARIES}\
${MU_LIB_SIEVE}\
${MU_LIB_MBOX}\
${MU_LIB_IMAP}\
......
......@@ -252,7 +252,7 @@ lmtp_reply (FILE *fp, char *code, char *enh, char *fmt, ...)
vasprintf (&str, fmt, ap);
va_end (ap);
if (daemon_param.transcript)
if (mu_gocs_daemon.transcript)
{
if (enh)
syslog (LOG_INFO, "LMTP reply: %s %s %s", code, enh, str);
......@@ -737,7 +737,7 @@ lmtp_loop (FILE *in, FILE *out)
trimnl (buf);
if (daemon_param.transcript)
if (mu_gocs_daemon.transcript)
syslog (LOG_INFO, "LMTP recieve: %s", buf);
if (next_state != state_none)
......@@ -784,7 +784,7 @@ lmtp_daemon (char *urlstr)
socklen_t addrlen;
pid_t pid;
if (daemon_param.mode == MODE_DAEMON)
if (mu_gocs_daemon.mode == MODE_DAEMON)
{
if (daemon (0, 0) < 0)
{
......@@ -819,7 +819,7 @@ lmtp_daemon (char *urlstr)
for (;;)
{
process_cleanup ();
if (children > daemon_param.maxchildren)
if (children > mu_gocs_daemon.maxchildren)
{
mu_error (_("too many children (%lu)"),
(unsigned long) children);
......@@ -879,11 +879,11 @@ maidag_lmtp_server ()
if (lmtp_url_string)
return lmtp_daemon (lmtp_url_string);
else if (daemon_param.mode == MODE_INTERACTIVE)
else if (mu_gocs_daemon.mode == MODE_INTERACTIVE)
return lmtp_loop (stdin, stdout);
else
{
const char *pstr = mu_umaxtostr (0, daemon_param.port);
const char *pstr = mu_umaxtostr (0, mu_gocs_daemon.port);
char *urls = malloc (sizeof (DEFAULT_URL) + strlen (pstr));
if (!urls)
{
......
......@@ -50,7 +50,7 @@ char *lmtp_url_string;
int reuse_lmtp_address = 1;
char *lmtp_group = "mail";
struct daemon_param daemon_param = {
struct mu_gocs_daemon daemon_param = {
MODE_INTERACTIVE, /* Start in interactive (inetd) mode */
20, /* Default maximum number of children */
0, /* No standard port */
......@@ -111,7 +111,7 @@ static struct argp argp = {
NULL, NULL
};
static const char *argp_capa[] = {
static const char *maidag_argp_capa[] = {
"daemon",
"auth",
"common",
......@@ -119,7 +119,6 @@ static const char *argp_capa[] = {
"logging",
"mailbox",
"mailer",
"sieve",
NULL
};
......@@ -255,10 +254,10 @@ struct mu_cfg_param maidag_cfg_param[] = {
#ifdef USE_SQL
{ "quota-query", mu_cfg_string, &quota_query },
#endif
{ "sieve", mu_cfg_string, &sieve_pattern },
{ "sieve-filter", mu_cfg_string, &sieve_pattern },
{ "message-id-header", mu_cfg_string, &message_id_header },
#ifdef WITH_GUILE
{ "source", mu_cfg_string, &progfile_pattern },
{ "guile-filter", mu_cfg_string, &progfile_pattern },
#endif
{ "debug", mu_cfg_callback, NULL, cb_debug },
{ "stderr", mu_cfg_bool, &log_to_stderr },
......@@ -461,8 +460,6 @@ main (int argc, char *argv[])
mu_locker_set_default_retry_timeout (1);
mu_locker_set_default_retry_count (300);
/* Default error code for command line errors */
mu_argp_error_code = EX_CONFIG;
/* Register needed modules */
MU_AUTH_REGISTER_ALL_MODULES ();
......@@ -473,12 +470,13 @@ main (int argc, char *argv[])
mu_registrar_record (mu_sendmail_record);
mu_registrar_record (mu_smtp_record);
mu_argp_init (program_version, NULL);
mu_sieve_argp_init ();
mu_gocs_register ("sieve", mu_sieve_module_init);
/* Parse command line */
mu_argp_set_config_param (maidag_cfg_param);
mu_argp_parse (&argp, &argc, &argv, 0, argp_capa, &arg_index, &daemon_param);
mu_argp_init (program_version, NULL);
if (mu_app_init (&argp, maidag_argp_capa, maidag_cfg_param,
argc, argv, 0, &arg_index, NULL))
exit (EX_CONFIG);
current_uid = getuid ();
......
......@@ -82,6 +82,7 @@
#include <mailutils/mu_auth.h>
#include <mailutils/libsieve.h>
#include <mailutils/nls.h>
#include <mailutils/daemon.h>
#include <mu_dbm.h>
#include <mu_asprintf.h>
......@@ -91,7 +92,8 @@
# define USE_MAILBOX_QUOTAS 1
#endif
#include <mailutils/argp.h>
#include "muinit.h"
/* Debug */
extern int debug_level;
#define dbg() if (debug_level) debug
......@@ -120,7 +122,6 @@ extern int lmtp_mode;
extern char *lmtp_url_string;
extern int reuse_lmtp_address;
extern char *lmtp_group;
extern struct daemon_param daemon_param;
void close_fds (void);
int switch_user_id (struct mu_auth_data *auth, int user);
......
......@@ -162,12 +162,12 @@ sql_retrieve_quota (char *name, mu_off_t *quota)
return RETR_FAILURE;
status = mu_sql_connection_init (&conn,
sql_interface,
mu_sql_host,
mu_sql_port,
mu_sql_user,
mu_sql_passwd,
mu_sql_db);
mu_sql_module_config.interface,
mu_sql_module_config.host,
mu_sql_module_config.port,
mu_sql_module_config.user,
mu_sql_module_config.passwd,
mu_sql_module_config.db);
if (status)
{
......
......@@ -26,7 +26,7 @@ mail_local_SOURCES = main.c mailquota.c script.c mail.local.h
mail_local_LDADD = \
@LIBMU_SCM@ @GUILE_LIBS@\
@LIBMU_SCM_DEPS@\
../lib/libmuaux.la \
${MU_APP_LIBRARIES}\
${MU_LIB_SIEVE}\
${MU_LIB_MBOX}\
${MU_LIB_IMAP}\
......
......@@ -92,7 +92,6 @@
# define USE_MAILBOX_QUOTAS 1
#endif
#include <mailutils/argp.h>
/* Debug */
extern int debug_level;
#define dbg() if (debug_level) debug
......
......@@ -162,12 +162,12 @@ sql_retrieve_quota (char *name, mu_off_t *quota)
return RETR_FAILURE;
status = mu_sql_connection_init (&conn,
sql_interface,
mu_sql_host,
mu_sql_port,
mu_sql_user,
mu_sql_passwd,
mu_sql_db);
mu_sql_module_config.interface,
mu_sql_module_config.host,
mu_sql_module_config.port,
mu_sql_module_config.user,
mu_sql_module_config.passwd,
mu_sql_module_config.db);
if (status)
{
......
......@@ -18,6 +18,7 @@
MA 02110-1301 USA */
#include <mail.local.h>
#include "muinit.h"
int multiple_delivery; /* Don't return errors when delivering to multiple
recipients */
......@@ -117,7 +118,6 @@ static const char *argp_capa[] = {
"logging",
"mailbox",
"mailer",
"sieve",
NULL
};
......@@ -365,15 +365,14 @@ main (int argc, char *argv[])
mu_locker_set_default_retry_timeout (1);
mu_locker_set_default_retry_count (300);
/* Default error code for command line errors */
mu_argp_error_code = EX_CONFIG;
/* Register needed modules */
MU_AUTH_REGISTER_ALL_MODULES();
mu_argp_init (program_version, NULL);
mu_sieve_argp_init ();
/* Parse command line */
mu_argp_set_config_param (mail_local_cfg_param);
mu_argp_parse (&argp, &argc, &argv, 0, argp_capa, &arg_index, NULL);
mu_gocs_register ("sieve", mu_sieve_module_init);
mu_argp_init (program_version, NULL);
if (mu_app_init (&argp, argp_capa, mail_local_cfg_param,
argc, argv, 0, &arg_index, NULL))
exit (EX_CONFIG);
uid = getuid ();
......
......@@ -27,7 +27,7 @@ libexec_PROGRAMS = @BUILD_SMTP_PROGRAMS@
mail_remote_SOURCES = mail.remote.c
mail_remote_LDADD = \
../lib/libmuaux.la\
${MU_APP_LIBRARIES}\
${MU_LIB_AUTH}\
${MU_LIB_MAILER}\
@MU_AUTHLIBS@\
......
......@@ -31,7 +31,6 @@
#include <unistd.h>
#include <mailutils/address.h>
#include <mailutils/argp.h>
#include <mailutils/debug.h>
#include <mailutils/errno.h>
#include <mailutils/list.h>
......@@ -44,6 +43,7 @@
#include <mailutils/error.h>
#include <mailutils/nls.h>
#include <mailutils/mu_auth.h>
#include "muinit.h"
const char *program_version = "mail.remote (" PACKAGE_STRING ")";
static char doc[] =
......@@ -171,8 +171,9 @@ main (int argc, char **argv)
MU_AUTH_REGISTER_ALL_MODULES();
mu_argp_init (program_version, NULL);
mu_argp_set_config_param (mail_remote_cfg_param);
mu_argp_parse (&argp, &argc, &argv, 0, capa, &optind, NULL);
if (mu_app_init (&argp, capa, mail_remote_cfg_param,
argc, argv, 0, &optind, NULL))
exit (1);
if (optfrom)
{
......