Convert remaining utilities (except mh) to mu_cli.
* Makefile.am: Remove libmu_argp and libmu_cfg * configure.ac: Likewise. * libmu_argp/: Remove. * libmu_cfg/: Remove. * include/mailutils/Makefile.am (pkginclude_HEADERS): Remove gocs.h, libargp.h, libcfg.h * frm/frm.c: Register tls auth module * frm/from.c: Likewise. * maidag/maidag.c: Likewise. * mail/mail.c: Likewise. * messages/messages.c: Likewise. * movemail/movemail.c: Likewise. * readmsg/readmsg.c: Likewise. * sieve/sieve.c: Likewise. * frm/frm.h: Remove obsolete includes * imap4d/Makefile.am: Update. * imap4d/imap4d.c: Use mu_cli for command line and configuration parsing. * imap4d/imap4d.h: Update. * include/mailutils/gocs.h: Remove. * libmailutils/cfg/gocs.c: Remove. * libmailutils/cfg/Makefile.am: Remove gocs.c * include/mailutils/cli.h (mu_cli_capa_apply): Rename to mu_cli_capa_extend_settings (mu_cli_setup) <inorder, prog_doc_hook>: New fields. * include/mailutils/daemon.h: Remove obsolete includes. * include/mailutils/gsasl.h: Likewise. * include/mailutils/mailutils.h: Update. * include/mailutils/mu_auth.h (mu_auth_mode): New enum (mu_auth_module): Redo structure. * include/mailutils/opt.h (mu_parseopt) <po_prog_doc_hook>: New field. * include/mailutils/sql.h (mu_sql_module_config): New extern. (mu_sql_interface_index): Change proto. * libmailutils/auth/mu_auth.c: Rewrite. * libmailutils/auth/system.c (mu_auth_system_module): Update structure * libmailutils/cli/capa.c (mu_cli_capa_apply): Rename to mu_cli_capa_extend_settings * libmailutils/cli/cli.c: Extend settings from auth modules as well. * libmailutils/opt/help.c (mu_program_help): Invoke po_prog_doc_hook if defined. * libmailutils/opt/opt.c (parseopt_init): Check the MU_PARSEOPT_PROG_DOC_HOOK flag. (find_long_option): Fix recognition of ambiguous options in case of exact match. * libmu_auth/gsasl.c: Add configuration. * libmu_auth/ldap.c: Likewise. * libmu_auth/pam.c: Likewise. * libmu_auth/radius.c: Likewise. * libmu_auth/sql.c: Likewise. * libmu_auth/tls.c: Likewise. * libmu_auth/virtual.c: Likewise. * mu/Makefile.am: Update. * mu/mu.c: Rewrite using mu_cli * mu/mu.h: Likewise. * mu/acl.c: Likewise. * mu/cflags.c: Likewise. * mu/dbm.c: Likewise. * mu/dispatch.c: Likewise. * mu/filter.c: Likewise. * mu/flt2047.c: Likewise. * mu/getans.c: Likewise. * mu/getarg.c: Likewise. * mu/getyn.c: Likewise. * mu/help.c: Likewise. * mu/imap.c: Likewise. * mu/info.c: Likewise. * mu/ldflags.c: Likewise. * mu/logger.c: Likewise. * mu/pop.c: Likewise. * mu/query.c: Likewise. * mu/send.c: Likewise. * mu/shell.c: Likewise. * mu/smtp.c: Likewise. * mu/util.c: Likewise. * mu/verbose.c: Likewise. * mu/wicket.c: Likewise. * pop3d/Makefile.am: Update. * pop3d/pop3d.c: Convert to mu_cli interface. * pop3d/pop3d.h: Likewise. * sql/sql.c (mu_sql_interface_index): Change argument qualifiers.
Showing
99 changed files
with
587 additions
and
3450 deletions
... | @@ -97,8 +97,6 @@ SUBDIRS = . \ | ... | @@ -97,8 +97,6 @@ SUBDIRS = . \ |
97 | libmu_compat\ | 97 | libmu_compat\ |
98 | testsuite\ | 98 | testsuite\ |
99 | lib\ | 99 | lib\ |
100 | libmu_argp\ | ||
101 | libmu_cfg\ | ||
102 | $(LIBMU_CPP_DIR)\ | 100 | $(LIBMU_CPP_DIR)\ |
103 | $(GINT_DIR)\ | 101 | $(GINT_DIR)\ |
104 | $(LIBMU_SCM_DIR)\ | 102 | $(LIBMU_SCM_DIR)\ | ... | ... |
... | @@ -1480,9 +1480,7 @@ AC_CONFIG_FILES([ | ... | @@ -1480,9 +1480,7 @@ AC_CONFIG_FILES([ |
1480 | include/mailutils/cpp/Makefile | 1480 | include/mailutils/cpp/Makefile |
1481 | lib/Makefile | 1481 | lib/Makefile |
1482 | lib/gnu/Makefile | 1482 | lib/gnu/Makefile |
1483 | libmu_argp/Makefile | ||
1484 | libmu_auth/Makefile | 1483 | libmu_auth/Makefile |
1485 | libmu_cfg/Makefile | ||
1486 | libmu_cpp/Makefile | 1484 | libmu_cpp/Makefile |
1487 | libmu_scm/Makefile | 1485 | libmu_scm/Makefile |
1488 | libmu_scm/mailutils/Makefile | 1486 | libmu_scm/mailutils/Makefile | ... | ... |
... | @@ -181,7 +181,6 @@ static char *frm_argp_capa[] = { | ... | @@ -181,7 +181,6 @@ static char *frm_argp_capa[] = { |
181 | "debug", | 181 | "debug", |
182 | "mailbox", | 182 | "mailbox", |
183 | "locking", | 183 | "locking", |
184 | "tls", | ||
185 | NULL | 184 | NULL |
186 | }; | 185 | }; |
187 | 186 | ||
... | @@ -328,7 +327,7 @@ main (int argc, char **argv) | ... | @@ -328,7 +327,7 @@ main (int argc, char **argv) |
328 | /* register the formats. */ | 327 | /* register the formats. */ |
329 | mu_register_all_mbox_formats (); | 328 | mu_register_all_mbox_formats (); |
330 | 329 | ||
331 | mu_cli_capa_register (&mu_cli_capa_tls); | 330 | mu_auth_register_module (&mu_auth_tls_module); |
332 | mu_cli (argc, argv, &cli, frm_argp_capa, NULL, &argc, &argv); | 331 | mu_cli (argc, argv, &cli, frm_argp_capa, NULL, &argc, &argv); |
333 | 332 | ||
334 | if (align && (s = util_getcols ())) | 333 | if (align && (s = util_getcols ())) | ... | ... |
... | @@ -63,6 +63,7 @@ | ... | @@ -63,6 +63,7 @@ |
63 | #include <mailutils/error.h> | 63 | #include <mailutils/error.h> |
64 | #include <mailutils/util.h> | 64 | #include <mailutils/util.h> |
65 | #include <mailutils/mime.h> | 65 | #include <mailutils/mime.h> |
66 | #include <mailutils/mu_auth.h> | ||
66 | 67 | ||
67 | #include "mailutils/cli.h" | 68 | #include "mailutils/cli.h" |
68 | 69 | ... | ... |
... | @@ -48,7 +48,6 @@ static char *capa[] = { | ... | @@ -48,7 +48,6 @@ static char *capa[] = { |
48 | "debug", | 48 | "debug", |
49 | "mailbox", | 49 | "mailbox", |
50 | "locking", | 50 | "locking", |
51 | "tls", | ||
52 | NULL | 51 | NULL |
53 | }; | 52 | }; |
54 | 53 | ||
... | @@ -89,7 +88,7 @@ main (int argc, char **argv) | ... | @@ -89,7 +88,7 @@ main (int argc, char **argv) |
89 | /* register the formats. */ | 88 | /* register the formats. */ |
90 | mu_register_all_mbox_formats (); | 89 | mu_register_all_mbox_formats (); |
91 | 90 | ||
92 | mu_cli_capa_register (&mu_cli_capa_tls); | 91 | mu_auth_register_module (&mu_auth_tls_module); |
93 | mu_cli (argc, argv, &cli, capa, NULL, &argc, &argv); | 92 | mu_cli (argc, argv, &cli, capa, NULL, &argc, &argv); |
94 | 93 | ||
95 | if (argc > 1) | 94 | if (argc > 1) | ... | ... |
... | @@ -72,7 +72,7 @@ imap4d_SOURCES = \ | ... | @@ -72,7 +72,7 @@ imap4d_SOURCES = \ |
72 | util.c | 72 | util.c |
73 | 73 | ||
74 | imap4d_LDADD = \ | 74 | imap4d_LDADD = \ |
75 | ${MU_APP_LIBRARIES}\ | 75 | ${MU_APP_NEW_LIBRARIES}\ |
76 | ${MU_LIB_MBOX}\ | 76 | ${MU_LIB_MBOX}\ |
77 | ${MU_LIB_MH}\ | 77 | ${MU_LIB_MH}\ |
78 | ${MU_LIB_MAILDIR}\ | 78 | ${MU_LIB_MAILDIR}\ | ... | ... |
... | @@ -17,7 +17,7 @@ | ... | @@ -17,7 +17,7 @@ |
17 | 17 | ||
18 | #include "imap4d.h" | 18 | #include "imap4d.h" |
19 | #include <mailutils/gsasl.h> | 19 | #include <mailutils/gsasl.h> |
20 | #include "mailutils/libargp.h" | 20 | #include "mailutils/cli.h" |
21 | #include "mailutils/kwd.h" | 21 | #include "mailutils/kwd.h" |
22 | #include "tcpwrap.h" | 22 | #include "tcpwrap.h" |
23 | 23 | ||
... | @@ -56,93 +56,79 @@ int ident_encrypt_only; | ... | @@ -56,93 +56,79 @@ int ident_encrypt_only; |
56 | int test_mode; | 56 | int test_mode; |
57 | 57 | ||
58 | const char *program_version = "imap4d (" PACKAGE_STRING ")"; | 58 | const char *program_version = "imap4d (" PACKAGE_STRING ")"; |
59 | static char doc[] = N_("GNU imap4d -- the IMAP4D daemon."); | 59 | |
60 | 60 | ||
61 | #define OPT_PREAUTH 259 | 61 | static void |
62 | #define OPT_FOREGROUND 260 | 62 | set_foreground (struct mu_parseopt *po, struct mu_option *opt, |
63 | #define OPT_TEST_MODE 261 | 63 | char const *arg) |
64 | 64 | { | |
65 | static struct argp_option options[] = { | 65 | mu_m_server_set_foreground (server, 1); |
66 | { "foreground", OPT_FOREGROUND, 0, 0, N_("remain in foreground"), 0}, | 66 | } |
67 | { "inetd", 'i', 0, 0, N_("run in inetd mode"), 0}, | 67 | |
68 | { "daemon", 'd', N_("NUMBER"), OPTION_ARG_OPTIONAL, | 68 | static void |
69 | N_("runs in daemon mode with a maximum of NUMBER children"), 0 }, | 69 | set_inetd_mode (struct mu_parseopt *po, struct mu_option *opt, |
70 | { "test", OPT_TEST_MODE, 0, 0, | 70 | char const *arg) |
71 | N_("run in test mode"), 0 }, | 71 | { |
72 | { "preauth", OPT_PREAUTH, NULL, 0, | 72 | mu_m_server_set_mode (server, MODE_INTERACTIVE); |
73 | N_("start in preauth mode") }, | 73 | } |
74 | 74 | ||
75 | {NULL, 0, NULL, 0, NULL, 0} | 75 | static void |
76 | }; | 76 | set_daemon_mode (struct mu_parseopt *po, struct mu_option *opt, |
77 | char const *arg) | ||
78 | { | ||
79 | mu_m_server_set_mode (server, MODE_DAEMON); | ||
80 | if (arg) | ||
81 | { | ||
82 | size_t max_children; | ||
83 | char *errmsg; | ||
84 | int rc = mu_str_to_c (arg, mu_c_size, &max_children, &errmsg); | ||
85 | if (rc) | ||
86 | { | ||
87 | mu_parseopt_error (po, _("%s: bad argument"), arg); | ||
88 | exit (po->po_exit_error); | ||
89 | } | ||
90 | mu_m_server_set_max_children (server, max_children); | ||
91 | } | ||
92 | } | ||
77 | 93 | ||
94 | static void | ||
95 | set_preauth (struct mu_parseopt *po, struct mu_option *opt, char const *arg) | ||
96 | { | ||
97 | preauth_mode = preauth_stdio; | ||
98 | } | ||
78 | 99 | ||
79 | static error_t imap4d_parse_opt (int key, char *arg, | 100 | static struct mu_option imap4d_options[] = { |
80 | struct argp_state *state); | 101 | { "foreground", 0, NULL, MU_OPTION_DEFAULT, |
102 | N_("remain in foreground"), | ||
103 | mu_c_bool, NULL, set_foreground }, | ||
104 | { "inetd", 'i', NULL, MU_OPTION_DEFAULT, | ||
105 | N_("run in inetd mode"), | ||
106 | mu_c_bool, NULL, set_inetd_mode }, | ||
107 | { "daemon", 'd', N_("NUMBER"), MU_OPTION_ARG_OPTIONAL, | ||
108 | N_("runs in daemon mode with a maximum of NUMBER children"), | ||
109 | mu_c_string, NULL, set_daemon_mode }, | ||
81 | 110 | ||
82 | static struct argp argp = { | 111 | { "test", 0, NULL, MU_OPTION_DEFAULT, |
83 | options, | 112 | N_("run in test mode"), |
84 | imap4d_parse_opt, | 113 | mu_c_bool, &test_mode }, |
85 | NULL, | ||
86 | doc, | ||
87 | NULL, | ||
88 | NULL, NULL | ||
89 | }; | ||
90 | 114 | ||
91 | static const char *imap4d_capa[] = { | 115 | { "preauth", 0, NULL, MU_OPTION_DEFAULT, |
92 | "mailutils", | 116 | N_("start in preauth mode"), |
117 | mu_c_string, NULL, set_preauth }, | ||
118 | |||
119 | MU_OPTION_END | ||
120 | }, *options[] = { imap4d_options, NULL }; | ||
121 | |||
122 | |||
123 | static char *capa[] = { | ||
93 | "auth", | 124 | "auth", |
94 | "common", | ||
95 | "debug", | 125 | "debug", |
96 | "mailbox", | 126 | "mailbox", |
97 | "locking", | 127 | "locking", |
98 | "logging", | 128 | "logging", |
99 | NULL | 129 | NULL |
100 | }; | 130 | }; |
101 | 131 | ||
102 | static error_t | ||
103 | imap4d_parse_opt (int key, char *arg, struct argp_state *state) | ||
104 | { | ||
105 | static mu_list_t lst; | ||
106 | |||
107 | switch (key) | ||
108 | { | ||
109 | case 'd': | ||
110 | mu_argp_node_list_new (lst, "mode", "daemon"); | ||
111 | if (arg) | ||
112 | mu_argp_node_list_new (lst, "max-children", arg); | ||
113 | break; | ||
114 | |||
115 | case 'i': | ||
116 | mu_argp_node_list_new (lst, "mode", "inetd"); | ||
117 | break; | ||
118 | |||
119 | case OPT_FOREGROUND: | ||
120 | mu_argp_node_list_new (lst, "foreground", "yes"); | ||
121 | break; | ||
122 | |||
123 | case OPT_PREAUTH: | ||
124 | preauth_mode = preauth_stdio; | ||
125 | break; | ||
126 | |||
127 | case OPT_TEST_MODE: | ||
128 | mu_argp_node_list_new (lst, "mode", "inetd"); | ||
129 | test_mode = 1; | ||
130 | break; | ||
131 | |||
132 | case ARGP_KEY_INIT: | ||
133 | mu_argp_node_list_init (&lst); | ||
134 | break; | ||
135 | |||
136 | case ARGP_KEY_FINI: | ||
137 | mu_argp_node_list_finish (lst, NULL, NULL); | ||
138 | break; | ||
139 | |||
140 | default: | ||
141 | return ARGP_ERR_UNKNOWN; | ||
142 | } | ||
143 | return 0; | ||
144 | } | ||
145 | |||
146 | static int | 132 | static int |
147 | cb_mode (void *data, mu_config_value_t *val) | 133 | cb_mode (void *data, mu_config_value_t *val) |
148 | { | 134 | { |
... | @@ -455,6 +441,12 @@ static struct mu_cfg_param imap4d_cfg_param[] = { | ... | @@ -455,6 +441,12 @@ static struct mu_cfg_param imap4d_cfg_param[] = { |
455 | { NULL } | 441 | { NULL } |
456 | }; | 442 | }; |
457 | 443 | ||
444 | struct mu_cli_setup cli = { | ||
445 | options, | ||
446 | imap4d_cfg_param, | ||
447 | N_("GNU imap4d -- the IMAP4D daemon.") | ||
448 | }; | ||
449 | |||
458 | int | 450 | int |
459 | mu_get_user_groups (const char *user, mu_list_t retain, mu_list_t *pgrouplist) | 451 | mu_get_user_groups (const char *user, mu_list_t retain, mu_list_t *pgrouplist) |
460 | { | 452 | { |
... | @@ -933,18 +925,10 @@ main (int argc, char **argv) | ... | @@ -933,18 +925,10 @@ main (int argc, char **argv) |
933 | mu_register_local_mbox_formats (); | 925 | mu_register_local_mbox_formats (); |
934 | 926 | ||
935 | imap4d_capability_init (); | 927 | imap4d_capability_init (); |
936 | #ifdef WITH_TLS | ||
937 | mu_gocs_register ("tls", mu_tls_module_init); | ||
938 | #endif /* WITH_TLS */ | ||
939 | #ifdef WITH_GSASL | ||
940 | mu_gocs_register ("gsasl", mu_gsasl_module_init); | ||
941 | #endif | ||
942 | mu_tcpwrapper_cfg_init (); | 928 | mu_tcpwrapper_cfg_init (); |
943 | manlock_cfg_init (); | 929 | manlock_cfg_init (); |
944 | mu_acl_cfg_init (); | 930 | mu_acl_cfg_init (); |
945 | 931 | ||
946 | mu_argp_init (NULL, NULL); | ||
947 | |||
948 | mu_m_server_create (&server, program_version); | 932 | mu_m_server_create (&server, program_version); |
949 | mu_m_server_set_config_size (server, sizeof (struct imap4d_srv_config)); | 933 | mu_m_server_set_config_size (server, sizeof (struct imap4d_srv_config)); |
950 | mu_m_server_set_conn (server, imap4d_connection); | 934 | mu_m_server_set_conn (server, imap4d_connection); |
... | @@ -961,10 +945,16 @@ main (int argc, char **argv) | ... | @@ -961,10 +945,16 @@ main (int argc, char **argv) |
961 | 945 | ||
962 | mu_log_syslog = 1; | 946 | mu_log_syslog = 1; |
963 | 947 | ||
964 | if (mu_app_init (&argp, imap4d_capa, imap4d_cfg_param, | 948 | mu_cli (argc, argv, &cli, capa, server, &argc, &argv); |
965 | argc, argv, 0, NULL, server)) | 949 | if (argc) |
966 | exit (EX_CONFIG); /* FIXME: No way to discern from EX_USAGE? */ | 950 | { |
967 | 951 | mu_error (_("too many arguments")); | |
952 | exit (EX_USAGE); | ||
953 | } | ||
954 | |||
955 | if (test_mode) | ||
956 | mu_m_server_set_mode (server, MODE_INTERACTIVE); | ||
957 | |||
968 | if (login_disabled) | 958 | if (login_disabled) |
969 | imap4d_capability_add (IMAP_CAPA_LOGINDISABLED); | 959 | imap4d_capability_add (IMAP_CAPA_LOGINDISABLED); |
970 | 960 | ... | ... |
... | @@ -106,6 +106,7 @@ | ... | @@ -106,6 +106,7 @@ |
106 | #include <mailutils/imapio.h> | 106 | #include <mailutils/imapio.h> |
107 | #include <mailutils/imaputil.h> | 107 | #include <mailutils/imaputil.h> |
108 | #include <mailutils/msgset.h> | 108 | #include <mailutils/msgset.h> |
109 | #include <mailutils/syslog.h> | ||
109 | 110 | ||
110 | #include <mu_umaxtostr.h> | 111 | #include <mu_umaxtostr.h> |
111 | #include <muaux.h> | 112 | #include <muaux.h> | ... | ... |
... | @@ -48,7 +48,6 @@ pkginclude_HEADERS = \ | ... | @@ -48,7 +48,6 @@ pkginclude_HEADERS = \ |
48 | error.h\ | 48 | error.h\ |
49 | filter.h\ | 49 | filter.h\ |
50 | folder.h\ | 50 | folder.h\ |
51 | gocs.h\ | ||
52 | gsasl.h\ | 51 | gsasl.h\ |
53 | guile.h\ | 52 | guile.h\ |
54 | header.h\ | 53 | header.h\ |
... | @@ -59,8 +58,6 @@ pkginclude_HEADERS = \ | ... | @@ -59,8 +58,6 @@ pkginclude_HEADERS = \ |
59 | iterator.h\ | 58 | iterator.h\ |
60 | kwd.h\ | 59 | kwd.h\ |
61 | ldap.h\ | 60 | ldap.h\ |
62 | libargp.h\ | ||
63 | libcfg.h\ | ||
64 | list.h\ | 61 | list.h\ |
65 | locker.h\ | 62 | locker.h\ |
66 | log.h\ | 63 | log.h\ | ... | ... |
... | @@ -35,7 +35,8 @@ struct mu_cli_capa | ... | @@ -35,7 +35,8 @@ struct mu_cli_capa |
35 | 35 | ||
36 | void mu_cli_capa_init (void); | 36 | void mu_cli_capa_init (void); |
37 | void mu_cli_capa_register (struct mu_cli_capa *capa); | 37 | void mu_cli_capa_register (struct mu_cli_capa *capa); |
38 | void mu_cli_capa_apply (char const *name, mu_list_t opts, mu_list_t commits); | 38 | void mu_cli_capa_extend_settings (char const *name, mu_list_t opts, |
39 | mu_list_t commits); | ||
39 | 40 | ||
40 | struct mu_cli_setup | 41 | struct mu_cli_setup |
41 | { | 42 | { |
... | @@ -49,6 +50,8 @@ struct mu_cli_setup | ... | @@ -49,6 +50,8 @@ struct mu_cli_setup |
49 | int ex_usage; /* If not 0, exit code on usage errors */ | 50 | int ex_usage; /* If not 0, exit code on usage errors */ |
50 | int ex_config; /* If not 0, exit code on configuration | 51 | int ex_config; /* If not 0, exit code on configuration |
51 | errors */ | 52 | errors */ |
53 | int inorder; | ||
54 | void (*prog_doc_hook) (mu_stream_t); | ||
52 | }; | 55 | }; |
53 | 56 | ||
54 | void mu_version_func (struct mu_parseopt *po, mu_stream_t stream); | 57 | void mu_version_func (struct mu_parseopt *po, mu_stream_t stream); | ... | ... |
... | @@ -20,7 +20,6 @@ | ... | @@ -20,7 +20,6 @@ |
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> | ||
24 | 23 | ||
25 | #ifdef __cplusplus | 24 | #ifdef __cplusplus |
26 | extern "C" { | 25 | extern "C" { |
... | @@ -33,8 +32,6 @@ extern "C" { | ... | @@ -33,8 +32,6 @@ extern "C" { |
33 | extern int mu_daemon_create_pidfile (const char *); | 32 | extern int mu_daemon_create_pidfile (const char *); |
34 | extern void mu_daemon_remove_pidfile (void); | 33 | extern void mu_daemon_remove_pidfile (void); |
35 | 34 | ||
36 | extern struct mu_gocs_daemon mu_gocs_daemon; | ||
37 | |||
38 | #ifdef __cplusplus | 35 | #ifdef __cplusplus |
39 | } | 36 | } |
40 | #endif | 37 | #endif | ... | ... |
include/mailutils/gocs.h
deleted
100644 → 0
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2007-2008, 2010-2012, 2014-2016 Free Software | ||
3 | 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, see | ||
17 | <http://www.gnu.org/licenses/>. */ | ||
18 | |||
19 | #ifndef _MAILUTILS_GOCS_H | ||
20 | #define _MAILUTILS_GOCS_H | ||
21 | |||
22 | #include <mailutils/types.h> | ||
23 | #include <mailutils/list.h> | ||
24 | #include <mailutils/syslog.h> | ||
25 | |||
26 | #ifdef __cplusplus | ||
27 | extern "C" { | ||
28 | #endif | ||
29 | |||
30 | struct mu_gocs_debug | ||
31 | { | ||
32 | char *string; | ||
33 | int line_info; | ||
34 | }; | ||
35 | |||
36 | struct mu_gocs_mailbox | ||
37 | { | ||
38 | char *mail_spool; | ||
39 | char *mailbox_pattern; | ||
40 | char *mailbox_type; | ||
41 | }; | ||
42 | |||
43 | struct mu_gocs_locking | ||
44 | { | ||
45 | char *lock_flags; | ||
46 | unsigned long lock_retry_timeout; | ||
47 | unsigned long lock_retry_count; | ||
48 | unsigned long lock_expire_timeout; | ||
49 | char *external_locker; | ||
50 | }; | ||
51 | |||
52 | struct mu_gocs_source_email | ||
53 | { | ||
54 | char *address; | ||
55 | char *domain; | ||
56 | }; | ||
57 | |||
58 | struct mu_gocs_mailer | ||
59 | { | ||
60 | char *mailer; | ||
61 | }; | ||
62 | |||
63 | struct mu_gocs_pam | ||
64 | { | ||
65 | char *service; | ||
66 | }; | ||
67 | |||
68 | struct mu_gocs_virtual | ||
69 | { | ||
70 | char *pwddir; | ||
71 | }; | ||
72 | |||
73 | /* Auxiliary variables for use by libargp/libcfg */ | ||
74 | extern char *mu_site_rcfile; | ||
75 | extern int mu_load_user_rcfile; | ||
76 | extern int mu_load_site_rcfile; | ||
77 | extern char *mu_load_rcfile; | ||
78 | |||
79 | typedef int (*mu_gocs_init_fp) (enum mu_gocs_op op, void *data); | ||
80 | |||
81 | void mu_gocs_register (const char *capa, mu_gocs_init_fp init); | ||
82 | void mu_gocs_register_std (const 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 (enum mu_gocs_op, void *data); | ||
88 | int mu_gocs_locking_init (enum mu_gocs_op, void *data); | ||
89 | int mu_gocs_source_email_init (enum mu_gocs_op, void *data); | ||
90 | int mu_gocs_mailer_init (enum mu_gocs_op, void *data); | ||
91 | int mu_gocs_logging_init (enum mu_gocs_op, void *data); | ||
92 | int mu_gocs_debug_init (enum mu_gocs_op, void *data); | ||
93 | |||
94 | #ifdef __cplusplus | ||
95 | } | ||
96 | #endif | ||
97 | |||
98 | #endif |
... | @@ -18,6 +18,7 @@ | ... | @@ -18,6 +18,7 @@ |
18 | 18 | ||
19 | #ifndef _MAILUTILS_GSASL_H | 19 | #ifndef _MAILUTILS_GSASL_H |
20 | #define _MAILUTILS_GSASL_H | 20 | #define _MAILUTILS_GSASL_H |
21 | #include <mailutils/cli.h> | ||
21 | 22 | ||
22 | struct mu_gsasl_module_data | 23 | struct mu_gsasl_module_data |
23 | { | 24 | { |
... | @@ -28,16 +29,13 @@ struct mu_gsasl_module_data | ... | @@ -28,16 +29,13 @@ struct mu_gsasl_module_data |
28 | char *anon_user; | 29 | char *anon_user; |
29 | char *cram_md5_pwd; | 30 | char *cram_md5_pwd; |
30 | }; | 31 | }; |
32 | extern struct mu_gsasl_module_data mu_gsasl_module_data; | ||
31 | 33 | ||
32 | int mu_gsasl_enabled (void); | 34 | int mu_gsasl_enabled (void); |
33 | 35 | ||
34 | #ifdef WITH_GSASL | 36 | #ifdef WITH_GSASL |
35 | #include <gsasl.h> | 37 | #include <gsasl.h> |
36 | 38 | ||
37 | int mu_gsasl_module_init (enum mu_gocs_op, void *); | ||
38 | extern struct mu_gsasl_module_data mu_gsasl_module_data; | ||
39 | |||
40 | |||
41 | int gsasl_encoder_stream (mu_stream_t *pstr, mu_stream_t transport, | 39 | int gsasl_encoder_stream (mu_stream_t *pstr, mu_stream_t transport, |
42 | Gsasl_session *ctx, int flags); | 40 | Gsasl_session *ctx, int flags); |
43 | int gsasl_decoder_stream (mu_stream_t *pstr, mu_stream_t transport, | 41 | int gsasl_decoder_stream (mu_stream_t *pstr, mu_stream_t transport, | ... | ... |
include/mailutils/libargp.h
deleted
100644 → 0
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 1999-2001, 2004-2005, 2007-2008, 2010-2012, 2014-2016 | ||
3 | 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, see | ||
17 | <http://www.gnu.org/licenses/>. */ | ||
18 | |||
19 | #ifndef _MAILUTILS_LIBARGP_H | ||
20 | #define _MAILUTILS_LIBARGP_H | ||
21 | |||
22 | #include "mailutils/types.h" | ||
23 | #include "mailutils/gocs.h" | ||
24 | #include "mailutils/nls.h" | ||
25 | #include "mailutils/error.h" | ||
26 | #include "mailutils/errno.h" | ||
27 | #include "mailutils/version.h" | ||
28 | #include "argp.h" | ||
29 | #include "errno.h" | ||
30 | #include "strings.h" | ||
31 | |||
32 | #include "mailutils/libcfg.h" | ||
33 | |||
34 | #ifdef __cplusplus | ||
35 | extern "C" { | ||
36 | #endif | ||
37 | |||
38 | struct mu_cmdline_capa | ||
39 | { | ||
40 | char *name; | ||
41 | struct argp_child *child; | ||
42 | void (*modflags) (int *); | ||
43 | }; | ||
44 | |||
45 | extern int mu_help_config_mode; | ||
46 | extern int mu_rcfile_lint; | ||
47 | extern int (*mu_app_cfg_verifier) (void); | ||
48 | |||
49 | extern struct mu_cmdline_capa mu_mailutils_cmdline; | ||
50 | extern struct mu_cmdline_capa mu_common_cmdline; | ||
51 | extern struct mu_cmdline_capa mu_logging_cmdline; | ||
52 | extern struct mu_cmdline_capa mu_mailbox_cmdline; | ||
53 | extern struct mu_cmdline_capa mu_locking_cmdline; | ||
54 | extern struct mu_cmdline_capa mu_address_cmdline; | ||
55 | extern struct mu_cmdline_capa mu_mailer_cmdline; | ||
56 | extern struct mu_cmdline_capa mu_sieve_cmdline; | ||
57 | extern struct mu_cmdline_capa mu_debug_cmdline; | ||
58 | |||
59 | extern struct mu_cmdline_capa mu_pam_cmdline; | ||
60 | extern struct mu_cmdline_capa mu_gsasl_cmdline; | ||
61 | extern struct mu_cmdline_capa mu_radius_cmdline; | ||
62 | extern struct mu_cmdline_capa mu_sql_cmdline; | ||
63 | extern struct mu_cmdline_capa mu_virtdomain_cmdline; | ||
64 | |||
65 | extern void mu_libargp_init (void); | ||
66 | |||
67 | extern struct argp *mu_argp_build (const struct argp *argp, char ***pcapa, | ||
68 | int *flags); | ||
69 | extern void mu_argp_done (struct argp *argp); | ||
70 | |||
71 | extern int mu_register_argp_capa (const char *name, struct argp_child *child, | ||
72 | void (*modflags) (int*)); | ||
73 | |||
74 | void mu_argp_init (const char *vers, const char *bugaddr); | ||
75 | int mu_app_init (struct argp *myargp, const char **capa, | ||
76 | struct mu_cfg_param *cfg_param, | ||
77 | int argc, char **argv, int flags, int *pindex, void *data); | ||
78 | extern void mu_program_version_hook (FILE *stream, struct argp_state *state); | ||
79 | |||
80 | error_t mu_argp_parse (const struct argp *myargp, | ||
81 | int *pargc, char **pargv[], | ||
82 | unsigned flags, | ||
83 | const char *capa[], | ||
84 | int *arg_index, | ||
85 | void *input) MU_DEPRECATED; | ||
86 | |||
87 | void mu_argp_node_list_init (mu_list_t *); | ||
88 | void mu_argp_node_list_add (mu_list_t, mu_cfg_node_t *); | ||
89 | void mu_argp_node_list_new (mu_list_t, const char *, const char *); | ||
90 | void mu_argp_node_list_finish (mu_list_t, char *, char *); | ||
91 | |||
92 | #ifdef __cplusplus | ||
93 | } | ||
94 | #endif | ||
95 | |||
96 | #endif | ||
97 |
include/mailutils/libcfg.h
deleted
100644 → 0
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2007-2012, 2014-2016 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, see | ||
16 | <http://www.gnu.org/licenses/>. */ | ||
17 | |||
18 | #ifndef _MAILUTILS_LIBCFG_H | ||
19 | #define _MAILUTILS_LIBCFG_H | ||
20 | |||
21 | #include <mailutils/cfg.h> | ||
22 | #include <mailutils/gocs.h> | ||
23 | #include <mailutils/nls.h> | ||
24 | #include <mailutils/error.h> | ||
25 | #include <mailutils/errno.h> | ||
26 | |||
27 | #ifndef MU_USER_CONFIG_FILE | ||
28 | # define MU_USER_CONFIG_FILE "~/.mailutils" | ||
29 | #endif | ||
30 | |||
31 | #ifdef __cplusplus | ||
32 | extern "C" { | ||
33 | #endif | ||
34 | |||
35 | struct mu_cfg_capa | ||
36 | { | ||
37 | char *name; | ||
38 | struct mu_cfg_param *cfgparam; | ||
39 | mu_cfg_section_fp parser; | ||
40 | }; | ||
41 | |||
42 | extern int mu_libcfg_register_capa (struct mu_cfg_capa *capa); | ||
43 | extern void mu_libcfg_init (char **cnames); | ||
44 | extern int mu_parse_config_files (struct mu_cfg_param *param, | ||
45 | void *target_ptr) MU_CFG_DEPRECATED; | ||
46 | int mu_libcfg_parse_config (mu_cfg_tree_t **ptree); | ||
47 | |||
48 | extern void mu_acl_cfg_init (void); | ||
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 | const char *section_label, void **section_data, \ | ||
57 | void *call_data, mu_cfg_tree_t *tree) \ | ||
58 | { \ | ||
59 | switch (stage) \ | ||
60 | { \ | ||
61 | case mu_cfg_section_start: \ | ||
62 | break; \ | ||
63 | \ | ||
64 | case mu_cfg_section_end: \ | ||
65 | mu_gocs_store (#capa, &__mu_common_cat2__(capa, _settings)); \ | ||
66 | } \ | ||
67 | return 0; \ | ||
68 | } | ||
69 | |||
70 | #define DCL_DEFAULT_CFG_CAPA(capa) \ | ||
71 | struct mu_cfg_capa __mu_common_cat3__(mu_,capa,_cfg_capa) = { \ | ||
72 | #capa, \ | ||
73 | __mu_common_cat3__(mu_,capa,_param), \ | ||
74 | __mu_common_cat3__(mu_,capa,_section_parser) \ | ||
75 | } | ||
76 | |||
77 | #define DCL_CFG_CAPA(capa) \ | ||
78 | DCL_PARSER (capa) \ | ||
79 | DCL_DEFAULT_CFG_CAPA (capa) | ||
80 | |||
81 | extern struct mu_cfg_capa mu_mailbox_cfg_capa; | ||
82 | extern struct mu_cfg_capa mu_locking_cfg_capa; | ||
83 | extern struct mu_cfg_capa mu_address_cfg_capa; | ||
84 | extern struct mu_cfg_capa mu_mailer_cfg_capa; | ||
85 | extern struct mu_cfg_capa mu_logging_cfg_capa; | ||
86 | extern struct mu_cfg_capa mu_debug_cfg_capa; | ||
87 | extern struct mu_cfg_capa mu_gsasl_cfg_capa; | ||
88 | extern struct mu_cfg_capa mu_pam_cfg_capa; | ||
89 | extern struct mu_cfg_capa mu_radius_cfg_capa; | ||
90 | extern struct mu_cfg_capa mu_sql_cfg_capa; | ||
91 | extern struct mu_cfg_capa mu_tls_cfg_capa; | ||
92 | extern struct mu_cfg_capa mu_virtdomain_cfg_capa; | ||
93 | extern struct mu_cfg_capa mu_sieve_cfg_capa; | ||
94 | extern struct mu_cfg_capa mu_auth_cfg_capa; | ||
95 | extern struct mu_cfg_capa mu_ldap_cfg_capa; | ||
96 | |||
97 | #ifdef __cplusplus | ||
98 | } | ||
99 | #endif | ||
100 | |||
101 | #endif |
... | @@ -58,7 +58,6 @@ | ... | @@ -58,7 +58,6 @@ |
58 | #include <mailutils/stream.h> | 58 | #include <mailutils/stream.h> |
59 | #include <mailutils/tls.h> | 59 | #include <mailutils/tls.h> |
60 | #include <mailutils/url.h> | 60 | #include <mailutils/url.h> |
61 | #include <mailutils/gocs.h> | ||
62 | #include <mailutils/version.h> | 61 | #include <mailutils/version.h> |
63 | #include <mailutils/io.h> | 62 | #include <mailutils/io.h> |
64 | #include <mailutils/secret.h> | 63 | #include <mailutils/secret.h> |
... | @@ -66,6 +65,7 @@ | ... | @@ -66,6 +65,7 @@ |
66 | #include <mailutils/cstr.h> | 65 | #include <mailutils/cstr.h> |
67 | #include <mailutils/wordsplit.h> | 66 | #include <mailutils/wordsplit.h> |
68 | #include <mailutils/log.h> | 67 | #include <mailutils/log.h> |
68 | #include <mailutils/syslog.h> | ||
69 | #include <mailutils/stdstream.h> | 69 | #include <mailutils/stdstream.h> |
70 | #include <mailutils/prog.h> | 70 | #include <mailutils/prog.h> |
71 | #include <mailutils/sockaddr.h> | 71 | #include <mailutils/sockaddr.h> | ... | ... |
... | @@ -20,8 +20,8 @@ | ... | @@ -20,8 +20,8 @@ |
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> | ||
24 | #include <mailutils/debug.h> | 23 | #include <mailutils/debug.h> |
24 | #include <mailutils/cli.h> | ||
25 | 25 | ||
26 | #define MU_AUTH_NAME "name" | 26 | #define MU_AUTH_NAME "name" |
27 | #define MU_AUTH_PASSWD "passwd" | 27 | #define MU_AUTH_PASSWD "passwd" |
... | @@ -64,30 +64,41 @@ typedef int (*mu_auth_fp) (struct mu_auth_data **data, | ... | @@ -64,30 +64,41 @@ typedef int (*mu_auth_fp) (struct mu_auth_data **data, |
64 | void *func_data, | 64 | void *func_data, |
65 | void *call_data); | 65 | void *call_data); |
66 | 66 | ||
67 | enum mu_auth_mode | ||
68 | { | ||
69 | mu_auth_authenticate, | ||
70 | mu_auth_getpwnam, | ||
71 | mu_auth_getpwuid | ||
72 | }; | ||
73 | |||
74 | #define MU_AUTH_MODE_COUNT 3 | ||
75 | |||
67 | struct mu_auth_module | 76 | struct mu_auth_module |
68 | { | 77 | { |
69 | char *name; | 78 | char *name; |
70 | mu_gocs_init_fp init; | 79 | mu_auth_fp handler[MU_AUTH_MODE_COUNT]; |
71 | mu_auth_fp authenticate; | 80 | void *data[MU_AUTH_MODE_COUNT]; |
72 | void *authenticate_data; | 81 | |
73 | mu_auth_fp auth_by_name; | 82 | struct mu_option *opt; |
74 | void *auth_by_name_data; | 83 | struct mu_cfg_param *cfg; |
75 | mu_auth_fp auth_by_uid; | 84 | mu_cfg_section_fp parser; |
76 | void *auth_by_uid_data; | 85 | mu_cli_capa_commit_fp commit; |
77 | }; | 86 | }; |
78 | 87 | ||
79 | enum mu_auth_key_type | 88 | enum mu_auth_key_type |
80 | { | 89 | { |
81 | mu_auth_key_name, | 90 | mu_auth_key_name = mu_auth_getpwnam, |
82 | mu_auth_key_uid | 91 | mu_auth_key_uid = mu_auth_getpwuid |
83 | }; | 92 | }; |
84 | 93 | ||
85 | void mu_auth_begin_setup (void); | 94 | void mu_auth_begin_setup (void); |
86 | void mu_auth_finish_setup (void); | 95 | void mu_auth_finish_setup (void); |
96 | void mu_auth_extend_settings (mu_list_t opts, mu_list_t commits); | ||
87 | 97 | ||
88 | extern int mu_auth_runlist (mu_list_t flist, | 98 | int mu_auth_runlist (mu_list_t flist, |
89 | struct mu_auth_data **return_data, | 99 | enum mu_auth_mode mode, |
90 | const void *key, void *data); | 100 | const void *key, void *data, |
101 | struct mu_auth_data **return_data); | ||
91 | 102 | ||
92 | extern int mu_get_auth (struct mu_auth_data **auth, enum mu_auth_key_type type, | 103 | extern int mu_get_auth (struct mu_auth_data **auth, enum mu_auth_key_type type, |
93 | const void *key); | 104 | const void *key); |
... | @@ -116,7 +127,6 @@ extern void mu_authentication_add_module_list (const char *modlist); | ... | @@ -116,7 +127,6 @@ extern void mu_authentication_add_module_list (const char *modlist); |
116 | extern void mu_authentication_clear_list (void); | 127 | extern void mu_authentication_clear_list (void); |
117 | extern void mu_authorization_clear_list (void); | 128 | extern void mu_authorization_clear_list (void); |
118 | 129 | ||
119 | extern void mu_auth_init (void); | ||
120 | extern int mu_auth_data_alloc (struct mu_auth_data **ptr, | 130 | extern int mu_auth_data_alloc (struct mu_auth_data **ptr, |
121 | const char *name, | 131 | const char *name, |
122 | const char *passwd, | 132 | const char *passwd, |
... | @@ -138,6 +148,8 @@ extern struct mu_auth_module mu_auth_sql_module; | ... | @@ -138,6 +148,8 @@ extern struct mu_auth_module mu_auth_sql_module; |
138 | extern struct mu_auth_module mu_auth_virtual_module; | 148 | extern struct mu_auth_module mu_auth_virtual_module; |
139 | extern struct mu_auth_module mu_auth_radius_module; | 149 | extern struct mu_auth_module mu_auth_radius_module; |
140 | extern struct mu_auth_module mu_auth_ldap_module; | 150 | extern struct mu_auth_module mu_auth_ldap_module; |
151 | extern struct mu_auth_module mu_auth_gsasl_module; | ||
152 | extern struct mu_auth_module mu_auth_tls_module; | ||
141 | 153 | ||
142 | #define MU_AUTH_REGISTER_ALL_MODULES() do {\ | 154 | #define MU_AUTH_REGISTER_ALL_MODULES() do {\ |
143 | mu_auth_register_module (&mu_auth_generic_module); \ | 155 | mu_auth_register_module (&mu_auth_generic_module); \ |
... | @@ -147,6 +159,8 @@ extern struct mu_auth_module mu_auth_ldap_module; | ... | @@ -147,6 +159,8 @@ extern struct mu_auth_module mu_auth_ldap_module; |
147 | mu_auth_register_module (&mu_auth_virtual_module);\ | 159 | mu_auth_register_module (&mu_auth_virtual_module);\ |
148 | mu_auth_register_module (&mu_auth_radius_module);\ | 160 | mu_auth_register_module (&mu_auth_radius_module);\ |
149 | mu_auth_register_module (&mu_auth_ldap_module);\ | 161 | mu_auth_register_module (&mu_auth_ldap_module);\ |
162 | mu_auth_register_module (&mu_auth_gsasl_module);\ | ||
163 | mu_auth_register_module (&mu_auth_tls_module);\ | ||
150 | } while (0) | 164 | } while (0) |
151 | 165 | ||
152 | #endif | 166 | #endif | ... | ... |
... | @@ -102,6 +102,7 @@ struct mu_option_cache | ... | @@ -102,6 +102,7 @@ struct mu_option_cache |
102 | #define MU_PARSEOPT_HELP_HOOK 0x00200000 | 102 | #define MU_PARSEOPT_HELP_HOOK 0x00200000 |
103 | #define MU_PARSEOPT_DATA 0x00400000 | 103 | #define MU_PARSEOPT_DATA 0x00400000 |
104 | #define MU_PARSEOPT_VERSION_HOOK 0x00800000 | 104 | #define MU_PARSEOPT_VERSION_HOOK 0x00800000 |
105 | #define MU_PARSEOPT_PROG_DOC_HOOK 0x01000000 | ||
105 | 106 | ||
106 | /* Reuse mu_parseopt struct initialized previously */ | 107 | /* Reuse mu_parseopt struct initialized previously */ |
107 | #define MU_PARSEOPT_REUSE 0x80000000 | 108 | #define MU_PARSEOPT_REUSE 0x80000000 |
... | @@ -131,6 +132,7 @@ struct mu_parseopt | ... | @@ -131,6 +132,7 @@ struct mu_parseopt |
131 | char const *po_package_url; | 132 | char const *po_package_url; |
132 | char const *po_extra_info; | 133 | char const *po_extra_info; |
133 | 134 | ||
135 | void (*po_prog_doc_hook) (struct mu_parseopt *po, mu_stream_t stream); | ||
134 | void (*po_help_hook) (struct mu_parseopt *po, mu_stream_t stream); | 136 | void (*po_help_hook) (struct mu_parseopt *po, mu_stream_t stream); |
135 | void (*po_version_hook) (struct mu_parseopt *po, mu_stream_t stream); | 137 | void (*po_version_hook) (struct mu_parseopt *po, mu_stream_t stream); |
136 | 138 | ... | ... |
... | @@ -272,17 +272,6 @@ int mu_sieve_disass (mu_sieve_machine_t mach); | ... | @@ -272,17 +272,6 @@ int mu_sieve_disass (mu_sieve_machine_t mach); |
272 | #define MU_SIEVE_CLEAR_INCLUDE_PATH 0x1 | 272 | #define MU_SIEVE_CLEAR_INCLUDE_PATH 0x1 |
273 | #define MU_SIEVE_CLEAR_LIBRARY_PATH 0x2 | 273 | #define MU_SIEVE_CLEAR_LIBRARY_PATH 0x2 |
274 | 274 | ||
275 | struct mu_gocs_sieve | ||
276 | { | ||
277 | int clearflags; | ||
278 | /* mu_list_t include_path_prefix;*/ | ||
279 | mu_list_t include_path; | ||
280 | mu_list_t library_path_prefix; | ||
281 | mu_list_t library_path; | ||
282 | }; | ||
283 | |||
284 | int mu_sieve_module_init (enum mu_gocs_op, void *); | ||
285 | |||
286 | extern struct mu_cli_capa mu_cli_capa_sieve; | 275 | extern struct mu_cli_capa mu_cli_capa_sieve; |
287 | 276 | ||
288 | #ifdef __cplusplus | 277 | #ifdef __cplusplus | ... | ... |
... | @@ -29,24 +29,6 @@ enum mu_password_type | ... | @@ -29,24 +29,6 @@ enum mu_password_type |
29 | 29 | ||
30 | struct mu_sql_module_config | 30 | struct mu_sql_module_config |
31 | { | 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 | int positional; | ||
43 | mu_assoc_t field_map; | ||
44 | }; | ||
45 | |||
46 | /* FIXME: Should not be here, but needed for several other sources | ||
47 | (imap4d/auth_gsasl.c, for instance) */ | ||
48 | struct mu_internal_sql_config | ||
49 | { | ||
50 | int interface; | 32 | int interface; |
51 | char *getpwnam_query; | 33 | char *getpwnam_query; |
52 | char *getpass_query; | 34 | char *getpass_query; |
... | @@ -61,7 +43,7 @@ struct mu_internal_sql_config | ... | @@ -61,7 +43,7 @@ struct mu_internal_sql_config |
61 | mu_assoc_t field_map; | 43 | mu_assoc_t field_map; |
62 | }; | 44 | }; |
63 | 45 | ||
64 | extern struct mu_internal_sql_config mu_sql_module_config; | 46 | extern struct mu_sql_module_config mu_sql_module_config; |
65 | 47 | ||
66 | /* Loadable Modules Support */ | 48 | /* Loadable Modules Support */ |
67 | #define __s_cat2__(a,b) a ## b | 49 | #define __s_cat2__(a,b) a ## b |
... | @@ -131,7 +113,7 @@ struct mu_sql_dispatch | ... | @@ -131,7 +113,7 @@ struct mu_sql_dispatch |
131 | }; | 113 | }; |
132 | 114 | ||
133 | /* Public interfaces */ | 115 | /* Public interfaces */ |
134 | int mu_sql_interface_index (char *name); | 116 | int mu_sql_interface_index (char const *name); |
135 | 117 | ||
136 | int mu_sql_connection_init (mu_sql_connection_t *conn, int interface, | 118 | int mu_sql_connection_init (mu_sql_connection_t *conn, int interface, |
137 | char *server, int port, char *login, | 119 | char *server, int port, char *login, | ... | ... |
... | @@ -42,8 +42,6 @@ struct mu_tls_module_config | ... | @@ -42,8 +42,6 @@ struct mu_tls_module_config |
42 | char *priorities; | 42 | char *priorities; |
43 | }; | 43 | }; |
44 | 44 | ||
45 | extern int mu_tls_module_init (enum mu_gocs_op, void *); | ||
46 | |||
47 | extern int mu_tls_server_stream_create (mu_stream_t *stream, | 45 | extern int mu_tls_server_stream_create (mu_stream_t *stream, |
48 | mu_stream_t strin, mu_stream_t strout, | 46 | mu_stream_t strin, mu_stream_t strout, |
49 | int flags); | 47 | int flags); | ... | ... |
... | @@ -151,12 +151,6 @@ struct mu_locus | ... | @@ -151,12 +151,6 @@ struct mu_locus |
151 | unsigned mu_col; | 151 | unsigned mu_col; |
152 | }; | 152 | }; |
153 | 153 | ||
154 | enum mu_gocs_op | ||
155 | { | ||
156 | mu_gocs_op_set, | ||
157 | mu_gocs_op_flush | ||
158 | }; | ||
159 | |||
160 | #ifdef __cplusplus | 154 | #ifdef __cplusplus |
161 | } | 155 | } |
162 | #endif | 156 | #endif | ... | ... |
lib/argp_base.c
deleted
100644 → 0
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2007, 2009-2012, 2014-2016 Free Software Foundation, | ||
3 | 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, see | ||
17 | <http://www.gnu.org/licenses/>. */ | ||
18 | |||
19 | #ifdef HAVE_CONFIG_H | ||
20 | # include <config.h> | ||
21 | #endif | ||
22 | #include <unistd.h> | ||
23 | #include <string.h> | ||
24 | |||
25 | char * | ||
26 | __argp_base_name (const char *arg) | ||
27 | { | ||
28 | char *p = strrchr (arg, '/'); | ||
29 | return (char *)(p ? p + 1 : arg); | ||
30 | } | ||
31 |
... | @@ -161,23 +161,19 @@ mu_auth_data_destroy (struct mu_auth_data **pptr) | ... | @@ -161,23 +161,19 @@ mu_auth_data_destroy (struct mu_auth_data **pptr) |
161 | 161 | ||
162 | /* Generic functions */ | 162 | /* Generic functions */ |
163 | 163 | ||
164 | struct auth_stack_entry { | 164 | static void |
165 | char *name; /* for diagnostics purposes */ | 165 | append_auth_module (mu_list_t *pflist, struct mu_auth_module *mod) |
166 | mu_auth_fp fun; | ||
167 | void *func_data; | ||
168 | }; | ||
169 | |||
170 | void | ||
171 | mu_insert_stack_entry (mu_list_t *pflist, struct auth_stack_entry *entry) | ||
172 | { | 166 | { |
173 | if (!*pflist && mu_list_create (pflist)) | 167 | if (!*pflist && mu_list_create (pflist)) |
174 | return; | 168 | return; |
175 | mu_list_append (*pflist, entry); | 169 | mu_list_append (*pflist, mod); |
176 | } | 170 | } |
177 | 171 | ||
178 | int | 172 | int |
179 | mu_auth_runlist (mu_list_t flist, struct mu_auth_data **return_data, | 173 | mu_auth_runlist (mu_list_t flist, |
180 | const void *key, void *data) | 174 | enum mu_auth_mode mode, |
175 | const void *key, void *data, | ||
176 | struct mu_auth_data **return_data) | ||
181 | { | 177 | { |
182 | int status = MU_ERR_AUTH_FAILURE; | 178 | int status = MU_ERR_AUTH_FAILURE; |
183 | int rc; | 179 | int rc; |
... | @@ -185,15 +181,17 @@ mu_auth_runlist (mu_list_t flist, struct mu_auth_data **return_data, | ... | @@ -185,15 +181,17 @@ mu_auth_runlist (mu_list_t flist, struct mu_auth_data **return_data, |
185 | 181 | ||
186 | if (mu_list_get_iterator (flist, &itr) == 0) | 182 | if (mu_list_get_iterator (flist, &itr) == 0) |
187 | { | 183 | { |
188 | struct auth_stack_entry *ep; | 184 | struct mu_auth_module *ep; |
189 | 185 | ||
190 | for (mu_iterator_first (itr); !mu_iterator_is_done (itr); | 186 | for (mu_iterator_first (itr); !mu_iterator_is_done (itr); |
191 | mu_iterator_next (itr)) | 187 | mu_iterator_next (itr)) |
192 | { | 188 | { |
193 | mu_iterator_current (itr, (void **)&ep); | 189 | mu_iterator_current (itr, (void **)&ep); |
190 | if (!ep->handler[mode]) | ||
191 | continue; | ||
194 | mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE2, | 192 | mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE2, |
195 | ("Trying %s...", ep->name)); | 193 | ("Trying %s...", ep->name)); |
196 | rc = ep->fun (return_data, key, ep->func_data, data); | 194 | rc = ep->handler[mode] (return_data, key, ep->data[mode], data); |
197 | mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE2, | 195 | mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE2, |
198 | ("%s yields %d=%s", ep->name, rc, mu_strerror (rc))); | 196 | ("%s yields %d=%s", ep->name, rc, mu_strerror (rc))); |
199 | if (rc == 0) | 197 | if (rc == 0) |
... | @@ -230,30 +228,25 @@ mu_auth_nosupport (struct mu_auth_data **return_data MU_ARG_UNUSED, | ... | @@ -230,30 +228,25 @@ mu_auth_nosupport (struct mu_auth_data **return_data MU_ARG_UNUSED, |
230 | 228 | ||
231 | /* II. Authorization: retrieving information about user */ | 229 | /* II. Authorization: retrieving information about user */ |
232 | 230 | ||
233 | static mu_list_t mu_auth_by_name_list, _tmp_auth_by_name_list; | 231 | static mu_list_t mu_getpw_modules, selected_getpw_modules; |
234 | static mu_list_t mu_auth_by_uid_list, _tmp_auth_by_uid_list; | ||
235 | 232 | ||
236 | int | 233 | int |
237 | mu_get_auth (struct mu_auth_data **auth, enum mu_auth_key_type type, | 234 | mu_get_auth (struct mu_auth_data **auth, enum mu_auth_key_type type, |
238 | const void *key) | 235 | const void *key) |
239 | { | 236 | { |
240 | mu_list_t list; | 237 | if (!mu_getpw_modules) |
241 | |||
242 | if (!mu_auth_by_name_list) | ||
243 | mu_auth_begin_setup (); | 238 | mu_auth_begin_setup (); |
244 | switch (type) | 239 | switch (type) |
245 | { | 240 | { |
246 | case mu_auth_key_name: | 241 | case mu_auth_key_name: |
247 | mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE1, | 242 | mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE1, |
248 | ("Getting auth info for user %s", (char*) key)); | 243 | ("Getting auth info for user %s", (char*) key)); |
249 | list = mu_auth_by_name_list; | ||
250 | break; | 244 | break; |
251 | 245 | ||
252 | case mu_auth_key_uid: | 246 | case mu_auth_key_uid: |
253 | mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE1, | 247 | mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE1, |
254 | ("Getting auth info for UID %lu", | 248 | ("Getting auth info for UID %lu", |
255 | (unsigned long) *(uid_t*) key)); | 249 | (unsigned long) *(uid_t*) key)); |
256 | list = mu_auth_by_uid_list; | ||
257 | break; | 250 | break; |
258 | 251 | ||
259 | default: | 252 | default: |
... | @@ -261,7 +254,7 @@ mu_get_auth (struct mu_auth_data **auth, enum mu_auth_key_type type, | ... | @@ -261,7 +254,7 @@ mu_get_auth (struct mu_auth_data **auth, enum mu_auth_key_type type, |
261 | ("Unknown mu_auth_key_type: %d", type)); | 254 | ("Unknown mu_auth_key_type: %d", type)); |
262 | return EINVAL; | 255 | return EINVAL; |
263 | } | 256 | } |
264 | return mu_auth_runlist (list, auth, key, NULL); | 257 | return mu_auth_runlist (mu_getpw_modules, type, key, NULL, auth); |
265 | } | 258 | } |
266 | 259 | ||
267 | struct mu_auth_data * | 260 | struct mu_auth_data * |
... | @@ -282,7 +275,7 @@ mu_get_auth_by_uid (uid_t uid) | ... | @@ -282,7 +275,7 @@ mu_get_auth_by_uid (uid_t uid) |
282 | 275 | ||
283 | /* III. Authentication: determining the authenticity of a user */ | 276 | /* III. Authentication: determining the authenticity of a user */ |
284 | 277 | ||
285 | static mu_list_t mu_authenticate_list, _tmp_authenticate_list; | 278 | static mu_list_t mu_auth_modules, selected_auth_modules; |
286 | 279 | ||
287 | int | 280 | int |
288 | mu_authenticate (struct mu_auth_data *auth_data, const char *pass) | 281 | mu_authenticate (struct mu_auth_data *auth_data, const char *pass) |
... | @@ -292,68 +285,52 @@ mu_authenticate (struct mu_auth_data *auth_data, const char *pass) | ... | @@ -292,68 +285,52 @@ mu_authenticate (struct mu_auth_data *auth_data, const char *pass) |
292 | mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE1, | 285 | mu_debug (MU_DEBCAT_AUTH, MU_DEBUG_TRACE1, |
293 | ("mu_authenticate, user %s, source %s", | 286 | ("mu_authenticate, user %s, source %s", |
294 | auth_data->name, auth_data->source)); | 287 | auth_data->name, auth_data->source)); |
295 | if (!mu_authenticate_list) | 288 | if (!mu_auth_modules) |
296 | mu_auth_begin_setup (); | 289 | mu_auth_begin_setup (); |
297 | return mu_auth_runlist (mu_authenticate_list, NULL, auth_data, (void*) pass); | 290 | return mu_auth_runlist (mu_auth_modules, |
291 | mu_auth_authenticate, | ||
292 | auth_data, pass, NULL); | ||
298 | } | 293 | } |
299 | 294 | ||
300 | 295 | ||
301 | /* ************************************************************************* */ | 296 | /* ************************************************************************* */ |
302 | 297 | ||
303 | struct _module_handler { | 298 | static mu_list_t module_list; |
304 | struct auth_stack_entry authenticate; | ||
305 | struct auth_stack_entry auth_by_name; | ||
306 | struct auth_stack_entry auth_by_uid; | ||
307 | }; | ||
308 | 299 | ||
309 | static mu_list_t module_handler_list; | 300 | static void |
301 | module_list_init (void) | ||
302 | { | ||
303 | if (!module_list) | ||
304 | { | ||
305 | if (mu_list_create (&module_list)) | ||
306 | abort (); | ||
307 | mu_list_append (module_list, &mu_auth_generic_module); | ||
308 | mu_list_append (module_list, &mu_auth_system_module); | ||
309 | } | ||
310 | } | ||
310 | 311 | ||
311 | void | 312 | void |
312 | mu_auth_register_module (struct mu_auth_module *mod) | 313 | mu_auth_register_module (struct mu_auth_module *mod) |
313 | { | 314 | { |
314 | struct _module_handler *entry; | 315 | module_list_init (); |
315 | 316 | mu_list_append (module_list, mod); | |
316 | if (mod->init) | ||
317 | mu_gocs_register (mod->name, mod->init); | ||
318 | |||
319 | if (!module_handler_list && mu_list_create (&module_handler_list)) | ||
320 | abort (); | ||
321 | |||
322 | entry = malloc (sizeof (*entry)); | ||
323 | if (!entry) | ||
324 | { | ||
325 | mu_error ("not enough memory"); | ||
326 | exit (1); | ||
327 | } | ||
328 | entry->authenticate.name = mod->name; | ||
329 | entry->authenticate.fun = mod->authenticate; | ||
330 | entry->authenticate.func_data = mod->authenticate_data; | ||
331 | entry->auth_by_name.name = mod->name; | ||
332 | entry->auth_by_name.fun = mod->auth_by_name; | ||
333 | entry->auth_by_name.func_data = mod->auth_by_name_data; | ||
334 | entry->auth_by_uid.name = mod->name; | ||
335 | entry->auth_by_uid.fun = mod->auth_by_uid; | ||
336 | entry->auth_by_uid.func_data = mod->auth_by_uid_data; | ||
337 | |||
338 | mu_list_append (module_handler_list, entry); | ||
339 | |||
340 | } | 317 | } |
341 | 318 | ||
342 | static struct _module_handler * | 319 | static struct mu_auth_module * |
343 | _locate (const char *name) | 320 | _locate (const char *name) |
344 | { | 321 | { |
345 | struct _module_handler *rp = NULL; | 322 | struct mu_auth_module *rp = NULL; |
346 | mu_iterator_t itr; | 323 | mu_iterator_t itr; |
347 | 324 | ||
348 | if (mu_list_get_iterator (module_handler_list, &itr) == 0) | 325 | if (mu_list_get_iterator (module_list, &itr) == 0) |
349 | { | 326 | { |
350 | struct _module_handler *p; | 327 | struct mu_auth_module *p; |
351 | 328 | ||
352 | for (mu_iterator_first (itr); !rp && !mu_iterator_is_done (itr); | 329 | for (mu_iterator_first (itr); !rp && !mu_iterator_is_done (itr); |
353 | mu_iterator_next (itr)) | 330 | mu_iterator_next (itr)) |
354 | { | 331 | { |
355 | mu_iterator_current (itr, (void **)&p); | 332 | mu_iterator_current (itr, (void **)&p); |
356 | if (strcmp (p->authenticate.name, name) == 0) | 333 | if (strcmp (p->name, name) == 0) |
357 | rp = p; | 334 | rp = p; |
358 | } | 335 | } |
359 | 336 | ||
... | @@ -397,15 +374,14 @@ _add_module_list (const char *modlist, int (*fun)(const char *name)) | ... | @@ -397,15 +374,14 @@ _add_module_list (const char *modlist, int (*fun)(const char *name)) |
397 | int | 374 | int |
398 | mu_authorization_add_module (const char *name) | 375 | mu_authorization_add_module (const char *name) |
399 | { | 376 | { |
400 | struct _module_handler *mod = _locate (name); | 377 | struct mu_auth_module *mod = _locate (name); |
401 | 378 | ||
402 | if (!mod) | 379 | if (!mod) |
403 | { | 380 | { |
404 | errno = MU_ERR_NOENT; | 381 | errno = MU_ERR_NOENT; |
405 | return 1; | 382 | return 1; |
406 | } | 383 | } |
407 | mu_insert_stack_entry (&_tmp_auth_by_name_list, &mod->auth_by_name); | 384 | append_auth_module (&selected_getpw_modules, mod); |
408 | mu_insert_stack_entry (&_tmp_auth_by_uid_list, &mod->auth_by_uid); | ||
409 | return 0; | 385 | return 0; |
410 | } | 386 | } |
411 | 387 | ||
... | @@ -418,22 +394,21 @@ mu_authorization_add_module_list (const char *modlist) | ... | @@ -418,22 +394,21 @@ mu_authorization_add_module_list (const char *modlist) |
418 | void | 394 | void |
419 | mu_authorization_clear_list () | 395 | mu_authorization_clear_list () |
420 | { | 396 | { |
421 | mu_list_destroy (&_tmp_auth_by_name_list); | 397 | mu_list_destroy (&selected_getpw_modules); |
422 | mu_list_destroy (&_tmp_auth_by_uid_list); | ||
423 | } | 398 | } |
424 | 399 | ||
425 | 400 | ||
426 | int | 401 | int |
427 | mu_authentication_add_module (const char *name) | 402 | mu_authentication_add_module (const char *name) |
428 | { | 403 | { |
429 | struct _module_handler *mod = _locate (name); | 404 | struct mu_auth_module *mod = _locate (name); |
430 | 405 | ||
431 | if (!mod) | 406 | if (!mod) |
432 | { | 407 | { |
433 | errno = MU_ERR_NOENT; | 408 | errno = MU_ERR_NOENT; |
434 | return 1; | 409 | return 1; |
435 | } | 410 | } |
436 | mu_insert_stack_entry (&_tmp_authenticate_list, &mod->authenticate); | 411 | append_auth_module (&selected_auth_modules, mod); |
437 | return 0; | 412 | return 0; |
438 | } | 413 | } |
439 | 414 | ||
... | @@ -446,7 +421,7 @@ mu_authentication_add_module_list (const char *modlist) | ... | @@ -446,7 +421,7 @@ mu_authentication_add_module_list (const char *modlist) |
446 | void | 421 | void |
447 | mu_authentication_clear_list () | 422 | mu_authentication_clear_list () |
448 | { | 423 | { |
449 | mu_list_destroy (&_tmp_authenticate_list); | 424 | mu_list_destroy (&selected_auth_modules); |
450 | } | 425 | } |
451 | 426 | ||
452 | 427 | ||
... | @@ -462,45 +437,39 @@ mu_authentication_clear_list () | ... | @@ -462,45 +437,39 @@ mu_authentication_clear_list () |
462 | argp_parse() exits. */ | 437 | argp_parse() exits. */ |
463 | 438 | ||
464 | void | 439 | void |
465 | mu_auth_begin_setup () | 440 | mu_auth_begin_setup (void) |
466 | { | 441 | { |
467 | mu_iterator_t itr; | 442 | mu_iterator_t itr; |
468 | 443 | ||
469 | if (!module_handler_list) | 444 | module_list_init (); |
470 | { | 445 | |
471 | mu_auth_register_module (&mu_auth_generic_module); | 446 | if (!mu_auth_modules) |
472 | mu_auth_register_module (&mu_auth_system_module); | ||
473 | } | ||
474 | |||
475 | if (!mu_authenticate_list) | ||
476 | { | 447 | { |
477 | if (mu_list_get_iterator (module_handler_list, &itr) == 0) | 448 | if (mu_list_get_iterator (module_list, &itr) == 0) |
478 | { | 449 | { |
479 | struct _module_handler *mod; | 450 | struct mu_auth_module *mod; |
480 | 451 | ||
481 | for (mu_iterator_first (itr); !mu_iterator_is_done (itr); | 452 | for (mu_iterator_first (itr); !mu_iterator_is_done (itr); |
482 | mu_iterator_next (itr)) | 453 | mu_iterator_next (itr)) |
483 | { | 454 | { |
484 | mu_iterator_current (itr, (void **)&mod); | 455 | mu_iterator_current (itr, (void **)&mod); |
485 | mu_insert_stack_entry (&mu_authenticate_list, | 456 | append_auth_module (&mu_auth_modules, mod); |
486 | &mod->authenticate); | ||
487 | } | 457 | } |
488 | mu_iterator_destroy (&itr); | 458 | mu_iterator_destroy (&itr); |
489 | } | 459 | } |
490 | } | 460 | } |
491 | 461 | ||
492 | if (!mu_auth_by_name_list) | 462 | if (!mu_getpw_modules) |
493 | { | 463 | { |
494 | if (mu_list_get_iterator (module_handler_list, &itr) == 0) | 464 | if (mu_list_get_iterator (module_list, &itr) == 0) |
495 | { | 465 | { |
496 | struct _module_handler *mod; | 466 | struct mu_auth_module *mod; |
497 | 467 | ||
498 | for (mu_iterator_first (itr); !mu_iterator_is_done (itr); | 468 | for (mu_iterator_first (itr); !mu_iterator_is_done (itr); |
499 | mu_iterator_next (itr)) | 469 | mu_iterator_next (itr)) |
500 | { | 470 | { |
501 | mu_iterator_current (itr, (void **)&mod); | 471 | mu_iterator_current (itr, (void **)&mod); |
502 | mu_insert_stack_entry (&mu_auth_by_name_list, &mod->auth_by_name); | 472 | append_auth_module (&mu_getpw_modules, mod); |
503 | mu_insert_stack_entry (&mu_auth_by_uid_list, &mod->auth_by_uid); | ||
504 | } | 473 | } |
505 | mu_iterator_destroy (&itr); | 474 | mu_iterator_destroy (&itr); |
506 | } | 475 | } |
... | @@ -508,20 +477,48 @@ mu_auth_begin_setup () | ... | @@ -508,20 +477,48 @@ mu_auth_begin_setup () |
508 | } | 477 | } |
509 | 478 | ||
510 | void | 479 | void |
511 | mu_auth_finish_setup () | 480 | mu_auth_finish_setup (void) |
512 | { | 481 | { |
513 | mu_list_destroy (&mu_authenticate_list); | 482 | mu_list_destroy (&mu_auth_modules); |
514 | mu_list_destroy (&mu_auth_by_name_list); | 483 | mu_auth_modules = selected_auth_modules; |
515 | mu_list_destroy (&mu_auth_by_uid_list); | 484 | selected_auth_modules = NULL; |
516 | 485 | ||
517 | mu_authenticate_list = _tmp_authenticate_list; | 486 | mu_list_destroy (&mu_getpw_modules); |
518 | _tmp_authenticate_list = NULL; | 487 | mu_getpw_modules = selected_getpw_modules; |
519 | mu_auth_by_name_list = _tmp_auth_by_name_list; | 488 | selected_getpw_modules = NULL; |
520 | _tmp_auth_by_name_list = NULL; | ||
521 | mu_auth_by_uid_list = _tmp_auth_by_uid_list; | ||
522 | _tmp_auth_by_uid_list = NULL; | ||
523 | 489 | ||
524 | mu_auth_begin_setup (); | 490 | mu_auth_begin_setup (); |
525 | } | 491 | } |
492 | |||
493 | struct settings | ||
494 | { | ||
495 | mu_list_t opts; | ||
496 | mu_list_t commits; | ||
497 | }; | ||
498 | |||
499 | static int | ||
500 | do_extend (void *item, void *data) | ||
501 | { | ||
502 | struct mu_auth_module *mod = item; | ||
503 | struct settings *set = data; | ||
504 | |||
505 | if (mod->opt) | ||
506 | mu_list_append (set->opts, mod->opt); | ||
507 | if (mod->commit) | ||
508 | mu_list_append (set->commits, mod->commit); | ||
509 | if (mod->parser || mod->cfg) | ||
510 | mu_config_root_register_section (NULL, mod->name, NULL, | ||
511 | mod->parser, mod->cfg); | ||
512 | return 0; | ||
513 | } | ||
514 | |||
515 | void | ||
516 | mu_auth_extend_settings (mu_list_t opts, mu_list_t commits) | ||
517 | { | ||
518 | struct settings s; | ||
519 | s.opts = opts; | ||
520 | s.commits = commits; | ||
521 | mu_list_foreach (module_list, do_extend, &s); | ||
522 | } | ||
526 | 523 | ||
527 | 524 | ... | ... |
... | @@ -141,25 +141,19 @@ mu_authenticate_system (struct mu_auth_data **return_data MU_ARG_UNUSED, | ... | @@ -141,25 +141,19 @@ mu_authenticate_system (struct mu_auth_data **return_data MU_ARG_UNUSED, |
141 | 141 | ||
142 | 142 | ||
143 | struct mu_auth_module mu_auth_system_module = { | 143 | struct mu_auth_module mu_auth_system_module = { |
144 | "system", | 144 | .name = "system", |
145 | NULL, | 145 | .handler = { |
146 | mu_authenticate_system, | 146 | [mu_auth_authenticate] = mu_authenticate_system, |
147 | NULL, | 147 | [mu_auth_getpwnam] = mu_auth_system_by_name, |
148 | mu_auth_system_by_name, | 148 | [mu_auth_getpwuid] = mu_auth_system_by_uid |
149 | NULL, | 149 | } |
150 | mu_auth_system_by_uid, | ||
151 | NULL | ||
152 | }; | 150 | }; |
153 | 151 | ||
154 | 152 | ||
155 | struct mu_auth_module mu_auth_generic_module = { | 153 | struct mu_auth_module mu_auth_generic_module = { |
156 | "generic", | 154 | .name = "generic", |
157 | NULL, | 155 | .handler = { |
158 | mu_authenticate_generic, | 156 | [mu_auth_authenticate] = mu_authenticate_generic |
159 | NULL, | 157 | } |
160 | mu_auth_nosupport, | ||
161 | NULL, | ||
162 | mu_auth_nosupport, | ||
163 | NULL | ||
164 | }; | 158 | }; |
165 | 159 | ... | ... |
... | @@ -21,8 +21,7 @@ libcfg_la_SOURCES = \ | ... | @@ -21,8 +21,7 @@ libcfg_la_SOURCES = \ |
21 | driver.c\ | 21 | driver.c\ |
22 | format.c\ | 22 | format.c\ |
23 | lexer.c\ | 23 | lexer.c\ |
24 | parser.c\ | 24 | parser.c |
25 | gocs.c | ||
26 | 25 | ||
27 | localedir = $(datadir)/locale | 26 | localedir = $(datadir)/locale |
28 | AM_CPPFLAGS = \ | 27 | AM_CPPFLAGS = \ | ... | ... |
libmailutils/cfg/gocs.c
deleted
100644 → 0
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2007-2012, 2014-2016 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, see | ||
16 | <http://www.gnu.org/licenses/>. */ | ||
17 | |||
18 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | #include <stdlib.h> | ||
22 | #include <string.h> | ||
23 | #include <mailutils/types.h> | ||
24 | #include <mailutils/gocs.h> | ||
25 | #include <mailutils/mailbox.h> | ||
26 | #include <mailutils/locker.h> | ||
27 | #include <mailutils/util.h> | ||
28 | #include <mailutils/mailer.h> | ||
29 | #include <mailutils/error.h> | ||
30 | #include <mailutils/errno.h> | ||
31 | #include <mailutils/nls.h> | ||
32 | #include <mailutils/debug.h> | ||
33 | #include <mailutils/syslog.h> | ||
34 | #include <mailutils/registrar.h> | ||
35 | #include <mailutils/stdstream.h> | ||
36 | #include <mailutils/stream.h> | ||
37 | #include <mailutils/log.h> | ||
38 | #include <syslog.h> | ||
39 | |||
40 | #ifndef MU_CONFIG_FILE | ||
41 | # define MU_CONFIG_FILE SYSCONFDIR "/mailutils.rc" | ||
42 | #endif | ||
43 | |||
44 | char *mu_site_rcfile = MU_CONFIG_FILE; | ||
45 | int mu_load_user_rcfile = 1; | ||
46 | int mu_load_site_rcfile = 1; | ||
47 | char *mu_load_rcfile = NULL; | ||
48 | |||
49 | |||
50 | int | ||
51 | mu_gocs_dummy (enum mu_gocs_op op, void *data) | ||
52 | { | ||
53 | return 0; | ||
54 | } | ||
55 | |||
56 | int | ||
57 | mu_gocs_mailbox_init (enum mu_gocs_op op, void *data) | ||
58 | { | ||
59 | int rc; | ||
60 | struct mu_gocs_mailbox *p = data; | ||
61 | |||
62 | if (op == mu_gocs_op_set && p) | ||
63 | { | ||
64 | if (p->mail_spool) | ||
65 | { | ||
66 | rc = mu_set_mail_directory (p->mail_spool); | ||
67 | if (rc) | ||
68 | mu_error (_("cannot set mail directory name to `%s': %s"), | ||
69 | p->mail_spool, mu_strerror (rc)); | ||
70 | free (p->mail_spool); | ||
71 | p->mail_spool = NULL; | ||
72 | } | ||
73 | if (p->mailbox_pattern) | ||
74 | { | ||
75 | rc = mu_set_mailbox_pattern (p->mailbox_pattern); | ||
76 | if (rc) | ||
77 | mu_error (_("cannot set mailbox pattern to `%s': %s"), | ||
78 | p->mailbox_pattern, mu_strerror (rc)); | ||
79 | free (p->mailbox_pattern); | ||
80 | p->mailbox_pattern = NULL; | ||
81 | } | ||
82 | if (p->mailbox_type) | ||
83 | { | ||
84 | if (mu_registrar_set_default_scheme (p->mailbox_type)) | ||
85 | mu_error (_("invalid mailbox type: %s"), p->mailbox_type); | ||
86 | free (p->mailbox_type); | ||
87 | p->mailbox_type = NULL; | ||
88 | } | ||
89 | } | ||
90 | return 0; | ||
91 | } | ||
92 | |||
93 | int | ||
94 | mu_gocs_locking_init (enum mu_gocs_op op, void *data) | ||
95 | { | ||
96 | struct mu_gocs_locking *p = data; | ||
97 | |||
98 | if (!(op == mu_gocs_op_set && p)) | ||
99 | return 0; | ||
100 | |||
101 | if (p->lock_flags) | ||
102 | { | ||
103 | int flags = 0; | ||
104 | char *s; | ||
105 | |||
106 | for (s = p->lock_flags; *s; s++) | ||
107 | { | ||
108 | switch (*s) | ||
109 | { | ||
110 | case 'E': | ||
111 | flags |= MU_LOCKER_EXTERNAL; | ||
112 | break; | ||
113 | |||
114 | case 'R': | ||
115 | flags |= MU_LOCKER_RETRY; | ||
116 | break; | ||
117 | |||
118 | case 'T': | ||
119 | flags |= MU_LOCKER_TIME; | ||
120 | break; | ||
121 | |||
122 | case 'P': | ||
123 | flags |= MU_LOCKER_PID; | ||
124 | break; | ||
125 | |||
126 | default: | ||
127 | mu_error (_("invalid lock flag `%c'"), *s); | ||
128 | } | ||
129 | } | ||
130 | mu_locker_set_default_flags (flags, mu_locker_assign); | ||
131 | free (p->lock_flags); | ||
132 | p->lock_flags = NULL; | ||
133 | } | ||
134 | |||
135 | if (p->lock_retry_count) | ||
136 | { | ||
137 | mu_locker_set_default_retry_count (p->lock_retry_count); | ||
138 | mu_locker_set_default_flags (MU_LOCKER_RETRY, mu_locker_set_bit); | ||
139 | p->lock_retry_count = 0; | ||
140 | } | ||
141 | |||
142 | if (p->lock_retry_timeout) | ||
143 | { | ||
144 | mu_locker_set_default_retry_timeout (p->lock_retry_timeout); | ||
145 | mu_locker_set_default_flags (MU_LOCKER_RETRY, mu_locker_set_bit); | ||
146 | p->lock_retry_timeout = 0; | ||
147 | } | ||
148 | |||
149 | if (p->lock_expire_timeout) | ||
150 | { | ||
151 | mu_locker_set_default_expire_timeout (p->lock_expire_timeout); | ||
152 | mu_locker_set_default_flags (MU_LOCKER_EXTERNAL, mu_locker_set_bit); | ||
153 | p->lock_expire_timeout = 0; | ||
154 | } | ||
155 | |||
156 | if (p->external_locker) | ||
157 | { | ||
158 | mu_locker_set_default_external_program (p->external_locker); | ||
159 | mu_locker_set_default_flags (MU_LOCKER_TIME, mu_locker_set_bit); | ||
160 | free (p->external_locker); | ||
161 | p->external_locker = NULL; | ||
162 | } | ||
163 | return 0; | ||
164 | } | ||
165 | |||
166 | int | ||
167 | mu_gocs_source_email_init (enum mu_gocs_op op, void *data) | ||
168 | { | ||
169 | struct mu_gocs_source_email *p = data; | ||
170 | int rc; | ||
171 | |||
172 | if (!(op == mu_gocs_op_set && p)) | ||
173 | return 0; | ||
174 | |||
175 | if (p->address) | ||
176 | { | ||
177 | if ((rc = mu_set_user_email (p->address)) != 0) | ||
178 | mu_error (_("invalid email address `%s': %s"), | ||
179 | p->address, mu_strerror (rc)); | ||
180 | free (p->address); | ||
181 | p->address = NULL; | ||
182 | } | ||
183 | |||
184 | if (p->domain) | ||
185 | { | ||
186 | if ((rc = mu_set_user_email_domain (p->domain)) != 0) | ||
187 | mu_error (_("invalid email domain `%s': %s"), | ||
188 | p->domain, mu_strerror (rc)); | ||
189 | |||
190 | free (p->domain); | ||
191 | p->domain = NULL; | ||
192 | } | ||
193 | return 0; | ||
194 | } | ||
195 | |||
196 | int | ||
197 | mu_gocs_mailer_init (enum mu_gocs_op op, void *data) | ||
198 | { | ||
199 | struct mu_gocs_mailer *p = data; | ||
200 | int rc; | ||
201 | |||
202 | if (!(op == mu_gocs_op_set && p)) | ||
203 | return 0; | ||
204 | |||
205 | if (p->mailer) | ||
206 | { | ||
207 | if ((rc = mu_mailer_set_url_default (p->mailer)) != 0) | ||
208 | mu_error (_("invalid mailer URL `%s': %s"), | ||
209 | p->mailer, mu_strerror (rc)); | ||
210 | free (p->mailer); | ||
211 | p->mailer = NULL; | ||
212 | } | ||
213 | return 0; | ||
214 | } | ||
215 | |||
216 | int | ||
217 | mu_gocs_logging_init (enum mu_gocs_op op, void *data) | ||
218 | { | ||
219 | if (mu_log_syslog >= 0) | ||
220 | mu_stdstream_strerr_setup (mu_log_syslog ? | ||
221 | MU_STRERR_SYSLOG : MU_STRERR_STDERR); | ||
222 | return 0; | ||
223 | } | ||
224 | |||
225 | int | ||
226 | mu_gocs_debug_init (enum mu_gocs_op op, void *data) | ||
227 | { | ||
228 | if (op == mu_gocs_op_set && data) | ||
229 | { | ||
230 | struct mu_gocs_debug *p = data; | ||
231 | if (p->string) | ||
232 | mu_debug_parse_spec (p->string); | ||
233 | if (p->line_info >= 0) | ||
234 | mu_debug_line_info = p->line_info; | ||
235 | } | ||
236 | return 0; | ||
237 | } | ||
238 | |||
239 | |||
240 | struct mu_gocs_entry | ||
241 | { | ||
242 | const char *name; | ||
243 | mu_gocs_init_fp init; | ||
244 | }; | ||
245 | |||
246 | #define MAX_GOCS 512 | ||
247 | |||
248 | static struct mu_gocs_entry _gocs_table[MAX_GOCS]; | ||
249 | |||
250 | void | ||
251 | mu_gocs_register (const char *capa, mu_gocs_init_fp init) | ||
252 | { | ||
253 | int i; | ||
254 | for (i = 0; _gocs_table[i].name; i++) | ||
255 | { | ||
256 | if (i == MAX_GOCS-1) | ||
257 | { | ||
258 | mu_error (_("gocs table overflow")); | ||
259 | abort (); | ||
260 | } | ||
261 | else if (strcmp (_gocs_table[i].name, capa) == 0) | ||
262 | return; | ||
263 | } | ||
264 | _gocs_table[i].name = capa; | ||
265 | _gocs_table[i].init = init; | ||
266 | } | ||
267 | |||
268 | int | ||
269 | mu_gocs_enumerate (mu_list_action_t action, void *data) | ||
270 | { | ||
271 | int i; | ||
272 | |||
273 | for (i = 0; _gocs_table[i].name; i++) | ||
274 | { | ||
275 | int rc = action ((void*) _gocs_table[i].name, data); | ||
276 | if (rc) | ||
277 | return rc; | ||
278 | } | ||
279 | return 0; | ||
280 | } | ||
281 | |||
282 | static mu_gocs_init_fp | ||
283 | find_init_function (struct mu_gocs_entry *tab, const char *capa) | ||
284 | { | ||
285 | for (; tab->name; tab++) | ||
286 | if (strcmp (tab->name, capa) == 0) | ||
287 | return tab->init; | ||
288 | return NULL; | ||
289 | } | ||
290 | |||
291 | static struct mu_gocs_entry std_gocs_table[] = { | ||
292 | { "mailutils", mu_gocs_dummy }, | ||
293 | { "common", mu_gocs_dummy }, | ||
294 | { "mailbox", mu_gocs_mailbox_init }, | ||
295 | { "locking", mu_gocs_locking_init }, | ||
296 | { "address", mu_gocs_source_email_init }, | ||
297 | { "mailer", mu_gocs_mailer_init }, | ||
298 | { "logging", mu_gocs_logging_init }, | ||
299 | { "debug", mu_gocs_debug_init }, | ||
300 | { "auth", mu_gocs_dummy }, | ||
301 | { NULL } | ||
302 | }; | ||
303 | |||
304 | void | ||
305 | mu_gocs_register_std (const char *name) | ||
306 | { | ||
307 | mu_gocs_init_fp init = find_init_function (std_gocs_table, name); | ||
308 | if (!init) | ||
309 | { | ||
310 | mu_error (_("INTERNAL ERROR at %s:%d: unknown standard capability `%s'"), | ||
311 | __FILE__, __LINE__, name); | ||
312 | abort (); | ||
313 | } | ||
314 | mu_gocs_register (name, init); | ||
315 | } | ||
316 | |||
317 | |||
318 | struct mu_gocs_data | ||
319 | { | ||
320 | char *capa; | ||
321 | void *data; | ||
322 | }; | ||
323 | |||
324 | static mu_list_t /* of struct mu_gocs_data */ data_list; | ||
325 | |||
326 | static int | ||
327 | _gocs_comp (const void *a, const void *b) | ||
328 | { | ||
329 | const struct mu_gocs_data *da = a, *db = b; | ||
330 | return !(strcmp (da->capa, db->capa) == 0 && da->data == db->data); | ||
331 | } | ||
332 | |||
333 | void | ||
334 | mu_gocs_store (char *capa, void *data) | ||
335 | { | ||
336 | struct mu_gocs_data *s; | ||
337 | if (!data_list) | ||
338 | { | ||
339 | mu_list_create (&data_list); | ||
340 | mu_list_set_destroy_item (data_list, mu_list_free_item); | ||
341 | mu_list_set_comparator (data_list, _gocs_comp); | ||
342 | } | ||
343 | s = malloc (sizeof *s); | ||
344 | if (!s) | ||
345 | { | ||
346 | mu_error ("%s", mu_strerror (ENOMEM)); | ||
347 | exit (1); | ||
348 | } | ||
349 | s->capa = capa; | ||
350 | s->data = data; | ||
351 | if (mu_list_locate (data_list, s, NULL) == 0) | ||
352 | free (s); | ||
353 | else | ||
354 | mu_list_prepend (data_list, s); | ||
355 | } | ||
356 | |||
357 | int | ||
358 | _gocs_flush (void *item, void *data) | ||
359 | { | ||
360 | struct mu_gocs_data *s = item; | ||
361 | mu_gocs_init_fp initfun = find_init_function (_gocs_table, s->capa); | ||
362 | |||
363 | if (!initfun) | ||
364 | { | ||
365 | mu_error (_("INTERNAL ERROR at %s:%d: unknown capability `%s'"), | ||
366 | __FILE__, __LINE__, s->capa); | ||
367 | abort (); | ||
368 | } | ||
369 | |||
370 | if (initfun (mu_gocs_op_set, s->data)) | ||
371 | { | ||
372 | mu_error (_("initialization of GOCS `%s' failed"), s->capa); | ||
373 | return 1; | ||
374 | } | ||
375 | |||
376 | return 0; | ||
377 | } | ||
378 | |||
379 | void | ||
380 | mu_gocs_flush () | ||
381 | { | ||
382 | int i; | ||
383 | mu_list_foreach (data_list, _gocs_flush, NULL); | ||
384 | |||
385 | for (i = 0; _gocs_table[i].name; i++) | ||
386 | _gocs_table[i].init (mu_gocs_op_flush, NULL); | ||
387 | } |
... | @@ -60,7 +60,7 @@ struct capa_apply | ... | @@ -60,7 +60,7 @@ struct capa_apply |
60 | }; | 60 | }; |
61 | 61 | ||
62 | static int | 62 | static int |
63 | capa_apply (void *item, void *data) | 63 | capa_extend (void *item, void *data) |
64 | { | 64 | { |
65 | struct mu_cli_capa *cp = item; | 65 | struct mu_cli_capa *cp = item; |
66 | struct capa_apply *ap = data; | 66 | struct capa_apply *ap = data; |
... | @@ -80,14 +80,15 @@ capa_apply (void *item, void *data) | ... | @@ -80,14 +80,15 @@ capa_apply (void *item, void *data) |
80 | } | 80 | } |
81 | 81 | ||
82 | void | 82 | void |
83 | mu_cli_capa_apply (char const *name, mu_list_t opts, mu_list_t commits) | 83 | mu_cli_capa_extend_settings (char const *name, mu_list_t opts, |
84 | mu_list_t commits) | ||
84 | { | 85 | { |
85 | struct capa_apply app; | 86 | struct capa_apply app; |
86 | app.name = name; | 87 | app.name = name; |
87 | app.opts = opts; | 88 | app.opts = opts; |
88 | app.commits = commits; | 89 | app.commits = commits; |
89 | app.found = 0; | 90 | app.found = 0; |
90 | mu_list_foreach (capa_list, capa_apply, &app); | 91 | mu_list_foreach (capa_list, capa_extend, &app); |
91 | if (!app.found) | 92 | if (!app.found) |
92 | mu_error (_("INTERNAL ERROR at %s:%d: unknown standard capability `%s'"), | 93 | mu_error (_("INTERNAL ERROR at %s:%d: unknown standard capability `%s'"), |
93 | __FILE__, __LINE__, name); | 94 | __FILE__, __LINE__, name); | ... | ... |
... | @@ -31,6 +31,7 @@ | ... | @@ -31,6 +31,7 @@ |
31 | #include <mailutils/stdstream.h> | 31 | #include <mailutils/stdstream.h> |
32 | #include <mailutils/io.h> | 32 | #include <mailutils/io.h> |
33 | #include <mailutils/syslog.h> | 33 | #include <mailutils/syslog.h> |
34 | #include <mailutils/mu_auth.h> | ||
34 | 35 | ||
35 | #ifndef MU_SITE_CONFIG_FILE | 36 | #ifndef MU_SITE_CONFIG_FILE |
36 | # define MU_SITE_CONFIG_FILE SYSCONFDIR "/mailutils.rc" | 37 | # define MU_SITE_CONFIG_FILE SYSCONFDIR "/mailutils.rc" |
... | @@ -85,6 +86,14 @@ extra_help_hook (struct mu_parseopt *po, mu_stream_t stream) | ... | @@ -85,6 +86,14 @@ extra_help_hook (struct mu_parseopt *po, mu_stream_t stream) |
85 | struct mu_cli_setup *setup = hints->data; | 86 | struct mu_cli_setup *setup = hints->data; |
86 | mu_stream_printf (stream, "%s\n", _(setup->prog_extra_doc)); | 87 | mu_stream_printf (stream, "%s\n", _(setup->prog_extra_doc)); |
87 | } | 88 | } |
89 | |||
90 | static void | ||
91 | prog_doc_hook (struct mu_parseopt *po, mu_stream_t stream) | ||
92 | { | ||
93 | struct mu_cfg_parse_hints *hints = po->po_data; | ||
94 | struct mu_cli_setup *setup = hints->data; | ||
95 | setup->prog_doc_hook (stream); | ||
96 | } | ||
88 | 97 | ||
89 | static void | 98 | static void |
90 | change_progname (struct mu_parseopt *po, struct mu_option *opt, | 99 | change_progname (struct mu_parseopt *po, struct mu_option *opt, |
... | @@ -283,6 +292,7 @@ init_options (char **capa, struct mu_cli_setup *setup, | ... | @@ -283,6 +292,7 @@ init_options (char **capa, struct mu_cli_setup *setup, |
283 | { | 292 | { |
284 | size_t i, s; | 293 | size_t i, s; |
285 | mu_list_t oplist; | 294 | mu_list_t oplist; |
295 | mu_list_t comlist; | ||
286 | struct mu_parseopt po; | 296 | struct mu_parseopt po; |
287 | 297 | ||
288 | mu_list_create (&oplist); | 298 | mu_list_create (&oplist); |
... | @@ -291,16 +301,16 @@ init_options (char **capa, struct mu_cli_setup *setup, | ... | @@ -291,16 +301,16 @@ init_options (char **capa, struct mu_cli_setup *setup, |
291 | for (i = 0; setup->optv[i]; i++) | 301 | for (i = 0; setup->optv[i]; i++) |
292 | mu_list_append (oplist, setup->optv[i]); | 302 | mu_list_append (oplist, setup->optv[i]); |
293 | } | 303 | } |
304 | |||
305 | mu_list_create (&comlist); | ||
306 | mu_auth_extend_settings (oplist, comlist); | ||
294 | if (capa) | 307 | if (capa) |
295 | { | 308 | { |
296 | mu_list_t comlist; | ||
297 | mu_list_create (&comlist); | ||
298 | for (i = 0; capa[i]; i++) | 309 | for (i = 0; capa[i]; i++) |
299 | mu_cli_capa_apply (capa[i], oplist, comlist); | 310 | mu_cli_capa_extend_settings (capa[i], oplist, comlist); |
300 | *ret_comlist = comlist; | ||
301 | } | 311 | } |
302 | else | 312 | |
303 | *ret_comlist = NULL; | 313 | *ret_comlist = comlist; |
304 | 314 | ||
305 | mu_list_append (oplist, mu_common_options); | 315 | mu_list_append (oplist, mu_common_options); |
306 | mu_list_append (oplist, mu_extra_help_options); | 316 | mu_list_append (oplist, mu_extra_help_options); |
... | @@ -346,7 +356,9 @@ mu_cli (int argc, char **argv, struct mu_cli_setup *setup, char **capa, | ... | @@ -346,7 +356,9 @@ mu_cli (int argc, char **argv, struct mu_cli_setup *setup, char **capa, |
346 | setup->ex_usage = EX_USAGE; | 356 | setup->ex_usage = EX_USAGE; |
347 | if (setup->ex_config == 0) | 357 | if (setup->ex_config == 0) |
348 | setup->ex_config = EX_CONFIG; | 358 | setup->ex_config = EX_CONFIG; |
349 | 359 | if (setup->inorder) | |
360 | flags |= MU_PARSEOPT_IN_ORDER; | ||
361 | |||
350 | /* Set program name */ | 362 | /* Set program name */ |
351 | mu_set_program_name (argv[0]); | 363 | mu_set_program_name (argv[0]); |
352 | 364 | ||
... | @@ -358,7 +370,7 @@ mu_cli (int argc, char **argv, struct mu_cli_setup *setup, char **capa, | ... | @@ -358,7 +370,7 @@ mu_cli (int argc, char **argv, struct mu_cli_setup *setup, char **capa, |
358 | 370 | ||
359 | /* Initialize standard capabilities */ | 371 | /* Initialize standard capabilities */ |
360 | mu_cli_capa_init (); | 372 | mu_cli_capa_init (); |
361 | 373 | ||
362 | /* Initialize hints */ | 374 | /* Initialize hints */ |
363 | memset (&hints, 0, sizeof (hints)); | 375 | memset (&hints, 0, sizeof (hints)); |
364 | hints.flags |= MU_CFG_PARSE_SITE_RCFILE; | 376 | hints.flags |= MU_CFG_PARSE_SITE_RCFILE; |
... | @@ -370,6 +382,7 @@ mu_cli (int argc, char **argv, struct mu_cli_setup *setup, char **capa, | ... | @@ -370,6 +382,7 @@ mu_cli (int argc, char **argv, struct mu_cli_setup *setup, char **capa, |
370 | hints.data = setup; | 382 | hints.data = setup; |
371 | 383 | ||
372 | /* Initialize po */ | 384 | /* Initialize po */ |
385 | |||
373 | if (setup->prog_doc) | 386 | if (setup->prog_doc) |
374 | { | 387 | { |
375 | po.po_prog_doc = setup->prog_doc; | 388 | po.po_prog_doc = setup->prog_doc; |
... | @@ -423,6 +436,12 @@ mu_cli (int argc, char **argv, struct mu_cli_setup *setup, char **capa, | ... | @@ -423,6 +436,12 @@ mu_cli (int argc, char **argv, struct mu_cli_setup *setup, char **capa, |
423 | po.po_help_hook = extra_help_hook; | 436 | po.po_help_hook = extra_help_hook; |
424 | flags |= MU_PARSEOPT_HELP_HOOK; | 437 | flags |= MU_PARSEOPT_HELP_HOOK; |
425 | } | 438 | } |
439 | |||
440 | if (setup->prog_doc_hook) | ||
441 | { | ||
442 | po.po_prog_doc_hook = prog_doc_hook; | ||
443 | flags |= MU_PARSEOPT_PROG_DOC_HOOK; | ||
444 | } | ||
426 | 445 | ||
427 | po.po_data = &hints; | 446 | po.po_data = &hints; |
428 | flags |= MU_PARSEOPT_DATA; | 447 | flags |= MU_PARSEOPT_DATA; |
... | @@ -458,7 +477,7 @@ mu_cli (int argc, char **argv, struct mu_cli_setup *setup, char **capa, | ... | @@ -458,7 +477,7 @@ mu_cli (int argc, char **argv, struct mu_cli_setup *setup, char **capa, |
458 | 477 | ||
459 | mu_list_foreach (com_list, run_commit, NULL); | 478 | mu_list_foreach (com_list, run_commit, NULL); |
460 | mu_list_destroy (&com_list); | 479 | mu_list_destroy (&com_list); |
461 | 480 | ||
462 | if (hints.flags & MU_PARSE_CONFIG_LINT) | 481 | if (hints.flags & MU_PARSE_CONFIG_LINT) |
463 | exit (0); | 482 | exit (0); |
464 | 483 | ... | ... |
... | @@ -352,6 +352,12 @@ mu_program_help (struct mu_parseopt *po, mu_stream_t outstr) | ... | @@ -352,6 +352,12 @@ mu_program_help (struct mu_parseopt *po, mu_stream_t outstr) |
352 | } | 352 | } |
353 | mu_stream_printf (str, "\n"); | 353 | mu_stream_printf (str, "\n"); |
354 | 354 | ||
355 | if (po->po_prog_doc_hook) | ||
356 | { | ||
357 | po->po_prog_doc_hook (po, str); | ||
358 | mu_stream_printf (str, "\n"); | ||
359 | } | ||
360 | |||
355 | mu_option_describe_options (str, po->po_optv, po->po_optc); | 361 | mu_option_describe_options (str, po->po_optv, po->po_optc); |
356 | 362 | ||
357 | if (po->po_help_hook) | 363 | if (po->po_help_hook) | ... | ... |
... | @@ -213,6 +213,8 @@ find_long_option (struct mu_parseopt *po, char const *optstr, | ... | @@ -213,6 +213,8 @@ find_long_option (struct mu_parseopt *po, char const *optstr, |
213 | case 0: | 213 | case 0: |
214 | ind = i; | 214 | ind = i; |
215 | found++; | 215 | found++; |
216 | if (optlen == strlen (po->po_optv[i]->opt_long)) | ||
217 | i = po->po_optc - 1; /* exact match: break the loop */ | ||
216 | break; | 218 | break; |
217 | 219 | ||
218 | case 1: | 220 | case 1: |
... | @@ -511,6 +513,8 @@ parseopt_init (struct mu_parseopt *po, struct mu_option **options, | ... | @@ -511,6 +513,8 @@ parseopt_init (struct mu_parseopt *po, struct mu_option **options, |
511 | po->po_exit_error = EXIT_ERROR; | 513 | po->po_exit_error = EXIT_ERROR; |
512 | if (!(flags & MU_PARSEOPT_VERSION_HOOK)) | 514 | if (!(flags & MU_PARSEOPT_VERSION_HOOK)) |
513 | po->po_version_hook = NULL; | 515 | po->po_version_hook = NULL; |
516 | if (!(flags & MU_PARSEOPT_PROG_DOC_HOOK)) | ||
517 | po->po_prog_doc_hook = NULL; | ||
514 | 518 | ||
515 | /* Count the options */ | 519 | /* Count the options */ |
516 | po->po_optc = 0; | 520 | po->po_optc = 0; | ... | ... |
libmu_argp/.gitignore
deleted
100644 → 0
libmu_argp/Makefile.am
deleted
100644 → 0
1 | # This file is part of GNU Mailutils | ||
2 | # Copyright (C) 2007, 2009-2012, 2014-2016 Free Software Foundation, | ||
3 | # Inc. | ||
4 | # | ||
5 | # GNU Mailutils is free software; you can redistribute it and/or | ||
6 | # modify it under the terms of the GNU General Public License as | ||
7 | # published by the Free Software Foundation; either version 3, or (at | ||
8 | # your option) any later version. | ||
9 | # | ||
10 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
11 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | # General Public License for more details. | ||
14 | # | ||
15 | # You should have received a copy of the GNU General Public License | ||
16 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | # This library uses gnulib calls and is always linked with gnulib, therefore | ||
19 | # we use application includes here. | ||
20 | AM_CPPFLAGS = \ | ||
21 | @MU_APP_COMMON_INCLUDES@\ | ||
22 | -DSYSCONFDIR=\"$(sysconfdir)\"\ | ||
23 | -DSITE_VIRTUAL_PWDDIR=\"@SITE_VIRTUAL_PWDDIR@\"\ | ||
24 | -DSITE_CRAM_MD5_PWD=\"@SITE_CRAM_MD5_PWD@\" | ||
25 | |||
26 | lib_LTLIBRARIES = libmu_argp.la | ||
27 | |||
28 | libmu_argp_la_SOURCES =\ | ||
29 | cmdline.c\ | ||
30 | cmdline.h\ | ||
31 | common.c\ | ||
32 | mailutils.c\ | ||
33 | mu_argp.c\ | ||
34 | muinit.c\ | ||
35 | sieve.c | ||
36 | |||
37 | libmu_argp_la_LIBADD=../lib/libmuaux.la | ||
38 | |||
39 | libmu_argp_la_LDFLAGS=-version-info @VI_CURRENT@:@VI_REVISION@:@VI_AGE@ |
libmu_argp/cmdline.c
deleted
100644 → 0
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2007-2012, 2014-2016 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, see | ||
16 | <http://www.gnu.org/licenses/>. */ | ||
17 | |||
18 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | #include <stdlib.h> | ||
22 | #include "cmdline.h" | ||
23 | |||
24 | static struct mu_cmdline_capa *all_cmdline_capa[] = { | ||
25 | &mu_mailutils_cmdline, | ||
26 | &mu_common_cmdline, | ||
27 | &mu_logging_cmdline, | ||
28 | &mu_mailer_cmdline, | ||
29 | &mu_debug_cmdline, | ||
30 | &mu_sieve_cmdline, | ||
31 | NULL | ||
32 | }; | ||
33 | |||
34 | static int libargp_init_passed = 0; | ||
35 | |||
36 | void | ||
37 | mu_libargp_init () | ||
38 | { | ||
39 | struct mu_cmdline_capa **cpp; | ||
40 | if (libargp_init_passed) | ||
41 | return; | ||
42 | libargp_init_passed = 1; | ||
43 | for (cpp = all_cmdline_capa; *cpp; cpp++) | ||
44 | { | ||
45 | struct mu_cmdline_capa *cp = *cpp; | ||
46 | if (mu_register_argp_capa (cp->name, cp->child, cp->modflags)) | ||
47 | { | ||
48 | mu_error (_("INTERNAL ERROR: cannot register argp capability `%s'"), | ||
49 | cp->name); | ||
50 | abort (); | ||
51 | } | ||
52 | } | ||
53 | } | ||
54 | |||
55 | void | ||
56 | mu_argp_node_list_init (mu_list_t *plist) | ||
57 | { | ||
58 | int rc = mu_cfg_create_node_list (plist); | ||
59 | if (rc) | ||
60 | { | ||
61 | mu_diag_funcall (MU_DIAG_ERROR, "mu_cfg_create_node_list", NULL, rc); | ||
62 | abort (); | ||
63 | } | ||
64 | } | ||
65 | |||
66 | void | ||
67 | mu_argp_node_list_add (mu_list_t lst, mu_cfg_node_t *node) | ||
68 | { | ||
69 | int rc = mu_list_append (lst, node); | ||
70 | if (rc) | ||
71 | { | ||
72 | mu_diag_funcall (MU_DIAG_ERROR, "mu_list_append", NULL, rc); | ||
73 | abort (); | ||
74 | } | ||
75 | } | ||
76 | |||
77 | void | ||
78 | mu_argp_node_list_new (mu_list_t lst, const char *tag, const char *label) | ||
79 | { | ||
80 | mu_cfg_node_t *node; | ||
81 | size_t n; | ||
82 | struct mu_locus loc = { "command line", 0 }; | ||
83 | |||
84 | mu_list_count (lst, &n); | ||
85 | loc.mu_line = n; | ||
86 | node = mu_cfg_tree_create_node (mu_argp_tree, mu_cfg_node_param, | ||
87 | &loc, tag, label, NULL); | ||
88 | mu_argp_node_list_add (lst, node); | ||
89 | } | ||
90 | |||
91 | void | ||
92 | mu_argp_node_list_finish (mu_list_t lst, char *tag, char *label) | ||
93 | { | ||
94 | if (mu_list_is_empty (lst)) | ||
95 | return; | ||
96 | if (tag) | ||
97 | { | ||
98 | mu_cfg_node_t *node = mu_cfg_tree_create_node (mu_argp_tree, | ||
99 | mu_cfg_node_statement, | ||
100 | NULL, | ||
101 | tag, label, | ||
102 | lst); | ||
103 | mu_cfg_tree_add_node (mu_argp_tree, node); | ||
104 | } | ||
105 | else | ||
106 | { | ||
107 | mu_cfg_tree_add_nodelist (mu_argp_tree, lst); | ||
108 | mu_list_destroy (&lst); | ||
109 | } | ||
110 | } | ||
111 |
libmu_argp/cmdline.h
deleted
100644 → 0
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2007, 2010-2012, 2014-2016 Free Software Foundation, | ||
3 | 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, see | ||
17 | <http://www.gnu.org/licenses/>. */ | ||
18 | |||
19 | #include "mailutils/libcfg.h" | ||
20 | #include "mailutils/libargp.h" | ||
21 | |||
22 | extern struct mu_cfg_tree *mu_argp_tree; |
libmu_argp/common.c
deleted
100644 → 0
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2007-2012, 2014-2016 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, see | ||
16 | <http://www.gnu.org/licenses/>. */ | ||
17 | |||
18 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | #include "cmdline.h" | ||
22 | #include <unistd.h> | ||
23 | #include <stdlib.h> | ||
24 | #include <string.h> | ||
25 | #include <mailutils/syslog.h> | ||
26 | #include <mailutils/mailbox.h> | ||
27 | |||
28 | |||
29 | /* ************************************************************************* */ | ||
30 | /* Common */ | ||
31 | /* ************************************************************************* */ | ||
32 | |||
33 | enum { | ||
34 | OPT_SHOW_OPTIONS=256, | ||
35 | OPT_NO_USER_RCFILE, | ||
36 | OPT_NO_SITE_RCFILE, | ||
37 | OPT_RCFILE, | ||
38 | OPT_RCFILE_LINT, | ||
39 | OPT_RCFILE_VERBOSE, | ||
40 | OPT_LOG_FACILITY, | ||
41 | OPT_LICENSE, | ||
42 | OPT_DEBUG_LEVEL, | ||
43 | OPT_LINE_INFO, | ||
44 | OPT_HELP_CONFIG, | ||
45 | OPT_SET | ||
46 | }; | ||
47 | |||
48 | static struct argp_option mu_common_argp_options[] = | ||
49 | { | ||
50 | { NULL, 0, NULL, 0, N_("Common options"), 0}, | ||
51 | { "show-config-options", OPT_SHOW_OPTIONS, NULL, 0, | ||
52 | N_("show compilation options"), 0 }, | ||
53 | { "config-help", OPT_HELP_CONFIG, NULL, 0, | ||
54 | N_("show configuration file summary"), 0 }, | ||
55 | { "no-user-config", OPT_NO_USER_RCFILE, NULL, 0, | ||
56 | N_("do not load user configuration file"), 0 }, | ||
57 | { "no-user-rcfile", 0, NULL, OPTION_ALIAS, NULL }, | ||
58 | { "no-site-config", OPT_NO_SITE_RCFILE, NULL, 0, | ||
59 | N_("do not load site configuration file"), 0 }, | ||
60 | { "no-site-rcfile", 0, NULL, OPTION_ALIAS, NULL }, | ||
61 | { "config-file", OPT_RCFILE, N_("FILE"), 0, | ||
62 | N_("load this configuration file"), 0, }, | ||
63 | { "rcfile", 0, NULL, OPTION_ALIAS, NULL }, | ||
64 | { "config-verbose", OPT_RCFILE_VERBOSE, NULL, 0, | ||
65 | N_("verbosely log parsing of the configuration files"), 0 }, | ||
66 | { "rcfile-verbose", 0, NULL, OPTION_ALIAS, NULL }, | ||
67 | { "config-lint", OPT_RCFILE_LINT, NULL, 0, | ||
68 | N_("check configuration file syntax and exit"), 0 }, | ||
69 | { "rcfile-lint", 0, NULL, OPTION_ALIAS, NULL }, | ||
70 | { "set", OPT_SET, N_("PARAM=VALUE"), 0, | ||
71 | N_("set configuration parameter"), 0 }, | ||
72 | { NULL, 0, NULL, 0, NULL, 0 } | ||
73 | }; | ||
74 | |||
75 | static void | ||
76 | set_config_param (const char *path, struct argp_state *state) | ||
77 | { | ||
78 | mu_cfg_node_t *node; | ||
79 | int rc = mu_cfg_create_subtree (path, &node); | ||
80 | if (rc) | ||
81 | argp_error (state, "cannot create node: %s", mu_strerror (rc)); | ||
82 | mu_cfg_tree_add_node (mu_argp_tree, node); | ||
83 | } | ||
84 | |||
85 | static error_t | ||
86 | mu_common_argp_parser (int key, char *arg, struct argp_state *state) | ||
87 | { | ||
88 | switch (key) | ||
89 | { | ||
90 | case OPT_SHOW_OPTIONS: | ||
91 | mu_print_options (); | ||
92 | exit (0); | ||
93 | |||
94 | case OPT_NO_USER_RCFILE: | ||
95 | mu_load_user_rcfile = 0; | ||
96 | break; | ||
97 | |||
98 | case OPT_NO_SITE_RCFILE: | ||
99 | mu_load_site_rcfile = 0; | ||
100 | break; | ||
101 | |||
102 | case OPT_RCFILE: | ||
103 | mu_load_rcfile = arg; | ||
104 | break; | ||
105 | |||
106 | case OPT_RCFILE_LINT: | ||
107 | mu_cfg_parser_verbose++; | ||
108 | mu_rcfile_lint = 1; | ||
109 | break; | ||
110 | |||
111 | case OPT_RCFILE_VERBOSE: | ||
112 | mu_cfg_parser_verbose++; | ||
113 | break; | ||
114 | |||
115 | case OPT_HELP_CONFIG: | ||
116 | mu_help_config_mode = 1; | ||
117 | break; | ||
118 | |||
119 | case OPT_SET: | ||
120 | set_config_param (arg, state); | ||
121 | break; | ||
122 | |||
123 | default: | ||
124 | return ARGP_ERR_UNKNOWN; | ||
125 | } | ||
126 | return 0; | ||
127 | } | ||
128 | |||
129 | struct argp mu_common_argp = { | ||
130 | mu_common_argp_options, | ||
131 | mu_common_argp_parser, | ||
132 | }; | ||
133 | |||
134 | struct argp_child mu_common_argp_child = { | ||
135 | &mu_common_argp, | ||
136 | 0, | ||
137 | NULL, | ||
138 | 0, | ||
139 | }; | ||
140 | |||
141 | struct mu_cmdline_capa mu_common_cmdline = { | ||
142 | "common", &mu_common_argp_child | ||
143 | }; | ||
144 | |||
145 | |||
146 | /* ************************************************************************* */ | ||
147 | /* Logging */ | ||
148 | /* ************************************************************************* */ | ||
149 | |||
150 | static struct argp_option mu_logging_argp_option[] = { | ||
151 | {"log-facility", OPT_LOG_FACILITY, N_("FACILITY"), 0, | ||
152 | N_("output logs to syslog FACILITY"), 0}, | ||
153 | { NULL, 0, NULL, 0, NULL, 0 } | ||
154 | }; | ||
155 | |||
156 | static error_t | ||
157 | mu_logging_argp_parser (int key, char *arg, struct argp_state *state) | ||
158 | { | ||
159 | static mu_list_t lst; | ||
160 | |||
161 | switch (key) | ||
162 | { | ||
163 | /* log */ | ||
164 | case OPT_LOG_FACILITY: | ||
165 | mu_argp_node_list_new (lst, "facility", arg); | ||
166 | break; | ||
167 | |||
168 | case ARGP_KEY_INIT: | ||
169 | mu_argp_node_list_init (&lst); | ||
170 | break; | ||
171 | |||
172 | case ARGP_KEY_FINI: | ||
173 | mu_argp_node_list_finish (lst, "logging", NULL); | ||
174 | break; | ||
175 | |||
176 | default: | ||
177 | return ARGP_ERR_UNKNOWN; | ||
178 | } | ||
179 | return 0; | ||
180 | } | ||
181 | |||
182 | struct argp mu_logging_argp = { | ||
183 | mu_logging_argp_option, | ||
184 | mu_logging_argp_parser, | ||
185 | }; | ||
186 | |||
187 | struct argp_child mu_logging_argp_child = { | ||
188 | &mu_logging_argp, | ||
189 | 0, | ||
190 | NULL, | ||
191 | 0 | ||
192 | }; | ||
193 | |||
194 | struct mu_cmdline_capa mu_logging_cmdline = { | ||
195 | "logging", &mu_logging_argp_child | ||
196 | }; | ||
197 | |||
198 | |||
199 | /* ************************************************************************* */ | ||
200 | /* Mailer */ | ||
201 | /* ************************************************************************* */ | ||
202 | |||
203 | /* Options used by programs that send mail. */ | ||
204 | static struct argp_option mu_mailer_argp_option[] = { | ||
205 | {"mailer", 'M', N_("MAILER"), 0, | ||
206 | N_("use specified URL as the default mailer"), 0}, | ||
207 | { NULL, 0, NULL, 0, NULL, 0 } | ||
208 | }; | ||
209 | |||
210 | static error_t | ||
211 | mu_mailer_argp_parser (int key, char *arg, struct argp_state *state) | ||
212 | { | ||
213 | static mu_list_t lst; | ||
214 | |||
215 | switch (key) | ||
216 | { | ||
217 | /* mailer */ | ||
218 | case 'M': | ||
219 | mu_argp_node_list_new (lst, "url", arg); | ||
220 | break; | ||
221 | |||
222 | case ARGP_KEY_INIT: | ||
223 | mu_argp_node_list_init (&lst); | ||
224 | break; | ||
225 | |||
226 | case ARGP_KEY_FINI: | ||
227 | mu_argp_node_list_finish (lst, "mailer", NULL); | ||
228 | break; | ||
229 | |||
230 | default: | ||
231 | return ARGP_ERR_UNKNOWN; | ||
232 | } | ||
233 | return 0; | ||
234 | } | ||
235 | |||
236 | struct argp mu_mailer_argp = { | ||
237 | mu_mailer_argp_option, | ||
238 | mu_mailer_argp_parser, | ||
239 | }; | ||
240 | |||
241 | struct argp_child mu_mailer_argp_child = { | ||
242 | &mu_mailer_argp, | ||
243 | 0, | ||
244 | NULL, | ||
245 | 0 | ||
246 | }; | ||
247 | |||
248 | struct mu_cmdline_capa mu_mailer_cmdline = { | ||
249 | "mailer", &mu_mailer_argp_child | ||
250 | }; | ||
251 | |||
252 | |||
253 | static struct argp_option mu_debug_argp_options[] = | ||
254 | { | ||
255 | { "debug-level", OPT_DEBUG_LEVEL, N_("LEVEL"), 0, | ||
256 | N_("set Mailutils debugging level"), 0 }, | ||
257 | { "debug-line-info", OPT_LINE_INFO, NULL, 0, | ||
258 | N_("show source info with debugging messages"), 0 }, | ||
259 | { NULL } | ||
260 | }; | ||
261 | |||
262 | static error_t | ||
263 | mu_debug_argp_parser (int key, char *arg, struct argp_state *state) | ||
264 | { | ||
265 | static mu_list_t lst; | ||
266 | |||
267 | switch (key) | ||
268 | { | ||
269 | case OPT_DEBUG_LEVEL: | ||
270 | mu_debug_parse_spec (arg); | ||
271 | /*mu_argp_node_list_new (lst, "level", arg);*/ | ||
272 | break; | ||
273 | |||
274 | case OPT_LINE_INFO: | ||
275 | mu_argp_node_list_new (lst, "line-info", "yes"); | ||
276 | break; | ||
277 | |||
278 | case ARGP_KEY_INIT: | ||
279 | mu_argp_node_list_init (&lst); | ||
280 | break; | ||
281 | |||
282 | case ARGP_KEY_FINI: | ||
283 | mu_argp_node_list_finish (lst, "debug", NULL); | ||
284 | break; | ||
285 | |||
286 | default: | ||
287 | return ARGP_ERR_UNKNOWN; | ||
288 | } | ||
289 | return 0; | ||
290 | } | ||
291 | |||
292 | struct argp mu_debug_argp = { | ||
293 | mu_debug_argp_options, | ||
294 | mu_debug_argp_parser, | ||
295 | }; | ||
296 | |||
297 | struct argp_child mu_debug_argp_child = { | ||
298 | &mu_debug_argp, | ||
299 | 0, | ||
300 | N_("Global debugging settings"), | ||
301 | 0 | ||
302 | }; | ||
303 | |||
304 | struct mu_cmdline_capa mu_debug_cmdline = { | ||
305 | "debug", &mu_debug_argp_child | ||
306 | }; |
libmu_argp/mailutils.c
deleted
100644 → 0
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2007-2012, 2014-2016 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, see | ||
16 | <http://www.gnu.org/licenses/>. */ | ||
17 | |||
18 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | #include "cmdline.h" | ||
22 | #include <unistd.h> | ||
23 | #include <stdlib.h> | ||
24 | /* Provide declaration of __argp_base_name: */ | ||
25 | #include <argp-namefrob.h> | ||
26 | |||
27 | |||
28 | /* ************************************************************************* */ | ||
29 | /* GNU Mailutils help and version output */ | ||
30 | /* ************************************************************************* */ | ||
31 | |||
32 | #define OPT_PROGNAME -2 | ||
33 | #define OPT_USAGE -3 | ||
34 | #define OPT_HANG -4 | ||
35 | |||
36 | static struct argp_option mu_mailutils_argp_options[] = | ||
37 | { | ||
38 | {"help", '?', 0, 0, N_("give this help list"), -1}, | ||
39 | {"usage", OPT_USAGE, 0, 0, N_("give a short usage message"), 0}, | ||
40 | {"version", 'V', 0, 0, N_("print program version"), -1}, | ||
41 | {"program-name",OPT_PROGNAME,N_("NAME"), OPTION_HIDDEN, N_("set the program name"), 0}, | ||
42 | {"HANG", OPT_HANG, N_("SECS"), OPTION_ARG_OPTIONAL | OPTION_HIDDEN, | ||
43 | N_("hang for SECS seconds (default 3600)"), 0}, | ||
44 | { NULL } | ||
45 | }; | ||
46 | |||
47 | static error_t | ||
48 | mu_mailutils_argp_parser (int key, char *arg, struct argp_state *state) | ||
49 | { | ||
50 | switch (key) | ||
51 | { | ||
52 | case '?': | ||
53 | argp_state_help (state, state->out_stream, | ||
54 | ARGP_HELP_SHORT_USAGE | ARGP_HELP_LONG | ARGP_HELP_DOC); | ||
55 | /* TRANSLATORS: The placeholder indicates the bug-reporting address | ||
56 | for this package. Please add _another line_ saying | ||
57 | "Report translation bugs to <...>\n" with the address for translation | ||
58 | bugs (typically your translation team's web or email address). */ | ||
59 | printf (_("\nReport bugs to: %s\n"), "<" PACKAGE_BUGREPORT ">"); | ||
60 | |||
61 | #ifdef PACKAGE_PACKAGER_BUG_REPORTS | ||
62 | printf (_("Report %s bugs to: %s\n"), PACKAGE_PACKAGER, | ||
63 | PACKAGE_PACKAGER_BUG_REPORTS); | ||
64 | #endif | ||
65 | |||
66 | #ifdef PACKAGE_URL | ||
67 | printf (_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL); | ||
68 | #endif | ||
69 | fputs (_("General help using GNU software: <http://www.gnu.org/gethelp/>\n"), | ||
70 | stdout); | ||
71 | exit (0); | ||
72 | |||
73 | case OPT_USAGE: | ||
74 | argp_state_help (state, state->out_stream, | ||
75 | ARGP_HELP_USAGE | ARGP_HELP_EXIT_OK); | ||
76 | break; | ||
77 | |||
78 | case 'V': | ||
79 | if (argp_program_version_hook) | ||
80 | (*argp_program_version_hook) (state->out_stream, state); | ||
81 | else if (argp_program_version) | ||
82 | fprintf (state->out_stream, "%s\n", argp_program_version); | ||
83 | else | ||
84 | argp_error (state, "%s", | ||
85 | dgettext (state->root_argp->argp_domain, | ||
86 | "(PROGRAM ERROR) No version known!?")); | ||
87 | exit(0); | ||
88 | |||
89 | case OPT_PROGNAME: /* Set the program name. */ | ||
90 | #if HAVE_DECL_PROGRAM_INVOCATION_NAME | ||
91 | program_invocation_name = arg; | ||
92 | #endif | ||
93 | /* Update what we use for messages. */ | ||
94 | state->name = __argp_base_name (arg); | ||
95 | |||
96 | #if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME | ||
97 | program_invocation_short_name = state->name; | ||
98 | #endif | ||
99 | |||
100 | if ((state->flags & (ARGP_PARSE_ARGV0 | ARGP_NO_ERRS)) | ||
101 | == ARGP_PARSE_ARGV0) | ||
102 | /* Update what getopt uses too. */ | ||
103 | state->argv[0] = arg; | ||
104 | break; | ||
105 | |||
106 | case OPT_HANG: | ||
107 | { | ||
108 | int hang = atoi (arg ? arg : "3600"); | ||
109 | while (hang-- > 0) | ||
110 | sleep (1); | ||
111 | break; | ||
112 | } | ||
113 | |||
114 | default: | ||
115 | return ARGP_ERR_UNKNOWN; | ||
116 | } | ||
117 | return 0; | ||
118 | } | ||
119 | |||
120 | struct argp mu_mailutils_argp = { | ||
121 | mu_mailutils_argp_options, | ||
122 | mu_mailutils_argp_parser, | ||
123 | }; | ||
124 | |||
125 | struct argp_child mu_mailutils_argp_child = { | ||
126 | &mu_mailutils_argp, | ||
127 | 0, | ||
128 | NULL, | ||
129 | -1, | ||
130 | }; | ||
131 | |||
132 | static void | ||
133 | mu_mailutils_modflags(int *flags) | ||
134 | { | ||
135 | *flags |= ARGP_NO_HELP; | ||
136 | } | ||
137 | |||
138 | struct mu_cmdline_capa mu_mailutils_cmdline = { | ||
139 | "mailutils", &mu_mailutils_argp_child, mu_mailutils_modflags | ||
140 | }; | ||
141 | |||
142 | |||
143 | |||
144 | |||
145 | |||
146 |
libmu_argp/mu_argp.c
deleted
100644 → 0
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 1999, 2001-2007, 2009-2012, 2014-2016 Free Software | ||
3 | 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, see | ||
17 | <http://www.gnu.org/licenses/>. */ | ||
18 | |||
19 | #ifdef HAVE_CONFIG_H | ||
20 | # include <config.h> | ||
21 | #endif | ||
22 | #include <pwd.h> | ||
23 | #include <stdio.h> | ||
24 | #include <stdlib.h> | ||
25 | #include <string.h> | ||
26 | #include <syslog.h> | ||
27 | #include <unistd.h> | ||
28 | |||
29 | #include <sys/types.h> | ||
30 | #include <sys/stat.h> | ||
31 | |||
32 | #include "mailutils/libargp.h" | ||
33 | |||
34 | |||
35 | /* ************************************************************************* */ | ||
36 | /* Capability array and auxiliary functions. */ | ||
37 | /* ************************************************************************* */ | ||
38 | |||
39 | #define MU_MAX_CAPA 24 | ||
40 | |||
41 | struct argp_capa { | ||
42 | char *capability; | ||
43 | struct argp_child *child; | ||
44 | void (*modflags)(int*); | ||
45 | } mu_argp_capa[MU_MAX_CAPA] = { | ||
46 | {NULL,} | ||
47 | }; | ||
48 | |||
49 | int | ||
50 | mu_register_argp_capa (const char *name, struct argp_child *child, | ||
51 | void (*modflags)(int*)) | ||
52 | { | ||
53 | int i; | ||
54 | |||
55 | for (i = 0; i < MU_MAX_CAPA; i++) | ||
56 | if (mu_argp_capa[i].capability == NULL) | ||
57 | { | ||
58 | if ((mu_argp_capa[i].capability = strdup (name)) == NULL) | ||
59 | return ENOMEM; | ||
60 | mu_argp_capa[i].child = child; | ||
61 | mu_argp_capa[i].modflags = modflags; | ||
62 | return 0; | ||
63 | } | ||
64 | return 1; | ||
65 | } | ||
66 | |||
67 | static struct argp_capa * | ||
68 | find_capa (const char *name) | ||
69 | { | ||
70 | int i; | ||
71 | for (i = 0; mu_argp_capa[i].capability; i++) | ||
72 | if (strcmp (mu_argp_capa[i].capability, name) == 0) | ||
73 | return &mu_argp_capa[i]; | ||
74 | return NULL; | ||
75 | } | ||
76 | |||
77 | static struct argp * | ||
78 | mu_build_argp (const struct argp *template, char **capa, int *flags) | ||
79 | { | ||
80 | int n; | ||
81 | int nchild; | ||
82 | struct argp_child *ap; | ||
83 | const struct argp_option *opt; | ||
84 | struct argp *argp; | ||
85 | int group = 0; | ||
86 | |||
87 | /* Count the capabilities. */ | ||
88 | for (n = 0; capa && capa[n]; n++) | ||
89 | ; | ||
90 | if (template->children) | ||
91 | for (; template->children[n].argp; n++) | ||
92 | ; | ||
93 | |||
94 | ap = calloc (n + 1, sizeof (*ap)); | ||
95 | if (!ap) | ||
96 | { | ||
97 | mu_error (_("not enough memory")); | ||
98 | abort (); | ||
99 | } | ||
100 | |||
101 | /* Copy the template's children. */ | ||
102 | nchild = 0; | ||
103 | if (template->children) | ||
104 | for (n = 0; template->children[n].argp; n++, nchild++) | ||
105 | ap[nchild] = template->children[n]; | ||
106 | |||
107 | /* Find next group number */ | ||
108 | for (opt = template->options; | ||
109 | opt && ((opt->name && opt->key) || opt->doc); opt++) | ||
110 | if (opt->group > group) | ||
111 | group = opt->group; | ||
112 | |||
113 | group++; | ||
114 | |||
115 | /* Append any capabilities to the children or options, as appropriate. */ | ||
116 | for (n = 0; capa && capa[n]; n++) | ||
117 | { | ||
118 | struct argp_capa *cp = find_capa (capa[n]); | ||
119 | if (cp) | ||
120 | { | ||
121 | if (cp->modflags) | ||
122 | cp->modflags (flags); | ||
123 | if (cp->child) | ||
124 | { | ||
125 | ap[nchild] = *cp->child; | ||
126 | if (ap[nchild].group < 0) | ||
127 | ap[nchild].group = 0; | ||
128 | else | ||
129 | ap[nchild].group = group++; | ||
130 | nchild++; | ||
131 | } | ||
132 | } | ||
133 | } | ||
134 | ap[nchild].argp = NULL; | ||
135 | |||
136 | /* Copy the template, and give it the expanded children. */ | ||
137 | argp = malloc (sizeof (*argp)); | ||
138 | if (!argp) | ||
139 | { | ||
140 | mu_error (_("not enough memory")); | ||
141 | abort (); | ||
142 | } | ||
143 | |||
144 | memcpy (argp, template, sizeof (*argp)); | ||
145 | |||
146 | argp->children = ap; | ||
147 | |||
148 | return argp; | ||
149 | } | ||
150 | |||
151 | struct cap_buf | ||
152 | { | ||
153 | char **capa; | ||
154 | size_t numcapa; | ||
155 | size_t maxcapa; | ||
156 | }; | ||
157 | |||
158 | static void | ||
159 | cap_buf_init (struct cap_buf *bp) | ||
160 | { | ||
161 | bp->numcapa = 0; | ||
162 | bp->maxcapa = 2; | ||
163 | bp->capa = calloc (bp->maxcapa, sizeof bp->capa[0]); | ||
164 | if (!bp->capa) | ||
165 | { | ||
166 | mu_error ("%s", mu_strerror (errno)); | ||
167 | abort (); | ||
168 | } | ||
169 | bp->capa[0] = NULL; | ||
170 | } | ||
171 | |||
172 | static void | ||
173 | cap_buf_add (struct cap_buf *bp, char *str) | ||
174 | { | ||
175 | if (bp->numcapa == bp->maxcapa) | ||
176 | { | ||
177 | bp->maxcapa *= 2; | ||
178 | bp->capa = realloc (bp->capa, bp->maxcapa * sizeof bp->capa[0]); | ||
179 | if (!bp->capa) | ||
180 | { | ||
181 | mu_error ("%s", mu_strerror (errno)); | ||
182 | abort (); | ||
183 | } | ||
184 | } | ||
185 | bp->capa[bp->numcapa] = str; | ||
186 | if (str) | ||
187 | bp->numcapa++; | ||
188 | } | ||
189 | |||
190 | static void | ||
191 | cap_buf_free (struct cap_buf *bp) | ||
192 | { | ||
193 | free (bp->capa); | ||
194 | } | ||
195 | |||
196 | static int | ||
197 | argp_reg_action (void *item, void *data) | ||
198 | { | ||
199 | struct cap_buf *bp = data; | ||
200 | cap_buf_add (bp, item); | ||
201 | return 0; | ||
202 | } | ||
203 | |||
204 | struct argp * | ||
205 | mu_argp_build (const struct argp *init_argp, char ***pcapa, int *flags) | ||
206 | { | ||
207 | struct cap_buf cb; | ||
208 | struct argp *argp; | ||
209 | |||
210 | cap_buf_init (&cb); | ||
211 | mu_gocs_enumerate (argp_reg_action, &cb); | ||
212 | cap_buf_add (&cb, NULL); | ||
213 | mu_libargp_init (); | ||
214 | argp = mu_build_argp (init_argp, cb.capa, flags); | ||
215 | if (pcapa) | ||
216 | *pcapa = cb.capa; | ||
217 | else | ||
218 | cap_buf_free (&cb); | ||
219 | return argp; | ||
220 | } | ||
221 | |||
222 | void | ||
223 | mu_argp_done (struct argp *argp) | ||
224 | { | ||
225 | free ((void*) argp->children); | ||
226 | free ((void*) argp); | ||
227 | } |
libmu_argp/muinit.c
deleted
100644 → 0
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 2007-2012, 2014-2016 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, see | ||
16 | <http://www.gnu.org/licenses/>. */ | ||
17 | |||
18 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | #include "cmdline.h" | ||
22 | #include <unistd.h> | ||
23 | #include <stdlib.h> | ||
24 | #include <mailutils/alloc.h> | ||
25 | #include <mailutils/stream.h> | ||
26 | #include <mailutils/io.h> | ||
27 | #include <mailutils/stdstream.h> | ||
28 | #include <string.h> | ||
29 | #ifdef MU_ALPHA_RELEASE | ||
30 | # include <git-describe.h> | ||
31 | #endif | ||
32 | struct mu_cfg_tree *mu_argp_tree; | ||
33 | |||
34 | const char version_etc_copyright[] = | ||
35 | /* Do *not* mark this string for translation. %s is a copyright | ||
36 | symbol suitable for this locale, and %d is the copyright | ||
37 | year. */ | ||
38 | "Copyright %s 2007-2015 Free Software Foundation, inc."; | ||
39 | |||
40 | void | ||
41 | mu_program_version_hook (FILE *stream, struct argp_state *state) | ||
42 | { | ||
43 | #ifdef GIT_DESCRIBE | ||
44 | fprintf (stream, "%s (%s) %s [%s]\n", | ||
45 | mu_program_name, PACKAGE_NAME, PACKAGE_VERSION, GIT_DESCRIBE); | ||
46 | #else | ||
47 | fprintf (stream, "%s (%s) %s\n", mu_program_name, | ||
48 | PACKAGE_NAME, PACKAGE_VERSION); | ||
49 | #endif | ||
50 | /* TRANSLATORS: Translate "(C)" to the copyright symbol | ||
51 | (C-in-a-circle), if this symbol is available in the user's | ||
52 | locale. Otherwise, do not translate "(C)"; leave it as-is. */ | ||
53 | fprintf (stream, version_etc_copyright, _("(C)")); | ||
54 | |||
55 | fputs (_("\ | ||
56 | \n\ | ||
57 | License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: you are free to change and redistribute it.\n\ | ||
58 | There is NO WARRANTY, to the extent permitted by law.\n\ | ||
59 | \n\ | ||
60 | "), | ||
61 | stream); | ||
62 | } | ||
63 | |||
64 | void | ||
65 | mu_argp_init (const char *vers, const char *bugaddr) | ||
66 | { | ||
67 | if (vers) | ||
68 | argp_program_version = vers; | ||
69 | else | ||
70 | argp_program_version_hook = mu_program_version_hook; | ||
71 | argp_program_bug_address = bugaddr ? bugaddr : "<" PACKAGE_BUGREPORT ">"; | ||
72 | } | ||
73 | |||
74 | static char * | ||
75 | get_canonical_name () | ||
76 | { | ||
77 | char *name; | ||
78 | size_t len; | ||
79 | char *p; | ||
80 | |||
81 | if (!argp_program_version || | ||
82 | !(p = strchr (argp_program_version, ' '))) | ||
83 | return strdup (mu_program_name); | ||
84 | len = p - argp_program_version; | ||
85 | name = mu_alloc (len + 1); | ||
86 | memcpy (name, argp_program_version, len); | ||
87 | name[len] = 0; | ||
88 | return name; | ||
89 | } | ||
90 | |||
91 | int mu_help_config_mode; | ||
92 | int mu_rcfile_lint; | ||
93 | |||
94 | int (*mu_app_cfg_verifier) (void) = NULL; | ||
95 | |||
96 | int | ||
97 | mu_app_init (struct argp *myargp, const char **capa, | ||
98 | struct mu_cfg_param *cfg_param, | ||
99 | int argc, char **argv, int flags, int *pindex, void *data) | ||
100 | { | ||
101 | int rc, i; | ||
102 | struct argp *argp; | ||
103 | struct argp argpnull = { 0 }; | ||
104 | char **excapa; | ||
105 | struct mu_cfg_tree *parse_tree = NULL; | ||
106 | |||
107 | if (!mu_program_name) | ||
108 | mu_set_program_name (argv[0]); | ||
109 | if (!mu_log_tag) | ||
110 | mu_log_tag = (char*)mu_program_name; | ||
111 | mu_stdstream_setup (MU_STDSTREAM_RESET_NONE); | ||
112 | |||
113 | mu_libargp_init (); | ||
114 | if (capa) | ||
115 | for (i = 0; capa[i]; i++) | ||
116 | mu_gocs_register_std (capa[i]); /*FIXME*/ | ||
117 | if (!myargp) | ||
118 | myargp = &argpnull; | ||
119 | argp = mu_argp_build (myargp, &excapa, &flags); | ||
120 | |||
121 | mu_cfg_tree_create (&mu_argp_tree); | ||
122 | rc = argp_parse (argp, argc, argv, flags, pindex, data); | ||
123 | mu_argp_done (argp); | ||
124 | if (rc) | ||
125 | return rc; | ||
126 | |||
127 | /* Reset program name, it may have been changed using the `--program-name' | ||
128 | option. */ | ||
129 | mu_set_program_name (program_invocation_name); | ||
130 | |||
131 | mu_libcfg_init (excapa); | ||
132 | free (excapa); | ||
133 | |||
134 | if (mu_help_config_mode) | ||
135 | { | ||
136 | char *comment; | ||
137 | char *canonical_name = get_canonical_name (); | ||
138 | mu_stream_t stream; | ||
139 | struct mu_cfg_cont *cont; | ||
140 | static struct mu_cfg_param dummy_include_param[] = { | ||
141 | { "include", mu_c_string, NULL, 0, NULL, | ||
142 | N_("Include contents of the given file. If a directory is given, " | ||
143 | "include contents of the file <file>/<program>, where " | ||
144 | "<program> is the name of the program. This latter form is " | ||
145 | "allowed only in the site-wide configuration file."), | ||
146 | N_("file-or-directory") }, | ||
147 | { NULL } | ||
148 | }; | ||
149 | |||
150 | mu_stdio_stream_create (&stream, MU_STDOUT_FD, 0); | ||
151 | |||
152 | mu_asprintf (&comment, | ||
153 | "Configuration file structure for %s utility.", | ||
154 | mu_program_name); | ||
155 | mu_cfg_format_docstring (stream, comment, 0); | ||
156 | free (comment); | ||
157 | mu_asprintf (&comment, | ||
158 | "For use in global configuration file (%s), enclose it " | ||
159 | "in `program %s { ... };", | ||
160 | mu_site_rcfile, | ||
161 | mu_program_name); | ||
162 | mu_cfg_format_docstring (stream, comment, 0); | ||
163 | free (comment); | ||
164 | mu_asprintf (&comment, "For more information, use `info %s'.", | ||
165 | canonical_name); | ||
166 | mu_cfg_format_docstring (stream, comment, 0); | ||
167 | free (comment); | ||
168 | |||
169 | cont = mu_config_clone_root_container (); | ||
170 | mu_config_container_register_section (&cont, NULL, NULL, NULL, NULL, | ||
171 | dummy_include_param, NULL); | ||
172 | mu_config_container_register_section (&cont, NULL, NULL, NULL, NULL, | ||
173 | cfg_param, NULL); | ||
174 | mu_cfg_format_container (stream, cont); | ||
175 | mu_config_destroy_container (&cont); | ||
176 | |||
177 | mu_stream_destroy (&stream); | ||
178 | exit (0); | ||
179 | } | ||
180 | |||
181 | rc = mu_libcfg_parse_config (&parse_tree); | ||
182 | if (rc == 0) | ||
183 | { | ||
184 | struct mu_cfg_parse_hints hints = { MU_PARSE_CONFIG_PLAIN }; | ||
185 | |||
186 | hints.flags |= MU_CFG_PARSE_PROGRAM; | ||
187 | hints.program = (char*)mu_program_name; | ||
188 | |||
189 | if (mu_cfg_parser_verbose) | ||
190 | hints.flags |= MU_PARSE_CONFIG_VERBOSE; | ||
191 | if (mu_cfg_parser_verbose > 1) | ||
192 | hints.flags |= MU_PARSE_CONFIG_DUMP; | ||
193 | mu_cfg_tree_postprocess (mu_argp_tree, &hints); | ||
194 | mu_cfg_tree_union (&parse_tree, &mu_argp_tree); | ||
195 | rc = mu_cfg_tree_reduce (parse_tree, &hints, cfg_param, data); | ||
196 | } | ||
197 | |||
198 | if (mu_rcfile_lint) | ||
199 | { | ||
200 | if (rc || mu_cfg_error_count) | ||
201 | exit (1); | ||
202 | if (mu_app_cfg_verifier) | ||
203 | rc = mu_app_cfg_verifier (); | ||
204 | exit (rc ? 1 : 0); | ||
205 | } | ||
206 | |||
207 | mu_gocs_flush (); | ||
208 | mu_cfg_destroy_tree (&mu_argp_tree); | ||
209 | mu_cfg_destroy_tree (&parse_tree); | ||
210 | |||
211 | return !!(rc || mu_cfg_error_count); | ||
212 | } | ||
213 |
libmu_argp/sieve.c
deleted
100644 → 0
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 1999-2002, 2005, 2007, 2009-2012, 2014-2016 Free | ||
3 | 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, see | ||
17 | <http://www.gnu.org/licenses/>. */ | ||
18 | |||
19 | #ifdef HAVE_CONFIG_H | ||
20 | # include <config.h> | ||
21 | #endif | ||
22 | #include "cmdline.h" | ||
23 | #include "mailutils/sieve.h" | ||
24 | |||
25 | enum { | ||
26 | OPT_CLEAR_INCLUDE_PATH = 256, | ||
27 | OPT_CLEAR_LIBRARY_PATH, | ||
28 | OPT_PREFIX_LIBRARY_PATH | ||
29 | }; | ||
30 | |||
31 | static struct argp_option sieve_argp_option[] = { | ||
32 | { "includedir", 'I', N_("DIR"), 0, | ||
33 | N_("append DIR to the list of directories searched for include files"), 0 }, | ||
34 | { "libdir", 'L', N_("DIR"), 0, | ||
35 | N_("append DIR to the list of directories searched for library files"), 0 }, | ||
36 | { "libdir-prefix", OPT_PREFIX_LIBRARY_PATH, N_("DIR"), 0, | ||
37 | N_("add DIR to the beginning of the list of directories searched for " | ||
38 | "library files"), 0 }, | ||
39 | { "clear-include-path", OPT_CLEAR_INCLUDE_PATH, NULL, 0, | ||
40 | N_("clear Sieve include path"), 0 }, | ||
41 | { "clear-library-path", OPT_CLEAR_LIBRARY_PATH, NULL, 0, | ||
42 | N_("clear Sieve library path"), 0 }, | ||
43 | { "clearpath", 0, NULL, OPTION_ALIAS, NULL }, | ||
44 | { NULL, 0, NULL, 0, NULL, 0 } | ||
45 | }; | ||
46 | |||
47 | static error_t | ||
48 | sieve_argp_parser (int key, char *arg, struct argp_state *state) | ||
49 | { | ||
50 | static mu_list_t lst; | ||
51 | |||
52 | switch (key) | ||
53 | { | ||
54 | case 'I': | ||
55 | mu_argp_node_list_new (lst, "include-path", arg); | ||
56 | break; | ||
57 | |||
58 | case 'L': | ||
59 | mu_argp_node_list_new (lst, "library-path", arg); | ||
60 | break; | ||
61 | |||
62 | case OPT_PREFIX_LIBRARY_PATH: | ||
63 | mu_argp_node_list_new (lst, "library-path-prefix", arg); | ||
64 | break; | ||
65 | |||
66 | case OPT_CLEAR_INCLUDE_PATH: | ||
67 | mu_argp_node_list_new (lst, "clear-include-path", "yes"); | ||
68 | break; | ||
69 | |||
70 | case OPT_CLEAR_LIBRARY_PATH: | ||
71 | mu_argp_node_list_new (lst, "clear-library-path", "yes"); | ||
72 | break; | ||
73 | |||
74 | case ARGP_KEY_INIT: | ||
75 | mu_argp_node_list_init (&lst); | ||
76 | break; | ||
77 | |||
78 | case ARGP_KEY_FINI: | ||
79 | mu_argp_node_list_finish (lst, "sieve", NULL); | ||
80 | break; | ||
81 | |||
82 | default: | ||
83 | return ARGP_ERR_UNKNOWN; | ||
84 | } | ||
85 | return 0; | ||
86 | } | ||
87 | |||
88 | static struct argp sieve_argp = { | ||
89 | sieve_argp_option, | ||
90 | sieve_argp_parser, | ||
91 | }; | ||
92 | |||
93 | static struct argp_child sieve_argp_child = { | ||
94 | &sieve_argp, | ||
95 | 0, | ||
96 | N_("Sieve options"), | ||
97 | 0 | ||
98 | }; | ||
99 | |||
100 | struct mu_cmdline_capa mu_sieve_cmdline = { | ||
101 | "sieve", &sieve_argp_child | ||
102 | }; | ||
103 |
... | @@ -19,6 +19,7 @@ | ... | @@ -19,6 +19,7 @@ |
19 | #if HAVE_CONFIG_H | 19 | #if HAVE_CONFIG_H |
20 | # include <config.h> | 20 | # include <config.h> |
21 | #endif | 21 | #endif |
22 | #include <mailutils/cli.h> | ||
22 | 23 | ||
23 | #ifdef WITH_GSASL | 24 | #ifdef WITH_GSASL |
24 | 25 | ||
... | @@ -45,14 +46,28 @@ struct mu_gsasl_module_data mu_gsasl_module_data = { | ... | @@ -45,14 +46,28 @@ struct mu_gsasl_module_data mu_gsasl_module_data = { |
45 | NULL, | 46 | NULL, |
46 | SITE_CRAM_MD5_PWD | 47 | SITE_CRAM_MD5_PWD |
47 | }; | 48 | }; |
48 | 49 | ||
49 | int | 50 | static struct mu_cfg_param mu_gsasl_param[] = { |
50 | mu_gsasl_module_init (enum mu_gocs_op op, void *data) | 51 | { "enable", mu_c_bool, &mu_gsasl_module_data.enable, 0, NULL, |
51 | { | 52 | N_("Enable GSASL (default)") }, |
52 | if (op == mu_gocs_op_set && data) | 53 | { "cram-passwd", mu_c_string, &mu_gsasl_module_data.cram_md5_pwd, 0, NULL, |
53 | memcpy (&mu_gsasl_module_data, data, sizeof (mu_gsasl_module_data)); | 54 | N_("Name of GSASL password file."), |
54 | return 0; | 55 | N_("file") }, |
55 | } | 56 | { "service", mu_c_string, &mu_gsasl_module_data.service, 0, NULL, |
57 | N_("SASL service name."), | ||
58 | N_("name") }, | ||
59 | { "realm", mu_c_string, &mu_gsasl_module_data.realm, 0, NULL, | ||
60 | N_("SASL realm name."), | ||
61 | N_("name") }, | ||
62 | { "hostname", mu_c_string, &mu_gsasl_module_data.hostname, 0, NULL, | ||
63 | N_("SASL host name."), | ||
64 | N_("name") }, | ||
65 | { "anonymous-user", mu_c_string, &mu_gsasl_module_data.anon_user, 0, NULL, | ||
66 | N_("Anonymous user name."), | ||
67 | N_("name") }, | ||
68 | |||
69 | { NULL } | ||
70 | }; | ||
56 | 71 | ||
57 | int | 72 | int |
58 | mu_gsasl_enabled (void) | 73 | mu_gsasl_enabled (void) |
... | @@ -231,4 +246,10 @@ mu_gsasl_enabled (void) | ... | @@ -231,4 +246,10 @@ mu_gsasl_enabled (void) |
231 | { | 246 | { |
232 | return 0; | 247 | return 0; |
233 | } | 248 | } |
249 | #define mu_gsasl_param NULL | ||
234 | #endif | 250 | #endif |
251 | |||
252 | struct mu_auth_module mu_auth_gsasl_module = { | ||
253 | .name = "gsasl", | ||
254 | .cfg = mu_gsasl_param | ||
255 | }; | ... | ... |
... | @@ -61,17 +61,82 @@ const char *default_field_map = | ... | @@ -61,17 +61,82 @@ const char *default_field_map = |
61 | 61 | ||
62 | static struct mu_ldap_module_config ldap_param; | 62 | static struct mu_ldap_module_config ldap_param; |
63 | 63 | ||
64 | int | 64 | |
65 | mu_ldap_module_init (enum mu_gocs_op op, void *data) | 65 | |
66 | static int | ||
67 | _cb2_field_map (const char *arg, void *data) | ||
68 | { | ||
69 | int err; | ||
70 | int rc = mutil_parse_field_map (arg, &ldap_param.field_map, &err); | ||
71 | if (rc) | ||
72 | /* FIXME: this message can be misleading */ | ||
73 | mu_error (_("error near element %d: %s"), err, mu_strerror (rc)); | ||
74 | return 0; | ||
75 | } | ||
76 | |||
77 | static int | ||
78 | cb_field_map (void *data, mu_config_value_t *val) | ||
66 | { | 79 | { |
67 | struct mu_ldap_module_config *cfg = data; | 80 | return mu_cfg_string_value_cb (val, _cb2_field_map, NULL); |
81 | } | ||
68 | 82 | ||
69 | if (op != mu_gocs_op_set) | 83 | static struct mu_cfg_param mu_ldap_param[] = { |
70 | return 0; | 84 | { "enable", mu_c_bool, &ldap_param.enable, 0, NULL, |
71 | 85 | N_("Enable LDAP lookups.") }, | |
72 | if (cfg) | 86 | { "url", mu_c_string, &ldap_param.url, 0, NULL, |
73 | ldap_param = *cfg; | 87 | N_("Set URL of the LDAP server."), |
88 | N_("url") }, | ||
89 | { "base", mu_c_string, &ldap_param.base, 0, NULL, | ||
90 | N_("Base DN for LDAP lookups."), | ||
91 | N_("dn") }, | ||
92 | { "binddn", mu_c_string, &ldap_param.binddn, 0, NULL, | ||
93 | N_("DN for accessing LDAP database."), | ||
94 | N_("dn") }, | ||
95 | { "passwd", mu_c_string, &ldap_param.passwd, 0, NULL, | ||
96 | N_("Password for use with binddn.") }, | ||
97 | { "tls", mu_c_bool, &ldap_param.tls, 0, NULL, | ||
98 | N_("Use TLS encryption.") }, | ||
99 | { "debug", mu_c_int, &ldap_param.debug, 0, NULL, | ||
100 | N_("Set LDAP debugging level.") }, | ||
101 | { "field-map", mu_cfg_callback, NULL, 0, cb_field_map, | ||
102 | N_("Set a field-map for parsing LDAP replies. The map is a " | ||
103 | "column-separated list of definitions. Each definition has the " | ||
104 | "following form:\n" | ||
105 | " <name: string>=<attr: string>\n" | ||
106 | "where <name> is one of the following: name, passwd, uid, gid, " | ||
107 | "gecos, dir, shell, mailbox, quota, and <attr> is the name of " | ||
108 | "the corresponding LDAP attribute."), | ||
109 | N_("map") }, | ||
110 | { "getpwnam", mu_c_string, &ldap_param.getpwnam_filter, 0, NULL, | ||
111 | N_("LDAP filter to use for getpwnam requests."), | ||
112 | N_("filter") }, | ||
113 | { "getpwuid", mu_c_string, &ldap_param.getpwuid_filter, 0, NULL, | ||
114 | N_("LDAP filter to use for getpwuid requests."), | ||
115 | N_("filter") }, | ||
116 | { NULL } | ||
117 | }; | ||
118 | |||
119 | int | ||
120 | mu_ldap_section_parser | ||
121 | (enum mu_cfg_section_stage stage, const mu_cfg_node_t *node, | ||
122 | const char *section_label, void **section_data, | ||
123 | void *call_data, mu_cfg_tree_t *tree) | ||
124 | { | ||
125 | switch (stage) | ||
126 | { | ||
127 | case mu_cfg_section_start: | ||
128 | ldap_param.enable = 1; | ||
129 | break; | ||
130 | default: | ||
131 | break; | ||
132 | } | ||
133 | return 0; | ||
134 | } | ||
74 | 135 | ||
136 | |||
137 | static void | ||
138 | module_init (void *ptr) | ||
139 | { | ||
75 | if (ldap_param.enable) | 140 | if (ldap_param.enable) |
76 | { | 141 | { |
77 | if (!ldap_param.getpwnam_filter) | 142 | if (!ldap_param.getpwnam_filter) |
... | @@ -85,7 +150,6 @@ mu_ldap_module_init (enum mu_gocs_op op, void *data) | ... | @@ -85,7 +150,6 @@ mu_ldap_module_init (enum mu_gocs_op op, void *data) |
85 | mutil_parse_field_map (default_field_map, &ldap_param.field_map, &d); | 150 | mutil_parse_field_map (default_field_map, &ldap_param.field_map, &d); |
86 | } | 151 | } |
87 | } | 152 | } |
88 | return 0; | ||
89 | } | 153 | } |
90 | 154 | ||
91 | static int | 155 | static int |
... | @@ -271,8 +335,6 @@ _mu_conn_setup (LDAP **pld) | ... | @@ -271,8 +335,6 @@ _mu_conn_setup (LDAP **pld) |
271 | *pld = ld; | 335 | *pld = ld; |
272 | return 0; | 336 | return 0; |
273 | } | 337 | } |
274 | |||
275 | |||
276 | 338 | ||
277 | static int | 339 | static int |
278 | _mu_ldap_bind (LDAP *ld) | 340 | _mu_ldap_bind (LDAP *ld) |
... | @@ -862,15 +924,16 @@ mu_auth_ldap_user_by_uid (struct mu_auth_data **return_data, | ... | @@ -862,15 +924,16 @@ mu_auth_ldap_user_by_uid (struct mu_auth_data **return_data, |
862 | # define mu_ldap_authenticate mu_auth_nosupport | 924 | # define mu_ldap_authenticate mu_auth_nosupport |
863 | # define mu_auth_ldap_user_by_name mu_auth_nosupport | 925 | # define mu_auth_ldap_user_by_name mu_auth_nosupport |
864 | # define mu_auth_ldap_user_by_uid mu_auth_nosupport | 926 | # define mu_auth_ldap_user_by_uid mu_auth_nosupport |
927 | |||
865 | #endif | 928 | #endif |
866 | 929 | ||
867 | struct mu_auth_module mu_auth_ldap_module = { | 930 | struct mu_auth_module mu_auth_ldap_module = { |
868 | "ldap", | 931 | .name = "ldap", |
869 | mu_ldap_module_init, | 932 | .commit = module_init, |
870 | mu_ldap_authenticate, | 933 | .handler = { |
871 | NULL, | 934 | [mu_auth_authenticate] = mu_ldap_authenticate, |
872 | mu_auth_ldap_user_by_name, | 935 | [mu_auth_getpwnam] = mu_auth_ldap_user_by_name, |
873 | NULL, | 936 | [mu_auth_getpwuid] = mu_auth_ldap_user_by_uid |
874 | mu_auth_ldap_user_by_uid, | 937 | }, |
875 | NULL | 938 | .cfg = mu_ldap_param |
876 | }; | 939 | }; | ... | ... |
... | @@ -49,6 +49,14 @@ | ... | @@ -49,6 +49,14 @@ |
49 | char *mu_pam_service = PACKAGE; | 49 | char *mu_pam_service = PACKAGE; |
50 | 50 | ||
51 | #ifdef USE_LIBPAM | 51 | #ifdef USE_LIBPAM |
52 | static struct mu_cfg_param mu_pam_param[] = { | ||
53 | { "service", mu_c_string, &mu_pam_service, 0, NULL, | ||
54 | N_("Set PAM service name."), | ||
55 | N_("name") }, | ||
56 | { NULL } | ||
57 | }; | ||
58 | |||
59 | |||
52 | #define COPY_STRING(s) (s) ? strdup(s) : NULL | 60 | #define COPY_STRING(s) (s) ? strdup(s) : NULL |
53 | 61 | ||
54 | static char *_pwd; | 62 | static char *_pwd; |
... | @@ -175,43 +183,13 @@ mu_authenticate_pam (struct mu_auth_data **return_data MU_ARG_UNUSED, | ... | @@ -175,43 +183,13 @@ mu_authenticate_pam (struct mu_auth_data **return_data MU_ARG_UNUSED, |
175 | } | 183 | } |
176 | 184 | ||
177 | #else | 185 | #else |
178 | 186 | # define mu_pam_param NULL | |
179 | int | 187 | # define mu_authenticate_pam NULL |
180 | mu_authenticate_pam (struct mu_auth_data **return_data MU_ARG_UNUSED, | ||
181 | const void *key MU_ARG_UNUSED, | ||
182 | void *func_data MU_ARG_UNUSED, | ||
183 | void *call_data MU_ARG_UNUSED) | ||
184 | { | ||
185 | return ENOSYS; | ||
186 | } | ||
187 | |||
188 | #endif | 188 | #endif |
189 | 189 | ||
190 | int | ||
191 | mu_pam_module_init (enum mu_gocs_op op, void *data) | ||
192 | { | ||
193 | if (op == mu_gocs_op_set && data) | ||
194 | { | ||
195 | struct mu_gocs_pam *p = data; | ||
196 | if (p->service) | ||
197 | { | ||
198 | if ((mu_pam_service = strdup (p->service)) == NULL) | ||
199 | return ENOMEM; | ||
200 | } | ||
201 | else | ||
202 | mu_pam_service = NULL; | ||
203 | } | ||
204 | return 0; | ||
205 | } | ||
206 | |||
207 | struct mu_auth_module mu_auth_pam_module = { | 190 | struct mu_auth_module mu_auth_pam_module = { |
208 | "pam", | 191 | .name = "pam", |
209 | mu_pam_module_init, | 192 | .handler = { [mu_auth_authenticate] = mu_authenticate_pam }, |
210 | mu_authenticate_pam, | 193 | .cfg = mu_pam_param |
211 | NULL, | ||
212 | mu_auth_nosupport, | ||
213 | NULL, | ||
214 | mu_auth_nosupport, | ||
215 | NULL | ||
216 | }; | 194 | }; |
217 | 195 | ... | ... |
... | @@ -42,6 +42,9 @@ | ... | @@ -42,6 +42,9 @@ |
42 | #include <mailutils/nls.h> | 42 | #include <mailutils/nls.h> |
43 | #include <mailutils/io.h> | 43 | #include <mailutils/io.h> |
44 | #include <mailutils/cctype.h> | 44 | #include <mailutils/cctype.h> |
45 | #include <mailutils/cli.h> | ||
46 | #include <mailutils/stream.h> | ||
47 | #include <mailutils/stdstream.h> | ||
45 | 48 | ||
46 | #ifdef ENABLE_RADIUS | 49 | #ifdef ENABLE_RADIUS |
47 | 50 | ||
... | @@ -62,7 +65,6 @@ static grad_avp_t *auth_request; | ... | @@ -62,7 +65,6 @@ static grad_avp_t *auth_request; |
62 | static grad_avp_t *getpwnam_request; | 65 | static grad_avp_t *getpwnam_request; |
63 | static grad_avp_t *getpwuid_request; | 66 | static grad_avp_t *getpwuid_request; |
64 | 67 | ||
65 | |||
66 | int | 68 | int |
67 | get_attribute (int *pattr, char *name) | 69 | get_attribute (int *pattr, char *name) |
68 | { | 70 | { |
... | @@ -84,30 +86,41 @@ enum parse_state | ... | @@ -84,30 +86,41 @@ enum parse_state |
84 | state_delim | 86 | state_delim |
85 | }; | 87 | }; |
86 | 88 | ||
87 | int | 89 | static int |
88 | parse_pairlist (grad_avp_t **plist, char *input) | 90 | cb_request (void *data, mu_config_value_t *val) |
89 | { | 91 | { |
92 | grad_avp_t **plist = data; | ||
90 | size_t i; | 93 | size_t i; |
91 | struct mu_wordsplit ws; | 94 | struct mu_wordsplit ws; |
92 | enum parse_state state; | 95 | enum parse_state state; |
93 | grad_locus_t loc; | 96 | grad_locus_t loc; |
94 | char *name; | 97 | char *name; |
95 | char *op; /* FIXME: It is actually ignored. Should it be? */ | 98 | struct mu_locus locus; |
96 | 99 | ||
97 | if (!input) | 100 | if (mu_cfg_assert_value_type (val, MU_CFG_STRING)) |
98 | return 1; | 101 | return 1; |
99 | 102 | ||
100 | ws.ws_delim = ","; | 103 | ws.ws_delim = ","; |
101 | if (mu_wordsplit (input, &ws, | 104 | if (mu_wordsplit (val->v.string, &ws, |
102 | MU_WRDSF_DEFFLAGS|MU_WRDSF_DELIM|MU_WRDSF_RETURN_DELIMS)) | 105 | MU_WRDSF_DEFFLAGS|MU_WRDSF_DELIM|MU_WRDSF_RETURN_DELIMS)) |
103 | { | 106 | { |
104 | mu_error (_("cannot parse input `%s': %s"), input, | 107 | mu_error (_("cannot parse input `%s': %s"), val->v.string, |
105 | mu_wordsplit_strerror (&ws)); | 108 | mu_wordsplit_strerror (&ws)); |
106 | return 1; | 109 | return 1; |
107 | } | 110 | } |
108 | 111 | ||
109 | loc.file = "<configuration>"; /*FIXME*/ | 112 | if (mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, |
110 | loc.line = 0; | 113 | MU_IOCTL_LOGSTREAM_GET_LOCUS, |
114 | &locus) == 0) | ||
115 | { | ||
116 | loc.file = locus.mu_file; | ||
117 | loc.line = locus.mu_line; | ||
118 | } | ||
119 | else | ||
120 | { | ||
121 | loc.file = "<unknown>"; | ||
122 | loc.line = 0; | ||
123 | } | ||
111 | 124 | ||
112 | for (i = 0, state = state_lhs; i < ws.ws_wordc; i++) | 125 | for (i = 0, state = state_lhs; i < ws.ws_wordc; i++) |
113 | { | 126 | { |
... | @@ -121,7 +134,7 @@ parse_pairlist (grad_avp_t **plist, char *input) | ... | @@ -121,7 +134,7 @@ parse_pairlist (grad_avp_t **plist, char *input) |
121 | break; | 134 | break; |
122 | 135 | ||
123 | case state_op: | 136 | case state_op: |
124 | op = ws.ws_wordv[i]; | 137 | //op = ws.ws_wordv[i]; |
125 | state = state_rhs; | 138 | state = state_rhs; |
126 | break; | 139 | break; |
127 | 140 | ||
... | @@ -155,16 +168,45 @@ parse_pairlist (grad_avp_t **plist, char *input) | ... | @@ -155,16 +168,45 @@ parse_pairlist (grad_avp_t **plist, char *input) |
155 | return 1; | 168 | return 1; |
156 | } | 169 | } |
157 | 170 | ||
171 | return 0; | ||
172 | } | ||
173 | |||
174 | static int | ||
175 | cb_config_dir (void *data, mu_config_value_t *val) | ||
176 | { | ||
177 | if (mu_cfg_assert_value_type (val, MU_CFG_STRING)) | ||
178 | return 1; | ||
179 | grad_config_dir = grad_estrdup (val->v.string); | ||
158 | return 0; | 180 | return 0; |
159 | } | 181 | } |
160 | 182 | ||
183 | static struct mu_cfg_param mu_radius_param[] = { | ||
184 | { "auth", mu_cfg_callback, &auth_request, 0, cb_request, | ||
185 | N_("Radius request for authorization."), | ||
186 | N_("request: string") }, | ||
187 | { "getpwnam", mu_cfg_callback, &getpwnam_request, 0, cb_request, | ||
188 | N_("Radius request for getpwnam."), | ||
189 | N_("request: string") }, | ||
190 | { "getpwuid", mu_cfg_callback, &getpwuid_request, 0, cb_request, | ||
191 | N_("Radius request for getpwuid."), | ||
192 | N_("request: string") }, | ||
193 | { "directory", mu_cfg_callback, NULL, 0, cb_config_dir, | ||
194 | N_("Set radius configuration directory.") }, | ||
195 | { NULL } | ||
196 | }; | ||
197 | |||
198 | struct mu_cli_capa mu_cli_capa_radius = { | ||
199 | "radius", | ||
200 | NULL, | ||
201 | mu_radius_param | ||
202 | }; | ||
203 | |||
161 | /* Assume radius support is needed if any of the above requests is | 204 | /* Assume radius support is needed if any of the above requests is |
162 | defined. Actually, all of them should be, but it is the responsibility | 205 | defined. Actually, all of them should be, but it is the responsibility |
163 | of init to check for consistency of the configuration */ | 206 | of init to check for consistency of the configuration */ |
164 | 207 | ||
165 | #define NEED_RADIUS_P(cfg) \ | 208 | #define NEED_RADIUS_P() \ |
166 | ((cfg) && \ | 209 | (auth_request || getpwnam_request || getpwuid_request) |
167 | ((cfg)->auth_request || (cfg)->getpwnam_request || (cfg)->getpwuid_request)) | ||
168 | 210 | ||
169 | static void | 211 | static void |
170 | mu_grad_logger(int level, | 212 | mu_grad_logger(int level, |
... | @@ -196,21 +238,16 @@ mu_grad_logger(int level, | ... | @@ -196,21 +238,16 @@ mu_grad_logger(int level, |
196 | } | 238 | } |
197 | mu_diag_voutput (mlevel[level & GRAD_LOG_PRIMASK], pfx ? pfx : fmt, ap); | 239 | mu_diag_voutput (mlevel[level & GRAD_LOG_PRIMASK], pfx ? pfx : fmt, ap); |
198 | if (pfx) | 240 | if (pfx) |
199 | free(pfx); | 241 | free (pfx); |
200 | } | 242 | } |
201 | 243 | ||
202 | int | 244 | static void |
203 | mu_radius_module_init (enum mu_gocs_op op, void *data) | 245 | module_init (void *ptr) |
204 | { | 246 | { |
205 | struct mu_radius_module_data *cfg = data; | 247 | if (!NEED_RADIUS_P ()) |
206 | 248 | return; | |
207 | if (op != mu_gocs_op_set) | ||
208 | return 0; | ||
209 | if (!NEED_RADIUS_P (cfg)) | ||
210 | return 0; | ||
211 | 249 | ||
212 | grad_set_logger (mu_grad_logger); | 250 | grad_set_logger (mu_grad_logger); |
213 | grad_config_dir = grad_estrdup (cfg->config_dir); | ||
214 | 251 | ||
215 | grad_path_init (); | 252 | grad_path_init (); |
216 | srand (time (NULL) + getpid ()); | 253 | srand (time (NULL) + getpid ()); |
... | @@ -218,7 +255,7 @@ mu_radius_module_init (enum mu_gocs_op op, void *data) | ... | @@ -218,7 +255,7 @@ mu_radius_module_init (enum mu_gocs_op op, void *data) |
218 | if (grad_dict_init ()) | 255 | if (grad_dict_init ()) |
219 | { | 256 | { |
220 | mu_error (_("cannot read radius dictionaries")); | 257 | mu_error (_("cannot read radius dictionaries")); |
221 | return 1; | 258 | return; |
222 | } | 259 | } |
223 | 260 | ||
224 | /* Check whether mailutils attributes are defined */ | 261 | /* Check whether mailutils attributes are defined */ |
... | @@ -229,16 +266,9 @@ mu_radius_module_init (enum mu_gocs_op op, void *data) | ... | @@ -229,16 +266,9 @@ mu_radius_module_init (enum mu_gocs_op op, void *data) |
229 | || get_attribute (&MU_Dir, "MU-Dir") | 266 | || get_attribute (&MU_Dir, "MU-Dir") |
230 | || get_attribute (&MU_Shell, "MU-Shell") | 267 | || get_attribute (&MU_Shell, "MU-Shell") |
231 | || get_attribute (&MU_Mailbox, "MU-Mailbox")) | 268 | || get_attribute (&MU_Mailbox, "MU-Mailbox")) |
232 | return 1; | 269 | return; |
233 | |||
234 | /* Parse saved requests */ | ||
235 | if (parse_pairlist (&auth_request, cfg->auth_request) | ||
236 | || parse_pairlist (&getpwnam_request, cfg->getpwnam_request) | ||
237 | || parse_pairlist (&getpwuid_request, cfg->getpwuid_request)) | ||
238 | return 1; | ||
239 | 270 | ||
240 | radius_auth_enabled = 1; | 271 | radius_auth_enabled = 1; |
241 | return 0; | ||
242 | } | 272 | } |
243 | 273 | ||
244 | static char * | 274 | static char * |
... | @@ -518,44 +548,19 @@ mu_auth_radius_user_by_uid (struct mu_auth_data **return_data, | ... | @@ -518,44 +548,19 @@ mu_auth_radius_user_by_uid (struct mu_auth_data **return_data, |
518 | return rc; | 548 | return rc; |
519 | } | 549 | } |
520 | 550 | ||
521 | #else | ||
522 | static int | ||
523 | mu_radius_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED, | ||
524 | const void *key, | ||
525 | void *func_data MU_ARG_UNUSED, void *call_data) | ||
526 | { | ||
527 | return ENOSYS; | ||
528 | } | ||
529 | |||
530 | static int | ||
531 | mu_auth_radius_user_by_name (struct mu_auth_data **return_data MU_ARG_UNUSED, | ||
532 | const void *key MU_ARG_UNUSED, | ||
533 | void *func_data MU_ARG_UNUSED, | ||
534 | void *call_data MU_ARG_UNUSED) | ||
535 | { | ||
536 | return ENOSYS; | ||
537 | } | ||
538 | |||
539 | static int | ||
540 | mu_auth_radius_user_by_uid (struct mu_auth_data **return_data, | ||
541 | const void *key, | ||
542 | void *func_data, void *call_data) | ||
543 | { | ||
544 | return ENOSYS; | ||
545 | } | ||
546 | #endif | ||
547 | |||
548 | struct mu_auth_module mu_auth_radius_module = { | 551 | struct mu_auth_module mu_auth_radius_module = { |
549 | "radius", | 552 | .name = "radius", |
550 | #ifdef ENABLE_RADIUS | 553 | .cfg = mu_radius_param, |
551 | mu_radius_module_init, | 554 | .commit = module_init, |
555 | .handler = { | ||
556 | [mu_auth_authenticate] = mu_radius_authenticate, | ||
557 | [mu_auth_getpwnam] = mu_auth_radius_user_by_name, | ||
558 | [mu_auth_getpwuid] = mu_auth_radius_user_by_uid | ||
559 | } | ||
560 | }; | ||
552 | #else | 561 | #else |
553 | NULL, | 562 | struct mu_auth_module mu_auth_radius_module = { |
554 | #endif | 563 | .name = "radius" |
555 | mu_radius_authenticate, | ||
556 | NULL, | ||
557 | mu_auth_radius_user_by_name, | ||
558 | NULL, | ||
559 | mu_auth_radius_user_by_uid, | ||
560 | NULL | ||
561 | }; | 564 | }; |
565 | #endif | ||
566 | ... | ... |
... | @@ -50,12 +50,97 @@ | ... | @@ -50,12 +50,97 @@ |
50 | #include <mailutils/sql.h> | 50 | #include <mailutils/sql.h> |
51 | #include <mailutils/cstr.h> | 51 | #include <mailutils/cstr.h> |
52 | #include <mailutils/wordsplit.h> | 52 | #include <mailutils/wordsplit.h> |
53 | #include <mailutils/cli.h> | ||
53 | #include "sql.h" | 54 | #include "sql.h" |
54 | 55 | ||
55 | #ifdef USE_SQL | 56 | #ifdef USE_SQL |
56 | 57 | ||
57 | struct mu_internal_sql_config mu_sql_module_config; | 58 | struct mu_sql_module_config mu_sql_module_config; |
59 | /* Resource file configuration */ | ||
60 | static int | ||
61 | cb_password_type (void *data, mu_config_value_t *val) | ||
62 | { | ||
63 | if (mu_cfg_assert_value_type (val, MU_CFG_STRING)) | ||
64 | return 1; | ||
65 | |||
66 | if (mu_sql_decode_password_type (val->v.string, &mu_sql_module_config.password_type)) | ||
67 | mu_error (_("unknown password type `%s'"), val->v.string); | ||
68 | return 0; | ||
69 | } | ||
70 | |||
71 | static int | ||
72 | _cb2_field_map (const char *arg, void *data) | ||
73 | { | ||
74 | int err; | ||
75 | int rc = mutil_parse_field_map (arg, &mu_sql_module_config.field_map, &err); | ||
76 | if (rc) | ||
77 | /* FIXME: this message may be misleading */ | ||
78 | mu_error (_("error near element %d: %s"), err, mu_strerror (rc)); | ||
79 | return 0; | ||
80 | } | ||
58 | 81 | ||
82 | static int | ||
83 | cb_field_map (void *data, mu_config_value_t *val) | ||
84 | { | ||
85 | return mu_cfg_string_value_cb (val, _cb2_field_map, NULL); | ||
86 | } | ||
87 | |||
88 | static int | ||
89 | cb_interface (void *data, mu_config_value_t *val) | ||
90 | { | ||
91 | if (mu_cfg_assert_value_type (val, MU_CFG_STRING)) | ||
92 | return 1; | ||
93 | mu_sql_module_config.interface = mu_sql_interface_index (val->v.string); | ||
94 | if (mu_sql_module_config.interface == 0) | ||
95 | { | ||
96 | mu_error (_("unknown SQL interface `%s'"), val->v.string); | ||
97 | return 1; | ||
98 | } | ||
99 | return 0; | ||
100 | } | ||
101 | |||
102 | static struct mu_cfg_param mu_sql_param[] = { | ||
103 | { "interface", mu_cfg_callback, &mu_sql_module_config.interface, 0, | ||
104 | cb_interface, | ||
105 | N_("Set SQL interface to use."), | ||
106 | N_("iface: mysql|odbc|postgres") }, | ||
107 | { "getpwnam", mu_c_string, &mu_sql_module_config.getpwnam_query, 0, NULL, | ||
108 | N_("SQL query to use for getpwnam requests."), | ||
109 | N_("query") }, | ||
110 | { "getpwuid", mu_c_string, &mu_sql_module_config.getpwuid_query, 0, NULL, | ||
111 | N_("SQL query to use for getpwuid requests."), | ||
112 | N_("query") }, | ||
113 | { "getpass", mu_c_string, &mu_sql_module_config.getpass_query, 0, NULL, | ||
114 | N_("SQL query returning the user's password."), | ||
115 | N_("query") }, | ||
116 | { "host", mu_c_string, &mu_sql_module_config.host, 0, NULL, | ||
117 | N_("SQL server host name.") }, | ||
118 | { "user", mu_c_string, &mu_sql_module_config.user, 0, NULL, | ||
119 | N_("SQL user name.") }, | ||
120 | { "passwd", mu_c_string, &mu_sql_module_config.passwd, 0, NULL, | ||
121 | N_("Password for the SQL user.") }, | ||
122 | { "port", mu_c_int, &mu_sql_module_config.port, 0, NULL, | ||
123 | N_("SQL server port.") }, | ||
124 | { "db", mu_c_string, &mu_sql_module_config.db, 0, NULL, | ||
125 | N_("Database name.") }, | ||
126 | { "password-type", mu_cfg_callback, NULL, 0, cb_password_type, | ||
127 | N_("Type of password returned by getpass query (one of: plain, hash, " | ||
128 | "scrambled).") }, | ||
129 | { "positional", mu_c_bool, &mu_sql_module_config.positional, 0, NULL, | ||
130 | N_("Use positional (v1.0 compatible) field interface.") }, | ||
131 | { "field-map", mu_cfg_callback, NULL, 0, cb_field_map, | ||
132 | N_("Set a field-map for parsing SQL replies. The map is a " | ||
133 | "column-separated list of definitions. Each definition has the " | ||
134 | "following form:\n" | ||
135 | " <name: string>=<column: string>\n" | ||
136 | "where <name> is one of the following: name, passwd, uid, gid, " | ||
137 | "gecos, dir, shell, mailbox, quota, and <column> is the name of " | ||
138 | "the corresponding SQL column."), | ||
139 | N_("map") }, | ||
140 | { NULL } | ||
141 | }; | ||
142 | |||
143 | |||
59 | static char * | 144 | static char * |
60 | sql_escape_string (const char *ustr) | 145 | sql_escape_string (const char *ustr) |
61 | { | 146 | { |
... | @@ -668,55 +753,22 @@ mu_sql_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED, | ... | @@ -668,55 +753,22 @@ mu_sql_authenticate (struct mu_auth_data **return_data MU_ARG_UNUSED, |
668 | return rc == 0 ? 0 : MU_ERR_AUTH_FAILURE; | 753 | return rc == 0 ? 0 : MU_ERR_AUTH_FAILURE; |
669 | } | 754 | } |
670 | 755 | ||
671 | int | ||
672 | mu_sql_module_init (enum mu_gocs_op op, void *data) | ||
673 | { | ||
674 | struct mu_sql_module_config *cfg = data; | ||
675 | |||
676 | if (op != mu_gocs_op_set) | ||
677 | return 0; | ||
678 | mu_sql_module_config.interface = mu_sql_interface_index (cfg->interface); | ||
679 | if (mu_sql_module_config.interface == 0) | ||
680 | { | ||
681 | mu_error (_("unknown SQL interface `%s'"), cfg->interface); | ||
682 | return 1; | ||
683 | } | ||
684 | |||
685 | mu_sql_module_config.getpwnam_query = cfg->getpwnam_query; | ||
686 | mu_sql_module_config.getpass_query = cfg->getpass_query; | ||
687 | mu_sql_module_config.getpwuid_query = cfg->getpwuid_query; | ||
688 | mu_sql_module_config.host = cfg->host; | ||
689 | mu_sql_module_config.user = cfg->user; | ||
690 | mu_sql_module_config.passwd = cfg->passwd; | ||
691 | mu_sql_module_config.db = cfg->db; | ||
692 | mu_sql_module_config.port = cfg->port; | ||
693 | mu_sql_module_config.password_type = cfg->password_type; | ||
694 | mu_sql_module_config.field_map = cfg->field_map; | ||
695 | |||
696 | return 0; | ||
697 | } | ||
698 | |||
699 | #else | 756 | #else |
700 | 757 | ||
701 | # define mu_sql_authenticate mu_auth_nosupport | 758 | # define mu_sql_authenticate mu_auth_nosupport |
702 | # define mu_auth_sql_by_name mu_auth_nosupport | 759 | # define mu_auth_sql_by_name mu_auth_nosupport |
703 | # define mu_auth_sql_by_uid mu_auth_nosupport | 760 | # define mu_auth_sql_by_uid mu_auth_nosupport |
704 | 761 | # define mu_sql_param NULL | |
705 | #endif | 762 | #endif |
706 | 763 | ||
707 | 764 | ||
708 | struct mu_auth_module mu_auth_sql_module = { | 765 | struct mu_auth_module mu_auth_sql_module = { |
709 | "sql", | 766 | .name = "sql", |
710 | #ifdef USE_SQL | 767 | .cfg = mu_sql_param, |
711 | mu_sql_module_init, | 768 | .handler = { |
712 | #else | 769 | [mu_auth_authenticate] = mu_sql_authenticate, |
713 | NULL, | 770 | [mu_auth_getpwnam] = mu_auth_sql_by_name, |
714 | #endif | 771 | [mu_auth_getpwuid] = mu_auth_sql_by_uid |
715 | mu_sql_authenticate, | 772 | } |
716 | NULL, | ||
717 | mu_auth_sql_by_name, | ||
718 | NULL, | ||
719 | mu_auth_sql_by_uid, | ||
720 | NULL | ||
721 | }; | 773 | }; |
722 | 774 | ... | ... |
... | @@ -64,22 +64,6 @@ struct mu_tls_module_config mu_tls_module_config = { | ... | @@ -64,22 +64,6 @@ struct mu_tls_module_config mu_tls_module_config = { |
64 | 0 | 64 | 0 |
65 | #endif | 65 | #endif |
66 | }; | 66 | }; |
67 | //FIXME: REMOVE | ||
68 | int | ||
69 | mu_tls_module_init (enum mu_gocs_op op, void *data) | ||
70 | { | ||
71 | switch (op) | ||
72 | { | ||
73 | case mu_gocs_op_set: | ||
74 | if (data) | ||
75 | memcpy (&mu_tls_module_config, data, sizeof mu_tls_module_config); | ||
76 | break; | ||
77 | |||
78 | case mu_gocs_op_flush: | ||
79 | break; | ||
80 | } | ||
81 | return 0; | ||
82 | } | ||
83 | 67 | ||
84 | #ifdef WITH_TLS | 68 | #ifdef WITH_TLS |
85 | 69 | ||
... | @@ -870,16 +854,14 @@ static struct mu_cfg_param mu_tls_param[] = { | ... | @@ -870,16 +854,14 @@ static struct mu_cfg_param mu_tls_param[] = { |
870 | { NULL } | 854 | { NULL } |
871 | }; | 855 | }; |
872 | 856 | ||
873 | struct mu_cli_capa mu_cli_capa_tls = { | 857 | struct mu_auth_module mu_auth_tls_module = { |
874 | "tls", | 858 | .name = "tls", |
875 | NULL, | 859 | .cfg = mu_tls_param |
876 | mu_tls_param, | ||
877 | NULL, NULL | ||
878 | }; | 860 | }; |
861 | |||
879 | #else | 862 | #else |
880 | struct mu_cli_capa mu_cli_capa_tls = { | 863 | struct mu_auth_module mu_auth_tls_module = { |
881 | "tls", | 864 | .name = "tls" |
882 | NULL | ||
883 | }; | 865 | }; |
884 | #endif /* WITH_TLS */ | 866 | #endif /* WITH_TLS */ |
885 | 867 | ... | ... |
... | @@ -53,22 +53,20 @@ | ... | @@ -53,22 +53,20 @@ |
53 | #include <mailutils/nls.h> | 53 | #include <mailutils/nls.h> |
54 | #include <mailutils/errno.h> | 54 | #include <mailutils/errno.h> |
55 | #include <mailutils/util.h> | 55 | #include <mailutils/util.h> |
56 | #include <mailutils/cli.h> | ||
56 | 57 | ||
57 | #ifdef ENABLE_VIRTUAL_DOMAINS | 58 | #ifdef ENABLE_VIRTUAL_DOMAINS |
58 | 59 | ||
59 | struct mu_gocs_virtual mu_virtual_module_config = { SITE_VIRTUAL_PWDDIR }; | 60 | static char *pwddir = { SITE_VIRTUAL_PWDDIR }; |
60 | |||
61 | int | ||
62 | mu_virtual_module_init (enum mu_gocs_op op, void *data) | ||
63 | { | ||
64 | if (op == mu_gocs_op_set && data) | ||
65 | { | ||
66 | struct mu_gocs_virtual *p = data; | ||
67 | mu_virtual_module_config = *p; | ||
68 | } | ||
69 | return 0; | ||
70 | } | ||
71 | 61 | ||
62 | static struct mu_cfg_param mu_virtdomain_param[] = { | ||
63 | { "passwd-dir", mu_c_string, &pwddir, 0, NULL, | ||
64 | N_("Name of the directory where virtual domain password files are " | ||
65 | "located."), | ||
66 | N_("dir") }, | ||
67 | { NULL } | ||
68 | }; | ||
69 | |||
72 | #if !HAVE_FGETPWENT | 70 | #if !HAVE_FGETPWENT |
73 | /* FIXME: A temporary solution. Need proper declaration in .h */ | 71 | /* FIXME: A temporary solution. Need proper declaration in .h */ |
74 | extern struct passwd *mu_fgetpwent (FILE *fp); | 72 | extern struct passwd *mu_fgetpwent (FILE *fp); |
... | @@ -90,7 +88,7 @@ getpwnam_virtual (const char *u) | ... | @@ -90,7 +88,7 @@ getpwnam_virtual (const char *u) |
90 | if (delim == 0) | 88 | if (delim == 0) |
91 | return NULL; | 89 | return NULL; |
92 | 90 | ||
93 | filename = mu_make_file_name (mu_virtual_module_config.pwddir, &u[delim + 1]); | 91 | filename = mu_make_file_name (pwddir, &u[delim + 1]); |
94 | if (filename == NULL) | 92 | if (filename == NULL) |
95 | return NULL; | 93 | return NULL; |
96 | 94 | ||
... | @@ -191,28 +189,15 @@ mu_auth_virt_domain_by_name (struct mu_auth_data **return_data, | ... | @@ -191,28 +189,15 @@ mu_auth_virt_domain_by_name (struct mu_auth_data **return_data, |
191 | } | 189 | } |
192 | 190 | ||
193 | #else | 191 | #else |
194 | static int | 192 | # define mu_virtdomain_param NULL |
195 | mu_auth_virt_domain_by_name (struct mu_auth_data **return_data MU_ARG_UNUSED, | 193 | # define mu_auth_virt_domain_by_name NULL |
196 | const void *key MU_ARG_UNUSED, | ||
197 | void *func_data MU_ARG_UNUSED, | ||
198 | void *call_data MU_ARG_UNUSED) | ||
199 | { | ||
200 | return ENOSYS; | ||
201 | } | ||
202 | #endif | 194 | #endif |
203 | 195 | ||
204 | struct mu_auth_module mu_auth_virtual_module = { | 196 | struct mu_auth_module mu_auth_virtual_module = { |
205 | "virtdomain", | 197 | .name = "virtdomain", |
206 | #ifdef ENABLE_VIRTUAL_DOMAINS | 198 | .cfg = mu_virtdomain_param, |
207 | mu_virtual_module_init, | 199 | .handler = { |
208 | #else | 200 | [mu_auth_getpwnam] = mu_auth_virt_domain_by_name, |
209 | NULL, | 201 | } |
210 | #endif | ||
211 | mu_auth_nosupport, | ||
212 | NULL, | ||
213 | mu_auth_virt_domain_by_name, | ||
214 | NULL, | ||
215 | mu_auth_nosupport, | ||
216 | NULL | ||
217 | }; | 202 | }; |
218 | 203 | ... | ... |
libmu_cfg/.gitignore
deleted
100644 → 0
libmu_cfg/Makefile.am
deleted
100644 → 0
1 | # This file is part of GNU Mailutils | ||
2 | # Copyright (C) 2007, 2009-2012, 2014-2016 Free Software Foundation, | ||
3 | # Inc. | ||
4 | # | ||
5 | # GNU Mailutils is free software; you can redistribute it and/or | ||
6 | # modify it under the terms of the GNU General Public License as | ||
7 | # published by the Free Software Foundation; either version 3, or (at | ||
8 | # your option) any later version. | ||
9 | # | ||
10 | # GNU Mailutils is distributed in the hope that it will be useful, but | ||
11 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | # General Public License for more details. | ||
14 | # | ||
15 | # You should have received a copy of the GNU General Public License | ||
16 | # along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
17 | |||
18 | AM_CPPFLAGS = \ | ||
19 | @MU_LIB_COMMON_INCLUDES@\ | ||
20 | -DSITE_VIRTUAL_PWDDIR=\"@SITE_VIRTUAL_PWDDIR@\" \ | ||
21 | -DSITE_CRAM_MD5_PWD=\"@SITE_CRAM_MD5_PWD@\" | ||
22 | |||
23 | lib_LTLIBRARIES = libmu_cfg.la | ||
24 | libmu_cfg_la_SOURCES=\ | ||
25 | acl.c\ | ||
26 | auth.c\ | ||
27 | common.c\ | ||
28 | init.c\ | ||
29 | gsasl.c\ | ||
30 | ldap.c\ | ||
31 | pam.c\ | ||
32 | radius.c\ | ||
33 | sieve.c\ | ||
34 | sql.c\ | ||
35 | tls.c\ | ||
36 | virtdomain.c | ||
37 | |||
38 | libmu_cfg_la_LDFLAGS=-version-info @VI_CURRENT@:@VI_REVISION@:@VI_AGE@ |
libmu_cfg/acl.c
deleted
100644 → 0
1 | /* This file is part of GNU Mailutils | ||
2 | Copyright (C) 2007-2012, 2014-2016 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, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | #include "mailutils/libcfg.h" | ||
22 | #include "mailutils/acl.h" | ||
23 | #include "mailutils/argcv.h" | ||
24 | #include "mailutils/cidr.h" | ||
25 | #include <stdlib.h> | ||
26 | #include <stdio.h> | ||
27 | #include <string.h> | ||
28 | #include <unistd.h> | ||
29 | #include <sys/time.h> | ||
30 | #include <sys/types.h> | ||
31 | #include <sys/socket.h> | ||
32 | #include <netinet/in.h> | ||
33 | #include <arpa/inet.h> | ||
34 | |||
35 | #define ISSPACE(c) ((c)==' '||(c)=='\t') | ||
36 | |||
37 | #define SKIPWS(p) while (*(p) && ISSPACE (*(p))) (p)++; | ||
38 | |||
39 | static const char * | ||
40 | getword (mu_config_value_t *val, int *pn) | ||
41 | { | ||
42 | int n = (*pn)++; | ||
43 | mu_config_value_t *v; | ||
44 | |||
45 | if (n >= val->v.arg.c) | ||
46 | { | ||
47 | mu_error (_("not enough arguments")); | ||
48 | return NULL; | ||
49 | } | ||
50 | v = &val->v.arg.v[n]; | ||
51 | if (mu_cfg_assert_value_type (v, MU_CFG_STRING)) | ||
52 | return NULL; | ||
53 | return v->v.string; | ||
54 | } | ||
55 | |||
56 | static int | ||
57 | parsearg (mu_config_value_t *val, struct mu_cidr *cidr, char **prest) | ||
58 | { | ||
59 | const char *w; | ||
60 | int n = 0; | ||
61 | int rc; | ||
62 | |||
63 | if (mu_cfg_assert_value_type (val, MU_CFG_ARRAY)) | ||
64 | return 1; | ||
65 | |||
66 | w = getword (val, &n); | ||
67 | if (!w) | ||
68 | return 1; | ||
69 | if (strcmp (w, "from") == 0) { | ||
70 | w = getword (val, &n); | ||
71 | if (!w) | ||
72 | return 1; | ||
73 | } | ||
74 | |||
75 | if (strcmp (w, "any") == 0) | ||
76 | cidr->len = 0; | ||
77 | else | ||
78 | { | ||
79 | rc = mu_cidr_from_string (cidr, w); | ||
80 | if (rc) | ||
81 | { | ||
82 | mu_error (_("invalid source CIDR: %s"), mu_strerror (rc)); | ||
83 | return 1; | ||
84 | } | ||
85 | } | ||
86 | |||
87 | if (prest) | ||
88 | { | ||
89 | if (n == val->v.arg.c) | ||
90 | *prest = NULL; | ||
91 | else | ||
92 | { | ||
93 | size_t size = 0; | ||
94 | int i; | ||
95 | char *buf; | ||
96 | |||
97 | for (i = n; i < val->v.arg.c; i++) | ||
98 | { | ||
99 | if (mu_cfg_assert_value_type (&val->v.arg.v[i], MU_CFG_STRING)) | ||
100 | return 1; | ||
101 | size += strlen (val->v.arg.v[i].v.string) + 1; | ||
102 | } | ||
103 | |||
104 | buf = malloc (size); | ||
105 | if (!buf) | ||
106 | { | ||
107 | mu_error ("%s", mu_strerror (errno)); | ||
108 | return 1; | ||
109 | } | ||
110 | |||
111 | *prest = buf; | ||
112 | for (i = n; i < val->v.arg.c; i++) | ||
113 | { | ||
114 | if (i > n) | ||
115 | *buf++ = ' '; | ||
116 | strcpy (buf, val->v.arg.v[i].v.string); | ||
117 | buf += strlen (buf); | ||
118 | } | ||
119 | *buf = 0; | ||
120 | } | ||
121 | } | ||
122 | else if (n != val->v.arg.c) | ||
123 | { | ||
124 | mu_error (_("junk after IP address")); | ||
125 | return 1; | ||
126 | } | ||
127 | return 0; | ||
128 | } | ||
129 | |||
130 | static int | ||
131 | cb_allow (void *data, mu_config_value_t *val) | ||
132 | { | ||
133 | int rc; | ||
134 | mu_acl_t acl = *(mu_acl_t*)data; | ||
135 | struct mu_cidr cidr; | ||
136 | |||
137 | if (parsearg (val, &cidr, NULL)) | ||
138 | return 1; | ||
139 | rc = mu_acl_append (acl, mu_acl_accept, NULL, &cidr); | ||
140 | if (rc) | ||
141 | mu_error (_("cannot append acl entry: %s"), mu_strerror (rc)); | ||
142 | return rc; | ||
143 | } | ||
144 | |||
145 | static int | ||
146 | cb_deny (void *data, mu_config_value_t *val) | ||
147 | { | ||
148 | int rc; | ||
149 | mu_acl_t acl = *(mu_acl_t*)data; | ||
150 | struct mu_cidr cidr; | ||
151 | |||
152 | if (parsearg (val, &cidr, NULL)) | ||
153 | return 1; | ||
154 | rc = mu_acl_append (acl, mu_acl_deny, NULL, &cidr); | ||
155 | if (rc) | ||
156 | mu_error (_("cannot append acl entry: %s"), mu_strerror (rc)); | ||
157 | return rc; | ||
158 | } | ||
159 | |||
160 | static int | ||
161 | cb_log (void *data, mu_config_value_t *val) | ||
162 | { | ||
163 | int rc; | ||
164 | mu_acl_t acl = *(mu_acl_t*)data; | ||
165 | struct mu_cidr cidr; | ||
166 | char *rest; | ||
167 | |||
168 | if (parsearg (val, &cidr, &rest)) | ||
169 | return 1; | ||
170 | rc = mu_acl_append (acl, mu_acl_log, rest, &cidr); | ||
171 | if (rc) | ||
172 | mu_error (_("cannot append acl entry: %s"), mu_strerror (rc)); | ||
173 | return rc; | ||
174 | } | ||
175 | |||
176 | static int | ||
177 | cb_exec (void *data, mu_config_value_t *val) | ||
178 | { | ||
179 | int rc; | ||
180 | mu_acl_t acl = *(mu_acl_t*)data; | ||
181 | struct mu_cidr cidr; | ||
182 | char *rest; | ||
183 | |||
184 | if (parsearg (val, &cidr, &rest)) | ||
185 | return 1; | ||
186 | rc = mu_acl_append (acl, mu_acl_exec, rest, &cidr); | ||
187 | if (rc) | ||
188 | mu_error (_("cannot append acl entry: %s"), mu_strerror (rc)); | ||
189 | return rc; | ||
190 | } | ||
191 | |||
192 | static int | ||
193 | cb_ifexec (void *data, mu_config_value_t *val) | ||
194 | { | ||
195 | int rc; | ||
196 | mu_acl_t acl = *(mu_acl_t*)data; | ||
197 | struct mu_cidr cidr; | ||
198 | char *rest; | ||
199 | |||
200 | if (parsearg (val, &cidr, &rest)) | ||
201 | return 1; | ||
202 | rc = mu_acl_append (acl, mu_acl_ifexec, rest, &cidr); | ||
203 | if (rc) | ||
204 | mu_error (_("cannot append acl entry: %s"), mu_strerror (rc)); | ||
205 | return rc; | ||
206 | } | ||
207 | |||
208 | static struct mu_cfg_param acl_param[] = { | ||
209 | { "allow", mu_cfg_callback, NULL, 0, cb_allow, | ||
210 | N_("Allow connections from this IP address. Optional word `from' is " | ||
211 | "allowed between it and its argument. The same holds true for other " | ||
212 | "actions below."), | ||
213 | N_("addr: IP") }, | ||
214 | { "deny", mu_cfg_callback, NULL, 0, cb_deny, | ||
215 | N_("Deny connections from this IP address."), | ||
216 | N_("addr: IP") }, | ||
217 | { "log", mu_cfg_callback, NULL, 0, cb_log, | ||
218 | N_("Log connections from this IP address."), | ||
219 | N_("addr: IP") }, | ||
220 | { "exec", mu_cfg_callback, NULL, 0, cb_exec, | ||
221 | N_("Execute supplied program if a connection from this IP address is " | ||
222 | "requested. Arguments are:\n" | ||
223 | " <addr: IP> <program: string>\n" | ||
224 | "Following macros are expanded in <program> before executing:\n" | ||
225 | " address - Source IP address\n" | ||
226 | " port - Source port number\n") }, | ||
227 | { "ifexec", mu_cfg_callback, NULL, 0, cb_ifexec, | ||
228 | N_("If a connection from this IP address is requested, execute supplied " | ||
229 | "program and allow or deny the connection depending on its exit code. " | ||
230 | "See `exec' for a description of its arguments.") }, | ||
231 | { NULL } | ||
232 | }; | ||
233 | |||
234 | static int | ||
235 | acl_section_parser (enum mu_cfg_section_stage stage, | ||
236 | const mu_cfg_node_t *node, | ||
237 | const char *section_label, void **section_data, | ||
238 | void *call_data, | ||
239 | mu_cfg_tree_t *tree) | ||
240 | { | ||
241 | switch (stage) | ||
242 | { | ||
243 | case mu_cfg_section_start: | ||
244 | { | ||
245 | void *data = *section_data; | ||
246 | mu_acl_create ((mu_acl_t*)data); | ||
247 | } | ||
248 | break; | ||
249 | |||
250 | case mu_cfg_section_end: | ||
251 | break; | ||
252 | } | ||
253 | return 0; | ||
254 | } | ||
255 | |||
256 | void | ||
257 | mu_acl_cfg_init () | ||
258 | { | ||
259 | struct mu_cfg_section *section; | ||
260 | if (mu_create_canned_section ("acl", §ion) == 0) | ||
261 | { | ||
262 | section->parser = acl_section_parser; | ||
263 | mu_cfg_section_add_params (section, acl_param); | ||
264 | } | ||
265 | } |
libmu_cfg/auth.c
deleted
100644 → 0
1 | /* This file is part of GNU Mailutils | ||
2 | Copyright (C) 2007-2008, 2010-2012, 2014-2016 Free Software | ||
3 | Foundation, Inc. | ||
4 | |||
5 | GNU Mailutils is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU General Public License as | ||
7 | published by the Free Software Foundation; either version 3, or (at | ||
8 | your option) any later version. | ||
9 | |||
10 | GNU Mailutils is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #ifdef HAVE_CONFIG_H | ||
20 | # include <config.h> | ||
21 | #endif | ||
22 | #include "mailutils/libcfg.h" | ||
23 | #include <mailutils/mu_auth.h> | ||
24 | #include <string.h> | ||
25 | |||
26 | /* FIXME: mu_auth.c should be reviewed */ | ||
27 | |||
28 | |||
29 | /* ************************************************************************* */ | ||
30 | /* Resource-style configuration */ | ||
31 | /* ************************************************************************* */ | ||
32 | static int | ||
33 | cb_authentication (void *data, mu_config_value_t *val) | ||
34 | { | ||
35 | if (val->type == MU_CFG_STRING) | ||
36 | { | ||
37 | if (strcmp (val->v.string, "clear") == 0) | ||
38 | mu_authentication_clear_list (); | ||
39 | else | ||
40 | /*FIXME: use err for error reporting*/ | ||
41 | mu_authentication_add_module_list (val->v.string); | ||
42 | } | ||
43 | else if (val->type == MU_CFG_LIST) | ||
44 | { | ||
45 | int i; | ||
46 | for (i = 0; i < val->v.arg.c; i++) | ||
47 | { | ||
48 | if (mu_cfg_assert_value_type (&val->v.arg.v[i], MU_CFG_STRING)) | ||
49 | return 1; | ||
50 | if (strcmp (val->v.arg.v[i].v.string, "clear") == 0) | ||
51 | mu_authentication_clear_list (); | ||
52 | else | ||
53 | mu_authentication_add_module (val->v.arg.v[i].v.string); | ||
54 | } | ||
55 | } | ||
56 | else | ||
57 | { | ||
58 | mu_error (_("expected string value")); | ||
59 | return 1; | ||
60 | } | ||
61 | return 0; | ||
62 | } | ||
63 | |||
64 | static int | ||
65 | cb_authorization (void *data, mu_config_value_t *val) | ||
66 | { | ||
67 | if (val->type == MU_CFG_STRING) | ||
68 | { | ||
69 | if (strcmp (val->v.string, "clear") == 0) | ||
70 | mu_authorization_clear_list (); | ||
71 | else | ||
72 | /*FIXME: use err for error reporting*/ | ||
73 | mu_authorization_add_module_list (val->v.string); | ||
74 | } | ||
75 | else if (val->type == MU_CFG_LIST) | ||
76 | { | ||
77 | int i; | ||
78 | for (i = 0; i < val->v.arg.c; i++) | ||
79 | { | ||
80 | if (mu_cfg_assert_value_type (&val->v.arg.v[i], MU_CFG_STRING)) | ||
81 | return 1; | ||
82 | if (strcmp (val->v.arg.v[i].v.string, "clear") == 0) | ||
83 | mu_authorization_clear_list (); | ||
84 | else | ||
85 | mu_authorization_add_module (val->v.arg.v[i].v.string); | ||
86 | } | ||
87 | } | ||
88 | else | ||
89 | { | ||
90 | mu_error (_("expected string value")); | ||
91 | return 1; | ||
92 | } | ||
93 | return 0; | ||
94 | } | ||
95 | |||
96 | static struct mu_cfg_param mu_auth_param[] = { | ||
97 | { "authentication", mu_cfg_callback, NULL, 0, cb_authentication, | ||
98 | /* FIXME: The description is incomplete. MU-list is also allowed as | ||
99 | argument */ | ||
100 | N_("Set a list of modules for authentication. Modlist is a " | ||
101 | "colon-separated list of module names or a word `clear' to " | ||
102 | "clear the previously set up values."), | ||
103 | N_("modlist") }, | ||
104 | { "authorization", mu_cfg_callback, NULL, 0, cb_authorization, | ||
105 | N_("Set a list of modules for authorization. Modlist is a " | ||
106 | "colon-separated list of module names or a word `clear' to " | ||
107 | "clear the previously set up values."), | ||
108 | N_("modlist") }, | ||
109 | { NULL } | ||
110 | }; | ||
111 | |||
112 | int | ||
113 | mu_auth_section_parser | ||
114 | (enum mu_cfg_section_stage stage, const mu_cfg_node_t *node, | ||
115 | const char *section_label, void **section_data, void *call_data, | ||
116 | mu_cfg_tree_t *tree) | ||
117 | { | ||
118 | switch (stage) | ||
119 | { | ||
120 | case mu_cfg_section_start: | ||
121 | break; | ||
122 | |||
123 | case mu_cfg_section_end: | ||
124 | mu_auth_finish_setup (); | ||
125 | } | ||
126 | return 0; | ||
127 | } | ||
128 | |||
129 | struct mu_cfg_capa mu_auth_cfg_capa = { | ||
130 | "auth", mu_auth_param, mu_auth_section_parser | ||
131 | }; |
libmu_cfg/common.c
deleted
100644 → 0
1 | /* This file is part of GNU Mailutils | ||
2 | Copyright (C) 2007-2012, 2014-2016 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, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | #include <stdlib.h> | ||
22 | #include <string.h> | ||
23 | #include "mailutils/libcfg.h" | ||
24 | #include <mailutils/debug.h> | ||
25 | #include <mailutils/syslog.h> | ||
26 | #include <mailutils/mailbox.h> | ||
27 | #include <mailutils/io.h> | ||
28 | #include <mailutils/stream.h> | ||
29 | #include <mailutils/stdstream.h> | ||
30 | |||
31 | static struct mu_gocs_locking locking_settings; | ||
32 | static struct mu_gocs_mailbox mailbox_settings; | ||
33 | static struct mu_gocs_source_email address_settings; | ||
34 | static struct mu_gocs_mailer mailer_settings; | ||
35 | static struct mu_gocs_debug debug_settings; | ||
36 | |||
37 | |||
38 | /* ************************************************************************* */ | ||
39 | /* Mailbox */ | ||
40 | /* ************************************************************************* */ | ||
41 | |||
42 | static int | ||
43 | _cb_folder (void *data, mu_config_value_t *val) | ||
44 | { | ||
45 | if (mu_cfg_assert_value_type (val, MU_CFG_STRING)) | ||
46 | return 1; | ||
47 | mu_set_folder_directory (val->v.string); | ||
48 | return 0; | ||
49 | } | ||
50 | |||
51 | static struct mu_cfg_param mu_mailbox_param[] = { | ||
52 | { "mail-spool", mu_c_string, &mailbox_settings.mail_spool, 0, NULL, | ||
53 | N_("Use specified URL as a mailspool directory."), | ||
54 | N_("url") }, | ||
55 | { "mailbox-pattern", mu_c_string, &mailbox_settings.mailbox_pattern, | ||
56 | 0, NULL, | ||
57 | N_("Create mailbox URL using <pattern>."), | ||
58 | N_("pattern") }, | ||
59 | { "mailbox-type", mu_c_string, &mailbox_settings.mailbox_type, 0, NULL, | ||
60 | N_("Default mailbox type."), N_("protocol") }, | ||
61 | { "folder", mu_cfg_callback, NULL, 0, _cb_folder, | ||
62 | N_("Default user mail folder"), | ||
63 | N_("dir") }, | ||
64 | { NULL } | ||
65 | }; | ||
66 | |||
67 | DCL_CFG_CAPA (mailbox); | ||
68 | |||
69 | |||
70 | /* ************************************************************************* */ | ||
71 | /* Locking */ | ||
72 | /* ************************************************************************* */ | ||
73 | |||
74 | static struct mu_cfg_param mu_locking_param[] = { | ||
75 | /* FIXME: Flags are superfluous. */ | ||
76 | { "flags", mu_c_string, &locking_settings.lock_flags, 0, NULL, | ||
77 | N_("Default locker flags (E=external, R=retry, T=time, P=pid).") }, | ||
78 | { "retry-timeout", mu_c_ulong, &locking_settings.lock_retry_timeout, | ||
79 | 0, NULL, | ||
80 | N_("Set timeout for acquiring the lock.") }, | ||
81 | { "retry-count", mu_c_ulong, &locking_settings.lock_retry_count, 0, NULL, | ||
82 | N_("Set the maximum number of times to retry acquiring the lock.") }, | ||
83 | { "expire-timeout", mu_c_ulong, &locking_settings.lock_expire_timeout, | ||
84 | 0, NULL, | ||
85 | N_("Expire locks older than this amount of time.") }, | ||
86 | { "external-locker", mu_c_string, &locking_settings.external_locker, | ||
87 | 0, NULL, | ||
88 | N_("Use external locker program."), | ||
89 | N_("prog") }, | ||
90 | { NULL, } | ||
91 | }; | ||
92 | |||
93 | DCL_CFG_CAPA (locking); | ||
94 | |||
95 | |||
96 | /* ************************************************************************* */ | ||
97 | /* Address */ | ||
98 | /* ************************************************************************* */ | ||
99 | |||
100 | static struct mu_cfg_param mu_address_param[] = { | ||
101 | { "email-addr", mu_c_string, &address_settings.address, 0, NULL, | ||
102 | N_("Set the current user email address (default is " | ||
103 | "loginname@defaultdomain)."), | ||
104 | N_("email") }, | ||
105 | { "email-domain", mu_c_string, &address_settings.domain, 0, NULL, | ||
106 | N_("Set e-mail domain for unqualified user names (default is this host)"), | ||
107 | N_("domain") }, | ||
108 | { NULL } | ||
109 | }; | ||
110 | |||
111 | DCL_CFG_CAPA (address); | ||
112 | |||
113 | |||
114 | /* ************************************************************************* */ | ||
115 | /* Mailer */ | ||
116 | /* ************************************************************************* */ | ||
117 | |||
118 | static struct mu_cfg_param mu_mailer_param[] = { | ||
119 | { "url", mu_c_string, &mailer_settings.mailer, 0, NULL, | ||
120 | N_("Use this URL as the default mailer"), | ||
121 | N_("url") }, | ||
122 | { NULL } | ||
123 | }; | ||
124 | |||
125 | DCL_CFG_CAPA (mailer); | ||
126 | |||
127 | |||
128 | /* ************************************************************************* */ | ||
129 | /* Logging */ | ||
130 | /* ************************************************************************* */ | ||
131 | |||
132 | static int | ||
133 | cb_facility (void *data, mu_config_value_t *val) | ||
134 | { | ||
135 | if (mu_cfg_assert_value_type (val, MU_CFG_STRING)) | ||
136 | return 1; | ||
137 | |||
138 | if (mu_string_to_syslog_facility (val->v.string, &mu_log_facility)) | ||
139 | { | ||
140 | mu_error (_("unknown syslog facility `%s'"), val->v.string); | ||
141 | return 1; | ||
142 | } | ||
143 | return 0; | ||
144 | } | ||
145 | |||
146 | static int | ||
147 | cb_severity (void *data, mu_config_value_t *val) | ||
148 | { | ||
149 | unsigned n; | ||
150 | |||
151 | if (mu_cfg_assert_value_type (val, MU_CFG_STRING)) | ||
152 | return 1; | ||
153 | if (mu_severity_from_string (val->v.string, &n)) | ||
154 | { | ||
155 | mu_error (_("unknown severity `%s'"), val->v.string); | ||
156 | return 1; | ||
157 | } | ||
158 | mu_log_severity_threshold = n; | ||
159 | return 0; | ||
160 | } | ||
161 | |||
162 | static struct mu_cfg_param mu_logging_param[] = { | ||
163 | { "syslog", mu_c_bool, &mu_log_syslog, 0, NULL, | ||
164 | N_("Send diagnostics to syslog.") }, | ||
165 | { "print-severity", mu_c_bool, &mu_log_print_severity, 0, NULL, | ||
166 | N_("Print message severity levels.") }, | ||
167 | { "severity", mu_cfg_callback, NULL, 0, cb_severity, | ||
168 | N_("Output only messages with a severity equal to or greater than " | ||
169 | "this one.") }, | ||
170 | { "facility", mu_cfg_callback, NULL, 0, cb_facility, | ||
171 | N_("Set syslog facility. Arg is one of the following: user, daemon, " | ||
172 | "auth, authpriv, mail, cron, local0 through local7 (case-insensitive), " | ||
173 | "or a facility number.") }, | ||
174 | { "session-id", mu_c_bool, &mu_log_session_id, 0, NULL, | ||
175 | N_("Log session ID") }, | ||
176 | { "tag", mu_c_string, &mu_log_tag, 0, NULL, | ||
177 | N_("Tag syslog messages with this string.") }, | ||
178 | { NULL } | ||
179 | }; | ||
180 | |||
181 | static int logging_settings; /* Dummy variable */ | ||
182 | DCL_CFG_CAPA (logging); | ||
183 | |||
184 | |||
185 | /* ************************************************************************* */ | ||
186 | /* Debug */ | ||
187 | /* ************************************************************************* */ | ||
188 | |||
189 | static int | ||
190 | _cb2_debug_level (const char *arg, void *data MU_ARG_UNUSED) | ||
191 | { | ||
192 | mu_debug_parse_spec (arg); | ||
193 | return 0; | ||
194 | } | ||
195 | |||
196 | static int | ||
197 | cb_debug_level (void *data, mu_config_value_t *val) | ||
198 | { | ||
199 | return mu_cfg_string_value_cb (val, _cb2_debug_level, NULL); | ||
200 | } | ||
201 | |||
202 | static struct mu_cfg_param mu_debug_param[] = { | ||
203 | { "level", mu_cfg_callback, NULL, 0, &cb_debug_level, | ||
204 | N_("Set Mailutils debugging level. Argument is a colon-separated list " | ||
205 | "of debugging specifications in the form:\n" | ||
206 | " <object: string>[[:]=<level: number>].") }, | ||
207 | { "line-info", mu_c_bool, &debug_settings.line_info, 0, NULL, | ||
208 | N_("Prefix debug messages with Mailutils source locations.") }, | ||
209 | { NULL } | ||
210 | }; | ||
211 | |||
212 | DCL_CFG_CAPA (debug); | ||
213 |
libmu_cfg/gsasl.c
deleted
100644 → 0
1 | /* This file is part of GNU Mailutils | ||
2 | Copyright (C) 2007, 2010-2012, 2014-2016 Free Software Foundation, | ||
3 | Inc. | ||
4 | |||
5 | GNU Mailutils is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU General Public License as | ||
7 | published by the Free Software Foundation; either version 3, or (at | ||
8 | your option) any later version. | ||
9 | |||
10 | GNU Mailutils is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #ifdef HAVE_CONFIG_H | ||
20 | # include <config.h> | ||
21 | #endif | ||
22 | #include <stdlib.h> | ||
23 | #include "mailutils/libcfg.h" | ||
24 | #include <mailutils/gsasl.h> | ||
25 | |||
26 | static struct mu_gsasl_module_data gsasl_settings; | ||
27 | |||
28 | static struct mu_cfg_param mu_gsasl_param[] = { | ||
29 | { "enable", mu_c_bool, &gsasl_settings.enable, 0, NULL, | ||
30 | N_("Enable GSASL (default)") }, | ||
31 | { "cram-passwd", mu_c_string, &gsasl_settings.cram_md5_pwd, 0, NULL, | ||
32 | N_("Name of GSASL password file."), | ||
33 | N_("file") }, | ||
34 | { "service", mu_c_string, &gsasl_settings.service, 0, NULL, | ||
35 | N_("SASL service name."), | ||
36 | N_("name") }, | ||
37 | { "realm", mu_c_string, &gsasl_settings.realm, 0, NULL, | ||
38 | N_("SASL realm name."), | ||
39 | N_("name") }, | ||
40 | { "hostname", mu_c_string, &gsasl_settings.hostname, 0, NULL, | ||
41 | N_("SASL host name."), | ||
42 | N_("name") }, | ||
43 | { "anonymous-user", mu_c_string, &gsasl_settings.anon_user, 0, NULL, | ||
44 | N_("Anonymous user name."), | ||
45 | N_("name") }, | ||
46 | |||
47 | { NULL } | ||
48 | }; | ||
49 | |||
50 | DCL_CFG_CAPA (gsasl); | ||
51 | |||
52 |
libmu_cfg/init.c
deleted
100644 → 0
1 | /* This file is part of GNU Mailutils | ||
2 | Copyright (C) 2007-2012, 2014-2016 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, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | #define MU_CFG_COMPATIBILITY /* This source uses deprecated cfg interfaces */ | ||
22 | #include "mailutils/libcfg.h" | ||
23 | #include <string.h> | ||
24 | #include <stdlib.h> | ||
25 | |||
26 | #define CFG_CAPA_MAX 512 | ||
27 | static struct mu_cfg_capa *cfg_capa_table[CFG_CAPA_MAX] = { | ||
28 | #define S(c) &__mu_common_cat3__(mu_,c,_cfg_capa) | ||
29 | S (auth), | ||
30 | S (mailbox), | ||
31 | S (locking), | ||
32 | S (address), | ||
33 | S (mailer), | ||
34 | S (logging), | ||
35 | S (gsasl), | ||
36 | S (pam), | ||
37 | S (radius), | ||
38 | S (sql), | ||
39 | S (tls), | ||
40 | S (virtdomain), | ||
41 | S (sieve), | ||
42 | S (ldap), | ||
43 | S (debug), | ||
44 | NULL | ||
45 | }; | ||
46 | |||
47 | static int cfg_capa_index = MU_ARRAY_SIZE(cfg_capa_table) - 1; | ||
48 | |||
49 | static struct mu_cfg_capa * | ||
50 | find_cfg_capa (const char *name) | ||
51 | { | ||
52 | int i; | ||
53 | |||
54 | for (i = 0; cfg_capa_table[i]; i++) | ||
55 | if (strcmp (cfg_capa_table[i]->name, name) == 0) | ||
56 | return cfg_capa_table[i]; | ||
57 | return NULL; | ||
58 | } | ||
59 | |||
60 | static int | ||
61 | reserved_name (const char *name) | ||
62 | { | ||
63 | static char *reserved[] = { "common", NULL }; | ||
64 | char **p; | ||
65 | |||
66 | if (name[0] == '.') | ||
67 | return 1; | ||
68 | |||
69 | for (p = reserved; *p; p++) | ||
70 | if (strcmp (name, *p) == 0) | ||
71 | return 1; | ||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | int | ||
76 | mu_libcfg_register_capa (struct mu_cfg_capa *capa) | ||
77 | { | ||
78 | if (cfg_capa_index == CFG_CAPA_MAX) | ||
79 | return MU_ERR_NOENT; | ||
80 | cfg_capa_table[cfg_capa_index++] = capa; | ||
81 | return 0; | ||
82 | } | ||
83 | |||
84 | void | ||
85 | mu_libcfg_init (char **cnames) | ||
86 | { | ||
87 | int i; | ||
88 | for (i = 0; cnames[i]; i++) | ||
89 | { | ||
90 | if (!reserved_name (cnames[i])) | ||
91 | { | ||
92 | struct mu_cfg_capa *cp = find_cfg_capa (cnames[i]); | ||
93 | if (cp) | ||
94 | mu_config_root_register_section (NULL, cp->name, NULL, | ||
95 | cp->parser, cp->cfgparam); | ||
96 | #if 0 | ||
97 | else | ||
98 | mu_error (_("unknown configuration group requested `%s'"), | ||
99 | cnames[i]); | ||
100 | #endif | ||
101 | } | ||
102 | } | ||
103 | } | ||
104 | |||
105 | int | ||
106 | mu_libcfg_parse_config (mu_cfg_tree_t **ptree) | ||
107 | { | ||
108 | struct mu_cfg_parse_hints hints; | ||
109 | |||
110 | memset (&hints, 0, sizeof (hints)); | ||
111 | |||
112 | if (mu_cfg_parser_verbose) | ||
113 | hints.flags |= MU_PARSE_CONFIG_VERBOSE; | ||
114 | if (mu_cfg_parser_verbose > 1) | ||
115 | hints.flags |= MU_PARSE_CONFIG_DUMP; | ||
116 | |||
117 | if (mu_load_site_rcfile) | ||
118 | { | ||
119 | hints.flags |= MU_CFG_PARSE_SITE_RCFILE; | ||
120 | hints.site_rcfile = mu_site_rcfile; | ||
121 | } | ||
122 | |||
123 | if (mu_load_user_rcfile && mu_program_name) | ||
124 | { | ||
125 | hints.flags |= MU_CFG_PARSE_PROGRAM; | ||
126 | hints.program = (char*) mu_program_name; | ||
127 | } | ||
128 | |||
129 | if (mu_load_rcfile) | ||
130 | { | ||
131 | hints.flags |= MU_CFG_PARSE_CUSTOM_RCFILE; | ||
132 | hints.custom_rcfile = mu_load_rcfile; | ||
133 | } | ||
134 | |||
135 | return mu_cfg_parse_config (ptree, &hints); | ||
136 | } | ||
137 | |||
138 | |||
139 | |||
140 | /* FIXME: Deprecated */ | ||
141 | int | ||
142 | mu_parse_config_files (struct mu_cfg_param *param, void *target) | ||
143 | { | ||
144 | int flags = 0; | ||
145 | int rc; | ||
146 | |||
147 | if (mu_cfg_parser_verbose) | ||
148 | flags |= MU_PARSE_CONFIG_VERBOSE; | ||
149 | if (mu_cfg_parser_verbose > 1) | ||
150 | flags |= MU_PARSE_CONFIG_DUMP; | ||
151 | |||
152 | if (mu_load_site_rcfile) | ||
153 | { | ||
154 | rc = mu_parse_config (mu_site_rcfile, mu_program_name, param, | ||
155 | flags | MU_PARSE_CONFIG_GLOBAL, target); | ||
156 | if (rc == ENOMEM) | ||
157 | { | ||
158 | mu_error ("%s", mu_strerror (rc)); | ||
159 | return rc; | ||
160 | } | ||
161 | } | ||
162 | |||
163 | if (mu_load_user_rcfile && mu_program_name) | ||
164 | { | ||
165 | size_t size = 3 + strlen (mu_program_name) + 1; | ||
166 | char *file_name = malloc (size); | ||
167 | if (file_name) | ||
168 | { | ||
169 | strcpy (file_name, "~/."); | ||
170 | strcat (file_name, mu_program_name); | ||
171 | |||
172 | rc = mu_parse_config (file_name, mu_program_name, param, flags, | ||
173 | target); | ||
174 | if (rc == ENOMEM) | ||
175 | { | ||
176 | mu_error ("%s", mu_strerror (rc)); | ||
177 | return rc; | ||
178 | } | ||
179 | |||
180 | free (file_name); | ||
181 | } | ||
182 | } | ||
183 | |||
184 | if (mu_load_rcfile) | ||
185 | { | ||
186 | rc = mu_parse_config (mu_load_rcfile, mu_program_name, param, | ||
187 | flags, target); | ||
188 | if (rc) | ||
189 | { | ||
190 | mu_error (_("errors parsing file %s: %s"), mu_load_rcfile, | ||
191 | mu_strerror (rc)); | ||
192 | return rc; | ||
193 | } | ||
194 | } | ||
195 | |||
196 | return 0; | ||
197 | } |
libmu_cfg/ldap.c
deleted
100644 → 0
1 | /* This file is part of GNU Mailutils | ||
2 | Copyright (C) 2007-2012, 2014-2016 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, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #ifdef HAVE_CONFIG_H | ||
19 | # include <config.h> | ||
20 | #endif | ||
21 | #include <stdlib.h> | ||
22 | #include "mailutils/libcfg.h" | ||
23 | #include "mailutils/util.h" | ||
24 | #include "mailutils/ldap.h" | ||
25 | |||
26 | static struct mu_ldap_module_config ldap_settings; | ||
27 | |||
28 | static int | ||
29 | _cb2_field_map (const char *arg, void *data) | ||
30 | { | ||
31 | int err; | ||
32 | int rc = mutil_parse_field_map (arg, &ldap_settings.field_map, &err); | ||
33 | if (rc) | ||
34 | /* FIXME: this message can be misleading */ | ||
35 | mu_error (_("error near element %d: %s"), err, mu_strerror (rc)); | ||
36 | return 0; | ||
37 | } | ||
38 | |||
39 | static int | ||
40 | cb_field_map (void *data, mu_config_value_t *val) | ||
41 | { | ||
42 | return mu_cfg_string_value_cb (val, _cb2_field_map, NULL); | ||
43 | } | ||
44 | |||
45 | static struct mu_cfg_param mu_ldap_param[] = { | ||
46 | { "enable", mu_c_bool, &ldap_settings.enable, 0, NULL, | ||
47 | N_("Enable LDAP lookups.") }, | ||
48 | { "url", mu_c_string, &ldap_settings.url, 0, NULL, | ||
49 | N_("Set URL of the LDAP server."), | ||
50 | N_("url") }, | ||
51 | { "base", mu_c_string, &ldap_settings.base, 0, NULL, | ||
52 | N_("Base DN for LDAP lookups."), | ||
53 | N_("dn") }, | ||
54 | { "binddn", mu_c_string, &ldap_settings.binddn, 0, NULL, | ||
55 | N_("DN for accessing LDAP database."), | ||
56 | N_("dn") }, | ||
57 | { "passwd", mu_c_string, &ldap_settings.passwd, 0, NULL, | ||
58 | N_("Password for use with binddn.") }, | ||
59 | { "tls", mu_c_bool, &ldap_settings.tls, 0, NULL, | ||
60 | N_("Use TLS encryption.") }, | ||
61 | { "debug", mu_c_int, &ldap_settings.debug, 0, NULL, | ||
62 | N_("Set LDAP debugging level.") }, | ||
63 | { "field-map", mu_cfg_callback, NULL, 0, cb_field_map, | ||
64 | N_("Set a field-map for parsing LDAP replies. The map is a " | ||
65 | "column-separated list of definitions. Each definition has the " | ||
66 | "following form:\n" | ||
67 | " <name: string>=<attr: string>\n" | ||
68 | "where <name> is one of the following: name, passwd, uid, gid, " | ||
69 | "gecos, dir, shell, mailbox, quota, and <attr> is the name of " | ||
70 | "the corresponding LDAP attribute."), | ||
71 | N_("map") }, | ||
72 | { "getpwnam", mu_c_string, &ldap_settings.getpwnam_filter, 0, NULL, | ||
73 | N_("LDAP filter to use for getpwnam requests."), | ||
74 | N_("filter") }, | ||
75 | { "getpwuid", mu_c_string, &ldap_settings.getpwuid_filter, 0, NULL, | ||
76 | N_("LDAP filter to use for getpwuid requests."), | ||
77 | N_("filter") }, | ||
78 | { NULL } | ||
79 | }; | ||
80 | |||
81 | int | ||
82 | mu_ldap_section_parser | ||
83 | (enum mu_cfg_section_stage stage, const mu_cfg_node_t *node, | ||
84 | const char *section_label, void **section_data, | ||
85 | void *call_data, mu_cfg_tree_t *tree) | ||
86 | { | ||
87 | switch (stage) | ||
88 | { | ||
89 | case mu_cfg_section_start: | ||
90 | ldap_settings.enable = 1; | ||
91 | break; | ||
92 | |||
93 | case mu_cfg_section_end: | ||
94 | mu_gocs_store ("ldap", &ldap_settings); | ||
95 | } | ||
96 | return 0; | ||
97 | } | ||
98 | |||
99 | struct mu_cfg_capa mu_ldap_cfg_capa = { | ||
100 | "ldap", mu_ldap_param, mu_ldap_section_parser | ||
101 | }; |
libmu_cfg/pam.c
deleted
100644 → 0
1 | /* This file is part of GNU Mailutils | ||
2 | Copyright (C) 2007, 2010-2012, 2014-2016 Free Software Foundation, | ||
3 | Inc. | ||
4 | |||
5 | GNU Mailutils is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU General Public License as | ||
7 | published by the Free Software Foundation; either version 3, or (at | ||
8 | your option) any later version. | ||
9 | |||
10 | GNU Mailutils is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #ifdef HAVE_CONFIG_H | ||
20 | # include <config.h> | ||
21 | #endif | ||
22 | #include <stdlib.h> | ||
23 | #include "mailutils/libcfg.h" | ||
24 | |||
25 | static char *pam_settings; | ||
26 | |||
27 | static struct mu_cfg_param mu_pam_param[] = { | ||
28 | { "service", mu_c_string, &pam_settings, 0, NULL, | ||
29 | N_("Set PAM service name."), | ||
30 | N_("name") }, | ||
31 | { NULL } | ||
32 | }; | ||
33 | |||
34 | DCL_CFG_CAPA (pam); | ||
35 |
libmu_cfg/radius.c
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
libmu_cfg/sieve.c
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
libmu_cfg/sql.c
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
libmu_cfg/tls.c
deleted
100644 → 0
This diff is collapsed.
Click to expand it.
libmu_cfg/virtdomain.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.
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