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.
Showing
126 changed files
with
2793 additions
and
849 deletions
1 | 2007-11-17 Sergey Poznyakoff <gray@gnu.org.ua> | ||
2 | |||
3 | Move rc file and argp parsing into separate abstract layers. | ||
4 | |||
5 | * include/mailutils/gocs.h, include/mailutils/pam.h, | ||
6 | include/mailutils/radius.h, include/mailutils/syslog.h: New files | ||
7 | * lib/argpinit.c, lib/muinit.c, lib/muinit.h: New files. | ||
8 | * libsieve/conf.c: New file. | ||
9 | |||
10 | * libcfg: New directory | ||
11 | * libcfg/libcfg.h, libcfg/auth.c, libcfg/common.c, libcfg/init.c, | ||
12 | libcfg/gsasl.c, libcfg/pam.c, libcfg/radius.c, libcfg/sieve.c, | ||
13 | libcfg/sql.c, libcfg/tls.c, libcfg/virtdomain.c, | ||
14 | libcfg/.cvsignore: New files. | ||
15 | |||
16 | * libargp: New directory | ||
17 | * libargp/auth.c, libargp/cmdline.h, libargp/common.c, | ||
18 | libargp/gsasl.c, libargp/mu_argp.h, libargp/mu_argp.c, | ||
19 | libargp/pam.c, libargp/radius.c, libargp/sieve.c, libargp/sql.c, | ||
20 | libargp/tls.c, libargp/virtdomain.c, libargp/.cvsignore: New | ||
21 | files. | ||
22 | |||
23 | * mailbox/.cvsignore: Add cfg_parser.c and cfg_parser.h. | ||
24 | * Makefile.am (SUBDIRS): Add libargp and libcfg. | ||
25 | * configure.ac (MU_APP_LIBRARIES): New variable | ||
26 | (MU_COMMON_INCLUDES): add libargp and libcfg | ||
27 | (AC_CONFIG_FILES): Add libargp and libcfg. | ||
28 | |||
29 | * auth/gsasl.c, auth/pam.c, auth/radius.c, auth/sql.c, auth/sql.h, | ||
30 | auth/tls.c, auth/virtual.c, comsat/comsat.h, frm/frm.h, | ||
31 | guimb/guimb.h, imap4d/imap4d.h, include/mailutils/gsasl.h, | ||
32 | include/mailutils/libsieve.h, include/mailutils/mailutils.h, | ||
33 | include/mailutils/mu_auth.h, include/mailutils/tls.h, | ||
34 | include/mailutils/sql.h, maidag/maidag.h, mail/mail.h, | ||
35 | mail.local/mail.local.h, mailbox/daemon.c, mailbox/system.c, | ||
36 | mh/mh_argp.c, mh/mh_getopt.h, pop3d/pop3d.h, | ||
37 | readmsg/readmsg.h: Remove argp stuff | ||
38 | |||
39 | * comsat/comsat.c, config/mailutils-config.c, dotlock/dotlock.c, | ||
40 | examples/muauth.c, examples/muemail.c, frm/frm.c, frm/from.c, | ||
41 | guimb/main.c, imap4d/idle.c, imap4d/imap4d.c, imap4d/util.c, | ||
42 | imap4d/version.c, maidag/lmtp.c, maidag/maidag.c, | ||
43 | maidag/mailquota.c, mail/mail.c, mail/send.c, mail/version.c, | ||
44 | mail.local/mailquota.c, mail.local/main.c, | ||
45 | mail.remote/mail.remote.c, mailbox/mu_auth.c, messages/messages.c, | ||
46 | mimeview/mimeview.c, movemail/movemail.c, pop3d/extra.c, | ||
47 | pop3d/pop3d.c, pop3d/popauth.c, readmsg/readmsg.c, sieve/sieve.c: | ||
48 | Use mu_app_init for parsing command line and | ||
49 | configuration files. | ||
50 | * comsat/Makefile.am, config/Makefile.am, dotlock/Makefile.am, | ||
51 | examples/Makefile.am, frm/Makefile.am, guimb/Makefile.am, | ||
52 | imap4d/Makefile.am, maidag/Makefile.am, mail/Makefile.am, | ||
53 | mail.local/Makefile.am, mail.remote/Makefile.am, | ||
54 | mailbox/Makefile.am, messages/Makefile.am, mimeview/Makefile.am, | ||
55 | movemail/Makefile.am, pop3d/Makefile.am, readmsg/Makefile.am, | ||
56 | sieve/Makefile.am: Use MU_APP_LIBRARIES. | ||
57 | |||
58 | * include/mailutils/Makefile.am: Add new files. | ||
59 | * include/mailutils/argp.h: Remove. | ||
60 | * include/mailutils/cfg.h: New file. | ||
61 | * include/mailutils/daemon.h (MODE_INTERACTIVE,MODE_DAEMON): New | ||
62 | defines (from removed argp.h). | ||
63 | (mu_gocs_daemon): New decl. | ||
64 | * include/mailutils/error.h (mu_program_name): New variable | ||
65 | (mu_set_program_name): New function. | ||
66 | * lib/Makefile.am (libmuaux_la_SOURCES): Add new files. | ||
67 | * libsieve/Makefile.am (libsieve_la_SOURCES): Remove argp.c, add | ||
68 | conf.c instead. | ||
69 | * libsieve/argp.c: Remove. | ||
70 | |||
71 | * mailbox/cfg_parser.y (mu_cfg_parse_boolean): New function. | ||
72 | * mailbox/mu_argp.c: Remove. | ||
73 | |||
74 | * mailbox/muerror.c (mu_program_name): New variable | ||
75 | (mu_set_program_name): New function | ||
76 | (mu_default_error_printer): Print program name before diagnostic | ||
77 | string. | ||
78 | * mailbox/mutil.c (mu_sql_decode_password_type): New function. | ||
79 | * mh/mh_whom.c (mh_alias_expand): Bugfix | ||
80 | * po/POTFILES.in: Update | ||
81 | * testsuite/lib/mailutils.exp (mu_init): Pass --no-site-rcfile | ||
82 | --no-user-rcfile to all programs. | ||
83 | |||
1 | 2007-11-12 Sergey Poznyakoff <gray@gnu.org.ua> | 84 | 2007-11-12 Sergey Poznyakoff <gray@gnu.org.ua> |
2 | 85 | ||
3 | * maidag/lmtp.c: Use English reply texts. | 86 | * maidag/lmtp.c: Use English reply texts. | ... | ... |
... | @@ -26,7 +26,6 @@ | ... | @@ -26,7 +26,6 @@ |
26 | #include <string.h> | 26 | #include <string.h> |
27 | #include <limits.h> | 27 | #include <limits.h> |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | #include <mailutils/argp.h> | ||
30 | #include <mailutils/error.h> | 29 | #include <mailutils/error.h> |
31 | #include <mailutils/errno.h> | 30 | #include <mailutils/errno.h> |
32 | #include <mailutils/mu_auth.h> | 31 | #include <mailutils/mu_auth.h> |
... | @@ -36,54 +35,21 @@ | ... | @@ -36,54 +35,21 @@ |
36 | #include <gsasl.h> | 35 | #include <gsasl.h> |
37 | #include <lbuf.h> | 36 | #include <lbuf.h> |
38 | 37 | ||
39 | char *mu_gsasl_cram_md5_pwd = SITE_CRAM_MD5_PWD; | 38 | struct mu_gsasl_module_data mu_gsasl_module_data; |
40 | 39 | ||
41 | #define ARG_CRAM_PASSWD 1 | 40 | int |
42 | 41 | mu_gsasl_module_init (void *data) | |
43 | static struct argp_option _gsasl_argp_options[] = { | ||
44 | {"cram-passwd", ARG_CRAM_PASSWD, N_("FILE"), OPTION_HIDDEN, | ||
45 | N_("Specify password file for CRAM-MD5 authentication"), 0}, | ||
46 | { NULL, 0, NULL, 0, NULL, 0 } | ||
47 | }; | ||
48 | |||
49 | static error_t | ||
50 | _gsasl_argp_parser (int key, char *arg, struct argp_state *state) | ||
51 | { | 42 | { |
52 | switch (key) | 43 | static struct mu_gsasl_module_data _default_module_data = { |
53 | { | 44 | SITE_CRAM_MD5_PWD |
54 | case ARG_CRAM_PASSWD: | 45 | }; |
55 | mu_gsasl_cram_md5_pwd = arg; | 46 | |
56 | break; | 47 | if (!data) |
57 | 48 | mu_gsasl_module_data = _default_module_data; | |
58 | default: | 49 | memcpy (&mu_gsasl_module_data, data, sizeof (mu_gsasl_module_data)); |
59 | return ARGP_ERR_UNKNOWN; | ||
60 | } | ||
61 | return 0; | 50 | return 0; |
62 | } | 51 | } |
63 | 52 | ||
64 | static struct argp _gsasl_argp = { | ||
65 | _gsasl_argp_options, | ||
66 | _gsasl_argp_parser | ||
67 | }; | ||
68 | |||
69 | static struct argp_child _gsasl_argp_child = { | ||
70 | &_gsasl_argp, | ||
71 | 0, | ||
72 | NULL, | ||
73 | 0 | ||
74 | }; | ||
75 | |||
76 | void | ||
77 | mu_gsasl_init_argp () | ||
78 | { | ||
79 | if (mu_register_capa ("gsasl", &_gsasl_argp_child, NULL)) | ||
80 | { | ||
81 | mu_error (_("INTERNAL ERROR: cannot register argp capability gsasl")); | ||
82 | abort (); | ||
83 | } | ||
84 | } | ||
85 | |||
86 | |||
87 | struct _gsasl_stream { | 53 | struct _gsasl_stream { |
88 | Gsasl_session_ctx *sess_ctx; /* Context */ | 54 | Gsasl_session_ctx *sess_ctx; /* Context */ |
89 | int last_err; /* Last Gsasl error code */ | 55 | int last_err; /* Last Gsasl error code */ | ... | ... |
... | @@ -43,11 +43,10 @@ | ... | @@ -43,11 +43,10 @@ |
43 | #include <mailutils/list.h> | 43 | #include <mailutils/list.h> |
44 | #include <mailutils/iterator.h> | 44 | #include <mailutils/iterator.h> |
45 | #include <mailutils/mailbox.h> | 45 | #include <mailutils/mailbox.h> |
46 | #include <mailutils/argp.h> | ||
47 | #include <mailutils/mu_auth.h> | 46 | #include <mailutils/mu_auth.h> |
48 | #include <mailutils/nls.h> | 47 | #include <mailutils/nls.h> |
49 | 48 | ||
50 | char *pam_service = NULL; | 49 | char *mu_pam_service = NULL; |
51 | 50 | ||
52 | #ifdef USE_LIBPAM | 51 | #ifdef USE_LIBPAM |
53 | #define COPY_STRING(s) (s) ? strdup(s) : NULL | 52 | #define COPY_STRING(s) (s) ? strdup(s) : NULL |
... | @@ -120,7 +119,7 @@ mu_authenticate_pam (struct mu_auth_data **return_data MU_ARG_UNUSED, | ... | @@ -120,7 +119,7 @@ mu_authenticate_pam (struct mu_auth_data **return_data MU_ARG_UNUSED, |
120 | 119 | ||
121 | _user = (char *) auth_data->name; | 120 | _user = (char *) auth_data->name; |
122 | _pwd = pass; | 121 | _pwd = pass; |
123 | pamerror = pam_start (pam_service, _user, &PAM_conversation, &pamh); | 122 | pamerror = pam_start (mu_pam_service, _user, &PAM_conversation, &pamh); |
124 | PAM_ERROR; | 123 | PAM_ERROR; |
125 | pamerror = pam_authenticate (pamh, 0); | 124 | pamerror = pam_authenticate (pamh, 0); |
126 | PAM_ERROR; | 125 | PAM_ERROR; |
... | @@ -132,39 +131,6 @@ mu_authenticate_pam (struct mu_auth_data **return_data MU_ARG_UNUSED, | ... | @@ -132,39 +131,6 @@ mu_authenticate_pam (struct mu_auth_data **return_data MU_ARG_UNUSED, |
132 | return pamerror != PAM_SUCCESS; | 131 | return pamerror != PAM_SUCCESS; |
133 | } | 132 | } |
134 | 133 | ||
135 | #define ARG_PAM_SERVICE 1 | ||
136 | |||
137 | static error_t | ||
138 | mu_pam_argp_parser (int key, char *arg, struct argp_state *state) | ||
139 | { | ||
140 | switch (key) | ||
141 | { | ||
142 | case ARG_PAM_SERVICE: | ||
143 | pam_service = arg; | ||
144 | break; | ||
145 | |||
146 | default: | ||
147 | return ARGP_ERR_UNKNOWN; | ||
148 | } | ||
149 | return 0; | ||
150 | } | ||
151 | |||
152 | static struct argp_option mu_pam_argp_option[] = { | ||
153 | { "pam-service", ARG_PAM_SERVICE, N_("STRING"), OPTION_HIDDEN, | ||
154 | N_("Use STRING as PAM service name"), 0}, | ||
155 | { NULL, 0, NULL, 0, NULL, 0 } | ||
156 | }; | ||
157 | |||
158 | struct argp mu_pam_argp = { | ||
159 | mu_pam_argp_option, | ||
160 | mu_pam_argp_parser, | ||
161 | }; | ||
162 | |||
163 | static struct mu_cfg_param pam_cfg_param[] = { | ||
164 | { "service", mu_cfg_string, &pam_service }, | ||
165 | { NULL } | ||
166 | }; | ||
167 | |||
168 | #else | 134 | #else |
169 | 135 | ||
170 | int | 136 | int |
... | @@ -178,16 +144,18 @@ mu_authenticate_pam (struct mu_auth_data **return_data MU_ARG_UNUSED, | ... | @@ -178,16 +144,18 @@ mu_authenticate_pam (struct mu_auth_data **return_data MU_ARG_UNUSED, |
178 | } | 144 | } |
179 | 145 | ||
180 | #endif | 146 | #endif |
181 | 147 | ||
148 | int | ||
149 | mu_pam_module_init (void *data) | ||
150 | { | ||
151 | if (data) | ||
152 | mu_pam_service = strdup (data); | ||
153 | return 0; | ||
154 | } | ||
155 | |||
182 | struct mu_auth_module mu_auth_pam_module = { | 156 | struct mu_auth_module mu_auth_pam_module = { |
183 | "pam", | 157 | "pam", |
184 | #ifdef USE_LIBPAM | 158 | mu_pam_module_init, |
185 | &mu_pam_argp, | ||
186 | pam_cfg_param, | ||
187 | #else | ||
188 | NULL, | ||
189 | NULL, | ||
190 | #endif | ||
191 | mu_authenticate_pam, | 159 | mu_authenticate_pam, |
192 | NULL, | 160 | NULL, |
193 | mu_auth_nosupport, | 161 | mu_auth_nosupport, | ... | ... |
... | @@ -34,7 +34,7 @@ | ... | @@ -34,7 +34,7 @@ |
34 | #include <mailutils/list.h> | 34 | #include <mailutils/list.h> |
35 | #include <mailutils/iterator.h> | 35 | #include <mailutils/iterator.h> |
36 | #include <mailutils/mailbox.h> | 36 | #include <mailutils/mailbox.h> |
37 | #include <mailutils/argp.h> | 37 | #include <mailutils/radius.h> |
38 | #include <mailutils/argcv.h> | 38 | #include <mailutils/argcv.h> |
39 | #include <mailutils/mu_auth.h> | 39 | #include <mailutils/mu_auth.h> |
40 | #include <mailutils/error.h> | 40 | #include <mailutils/error.h> |
... | @@ -45,39 +45,6 @@ | ... | @@ -45,39 +45,6 @@ |
45 | 45 | ||
46 | #include <radius/radius.h> | 46 | #include <radius/radius.h> |
47 | 47 | ||
48 | #define ARG_AUTH_REQUEST 256 | ||
49 | #define ARG_GETPWNAM_REQUEST 257 | ||
50 | #define ARG_GETPWUID_REQUEST 258 | ||
51 | #define ARG_RADIUS_DIR 259 | ||
52 | |||
53 | static struct argp_option mu_radius_argp_option[] = { | ||
54 | { "radius-auth-request", ARG_AUTH_REQUEST, N_("REQUEST"), OPTION_HIDDEN, | ||
55 | N_("Radius request to authenitcate the user"), 0 }, | ||
56 | { "radius-getpwnam-request", ARG_GETPWNAM_REQUEST, N_("REQUEST"), OPTION_HIDDEN, | ||
57 | N_("Radius request to retrieve a passwd entry based on username"), 0 }, | ||
58 | { "radius-getpwuid-request", ARG_GETPWUID_REQUEST, N_("REQUEST"), OPTION_HIDDEN, | ||
59 | N_("Radius request to retrieve a passwd entry based on UID"), 0 }, | ||
60 | { "radius-directory", ARG_RADIUS_DIR, N_("DIR"), OPTION_HIDDEN, | ||
61 | N_("Set path to the radius configuration directory"), 0 }, | ||
62 | { NULL } | ||
63 | }; | ||
64 | |||
65 | static char *auth_request_str; | ||
66 | static grad_avp_t *auth_request; | ||
67 | |||
68 | static char *getpwnam_request_str; | ||
69 | static grad_avp_t *getpwnam_request; | ||
70 | |||
71 | static char *getpwuid_request_str; | ||
72 | static grad_avp_t *getpwuid_request; | ||
73 | |||
74 | /* Assume radius support is needed if any of the above requests is | ||
75 | defined. Actually, all of them should be, but it is the responsibility | ||
76 | of init to check for consistency of the configuration */ | ||
77 | |||
78 | #define NEED_RADIUS_P() \ | ||
79 | (auth_request_str||getpwnam_request_str||getpwuid_request_str) | ||
80 | |||
81 | static int radius_auth_enabled; | 48 | static int radius_auth_enabled; |
82 | 49 | ||
83 | static int MU_User_Name; | 50 | static int MU_User_Name; |
... | @@ -88,13 +55,22 @@ static int MU_Dir; | ... | @@ -88,13 +55,22 @@ static int MU_Dir; |
88 | static int MU_Shell; | 55 | static int MU_Shell; |
89 | static int MU_Mailbox; | 56 | static int MU_Mailbox; |
90 | 57 | ||
91 | void | 58 | static grad_avp_t *auth_request; |
92 | get_attribute (int *pattr, char *name, struct argp_state *state) | 59 | static grad_avp_t *getpwnam_request; |
60 | static grad_avp_t *getpwuid_request; | ||
61 | |||
62 | |||
63 | int | ||
64 | get_attribute (int *pattr, char *name) | ||
93 | { | 65 | { |
94 | grad_dict_attr_t *attr = grad_attr_name_to_dict (name); | 66 | grad_dict_attr_t *attr = grad_attr_name_to_dict (name); |
95 | if (!attr) | 67 | if (!attr) |
96 | argp_error (state, _("Radius attribute %s not defined"), name); | 68 | { |
69 | mu_error (_("Radius attribute %s not defined"), name); | ||
70 | return 1; | ||
71 | } | ||
97 | *pattr = attr->value; | 72 | *pattr = attr->value; |
73 | return 0; | ||
98 | } | 74 | } |
99 | 75 | ||
100 | enum parse_state | 76 | enum parse_state |
... | @@ -106,8 +82,7 @@ enum parse_state | ... | @@ -106,8 +82,7 @@ enum parse_state |
106 | }; | 82 | }; |
107 | 83 | ||
108 | int | 84 | int |
109 | parse_pairlist (grad_avp_t **plist, const char *input, | 85 | parse_pairlist (grad_avp_t **plist, char *input) |
110 | struct argp_state *argp_state) | ||
111 | { | 86 | { |
112 | int rc; | 87 | int rc; |
113 | int i, argc; | 88 | int i, argc; |
... | @@ -121,10 +96,12 @@ parse_pairlist (grad_avp_t **plist, const char *input, | ... | @@ -121,10 +96,12 @@ parse_pairlist (grad_avp_t **plist, const char *input, |
121 | return 1; | 96 | return 1; |
122 | 97 | ||
123 | if ((rc = mu_argcv_get (input, ",", NULL, &argc, &argv))) | 98 | if ((rc = mu_argcv_get (input, ",", NULL, &argc, &argv))) |
124 | argp_error (argp_state, _("Cannot parse input `%s': %s"), | 99 | { |
125 | input, mu_strerror (rc)); | 100 | mu_error (_("Cannot parse input `%s': %s"), input, mu_strerror (rc)); |
101 | return 1; | ||
102 | } | ||
126 | 103 | ||
127 | loc.file = "<command line>"; /* FIXME */ | 104 | loc.file = "<configuration>"; /*FIXME*/ |
128 | loc.line = 0; | 105 | loc.line = 0; |
129 | 106 | ||
130 | for (i = 0, state = state_lhs; i < argc; i++) | 107 | for (i = 0, state = state_lhs; i < argc; i++) |
... | @@ -147,84 +124,81 @@ parse_pairlist (grad_avp_t **plist, const char *input, | ... | @@ -147,84 +124,81 @@ parse_pairlist (grad_avp_t **plist, const char *input, |
147 | loc.line = i; /* Just to keep track of error location */ | 124 | loc.line = i; /* Just to keep track of error location */ |
148 | pair = grad_create_pair (&loc, name, grad_operator_equal, argv[i]); | 125 | pair = grad_create_pair (&loc, name, grad_operator_equal, argv[i]); |
149 | if (!pair) | 126 | if (!pair) |
150 | argp_error (argp_state, _("cannot create radius A/V pair `%s'"), | 127 | { |
151 | name); | 128 | mu_error (_("cannot create radius A/V pair `%s'"), name); |
129 | return 1; | ||
130 | } | ||
152 | grad_avl_merge (plist, &pair); | 131 | grad_avl_merge (plist, &pair); |
153 | state = state_delim; | 132 | state = state_delim; |
154 | break; | 133 | break; |
155 | 134 | ||
156 | case state_delim: | 135 | case state_delim: |
157 | if (strcmp (argv[i], ",")) | 136 | if (strcmp (argv[i], ",")) |
158 | argp_error (argp_state, _("expected `,' but found `%s'"), argv[i]); | 137 | { |
138 | mu_error (_("expected `,' but found `%s'"), argv[i]); | ||
139 | return 1; | ||
140 | } | ||
159 | state = state_lhs; | 141 | state = state_lhs; |
160 | } | 142 | } |
161 | } | 143 | } |
162 | 144 | ||
163 | if (state != state_delim && state != state_delim) | 145 | if (state != state_delim && state != state_delim) |
164 | argp_error (argp_state, _("malformed radius A/V list")); | 146 | { |
147 | mu_error (_("malformed radius A/V list")); | ||
148 | return 1; | ||
149 | } | ||
165 | 150 | ||
166 | mu_argcv_free (argc, argv); | 151 | mu_argcv_free (argc, argv); |
167 | return 0; | 152 | return 0; |
168 | } | 153 | } |
169 | 154 | ||
170 | static void | 155 | /* Assume radius support is needed if any of the above requests is |
171 | init (struct argp_state *state) | 156 | defined. Actually, all of them should be, but it is the responsibility |
157 | of init to check for consistency of the configuration */ | ||
158 | |||
159 | #define NEED_RADIUS_P(cfg) \ | ||
160 | ((cfg) && \ | ||
161 | ((cfg)->auth_request || (cfg)->getpwnam_request || (cfg)->getpwuid_request)) | ||
162 | |||
163 | int | ||
164 | mu_radius_module_init (void *data) | ||
172 | { | 165 | { |
166 | struct mu_radius_module_data *cfg = data; | ||
167 | |||
168 | if (!NEED_RADIUS_P (cfg)) | ||
169 | return 0; | ||
170 | |||
171 | grad_config_dir = grad_estrdup (cfg->config_dir); | ||
172 | |||
173 | grad_path_init (); | 173 | grad_path_init (); |
174 | srand (time (NULL) + getpid ()); | 174 | srand (time (NULL) + getpid ()); |
175 | 175 | ||
176 | if (grad_dict_init ()) | 176 | if (grad_dict_init ()) |
177 | argp_error (state, _("Cannot read radius dictionaries")); | 177 | { |
178 | mu_error (_("Cannot read radius dictionaries")); | ||
179 | return 1; | ||
180 | } | ||
178 | 181 | ||
179 | /* Check whether mailutils attributes are defined */ | 182 | /* Check whether mailutils attributes are defined */ |
180 | get_attribute (&MU_User_Name, "MU-User-Name", state); | 183 | if (get_attribute (&MU_User_Name, "MU-User-Name") |
181 | get_attribute (&MU_UID, "MU-UID", state); | 184 | || get_attribute (&MU_UID, "MU-UID") |
182 | get_attribute (&MU_GID, "MU-GID", state); | 185 | || get_attribute (&MU_GID, "MU-GID") |
183 | get_attribute (&MU_GECOS, "MU-GECOS", state); | 186 | || get_attribute (&MU_GECOS, "MU-GECOS") |
184 | get_attribute (&MU_Dir, "MU-Dir", state); | 187 | || get_attribute (&MU_Dir, "MU-Dir") |
185 | get_attribute (&MU_Shell, "MU-Shell", state); | 188 | || get_attribute (&MU_Shell, "MU-Shell") |
186 | get_attribute (&MU_Mailbox, "MU-Mailbox", state); | 189 | || get_attribute (&MU_Mailbox, "MU-Mailbox")) |
190 | return 1; | ||
187 | 191 | ||
188 | /* Parse saved requests */ | 192 | /* Parse saved requests */ |
189 | parse_pairlist (&auth_request, auth_request_str, state); | 193 | if (parse_pairlist (&auth_request, cfg->auth_request) |
190 | parse_pairlist (&getpwnam_request, getpwnam_request_str, state); | 194 | || parse_pairlist (&getpwnam_request, cfg->getpwnam_request) |
191 | parse_pairlist (&getpwuid_request, getpwuid_request_str, state); | 195 | || parse_pairlist (&getpwuid_request, cfg->getpwuid_request)) |
196 | return 1; | ||
192 | 197 | ||
193 | radius_auth_enabled = 1; | 198 | radius_auth_enabled = 1; |
199 | return 0; | ||
194 | } | 200 | } |
195 | 201 | ||
196 | static error_t | ||
197 | mu_radius_argp_parser (int key, char *arg, struct argp_state *state) | ||
198 | { | ||
199 | switch (key) | ||
200 | { | ||
201 | case ARG_AUTH_REQUEST: | ||
202 | auth_request_str = arg; | ||
203 | break; | ||
204 | |||
205 | case ARG_GETPWNAM_REQUEST: | ||
206 | getpwnam_request_str = arg; | ||
207 | break; | ||
208 | |||
209 | case ARG_GETPWUID_REQUEST: | ||
210 | getpwuid_request_str = arg; | ||
211 | break; | ||
212 | |||
213 | case ARG_RADIUS_DIR: | ||
214 | grad_config_dir = grad_estrdup (arg); | ||
215 | break; | ||
216 | |||
217 | case ARGP_KEY_FINI: | ||
218 | if (NEED_RADIUS_P()) | ||
219 | init (state); | ||
220 | break; | ||
221 | |||
222 | default: | ||
223 | return ARGP_ERR_UNKNOWN; | ||
224 | } | ||
225 | return 0; | ||
226 | } | ||
227 | |||
228 | char * | 202 | char * |
229 | _expand_query (const char *query, const char *ustr, const char *passwd) | 203 | _expand_query (const char *query, const char *ustr, const char *passwd) |
230 | { | 204 | { |
... | @@ -320,20 +294,6 @@ _expand_query (const char *query, const char *ustr, const char *passwd) | ... | @@ -320,20 +294,6 @@ _expand_query (const char *query, const char *ustr, const char *passwd) |
320 | return res; | 294 | return res; |
321 | } | 295 | } |
322 | 296 | ||
323 | static int | ||
324 | cb_directory (mu_cfg_locus_t *locus, void *data, char *arg) | ||
325 | { | ||
326 | grad_config_dir = grad_estrdup (arg); | ||
327 | return 0; | ||
328 | } | ||
329 | |||
330 | static struct mu_cfg_param mu_radius_cfg_param[] = { | ||
331 | { "auth-request", mu_cfg_string, &auth_request_str }, | ||
332 | { "getpwnam-request", mu_cfg_string, &getpwnam_request_str }, | ||
333 | { "getpwuid-request", mu_cfg_string, &getpwuid_request_str }, | ||
334 | { "directory", mu_cfg_callback, NULL, cb_directory }, | ||
335 | { NULL } | ||
336 | }; | ||
337 | 297 | ||
338 | 298 | ||
339 | static grad_avp_t * | 299 | static grad_avp_t * |
... | @@ -577,11 +537,6 @@ mu_auth_radius_user_by_uid (struct mu_auth_data **return_data, | ... | @@ -577,11 +537,6 @@ mu_auth_radius_user_by_uid (struct mu_auth_data **return_data, |
577 | return rc; | 537 | return rc; |
578 | } | 538 | } |
579 | 539 | ||
580 | struct argp mu_radius_argp = { | ||
581 | mu_radius_argp_option, | ||
582 | mu_radius_argp_parser, | ||
583 | }; | ||
584 | |||
585 | #else | 540 | #else |
586 | static int | 541 | static int |
587 | mu_radius_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED, | 542 | 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, | ... | @@ -612,11 +567,9 @@ mu_auth_radius_user_by_uid (struct mu_auth_data **return_data, |
612 | struct mu_auth_module mu_auth_radius_module = { | 567 | struct mu_auth_module mu_auth_radius_module = { |
613 | "radius", | 568 | "radius", |
614 | #ifdef ENABLE_RADIUS | 569 | #ifdef ENABLE_RADIUS |
615 | &mu_radius_argp, | 570 | mu_radius_module_init, |
616 | mu_radius_cfg_param, | ||
617 | #else | 571 | #else |
618 | NULL, | 572 | NULL, |
619 | NULL, | ||
620 | #endif | 573 | #endif |
621 | mu_radius_authenticate, | 574 | mu_radius_authenticate, |
622 | NULL, | 575 | NULL, | ... | ... |
... | @@ -44,32 +44,18 @@ | ... | @@ -44,32 +44,18 @@ |
44 | #include <mailutils/list.h> | 44 | #include <mailutils/list.h> |
45 | #include <mailutils/iterator.h> | 45 | #include <mailutils/iterator.h> |
46 | #include <mailutils/mailbox.h> | 46 | #include <mailutils/mailbox.h> |
47 | #include <mailutils/argp.h> | 47 | #include <mailutils/sql.h> |
48 | #include <mailutils/mu_auth.h> | 48 | #include <mailutils/mu_auth.h> |
49 | #include <mailutils/error.h> | 49 | #include <mailutils/error.h> |
50 | #include <mailutils/errno.h> | 50 | #include <mailutils/errno.h> |
51 | #include <mailutils/nls.h> | 51 | #include <mailutils/nls.h> |
52 | #include <mailutils/mutil.h> | 52 | #include <mailutils/mutil.h> |
53 | #include <mailutils/sql.h> | 53 | #include <mailutils/sql.h> |
54 | #include "sql.h" | ||
54 | 55 | ||
55 | #ifdef USE_SQL | 56 | #ifdef USE_SQL |
56 | 57 | ||
57 | 58 | struct mu_internal_sql_config mu_sql_module_config; | |
58 | int sql_interface = 0; | ||
59 | char *mu_sql_getpwnam_query; | ||
60 | char *mu_sql_getpass_query; | ||
61 | char *mu_sql_getpwuid_query; | ||
62 | |||
63 | char *mu_sql_host = NULL; /* Hostname to connect to. NULL for UNIX | ||
64 | socket connection */ | ||
65 | char *mu_sql_user = "accounts"; /* Username for mysql access */ | ||
66 | char *mu_sql_passwd = "yurpass"; /* Password for mysql access */ | ||
67 | char *mu_sql_db = "accounts"; /* Database Name */ | ||
68 | int mu_sql_port = 0; /* Port number to connect to. | ||
69 | 0 means default port */ | ||
70 | enum mu_password_type mu_sql_password_type = password_hash; | ||
71 | |||
72 | static mu_assoc_t sql_field_map; | ||
73 | 59 | ||
74 | static char * | 60 | static char * |
75 | sql_escape_string (const char *ustr) | 61 | sql_escape_string (const char *ustr) |
... | @@ -175,176 +161,6 @@ mu_sql_expand_query (const char *query, const char *ustr) | ... | @@ -175,176 +161,6 @@ mu_sql_expand_query (const char *query, const char *ustr) |
175 | return res; | 161 | return res; |
176 | } | 162 | } |
177 | 163 | ||
178 | static int | ||
179 | set_sql_password_type (const char *arg) | ||
180 | { | ||
181 | if (strcmp (arg, "plain") == 0) | ||
182 | mu_sql_password_type = password_plaintext; | ||
183 | else if (strcmp (arg, "hash") == 0) | ||
184 | mu_sql_password_type = password_hash; | ||
185 | else if (strcmp (arg, "scrambled") == 0) | ||
186 | mu_sql_password_type = password_scrambled; | ||
187 | else | ||
188 | return 1; | ||
189 | return 0; | ||
190 | } | ||
191 | |||
192 | |||
193 | /* Command-line configuration */ | ||
194 | # define ARG_SQL_INTERFACE 256 | ||
195 | # define ARG_SQL_GETPWNAM 257 | ||
196 | # define ARG_SQL_GETPWUID 258 | ||
197 | # define ARG_SQL_GETPASS 259 | ||
198 | # define ARG_SQL_HOST 260 | ||
199 | # define ARG_SQL_USER 261 | ||
200 | # define ARG_SQL_PASSWD 262 | ||
201 | # define ARG_SQL_DB 263 | ||
202 | # define ARG_SQL_PORT 264 | ||
203 | # define ARG_SQL_MU_PASSWORD_TYPE 265 | ||
204 | # define ARG_SQL_FIELD_MAP 266 | ||
205 | |||
206 | static struct argp_option mu_sql_argp_option[] = { | ||
207 | {"sql-interface", ARG_SQL_INTERFACE, N_("NAME"), OPTION_HIDDEN, | ||
208 | N_("Type of SQL interface to use"), }, | ||
209 | {"sql-getpwnam", ARG_SQL_GETPWNAM, N_("QUERY"), OPTION_HIDDEN, | ||
210 | N_("SQL query to retrieve a passwd entry based on username"), 0}, | ||
211 | {"sql-getpwuid", ARG_SQL_GETPWUID, N_("QUERY"), OPTION_HIDDEN, | ||
212 | N_("SQL query to retrieve a passwd entry based on UID"), 0}, | ||
213 | {"sql-getpass", ARG_SQL_GETPASS, N_("QUERY"), OPTION_HIDDEN, | ||
214 | N_("SQL query to retrieve a password from the database"), 0}, | ||
215 | {"sql-host", ARG_SQL_HOST, N_("HOSTNAME"), OPTION_HIDDEN, | ||
216 | N_("Name or IP of MySQL server to connect to"), 0}, | ||
217 | {"sql-user", ARG_SQL_USER, N_("NAME"), OPTION_HIDDEN, | ||
218 | N_("SQL user name"), 0}, | ||
219 | {"sql-passwd", ARG_SQL_PASSWD, N_("STRING"), OPTION_HIDDEN, | ||
220 | N_("SQL connection password"), 0}, | ||
221 | {"sql-db", ARG_SQL_DB, N_("STRING"), OPTION_HIDDEN, | ||
222 | N_("Name of the database to connect to"), 0}, | ||
223 | {"sql-port", ARG_SQL_PORT, N_("NUMBER"), OPTION_HIDDEN, | ||
224 | N_("Port to use"), 0}, | ||
225 | {"sql-password-type", ARG_SQL_MU_PASSWORD_TYPE, N_("STRING"), OPTION_HIDDEN, | ||
226 | N_("Type of password returned by --sql-getpass query. STRING is one of: plain, hash, scrambled"), 0}, | ||
227 | {"sql-field-map", ARG_SQL_FIELD_MAP, N_("MAP"), OPTION_HIDDEN, | ||
228 | N_("Declare a name translation map for SQL fields in results of sql-getpwnam and " | ||
229 | "sql-getpwuid queries"), 0}, | ||
230 | { NULL, 0, NULL, 0, NULL, 0 } | ||
231 | }; | ||
232 | |||
233 | static error_t | ||
234 | mu_sql_argp_parser (int key, char *arg, struct argp_state *state) | ||
235 | { | ||
236 | int rc, err; | ||
237 | |||
238 | switch (key) | ||
239 | { | ||
240 | case ARG_SQL_INTERFACE: | ||
241 | sql_interface = mu_sql_interface_index (arg); | ||
242 | if (sql_interface == 0) | ||
243 | argp_error (state, _("Unknown SQL interface `%s'"), arg); | ||
244 | break; | ||
245 | |||
246 | case ARG_SQL_GETPWNAM: | ||
247 | mu_sql_getpwnam_query = arg; | ||
248 | break; | ||
249 | |||
250 | case ARG_SQL_GETPWUID: | ||
251 | mu_sql_getpwuid_query = arg; | ||
252 | break; | ||
253 | |||
254 | case ARG_SQL_GETPASS: | ||
255 | mu_sql_getpass_query = arg; | ||
256 | break; | ||
257 | |||
258 | case ARG_SQL_HOST: | ||
259 | mu_sql_host = arg; | ||
260 | break; | ||
261 | |||
262 | case ARG_SQL_USER: | ||
263 | mu_sql_user = arg; | ||
264 | break; | ||
265 | |||
266 | case ARG_SQL_PASSWD: | ||
267 | mu_sql_passwd = arg; | ||
268 | break; | ||
269 | |||
270 | case ARG_SQL_DB: | ||
271 | mu_sql_db = arg; | ||
272 | break; | ||
273 | |||
274 | case ARG_SQL_PORT: | ||
275 | mu_sql_port = strtoul (arg, NULL, 0); | ||
276 | break; | ||
277 | |||
278 | case ARG_SQL_MU_PASSWORD_TYPE: | ||
279 | if (set_sql_password_type (arg)) | ||
280 | argp_error (state, _("Unknown password type `%s'"), arg); | ||
281 | break; | ||
282 | |||
283 | case ARG_SQL_FIELD_MAP: | ||
284 | rc = mutil_parse_field_map (arg, &sql_field_map, &err); | ||
285 | if (rc) | ||
286 | argp_error (state, _("Error near element %d: %s"), | ||
287 | err, mu_strerror (rc)); | ||
288 | break; | ||
289 | |||
290 | default: | ||
291 | return ARGP_ERR_UNKNOWN; | ||
292 | } | ||
293 | return 0; | ||
294 | } | ||
295 | |||
296 | static struct argp mu_sql_argp = { | ||
297 | mu_sql_argp_option, | ||
298 | mu_sql_argp_parser, | ||
299 | }; | ||
300 | |||
301 | |||
302 | /* Resource file configuration */ | ||
303 | static int | ||
304 | cb_iface (mu_cfg_locus_t *locus, void *data, char *arg) | ||
305 | { | ||
306 | sql_interface = mu_sql_interface_index (arg); | ||
307 | if (sql_interface == 0) | ||
308 | mu_error (_("%s:%d: Unknown SQL interface `%s'"), | ||
309 | locus->file, locus->line, arg); | ||
310 | return 0; | ||
311 | } | ||
312 | |||
313 | static int | ||
314 | cb_password_type (mu_cfg_locus_t *locus, void *data, char *arg) | ||
315 | { | ||
316 | if (set_sql_password_type (arg)) | ||
317 | mu_error (_("%s:%d: Unknown password type `%s'"), | ||
318 | locus->file, locus->line, arg); | ||
319 | return 0; | ||
320 | } | ||
321 | |||
322 | static int | ||
323 | cb_field_map (mu_cfg_locus_t *locus, void *data, char *arg) | ||
324 | { | ||
325 | int err; | ||
326 | int rc = mutil_parse_field_map (arg, &sql_field_map, &err); | ||
327 | if (rc) | ||
328 | mu_error (_("%s:%d: Error near element %d: %s"), | ||
329 | locus->file, locus->line, err, mu_strerror (rc)); | ||
330 | return 0; | ||
331 | } | ||
332 | |||
333 | static struct mu_cfg_param mu_sql_param[] = { | ||
334 | { "interface", mu_cfg_callback, NULL, cb_iface }, | ||
335 | { "getwpnam", mu_cfg_string, &mu_sql_getpwnam_query }, | ||
336 | { "getpwuid", mu_cfg_string, &mu_sql_getpwuid_query }, | ||
337 | { "getpass", mu_cfg_string, &mu_sql_getpass_query }, | ||
338 | { "host", mu_cfg_string, &mu_sql_host }, | ||
339 | { "user", mu_cfg_string, &mu_sql_user }, | ||
340 | { "passwd", mu_cfg_string, &mu_sql_passwd }, | ||
341 | { "db", mu_cfg_string, &mu_sql_db }, | ||
342 | { "port", mu_cfg_int, &mu_sql_port }, | ||
343 | { "password-type", mu_cfg_callback, NULL, cb_password_type }, | ||
344 | { "field-map", mu_cfg_callback, NULL, cb_field_map }, | ||
345 | { NULL } | ||
346 | }; | ||
347 | |||
348 | 164 | ||
349 | static int | 165 | static int |
350 | decode_tuple_v1_0 (mu_sql_connection_t conn, int n, | 166 | 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, | ... | @@ -405,7 +221,7 @@ decode_tuple_v1_0 (mu_sql_connection_t conn, int n, |
405 | static int | 221 | static int |
406 | get_field (mu_sql_connection_t conn, const char *id, char **ret, int mandatory) | 222 | get_field (mu_sql_connection_t conn, const char *id, char **ret, int mandatory) |
407 | { | 223 | { |
408 | const char **name = mu_assoc_ref (sql_field_map, id); | 224 | const char **name = mu_assoc_ref (mu_sql_module_config.field_map, id); |
409 | int rc = mu_sql_get_field (conn, 0, name ? *name : id, ret); | 225 | int rc = mu_sql_get_field (conn, 0, name ? *name : id, ret); |
410 | if (rc) | 226 | if (rc) |
411 | { | 227 | { |
... | @@ -536,7 +352,7 @@ static int | ... | @@ -536,7 +352,7 @@ static int |
536 | decode_tuple (mu_sql_connection_t conn, int n, | 352 | decode_tuple (mu_sql_connection_t conn, int n, |
537 | struct mu_auth_data **return_data) | 353 | struct mu_auth_data **return_data) |
538 | { | 354 | { |
539 | if (sql_field_map) | 355 | if (mu_sql_module_config.field_map) |
540 | return decode_tuple_new (conn, n, return_data); | 356 | return decode_tuple_new (conn, n, return_data); |
541 | else | 357 | else |
542 | return decode_tuple_v1_0 (conn, n, return_data); | 358 | return decode_tuple_v1_0 (conn, n, return_data); |
... | @@ -556,17 +372,18 @@ mu_auth_sql_by_name (struct mu_auth_data **return_data, | ... | @@ -556,17 +372,18 @@ mu_auth_sql_by_name (struct mu_auth_data **return_data, |
556 | if (!key) | 372 | if (!key) |
557 | return EINVAL; | 373 | return EINVAL; |
558 | 374 | ||
559 | query_str = mu_sql_expand_query (mu_sql_getpwnam_query, key); | 375 | query_str = mu_sql_expand_query (mu_sql_module_config.getpwnam_query, key); |
560 | 376 | ||
561 | if (!query_str) | 377 | if (!query_str) |
562 | return MU_ERR_FAILURE; | 378 | return MU_ERR_FAILURE; |
563 | 379 | ||
564 | status = mu_sql_connection_init (&conn, | 380 | status = mu_sql_connection_init (&conn, |
565 | sql_interface, | 381 | mu_sql_module_config.interface, |
566 | mu_sql_host, | 382 | mu_sql_module_config.host, |
567 | mu_sql_port, | 383 | mu_sql_module_config.port, |
568 | mu_sql_user, mu_sql_passwd, | 384 | mu_sql_module_config.user, |
569 | mu_sql_db); | 385 | mu_sql_module_config.passwd, |
386 | mu_sql_module_config.db); | ||
570 | 387 | ||
571 | if (status) | 388 | if (status) |
572 | { | 389 | { |
... | @@ -638,17 +455,19 @@ mu_auth_sql_by_uid (struct mu_auth_data **return_data, | ... | @@ -638,17 +455,19 @@ mu_auth_sql_by_uid (struct mu_auth_data **return_data, |
638 | return EINVAL; | 455 | return EINVAL; |
639 | 456 | ||
640 | snprintf (uidstr, sizeof (uidstr), "%u", *(uid_t*)key); | 457 | snprintf (uidstr, sizeof (uidstr), "%u", *(uid_t*)key); |
641 | query_str = mu_sql_expand_query (mu_sql_getpwuid_query, uidstr); | 458 | query_str = mu_sql_expand_query (mu_sql_module_config.getpwuid_query, |
459 | uidstr); | ||
642 | 460 | ||
643 | if (!query_str) | 461 | if (!query_str) |
644 | return ENOMEM; | 462 | return ENOMEM; |
645 | 463 | ||
646 | status = mu_sql_connection_init (&conn, | 464 | status = mu_sql_connection_init (&conn, |
647 | sql_interface, | 465 | mu_sql_module_config.interface, |
648 | mu_sql_host, | 466 | mu_sql_module_config.host, |
649 | mu_sql_port, | 467 | mu_sql_module_config.port, |
650 | mu_sql_user, mu_sql_passwd, | 468 | mu_sql_module_config.user, |
651 | mu_sql_db); | 469 | mu_sql_module_config.passwd, |
470 | mu_sql_module_config.db); | ||
652 | 471 | ||
653 | if (status) | 472 | if (status) |
654 | { | 473 | { |
... | @@ -713,17 +532,18 @@ mu_sql_getpass (const char *username, char **passwd) | ... | @@ -713,17 +532,18 @@ mu_sql_getpass (const char *username, char **passwd) |
713 | int status; | 532 | int status; |
714 | char *sql_pass; | 533 | char *sql_pass; |
715 | 534 | ||
716 | query_str = mu_sql_expand_query (mu_sql_getpass_query, username); | 535 | query_str = mu_sql_expand_query (mu_sql_module_config.getpass_query, username); |
717 | 536 | ||
718 | if (!query_str) | 537 | if (!query_str) |
719 | return MU_ERR_FAILURE; | 538 | return MU_ERR_FAILURE; |
720 | 539 | ||
721 | status = mu_sql_connection_init (&conn, | 540 | status = mu_sql_connection_init (&conn, |
722 | sql_interface, | 541 | mu_sql_module_config.interface, |
723 | mu_sql_host, | 542 | mu_sql_module_config.host, |
724 | mu_sql_port, | 543 | mu_sql_module_config.port, |
725 | mu_sql_user, mu_sql_passwd, | 544 | mu_sql_module_config.user, |
726 | mu_sql_db); | 545 | mu_sql_module_config.passwd, |
546 | mu_sql_module_config.db); | ||
727 | 547 | ||
728 | if (status) | 548 | if (status) |
729 | { | 549 | { |
... | @@ -804,7 +624,7 @@ mu_sql_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED, | ... | @@ -804,7 +624,7 @@ mu_sql_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED, |
804 | if ((rc = mu_sql_getpass (auth_data->name, &sql_pass))) | 624 | if ((rc = mu_sql_getpass (auth_data->name, &sql_pass))) |
805 | return rc; | 625 | return rc; |
806 | 626 | ||
807 | switch (mu_sql_password_type) | 627 | switch (mu_sql_module_config.password_type) |
808 | { | 628 | { |
809 | case password_hash: | 629 | case password_hash: |
810 | rc = strcmp (sql_pass, crypt (pass, sql_pass)); | 630 | rc = strcmp (sql_pass, crypt (pass, sql_pass)); |
... | @@ -832,6 +652,32 @@ mu_sql_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED, | ... | @@ -832,6 +652,32 @@ mu_sql_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED, |
832 | return rc == 0 ? 0 : MU_ERR_AUTH_FAILURE; | 652 | return rc == 0 ? 0 : MU_ERR_AUTH_FAILURE; |
833 | } | 653 | } |
834 | 654 | ||
655 | int | ||
656 | mu_sql_module_init (void *data) | ||
657 | { | ||
658 | struct mu_sql_module_config *cfg = data; | ||
659 | |||
660 | mu_sql_module_config.interface = mu_sql_interface_index (cfg->interface); | ||
661 | if (mu_sql_module_config.interface == 0) | ||
662 | { | ||
663 | mu_error (_("Unknown SQL interface `%s'"), cfg->interface); | ||
664 | return 1; | ||
665 | } | ||
666 | |||
667 | mu_sql_module_config.getpwnam_query = cfg->getpwnam_query; | ||
668 | mu_sql_module_config.getpass_query = cfg->getpass_query; | ||
669 | mu_sql_module_config.getpwuid_query = cfg->getpwuid_query; | ||
670 | mu_sql_module_config.host = cfg->host; | ||
671 | mu_sql_module_config.user = cfg->user; | ||
672 | mu_sql_module_config.passwd = cfg->passwd; | ||
673 | mu_sql_module_config.db = cfg->db; | ||
674 | mu_sql_module_config.port = cfg->port; | ||
675 | mu_sql_module_config.password_type = cfg->password_type; | ||
676 | mu_sql_module_config.field_map = cfg->field_map; | ||
677 | |||
678 | return 0; | ||
679 | } | ||
680 | |||
835 | #else | 681 | #else |
836 | 682 | ||
837 | # define mu_sql_authenticate mu_auth_nosupport | 683 | # define mu_sql_authenticate mu_auth_nosupport |
... | @@ -844,11 +690,9 @@ mu_sql_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED, | ... | @@ -844,11 +690,9 @@ mu_sql_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED, |
844 | struct mu_auth_module mu_auth_sql_module = { | 690 | struct mu_auth_module mu_auth_sql_module = { |
845 | "sql", | 691 | "sql", |
846 | #ifdef USE_SQL | 692 | #ifdef USE_SQL |
847 | &mu_sql_argp, | 693 | mu_sql_module_init, |
848 | mu_sql_param, | ||
849 | #else | 694 | #else |
850 | NULL, | 695 | NULL, |
851 | NULL, | ||
852 | #endif | 696 | #endif |
853 | mu_sql_authenticate, | 697 | mu_sql_authenticate, |
854 | NULL, | 698 | NULL, | ... | ... |
... | @@ -40,15 +40,20 @@ | ... | @@ -40,15 +40,20 @@ |
40 | #include <mailutils/nls.h> | 40 | #include <mailutils/nls.h> |
41 | #include <mailutils/mailbox.h> | 41 | #include <mailutils/mailbox.h> |
42 | 42 | ||
43 | extern int sql_interface; | 43 | struct mu_internal_sql_config |
44 | extern char *mu_sql_getpwnam_query; | 44 | { |
45 | extern char *mu_sql_getpass_query; | 45 | int interface; |
46 | extern char *mu_sql_getpwuid_query; | 46 | char *getpwnam_query; |
47 | extern char *mu_sql_host; | 47 | char *getpass_query; |
48 | extern char *mu_sql_user; | 48 | char *getpwuid_query; |
49 | extern char *mu_sql_passwd; | 49 | char *host; |
50 | extern char *mu_sql_db; | 50 | char *user; |
51 | extern char *mu_sql_socket; | 51 | char *passwd; |
52 | extern int mu_sql_port; | 52 | char *db; |
53 | 53 | int port; | |
54 | enum mu_password_type password_type; | ||
55 | mu_assoc_t field_map; | ||
56 | }; | ||
57 | |||
58 | extern struct mu_internal_sql_config mu_sql_module_config; | ||
54 | 59 | ... | ... |
... | @@ -27,7 +27,6 @@ | ... | @@ -27,7 +27,6 @@ |
27 | #include <sys/stat.h> | 27 | #include <sys/stat.h> |
28 | #include <string.h> | 28 | #include <string.h> |
29 | 29 | ||
30 | #include <mailutils/argp.h> | ||
31 | #include <mailutils/error.h> | 30 | #include <mailutils/error.h> |
32 | #include <mailutils/mu_auth.h> | 31 | #include <mailutils/mu_auth.h> |
33 | #include <mailutils/tls.h> | 32 | #include <mailutils/tls.h> |
... | @@ -37,155 +36,69 @@ | ... | @@ -37,155 +36,69 @@ |
37 | 36 | ||
38 | #include <lbuf.h> | 37 | #include <lbuf.h> |
39 | 38 | ||
40 | #ifdef WITH_TLS | 39 | struct mu_tls_module_config mu_tls_module_config; |
41 | |||
42 | #include <gnutls/gnutls.h> | ||
43 | |||
44 | #define DH_BITS 768 | ||
45 | |||
46 | static gnutls_dh_params dh_params; | ||
47 | static gnutls_certificate_server_credentials x509_cred; | ||
48 | static char *ssl_cert = NULL; | ||
49 | static char *ssl_key = NULL; | ||
50 | static char *ssl_cafile = NULL; | ||
51 | |||
52 | #define ARG_TLS 1 | ||
53 | #define ARG_SSL_CERT 2 | ||
54 | #define ARG_SSL_KEY 3 | ||
55 | #define ARG_SSL_CAFILE 4 | ||
56 | |||
57 | static struct argp_option _tls_argp_options[] = { | ||
58 | {"ssl-cert", ARG_SSL_CERT, N_("FILE"), OPTION_HIDDEN, | ||
59 | N_("Specify SSL certificate file"), 0}, | ||
60 | {"ssl-key", ARG_SSL_KEY, N_("FILE"), OPTION_HIDDEN, | ||
61 | N_("Specify SSL certificate key"), }, | ||
62 | {"ssl-cafile", ARG_SSL_CAFILE, N_("FILE"), OPTION_HIDDEN, | ||
63 | N_("Specify trusted CAs file"), 0}, | ||
64 | {NULL, 0, NULL, 0, NULL, 0} | ||
65 | }; | ||
66 | |||
67 | static error_t | ||
68 | _tls_argp_parser (int key, char *arg, struct argp_state *state) | ||
69 | { | ||
70 | static int tls_enable = 1; | ||
71 | 40 | ||
72 | switch (key) | 41 | int |
42 | mu_tls_module_init (void *data) | ||
43 | { | ||
44 | if (data) | ||
73 | { | 45 | { |
74 | case ARG_TLS: | 46 | memcpy (&mu_tls_module_config, data, sizeof mu_tls_module_config); |
75 | if (!arg || strcasecmp (arg, "yes") == 0) | 47 | #ifdef WITH_TLS |
76 | tls_enable = 1; | 48 | if (mu_tls_module_config.client_enable) |
77 | else if (strcasecmp (arg, "no") == 0) | ||
78 | tls_enable = 0; | ||
79 | break; | ||
80 | |||
81 | case ARG_SSL_CERT: | ||
82 | ssl_cert = arg; | ||
83 | break; | ||
84 | |||
85 | case ARG_SSL_KEY: | ||
86 | ssl_key = arg; | ||
87 | break; | ||
88 | |||
89 | case ARG_SSL_CAFILE: | ||
90 | ssl_cafile = arg; | ||
91 | break; | ||
92 | |||
93 | case ARGP_KEY_FINI: | ||
94 | if (tls_enable) | ||
95 | mu_init_tls_libs (); | 49 | mu_init_tls_libs (); |
96 | break; | 50 | #endif |
97 | |||
98 | default: | ||
99 | return ARGP_ERR_UNKNOWN; | ||
100 | } | 51 | } |
101 | return 0; | 52 | return 0; |
102 | } | 53 | } |
103 | 54 | ||
104 | static struct argp _tls_argp = { | 55 | #ifdef WITH_TLS |
105 | _tls_argp_options, | ||
106 | _tls_argp_parser | ||
107 | }; | ||
108 | |||
109 | static struct argp_child _tls_argp_child = { | ||
110 | &_tls_argp, | ||
111 | 0, | ||
112 | NULL, | ||
113 | 0 | ||
114 | }; | ||
115 | |||
116 | void | ||
117 | mu_tls_init_argp () | ||
118 | { | ||
119 | if (mu_register_capa ("tls", &_tls_argp_child, NULL)) | ||
120 | { | ||
121 | mu_error (_("INTERNAL ERROR: cannot register argp capability tls")); | ||
122 | abort (); | ||
123 | } | ||
124 | } | ||
125 | 56 | ||
126 | static struct argp_option _tls_argp_client_options[] = { | 57 | #include <gnutls/gnutls.h> |
127 | {"tls", ARG_TLS, N_("BOOL"), OPTION_ARG_OPTIONAL, | ||
128 | N_("Enable TLS support") }, | ||
129 | {NULL, 0, NULL, 0, NULL, 0} | ||
130 | }; | ||
131 | |||
132 | static struct argp _tls_client_argp = { | ||
133 | _tls_argp_client_options, | ||
134 | _tls_argp_parser | ||
135 | }; | ||
136 | 58 | ||
137 | static struct argp_child _tls_argp_client_child = { | 59 | #define DH_BITS 768 |
138 | &_tls_client_argp, | ||
139 | 0, | ||
140 | NULL, | ||
141 | 0 | ||
142 | }; | ||
143 | 60 | ||
144 | void | 61 | static gnutls_dh_params dh_params; |
145 | mu_tls_init_client_argp () | 62 | static gnutls_certificate_server_credentials x509_cred; |
146 | { | ||
147 | if (mu_register_capa ("tls", &_tls_argp_client_child, NULL)) | ||
148 | { | ||
149 | mu_error (_("INTERNAL ERROR: cannot register argp capability tls")); | ||
150 | abort (); | ||
151 | } | ||
152 | } | ||
153 | 63 | ||
154 | int | 64 | int |
155 | mu_check_tls_environment (void) | 65 | mu_check_tls_environment (void) |
156 | { | 66 | { |
157 | /* Return: zero means NOT READY, one means READY */ | 67 | /* Return: zero means NOT READY, one means READY */ |
158 | 68 | ||
159 | if (ssl_cert && ssl_key) | 69 | if (mu_tls_module_config.ssl_cert && mu_tls_module_config.ssl_key) |
160 | { | 70 | { |
161 | struct stat st; | 71 | struct stat st; |
162 | 72 | ||
163 | if (stat (ssl_cert, &st) == -1) | 73 | if (stat (mu_tls_module_config.ssl_cert, &st) == -1) |
164 | { | 74 | { |
165 | mu_error ("%s: %s.", ssl_cert, mu_strerror (errno)); | 75 | mu_error ("%s: %s.", mu_tls_module_config.ssl_cert, |
76 | mu_strerror (errno)); | ||
166 | return 0; | 77 | return 0; |
167 | } | 78 | } |
168 | if (!(st.st_mode & S_IFREG) || !(st.st_mode & S_IFLNK)) | 79 | if (!(st.st_mode & S_IFREG) || !(st.st_mode & S_IFLNK)) |
169 | { | 80 | { |
170 | mu_error (_("%s is not a regular file or a symbolic link."), | 81 | mu_error (_("%s is not a regular file or a symbolic link."), |
171 | ssl_cert); | 82 | mu_tls_module_config.ssl_cert); |
172 | return 0; | 83 | return 0; |
173 | } | 84 | } |
174 | 85 | ||
175 | if (stat (ssl_key, &st) == -1) | 86 | if (stat (mu_tls_module_config.ssl_key, &st) == -1) |
176 | { | 87 | { |
177 | mu_error ("%s: %s.", ssl_key, mu_strerror(errno)); | 88 | mu_error ("%s: %s.", mu_tls_module_config.ssl_key, |
89 | mu_strerror(errno)); | ||
178 | return 0; | 90 | return 0; |
179 | } | 91 | } |
180 | if (!(st.st_mode & S_IFREG) || !(st.st_mode & S_IFLNK)) | 92 | if (!(st.st_mode & S_IFREG) || !(st.st_mode & S_IFLNK)) |
181 | { | 93 | { |
182 | mu_error (_("%s is not a regular file or a symbolic link."), | 94 | mu_error (_("%s is not a regular file or a symbolic link."), |
183 | ssl_key); | 95 | mu_tls_module_config.ssl_key); |
184 | return 0; | 96 | return 0; |
185 | } | 97 | } |
186 | if ((st.st_mode & S_IRWXG) || (st.st_mode & S_IRWXO)) | 98 | if ((st.st_mode & S_IRWXG) || (st.st_mode & S_IRWXO)) |
187 | { | 99 | { |
188 | mu_error (_("Wrong permissions on %s. Set 0600"), ssl_key); | 100 | mu_error (_("Wrong permissions on %s. Set 0600"), |
101 | mu_tls_module_config.ssl_key); | ||
189 | return 0; | 102 | return 0; |
190 | } | 103 | } |
191 | } | 104 | } |
... | @@ -507,12 +420,14 @@ _tls_open (mu_stream_t stream) | ... | @@ -507,12 +420,14 @@ _tls_open (mu_stream_t stream) |
507 | 420 | ||
508 | gnutls_certificate_allocate_credentials (&x509_cred); | 421 | gnutls_certificate_allocate_credentials (&x509_cred); |
509 | 422 | ||
510 | if (ssl_cafile) | 423 | if (mu_tls_module_config.ssl_cafile) |
511 | gnutls_certificate_set_x509_trust_file (x509_cred, ssl_cafile, | 424 | gnutls_certificate_set_x509_trust_file (x509_cred, |
425 | mu_tls_module_config.ssl_cafile, | ||
512 | GNUTLS_X509_FMT_PEM); | 426 | GNUTLS_X509_FMT_PEM); |
513 | 427 | ||
514 | rc = gnutls_certificate_set_x509_key_file (x509_cred, | 428 | rc = gnutls_certificate_set_x509_key_file (x509_cred, |
515 | ssl_cert, ssl_key, | 429 | mu_tls_module_config.ssl_cert, |
430 | mu_tls_module_config.ssl_key, | ||
516 | GNUTLS_X509_FMT_PEM); | 431 | GNUTLS_X509_FMT_PEM); |
517 | if (rc < 0) | 432 | if (rc < 0) |
518 | { | 433 | { |
... | @@ -561,10 +476,10 @@ prepare_client_session (struct _tls_stream *s) | ... | @@ -561,10 +476,10 @@ prepare_client_session (struct _tls_stream *s) |
561 | gnutls_mac_set_priority (s->session, mac_priority); | 476 | gnutls_mac_set_priority (s->session, mac_priority); |
562 | 477 | ||
563 | gnutls_certificate_allocate_credentials (&x509_cred); | 478 | gnutls_certificate_allocate_credentials (&x509_cred); |
564 | if (ssl_cafile) | 479 | if (mu_tls_module_config.ssl_cafile) |
565 | { | 480 | { |
566 | rc = gnutls_certificate_set_x509_trust_file (x509_cred, | 481 | rc = gnutls_certificate_set_x509_trust_file (x509_cred, |
567 | ssl_cafile, | 482 | mu_tls_module_config.ssl_cafile, |
568 | GNUTLS_X509_FMT_PEM); | 483 | GNUTLS_X509_FMT_PEM); |
569 | if (rc < 0) | 484 | if (rc < 0) |
570 | { | 485 | { |
... | @@ -737,7 +652,7 @@ mu_tls_stream_create_client (mu_stream_t *stream, | ... | @@ -737,7 +652,7 @@ mu_tls_stream_create_client (mu_stream_t *stream, |
737 | 652 | ||
738 | int | 653 | int |
739 | mu_tls_stream_create_client_from_tcp (mu_stream_t *stream, mu_stream_t tcp_str, | 654 | mu_tls_stream_create_client_from_tcp (mu_stream_t *stream, mu_stream_t tcp_str, |
740 | int flags) | 655 | int flags) |
741 | { | 656 | { |
742 | return mu_tls_stream_create_client (stream, tcp_str, tcp_str, flags); | 657 | return mu_tls_stream_create_client (stream, tcp_str, tcp_str, flags); |
743 | } | 658 | } | ... | ... |
... | @@ -49,15 +49,27 @@ | ... | @@ -49,15 +49,27 @@ |
49 | #include <mailutils/list.h> | 49 | #include <mailutils/list.h> |
50 | #include <mailutils/iterator.h> | 50 | #include <mailutils/iterator.h> |
51 | #include <mailutils/mailbox.h> | 51 | #include <mailutils/mailbox.h> |
52 | #include <mailutils/argp.h> | ||
53 | #include <mailutils/mu_auth.h> | 52 | #include <mailutils/mu_auth.h> |
54 | #include <mailutils/nls.h> | 53 | #include <mailutils/nls.h> |
55 | #include <mailutils/errno.h> | 54 | #include <mailutils/errno.h> |
56 | 55 | ||
57 | #ifdef ENABLE_VIRTUAL_DOMAINS | 56 | #ifdef ENABLE_VIRTUAL_DOMAINS |
58 | 57 | ||
58 | /* FIXME: Make global, prefix with mu_ */ | ||
59 | static char *site_virtual_pwddir = SITE_VIRTUAL_PWDDIR; | 59 | static char *site_virtual_pwddir = SITE_VIRTUAL_PWDDIR; |
60 | 60 | ||
61 | int | ||
62 | mu_virtual_module_init (void *data) | ||
63 | { | ||
64 | if (data) | ||
65 | { | ||
66 | site_virtual_pwddir = strdup (data); | ||
67 | if (!site_virtual_pwddir) | ||
68 | return 1; | ||
69 | } | ||
70 | return 0; | ||
71 | } | ||
72 | |||
61 | static struct passwd * | 73 | static struct passwd * |
62 | getpwnam_virtual (const char *u) | 74 | getpwnam_virtual (const char *u) |
63 | { | 75 | { |
... | @@ -173,34 +185,6 @@ mu_auth_virt_domain_by_name (struct mu_auth_data **return_data, | ... | @@ -173,34 +185,6 @@ mu_auth_virt_domain_by_name (struct mu_auth_data **return_data, |
173 | return rc; | 185 | return rc; |
174 | } | 186 | } |
175 | 187 | ||
176 | #define ARG_PWDDIR 1 | ||
177 | |||
178 | static error_t | ||
179 | mu_virt_argp_parser (int key, char *arg, struct argp_state *state) | ||
180 | { | ||
181 | switch (key) | ||
182 | { | ||
183 | case ARG_PWDDIR: | ||
184 | site_virtual_pwddir = arg; | ||
185 | break; | ||
186 | |||
187 | default: | ||
188 | return ARGP_ERR_UNKNOWN; | ||
189 | } | ||
190 | return 0; | ||
191 | } | ||
192 | |||
193 | static struct argp_option mu_virt_argp_option[] = { | ||
194 | { "virtual-passwd-dir", ARG_PWDDIR, N_("DIR"), OPTION_HIDDEN, | ||
195 | N_("Search for virtual passwd file in DIR"), 0}, | ||
196 | { NULL, 0, NULL, 0, NULL, 0 } | ||
197 | }; | ||
198 | |||
199 | struct argp mu_virt_argp = { | ||
200 | mu_virt_argp_option, | ||
201 | mu_virt_argp_parser, | ||
202 | }; | ||
203 | |||
204 | #else | 188 | #else |
205 | static int | 189 | static int |
206 | mu_auth_virt_domain_by_name (struct mu_auth_data **return_data MU_ARG_UNUSED, | 190 | 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, | ... | @@ -215,11 +199,9 @@ mu_auth_virt_domain_by_name (struct mu_auth_data **return_data MU_ARG_UNUSED, |
215 | struct mu_auth_module mu_auth_virtual_module = { | 199 | struct mu_auth_module mu_auth_virtual_module = { |
216 | "virtdomain", | 200 | "virtdomain", |
217 | #ifdef ENABLE_VIRTUAL_DOMAINS | 201 | #ifdef ENABLE_VIRTUAL_DOMAINS |
218 | &mu_virt_argp, | 202 | mu_virtual_module_init, |
219 | NULL, | ||
220 | #else | 203 | #else |
221 | NULL, | 204 | NULL, |
222 | NULL, | ||
223 | #endif | 205 | #endif |
224 | mu_auth_nosupport, | 206 | mu_auth_nosupport, |
225 | NULL, | 207 | NULL, | ... | ... |
... | @@ -24,7 +24,7 @@ sbin_PROGRAMS = comsatd | ... | @@ -24,7 +24,7 @@ sbin_PROGRAMS = comsatd |
24 | comsatd_SOURCES = action.c cfg.c comsat.c comsat.h | 24 | comsatd_SOURCES = action.c cfg.c comsat.c comsat.h |
25 | 25 | ||
26 | comsatd_LDADD = \ | 26 | comsatd_LDADD = \ |
27 | ../lib/libmuaux.la\ | 27 | ${MU_APP_LIBRARIES}\ |
28 | ${MU_LIB_MBOX}\ | 28 | ${MU_LIB_MBOX}\ |
29 | ${MU_LIB_IMAP}\ | 29 | ${MU_LIB_IMAP}\ |
30 | ${MU_LIB_POP}\ | 30 | ${MU_LIB_POP}\ | ... | ... |
... | @@ -18,6 +18,7 @@ | ... | @@ -18,6 +18,7 @@ |
18 | MA 02110-1301 USA */ | 18 | MA 02110-1301 USA */ |
19 | 19 | ||
20 | #include "comsat.h" | 20 | #include "comsat.h" |
21 | #include "muinit.h" | ||
21 | 22 | ||
22 | #ifndef PATH_DEV | 23 | #ifndef PATH_DEV |
23 | # define PATH_DEV "/dev" | 24 | # define PATH_DEV "/dev" |
... | @@ -90,7 +91,7 @@ static const char *comsat_argp_capa[] = { | ... | @@ -90,7 +91,7 @@ static const char *comsat_argp_capa[] = { |
90 | # define MAXHOSTNAMELEN 64 | 91 | # define MAXHOSTNAMELEN 64 |
91 | #endif | 92 | #endif |
92 | 93 | ||
93 | struct daemon_param daemon_param = { | 94 | struct mu_gocs_daemon default_gocs_daemon = { |
94 | MODE_INTERACTIVE, /* Start in interactive (inetd) mode */ | 95 | MODE_INTERACTIVE, /* Start in interactive (inetd) mode */ |
95 | 20, /* Default maximum number of children. | 96 | 20, /* Default maximum number of children. |
96 | Currently unused */ | 97 | Currently unused */ |
... | @@ -121,10 +122,6 @@ comsatd_parse_opt (int key, char *arg, struct argp_state *state) | ... | @@ -121,10 +122,6 @@ comsatd_parse_opt (int key, char *arg, struct argp_state *state) |
121 | { | 122 | { |
122 | switch (key) | 123 | switch (key) |
123 | { | 124 | { |
124 | case ARGP_KEY_INIT: | ||
125 | state->child_inputs[0] = state->input; | ||
126 | break; | ||
127 | |||
128 | case 'c': | 125 | case 'c': |
129 | config_file = arg; | 126 | config_file = arg; |
130 | break; | 127 | break; |
... | @@ -150,8 +147,9 @@ main (int argc, char **argv) | ... | @@ -150,8 +147,9 @@ main (int argc, char **argv) |
150 | mu_init_nls (); | 147 | mu_init_nls (); |
151 | 148 | ||
152 | mu_argp_init (program_version, NULL); | 149 | mu_argp_init (program_version, NULL); |
153 | mu_argp_parse (&argp, &argc, &argv, 0, comsat_argp_capa, | 150 | mu_gocs_daemon = default_gocs_daemon; |
154 | &ind, &daemon_param); | 151 | if (mu_app_init (&argp, comsat_argp_capa, NULL, argc, argv, 0, &ind, NULL)) |
152 | exit (1); | ||
155 | 153 | ||
156 | argc -= ind; | 154 | argc -= ind; |
157 | argv += ind; | 155 | argv += ind; |
... | @@ -191,7 +189,7 @@ main (int argc, char **argv) | ... | @@ -191,7 +189,7 @@ main (int argc, char **argv) |
191 | exit (0); | 189 | exit (0); |
192 | } | 190 | } |
193 | 191 | ||
194 | if (daemon_param.timeout > 0 && daemon_param.mode == MODE_DAEMON) | 192 | if (mu_gocs_daemon.timeout > 0 && mu_gocs_daemon.mode == MODE_DAEMON) |
195 | { | 193 | { |
196 | mu_error (_("--timeout and --daemon are incompatible")); | 194 | mu_error (_("--timeout and --daemon are incompatible")); |
197 | exit (EXIT_FAILURE); | 195 | exit (EXIT_FAILURE); |
... | @@ -199,7 +197,7 @@ main (int argc, char **argv) | ... | @@ -199,7 +197,7 @@ main (int argc, char **argv) |
199 | 197 | ||
200 | comsat_init (); | 198 | comsat_init (); |
201 | 199 | ||
202 | if (daemon_param.mode == MODE_DAEMON) | 200 | if (mu_gocs_daemon.mode == MODE_DAEMON) |
203 | { | 201 | { |
204 | /* Preserve invocation arguments */ | 202 | /* Preserve invocation arguments */ |
205 | xargc = argc; | 203 | xargc = argc; |
... | @@ -216,8 +214,8 @@ main (int argc, char **argv) | ... | @@ -216,8 +214,8 @@ main (int argc, char **argv) |
216 | 214 | ||
217 | chdir ("/"); | 215 | chdir ("/"); |
218 | 216 | ||
219 | if (daemon_param.mode == MODE_DAEMON) | 217 | if (mu_gocs_daemon.mode == MODE_DAEMON) |
220 | comsat_daemon (daemon_param.port); | 218 | comsat_daemon (mu_gocs_daemon.port); |
221 | else | 219 | else |
222 | c = comsat_main (0); | 220 | c = comsat_main (0); |
223 | 221 | ... | ... |
... | @@ -46,7 +46,6 @@ | ... | @@ -46,7 +46,6 @@ |
46 | # include <strings.h> | 46 | # include <strings.h> |
47 | #endif | 47 | #endif |
48 | 48 | ||
49 | #include <mailutils/argp.h> | ||
50 | #include <mailutils/body.h> | 49 | #include <mailutils/body.h> |
51 | #include <mailutils/errno.h> | 50 | #include <mailutils/errno.h> |
52 | #include <mailutils/error.h> | 51 | #include <mailutils/error.h> |
... | @@ -60,6 +59,7 @@ | ... | @@ -60,6 +59,7 @@ |
60 | #include <mailutils/mu_auth.h> | 59 | #include <mailutils/mu_auth.h> |
61 | #include <mailutils/argcv.h> | 60 | #include <mailutils/argcv.h> |
62 | #include <mailutils/nls.h> | 61 | #include <mailutils/nls.h> |
62 | #include <mailutils/daemon.h> | ||
63 | 63 | ||
64 | #ifndef INADDR_NONE | 64 | #ifndef INADDR_NONE |
65 | # define INADDR_NONE -1 | 65 | # define INADDR_NONE -1 | ... | ... |
... | @@ -23,8 +23,8 @@ bin_PROGRAMS = mailutils-config | ... | @@ -23,8 +23,8 @@ bin_PROGRAMS = mailutils-config |
23 | 23 | ||
24 | mailutils_config_SOURCES = mailutils-config.c | 24 | mailutils_config_SOURCES = mailutils-config.c |
25 | mailutils_config_LDADD = \ | 25 | mailutils_config_LDADD = \ |
26 | ../lib/libmuaux.la \ | 26 | ${MU_APP_LIBRARIES}\ |
27 | ${MU_LIB_MAILUTILS} \ | 27 | ${MU_LIB_MAILUTILS}\ |
28 | @MU_COMMON_LIBRARIES@ | 28 | @MU_COMMON_LIBRARIES@ |
29 | 29 | ||
30 | mailutils_config_CFLAGS = -DCOMPILE_FLAGS="\"-I$(includedir)\"" \ | 30 | mailutils_config_CFLAGS = -DCOMPILE_FLAGS="\"-I$(includedir)\"" \ | ... | ... |
... | @@ -21,8 +21,8 @@ | ... | @@ -21,8 +21,8 @@ |
21 | #endif | 21 | #endif |
22 | #include <string.h> | 22 | #include <string.h> |
23 | #include <mailutils/mailutils.h> | 23 | #include <mailutils/mailutils.h> |
24 | #include <mailutils/argp.h> | ||
25 | #include <mu_asprintf.h> | 24 | #include <mu_asprintf.h> |
25 | #include "muinit.h" | ||
26 | 26 | ||
27 | const char *program_version = "mailutils-config (" PACKAGE_STRING ")"; | 27 | const char *program_version = "mailutils-config (" PACKAGE_STRING ")"; |
28 | static char doc[] = N_("GNU mailutils-config -- Display compiler and loader options needed for building a program with mailutils"); | 28 | 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) | ... | @@ -166,7 +166,7 @@ main (int argc, char **argv) |
166 | int index; | 166 | int index; |
167 | 167 | ||
168 | mu_argp_init (program_version, NULL); | 168 | mu_argp_init (program_version, NULL); |
169 | if (mu_argp_parse (&argp, &argc, &argv, 0, argp_capa, &index, NULL)) | 169 | if (mu_app_init (&argp, argp_capa, NULL, argc, argv, 0, &index, NULL)) |
170 | { | 170 | { |
171 | argp_help (&argp, stdout, ARGP_HELP_SEE, program_invocation_short_name); | 171 | argp_help (&argp, stdout, ARGP_HELP_SEE, program_invocation_short_name); |
172 | return 1; | 172 | return 1; | ... | ... |
... | @@ -46,13 +46,15 @@ AC_SUBST(MU_LIB_POP,'${top_builddir}/libproto/pop/libmu_pop.la') | ... | @@ -46,13 +46,15 @@ AC_SUBST(MU_LIB_POP,'${top_builddir}/libproto/pop/libmu_pop.la') |
46 | AC_SUBST(MU_LIB_SIEVE,'${top_builddir}/libsieve/libsieve.la') | 46 | AC_SUBST(MU_LIB_SIEVE,'${top_builddir}/libsieve/libsieve.la') |
47 | AC_SUBST(MU_LIB_SCM,'${top_builddir}/libmu_scm/libmu_scm.la') | 47 | AC_SUBST(MU_LIB_SCM,'${top_builddir}/libmu_scm/libmu_scm.la') |
48 | AC_SUBST(MU_LIB_CPP,'${top_builddir}/libmu_cpp/libmu_cpp.la') | 48 | AC_SUBST(MU_LIB_CPP,'${top_builddir}/libmu_cpp/libmu_cpp.la') |
49 | AC_SUBST(MU_LIB_ARGP,'${top_builddir}/libargp/libargp.la') | ||
49 | 50 | ||
50 | dnl Other variables | 51 | dnl Other variables |
51 | AC_SUBST(SIEVE_MODDIR,'$(libdir)/$(PACKAGE)') | 52 | AC_SUBST(SIEVE_MODDIR,'$(libdir)/$(PACKAGE)') |
52 | 53 | ||
53 | AC_SUBST(MU_COMMON_LIBRARIES,'$(LTLIBINTL) $(LTLIBICONV)') | 54 | AC_SUBST(MU_COMMON_LIBRARIES,'$(LTLIBINTL) $(LTLIBICONV)') |
55 | AC_SUBST(MU_APP_LIBRARIES,'../lib/libmuaux.la ../libargp/libargp.a -L${top_builddir}/libcfg -lmucfg') | ||
54 | 56 | ||
55 | 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') | 57 | 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') |
56 | 58 | ||
57 | dnl Check for programs | 59 | dnl Check for programs |
58 | AC_PROG_CC | 60 | AC_PROG_CC |
... | @@ -1169,6 +1171,8 @@ AC_CONFIG_FILES([Makefile | ... | @@ -1169,6 +1171,8 @@ AC_CONFIG_FILES([Makefile |
1169 | libproto/include/Makefile | 1171 | libproto/include/Makefile |
1170 | libsieve/Makefile | 1172 | libsieve/Makefile |
1171 | libsieve/extensions/Makefile | 1173 | libsieve/extensions/Makefile |
1174 | libargp/Makefile | ||
1175 | libcfg/Makefile | ||
1172 | maidag/Makefile | 1176 | maidag/Makefile |
1173 | mail/Makefile | 1177 | mail/Makefile |
1174 | mail/testsuite/Makefile | 1178 | mail/testsuite/Makefile | ... | ... |
... | @@ -22,7 +22,7 @@ INCLUDES = @MU_COMMON_INCLUDES@ | ... | @@ -22,7 +22,7 @@ INCLUDES = @MU_COMMON_INCLUDES@ |
22 | bin_PROGRAMS = dotlock | 22 | bin_PROGRAMS = dotlock |
23 | 23 | ||
24 | dotlock_LDADD = \ | 24 | dotlock_LDADD = \ |
25 | ../lib/libmuaux.la\ | 25 | ${MU_APP_LIBRARIES}\ |
26 | ${MU_LIB_MAILUTILS}\ | 26 | ${MU_LIB_MAILUTILS}\ |
27 | @MU_COMMON_LIBRARIES@ | 27 | @MU_COMMON_LIBRARIES@ |
28 | 28 | ... | ... |
... | @@ -27,11 +27,12 @@ | ... | @@ -27,11 +27,12 @@ |
27 | #endif | 27 | #endif |
28 | #include <unistd.h> | 28 | #include <unistd.h> |
29 | 29 | ||
30 | #include <mailutils/argp.h> | ||
31 | #include <mailutils/errno.h> | 30 | #include <mailutils/errno.h> |
32 | #include <mailutils/locker.h> | 31 | #include <mailutils/locker.h> |
33 | #include <mailutils/nls.h> | 32 | #include <mailutils/nls.h> |
34 | 33 | ||
34 | #include "muinit.h" | ||
35 | |||
35 | const char *program_version = "GNU dotlock (" PACKAGE_STRING ")"; | 36 | const char *program_version = "GNU dotlock (" PACKAGE_STRING ")"; |
36 | static char doc[] = | 37 | static char doc[] = |
37 | N_("GNU dotlock -- lock mail spool files") | 38 | N_("GNU dotlock -- lock mail spool files") |
... | @@ -132,6 +133,7 @@ struct mu_cfg_param dotlock_cfg_param[] = { | ... | @@ -132,6 +133,7 @@ struct mu_cfg_param dotlock_cfg_param[] = { |
132 | 133 | ||
133 | const char *dotlock_capa[] = { | 134 | const char *dotlock_capa[] = { |
134 | "license", | 135 | "license", |
136 | "common", | ||
135 | NULL | 137 | NULL |
136 | }; | 138 | }; |
137 | 139 | ||
... | @@ -151,11 +153,13 @@ main (int argc, char *argv[]) | ... | @@ -151,11 +153,13 @@ main (int argc, char *argv[]) |
151 | if (setegid (usergid) < 0) | 153 | if (setegid (usergid) < 0) |
152 | return MU_DL_EX_ERROR; | 154 | return MU_DL_EX_ERROR; |
153 | 155 | ||
154 | mu_argp_init (program_version, NULL); | ||
155 | argp_err_exit_status = MU_DL_EX_ERROR; | 156 | argp_err_exit_status = MU_DL_EX_ERROR; |
157 | |||
158 | mu_argp_init (program_version, NULL); | ||
159 | if (mu_app_init (&argp, dotlock_capa, dotlock_cfg_param, | ||
160 | argc, argv, 0, NULL, NULL)) | ||
161 | exit (1); | ||
156 | 162 | ||
157 | mu_argp_set_config_param (dotlock_cfg_param); | ||
158 | mu_argp_parse (&argp, &argc, &argv, 0, dotlock_capa, NULL, NULL); | ||
159 | if (force) | 163 | if (force) |
160 | { | 164 | { |
161 | force *= 60; | 165 | force *= 60; | ... | ... |
... | @@ -125,6 +125,9 @@ lsf_LDADD = \ | ... | @@ -125,6 +125,9 @@ lsf_LDADD = \ |
125 | ${MU_LIB_MAILUTILS} | 125 | ${MU_LIB_MAILUTILS} |
126 | 126 | ||
127 | muauth_LDADD = \ | 127 | muauth_LDADD = \ |
128 | ${MU_APP_LIBRARIES}\ | ||
128 | ${MU_LIB_AUTH}\ | 129 | ${MU_LIB_AUTH}\ |
129 | @MU_AUTHLIBS@ \ | 130 | @MU_AUTHLIBS@ \ |
130 | ${MU_LIB_MAILUTILS} | 131 | ${MU_LIB_MAILUTILS} |
132 | |||
133 | muemail_LDADD = ${MU_APP_LIBRARIES} | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -25,6 +25,7 @@ | ... | @@ -25,6 +25,7 @@ |
25 | #include <ctype.h> | 25 | #include <ctype.h> |
26 | #include <string.h> | 26 | #include <string.h> |
27 | #include <mailutils/mailutils.h> | 27 | #include <mailutils/mailutils.h> |
28 | #include "muinit.h" | ||
28 | 29 | ||
29 | const char *program_version = "muauth (" PACKAGE_STRING ")"; | 30 | const char *program_version = "muauth (" PACKAGE_STRING ")"; |
30 | static char doc[] = | 31 | static char doc[] = |
... | @@ -90,7 +91,9 @@ main (int argc, char * argv []) | ... | @@ -90,7 +91,9 @@ main (int argc, char * argv []) |
90 | 91 | ||
91 | MU_AUTH_REGISTER_ALL_MODULES (); | 92 | MU_AUTH_REGISTER_ALL_MODULES (); |
92 | mu_argp_init (program_version, NULL); | 93 | mu_argp_init (program_version, NULL); |
93 | mu_argp_parse (&argp, &argc, &argv, 0, capa, &index, NULL); | 94 | if (mu_app_init (&argp, capa, NULL, argc, argv, 0, &index, NULL)) |
95 | exit (1); | ||
96 | |||
94 | if (index == argc) | 97 | if (index == argc) |
95 | { | 98 | { |
96 | mu_error ("not enough arguments, try `%s --help' for more info", | 99 | mu_error ("not enough arguments, try `%s --help' for more info", | ... | ... |
... | @@ -17,10 +17,9 @@ | ... | @@ -17,10 +17,9 @@ |
17 | MA 02110-1301 USA */ | 17 | MA 02110-1301 USA */ |
18 | 18 | ||
19 | #include <stdlib.h> | 19 | #include <stdlib.h> |
20 | #include <mailutils/mutil.h> | ||
21 | #include <mailutils/argp.h> | ||
22 | |||
23 | #include <stdio.h> | 20 | #include <stdio.h> |
21 | #include <mailutils/mutil.h> | ||
22 | #include "muinit.h" | ||
24 | 23 | ||
25 | const char *capa[] = { | 24 | const char *capa[] = { |
26 | "address", | 25 | "address", |
... | @@ -32,8 +31,8 @@ main (int argc, char *argv[]) | ... | @@ -32,8 +31,8 @@ main (int argc, char *argv[]) |
32 | { | 31 | { |
33 | int arg = 1; | 32 | int arg = 1; |
34 | 33 | ||
35 | if (mu_argp_parse (NULL, &argc, &argv, 0, capa, &arg, NULL)) | 34 | if (mu_app_init (NULL, capa, NULL, argc, argv, 0, &arg, NULL)) |
36 | abort (); | 35 | exit (1); |
37 | 36 | ||
38 | if (!argv[arg]) | 37 | if (!argv[arg]) |
39 | printf ("current user -> %s\n", mu_get_user_email (0)); | 38 | printf ("current user -> %s\n", mu_get_user_email (0)); | ... | ... |
... | @@ -30,7 +30,7 @@ frm_LDADD = $(common_ldadd) | ... | @@ -30,7 +30,7 @@ frm_LDADD = $(common_ldadd) |
30 | from_LDADD = $(common_ldadd) | 30 | from_LDADD = $(common_ldadd) |
31 | 31 | ||
32 | common_ldadd = \ | 32 | common_ldadd = \ |
33 | ../lib/libmuaux.la\ | 33 | ${MU_APP_LIBRARIES}\ |
34 | ${MU_LIB_MBOX}\ | 34 | ${MU_LIB_MBOX}\ |
35 | ${MU_LIB_IMAP}\ | 35 | ${MU_LIB_IMAP}\ |
36 | ${MU_LIB_POP}\ | 36 | ${MU_LIB_POP}\ | ... | ... |
... | @@ -218,9 +218,6 @@ static const char *frm_argp_capa[] = { | ... | @@ -218,9 +218,6 @@ static const char *frm_argp_capa[] = { |
218 | "common", | 218 | "common", |
219 | "license", | 219 | "license", |
220 | "mailbox", | 220 | "mailbox", |
221 | #ifdef WITH_TLS | ||
222 | "tls", | ||
223 | #endif | ||
224 | NULL | 221 | NULL |
225 | }; | 222 | }; |
226 | 223 | ||
... | @@ -292,7 +289,7 @@ frm (char *mailbox_name) | ... | @@ -292,7 +289,7 @@ frm (char *mailbox_name) |
292 | if (counter.new) | 289 | if (counter.new) |
293 | { | 290 | { |
294 | printf (ngettext ("%lu new message", | 291 | printf (ngettext ("%lu new message", |
295 | "%lu new messages", | 292 | "%lu new messages", |
296 | counter.new), | 293 | counter.new), |
297 | (u_long) counter.new); | 294 | (u_long) counter.new); |
298 | delim = ", "; | 295 | delim = ", "; |
... | @@ -366,12 +363,13 @@ main (int argc, char **argv) | ... | @@ -366,12 +363,13 @@ main (int argc, char **argv) |
366 | 363 | ||
367 | /* register the formats. */ | 364 | /* register the formats. */ |
368 | mu_register_all_mbox_formats (); | 365 | mu_register_all_mbox_formats (); |
369 | |||
370 | mu_argp_init (program_version, NULL); | ||
371 | #ifdef WITH_TLS | 366 | #ifdef WITH_TLS |
372 | mu_tls_init_client_argp (); | 367 | mu_gocs_register ("tls", mu_tls_module_init); |
373 | #endif | 368 | #endif |
374 | mu_argp_parse (&argp, &argc, &argv, 0, frm_argp_capa, &c, NULL); | 369 | |
370 | mu_argp_init (program_version, NULL); | ||
371 | if (mu_app_init (&argp, frm_argp_capa, NULL, argc, argv, 0, &c, NULL)) | ||
372 | exit (1); | ||
375 | 373 | ||
376 | /* have an argument */ | 374 | /* have an argument */ |
377 | if (c == argc) | 375 | if (c == argc) | ... | ... |
... | @@ -47,7 +47,6 @@ | ... | @@ -47,7 +47,6 @@ |
47 | #endif | 47 | #endif |
48 | 48 | ||
49 | #include <mailutils/address.h> | 49 | #include <mailutils/address.h> |
50 | #include <mailutils/argp.h> | ||
51 | #include <mailutils/attribute.h> | 50 | #include <mailutils/attribute.h> |
52 | #include <mailutils/debug.h> | 51 | #include <mailutils/debug.h> |
53 | #include <mailutils/errno.h> | 52 | #include <mailutils/errno.h> |
... | @@ -65,6 +64,8 @@ | ... | @@ -65,6 +64,8 @@ |
65 | #include <mailutils/mutil.h> | 64 | #include <mailutils/mutil.h> |
66 | #include <mailutils/mime.h> | 65 | #include <mailutils/mime.h> |
67 | 66 | ||
67 | #include "muinit.h" | ||
68 | |||
68 | typedef int (*frm_select_t) (size_t index, mu_message_t msg); | 69 | typedef int (*frm_select_t) (size_t index, mu_message_t msg); |
69 | 70 | ||
70 | extern char *show_field; /* Show this header field instead of the default | 71 | extern char *show_field; /* Show this header field instead of the default | ... | ... |
... | @@ -118,10 +118,8 @@ main (int argc, char **argv) | ... | @@ -118,10 +118,8 @@ main (int argc, char **argv) |
118 | mu_register_all_mbox_formats (); | 118 | mu_register_all_mbox_formats (); |
119 | 119 | ||
120 | mu_argp_init (program_version, NULL); | 120 | mu_argp_init (program_version, NULL); |
121 | #ifdef WITH_TLS | 121 | if (mu_app_init (&argp, capa, NULL, argc, argv, 0, &c, NULL)) |
122 | mu_tls_init_client_argp (); | 122 | exit (1); |
123 | #endif | ||
124 | mu_argp_parse (&argp, &argc, &argv, 0, capa, &c, NULL); | ||
125 | 123 | ||
126 | if (argc - c > 1) | 124 | if (argc - c > 1) |
127 | { | 125 | { | ... | ... |
... | @@ -25,7 +25,7 @@ bin_PROGRAMS=@GUIMB@ | ... | @@ -25,7 +25,7 @@ bin_PROGRAMS=@GUIMB@ |
25 | EXTRA_PROGRAMS=guimb | 25 | EXTRA_PROGRAMS=guimb |
26 | guimb_SOURCES=main.c collect.c util.c guimb.h | 26 | guimb_SOURCES=main.c collect.c util.c guimb.h |
27 | guimb_LDADD = \ | 27 | guimb_LDADD = \ |
28 | ../lib/libmuaux.la\ | 28 | ${MU_APP_LIBRARIES}\ |
29 | ../libmu_scm/libmu_scm.la\ | 29 | ../libmu_scm/libmu_scm.la\ |
30 | ${MU_LIB_MBOX}\ | 30 | ${MU_LIB_MBOX}\ |
31 | ${MU_LIB_IMAP}\ | 31 | ${MU_LIB_IMAP}\ | ... | ... |
... | @@ -41,7 +41,6 @@ | ... | @@ -41,7 +41,6 @@ |
41 | #include <mailutils/stream.h> | 41 | #include <mailutils/stream.h> |
42 | #include <mailutils/guile.h> | 42 | #include <mailutils/guile.h> |
43 | #include <mailutils/nls.h> | 43 | #include <mailutils/nls.h> |
44 | #include <mailutils/argp.h> | ||
45 | #include <mailutils/list.h> | 44 | #include <mailutils/list.h> |
46 | #include <mailutils/mutil.h> | 45 | #include <mailutils/mutil.h> |
47 | #include <mailutils/attribute.h> | 46 | #include <mailutils/attribute.h> | ... | ... |
... | @@ -18,6 +18,7 @@ | ... | @@ -18,6 +18,7 @@ |
18 | MA 02110-1301 USA */ | 18 | MA 02110-1301 USA */ |
19 | 19 | ||
20 | #include "guimb.h" | 20 | #include "guimb.h" |
21 | #include "muinit.h" | ||
21 | 22 | ||
22 | char *program_file; | 23 | char *program_file; |
23 | char *program_expr; | 24 | char *program_expr; |
... | @@ -155,8 +156,10 @@ main (int argc, char *argv[]) | ... | @@ -155,8 +156,10 @@ main (int argc, char *argv[]) |
155 | mu_init_nls (); | 156 | mu_init_nls (); |
156 | 157 | ||
157 | append_arg (""); | 158 | append_arg (""); |
159 | |||
158 | mu_argp_init (program_version, NULL); | 160 | mu_argp_init (program_version, NULL); |
159 | mu_argp_parse (&argp, &argc, &argv, 0, guimb_argp_capa, &index, &c); | 161 | if (mu_app_init (&argp, guimb_argp_capa, NULL, argc, argv, 0, &index, &c)) |
162 | exit (1); | ||
160 | 163 | ||
161 | for (; c < argc; c++) | 164 | for (; c < argc; c++) |
162 | append_arg (argv[c]); | 165 | append_arg (argv[c]); | ... | ... |
... | @@ -62,7 +62,7 @@ imap4d_SOURCES = \ | ... | @@ -62,7 +62,7 @@ imap4d_SOURCES = \ |
62 | 62 | ||
63 | imap4d_LDADD = \ | 63 | imap4d_LDADD = \ |
64 | @IMAP_AUTHOBJS@\ | 64 | @IMAP_AUTHOBJS@\ |
65 | ../lib/libmuaux.la\ | 65 | ${MU_APP_LIBRARIES}\ |
66 | ${MU_LIB_MBOX}\ | 66 | ${MU_LIB_MBOX}\ |
67 | ${MU_LIB_MH}\ | 67 | ${MU_LIB_MH}\ |
68 | ${MU_LIB_MAILDIR}\ | 68 | ${MU_LIB_MAILDIR}\ | ... | ... |
... | @@ -49,7 +49,7 @@ imap4d_idle (struct imap4d_command *command, char *arg) | ... | @@ -49,7 +49,7 @@ imap4d_idle (struct imap4d_command *command, char *arg) |
49 | if (rc) | 49 | if (rc) |
50 | break; | 50 | break; |
51 | } | 51 | } |
52 | else if (time (NULL) - start > daemon_param.timeout) | 52 | else if (time (NULL) - start > mu_gocs_daemon.timeout) |
53 | imap4d_bye (ERR_TIMEOUT); | 53 | imap4d_bye (ERR_TIMEOUT); |
54 | 54 | ||
55 | imap4d_sync (); | 55 | imap4d_sync (); | ... | ... |
... | @@ -21,6 +21,7 @@ | ... | @@ -21,6 +21,7 @@ |
21 | #ifdef WITH_GSASL | 21 | #ifdef WITH_GSASL |
22 | # include <mailutils/gsasl.h> | 22 | # include <mailutils/gsasl.h> |
23 | #endif | 23 | #endif |
24 | #include "muinit.h" | ||
24 | 25 | ||
25 | mu_mailbox_t mbox; | 26 | mu_mailbox_t mbox; |
26 | char *homedir; | 27 | char *homedir; |
... | @@ -28,7 +29,7 @@ int state = STATE_NONAUTH; | ... | @@ -28,7 +29,7 @@ int state = STATE_NONAUTH; |
28 | int debug_mode = 0; | 29 | int debug_mode = 0; |
29 | struct mu_auth_data *auth_data; | 30 | struct mu_auth_data *auth_data; |
30 | 31 | ||
31 | struct daemon_param daemon_param = { | 32 | struct mu_gocs_daemon default_gocs_daemon = { |
32 | MODE_INTERACTIVE, /* Start in interactive (inetd) mode */ | 33 | MODE_INTERACTIVE, /* Start in interactive (inetd) mode */ |
33 | 20, /* Default maximum number of children */ | 34 | 20, /* Default maximum number of children */ |
34 | 143, /* Standard IMAP4 port */ | 35 | 143, /* Standard IMAP4 port */ |
... | @@ -87,12 +88,6 @@ static struct argp argp = { | ... | @@ -87,12 +88,6 @@ static struct argp argp = { |
87 | static const char *imap4d_capa[] = { | 88 | static const char *imap4d_capa[] = { |
88 | "daemon", | 89 | "daemon", |
89 | "auth", | 90 | "auth", |
90 | #ifdef WITH_TLS | ||
91 | "tls", | ||
92 | #endif /* WITH_TLS */ | ||
93 | #ifdef WITH_GSASL | ||
94 | "gsasl", | ||
95 | #endif | ||
96 | "common", | 91 | "common", |
97 | "mailbox", | 92 | "mailbox", |
98 | "logging", | 93 | "logging", |
... | @@ -196,16 +191,17 @@ main (int argc, char **argv) | ... | @@ -196,16 +191,17 @@ main (int argc, char **argv) |
196 | 191 | ||
197 | MU_AUTH_REGISTER_ALL_MODULES (); | 192 | MU_AUTH_REGISTER_ALL_MODULES (); |
198 | imap4d_capability_init (); | 193 | imap4d_capability_init (); |
199 | 194 | mu_gocs_daemon = default_gocs_daemon; | |
200 | mu_argp_init (program_version, NULL); | ||
201 | #ifdef WITH_TLS | 195 | #ifdef WITH_TLS |
202 | mu_tls_init_argp (); | 196 | mu_gocs_register ("tls", mu_tls_module_init); |
203 | #endif /* WITH_TLS */ | 197 | #endif /* WITH_TLS */ |
204 | #ifdef WITH_GSASL | 198 | #ifdef WITH_GSASL |
205 | mu_gsasl_init_argp (); | 199 | mu_gocs_register ("gsasl", mu_gsasl_module_init); |
206 | #endif | 200 | #endif |
207 | mu_argp_set_config_param (imap4d_cfg_param); | 201 | mu_argp_init (program_version, NULL); |
208 | mu_argp_parse (&argp, &argc, &argv, 0, imap4d_capa, NULL, &daemon_param); | 202 | if (mu_app_init (&argp, imap4d_capa, imap4d_cfg_param, |
203 | argc, argv, 0, NULL, NULL)) | ||
204 | exit (1); | ||
209 | 205 | ||
210 | if (login_disabled) | 206 | if (login_disabled) |
211 | imap4d_capability_add (IMAP_CAPA_LOGINDISABLED); | 207 | imap4d_capability_add (IMAP_CAPA_LOGINDISABLED); |
... | @@ -218,11 +214,11 @@ main (int argc, char **argv) | ... | @@ -218,11 +214,11 @@ main (int argc, char **argv) |
218 | auth_gsasl_init (); | 214 | auth_gsasl_init (); |
219 | 215 | ||
220 | #ifdef USE_LIBPAM | 216 | #ifdef USE_LIBPAM |
221 | if (!pam_service) | 217 | if (!mu_pam_service) |
222 | pam_service = "gnu-imap4d"; | 218 | mu_pam_service = "gnu-imap4d"; |
223 | #endif | 219 | #endif |
224 | 220 | ||
225 | if (daemon_param.mode == MODE_INTERACTIVE && isatty (0)) | 221 | if (mu_gocs_daemon.mode == MODE_INTERACTIVE && isatty (0)) |
226 | { | 222 | { |
227 | /* If input is a tty, switch to debug mode */ | 223 | /* If input is a tty, switch to debug mode */ |
228 | debug_mode = 1; | 224 | debug_mode = 1; |
... | @@ -261,7 +257,7 @@ main (int argc, char **argv) | ... | @@ -261,7 +257,7 @@ main (int argc, char **argv) |
261 | /*signal (SIGPIPE, SIG_IGN); */ | 257 | /*signal (SIGPIPE, SIG_IGN); */ |
262 | signal (SIGABRT, imap4d_signal); | 258 | signal (SIGABRT, imap4d_signal); |
263 | 259 | ||
264 | if (daemon_param.mode == MODE_DAEMON) | 260 | if (mu_gocs_daemon.mode == MODE_DAEMON) |
265 | imap4d_daemon_init (); | 261 | imap4d_daemon_init (); |
266 | else | 262 | else |
267 | { | 263 | { |
... | @@ -278,9 +274,9 @@ main (int argc, char **argv) | ... | @@ -278,9 +274,9 @@ main (int argc, char **argv) |
278 | 274 | ||
279 | umask (S_IROTH | S_IWOTH | S_IXOTH); /* 007 */ | 275 | umask (S_IROTH | S_IWOTH | S_IXOTH); /* 007 */ |
280 | 276 | ||
281 | if (daemon_param.pidfile) | 277 | if (mu_gocs_daemon.pidfile) |
282 | { | 278 | { |
283 | mu_daemon_create_pidfile (daemon_param.pidfile); | 279 | mu_daemon_create_pidfile (mu_gocs_daemon.pidfile); |
284 | } | 280 | } |
285 | 281 | ||
286 | /* Check TLS environment, i.e. cert and key files */ | 282 | /* Check TLS environment, i.e. cert and key files */ |
... | @@ -289,8 +285,8 @@ main (int argc, char **argv) | ... | @@ -289,8 +285,8 @@ main (int argc, char **argv) |
289 | #endif /* WITH_TLS */ | 285 | #endif /* WITH_TLS */ |
290 | 286 | ||
291 | /* Actually run the daemon. */ | 287 | /* Actually run the daemon. */ |
292 | if (daemon_param.mode == MODE_DAEMON) | 288 | if (mu_gocs_daemon.mode == MODE_DAEMON) |
293 | imap4d_daemon (daemon_param.maxchildren, daemon_param.port); | 289 | imap4d_daemon (mu_gocs_daemon.maxchildren, mu_gocs_daemon.port); |
294 | /* exit (0) -- no way out of daemon except a signal. */ | 290 | /* exit (0) -- no way out of daemon except a signal. */ |
295 | else | 291 | else |
296 | status = imap4d_mainloop (fileno (stdin), stdin, stdout); | 292 | status = imap4d_mainloop (fileno (stdin), stdin, stdout); | ... | ... |
... | @@ -71,7 +71,6 @@ | ... | @@ -71,7 +71,6 @@ |
71 | #endif | 71 | #endif |
72 | 72 | ||
73 | #include <mailutils/address.h> | 73 | #include <mailutils/address.h> |
74 | #include <mailutils/argp.h> | ||
75 | #include <mailutils/attribute.h> | 74 | #include <mailutils/attribute.h> |
76 | #include <mailutils/body.h> | 75 | #include <mailutils/body.h> |
77 | #include <mailutils/daemon.h> | 76 | #include <mailutils/daemon.h> |
... | @@ -93,6 +92,8 @@ | ... | @@ -93,6 +92,8 @@ |
93 | #include <mailutils/stream.h> | 92 | #include <mailutils/stream.h> |
94 | #include <mailutils/tls.h> | 93 | #include <mailutils/tls.h> |
95 | #include <mailutils/url.h> | 94 | #include <mailutils/url.h> |
95 | #include <mailutils/daemon.h> | ||
96 | #include <mailutils/pam.h> | ||
96 | 97 | ||
97 | #include <mu_asprintf.h> | 98 | #include <mu_asprintf.h> |
98 | #include <mu_umaxtostr.h> | 99 | #include <mu_umaxtostr.h> |
... | @@ -161,9 +162,9 @@ extern char *rootdir; | ... | @@ -161,9 +162,9 @@ extern char *rootdir; |
161 | extern int state; | 162 | extern int state; |
162 | extern size_t children; | 163 | extern size_t children; |
163 | extern int is_virtual; | 164 | extern int is_virtual; |
164 | extern struct daemon_param daemon_param; | ||
165 | extern struct mu_auth_data *auth_data; | 165 | extern struct mu_auth_data *auth_data; |
166 | 166 | extern const char *program_version; | |
167 | |||
167 | extern int login_disabled; | 168 | extern int login_disabled; |
168 | extern int tls_required; | 169 | extern int tls_required; |
169 | 170 | ... | ... |
... | @@ -360,7 +360,7 @@ util_send (const char *format, ...) | ... | @@ -360,7 +360,7 @@ util_send (const char *format, ...) |
360 | if (!buf) | 360 | if (!buf) |
361 | imap4d_bye (ERR_NO_MEM); | 361 | imap4d_bye (ERR_NO_MEM); |
362 | 362 | ||
363 | if (daemon_param.transcript) | 363 | if (mu_gocs_daemon.transcript) |
364 | syslog (LOG_DEBUG, "sent: %s", buf); | 364 | syslog (LOG_DEBUG, "sent: %s", buf); |
365 | 365 | ||
366 | status = mu_stream_sequential_write (ostream, buf, strlen (buf)); | 366 | status = mu_stream_sequential_write (ostream, buf, strlen (buf)); |
... | @@ -414,7 +414,7 @@ util_out (int rc, const char *format, ...) | ... | @@ -414,7 +414,7 @@ util_out (int rc, const char *format, ...) |
414 | if (!buf) | 414 | if (!buf) |
415 | imap4d_bye (ERR_NO_MEM); | 415 | imap4d_bye (ERR_NO_MEM); |
416 | 416 | ||
417 | if (daemon_param.transcript) | 417 | if (mu_gocs_daemon.transcript) |
418 | syslog (LOG_DEBUG, "sent: %s", buf); | 418 | syslog (LOG_DEBUG, "sent: %s", buf); |
419 | 419 | ||
420 | status = mu_stream_sequential_write (ostream, buf, strlen (buf)); | 420 | status = mu_stream_sequential_write (ostream, buf, strlen (buf)); |
... | @@ -455,7 +455,7 @@ util_finish (struct imap4d_command *command, int rc, const char *format, ...) | ... | @@ -455,7 +455,7 @@ util_finish (struct imap4d_command *command, int rc, const char *format, ...) |
455 | strcat (buf, tempbuf); | 455 | strcat (buf, tempbuf); |
456 | free (tempbuf); | 456 | free (tempbuf); |
457 | 457 | ||
458 | if (daemon_param.transcript) | 458 | if (mu_gocs_daemon.transcript) |
459 | syslog (LOG_DEBUG, "sent: %s\r\n", buf); | 459 | syslog (LOG_DEBUG, "sent: %s\r\n", buf); |
460 | 460 | ||
461 | mu_stream_sequential_write (ostream, buf, strlen (buf)); | 461 | mu_stream_sequential_write (ostream, buf, strlen (buf)); |
... | @@ -503,7 +503,7 @@ imap4d_readline (void) | ... | @@ -503,7 +503,7 @@ imap4d_readline (void) |
503 | size_t sz; | 503 | size_t sz; |
504 | int rc; | 504 | int rc; |
505 | 505 | ||
506 | alarm (daemon_param.timeout); | 506 | alarm (mu_gocs_daemon.timeout); |
507 | rc = mu_stream_sequential_readline (istream, buffer, sizeof (buffer), &sz); | 507 | rc = mu_stream_sequential_readline (istream, buffer, sizeof (buffer), &sz); |
508 | if (sz == 0) | 508 | if (sz == 0) |
509 | { | 509 | { |
... | @@ -577,7 +577,7 @@ imap4d_readline (void) | ... | @@ -577,7 +577,7 @@ imap4d_readline (void) |
577 | } | 577 | } |
578 | } | 578 | } |
579 | while (number > 0 || (total && line[total - 1] != '\n')); | 579 | while (number > 0 || (total && line[total - 1] != '\n')); |
580 | if (daemon_param.transcript) | 580 | if (mu_gocs_daemon.transcript) |
581 | syslog (LOG_DEBUG, "recv: %s", line); | 581 | syslog (LOG_DEBUG, "recv: %s", line); |
582 | return line; | 582 | return line; |
583 | } | 583 | } | ... | ... |
... | @@ -21,6 +21,6 @@ | ... | @@ -21,6 +21,6 @@ |
21 | int | 21 | int |
22 | imap4d_version (struct imap4d_command *command, char *arg) | 22 | imap4d_version (struct imap4d_command *command, char *arg) |
23 | { | 23 | { |
24 | util_send ("* %s GNU %s\r\n", command->name, argp_program_version); | 24 | util_send ("* %s GNU %s\r\n", command->name, program_version); |
25 | return util_finish (command, RESP_OK, "Completed"); | 25 | return util_finish (command, RESP_OK, "Completed"); |
26 | } | 26 | } | ... | ... |
... | @@ -29,53 +29,56 @@ DISTCLEANFILES = types.h | ... | @@ -29,53 +29,56 @@ DISTCLEANFILES = types.h |
29 | 29 | ||
30 | pkginclude_DATA = types.h | 30 | pkginclude_DATA = types.h |
31 | pkginclude_HEADERS = \ | 31 | pkginclude_HEADERS = \ |
32 | address.h \ | 32 | address.h\ |
33 | argcv.h \ | 33 | argcv.h\ |
34 | argp.h \ | 34 | assoc.h\ |
35 | assoc.h \ | 35 | attribute.h\ |
36 | attribute.h \ | 36 | auth.h\ |
37 | auth.h \ | 37 | body.h\ |
38 | body.h \ | 38 | cfg.h\ |
39 | cfg.h \ | 39 | compat.h\ |
40 | compat.h \ | 40 | daemon.h\ |
41 | daemon.h \ | 41 | debug.h\ |
42 | debug.h \ | 42 | envelope.h\ |
43 | envelope.h \ | 43 | errno.h\ |
44 | errno.h \ | 44 | error.h\ |
45 | error.h \ | 45 | filter.h\ |
46 | filter.h \ | 46 | folder.h\ |
47 | folder.h \ | 47 | gocs.h\ |
48 | gsasl.h \ | 48 | gsasl.h\ |
49 | guile.h \ | 49 | guile.h\ |
50 | header.h \ | 50 | header.h\ |
51 | iterator.h \ | 51 | iterator.h\ |
52 | libsieve.h \ | 52 | libsieve.h\ |
53 | list.h \ | 53 | list.h\ |
54 | locker.h \ | 54 | locker.h\ |
55 | mailbox.h \ | 55 | mailbox.h\ |
56 | mailcap.h \ | 56 | mailcap.h\ |
57 | mailer.h \ | 57 | mailer.h\ |
58 | mailutils.h \ | 58 | mailutils.h\ |
59 | message.h \ | 59 | message.h\ |
60 | mime.h \ | 60 | mime.h\ |
61 | monitor.h \ | 61 | monitor.h\ |
62 | mu_auth.h \ | 62 | mu_auth.h\ |
63 | mutil.h \ | 63 | mutil.h\ |
64 | nls.h \ | 64 | nls.h\ |
65 | nntp.h \ | 65 | nntp.h\ |
66 | observer.h \ | 66 | observer.h\ |
67 | parse822.h \ | 67 | pam.h\ |
68 | pop3.h \ | 68 | parse822.h\ |
69 | property.h \ | 69 | pop3.h\ |
70 | refcount.h \ | 70 | property.h\ |
71 | registrar.h \ | 71 | radius.h\ |
72 | stream.h \ | 72 | refcount.h\ |
73 | sql.h \ | 73 | registrar.h\ |
74 | tls.h \ | 74 | stream.h\ |
75 | syslog.h\ | ||
76 | sql.h\ | ||
77 | tls.h\ | ||
75 | url.h | 78 | url.h |
76 | 79 | ||
77 | nobase_pkginclude_HEADERS = \ | 80 | nobase_pkginclude_HEADERS = \ |
78 | sys/nntp.h \ | 81 | sys/nntp.h\ |
79 | sys/pop3.h | 82 | sys/pop3.h |
80 | SUBDIRS = gnu sys | 83 | SUBDIRS = gnu sys |
81 | 84 | ... | ... |
... | @@ -18,6 +18,7 @@ | ... | @@ -18,6 +18,7 @@ |
18 | #ifndef _MAILUTILS_CFG_H | 18 | #ifndef _MAILUTILS_CFG_H |
19 | #define _MAILUTILS_CFG_H | 19 | #define _MAILUTILS_CFG_H |
20 | 20 | ||
21 | #include <mailutils/list.h> | ||
21 | #include <sys/socket.h> | 22 | #include <sys/socket.h> |
22 | #include <netinet/in.h> | 23 | #include <netinet/in.h> |
23 | #include <arpa/inet.h> | 24 | #include <arpa/inet.h> |
... | @@ -186,4 +187,6 @@ int mu_config_register_plain_section (const char *parent_path, | ... | @@ -186,4 +187,6 @@ int mu_config_register_plain_section (const char *parent_path, |
186 | int mu_parse_config (char *file, char *progname, | 187 | int mu_parse_config (char *file, char *progname, |
187 | struct mu_cfg_param *progparam, int global); | 188 | struct mu_cfg_param *progparam, int global); |
188 | 189 | ||
190 | int mu_cfg_parse_boolean (const char *str, int *res); | ||
191 | |||
189 | #endif | 192 | #endif | ... | ... |
... | @@ -20,14 +20,21 @@ | ... | @@ -20,14 +20,21 @@ |
20 | #define _MAILUTILS_DAEMON_H | 20 | #define _MAILUTILS_DAEMON_H |
21 | 21 | ||
22 | #include <mailutils/types.h> | 22 | #include <mailutils/types.h> |
23 | #include <mailutils/gocs.h> | ||
23 | 24 | ||
24 | #ifdef __cplusplus | 25 | #ifdef __cplusplus |
25 | extern "C" { | 26 | extern "C" { |
26 | #endif | 27 | #endif |
27 | 28 | ||
29 | /* FIXME: Namespace */ | ||
30 | #define MODE_INTERACTIVE 0 | ||
31 | #define MODE_DAEMON 1 | ||
32 | |||
28 | extern int mu_daemon_create_pidfile (const char *); | 33 | extern int mu_daemon_create_pidfile (const char *); |
29 | extern void mu_daemon_remove_pidfile (void); | 34 | extern void mu_daemon_remove_pidfile (void); |
30 | 35 | ||
36 | extern struct mu_gocs_daemon mu_gocs_daemon; | ||
37 | |||
31 | #ifdef __cplusplus | 38 | #ifdef __cplusplus |
32 | } | 39 | } |
33 | #endif | 40 | #endif | ... | ... |
... | @@ -29,6 +29,9 @@ extern "C" { | ... | @@ -29,6 +29,9 @@ extern "C" { |
29 | 29 | ||
30 | typedef int (*mu_error_pfn_t) (const char *fmt, va_list ap); | 30 | typedef int (*mu_error_pfn_t) (const char *fmt, va_list ap); |
31 | 31 | ||
32 | extern const char *mu_program_name; | ||
33 | extern void mu_set_program_name (const char *name); | ||
34 | |||
32 | extern int mu_verror (const char *fmt, va_list ap); | 35 | extern int mu_verror (const char *fmt, va_list ap); |
33 | extern int mu_error (const char *fmt, ...) MU_PRINTFLIKE(1,2); | 36 | extern int mu_error (const char *fmt, ...) MU_PRINTFLIKE(1,2); |
34 | extern void mu_error_set_print (mu_error_pfn_t); | 37 | extern void mu_error_set_print (mu_error_pfn_t); | ... | ... |
include/mailutils/gocs.h
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 3 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General | ||
15 | Public License along with this library; if not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | Boston, MA 02110-1301 USA */ | ||
18 | |||
19 | #ifndef _MAILUTILS_GOCS_H | ||
20 | #define _MAILUTILS_GOCS_H | ||
21 | |||
22 | #include <mailutils/types.h> | ||
23 | #include <mailutils/list.h> | ||
24 | |||
25 | #ifdef __cplusplus | ||
26 | extern "C" { | ||
27 | #endif | ||
28 | |||
29 | struct mu_gocs_daemon | ||
30 | { | ||
31 | int mode; | ||
32 | size_t maxchildren; | ||
33 | unsigned int port; | ||
34 | unsigned int timeout; | ||
35 | int transcript; | ||
36 | char *pidfile; | ||
37 | }; | ||
38 | |||
39 | struct mu_gocs_logging | ||
40 | { | ||
41 | int facility; | ||
42 | char *tag; | ||
43 | }; | ||
44 | |||
45 | struct mu_gocs_mailbox | ||
46 | { | ||
47 | char *mail_spool; | ||
48 | char *mailbox_type; | ||
49 | }; | ||
50 | |||
51 | struct mu_gocs_locking | ||
52 | { | ||
53 | char *lock_flags; | ||
54 | unsigned long lock_retry_timeout; | ||
55 | unsigned long lock_retry_count; | ||
56 | unsigned long lock_expire_timeout; | ||
57 | char *external_locker; | ||
58 | }; | ||
59 | |||
60 | struct mu_gocs_source_email | ||
61 | { | ||
62 | char *address; | ||
63 | char *domain; | ||
64 | }; | ||
65 | |||
66 | struct mu_gocs_mailer | ||
67 | { | ||
68 | char *mailer; | ||
69 | }; | ||
70 | |||
71 | /* Auxiliary variables for use by libargp/libcfg */ | ||
72 | extern int mu_load_user_rcfile; | ||
73 | extern int mu_load_site_rcfile; | ||
74 | extern char *mu_load_rcfile; | ||
75 | |||
76 | extern int log_facility; /* FIXME: 1. Belongs elsewhere; | ||
77 | 2. Does not begin with `mu_' */ | ||
78 | |||
79 | typedef int (*gocs_init_fp) (void *data); | ||
80 | |||
81 | void mu_gocs_register (char *capa, gocs_init_fp init); | ||
82 | void mu_gocs_register_std (char *name); | ||
83 | void mu_gocs_store (char *capa, void *data); | ||
84 | void mu_gocs_flush (void); | ||
85 | int mu_gocs_enumerate (mu_list_action_t action, void *data); | ||
86 | |||
87 | int mu_gocs_mailbox_init (void *data); | ||
88 | int mu_gocs_locking_init (void *data); | ||
89 | int mu_gocs_daemon_init (void *data); | ||
90 | int mu_gocs_source_email_init (void *data); | ||
91 | int mu_gocs_mailer_init (void *data); | ||
92 | int mu_gocs_logging_init (void *data); | ||
93 | |||
94 | #ifdef __cplusplus | ||
95 | } | ||
96 | #endif | ||
97 | |||
98 | #endif |
... | @@ -19,14 +19,22 @@ | ... | @@ -19,14 +19,22 @@ |
19 | #ifndef _MAILUTILS_GSASL_H | 19 | #ifndef _MAILUTILS_GSASL_H |
20 | #define _MAILUTILS_GSASL_H | 20 | #define _MAILUTILS_GSASL_H |
21 | 21 | ||
22 | struct mu_gsasl_module_data | ||
23 | { | ||
24 | char *cram_md5_pwd; | ||
25 | }; | ||
26 | |||
27 | int mu_gsasl_module_init (void *data); | ||
28 | |||
29 | struct mu_gsasl_module_data mu_gsasl_module_data; | ||
30 | |||
31 | #ifdef USE_GSASL | ||
22 | #include <gsasl.h> | 32 | #include <gsasl.h> |
23 | 33 | ||
24 | int mu_gsasl_stream_create (mu_stream_t *stream, mu_stream_t transport, | 34 | int mu_gsasl_stream_create (mu_stream_t *stream, mu_stream_t transport, |
25 | Gsasl_session_ctx *ctx, | 35 | Gsasl_session_ctx *ctx, |
26 | int flags); | 36 | int flags); |
27 | |||
28 | void mu_gsasl_init_argp (void); | ||
29 | 37 | ||
30 | extern char *mu_gsasl_cram_md5_pwd; | 38 | #endif |
31 | 39 | ||
32 | #endif /* not _MAILUTILS_GSASL_H */ | 40 | #endif /* not _MAILUTILS_GSASL_H */ | ... | ... |
... | @@ -259,9 +259,19 @@ int mu_sieve_mailbox (mu_sieve_machine_t mach, mu_mailbox_t mbox); | ... | @@ -259,9 +259,19 @@ int mu_sieve_mailbox (mu_sieve_machine_t mach, mu_mailbox_t mbox); |
259 | int mu_sieve_message (mu_sieve_machine_t mach, mu_message_t message); | 259 | int mu_sieve_message (mu_sieve_machine_t mach, mu_message_t message); |
260 | int mu_sieve_disass (mu_sieve_machine_t mach); | 260 | int mu_sieve_disass (mu_sieve_machine_t mach); |
261 | 261 | ||
262 | /* Command line handling */ | 262 | /* Configuration functions */ |
263 | 263 | ||
264 | extern void mu_sieve_argp_init (void); | 264 | #define MU_SIEVE_CLEAR_INCLUDE_PATH 0x1 |
265 | #define MU_SIEVE_CLEAR_LIBRARY_PATH 0x2 | ||
266 | |||
267 | struct mu_gocs_sieve | ||
268 | { | ||
269 | int clearflags; | ||
270 | mu_list_t include_path; | ||
271 | mu_list_t library_path; | ||
272 | }; | ||
273 | |||
274 | int mu_sieve_module_init (void *); | ||
265 | 275 | ||
266 | #ifdef __cplusplus | 276 | #ifdef __cplusplus |
267 | } | 277 | } | ... | ... |
... | @@ -19,7 +19,6 @@ | ... | @@ -19,7 +19,6 @@ |
19 | 19 | ||
20 | #include <mailutils/address.h> | 20 | #include <mailutils/address.h> |
21 | #include <mailutils/argcv.h> | 21 | #include <mailutils/argcv.h> |
22 | #include <mailutils/argp.h> | ||
23 | #include <mailutils/attribute.h> | 22 | #include <mailutils/attribute.h> |
24 | #include <mailutils/auth.h> | 23 | #include <mailutils/auth.h> |
25 | #include <mailutils/body.h> | 24 | #include <mailutils/body.h> |
... | @@ -53,6 +52,7 @@ | ... | @@ -53,6 +52,7 @@ |
53 | #include <mailutils/tls.h> | 52 | #include <mailutils/tls.h> |
54 | #include <mailutils/types.h> | 53 | #include <mailutils/types.h> |
55 | #include <mailutils/url.h> | 54 | #include <mailutils/url.h> |
55 | #include <mailutils/gocs.h> | ||
56 | 56 | ||
57 | #ifdef MU_COMPAT | 57 | #ifdef MU_COMPAT |
58 | # include <mailutils/compat.h> | 58 | # include <mailutils/compat.h> | ... | ... |
... | @@ -20,6 +20,7 @@ | ... | @@ -20,6 +20,7 @@ |
20 | #define _MAILUTILS_MU_AUTH_H | 20 | #define _MAILUTILS_MU_AUTH_H |
21 | 21 | ||
22 | #include <mailutils/types.h> | 22 | #include <mailutils/types.h> |
23 | #include <mailutils/gocs.h> | ||
23 | 24 | ||
24 | #define MU_AUTH_NAME "name" | 25 | #define MU_AUTH_NAME "name" |
25 | #define MU_AUTH_PASSWD "passwd" | 26 | #define MU_AUTH_PASSWD "passwd" |
... | @@ -61,8 +62,7 @@ typedef int (*mu_auth_fp) (struct mu_auth_data **data, | ... | @@ -61,8 +62,7 @@ typedef int (*mu_auth_fp) (struct mu_auth_data **data, |
61 | struct mu_auth_module | 62 | struct mu_auth_module |
62 | { | 63 | { |
63 | char *name; | 64 | char *name; |
64 | struct argp *argp; | 65 | gocs_init_fp init; |
65 | struct mu_cfg_param *cfg; | ||
66 | mu_auth_fp authenticate; | 66 | mu_auth_fp authenticate; |
67 | void *authenticate_data; | 67 | void *authenticate_data; |
68 | mu_auth_fp auth_by_name; | 68 | mu_auth_fp auth_by_name; |
... | @@ -130,7 +130,6 @@ extern struct mu_auth_module mu_auth_virtual_module; | ... | @@ -130,7 +130,6 @@ extern struct mu_auth_module mu_auth_virtual_module; |
130 | extern struct mu_auth_module mu_auth_radius_module; | 130 | extern struct mu_auth_module mu_auth_radius_module; |
131 | 131 | ||
132 | #define MU_AUTH_REGISTER_ALL_MODULES() do {\ | 132 | #define MU_AUTH_REGISTER_ALL_MODULES() do {\ |
133 | mu_auth_init (); \ | ||
134 | mu_auth_register_module (&mu_auth_generic_module); \ | 133 | mu_auth_register_module (&mu_auth_generic_module); \ |
135 | mu_auth_register_module (&mu_auth_system_module); \ | 134 | mu_auth_register_module (&mu_auth_system_module); \ |
136 | mu_auth_register_module (&mu_auth_pam_module);\ | 135 | mu_auth_register_module (&mu_auth_pam_module);\ | ... | ... |
... | @@ -152,7 +152,7 @@ extern size_t mu_strftime (char *s, size_t max, const char *format, | ... | @@ -152,7 +152,7 @@ extern size_t mu_strftime (char *s, size_t max, const char *format, |
152 | 152 | ||
153 | extern int mutil_parse_field_map (const char *map, mu_assoc_t *passoc_tab, | 153 | extern int mutil_parse_field_map (const char *map, mu_assoc_t *passoc_tab, |
154 | int *perr); | 154 | int *perr); |
155 | 155 | ||
156 | #ifdef __cplusplus | 156 | #ifdef __cplusplus |
157 | } | 157 | } |
158 | #endif | 158 | #endif | ... | ... |
include/mailutils/pam.h
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 1999, 2000, 2001, 2004, 2005, | ||
3 | 2007 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA */ | ||
19 | |||
20 | #ifndef _MAILUTILS_PAM_H | ||
21 | #define _MAILUTILS_PAM_H | ||
22 | #include <mailutils/types.h> | ||
23 | |||
24 | extern char *mu_pam_service; | ||
25 | |||
26 | #endif |
include/mailutils/radius.h
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 1999, 2000, 2001, 2004, 2005, | ||
3 | 2007 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA */ | ||
19 | |||
20 | #ifndef _MAILUTILS_RADIUS_H | ||
21 | #define _MAILUTILS_RADIUS_H | ||
22 | #include <mailutils/types.h> | ||
23 | |||
24 | struct mu_radius_module_data | ||
25 | { | ||
26 | char *config_dir; | ||
27 | char *auth_request; | ||
28 | char *getpwnam_request; | ||
29 | char *getpwuid_request; | ||
30 | }; | ||
31 | |||
32 | extern int mu_radius_module_init (void *data); | ||
33 | |||
34 | #endif |
... | @@ -19,7 +19,30 @@ | ... | @@ -19,7 +19,30 @@ |
19 | #ifndef _MAILUTILS_SQL_H | 19 | #ifndef _MAILUTILS_SQL_H |
20 | #define _MAILUTILS_SQL_H | 20 | #define _MAILUTILS_SQL_H |
21 | 21 | ||
22 | /* Loadable Modules Suppert */ | 22 | /* Configuration */ |
23 | enum mu_password_type | ||
24 | { | ||
25 | password_plaintext, /* Plaintext passwords */ | ||
26 | password_scrambled, /* Scrambled MySQL (>=3.21) password */ | ||
27 | password_hash, /* MD5 (or DES or whatever) hash */ | ||
28 | }; | ||
29 | |||
30 | struct mu_sql_module_config | ||
31 | { | ||
32 | char *interface; | ||
33 | char *getpwnam_query; | ||
34 | char *getpass_query; | ||
35 | char *getpwuid_query; | ||
36 | char *host; | ||
37 | char *user; | ||
38 | char *passwd; | ||
39 | char *db; | ||
40 | int port; | ||
41 | enum mu_password_type password_type; | ||
42 | mu_assoc_t field_map; | ||
43 | }; | ||
44 | |||
45 | /* Loadable Modules Support */ | ||
23 | #define __s_cat2__(a,b) a ## b | 46 | #define __s_cat2__(a,b) a ## b |
24 | #define __s_cat3__(a,b,c) a ## b ## c | 47 | #define __s_cat3__(a,b,c) a ## b ## c |
25 | #define RDL_EXPORT(module,name) __s_cat3__(module,_LTX_,name) | 48 | #define RDL_EXPORT(module,name) __s_cat3__(module,_LTX_,name) |
... | @@ -27,7 +50,7 @@ | ... | @@ -27,7 +50,7 @@ |
27 | typedef int (*mu_rdl_init_t) (void); | 50 | typedef int (*mu_rdl_init_t) (void); |
28 | typedef void (*mu_rdl_done_t) (void); | 51 | typedef void (*mu_rdl_done_t) (void); |
29 | 52 | ||
30 | #ifdef _HAVE_LIBLTDL //FIXME: Remove leading _ when SQL + ltdl works | 53 | #ifdef _HAVE_LIBLTDL /*FIXME: Remove leading _ when SQL + ltdl works*/ |
31 | # define MU_DECL_SQL_DISPATCH_T(mod) \ | 54 | # define MU_DECL_SQL_DISPATCH_T(mod) \ |
32 | mu_sql_dispatch_t RDL_EXPORT(mod,dispatch_tab) | 55 | mu_sql_dispatch_t RDL_EXPORT(mod,dispatch_tab) |
33 | #else | 56 | #else |
... | @@ -112,18 +135,11 @@ int mu_sql_get_field (mu_sql_connection_t conn, size_t nrow, char *fname, | ... | @@ -112,18 +135,11 @@ int mu_sql_get_field (mu_sql_connection_t conn, size_t nrow, char *fname, |
112 | 135 | ||
113 | const char *mu_sql_strerror (mu_sql_connection_t conn); | 136 | const char *mu_sql_strerror (mu_sql_connection_t conn); |
114 | 137 | ||
115 | enum mu_password_type | ||
116 | { | ||
117 | password_plaintext, /* Plaintext passwords */ | ||
118 | password_scrambled, /* Scrambled MySQL (>=3.21) password */ | ||
119 | password_hash, /* MD5 (or DES or whatever) hash */ | ||
120 | }; | ||
121 | |||
122 | extern enum mu_password_type mu_sql_password_type; | ||
123 | |||
124 | extern char *mu_sql_expand_query (const char *query, const char *ustr); | 138 | extern char *mu_sql_expand_query (const char *query, const char *ustr); |
125 | extern int mu_sql_getpass (const char *username, char **passwd); | 139 | extern int mu_sql_getpass (const char *username, char **passwd); |
126 | extern int mu_check_mysql_scrambled_password (const char *scrambled, | 140 | extern int mu_check_mysql_scrambled_password (const char *scrambled, |
127 | const char *message); | 141 | const char *message); |
128 | 142 | ||
143 | int mu_sql_decode_password_type (const char *arg, enum mu_password_type *t); | ||
144 | |||
129 | #endif | 145 | #endif | ... | ... |
include/mailutils/syslog.h
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 3 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General | ||
15 | Public License along with this library; if not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | Boston, MA 02110-1301 USA */ | ||
18 | |||
19 | #ifndef _MAILUTILS_SYSLOG_H | ||
20 | #define _MAILUTILS_SYSLOG_H | ||
21 | |||
22 | #include <syslog.h> | ||
23 | |||
24 | #ifdef __cplusplus | ||
25 | extern "C" { | ||
26 | #endif | ||
27 | |||
28 | int mu_string_to_syslog_facility (char *str, int *pfacility); | ||
29 | const char *mu_syslog_facility_to_string (int n); | ||
30 | int mu_string_to_syslog_priority (char *str, int *pprio); | ||
31 | const char *mu_syslog_priority_to_string (int n); | ||
32 | |||
33 | #ifdef __cplusplus | ||
34 | } | ||
35 | #endif | ||
36 | |||
37 | #endif | ||
38 | |||
39 |
... | @@ -19,28 +19,35 @@ | ... | @@ -19,28 +19,35 @@ |
19 | #ifndef _MAILUTILS_TLS_H | 19 | #ifndef _MAILUTILS_TLS_H |
20 | #define _MAILUTILS_TLS_H | 20 | #define _MAILUTILS_TLS_H |
21 | 21 | ||
22 | #ifdef WITH_TLS | ||
23 | |||
24 | #include <mailutils/types.h> | 22 | #include <mailutils/types.h> |
25 | 23 | ||
26 | #ifdef __cplusplus | 24 | #ifdef __cplusplus |
27 | extern "C" { | 25 | extern "C" { |
28 | #endif | 26 | #endif |
29 | 27 | ||
28 | struct mu_tls_module_config | ||
29 | { | ||
30 | int client_enable; | ||
31 | char *ssl_cert; | ||
32 | char *ssl_key; | ||
33 | char *ssl_cafile; | ||
34 | }; | ||
35 | |||
36 | extern int mu_tls_module_init (void *data); | ||
37 | |||
30 | extern int mu_tls_stream_create (mu_stream_t *stream, | 38 | extern int mu_tls_stream_create (mu_stream_t *stream, |
31 | mu_stream_t strin, mu_stream_t strout, int flags); | 39 | mu_stream_t strin, mu_stream_t strout, |
40 | int flags); | ||
32 | extern int mu_tls_stream_create_client (mu_stream_t *stream, | 41 | extern int mu_tls_stream_create_client (mu_stream_t *stream, |
33 | mu_stream_t strin, mu_stream_t strout, | 42 | mu_stream_t strin, mu_stream_t strout, |
34 | int flags); | 43 | int flags); |
35 | extern int mu_tls_stream_create_client_from_tcp (mu_stream_t *stream, | 44 | extern int mu_tls_stream_create_client_from_tcp (mu_stream_t *stream, |
36 | mu_stream_t tcp_str, | 45 | mu_stream_t tcp_str, |
37 | int flags); | 46 | int flags); |
38 | 47 | ||
39 | extern int mu_check_tls_environment (void); | 48 | extern int mu_check_tls_environment (void); |
40 | extern int mu_init_tls_libs (void); | 49 | extern int mu_init_tls_libs (void); |
41 | extern void mu_deinit_tls_libs (void); | 50 | extern void mu_deinit_tls_libs (void); |
42 | extern void mu_tls_init_argp (void); | ||
43 | extern void mu_tls_init_client_argp (void); | ||
44 | 51 | ||
45 | typedef int (*mu_tls_readline_fn) (void *iodata); | 52 | typedef int (*mu_tls_readline_fn) (void *iodata); |
46 | typedef int (*mu_tls_writeline_fn) (void *iodata, char *buf); | 53 | typedef int (*mu_tls_writeline_fn) (void *iodata, char *buf); |
... | @@ -58,6 +65,5 @@ extern int mu_tls_enable; | ... | @@ -58,6 +65,5 @@ extern int mu_tls_enable; |
58 | } | 65 | } |
59 | #endif | 66 | #endif |
60 | 67 | ||
61 | #endif /* WITH_TLS */ | ||
62 | #endif /* _MAILUTILS_TLS_H */ | 68 | #endif /* _MAILUTILS_TLS_H */ |
63 | 69 | ... | ... |
... | @@ -23,8 +23,11 @@ noinst_LTLIBRARIES = libmuaux.la | ... | @@ -23,8 +23,11 @@ noinst_LTLIBRARIES = libmuaux.la |
23 | INCLUDES = @MU_COMMON_INCLUDES@ | 23 | INCLUDES = @MU_COMMON_INCLUDES@ |
24 | 24 | ||
25 | libmuaux_la_SOURCES = \ | 25 | libmuaux_la_SOURCES = \ |
26 | argpinit.c\ | ||
26 | daemon.c\ | 27 | daemon.c\ |
27 | mailcap.c\ | 28 | mailcap.c\ |
29 | muinit.h\ | ||
30 | muinit.c\ | ||
28 | mu_dbm.c | 31 | mu_dbm.c |
29 | 32 | ||
30 | EXTRA_DIST = utmp.c | 33 | EXTRA_DIST = utmp.c | ... | ... |
lib/argpinit.c
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 3 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General | ||
15 | Public License along with this library; if not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | Boston, MA 02110-1301 USA */ | ||
18 | |||
19 | #ifdef HAVE_CONFIG_H | ||
20 | # include <config.h> | ||
21 | #endif | ||
22 | |||
23 | #include "muinit.h" | ||
24 | |||
25 | void | ||
26 | mu_argp_init (const char *vers, const char *bugaddr) | ||
27 | { | ||
28 | argp_program_version = vers ? vers : PACKAGE_STRING; | ||
29 | argp_program_bug_address = bugaddr ? bugaddr : "<" PACKAGE_BUGREPORT ">"; | ||
30 | } | ||
31 |
lib/muinit.c
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 3 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General | ||
15 | Public License along with this library; if not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | Boston, MA 02110-1301 USA */ | ||
18 | |||
19 | #ifdef HAVE_CONFIG_H | ||
20 | # include <config.h> | ||
21 | #endif | ||
22 | |||
23 | #include "muinit.h" | ||
24 | |||
25 | int | ||
26 | mu_app_init (struct argp *myargp, const char **capa, | ||
27 | struct mu_cfg_param *cfg_param, | ||
28 | int argc, char **argv, int flags, int *pindex, void *data) | ||
29 | { | ||
30 | int rc, i; | ||
31 | struct argp *argp; | ||
32 | const struct argp argpnull = { 0 }; | ||
33 | |||
34 | mu_set_program_name (argv[0]); | ||
35 | mu_libargp_init (); | ||
36 | for (i = 0; capa[i]; i++) | ||
37 | mu_gocs_register_std (capa[i]); /*FIXME*/ | ||
38 | if (!myargp) | ||
39 | myargp = &argpnull; | ||
40 | argp = mu_argp_build (myargp); | ||
41 | rc = argp_parse (argp, argc, argv, flags, pindex, data); | ||
42 | mu_argp_done (argp); | ||
43 | if (rc) | ||
44 | return rc; | ||
45 | |||
46 | mu_libcfg_init (capa); | ||
47 | mu_parse_config_files (cfg_param); | ||
48 | |||
49 | mu_gocs_flush (); | ||
50 | |||
51 | return 0; | ||
52 | } |
lib/muinit.h
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 3 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General | ||
15 | Public License along with this library; if not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | Boston, MA 02110-1301 USA */ | ||
18 | |||
19 | #include "cmdline.h" | ||
20 | #include "libcfg.h" | ||
21 | |||
22 | void mu_argp_init (const char *vers, const char *bugaddr); | ||
23 | int mu_app_init (struct argp *myargp, const char **capa, | ||
24 | struct mu_cfg_param *cfg_param, | ||
25 | int argc, char **argv, int flags, int *pindex, void *data); | ||
26 | |||
27 |
libargp/auth.c
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 3 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General | ||
15 | Public License along with this library; if not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | Boston, MA 02110-1301 USA */ | ||
18 | |||
19 | #ifdef HAVE_CONFIG_H | ||
20 | # include <config.h> | ||
21 | #endif | ||
22 | |||
23 | #include "cmdline.h" | ||
24 | |||
25 | |||
26 | /* ************************************************************************* */ | ||
27 | /* Traditional configuration */ | ||
28 | /* ************************************************************************* */ | ||
29 | |||
30 | static error_t mu_auth_argp_parser (int key, char *arg, | ||
31 | struct argp_state *state); | ||
32 | |||
33 | /* Options used by programs that use extended authentication mechanisms. */ | ||
34 | static struct argp_option mu_auth_argp_option[] = { | ||
35 | { "authentication", OPT_AUTHENTICATION, N_("MODLIST"), OPTION_HIDDEN, | ||
36 | N_("Set the list of modules to be used for authentication"), 0 }, | ||
37 | { "authorization", OPT_AUTHORIZATION, N_("MODLIST"), OPTION_HIDDEN, | ||
38 | N_("Set list of modules to be used for authorization"), 0 }, | ||
39 | { "clear-authorization", OPT_CLEAR_AUTHORIZATION, NULL, OPTION_HIDDEN, | ||
40 | N_("Clear the list of authorization modules"), 0 }, | ||
41 | { "clear-authentication", OPT_CLEAR_AUTHENTICATION, NULL, OPTION_HIDDEN, | ||
42 | N_("Clear the list of authentication modules"), 0 }, | ||
43 | { NULL, 0, NULL, 0, NULL, 0 } | ||
44 | }; | ||
45 | |||
46 | static struct argp mu_auth_argp = { | ||
47 | mu_auth_argp_option, | ||
48 | mu_auth_argp_parser, | ||
49 | }; | ||
50 | |||
51 | static struct argp_child mu_auth_argp_child = { | ||
52 | &mu_auth_argp, | ||
53 | 0, | ||
54 | NULL, | ||
55 | 0 | ||
56 | }; | ||
57 | |||
58 | static error_t | ||
59 | mu_auth_argp_parser (int key, char *arg, struct argp_state *state) | ||
60 | { | ||
61 | switch (key) | ||
62 | { | ||
63 | case ARGP_KEY_FINI: | ||
64 | mu_auth_finish_setup (); | ||
65 | break; | ||
66 | |||
67 | /* authentication */ | ||
68 | case OPT_AUTHORIZATION: | ||
69 | mu_authorization_add_module_list (arg); | ||
70 | break; | ||
71 | |||
72 | case OPT_AUTHENTICATION: | ||
73 | mu_authentication_add_module_list (arg); | ||
74 | break; | ||
75 | |||
76 | case OPT_CLEAR_AUTHENTICATION: | ||
77 | mu_authentication_clear_list (); | ||
78 | break; | ||
79 | |||
80 | case OPT_CLEAR_AUTHORIZATION: | ||
81 | mu_authorization_clear_list (); | ||
82 | break; | ||
83 | |||
84 | default: | ||
85 | return ARGP_ERR_UNKNOWN; | ||
86 | } | ||
87 | return 0; | ||
88 | } | ||
89 | |||
90 | struct mu_cmdline_capa mu_auth_cmdline = { | ||
91 | "auth", &mu_auth_argp_child | ||
92 | }; |
libargp/cmdline.h
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 1999, 2000, 2001, 2004, 2005, | ||
3 | 2007 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA */ | ||
19 | |||
20 | #ifndef _MAILUTILS_CMDLINE_H | ||
21 | #define _MAILUTILS_CMDLINE_H | ||
22 | |||
23 | #ifdef HAVE_CONFIG_H | ||
24 | # include <config.h> | ||
25 | #endif | ||
26 | #include "mailutils/types.h" | ||
27 | #include "mailutils/gocs.h" | ||
28 | #include "mailutils/nls.h" | ||
29 | #include "mailutils/error.h" | ||
30 | #include "mailutils/errno.h" | ||
31 | #include "argp.h" | ||
32 | #include <errno.h> /* May declare program_invocation_name */ | ||
33 | |||
34 | #ifdef __cplusplus | ||
35 | extern "C" { | ||
36 | #endif | ||
37 | |||
38 | enum { | ||
39 | OPT_LOG_FACILITY = 256, | ||
40 | OPT_LOCK_FLAGS, | ||
41 | OPT_LOCK_RETRY_COUNT, | ||
42 | OPT_LOCK_RETRY_TIMEOUT, | ||
43 | OPT_LOCK_EXPIRE_TIMEOUT, | ||
44 | OPT_LOCK_EXTERNAL_PROGRAM, | ||
45 | OPT_SHOW_OPTIONS, | ||
46 | OPT_LICENSE, | ||
47 | OPT_MAILBOX_TYPE, | ||
48 | OPT_CRAM_PASSWD, | ||
49 | OPT_PAM_SERVICE, | ||
50 | OPT_AUTH_REQUEST, | ||
51 | OPT_GETPWNAM_REQUEST, | ||
52 | OPT_GETPWUID_REQUEST, | ||
53 | OPT_RADIUS_DIR, | ||
54 | OPT_SQL_INTERFACE, | ||
55 | OPT_SQL_GETPWNAM, | ||
56 | OPT_SQL_GETPWUID, | ||
57 | OPT_SQL_GETPASS, | ||
58 | OPT_SQL_HOST, | ||
59 | OPT_SQL_USER, | ||
60 | OPT_SQL_PASSWD, | ||
61 | OPT_SQL_DB, | ||
62 | OPT_SQL_PORT, | ||
63 | OPT_SQL_MU_PASSWORD_TYPE, | ||
64 | OPT_SQL_FIELD_MAP, | ||
65 | OPT_TLS, | ||
66 | OPT_SSL_CERT, | ||
67 | OPT_SSL_KEY, | ||
68 | OPT_SSL_CAFILE, | ||
69 | OPT_PWDDIR, | ||
70 | OPT_AUTHORIZATION, | ||
71 | OPT_AUTHENTICATION, | ||
72 | OPT_CLEAR_AUTHORIZATION, | ||
73 | OPT_CLEAR_AUTHENTICATION, | ||
74 | OPT_NO_USER_RCFILE, | ||
75 | OPT_NO_SITE_RCFILE, | ||
76 | OPT_RCFILE, | ||
77 | OPT_CLEAR_INCLUDE_PATH, | ||
78 | OPT_CLEAR_LIBRARY_PATH | ||
79 | }; | ||
80 | |||
81 | struct mu_cmdline_capa | ||
82 | { | ||
83 | char *name; | ||
84 | struct argp_child *child; | ||
85 | }; | ||
86 | |||
87 | extern struct mu_cmdline_capa mu_common_cmdline; | ||
88 | extern struct mu_cmdline_capa mu_logging_cmdline; | ||
89 | extern struct mu_cmdline_capa mu_license_cmdline; | ||
90 | extern struct mu_cmdline_capa mu_mailbox_cmdline; | ||
91 | extern struct mu_cmdline_capa mu_locking_cmdline; | ||
92 | extern struct mu_cmdline_capa mu_address_cmdline; | ||
93 | extern struct mu_cmdline_capa mu_mailer_cmdline; | ||
94 | extern struct mu_cmdline_capa mu_daemon_cmdline; | ||
95 | extern struct mu_cmdline_capa mu_sieve_cmdline; | ||
96 | |||
97 | extern struct mu_cmdline_capa mu_pam_cmdline; | ||
98 | extern struct mu_cmdline_capa mu_gsasl_cmdline; | ||
99 | extern struct mu_cmdline_capa mu_tls_cmdline; | ||
100 | extern struct mu_cmdline_capa mu_radius_cmdline; | ||
101 | extern struct mu_cmdline_capa mu_sql_cmdline; | ||
102 | extern struct mu_cmdline_capa mu_virtdomain_cmdline; | ||
103 | extern struct mu_cmdline_capa mu_auth_cmdline; | ||
104 | |||
105 | extern char *mu_license_text; | ||
106 | |||
107 | extern void mu_libargp_init (void); | ||
108 | |||
109 | extern struct argp *mu_argp_build (const struct argp *argp); | ||
110 | extern void mu_argp_done (struct argp *argp); | ||
111 | |||
112 | extern int mu_register_argp_capa (const char *name, struct argp_child *child); | ||
113 | |||
114 | extern void mu_print_options (void); | ||
115 | extern const char *mu_check_option (char *name); | ||
116 | |||
117 | #ifdef __cplusplus | ||
118 | } | ||
119 | #endif | ||
120 | |||
121 | #endif | ||
122 |
libargp/common.c
0 → 100644
This diff is collapsed.
Click to expand it.
libargp/gsasl.c
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 3 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General | ||
15 | Public License along with this library; if not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | Boston, MA 02110-1301 USA */ | ||
18 | |||
19 | #ifdef HAVE_CONFIG_H | ||
20 | # include <config.h> | ||
21 | #endif | ||
22 | |||
23 | #include "cmdline.h" | ||
24 | #include <mailutils/gsasl.h> | ||
25 | |||
26 | static struct argp_option _gsasl_argp_options[] = { | ||
27 | {"cram-passwd", OPT_CRAM_PASSWD, N_("FILE"), OPTION_HIDDEN, | ||
28 | N_("Specify password file for CRAM-MD5 authentication"), 0}, | ||
29 | { NULL, 0, NULL, 0, NULL, 0 } | ||
30 | }; | ||
31 | |||
32 | static struct mu_gsasl_module_data gsasl_data = { | ||
33 | SITE_CRAM_MD5_PWD | ||
34 | }; | ||
35 | |||
36 | static error_t | ||
37 | _gsasl_argp_parser (int key, char *arg, struct argp_state *state) | ||
38 | { | ||
39 | switch (key) | ||
40 | { | ||
41 | case OPT_CRAM_PASSWD: | ||
42 | gsasl_data.cram_md5_pwd = arg; | ||
43 | break; | ||
44 | |||
45 | case ARGP_KEY_FINI: | ||
46 | mu_gocs_store ("gsasl", &gsasl_data); | ||
47 | break; | ||
48 | |||
49 | default: | ||
50 | return ARGP_ERR_UNKNOWN; | ||
51 | } | ||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | static struct argp _gsasl_argp = { | ||
56 | _gsasl_argp_options, | ||
57 | _gsasl_argp_parser | ||
58 | }; | ||
59 | |||
60 | struct argp_child mu_gsasl_argp_child = { | ||
61 | &_gsasl_argp, | ||
62 | 0, | ||
63 | NULL, | ||
64 | 0 | ||
65 | }; | ||
66 | |||
67 | struct mu_cmdline_capa mu_gsasl_cmdline = { | ||
68 | "gsasl", &mu_gsasl_argp_child | ||
69 | }; | ||
70 | |||
71 |
libargp/mu_argp.c
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2006, | ||
3 | 2007 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA */ | ||
19 | |||
20 | #ifdef HAVE_CONFIG_H | ||
21 | # include <config.h> | ||
22 | #endif | ||
23 | |||
24 | #include <getline.h> | ||
25 | #include <pwd.h> | ||
26 | #include <stdio.h> | ||
27 | #include <stdlib.h> | ||
28 | #include <string.h> | ||
29 | #include <syslog.h> | ||
30 | #include <unistd.h> | ||
31 | |||
32 | #include <sys/types.h> | ||
33 | #include <sys/stat.h> | ||
34 | |||
35 | #include "cmdline.h" | ||
36 | |||
37 | char *mu_license_text = | ||
38 | N_(" GNU Mailutils is free software; you can redistribute it and/or modify\n" | ||
39 | " it under the terms of the GNU General Public License as published by\n" | ||
40 | " the Free Software Foundation; either version 3 of the License, or\n" | ||
41 | " (at your option) any later version.\n" | ||
42 | "\n" | ||
43 | " GNU Mailutils is distributed in the hope that it will be useful,\n" | ||
44 | " but WITHOUT ANY WARRANTY; without even the implied warranty of\n" | ||
45 | " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" | ||
46 | " GNU General Public License for more details.\n" | ||
47 | "\n" | ||
48 | " You should have received a copy of the GNU General Public License along\n" | ||
49 | " with GNU Mailutils; if not, write to the Free Software Foundation,\n" | ||
50 | " Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n" | ||
51 | "\n" | ||
52 | "\n" | ||
53 | ); | ||
54 | |||
55 | static char *mu_conf_option[] = { | ||
56 | "VERSION=" VERSION, | ||
57 | #ifdef USE_LIBPAM | ||
58 | "USE_LIBPAM", | ||
59 | #endif | ||
60 | #ifdef HAVE_LIBLTDL | ||
61 | "HAVE_LIBLTDL", | ||
62 | #endif | ||
63 | #ifdef WITH_BDB2 | ||
64 | "WITH_BDB2", | ||
65 | #endif | ||
66 | #ifdef WITH_NDBM | ||
67 | "WITH_NDBM", | ||
68 | #endif | ||
69 | #ifdef WITH_OLD_DBM | ||
70 | "WITH_OLD_DBM", | ||
71 | #endif | ||
72 | #ifdef WITH_GDBM | ||
73 | "WITH_GDBM", | ||
74 | #endif | ||
75 | #ifdef WITH_GNUTLS | ||
76 | "WITH_GNUTLS", | ||
77 | #endif | ||
78 | #ifdef WITH_GSASL | ||
79 | "WITH_GSASL", | ||
80 | #endif | ||
81 | #ifdef WITH_GSSAPI | ||
82 | "WITH_GSSAPI", | ||
83 | #endif | ||
84 | #ifdef WITH_GUILE | ||
85 | "WITH_GUILE", | ||
86 | #endif | ||
87 | #ifdef WITH_PTHREAD | ||
88 | "WITH_PTHREAD", | ||
89 | #endif | ||
90 | #ifdef WITH_READLINE | ||
91 | "WITH_READLINE", | ||
92 | #endif | ||
93 | #ifdef HAVE_MYSQL | ||
94 | "HAVE_MYSQL", | ||
95 | #endif | ||
96 | #ifdef HAVE_PGSQL | ||
97 | "HAVE_PGSQL", | ||
98 | #endif | ||
99 | #ifdef ENABLE_VIRTUAL_DOMAINS | ||
100 | "ENABLE_VIRTUAL_DOMAINS", | ||
101 | #endif | ||
102 | #ifdef ENABLE_IMAP | ||
103 | "ENABLE_IMAP", | ||
104 | #endif | ||
105 | #ifdef ENABLE_POP | ||
106 | "ENABLE_POP", | ||
107 | #endif | ||
108 | #ifdef ENABLE_MH | ||
109 | "ENABLE_MH", | ||
110 | #endif | ||
111 | #ifdef ENABLE_MAILDIR | ||
112 | "ENABLE_MAILDIR", | ||
113 | #endif | ||
114 | #ifdef ENABLE_SMTP | ||
115 | "ENABLE_SMTP", | ||
116 | #endif | ||
117 | #ifdef ENABLE_SENDMAIL | ||
118 | "ENABLE_SENDMAIL", | ||
119 | #endif | ||
120 | #ifdef ENABLE_NNTP | ||
121 | "ENABLE_NNTP", | ||
122 | #endif | ||
123 | #ifdef ENABLE_RADIUS | ||
124 | "ENABLE_RADIUS", | ||
125 | #endif | ||
126 | #ifdef WITH_INCLUDED_LIBINTL | ||
127 | "WITH_INCLUDED_LIBINTL", | ||
128 | #endif | ||
129 | NULL | ||
130 | }; | ||
131 | |||
132 | void | ||
133 | mu_print_options () | ||
134 | { | ||
135 | int i; | ||
136 | |||
137 | for (i = 0; mu_conf_option[i]; i++) | ||
138 | printf ("%s\n", mu_conf_option[i]); | ||
139 | } | ||
140 | |||
141 | const char * | ||
142 | mu_check_option (char *name) | ||
143 | { | ||
144 | int i; | ||
145 | |||
146 | for (i = 0; mu_conf_option[i]; i++) | ||
147 | { | ||
148 | int len; | ||
149 | char *q, *p = strchr (mu_conf_option[i], '='); | ||
150 | if (p) | ||
151 | len = p - mu_conf_option[i]; | ||
152 | else | ||
153 | len = strlen (mu_conf_option[i]); | ||
154 | |||
155 | if (strncasecmp (mu_conf_option[i], name, len) == 0) | ||
156 | return mu_conf_option[i]; | ||
157 | else if ((q = strchr (mu_conf_option[i], '_')) != NULL | ||
158 | && strncasecmp (q + 1, name, | ||
159 | len - (q - mu_conf_option[i]) - 1) == 0) | ||
160 | return mu_conf_option[i]; | ||
161 | } | ||
162 | return NULL; | ||
163 | } | ||
164 | |||
165 | |||
166 | /* ************************************************************************* */ | ||
167 | /* Capability array and auxiliary functions. */ | ||
168 | /* ************************************************************************* */ | ||
169 | |||
170 | #define MU_MAX_CAPA 24 | ||
171 | |||
172 | struct argp_capa { | ||
173 | char *capability; | ||
174 | struct argp_child *child; | ||
175 | } mu_argp_capa[MU_MAX_CAPA] = { | ||
176 | {NULL,} | ||
177 | }; | ||
178 | |||
179 | int | ||
180 | mu_register_argp_capa (const char *name, struct argp_child *child) | ||
181 | { | ||
182 | int i; | ||
183 | |||
184 | for (i = 0; i < MU_MAX_CAPA; i++) | ||
185 | if (mu_argp_capa[i].capability == NULL) | ||
186 | { | ||
187 | mu_argp_capa[i].capability = strdup (name); | ||
188 | mu_argp_capa[i].child = child; | ||
189 | return 0; | ||
190 | } | ||
191 | return 1; | ||
192 | } | ||
193 | |||
194 | static struct argp_capa * | ||
195 | find_capa (const char *name) | ||
196 | { | ||
197 | int i; | ||
198 | for (i = 0; mu_argp_capa[i].capability; i++) | ||
199 | if (strcmp (mu_argp_capa[i].capability, name) == 0) | ||
200 | return &mu_argp_capa[i]; | ||
201 | return NULL; | ||
202 | } | ||
203 | |||
204 | static struct argp * | ||
205 | mu_build_argp (const struct argp *template, const char *capa[]) | ||
206 | { | ||
207 | int n; | ||
208 | int nchild; | ||
209 | struct argp_child *ap; | ||
210 | const struct argp_option *opt; | ||
211 | struct argp *argp; | ||
212 | int group = 0; | ||
213 | |||
214 | /* Count the capabilities. */ | ||
215 | for (n = 0; capa && capa[n]; n++) | ||
216 | ; | ||
217 | if (template->children) | ||
218 | for (; template->children[n].argp; n++) | ||
219 | ; | ||
220 | |||
221 | ap = calloc (n + 1, sizeof (*ap)); | ||
222 | if (!ap) | ||
223 | { | ||
224 | mu_error (_("Out of memory")); | ||
225 | abort (); | ||
226 | } | ||
227 | |||
228 | /* Copy the template's children. */ | ||
229 | nchild = 0; | ||
230 | if (template->children) | ||
231 | for (n = 0; template->children[n].argp; n++, nchild++) | ||
232 | ap[nchild] = template->children[n]; | ||
233 | |||
234 | /* Find next group number */ | ||
235 | for (opt = template->options; | ||
236 | opt && ((opt->name && opt->key) || opt->doc); opt++) | ||
237 | if (opt->group > group) | ||
238 | group = opt->group; | ||
239 | |||
240 | group++; | ||
241 | |||
242 | /* Append any capabilities to the children or options, as appropriate. */ | ||
243 | for (n = 0; capa && capa[n]; n++) | ||
244 | { | ||
245 | struct argp_capa *cp = find_capa (capa[n]); | ||
246 | if (!cp) | ||
247 | { | ||
248 | mu_error (_("INTERNAL ERROR: requested unknown argp " | ||
249 | "capability %s (please report)"), | ||
250 | capa[n]); | ||
251 | abort (); | ||
252 | } | ||
253 | ap[nchild] = *cp->child; | ||
254 | ap[nchild].group = group++; | ||
255 | nchild++; | ||
256 | |||
257 | } | ||
258 | ap[nchild].argp = NULL; | ||
259 | |||
260 | /* Copy the template, and give it the expanded children. */ | ||
261 | argp = malloc (sizeof (*argp)); | ||
262 | if (!argp) | ||
263 | { | ||
264 | mu_error (_("Out of memory")); | ||
265 | abort (); | ||
266 | } | ||
267 | |||
268 | memcpy (argp, template, sizeof (*argp)); | ||
269 | |||
270 | argp->children = ap; | ||
271 | |||
272 | return argp; | ||
273 | } | ||
274 | |||
275 | struct cap_buf | ||
276 | { | ||
277 | const char **capa; | ||
278 | size_t numcapa; | ||
279 | size_t maxcapa; | ||
280 | }; | ||
281 | |||
282 | static void | ||
283 | cap_buf_init (struct cap_buf *bp) | ||
284 | { | ||
285 | bp->numcapa = 0; | ||
286 | bp->maxcapa = 2; | ||
287 | bp->capa = calloc (bp->maxcapa, sizeof bp->capa[0]); | ||
288 | if (!bp->capa) | ||
289 | { | ||
290 | mu_error ("%s", mu_strerror (errno)); | ||
291 | abort (); | ||
292 | } | ||
293 | bp->capa[0] = NULL; | ||
294 | } | ||
295 | |||
296 | static void | ||
297 | cap_buf_add (struct cap_buf *bp, const char *str) | ||
298 | { | ||
299 | if (bp->numcapa == bp->maxcapa) | ||
300 | { | ||
301 | bp->maxcapa *= 2; | ||
302 | bp->capa = realloc (bp->capa, bp->maxcapa * sizeof bp->capa[0]); | ||
303 | if (!bp->capa) | ||
304 | { | ||
305 | mu_error ("%s", mu_strerror (errno)); | ||
306 | abort (); | ||
307 | } | ||
308 | } | ||
309 | bp->capa[bp->numcapa] = str; | ||
310 | if (str) | ||
311 | bp->numcapa++; | ||
312 | } | ||
313 | |||
314 | static void | ||
315 | cap_buf_free (struct cap_buf *bp) | ||
316 | { | ||
317 | free (bp->capa); | ||
318 | } | ||
319 | |||
320 | static int | ||
321 | argp_reg_action (void *item, void *data) | ||
322 | { | ||
323 | struct cap_buf *bp = data; | ||
324 | cap_buf_add (bp, item); | ||
325 | return 0; | ||
326 | } | ||
327 | |||
328 | struct argp * | ||
329 | mu_argp_build (const struct argp *init_argp) | ||
330 | { | ||
331 | struct cap_buf cb; | ||
332 | struct argp *argp; | ||
333 | |||
334 | cap_buf_init (&cb); | ||
335 | mu_gocs_enumerate (argp_reg_action, &cb); | ||
336 | cap_buf_add (&cb, NULL); | ||
337 | mu_libargp_init (); | ||
338 | argp = mu_build_argp (init_argp, cb.capa); | ||
339 | cap_buf_free (&cb); | ||
340 | return argp; | ||
341 | } | ||
342 | |||
343 | void | ||
344 | mu_argp_done (struct argp *argp) | ||
345 | { | ||
346 | free ((void*) argp->children); | ||
347 | free ((void*) argp); | ||
348 | } |
... | @@ -21,46 +21,23 @@ | ... | @@ -21,46 +21,23 @@ |
21 | #define _MAILUTILS_ARGP_H | 21 | #define _MAILUTILS_ARGP_H |
22 | 22 | ||
23 | #include <mailutils/types.h> | 23 | #include <mailutils/types.h> |
24 | #include <mailutils/cfg.h> | ||
25 | #include <argp.h> | 24 | #include <argp.h> |
26 | #include <errno.h> /* May declare program_invocation_name */ | 25 | #include <errno.h> /* May declare program_invocation_name */ |
27 | 26 | ||
28 | #define MODE_INTERACTIVE 0 | ||
29 | #define MODE_DAEMON 1 | ||
30 | |||
31 | struct daemon_param { | ||
32 | int mode; | ||
33 | size_t maxchildren; | ||
34 | unsigned int port; | ||
35 | unsigned int timeout; | ||
36 | int transcript; | ||
37 | char *pidfile; | ||
38 | }; | ||
39 | |||
40 | #ifdef USE_LIBPAM | ||
41 | extern char *pam_service; | ||
42 | #endif | ||
43 | extern int log_facility; | ||
44 | extern int mu_argp_error_code; | ||
45 | extern char *mu_license_text; | 27 | extern char *mu_license_text; |
46 | 28 | ||
47 | #ifdef __cplusplus | 29 | #ifdef __cplusplus |
48 | extern "C" { | 30 | extern "C" { |
49 | #endif | 31 | #endif |
50 | 32 | ||
51 | extern void mu_argp_init (const char *vers, const char *bugaddr); | 33 | extern void mu_argp_init (struct argp *argp, const char *vers, |
34 | const char *bugaddr, const char *capa[]); | ||
35 | extern void mu_argp_done (struct argp *argp); | ||
52 | 36 | ||
53 | extern error_t mu_argp_parse (const struct argp * argp, | 37 | extern int mu_register_argp_capa (const char *name, struct argp_child *child); |
54 | int *p_argc, char ***p_argv, | ||
55 | unsigned flags, | ||
56 | const char *capa[], | ||
57 | int *arg_index, void *input); | ||
58 | extern int mu_register_capa (const char *name, struct argp_child *child, | ||
59 | struct mu_cfg_param *param); | ||
60 | 38 | ||
61 | extern void mu_print_options (void); | 39 | extern void mu_print_options (void); |
62 | extern const char *mu_check_option (char *name); | 40 | extern const char *mu_check_option (char *name); |
63 | extern void mu_argp_set_config_param (struct mu_cfg_param *); | ||
64 | 41 | ||
65 | #ifdef __cplusplus | 42 | #ifdef __cplusplus |
66 | } | 43 | } | ... | ... |
libargp/pam.c
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 3 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General | ||
15 | Public License along with this library; if not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | Boston, MA 02110-1301 USA */ | ||
18 | |||
19 | #ifdef HAVE_CONFIG_H | ||
20 | # include <config.h> | ||
21 | #endif | ||
22 | |||
23 | #include "cmdline.h" | ||
24 | #include <mailutils/pam.h> | ||
25 | |||
26 | static char *service_name; | ||
27 | |||
28 | static error_t | ||
29 | mu_pam_argp_parser (int key, char *arg, struct argp_state *state) | ||
30 | { | ||
31 | switch (key) | ||
32 | { | ||
33 | case OPT_PAM_SERVICE: | ||
34 | service_name = arg; | ||
35 | break; | ||
36 | |||
37 | case ARGP_KEY_FINI: | ||
38 | mu_gocs_store ("pam", service_name); | ||
39 | break; | ||
40 | |||
41 | default: | ||
42 | return ARGP_ERR_UNKNOWN; | ||
43 | } | ||
44 | return 0; | ||
45 | } | ||
46 | |||
47 | static struct argp_option mu_pam_argp_option[] = { | ||
48 | { "pam-service", OPT_PAM_SERVICE, N_("STRING"), OPTION_HIDDEN, | ||
49 | N_("Use STRING as PAM service name"), 0}, | ||
50 | { NULL, 0, NULL, 0, NULL, 0 } | ||
51 | }; | ||
52 | |||
53 | static struct argp mu_pam_argp = { | ||
54 | mu_pam_argp_option, | ||
55 | mu_pam_argp_parser, | ||
56 | }; | ||
57 | |||
58 | struct argp_child mu_pam_argp_child = { | ||
59 | &mu_pam_argp, | ||
60 | 0, | ||
61 | NULL, | ||
62 | 0 | ||
63 | }; | ||
64 | |||
65 | struct mu_cmdline_capa mu_pam_cmdline = { | ||
66 | "pam", &mu_pam_argp_child | ||
67 | }; |
libargp/radius.c
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 3 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General | ||
15 | Public License along with this library; if not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | Boston, MA 02110-1301 USA */ | ||
18 | |||
19 | #ifdef HAVE_CONFIG_H | ||
20 | # include <config.h> | ||
21 | #endif | ||
22 | |||
23 | #include "cmdline.h" | ||
24 | #include <mailutils/radius.h> | ||
25 | |||
26 | static struct argp_option mu_radius_argp_option[] = { | ||
27 | { "radius-auth-request", OPT_AUTH_REQUEST, N_("REQUEST"), OPTION_HIDDEN, | ||
28 | N_("Radius request to authenitcate the user"), 0 }, | ||
29 | { "radius-getpwnam-request", OPT_GETPWNAM_REQUEST, N_("REQUEST"), OPTION_HIDDEN, | ||
30 | N_("Radius request to retrieve a passwd entry based on username"), 0 }, | ||
31 | { "radius-getpwuid-request", OPT_GETPWUID_REQUEST, N_("REQUEST"), OPTION_HIDDEN, | ||
32 | N_("Radius request to retrieve a passwd entry based on UID"), 0 }, | ||
33 | { "radius-directory", OPT_RADIUS_DIR, N_("DIR"), OPTION_HIDDEN, | ||
34 | N_("Set path to the radius configuration directory"), 0 }, | ||
35 | { NULL } | ||
36 | }; | ||
37 | |||
38 | |||
39 | static struct mu_radius_module_data radius_data; | ||
40 | |||
41 | static error_t | ||
42 | mu_radius_argp_parser (int key, char *arg, struct argp_state *state) | ||
43 | { | ||
44 | switch (key) | ||
45 | { | ||
46 | case OPT_AUTH_REQUEST: | ||
47 | radius_data.auth_request = arg; | ||
48 | break; | ||
49 | |||
50 | case OPT_GETPWNAM_REQUEST: | ||
51 | radius_data.getpwnam_request = arg; | ||
52 | break; | ||
53 | |||
54 | case OPT_GETPWUID_REQUEST: | ||
55 | radius_data.getpwuid_request = arg; | ||
56 | break; | ||
57 | |||
58 | case OPT_RADIUS_DIR: | ||
59 | radius_data.config_dir = arg; | ||
60 | break; | ||
61 | |||
62 | case ARGP_KEY_FINI: | ||
63 | mu_gocs_store ("radius", &radius_data); | ||
64 | break; | ||
65 | |||
66 | default: | ||
67 | return ARGP_ERR_UNKNOWN; | ||
68 | } | ||
69 | return 0; | ||
70 | } | ||
71 | |||
72 | static struct argp mu_radius_argp = { | ||
73 | mu_radius_argp_option, | ||
74 | mu_radius_argp_parser, | ||
75 | }; | ||
76 | |||
77 | struct argp_child mu_radius_argp_child = { | ||
78 | &mu_radius_argp, | ||
79 | 0, | ||
80 | NULL, | ||
81 | 0 | ||
82 | }; | ||
83 | |||
84 | struct mu_cmdline_capa mu_radius_cmdline = { | ||
85 | "radius", &mu_radius_argp_child | ||
86 | }; |
... | @@ -20,74 +20,53 @@ | ... | @@ -20,74 +20,53 @@ |
20 | #ifdef HAVE_CONFIG_H | 20 | #ifdef HAVE_CONFIG_H |
21 | # include <config.h> | 21 | # include <config.h> |
22 | #endif | 22 | #endif |
23 | #include <sieve.h> | 23 | #include "cmdline.h" |
24 | #include <mailutils/argp.h> | 24 | #include "mailutils/libsieve.h" |
25 | #include <string.h> | ||
26 | 25 | ||
27 | mu_list_t mu_sieve_include_path = NULL; | ||
28 | mu_list_t mu_sieve_library_path = NULL; | ||
29 | 26 | ||
30 | static error_t sieve_argp_parser (int key, char *arg, struct argp_state *state); | ||
31 | |||
32 | #define CLEARPATH_OPTION 256 | ||
33 | |||
34 | /* Options used by programs that use extended authentication mechanisms. */ | ||
35 | static struct argp_option sieve_argp_option[] = { | 27 | static struct argp_option sieve_argp_option[] = { |
36 | { "includedir", 'I', N_("DIR"), 0, | 28 | { "includedir", 'I', N_("DIR"), 0, |
37 | N_("Append directory DIR to the list of directories searched for include files"), 0 }, | 29 | N_("Append directory DIR to the list of directories searched for include files"), 0 }, |
38 | { "libdir", 'L', N_("DIR"), 0, | 30 | { "libdir", 'L', N_("DIR"), 0, |
39 | N_("Append directory DIR to the list of directories searched for library files"), 0 }, | 31 | N_("Append directory DIR to the list of directories searched for library files"), 0 }, |
40 | { "clearpath", CLEARPATH_OPTION, NULL, 0, | 32 | { "clear-include-path", OPT_CLEAR_INCLUDE_PATH, NULL, 0, |
41 | N_("Clear Sieve load path"), 0 }, | 33 | N_("Clear Sieve include path"), 0 }, |
34 | { "clear-library-path", OPT_CLEAR_LIBRARY_PATH, NULL, 0, | ||
35 | N_("Clear Sieve lobrary path"), 0 }, | ||
36 | { "clearpath", 0, NULL, OPTION_ALIAS, NULL }, | ||
42 | { NULL, 0, NULL, 0, NULL, 0 } | 37 | { NULL, 0, NULL, 0, NULL, 0 } |
43 | }; | 38 | }; |
44 | 39 | ||
45 | static struct argp sieve_argp = { | ||
46 | sieve_argp_option, | ||
47 | sieve_argp_parser, | ||
48 | }; | ||
49 | |||
50 | static struct argp_child sieve_argp_child = { | ||
51 | &sieve_argp, | ||
52 | 0, | ||
53 | "Sieve options", | ||
54 | 0 | ||
55 | }; | ||
56 | |||
57 | static void | ||
58 | destroy_string (void *str) | ||
59 | { | ||
60 | free (str); | ||
61 | } | ||
62 | |||
63 | static error_t | 40 | static error_t |
64 | sieve_argp_parser (int key, char *arg, struct argp_state *state) | 41 | sieve_argp_parser (int key, char *arg, struct argp_state *state) |
65 | { | 42 | { |
43 | static struct mu_gocs_sieve gocs_data; | ||
66 | mu_list_t *plist = NULL; | 44 | mu_list_t *plist = NULL; |
67 | 45 | ||
68 | switch (key) | 46 | switch (key) |
69 | { | 47 | { |
70 | case 'I': | 48 | case 'I': |
71 | plist = &mu_sieve_include_path; | 49 | plist = &gocs_data.include_path; |
72 | break; | 50 | break; |
73 | 51 | ||
74 | case 'L': | 52 | case 'L': |
75 | plist = &mu_sieve_library_path; | 53 | plist = &gocs_data.library_path; |
54 | break; | ||
55 | |||
56 | case OPT_CLEAR_INCLUDE_PATH: | ||
57 | gocs_data.clearflags |= MU_SIEVE_CLEAR_INCLUDE_PATH; | ||
76 | break; | 58 | break; |
77 | 59 | ||
78 | case CLEARPATH_OPTION: | 60 | case OPT_CLEAR_LIBRARY_PATH: |
79 | mu_list_destroy (&mu_sieve_library_path); | 61 | gocs_data.clearflags |= MU_SIEVE_CLEAR_LIBRARY_PATH; |
80 | break; | 62 | break; |
81 | 63 | ||
82 | case ARGP_KEY_INIT: | 64 | case ARGP_KEY_INIT: |
83 | #ifdef SIEVE_MODDIR | 65 | memset (&gocs_data, 0, sizeof gocs_data); |
84 | plist = &mu_sieve_library_path; | ||
85 | arg = SIEVE_MODDIR; | ||
86 | #endif | ||
87 | break; | 66 | break; |
88 | 67 | ||
89 | case ARGP_KEY_FINI: | 68 | case ARGP_KEY_FINI: |
90 | sieve_load_add_path (mu_sieve_library_path); | 69 | mu_gocs_store ("sieve", &gocs_data); |
91 | break; | 70 | break; |
92 | 71 | ||
93 | default: | 72 | default: |
... | @@ -101,24 +80,30 @@ sieve_argp_parser (int key, char *arg, struct argp_state *state) | ... | @@ -101,24 +80,30 @@ sieve_argp_parser (int key, char *arg, struct argp_state *state) |
101 | int rc = mu_list_create (plist); | 80 | int rc = mu_list_create (plist); |
102 | if (rc) | 81 | if (rc) |
103 | { | 82 | { |
104 | argp_error (state, "can't create list: %s", | 83 | argp_error (state, _("cannot create list: %s"), |
105 | mu_strerror (rc)); | 84 | mu_strerror (rc)); |
106 | exit (1); | 85 | exit (1); |
107 | } | 86 | } |
108 | mu_list_set_destroy_item (*plist, destroy_string); | ||
109 | } | 87 | } |
110 | mu_list_append (*plist, strdup (arg)); | 88 | mu_list_append (*plist, arg); |
111 | } | 89 | } |
112 | 90 | ||
113 | return 0; | 91 | return 0; |
114 | } | 92 | } |
115 | 93 | ||
116 | void | 94 | static struct argp sieve_argp = { |
117 | mu_sieve_argp_init () | 95 | sieve_argp_option, |
118 | { | 96 | sieve_argp_parser, |
119 | if (mu_register_capa ("sieve", &sieve_argp_child, NULL)) | 97 | }; |
120 | { | 98 | |
121 | mu_error ("INTERNAL ERROR: cannot register argp capability sieve"); | 99 | static struct argp_child sieve_argp_child = { |
122 | abort (); | 100 | &sieve_argp, |
123 | } | 101 | 0, |
124 | } | 102 | N_("Sieve options"), |
103 | 0 | ||
104 | }; | ||
105 | |||
106 | struct mu_cmdline_capa mu_sieve_cmdline = { | ||
107 | "sieve", &sieve_argp_child | ||
108 | }; | ||
109 | ... | ... |
libargp/sql.c
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 3 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General | ||
15 | Public License along with this library; if not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | Boston, MA 02110-1301 USA */ | ||
18 | |||
19 | #ifdef HAVE_CONFIG_H | ||
20 | # include <config.h> | ||
21 | #endif | ||
22 | |||
23 | #include "cmdline.h" | ||
24 | #include "mailutils/sql.h" | ||
25 | #include "mailutils/mutil.h" | ||
26 | |||
27 | static int sql_requested; | ||
28 | static struct mu_sql_module_config sql_config; | ||
29 | /* Command-line configuration */ | ||
30 | |||
31 | static struct argp_option mu_sql_argp_option[] = { | ||
32 | {"sql-interface", OPT_SQL_INTERFACE, N_("NAME"), OPTION_HIDDEN, | ||
33 | N_("Type of SQL interface to use"), }, | ||
34 | {"sql-getpwnam", OPT_SQL_GETPWNAM, N_("QUERY"), OPTION_HIDDEN, | ||
35 | N_("SQL query to retrieve a passwd entry based on username"), 0}, | ||
36 | {"sql-getpwuid", OPT_SQL_GETPWUID, N_("QUERY"), OPTION_HIDDEN, | ||
37 | N_("SQL query to retrieve a passwd entry based on UID"), 0}, | ||
38 | {"sql-getpass", OPT_SQL_GETPASS, N_("QUERY"), OPTION_HIDDEN, | ||
39 | N_("SQL query to retrieve a password from the database"), 0}, | ||
40 | {"sql-host", OPT_SQL_HOST, N_("HOSTNAME"), OPTION_HIDDEN, | ||
41 | N_("Name or IP of MySQL server to connect to"), 0}, | ||
42 | {"sql-user", OPT_SQL_USER, N_("NAME"), OPTION_HIDDEN, | ||
43 | N_("SQL user name"), 0}, | ||
44 | {"sql-passwd", OPT_SQL_PASSWD, N_("STRING"), OPTION_HIDDEN, | ||
45 | N_("SQL connection password"), 0}, | ||
46 | {"sql-db", OPT_SQL_DB, N_("STRING"), OPTION_HIDDEN, | ||
47 | N_("Name of the database to connect to"), 0}, | ||
48 | {"sql-port", OPT_SQL_PORT, N_("NUMBER"), OPTION_HIDDEN, | ||
49 | N_("Port to use"), 0}, | ||
50 | {"sql-password-type", OPT_SQL_MU_PASSWORD_TYPE, N_("STRING"), OPTION_HIDDEN, | ||
51 | N_("Type of password returned by --sql-getpass query. STRING is one of: plain, hash, scrambled"), 0}, | ||
52 | {"sql-field-map", OPT_SQL_FIELD_MAP, N_("MAP"), OPTION_HIDDEN, | ||
53 | N_("Declare a name translation map for SQL fields in results of sql-getpwnam and " | ||
54 | "sql-getpwuid queries"), 0}, | ||
55 | { NULL, 0, NULL, 0, NULL, 0 } | ||
56 | }; | ||
57 | |||
58 | static error_t | ||
59 | mu_sql_argp_parser (int key, char *arg, struct argp_state *state) | ||
60 | { | ||
61 | int rc, err; | ||
62 | |||
63 | switch (key) | ||
64 | { | ||
65 | case OPT_SQL_INTERFACE: | ||
66 | sql_config.interface = arg; | ||
67 | sql_requested = 1; | ||
68 | break; | ||
69 | |||
70 | case OPT_SQL_GETPWNAM: | ||
71 | sql_requested = 1; | ||
72 | sql_config.getpwnam_query = arg; | ||
73 | break; | ||
74 | |||
75 | case OPT_SQL_GETPWUID: | ||
76 | sql_requested = 1; | ||
77 | sql_config.getpwuid_query = arg; | ||
78 | break; | ||
79 | |||
80 | case OPT_SQL_GETPASS: | ||
81 | sql_requested = 1; | ||
82 | sql_config.getpass_query = arg; | ||
83 | break; | ||
84 | |||
85 | case OPT_SQL_HOST: | ||
86 | sql_requested = 1; | ||
87 | sql_config.host = arg; | ||
88 | break; | ||
89 | |||
90 | case OPT_SQL_USER: | ||
91 | sql_requested = 1; | ||
92 | sql_config.user = arg; | ||
93 | break; | ||
94 | |||
95 | case OPT_SQL_PASSWD: | ||
96 | sql_requested = 1; | ||
97 | sql_config.passwd = arg; | ||
98 | break; | ||
99 | |||
100 | case OPT_SQL_DB: | ||
101 | sql_requested = 1; | ||
102 | sql_config.db = arg; | ||
103 | break; | ||
104 | |||
105 | case OPT_SQL_PORT: | ||
106 | sql_requested = 1; | ||
107 | sql_config.port = strtoul (arg, NULL, 0); | ||
108 | break; | ||
109 | |||
110 | case OPT_SQL_MU_PASSWORD_TYPE: | ||
111 | if (mu_sql_decode_password_type (arg, &sql_config.password_type)) | ||
112 | argp_error (state, _("Unknown password type `%s'"), arg); | ||
113 | sql_requested = 1; | ||
114 | break; | ||
115 | |||
116 | case OPT_SQL_FIELD_MAP: | ||
117 | rc = mutil_parse_field_map (arg, &sql_config.field_map, &err); | ||
118 | if (rc) | ||
119 | argp_error (state, _("Error near element %d: %s"), | ||
120 | err, mu_strerror (rc)); | ||
121 | sql_requested = 1; | ||
122 | break; | ||
123 | |||
124 | case ARGP_KEY_FINI: | ||
125 | if (sql_requested) | ||
126 | mu_gocs_store ("sql", &sql_config); | ||
127 | break; | ||
128 | |||
129 | default: | ||
130 | return ARGP_ERR_UNKNOWN; | ||
131 | } | ||
132 | return 0; | ||
133 | } | ||
134 | |||
135 | static struct argp mu_sql_argp = { | ||
136 | mu_sql_argp_option, | ||
137 | mu_sql_argp_parser, | ||
138 | }; | ||
139 | |||
140 | struct argp_child mu_sql_argp_child = { | ||
141 | &mu_sql_argp, | ||
142 | 0, | ||
143 | NULL, | ||
144 | 0 | ||
145 | }; | ||
146 | |||
147 | struct mu_cmdline_capa mu_sql_cmdline = { | ||
148 | "sql", &mu_sql_argp_child | ||
149 | }; |
libargp/tls.c
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 3 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General | ||
15 | Public License along with this library; if not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | Boston, MA 02110-1301 USA */ | ||
18 | |||
19 | #ifdef HAVE_CONFIG_H | ||
20 | # include <config.h> | ||
21 | #endif | ||
22 | |||
23 | #include "cmdline.h" | ||
24 | #include <mailutils/tls.h> | ||
25 | #include "strcase.h" /* FIXME */ | ||
26 | |||
27 | static struct argp_option _tls_argp_options[] = { | ||
28 | {"ssl-cert", OPT_SSL_CERT, N_("FILE"), OPTION_HIDDEN, | ||
29 | N_("Specify SSL certificate file"), 0}, | ||
30 | {"ssl-key", OPT_SSL_KEY, N_("FILE"), OPTION_HIDDEN, | ||
31 | N_("Specify SSL certificate key"), }, | ||
32 | {"ssl-cafile", OPT_SSL_CAFILE, N_("FILE"), OPTION_HIDDEN, | ||
33 | N_("Specify trusted CAs file"), 0}, | ||
34 | {"tls", OPT_TLS, N_("BOOL"), OPTION_ARG_OPTIONAL, | ||
35 | N_("Enable TLS support") }, | ||
36 | {NULL, 0, NULL, 0, NULL, 0} | ||
37 | }; | ||
38 | |||
39 | static struct mu_tls_module_config tls_data = { 1, }; | ||
40 | |||
41 | static error_t | ||
42 | _tls_argp_parser (int key, char *arg, struct argp_state *state) | ||
43 | { | ||
44 | switch (key) | ||
45 | { | ||
46 | case OPT_TLS: | ||
47 | if (!arg || strcasecmp (arg, "yes") == 0) | ||
48 | tls_data.client_enable = 1; | ||
49 | else if (strcasecmp (arg, "no") == 0) | ||
50 | tls_data.client_enable = 0; | ||
51 | break; | ||
52 | |||
53 | case OPT_SSL_CERT: | ||
54 | tls_data.ssl_cert = arg; | ||
55 | break; | ||
56 | |||
57 | case OPT_SSL_KEY: | ||
58 | tls_data.ssl_key = arg; | ||
59 | break; | ||
60 | |||
61 | case OPT_SSL_CAFILE: | ||
62 | tls_data.ssl_cafile = arg; | ||
63 | break; | ||
64 | |||
65 | case ARGP_KEY_FINI: | ||
66 | mu_gocs_store ("tls", &tls_data); | ||
67 | break; | ||
68 | |||
69 | default: | ||
70 | return ARGP_ERR_UNKNOWN; | ||
71 | } | ||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | static struct argp _tls_argp = { | ||
76 | _tls_argp_options, | ||
77 | _tls_argp_parser | ||
78 | }; | ||
79 | |||
80 | static struct argp_child _tls_argp_child = { | ||
81 | &_tls_argp, | ||
82 | 0, | ||
83 | NULL, | ||
84 | 0 | ||
85 | }; | ||
86 | |||
87 | struct mu_cmdline_capa mu_tls_cmdline = { | ||
88 | "tls", &_tls_argp_child | ||
89 | }; | ||
90 |
libargp/virtdomain.c
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 3 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General | ||
15 | Public License along with this library; if not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | Boston, MA 02110-1301 USA */ | ||
18 | |||
19 | #ifdef HAVE_CONFIG_H | ||
20 | # include <config.h> | ||
21 | #endif | ||
22 | |||
23 | #include "cmdline.h" | ||
24 | |||
25 | static char *virtdir; | ||
26 | |||
27 | static error_t | ||
28 | mu_virt_argp_parser (int key, char *arg, struct argp_state *state) | ||
29 | { | ||
30 | switch (key) | ||
31 | { | ||
32 | case OPT_PWDDIR: | ||
33 | virtdir = arg; | ||
34 | break; | ||
35 | |||
36 | case ARGP_KEY_FINI: | ||
37 | mu_gocs_store ("virtdomain", virtdir); | ||
38 | break; | ||
39 | |||
40 | default: | ||
41 | return ARGP_ERR_UNKNOWN; | ||
42 | } | ||
43 | return 0; | ||
44 | } | ||
45 | |||
46 | static struct argp_option mu_virt_argp_option[] = { | ||
47 | { "virtual-passwd-dir", OPT_PWDDIR, N_("DIR"), OPTION_HIDDEN, | ||
48 | N_("Search for virtual passwd file in DIR"), 0}, | ||
49 | { NULL, 0, NULL, 0, NULL, 0 } | ||
50 | }; | ||
51 | |||
52 | static struct argp mu_virt_argp = { | ||
53 | mu_virt_argp_option, | ||
54 | mu_virt_argp_parser, | ||
55 | }; | ||
56 | |||
57 | struct argp_child mu_virt_argp_child = { | ||
58 | &mu_virt_argp, | ||
59 | 0, | ||
60 | NULL, | ||
61 | 0 | ||
62 | }; | ||
63 | |||
64 | struct mu_cmdline_capa mu_virtdomain_cmdline = { | ||
65 | "virtdomain", &mu_virt_argp_child | ||
66 | }; |
libcfg/Makefile.am
0 → 100644
1 | # This file is part of GNU Mailutils | ||
2 | # Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | # | ||
4 | # GNU Mailutils is free software; you can redistribute it and/or | ||
5 | # modify it under the terms of the GNU General Public License as | ||
6 | # published by the Free Software Foundation; either version 3, or (at | ||
7 | # your option) any later version. | ||
8 | # | ||
9 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
10 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | # General Public License for more details. | ||
13 | # | ||
14 | # You should have received a copy of the GNU General Public License | ||
15 | # along with GNU Mailutils; if not, write to the Free Software | ||
16 | # Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | # 02110-1301 USA | ||
18 | |||
19 | INCLUDES = @MU_COMMON_INCLUDES@ | ||
20 | AM_CFLAGS = -DSITE_VIRTUAL_PWDDIR=\"@SITE_VIRTUAL_PWDDIR@\" \ | ||
21 | -DSITE_CRAM_MD5_PWD=\"@SITE_CRAM_MD5_PWD@\" | ||
22 | |||
23 | lib_LTLIBRARIES = libmucfg.la | ||
24 | noinst_HEADERS = libcfg.h | ||
25 | libmucfg_la_SOURCES=\ | ||
26 | auth.c\ | ||
27 | common.c\ | ||
28 | init.c\ | ||
29 | gsasl.c\ | ||
30 | pam.c\ | ||
31 | radius.c\ | ||
32 | sieve.c\ | ||
33 | sql.c\ | ||
34 | tls.c\ | ||
35 | virtdomain.c |
libcfg/auth.c
0 → 100644
1 | /* This file is part of GNU Mailutils | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | GNU Mailutils is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU General Public License as | ||
6 | published by the Free Software Foundation; either version 3, or (at | ||
7 | your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, but | ||
10 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #include "libcfg.h" | ||
19 | #include <mailutils/mu_auth.h> | ||
20 | #include <string.h> | ||
21 | |||
22 | /* FIXME: mu_auth.c should be reviewed */ | ||
23 | |||
24 | |||
25 | /* ************************************************************************* */ | ||
26 | /* Resource-style configuration */ | ||
27 | /* ************************************************************************* */ | ||
28 | static int | ||
29 | cb_authentication (mu_cfg_locus_t *locus, void *data, char *arg) | ||
30 | { | ||
31 | if (strcmp (arg, "clear") == 0) | ||
32 | mu_authentication_clear_list (); | ||
33 | else | ||
34 | mu_authentication_add_module_list (arg);/*FIXME: error reporting*/ | ||
35 | return 0; | ||
36 | } | ||
37 | |||
38 | static int | ||
39 | cb_authorization (mu_cfg_locus_t *locus, void *data, char *arg) | ||
40 | { | ||
41 | if (strcmp (arg, "clear") == 0) | ||
42 | mu_authorization_clear_list (); | ||
43 | else | ||
44 | mu_authorization_add_module_list (arg); | ||
45 | return 0; | ||
46 | } | ||
47 | |||
48 | static struct mu_cfg_param mu_auth_param[] = { | ||
49 | { "authentication", mu_cfg_callback, NULL, cb_authentication }, | ||
50 | { "authorization", mu_cfg_callback, NULL, cb_authorization }, | ||
51 | { NULL } | ||
52 | }; | ||
53 | |||
54 | /* FIXME: init? */ | ||
55 |
libcfg/common.c
0 → 100644
1 | /* This file is part of GNU Mailutils | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | GNU Mailutils is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU General Public License as | ||
6 | published by the Free Software Foundation; either version 3, or (at | ||
7 | your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, but | ||
10 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #include "libcfg.h" | ||
19 | #include <string.h> | ||
20 | #include <mailutils/daemon.h> | ||
21 | |||
22 | static struct mu_gocs_daemon daemon_settings; | ||
23 | static struct mu_gocs_locking locking_settings; | ||
24 | static struct mu_gocs_logging logging_settings; | ||
25 | static struct mu_gocs_mailbox mailbox_settings; | ||
26 | static struct mu_gocs_source_email address_settings; | ||
27 | static struct mu_gocs_mailer mailer_settings; | ||
28 | |||
29 | |||
30 | /* ************************************************************************* */ | ||
31 | /* Mailbox */ | ||
32 | /* ************************************************************************* */ | ||
33 | |||
34 | static struct mu_cfg_param mu_mailbox_param[] = { | ||
35 | { "mail-spool", mu_cfg_string, &mailbox_settings.mail_spool }, | ||
36 | { "mailbox-type", mu_cfg_string, &mailbox_settings.mailbox_type }, | ||
37 | { NULL } | ||
38 | }; | ||
39 | |||
40 | DCL_CFG_CAPA (mailbox); | ||
41 | |||
42 | |||
43 | /* ************************************************************************* */ | ||
44 | /* Locking */ | ||
45 | /* ************************************************************************* */ | ||
46 | |||
47 | static struct mu_cfg_param mu_locking_param[] = { | ||
48 | { "lock-flags", mu_cfg_string, &locking_settings.lock_flags }, | ||
49 | { "lock-retry-timeout", mu_cfg_ulong, &locking_settings.lock_retry_timeout }, | ||
50 | { "lock-retry-count", mu_cfg_ulong, &locking_settings.lock_retry_count }, | ||
51 | { "lock-expire-timeout", mu_cfg_ulong, | ||
52 | &locking_settings.lock_expire_timeout }, | ||
53 | { "external-locker", mu_cfg_string, &locking_settings.external_locker }, | ||
54 | { NULL, } | ||
55 | }; | ||
56 | |||
57 | DCL_CFG_CAPA (locking); | ||
58 | |||
59 | |||
60 | /* ************************************************************************* */ | ||
61 | /* Address */ | ||
62 | /* ************************************************************************* */ | ||
63 | |||
64 | static struct mu_cfg_param mu_address_param[] = { | ||
65 | { "email-addr", mu_cfg_string, &address_settings.address }, | ||
66 | { "email-domain", mu_cfg_string, &address_settings.domain }, | ||
67 | { NULL } | ||
68 | }; | ||
69 | |||
70 | DCL_CFG_CAPA (address); | ||
71 | |||
72 | |||
73 | /* ************************************************************************* */ | ||
74 | /* Mailer */ | ||
75 | /* ************************************************************************* */ | ||
76 | |||
77 | static struct mu_cfg_param mu_mailer_param[] = { | ||
78 | { "url", mu_cfg_string, &mailer_settings.mailer }, | ||
79 | { NULL } | ||
80 | }; | ||
81 | |||
82 | DCL_CFG_CAPA (mailer); | ||
83 | |||
84 | |||
85 | /* ************************************************************************* */ | ||
86 | /* Logging */ | ||
87 | /* ************************************************************************* */ | ||
88 | |||
89 | static struct mu_cfg_param mu_logging_param[] = { | ||
90 | { "facility", mu_cfg_string, &logging_settings.facility }, | ||
91 | { NULL } | ||
92 | }; | ||
93 | |||
94 | DCL_CFG_CAPA (logging); | ||
95 | |||
96 | |||
97 | /* ************************************************************************* */ | ||
98 | /* Daemon */ | ||
99 | /* ************************************************************************* */ | ||
100 | |||
101 | static int | ||
102 | _cb_daemon_mode (mu_cfg_locus_t *locus, void *data, char *arg) | ||
103 | { | ||
104 | if (strcmp (arg, "inetd") == 0 | ||
105 | || strcmp (arg, "interactive") == 0) | ||
106 | daemon_settings.mode = MODE_INTERACTIVE; | ||
107 | else if (strcmp (arg, "daemon") == 0) | ||
108 | daemon_settings.mode = MODE_DAEMON; | ||
109 | else | ||
110 | { | ||
111 | mu_error ("%s:%d: unknown daemon mode", locus->file, locus->line); | ||
112 | return 1; | ||
113 | } | ||
114 | return 0; | ||
115 | } | ||
116 | |||
117 | static struct mu_cfg_param mu_daemon_param[] = { | ||
118 | { "max-children", mu_cfg_ulong, &daemon_settings.maxchildren }, | ||
119 | { "mode", mu_cfg_callback, NULL, _cb_daemon_mode }, | ||
120 | { "transcript", mu_cfg_bool, &daemon_settings.transcript }, | ||
121 | { "pidfile", mu_cfg_string, &daemon_settings.pidfile }, | ||
122 | { "port", mu_cfg_ushort, &daemon_settings.port }, | ||
123 | { "timeout", mu_cfg_ulong, &daemon_settings.timeout }, | ||
124 | { NULL } | ||
125 | }; | ||
126 |
libcfg/gsasl.c
0 → 100644
1 | /* This file is part of GNU Mailutils | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | GNU Mailutils is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU General Public License as | ||
6 | published by the Free Software Foundation; either version 3, or (at | ||
7 | your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, but | ||
10 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #include "libcfg.h" | ||
19 | #include <mailutils/gsasl.h> | ||
20 | |||
21 | static struct mu_gsasl_module_data gsasl_settings; | ||
22 | |||
23 | static struct mu_cfg_param mu_gsasl_param[] = { | ||
24 | { "cram-passwd", mu_cfg_string, &gsasl_settings.cram_md5_pwd }, | ||
25 | { NULL } | ||
26 | }; | ||
27 | |||
28 | DCL_CFG_CAPA (gsasl); | ||
29 | |||
30 |
libcfg/init.c
0 → 100644
1 | /* This file is part of GNU Mailutils | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | GNU Mailutils is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU General Public License as | ||
6 | published by the Free Software Foundation; either version 3, or (at | ||
7 | your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, but | ||
10 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #include "libcfg.h" | ||
19 | #include <string.h> | ||
20 | #include <stdlib.h> | ||
21 | |||
22 | struct mu_cfg_capa *cfg_capa_table[] = { | ||
23 | #define S(c) &__mu_common_cat3__(mu_,c,_cfg_capa) | ||
24 | S (mailbox), | ||
25 | S (locking), | ||
26 | S (address), | ||
27 | S (mailer), | ||
28 | S (logging), | ||
29 | S (gsasl), | ||
30 | S (pam), | ||
31 | S (radius), | ||
32 | S (sql), | ||
33 | S (tls), | ||
34 | S (virtdomain), | ||
35 | NULL | ||
36 | }; | ||
37 | |||
38 | struct mu_cfg_capa * | ||
39 | find_cfg_capa (const char *name) | ||
40 | { | ||
41 | int i; | ||
42 | |||
43 | for (i = 0; cfg_capa_table[i]; i++) | ||
44 | if (strcmp (cfg_capa_table[i]->name, name) == 0) | ||
45 | return cfg_capa_table[i]; | ||
46 | return NULL; | ||
47 | } | ||
48 | |||
49 | static int | ||
50 | reserved_name (const char *name) | ||
51 | { | ||
52 | static char *reserved[] = { "auth", "common", "daemon", "license", NULL }; | ||
53 | char **p; | ||
54 | for (p = reserved; *p; p++) | ||
55 | if (strcmp (name, *p) == 0) | ||
56 | return 1; | ||
57 | return 0; | ||
58 | } | ||
59 | |||
60 | void | ||
61 | mu_libcfg_init (const char **cnames) | ||
62 | { | ||
63 | int i; | ||
64 | for (i = 0; cnames[i]; i++) | ||
65 | { | ||
66 | if (!reserved_name (cnames[i])) | ||
67 | { | ||
68 | struct mu_cfg_capa *cp = find_cfg_capa (cnames[i]); | ||
69 | if (!cp) | ||
70 | mu_error (_("Requested unknown configuration group `%s'"), | ||
71 | cnames[i]); | ||
72 | else | ||
73 | mu_config_register_section (NULL, cp->name, cp->parser, NULL, | ||
74 | cp->cfgparam); | ||
75 | } | ||
76 | } | ||
77 | } | ||
78 | |||
79 | int | ||
80 | mu_parse_config_files (struct mu_cfg_param *param) | ||
81 | { | ||
82 | if (mu_load_site_rcfile) | ||
83 | mu_parse_config (MU_CONFIG_FILE, mu_program_name, param, 1); | ||
84 | |||
85 | if (mu_load_user_rcfile && mu_program_name) | ||
86 | { | ||
87 | size_t size = 3 + strlen (mu_program_name) + 1; | ||
88 | char *file_name = malloc (size); | ||
89 | if (file_name) | ||
90 | { | ||
91 | strcpy (file_name, "~/."); | ||
92 | strcat (file_name, mu_program_name); | ||
93 | |||
94 | mu_parse_config (file_name, mu_program_name, param, 0); | ||
95 | |||
96 | free (file_name); | ||
97 | } | ||
98 | } | ||
99 | |||
100 | if (mu_load_rcfile) | ||
101 | mu_parse_config (mu_load_rcfile, mu_program_name, param, 0); | ||
102 | |||
103 | return 0; | ||
104 | } |
libcfg/libcfg.h
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | This library is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU Lesser General Public | ||
6 | License as published by the Free Software Foundation; either | ||
7 | version 3 of the License, or (at your option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | Lesser General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Lesser General | ||
15 | Public License along with this library; if not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | Boston, MA 02110-1301 USA */ | ||
18 | |||
19 | #ifdef HAVE_CONFIG_H | ||
20 | # include <config.h> | ||
21 | #endif | ||
22 | #include <mailutils/cfg.h> | ||
23 | #include <mailutils/gocs.h> | ||
24 | #include <mailutils/nls.h> | ||
25 | #include <mailutils/error.h> | ||
26 | #include <mailutils/errno.h> | ||
27 | |||
28 | #ifndef MU_CONFIG_FILE | ||
29 | # define MU_CONFIG_FILE SYSCONFDIR "/mailutils.rc" | ||
30 | #endif | ||
31 | |||
32 | #ifndef MU_USER_CONFIG_FILE | ||
33 | # define MU_USER_CONFIG_FILE "~/.mailutils" | ||
34 | #endif | ||
35 | |||
36 | struct mu_cfg_capa | ||
37 | { | ||
38 | char *name; | ||
39 | struct mu_cfg_param *cfgparam; | ||
40 | mu_cfg_section_fp parser; | ||
41 | }; | ||
42 | |||
43 | extern int mu_register_cfg_capa (const char *name, | ||
44 | struct mu_cfg_param *cfgparam, | ||
45 | mu_cfg_section_fp *parser); | ||
46 | |||
47 | extern void mu_libcfg_init (const char **cnames); | ||
48 | extern int mu_parse_config_files (struct mu_cfg_param *param); | ||
49 | |||
50 | #define __mu_common_cat2__(a,b) a ## b | ||
51 | #define __mu_common_cat3__(a,b,c) a ## b ## c | ||
52 | #define DCL_PARSER(capa) \ | ||
53 | int \ | ||
54 | __mu_common_cat3__(mu_,capa,_section_parser) \ | ||
55 | (enum mu_cfg_section_stage stage, const mu_cfg_node_t *node, \ | ||
56 | void *section_data, void *call_data) \ | ||
57 | { \ | ||
58 | switch (stage) \ | ||
59 | { \ | ||
60 | case mu_cfg_section_start: \ | ||
61 | break; \ | ||
62 | \ | ||
63 | case mu_cfg_section_end: \ | ||
64 | mu_gocs_store (#capa, &__mu_common_cat2__(capa, _settings)); \ | ||
65 | } \ | ||
66 | return 0; \ | ||
67 | } | ||
68 | |||
69 | #define DCL_DEFAULT_CFG_CAPA(capa) \ | ||
70 | struct mu_cfg_capa __mu_common_cat3__(mu_,capa,_cfg_capa) = { \ | ||
71 | #capa, \ | ||
72 | __mu_common_cat3__(mu_,capa,_param), \ | ||
73 | __mu_common_cat3__(mu_,capa,_section_parser) \ | ||
74 | } | ||
75 | |||
76 | #define DCL_CFG_CAPA(capa) \ | ||
77 | DCL_PARSER (capa) \ | ||
78 | DCL_DEFAULT_CFG_CAPA (capa) | ||
79 | |||
80 | extern struct mu_cfg_capa mu_mailbox_cfg_capa; | ||
81 | extern struct mu_cfg_capa mu_locking_cfg_capa; | ||
82 | extern struct mu_cfg_capa mu_address_cfg_capa; | ||
83 | extern struct mu_cfg_capa mu_mailer_cfg_capa; | ||
84 | extern struct mu_cfg_capa mu_logging_cfg_capa; | ||
85 | extern struct mu_cfg_capa mu_gsasl_cfg_capa; | ||
86 | extern struct mu_cfg_capa mu_pam_cfg_capa; | ||
87 | extern struct mu_cfg_capa mu_radius_cfg_capa; | ||
88 | extern struct mu_cfg_capa mu_sql_cfg_capa; | ||
89 | extern struct mu_cfg_capa mu_tls_cfg_capa; | ||
90 | extern struct mu_cfg_capa mu_virtdomain_cfg_capa; | ||
91 |
libcfg/pam.c
0 → 100644
1 | /* This file is part of GNU Mailutils | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | GNU Mailutils is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU General Public License as | ||
6 | published by the Free Software Foundation; either version 3, or (at | ||
7 | your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, but | ||
10 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #include "libcfg.h" | ||
19 | |||
20 | static char *pam_settings; | ||
21 | |||
22 | static struct mu_cfg_param mu_pam_param[] = { | ||
23 | { "service", mu_cfg_string, &pam_settings }, | ||
24 | { NULL } | ||
25 | }; | ||
26 | |||
27 | DCL_CFG_CAPA (pam); | ||
28 |
libcfg/radius.c
0 → 100644
1 | /* This file is part of GNU Mailutils | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | GNU Mailutils is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU General Public License as | ||
6 | published by the Free Software Foundation; either version 3, or (at | ||
7 | your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, but | ||
10 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #include "libcfg.h" | ||
19 | #include <mailutils/radius.h> | ||
20 | |||
21 | static struct mu_radius_module_data radius_settings; | ||
22 | |||
23 | static struct mu_cfg_param mu_radius_param[] = { | ||
24 | { "auth-request", mu_cfg_string, &radius_settings.auth_request }, | ||
25 | { "getpwnam-request", mu_cfg_string, &radius_settings.getpwnam_request }, | ||
26 | { "getpwuid-request", mu_cfg_string, &radius_settings.getpwuid_request }, | ||
27 | { "directory", mu_cfg_string, &radius_settings.config_dir }, | ||
28 | { NULL } | ||
29 | }; | ||
30 | |||
31 | DCL_CFG_CAPA (radius); |
libcfg/sieve.c
0 → 100644
1 | /* This file is part of GNU Mailutils | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | GNU Mailutils is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU General Public License as | ||
6 | published by the Free Software Foundation; either version 3, or (at | ||
7 | your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, but | ||
10 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #include "libcfg.h" | ||
19 | #include <mailutils/libsieve.h> | ||
20 | |||
21 | static struct mu_gocs_sieve sieve_settings; | ||
22 | |||
23 | static int | ||
24 | cb_clear_library_path (mu_cfg_locus_t *locus, void *data, char *arg) | ||
25 | { | ||
26 | int flag; | ||
27 | if (mu_cfg_parse_boolean (arg, &flag)) | ||
28 | { | ||
29 | mu_error ("%s:%u: %s", locus->file, locus->line, _("not a boolean")); | ||
30 | return 1; | ||
31 | } | ||
32 | if (flag) | ||
33 | sieve_settings.clearflags |= MU_SIEVE_CLEAR_LIBRARY_PATH; | ||
34 | return 0; | ||
35 | } | ||
36 | |||
37 | static int | ||
38 | cb_clear_include_path (mu_cfg_locus_t *locus, void *data, char *arg) | ||
39 | { | ||
40 | int flag; | ||
41 | if (mu_cfg_parse_boolean (arg, &flag)) | ||
42 | { | ||
43 | mu_error ("%s:%u: %s", locus->file, locus->line, _("not a boolean")); | ||
44 | return 1; | ||
45 | } | ||
46 | if (flag) | ||
47 | sieve_settings.clearflags |= MU_SIEVE_CLEAR_INCLUDE_PATH; | ||
48 | return 0; | ||
49 | } | ||
50 | |||
51 | static void | ||
52 | destroy_string (void *str) | ||
53 | { | ||
54 | free (str); | ||
55 | } | ||
56 | |||
57 | static int | ||
58 | _add_path (mu_list_t *plist, mu_cfg_locus_t *locus, void *data, char *arg) | ||
59 | { | ||
60 | char *p; | ||
61 | |||
62 | if (!*plist) | ||
63 | { | ||
64 | int rc = mu_list_create (plist); | ||
65 | if (rc) | ||
66 | { | ||
67 | mu_error (_("cannot create list: %s"), mu_strerror (rc)); | ||
68 | exit (1); | ||
69 | } | ||
70 | mu_list_set_destroy_item (*plist, destroy_string); | ||
71 | } | ||
72 | for (p = strtok (arg, ":"); p; p = strtok (NULL, ":")) | ||
73 | mu_list_append (*plist, strdup (p)); | ||
74 | return 0; | ||
75 | } | ||
76 | |||
77 | static int | ||
78 | cb_include_path (mu_cfg_locus_t *locus, void *data, char *arg) | ||
79 | { | ||
80 | return _add_path (&sieve_settings.include_path, locus, data, arg); | ||
81 | } | ||
82 | |||
83 | static int | ||
84 | cb_library_path (mu_cfg_locus_t *locus, void *data, char *arg) | ||
85 | { | ||
86 | return _add_path (&sieve_settings.library_path, locus, data, arg); | ||
87 | } | ||
88 | |||
89 | static struct mu_cfg_param mu_sieve_param[] = { | ||
90 | { "clear-library-path", mu_cfg_callback, NULL, cb_clear_library_path }, | ||
91 | { "clear-include-path", mu_cfg_callback, NULL, cb_clear_include_path }, | ||
92 | { "library-path", mu_cfg_callback, NULL, cb_library_path }, | ||
93 | { "include-path", mu_cfg_callback, NULL, cb_include_path }, | ||
94 | { NULL } | ||
95 | }; | ||
96 | |||
97 | DCL_CFG_CAPA (sieve); |
libcfg/sql.c
0 → 100644
1 | /* This file is part of GNU Mailutils | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | GNU Mailutils is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU General Public License as | ||
6 | published by the Free Software Foundation; either version 3, or (at | ||
7 | your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, but | ||
10 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #include "libcfg.h" | ||
19 | #include <mailutils/sql.h> | ||
20 | #include <mailutils/mutil.h> | ||
21 | |||
22 | static struct mu_sql_module_config sql_settings; | ||
23 | |||
24 | |||
25 | |||
26 | /* Resource file configuration */ | ||
27 | static int | ||
28 | cb_password_type (mu_cfg_locus_t *locus, void *data, char *arg) | ||
29 | { | ||
30 | if (mu_sql_decode_password_type (arg, &sql_settings.password_type)) | ||
31 | mu_error (_("%s:%d: Unknown password type `%s'"), | ||
32 | locus->file, locus->line, arg); | ||
33 | return 0; | ||
34 | } | ||
35 | |||
36 | static int | ||
37 | cb_field_map (mu_cfg_locus_t *locus, void *data, char *arg) | ||
38 | { | ||
39 | int err; | ||
40 | int rc = mutil_parse_field_map (arg, &sql_settings.field_map, &err); | ||
41 | if (rc) | ||
42 | mu_error (_("%s:%d: Error near element %d: %s"), | ||
43 | locus->file, locus->line, err, mu_strerror (rc)); | ||
44 | return 0; | ||
45 | } | ||
46 | |||
47 | static struct mu_cfg_param mu_sql_param[] = { | ||
48 | { "interface", mu_cfg_string, &sql_settings.interface }, | ||
49 | { "getwpnam", mu_cfg_string, &sql_settings.getpwnam_query }, | ||
50 | { "getpwuid", mu_cfg_string, &sql_settings.getpwuid_query }, | ||
51 | { "getpass", mu_cfg_string, &sql_settings.getpass_query }, | ||
52 | { "host", mu_cfg_string, &sql_settings.host }, | ||
53 | { "user", mu_cfg_string, &sql_settings.user }, | ||
54 | { "passwd", mu_cfg_string, &sql_settings.passwd }, | ||
55 | { "db", mu_cfg_string, &sql_settings.db }, | ||
56 | { "port", mu_cfg_int, &sql_settings.port }, | ||
57 | { "password-type", mu_cfg_callback, NULL, cb_password_type }, | ||
58 | { "field-map", mu_cfg_callback, NULL, cb_field_map }, | ||
59 | { NULL } | ||
60 | }; | ||
61 | |||
62 | DCL_CFG_CAPA (sql); | ||
63 | |||
64 |
libcfg/tls.c
0 → 100644
1 | /* This file is part of GNU Mailutils | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | GNU Mailutils is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU General Public License as | ||
6 | published by the Free Software Foundation; either version 3, or (at | ||
7 | your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, but | ||
10 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #include "libcfg.h" | ||
19 | #include <mailutils/tls.h> | ||
20 | |||
21 | static struct mu_tls_module_config tls_settings; | ||
22 | |||
23 | static struct mu_cfg_param mu_tls_param[] = { | ||
24 | { "tls", mu_cfg_bool, &tls_settings.client_enable }, | ||
25 | { "ssl-cert", mu_cfg_string, &tls_settings.ssl_cert }, | ||
26 | { "ssl-key", mu_cfg_string, &tls_settings.ssl_key }, | ||
27 | { "ssl-cafile", mu_cfg_string, &tls_settings.ssl_cafile }, | ||
28 | { NULL } | ||
29 | }; | ||
30 | |||
31 | DCL_CFG_CAPA (tls); | ||
32 |
libcfg/virtdomain.c
0 → 100644
1 | /* This file is part of GNU Mailutils | ||
2 | Copyright (C) 2007 Free Software Foundation, Inc. | ||
3 | |||
4 | GNU Mailutils is free software; you can redistribute it and/or | ||
5 | modify it under the terms of the GNU General Public License as | ||
6 | published by the Free Software Foundation; either version 3, or (at | ||
7 | your option) any later version. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, but | ||
10 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
12 | General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #include "libcfg.h" | ||
19 | |||
20 | static char *virtdomain_settings; | ||
21 | |||
22 | static struct mu_cfg_param mu_virtdomain_param[] = { | ||
23 | { "passwd-dir", mu_cfg_string, &virtdomain_settings }, | ||
24 | { NULL } | ||
25 | }; | ||
26 | |||
27 | DCL_CFG_CAPA (virtdomain); | ||
28 |
libsieve/conf.c
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 1999, 2000, 2001, 2002, 2005, | ||
3 | 2007 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 3 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General | ||
16 | Public License along with this library; if not, write to the | ||
17 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | Boston, MA 02110-1301 USA */ | ||
19 | |||
20 | #ifdef HAVE_CONFIG_H | ||
21 | # include <config.h> | ||
22 | #endif | ||
23 | #include <sieve.h> | ||
24 | #include <string.h> | ||
25 | |||
26 | mu_list_t mu_sieve_include_path = NULL; | ||
27 | mu_list_t mu_sieve_library_path = NULL; | ||
28 | |||
29 | static void | ||
30 | destroy_string (void *str) | ||
31 | { | ||
32 | free (str); | ||
33 | } | ||
34 | |||
35 | static int | ||
36 | _path_append (void *item, void *data) | ||
37 | { | ||
38 | mu_list_t *plist = data; | ||
39 | if (!*plist) | ||
40 | { | ||
41 | int rc = mu_list_create (plist); | ||
42 | if (rc) | ||
43 | { | ||
44 | mu_error (_("cannot create list: %s"), mu_strerror (rc)); | ||
45 | exit (1); | ||
46 | } | ||
47 | mu_list_set_destroy_item (*plist, destroy_string); | ||
48 | } | ||
49 | return mu_list_append (*plist, strdup (item)); | ||
50 | } | ||
51 | |||
52 | int | ||
53 | mu_sieve_module_init (void *data) | ||
54 | { | ||
55 | struct mu_gocs_sieve *p; | ||
56 | if (!data) | ||
57 | return 0; | ||
58 | p = data; | ||
59 | if (p->clearflags & MU_SIEVE_CLEAR_INCLUDE_PATH) | ||
60 | mu_list_destroy (&mu_sieve_include_path); | ||
61 | mu_list_do (p->include_path, _path_append, &mu_sieve_include_path); | ||
62 | if (p->clearflags & MU_SIEVE_CLEAR_LIBRARY_PATH) | ||
63 | mu_list_destroy (&mu_sieve_library_path); | ||
64 | mu_list_do (p->library_path, _path_append, &mu_sieve_library_path); | ||
65 | sieve_load_add_path (mu_sieve_library_path); | ||
66 | mu_list_destroy (&p->library_path); | ||
67 | mu_list_destroy (&p->include_path); | ||
68 | return 0; | ||
69 | } |
... | @@ -31,7 +31,7 @@ maidag_SOURCES=\ | ... | @@ -31,7 +31,7 @@ maidag_SOURCES=\ |
31 | maidag_LDADD = \ | 31 | maidag_LDADD = \ |
32 | @LIBMU_SCM@ @GUILE_LIBS@\ | 32 | @LIBMU_SCM@ @GUILE_LIBS@\ |
33 | @LIBMU_SCM_DEPS@\ | 33 | @LIBMU_SCM_DEPS@\ |
34 | ../lib/libmuaux.la \ | 34 | ${MU_APP_LIBRARIES}\ |
35 | ${MU_LIB_SIEVE}\ | 35 | ${MU_LIB_SIEVE}\ |
36 | ${MU_LIB_MBOX}\ | 36 | ${MU_LIB_MBOX}\ |
37 | ${MU_LIB_IMAP}\ | 37 | ${MU_LIB_IMAP}\ | ... | ... |
... | @@ -252,7 +252,7 @@ lmtp_reply (FILE *fp, char *code, char *enh, char *fmt, ...) | ... | @@ -252,7 +252,7 @@ lmtp_reply (FILE *fp, char *code, char *enh, char *fmt, ...) |
252 | vasprintf (&str, fmt, ap); | 252 | vasprintf (&str, fmt, ap); |
253 | va_end (ap); | 253 | va_end (ap); |
254 | 254 | ||
255 | if (daemon_param.transcript) | 255 | if (mu_gocs_daemon.transcript) |
256 | { | 256 | { |
257 | if (enh) | 257 | if (enh) |
258 | syslog (LOG_INFO, "LMTP reply: %s %s %s", code, enh, str); | 258 | syslog (LOG_INFO, "LMTP reply: %s %s %s", code, enh, str); |
... | @@ -737,7 +737,7 @@ lmtp_loop (FILE *in, FILE *out) | ... | @@ -737,7 +737,7 @@ lmtp_loop (FILE *in, FILE *out) |
737 | 737 | ||
738 | trimnl (buf); | 738 | trimnl (buf); |
739 | 739 | ||
740 | if (daemon_param.transcript) | 740 | if (mu_gocs_daemon.transcript) |
741 | syslog (LOG_INFO, "LMTP recieve: %s", buf); | 741 | syslog (LOG_INFO, "LMTP recieve: %s", buf); |
742 | 742 | ||
743 | if (next_state != state_none) | 743 | if (next_state != state_none) |
... | @@ -784,7 +784,7 @@ lmtp_daemon (char *urlstr) | ... | @@ -784,7 +784,7 @@ lmtp_daemon (char *urlstr) |
784 | socklen_t addrlen; | 784 | socklen_t addrlen; |
785 | pid_t pid; | 785 | pid_t pid; |
786 | 786 | ||
787 | if (daemon_param.mode == MODE_DAEMON) | 787 | if (mu_gocs_daemon.mode == MODE_DAEMON) |
788 | { | 788 | { |
789 | if (daemon (0, 0) < 0) | 789 | if (daemon (0, 0) < 0) |
790 | { | 790 | { |
... | @@ -819,7 +819,7 @@ lmtp_daemon (char *urlstr) | ... | @@ -819,7 +819,7 @@ lmtp_daemon (char *urlstr) |
819 | for (;;) | 819 | for (;;) |
820 | { | 820 | { |
821 | process_cleanup (); | 821 | process_cleanup (); |
822 | if (children > daemon_param.maxchildren) | 822 | if (children > mu_gocs_daemon.maxchildren) |
823 | { | 823 | { |
824 | mu_error (_("too many children (%lu)"), | 824 | mu_error (_("too many children (%lu)"), |
825 | (unsigned long) children); | 825 | (unsigned long) children); |
... | @@ -879,11 +879,11 @@ maidag_lmtp_server () | ... | @@ -879,11 +879,11 @@ maidag_lmtp_server () |
879 | 879 | ||
880 | if (lmtp_url_string) | 880 | if (lmtp_url_string) |
881 | return lmtp_daemon (lmtp_url_string); | 881 | return lmtp_daemon (lmtp_url_string); |
882 | else if (daemon_param.mode == MODE_INTERACTIVE) | 882 | else if (mu_gocs_daemon.mode == MODE_INTERACTIVE) |
883 | return lmtp_loop (stdin, stdout); | 883 | return lmtp_loop (stdin, stdout); |
884 | else | 884 | else |
885 | { | 885 | { |
886 | const char *pstr = mu_umaxtostr (0, daemon_param.port); | 886 | const char *pstr = mu_umaxtostr (0, mu_gocs_daemon.port); |
887 | char *urls = malloc (sizeof (DEFAULT_URL) + strlen (pstr)); | 887 | char *urls = malloc (sizeof (DEFAULT_URL) + strlen (pstr)); |
888 | if (!urls) | 888 | if (!urls) |
889 | { | 889 | { | ... | ... |
... | @@ -50,7 +50,7 @@ char *lmtp_url_string; | ... | @@ -50,7 +50,7 @@ char *lmtp_url_string; |
50 | int reuse_lmtp_address = 1; | 50 | int reuse_lmtp_address = 1; |
51 | char *lmtp_group = "mail"; | 51 | char *lmtp_group = "mail"; |
52 | 52 | ||
53 | struct daemon_param daemon_param = { | 53 | struct mu_gocs_daemon daemon_param = { |
54 | MODE_INTERACTIVE, /* Start in interactive (inetd) mode */ | 54 | MODE_INTERACTIVE, /* Start in interactive (inetd) mode */ |
55 | 20, /* Default maximum number of children */ | 55 | 20, /* Default maximum number of children */ |
56 | 0, /* No standard port */ | 56 | 0, /* No standard port */ |
... | @@ -111,7 +111,7 @@ static struct argp argp = { | ... | @@ -111,7 +111,7 @@ static struct argp argp = { |
111 | NULL, NULL | 111 | NULL, NULL |
112 | }; | 112 | }; |
113 | 113 | ||
114 | static const char *argp_capa[] = { | 114 | static const char *maidag_argp_capa[] = { |
115 | "daemon", | 115 | "daemon", |
116 | "auth", | 116 | "auth", |
117 | "common", | 117 | "common", |
... | @@ -119,7 +119,6 @@ static const char *argp_capa[] = { | ... | @@ -119,7 +119,6 @@ static const char *argp_capa[] = { |
119 | "logging", | 119 | "logging", |
120 | "mailbox", | 120 | "mailbox", |
121 | "mailer", | 121 | "mailer", |
122 | "sieve", | ||
123 | NULL | 122 | NULL |
124 | }; | 123 | }; |
125 | 124 | ||
... | @@ -255,10 +254,10 @@ struct mu_cfg_param maidag_cfg_param[] = { | ... | @@ -255,10 +254,10 @@ struct mu_cfg_param maidag_cfg_param[] = { |
255 | #ifdef USE_SQL | 254 | #ifdef USE_SQL |
256 | { "quota-query", mu_cfg_string, "a_query }, | 255 | { "quota-query", mu_cfg_string, "a_query }, |
257 | #endif | 256 | #endif |
258 | { "sieve", mu_cfg_string, &sieve_pattern }, | 257 | { "sieve-filter", mu_cfg_string, &sieve_pattern }, |
259 | { "message-id-header", mu_cfg_string, &message_id_header }, | 258 | { "message-id-header", mu_cfg_string, &message_id_header }, |
260 | #ifdef WITH_GUILE | 259 | #ifdef WITH_GUILE |
261 | { "source", mu_cfg_string, &progfile_pattern }, | 260 | { "guile-filter", mu_cfg_string, &progfile_pattern }, |
262 | #endif | 261 | #endif |
263 | { "debug", mu_cfg_callback, NULL, cb_debug }, | 262 | { "debug", mu_cfg_callback, NULL, cb_debug }, |
264 | { "stderr", mu_cfg_bool, &log_to_stderr }, | 263 | { "stderr", mu_cfg_bool, &log_to_stderr }, |
... | @@ -461,8 +460,6 @@ main (int argc, char *argv[]) | ... | @@ -461,8 +460,6 @@ main (int argc, char *argv[]) |
461 | mu_locker_set_default_retry_timeout (1); | 460 | mu_locker_set_default_retry_timeout (1); |
462 | mu_locker_set_default_retry_count (300); | 461 | mu_locker_set_default_retry_count (300); |
463 | 462 | ||
464 | /* Default error code for command line errors */ | ||
465 | mu_argp_error_code = EX_CONFIG; | ||
466 | /* Register needed modules */ | 463 | /* Register needed modules */ |
467 | MU_AUTH_REGISTER_ALL_MODULES (); | 464 | MU_AUTH_REGISTER_ALL_MODULES (); |
468 | 465 | ||
... | @@ -473,12 +470,13 @@ main (int argc, char *argv[]) | ... | @@ -473,12 +470,13 @@ main (int argc, char *argv[]) |
473 | mu_registrar_record (mu_sendmail_record); | 470 | mu_registrar_record (mu_sendmail_record); |
474 | mu_registrar_record (mu_smtp_record); | 471 | mu_registrar_record (mu_smtp_record); |
475 | 472 | ||
476 | mu_argp_init (program_version, NULL); | 473 | mu_gocs_register ("sieve", mu_sieve_module_init); |
477 | mu_sieve_argp_init (); | ||
478 | 474 | ||
479 | /* Parse command line */ | 475 | /* Parse command line */ |
480 | mu_argp_set_config_param (maidag_cfg_param); | 476 | mu_argp_init (program_version, NULL); |
481 | mu_argp_parse (&argp, &argc, &argv, 0, argp_capa, &arg_index, &daemon_param); | 477 | if (mu_app_init (&argp, maidag_argp_capa, maidag_cfg_param, |
478 | argc, argv, 0, &arg_index, NULL)) | ||
479 | exit (EX_CONFIG); | ||
482 | 480 | ||
483 | current_uid = getuid (); | 481 | current_uid = getuid (); |
484 | 482 | ... | ... |
... | @@ -82,6 +82,7 @@ | ... | @@ -82,6 +82,7 @@ |
82 | #include <mailutils/mu_auth.h> | 82 | #include <mailutils/mu_auth.h> |
83 | #include <mailutils/libsieve.h> | 83 | #include <mailutils/libsieve.h> |
84 | #include <mailutils/nls.h> | 84 | #include <mailutils/nls.h> |
85 | #include <mailutils/daemon.h> | ||
85 | 86 | ||
86 | #include <mu_dbm.h> | 87 | #include <mu_dbm.h> |
87 | #include <mu_asprintf.h> | 88 | #include <mu_asprintf.h> |
... | @@ -91,7 +92,8 @@ | ... | @@ -91,7 +92,8 @@ |
91 | # define USE_MAILBOX_QUOTAS 1 | 92 | # define USE_MAILBOX_QUOTAS 1 |
92 | #endif | 93 | #endif |
93 | 94 | ||
94 | #include <mailutils/argp.h> | 95 | #include "muinit.h" |
96 | |||
95 | /* Debug */ | 97 | /* Debug */ |
96 | extern int debug_level; | 98 | extern int debug_level; |
97 | #define dbg() if (debug_level) debug | 99 | #define dbg() if (debug_level) debug |
... | @@ -120,7 +122,6 @@ extern int lmtp_mode; | ... | @@ -120,7 +122,6 @@ extern int lmtp_mode; |
120 | extern char *lmtp_url_string; | 122 | extern char *lmtp_url_string; |
121 | extern int reuse_lmtp_address; | 123 | extern int reuse_lmtp_address; |
122 | extern char *lmtp_group; | 124 | extern char *lmtp_group; |
123 | extern struct daemon_param daemon_param; | ||
124 | 125 | ||
125 | void close_fds (void); | 126 | void close_fds (void); |
126 | int switch_user_id (struct mu_auth_data *auth, int user); | 127 | int switch_user_id (struct mu_auth_data *auth, int user); | ... | ... |
... | @@ -162,12 +162,12 @@ sql_retrieve_quota (char *name, mu_off_t *quota) | ... | @@ -162,12 +162,12 @@ sql_retrieve_quota (char *name, mu_off_t *quota) |
162 | return RETR_FAILURE; | 162 | return RETR_FAILURE; |
163 | 163 | ||
164 | status = mu_sql_connection_init (&conn, | 164 | status = mu_sql_connection_init (&conn, |
165 | sql_interface, | 165 | mu_sql_module_config.interface, |
166 | mu_sql_host, | 166 | mu_sql_module_config.host, |
167 | mu_sql_port, | 167 | mu_sql_module_config.port, |
168 | mu_sql_user, | 168 | mu_sql_module_config.user, |
169 | mu_sql_passwd, | 169 | mu_sql_module_config.passwd, |
170 | mu_sql_db); | 170 | mu_sql_module_config.db); |
171 | 171 | ||
172 | if (status) | 172 | if (status) |
173 | { | 173 | { | ... | ... |
... | @@ -26,7 +26,7 @@ mail_local_SOURCES = main.c mailquota.c script.c mail.local.h | ... | @@ -26,7 +26,7 @@ mail_local_SOURCES = main.c mailquota.c script.c mail.local.h |
26 | mail_local_LDADD = \ | 26 | mail_local_LDADD = \ |
27 | @LIBMU_SCM@ @GUILE_LIBS@\ | 27 | @LIBMU_SCM@ @GUILE_LIBS@\ |
28 | @LIBMU_SCM_DEPS@\ | 28 | @LIBMU_SCM_DEPS@\ |
29 | ../lib/libmuaux.la \ | 29 | ${MU_APP_LIBRARIES}\ |
30 | ${MU_LIB_SIEVE}\ | 30 | ${MU_LIB_SIEVE}\ |
31 | ${MU_LIB_MBOX}\ | 31 | ${MU_LIB_MBOX}\ |
32 | ${MU_LIB_IMAP}\ | 32 | ${MU_LIB_IMAP}\ | ... | ... |
... | @@ -92,7 +92,6 @@ | ... | @@ -92,7 +92,6 @@ |
92 | # define USE_MAILBOX_QUOTAS 1 | 92 | # define USE_MAILBOX_QUOTAS 1 |
93 | #endif | 93 | #endif |
94 | 94 | ||
95 | #include <mailutils/argp.h> | ||
96 | /* Debug */ | 95 | /* Debug */ |
97 | extern int debug_level; | 96 | extern int debug_level; |
98 | #define dbg() if (debug_level) debug | 97 | #define dbg() if (debug_level) debug | ... | ... |
... | @@ -162,12 +162,12 @@ sql_retrieve_quota (char *name, mu_off_t *quota) | ... | @@ -162,12 +162,12 @@ sql_retrieve_quota (char *name, mu_off_t *quota) |
162 | return RETR_FAILURE; | 162 | return RETR_FAILURE; |
163 | 163 | ||
164 | status = mu_sql_connection_init (&conn, | 164 | status = mu_sql_connection_init (&conn, |
165 | sql_interface, | 165 | mu_sql_module_config.interface, |
166 | mu_sql_host, | 166 | mu_sql_module_config.host, |
167 | mu_sql_port, | 167 | mu_sql_module_config.port, |
168 | mu_sql_user, | 168 | mu_sql_module_config.user, |
169 | mu_sql_passwd, | 169 | mu_sql_module_config.passwd, |
170 | mu_sql_db); | 170 | mu_sql_module_config.db); |
171 | 171 | ||
172 | if (status) | 172 | if (status) |
173 | { | 173 | { | ... | ... |
... | @@ -18,6 +18,7 @@ | ... | @@ -18,6 +18,7 @@ |
18 | MA 02110-1301 USA */ | 18 | MA 02110-1301 USA */ |
19 | 19 | ||
20 | #include <mail.local.h> | 20 | #include <mail.local.h> |
21 | #include "muinit.h" | ||
21 | 22 | ||
22 | int multiple_delivery; /* Don't return errors when delivering to multiple | 23 | int multiple_delivery; /* Don't return errors when delivering to multiple |
23 | recipients */ | 24 | recipients */ |
... | @@ -117,7 +118,6 @@ static const char *argp_capa[] = { | ... | @@ -117,7 +118,6 @@ static const char *argp_capa[] = { |
117 | "logging", | 118 | "logging", |
118 | "mailbox", | 119 | "mailbox", |
119 | "mailer", | 120 | "mailer", |
120 | "sieve", | ||
121 | NULL | 121 | NULL |
122 | }; | 122 | }; |
123 | 123 | ||
... | @@ -365,15 +365,14 @@ main (int argc, char *argv[]) | ... | @@ -365,15 +365,14 @@ main (int argc, char *argv[]) |
365 | mu_locker_set_default_retry_timeout (1); | 365 | mu_locker_set_default_retry_timeout (1); |
366 | mu_locker_set_default_retry_count (300); | 366 | mu_locker_set_default_retry_count (300); |
367 | 367 | ||
368 | /* Default error code for command line errors */ | ||
369 | mu_argp_error_code = EX_CONFIG; | ||
370 | /* Register needed modules */ | 368 | /* Register needed modules */ |
371 | MU_AUTH_REGISTER_ALL_MODULES(); | 369 | MU_AUTH_REGISTER_ALL_MODULES(); |
372 | mu_argp_init (program_version, NULL); | ||
373 | mu_sieve_argp_init (); | ||
374 | /* Parse command line */ | 370 | /* Parse command line */ |
375 | mu_argp_set_config_param (mail_local_cfg_param); | 371 | mu_gocs_register ("sieve", mu_sieve_module_init); |
376 | mu_argp_parse (&argp, &argc, &argv, 0, argp_capa, &arg_index, NULL); | 372 | mu_argp_init (program_version, NULL); |
373 | if (mu_app_init (&argp, argp_capa, mail_local_cfg_param, | ||
374 | argc, argv, 0, &arg_index, NULL)) | ||
375 | exit (EX_CONFIG); | ||
377 | 376 | ||
378 | uid = getuid (); | 377 | uid = getuid (); |
379 | 378 | ... | ... |
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
mailbox/mu_argp.c
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
This diff is collapsed.
Click to expand it.
-
Please register or sign in to post a comment