summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac1
-rw-r--r--dotlock/Makefile.am2
-rw-r--r--dotlock/dotlock.c146
-rw-r--r--frm/Makefile.am2
-rw-r--r--frm/frm.c190
-rw-r--r--frm/frm.h2
-rw-r--r--frm/from.c83
-rw-r--r--include/mailutils/sieve.h3
-rw-r--r--include/mailutils/tls.h3
-rw-r--r--libmailutils/cli/cli.c2
-rw-r--r--libmailutils/cli/stdcapa.c102
-rw-r--r--libmu_auth/tls.c111
-rw-r--r--messages/Makefile.am2
-rw-r--r--messages/messages.c89
-rw-r--r--mimeview/Makefile.am2
-rw-r--r--mimeview/mimeview.c169
-rw-r--r--movemail/Makefile.am2
-rw-r--r--movemail/movemail.c294
-rw-r--r--readmsg/Makefile.am2
-rw-r--r--readmsg/readmsg.c140
-rw-r--r--sieve/Makefile.am2
-rw-r--r--sieve/sieve.c265
22 files changed, 753 insertions, 861 deletions
diff --git a/configure.ac b/configure.ac
index d729747cf..d9f1b588f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -58,6 +58,7 @@ AC_SUBST(MU_SIEVE_MODDIR,'$(libdir)/$(PACKAGE)')
AC_SUBST(MU_COMMON_LIBRARIES,'$(LTLIBINTL) $(LTLIBICONV)')
AC_SUBST(MU_APP_LIBRARIES,'${top_builddir}/libmu_argp/libmu_argp.la ${top_builddir}/libmu_cfg/libmu_cfg.la ${top_builddir}/lib/libmuaux.la')
+AC_SUBST(MU_APP_NEW_LIBRARIES,'${top_builddir}/lib/libmuaux.la')
# There are two sets of include directories: MU_LIB_COMMON_INCLUDES, used
# by the libraries, and MU_APP_COMMON_INCLUDES, which is used by applications.
diff --git a/dotlock/Makefile.am b/dotlock/Makefile.am
index 3425b0fd7..0ab3f34f6 100644
--- a/dotlock/Makefile.am
+++ b/dotlock/Makefile.am
@@ -20,7 +20,7 @@ AM_CPPFLAGS = @MU_APP_COMMON_INCLUDES@
bin_PROGRAMS = dotlock
dotlock_LDADD = \
- ${MU_APP_LIBRARIES}\
+ ${MU_APP_NEW_LIBRARIES}\
${MU_LIB_MAILUTILS}\
@MU_COMMON_LIBRARIES@
diff --git a/dotlock/dotlock.c b/dotlock/dotlock.c
index c6a96c504..0a8cfec26 100644
--- a/dotlock/dotlock.c
+++ b/dotlock/dotlock.c
@@ -20,49 +20,12 @@
#endif
#include <stdlib.h>
-#ifdef __EXT_QNX
-# undef __EXT_QNX
-#endif
#include <unistd.h>
#include <mailutils/errno.h>
#include <mailutils/locker.h>
#include <mailutils/nls.h>
-
-#include "mailutils/libargp.h"
-
-static char doc[] =
-N_("GNU dotlock -- lock mail spool files.")
-"\v"
-N_("Returns 0 on success, 3 if locking the file fails because\
- it's already locked, and 1 if some other kind of error occurred.");
-
-static char args_doc[] = N_("FILE");
-
-static struct argp_option options[] = {
- {"unlock", 'u', NULL, 0,
- N_("unlock"), 0},
-
- {"force", 'f', N_("MINUTES"), OPTION_ARG_OPTIONAL,
- N_("forcibly break an existing lock older than a certain time"), 0},
-
- {"retry", 'r', N_("RETRIES"), OPTION_ARG_OPTIONAL,
- N_("retry the lock a few times"), 0},
-
- {"debug", 'd', NULL, 0,
- N_("print details of failure reasons to stderr"), 0},
-
- {NULL, 0, NULL, 0, NULL, 0}
-};
-
-static error_t parse_opt (int key, char *arg, struct argp_state *state);
-
-static struct argp argp = {
- options,
- parse_opt,
- args_doc,
- doc,
-};
+#include "mailutils/cli.h"
static const char *file;
static int unlock;
@@ -71,55 +34,25 @@ static int retries;
static time_t force;
static int debug;
-static error_t
-parse_opt (int key, char *arg, struct argp_state *state)
-{
- static mu_list_t lst;
-
- switch (key)
- {
- case 'd':
- mu_argp_node_list_new (lst, "debug", "yes");
- break;
-
- case 'u':
- unlock = 1;
- break;
-
- case 'r':
- if (arg)
- mu_argp_node_list_new (lst, "retry", arg);
- break;
-
- case 'f':
- mu_argp_node_list_new (lst, "force", arg ? arg : "0");
- break;
-
- case ARGP_KEY_ARG:
- if (file)
- argp_error (state, _("only one FILE can be specified"));
- file = arg;
- break;
-
- case ARGP_KEY_NO_ARGS:
- if (!mu_help_config_mode)
- argp_error (state, _("FILE must be specified"));
- return ARGP_ERR_UNKNOWN;
-
- case ARGP_KEY_INIT:
- mu_argp_node_list_init (&lst);
- break;
-
- case ARGP_KEY_FINI:
- mu_argp_node_list_finish (lst, NULL, NULL);
- break;
-
- default:
- return ARGP_ERR_UNKNOWN;
- }
- return 0;
-}
-
+static struct mu_option dotlock_options[] = {
+ { "unlock", 'u', NULL, MU_OPTION_DEFAULT,
+ N_("unlock"),
+ mu_c_bool, &unlock },
+
+ { "force", 'f', N_("MINUTES"), MU_OPTION_ARG_OPTIONAL,
+ N_("forcibly break an existing lock older than a certain time"),
+ mu_c_time, &force },//FIXME: Default value
+
+ { "retry", 'r', N_("RETRIES"), MU_OPTION_ARG_OPTIONAL,
+ N_("retry the lock a few times"),
+ mu_c_int, &retries },
+
+ { "debug", 'd', NULL, MU_OPTION_DEFAULT,
+ N_("print details of failure reasons to stderr"),
+ mu_c_bool, &debug },
+
+ MU_OPTION_END
+}, *options[] = { dotlock_options, NULL };
struct mu_cfg_param dotlock_cfg_param[] = {
{ "force", mu_c_time, &force, 0, NULL,
@@ -130,12 +63,22 @@ struct mu_cfg_param dotlock_cfg_param[] = {
N_("Print details of failure reasons to stderr.") },
{ NULL }
};
+
+static struct mu_cli_setup cli = {
+ options,
+ dotlock_cfg_param,
+ N_("GNU dotlock -- lock mail spool files."),
+ //FIXME:
+ /*
+ N_("Returns 0 on success, 3 if locking the file fails because\
+ it's already locked, and 1 if some other kind of error occurred.");
+ */
+ N_("FILE")
+};
-const char *dotlock_capa[] = {
- "mailutils",
- "common",
+char *capa[] = {
"debug",
NULL
};
@@ -156,13 +99,24 @@ main (int argc, char *argv[])
if (setegid (usergid) < 0)
return MU_DL_EX_ERROR;
- argp_err_exit_status = MU_DL_EX_ERROR;
-
- mu_argp_init (NULL, NULL);
- if (mu_app_init (&argp, dotlock_capa, dotlock_cfg_param,
- argc, argv, 0, NULL, NULL))
- exit (1);
+ /* FIXME: Force mu_cli to exit with MU_DL_EX_ERROR on errors? */
+
+ mu_cli (argc, argv, &cli, capa, NULL, &argc, &argv);
+
+ switch (argc)
+ {
+ case 0:
+ mu_error (_("FILE must be specified"));
+ exit (MU_DL_EX_ERROR);
+
+ case 1:
+ file = argv[0];
+ break;
+ default:
+ mu_error (_("only one FILE can be specified"));
+ }
+
if (force)
{
force *= 60;
diff --git a/frm/Makefile.am b/frm/Makefile.am
index 7861b5172..8678e2f24 100644
--- a/frm/Makefile.am
+++ b/frm/Makefile.am
@@ -27,7 +27,7 @@ frm_LDADD = $(common_ldadd)
from_LDADD = $(common_ldadd)
common_ldadd = \
- ${MU_APP_LIBRARIES}\
+ ${MU_APP_NEW_LIBRARIES}\
${MU_LIB_MBOX}\
${MU_LIB_IMAP}\
${MU_LIB_POP}\
diff --git a/frm/frm.c b/frm/frm.c
index 4df0d87ad..99db1914d 100644
--- a/frm/frm.c
+++ b/frm/frm.c
@@ -29,8 +29,6 @@ static int align = 0; /* Tidy mode. -t option. */
#define IS_NEW 0x100
static int select_attribute;
-static char doc[] = N_("GNU frm -- display From: lines.");
-
static struct attr_tab {
char *name; /* Attribute name */
int code; /* Corresponding IS_.* flag */
@@ -84,7 +82,7 @@ prepare_attrs (void)
/* Translates the textual status representation to the corresponding
IS_.* flag */
static int
-decode_attr (char *arg)
+decode_attr (char const *arg)
{
struct attr_tab *p;
int len = strlen (arg);
@@ -111,105 +109,82 @@ decode_attr (char *arg)
}
+static void
+cli_show_field (struct mu_parseopt *po, struct mu_option *opt, char const *arg)
+{
+ show_field = mu_strdup (arg);
+ align = 0;
+}
-static struct argp_option options[] = {
- {"debug", 'd', NULL, 0, N_("enable debugging output"), 0},
- {"field", 'f', N_("NAME"), 0, N_("header field to display"), 0},
- {"to", 'l', NULL, 0, N_("include the To: information"), 0},
- {"number", 'n', NULL, 0, N_("display message numbers"), 0},
- {"Quiet", 'Q', NULL, 0, N_("do not display headers"), 0},
- {"query", 'q', NULL, 0, N_("print a message if the mailbox contains some unread mail"), 0},
- {"summary",'S', NULL, 0, N_("print a summary of messages"), 0},
- {"status", 's', N_("STATUS"), 0,
- /* TRANSLATORS: Please do *not* translate the words "new", "unread",
- "old" and "read". They are keywords. */
- N_("select messages with the specific attribute:"
- " new, unread, old (same as unread) or read (or any unambiguous"
- " abbreviation of these)"),
- 0},
- {"align", 't', NULL, 0, N_("tidy mode: align subject lines"), 0},
- {0, 0, 0, 0}
-};
+static void
+cli_Quiet (struct mu_parseopt *po, struct mu_option *opt, char const *arg)
+{
+ be_quiet += 2;
+}
-static error_t
-parse_opt (int key, char *arg, struct argp_state *state)
+static void
+cli_query (struct mu_parseopt *po, struct mu_option *opt, char const *arg)
{
- switch (key)
- {
- case 'd':
- frm_debug++;
- break;
-
- case 'f':
- show_field = arg;
- align = 0;
- break;
-
- case 'l':
- show_to = 1;
- break;
-
- case 'n':
- show_number = 1;
- break;
-
- case 'Q':
- /* Very silent. */
- be_quiet += 2;
- break;
-
- case 'q':
- be_quiet++;
- show_query = 1;
- break;
-
- case 'S':
- show_summary = 1;
- break;
-
- case 's':
- select_attribute = decode_attr (arg);
- break;
-
- case 't':
- align = 1;
- break;
-
- case ARGP_KEY_FINI:
- {
- size_t s;
- if (align && (s = util_getcols ()))
- init_output (s);
- else
- init_output (0);
- }
- break;
-
- default:
- return ARGP_ERR_UNKNOWN;
- }
- return 0;
+ be_quiet++;
+ show_query = 1;
+}
+
+static void
+cli_status (struct mu_parseopt *po, struct mu_option *opt, char const *arg)
+{
+ select_attribute = decode_attr (arg);
}
-static struct argp argp = {
+static struct mu_option frm_options[] = {
+ { "debug", 'd', NULL, MU_OPTION_DEFAULT,
+ N_("enable debugging output"),
+ mu_c_incr, &frm_debug },
+ { "field", 'f', N_("NAME"), MU_OPTION_DEFAULT,
+ N_("header field to display"),
+ mu_c_string, &show_field, cli_show_field },
+ { "to", 'l', NULL, MU_OPTION_DEFAULT,
+ N_("include the To: information"),
+ mu_c_bool, &show_to },
+ { "number", 'n', NULL, MU_OPTION_DEFAULT,
+ N_("display message numbers"),
+ mu_c_bool, &show_number },
+ { "Quiet", 'Q', NULL, MU_OPTION_DEFAULT,
+ N_("do not display headers"),
+ mu_c_int, &be_quiet, cli_Quiet },
+ { "query", 'q', NULL, MU_OPTION_DEFAULT,
+ N_("print a message if the mailbox contains some unread mail"),
+ mu_c_int, &be_quiet, cli_query },
+ { "summary",'S', NULL, MU_OPTION_DEFAULT,
+ N_("print a summary of messages"),
+ mu_c_bool, &show_summary },
+ { "status", 's', N_("STATUS"), 0,
+ /* TRANSLATORS: Please do *not* translate the words "new", "unread",
+ "old" and "read". They are keywords. */
+ N_("select messages with the specific attribute:"
+ " new, unread, old (same as unread) or read (or any unambiguous"
+ " abbreviation of these)"),
+ mu_c_string, NULL, cli_status},
+ { "align", 't', NULL, MU_OPTION_DEFAULT,
+ N_("tidy mode: align subject lines"),
+ mu_c_bool, &align },
+ MU_OPTION_END
+}, *options[] = { frm_options, NULL };
+
+static struct mu_cli_setup cli = {
options,
- parse_opt,
- N_("[URL ...]"),
- doc,
NULL,
- NULL, NULL
+ N_("GNU frm -- display From: lines."),
+ N_("[URL ...]"),
};
-static const char *frm_argp_capa[] = {
- "mailutils",
- "common",
+static char *frm_argp_capa[] = {
"debug",
"mailbox",
"locking",
+ "tls",
NULL
};
-
-
+
static struct
{
size_t new;
@@ -342,8 +317,8 @@ frm (char *mailbox_name)
int
main (int argc, char **argv)
{
- int c;
int status = 0;
+ size_t s;
/* Native Language Support */
MU_APP_INIT_NLS ();
@@ -352,25 +327,30 @@ main (int argc, char **argv)
/* register the formats. */
mu_register_all_mbox_formats ();
-#ifdef WITH_TLS
- mu_gocs_register ("tls", mu_tls_module_init);
-#endif
-
- mu_argp_init (NULL, NULL);
- if (mu_app_init (&argp, frm_argp_capa, NULL, argc, argv, 0, &c, NULL))
- exit (1);
+ mu_cli_capa_register (&mu_cli_capa_tls);
+ mu_cli (argc, argv, &cli, frm_argp_capa, NULL, &argc, &argv);
+
+ if (align && (s = util_getcols ()))
+ init_output (s);
+ else
+ init_output (0);
+
/* have an argument */
- if (c == argc)
+ if (argc == 0)
status = frm (NULL);
- else if (c + 1 == argc)
- status = frm (argv[c]);
+ else if (argc == 1)
+ status = frm (argv[0]);
else
- for (; c < argc; c++)
- {
- mu_printf ("%s:\n", argv[c]);
- status = frm (argv[c]);
- }
-
+ {
+ int i;
+
+ for (i = 0; i < argc; i++)
+ {
+ mu_printf ("%s:\n", argv[i]);
+ status = frm (argv[i]);
+ }
+ }
+
return status;
}
diff --git a/frm/frm.h b/frm/frm.h
index 44e265287..60b10a04b 100644
--- a/frm/frm.h
+++ b/frm/frm.h
@@ -64,7 +64,7 @@
#include <mailutils/util.h>
#include <mailutils/mime.h>
-#include "mailutils/libargp.h"
+#include "mailutils/cli.h"
typedef int (*frm_select_t) (size_t index, mu_message_t msg);
diff --git a/frm/from.c b/frm/from.c
index 270221f3d..7995bb472 100644
--- a/frm/from.c
+++ b/frm/from.c
@@ -21,58 +21,34 @@ int count_only;
char *sender_option;
char *mailbox_name;
-static char doc[] = N_("GNU from -- display from and subject.");
-
-static struct argp_option options[] = {
- {"count", 'c', NULL, 0, N_("just print a count of messages and exit")},
- {"sender", 's', N_("ADDRESS"), 0,
- N_("print only mail from addresses containing the supplied string") },
- {"file", 'f', N_("FILE"), 0,
- N_("read mail from FILE") },
- {"debug", 'd', NULL, 0, N_("enable debugging output"), 0},
- {0, 0, 0, 0}
-};
-
-static error_t
-parse_opt (int key, char *arg, struct argp_state *state)
-{
- switch (key)
- {
- case 'c':
- count_only = 1;
- break;
-
- case 's':
- sender_option = arg;
- break;
-
- case 'f':
- mailbox_name = arg;
- break;
-
- case 'd':
- frm_debug++;
- break;
-
- default:
- return ARGP_ERR_UNKNOWN;
- }
- return 0;
-}
-
-static struct argp argp = {
+static struct mu_option from_options[] = {
+ { "count", 'c', NULL, MU_OPTION_DEFAULT,
+ N_("just print a count of messages and exit"),
+ mu_c_bool, &count_only },
+ { "sender", 's', N_("ADDRESS"), MU_OPTION_DEFAULT,
+ N_("print only mail from addresses containing the supplied string"),
+ mu_c_string, &sender_option },
+ { "file", 'f', N_("FILE"), MU_OPTION_DEFAULT,
+ N_("read mail from FILE"),
+ mu_c_string, &mailbox_name },
+ { "debug", 'd', NULL, MU_OPTION_DEFAULT,
+ N_("enable debugging output"),
+ mu_c_incr, &frm_debug },
+ MU_OPTION_END
+}, *options[] = { from_options, NULL };
+
+static struct mu_cli_setup cli = {
options,
- parse_opt,
+ NULL,
+ N_("GNU from -- display from and subject."),
N_("[OPTIONS] [USER]"),
- doc,
};
-static const char *capa[] = {
- "mailutils",
- "common",
+static char *capa[] = {
"debug",
"mailbox",
"locking",
+ "tls",
NULL
};
@@ -105,7 +81,6 @@ from_select (size_t index, mu_message_t msg)
int
main (int argc, char **argv)
{
- int c;
size_t total;
/* Native Language Support */
@@ -113,20 +88,16 @@ main (int argc, char **argv)
/* register the formats. */
mu_register_all_mbox_formats ();
-#ifdef WITH_TLS
- mu_gocs_register ("tls", mu_tls_module_init);
-#endif
- mu_argp_init (NULL, NULL);
- if (mu_app_init (&argp, capa, NULL, argc, argv, 0, &c, NULL))
- exit (1);
+ mu_cli_capa_register (&mu_cli_capa_tls);
+ mu_cli (argc, argv, &cli, capa, NULL, &argc, &argv);
- if (argc - c > 1)
+ if (argc > 1)
{
mu_error (_("too many arguments"));
exit (1);
}
- else if (argc - c > 0)
+ else if (argc > 0)
{
if (mailbox_name)
{
@@ -134,9 +105,9 @@ main (int argc, char **argv)
exit (1);
}
- mailbox_name = mu_alloc (strlen (argv[c]) + 2);
+ mailbox_name = mu_alloc (strlen (argv[0]) + 2);
mailbox_name[0] = '%';
- strcpy (mailbox_name + 1, argv[c]);
+ strcpy (mailbox_name + 1, argv[0]);
}
init_output (0);
diff --git a/include/mailutils/sieve.h b/include/mailutils/sieve.h
index 712309504..1ba1a7279 100644
--- a/include/mailutils/sieve.h
+++ b/include/mailutils/sieve.h
@@ -22,6 +22,7 @@
#include <sys/types.h>
#include <stdarg.h>
#include <mailutils/mailutils.h>
+#include <mailutils/cli.h>
#ifdef __cplusplus
extern "C" {
@@ -282,6 +283,8 @@ struct mu_gocs_sieve
int mu_sieve_module_init (enum mu_gocs_op, void *);
+extern struct mu_cli_capa mu_cli_capa_sieve;
+
#ifdef __cplusplus
}
#endif
diff --git a/include/mailutils/tls.h b/include/mailutils/tls.h
index 08e00e936..db6e420ad 100644
--- a/include/mailutils/tls.h
+++ b/include/mailutils/tls.h
@@ -20,6 +20,7 @@
#define _MAILUTILS_TLS_H
#include <mailutils/types.h>
+#include <mailutils/cli.h>
#ifdef __cplusplus
extern "C" {
@@ -55,6 +56,8 @@ extern int mu_init_tls_libs (int x509);
extern void mu_deinit_tls_libs (void);
extern int mu_tls_enable;
+
+extern struct mu_cli_capa mu_cli_capa_tls;
#ifdef __cplusplus
}
diff --git a/libmailutils/cli/cli.c b/libmailutils/cli/cli.c
index 2be1af833..597ac915e 100644
--- a/libmailutils/cli/cli.c
+++ b/libmailutils/cli/cli.c
@@ -384,7 +384,7 @@ mu_cli (int argc, char **argv, struct mu_cli_setup *setup, char **capa,
optv = init_options (capa, setup, &com_list);
if (mu_parseopt (&po, argc, argv, optv, flags))
- exit (EX_USAGE);
+ exit (po.po_exit_error);
argc -= po.po_arg_start;
argv += po.po_arg_start;
diff --git a/libmailutils/cli/stdcapa.c b/libmailutils/cli/stdcapa.c
index 3b1cabe54..05a761fa6 100644
--- a/libmailutils/cli/stdcapa.c
+++ b/libmailutils/cli/stdcapa.c
@@ -28,6 +28,7 @@
#include <mailutils/mailbox.h>
#include <mailutils/registrar.h>
#include <mailutils/locker.h>
+#include <mailutils/mu_auth.h>
/* *************************************************************************
* Logging section
@@ -440,7 +441,106 @@ static struct mu_cfg_param address_cfg[] = {
N_("domain: string") },
{ NULL }
};
+
+/* ************************************************************************* *
+ * Authentication & Authorization *
+ * ************************************************************************* */
+static int
+cb_authentication (void *data, mu_config_value_t *val)
+{
+ if (val->type == MU_CFG_STRING)
+ {
+ if (strcmp (val->v.string, "clear") == 0)
+ mu_authentication_clear_list ();
+ else
+ /*FIXME: use err for error reporting*/
+ mu_authentication_add_module_list (val->v.string);
+ }
+ else if (val->type == MU_CFG_LIST)
+ {
+ int i;
+ for (i = 0; i < val->v.arg.c; i++)
+ {
+ if (mu_cfg_assert_value_type (&val->v.arg.v[i], MU_CFG_STRING))
+ return 1;
+ if (strcmp (val->v.arg.v[i].v.string, "clear") == 0)
+ mu_authentication_clear_list ();
+ else
+ mu_authentication_add_module (val->v.arg.v[i].v.string);
+ }
+ }
+ else
+ {
+ mu_error (_("expected string value"));
+ return 1;
+ }
+ return 0;
+}
+
+static int
+cb_authorization (void *data, mu_config_value_t *val)
+{
+ if (val->type == MU_CFG_STRING)
+ {
+ if (strcmp (val->v.string, "clear") == 0)
+ mu_authorization_clear_list ();
+ else
+ /*FIXME: use err for error reporting*/
+ mu_authorization_add_module_list (val->v.string);
+ }
+ else if (val->type == MU_CFG_LIST)
+ {
+ int i;
+ for (i = 0; i < val->v.arg.c; i++)
+ {
+ if (mu_cfg_assert_value_type (&val->v.arg.v[i], MU_CFG_STRING))
+ return 1;
+ if (strcmp (val->v.arg.v[i].v.string, "clear") == 0)
+ mu_authorization_clear_list ();
+ else
+ mu_authorization_add_module (val->v.arg.v[i].v.string);
+ }
+ }
+ else
+ {
+ mu_error (_("expected string value"));
+ return 1;
+ }
+ return 0;
+}
+static struct mu_cfg_param mu_auth_param[] = {
+ { "authentication", mu_cfg_callback, NULL, 0, cb_authentication,
+ /* FIXME: The description is incomplete. MU-list is also allowed as
+ argument */
+ N_("Set a list of modules for authentication. Modlist is a "
+ "colon-separated list of module names or a word `clear' to "
+ "clear the previously set up values."),
+ N_("modlist") },
+ { "authorization", mu_cfg_callback, NULL, 0, cb_authorization,
+ N_("Set a list of modules for authorization. Modlist is a "
+ "colon-separated list of module names or a word `clear' to "
+ "clear the previously set up values."),
+ N_("modlist") },
+ { NULL }
+};
+
+int
+mu_auth_section_parser
+ (enum mu_cfg_section_stage stage, const mu_cfg_node_t *node,
+ const char *section_label, void **section_data, void *call_data,
+ mu_cfg_tree_t *tree)
+{
+ switch (stage)
+ {
+ case mu_cfg_section_start:
+ break;
+
+ case mu_cfg_section_end:
+ mu_auth_finish_setup ();
+ }
+ return 0;
+}
/* ************************************************************************* *
* Registry of standard mailutils' capabilities *
@@ -453,6 +553,8 @@ struct mu_cli_capa mu_cli_std_capa[] = {
{ "mailbox", NULL, mailbox_cfg, NULL, NULL },
{ "locking", NULL, locking_cfg, NULL, NULL },
{ "address", NULL, address_cfg, NULL, NULL },
+ { "auth", NULL, mu_auth_param, mu_auth_section_parser },
+
{ NULL }
};
diff --git a/libmu_auth/tls.c b/libmu_auth/tls.c
index 331370ce1..89e3b528b 100644
--- a/libmu_auth/tls.c
+++ b/libmu_auth/tls.c
@@ -35,15 +35,36 @@
#include <mailutils/errno.h>
#include <mailutils/util.h>
#include <mailutils/property.h>
+#include <mailutils/cli.h>
+
+#define SSL_CERT_FILE_CHECKS (MU_FILE_SAFETY_GROUP_WRITABLE | \
+ MU_FILE_SAFETY_GROUP_WRITABLE | \
+ MU_FILE_SAFETY_LINKED_WRDIR)
+
+#define SSL_KEY_FILE_CHECKS (MU_FILE_SAFETY_ALL & \
+ ~MU_FILE_SAFETY_OWNER_MISMATCH)
+
+#define SSL_CA_FILE_CHECKS (MU_FILE_SAFETY_GROUP_WRITABLE | \
+ MU_FILE_SAFETY_GROUP_WRITABLE | \
+ MU_FILE_SAFETY_LINKED_WRDIR)
struct mu_tls_module_config mu_tls_module_config = {
#ifdef WITH_TLS
- 1 /* enable by default */
+ 1, /* enable by default */
+
+ NULL, /* Certificate file */
+ SSL_CERT_FILE_CHECKS,
+
+ NULL, /* Key file */
+ SSL_KEY_FILE_CHECKS, /* Stringent safety checks for keys */
+
+ NULL, /* CA file */
+ SSL_CA_FILE_CHECKS
#else
0
#endif
};
-
+//FIXME: REMOVE
int
mu_tls_module_init (enum mu_gocs_op op, void *data)
{
@@ -774,8 +795,92 @@ mu_tls_client_stream_create (mu_stream_t *pstream,
_tls_client_open,
strin, strout, flags);
}
+
+static int
+cb2_safety_checks (const char *name, void *data)
+{
+ int defval;
+
+ if (data == &mu_tls_module_config.ssl_key_safety_checks)
+ defval = SSL_KEY_FILE_CHECKS;
+ else if (data == &mu_tls_module_config.ssl_cert_safety_checks)
+ defval = SSL_CERT_FILE_CHECKS;
+ else if (data == &mu_tls_module_config.ssl_cafile_safety_checks)
+ defval = SSL_CA_FILE_CHECKS;
+ else
+ {
+ mu_error (_("INTERNAL ERROR at %s:%d: unknown default value?"),
+ __FILE__, __LINE__);
+ defval = MU_FILE_SAFETY_ALL;
+ }
+ if (mu_file_safety_compose (data, name, defval))
+ mu_error (_("unknown keyword: %s"), name);
+ return 0;
+}
-
+static int
+cb_safety_checks (void *data, mu_config_value_t *arg)
+{
+ return mu_cfg_string_value_cb (arg, cb2_safety_checks, data);
+}
+
+static struct mu_cfg_param mu_tls_param[] = {
+ { "enable", mu_c_bool, &mu_tls_module_config.enable, 0, NULL,
+ N_("Enable TLS encryption.") },
+ { "ssl-cert", mu_c_string, &mu_tls_module_config.ssl_cert, 0, NULL,
+ N_("Specify SSL certificate file."),
+ N_("file") },
+ { "ssl-key", mu_c_string, &mu_tls_module_config.ssl_key, 0, NULL,
+ N_("Specify SSL certificate key file."),
+ N_("file") },
+ { "ssl-cafile", mu_c_string, &mu_tls_module_config.ssl_cafile, 0, NULL,
+ N_("Specify trusted CAs file."),
+ N_("file") },
+ { "ssl-priorities", mu_c_string, &mu_tls_module_config.priorities, 0, NULL,
+ N_("Set the priorities to use on the ciphers, key exchange methods, "
+ "macs and compression methods."),
+ NULL },
+ { "key-file-safety-checks", mu_cfg_callback,
+ &mu_tls_module_config.ssl_key_safety_checks, 0,
+ cb_safety_checks,
+ N_("Configure safety checks for SSL key file. Argument is a list or "
+ "sequence of check names optionally prefixed with '+' to enable or "
+ "'-' to disable the corresponding check. Valid check names are:\n"
+ "\n"
+ " none disable all checks\n"
+ " all enable all checks\n"
+ " gwrfil forbid group writable files\n"
+ " awrfil forbid world writable files\n"
+ " grdfil forbid group readable files\n"
+ " ardfil forbid world writable files\n"
+ " linkwrdir forbid symbolic links in group or world writable directories\n"
+ " gwrdir forbid files in group writable directories\n"
+ " awrdir forbid files in world writable directories\n"),
+ N_("arg: list") },
+ { "cert-file-safety-checks", mu_cfg_callback,
+ &mu_tls_module_config.ssl_cert_safety_checks, 0,
+ cb_safety_checks,
+ N_("Configure safety checks for SSL certificate. See above for a description of <arg>."),
+ N_("arg: list") },
+ { "ca-file-safety-checks", mu_cfg_callback,
+ &mu_tls_module_config.ssl_cafile_safety_checks, 0,
+ cb_safety_checks,
+ N_("Configure safety checks for SSL certificate authority file. See above for a description of <arg>."),
+ N_("arg: list") },
+ { NULL }
+};
+
+struct mu_cli_capa mu_cli_capa_tls = {
+ "tls",
+ NULL,
+ mu_tls_param,
+ NULL, NULL
+};
+#else
+struct mu_cli_capa mu_cli_capa_tls = {
+ "tls",
+ NULL
+};
#endif /* WITH_TLS */
/* EOF */
diff --git a/messages/Makefile.am b/messages/Makefile.am
index d611b2c98..56ff5e72f 100644
--- a/messages/Makefile.am
+++ b/messages/Makefile.am
@@ -22,7 +22,7 @@ SUBDIRS = . tests
bin_PROGRAMS = messages
messages_SOURCES = messages.c
messages_LDADD =\
- ${MU_APP_LIBRARIES}\
+ ${MU_APP_NEW_LIBRARIES}\
${MU_LIB_MBOX}\
${MU_LIB_IMAP}\
${MU_LIB_POP}\
diff --git a/messages/messages.c b/messages/messages.c
index 4f5c614f6..84cf4bf62 100644
--- a/messages/messages.c
+++ b/messages/messages.c
@@ -20,85 +20,44 @@
#endif
#include <stdio.h>
-#ifdef HAVE_MALLOC_H
-# include <malloc.h>
-#endif
#include <mailutils/mailutils.h>
-#include "mailutils/libargp.h"
+#include <mailutils/cli.h>
static int messages_count (const char *);
-static char doc[] = N_("GNU messages -- count the number of messages in a mailbox");
-static char args_doc[] = N_("[mailbox...]");
+/* are we loud or quiet? */
+static int silent = 0;
-static struct argp_option options[] = {
- { NULL, 0, NULL, 0,
- /* TRANSLATORS: 'messages' is a program name. Do not translate it! */
- N_("messages specific switches:"), 0},
- {"quiet", 'q', NULL, 0, N_("only display number of messages")},
- {"silent", 's', NULL, OPTION_ALIAS, NULL },
- { 0 }
+static struct mu_option messages_options[] = {
+ { "quiet", 'q', NULL, MU_OPTION_DEFAULT,
+ N_("only display number of messages"),
+ mu_c_bool, &silent },
+ {"silent", 's', NULL, MU_OPTION_ALIAS },
+ MU_OPTION_END
};
-static const char *argp_capa[] = {
- "mailutils",
- "common",
+static char *capa[] = {
"debug",
"mailbox",
"locking",
+ "tls",
NULL
};
-struct arguments
-{
- int argc;
- char **argv;
-};
+static struct mu_option *options[] = { messages_options, NULL };
-/* are we loud or quiet? */
-static int silent = 0;
-
-static error_t
-parse_opt (int key, char *arg, struct argp_state *state)
-{
- struct arguments *args = state->input;
- switch (key)
- {
- case 'q':
- case 's':
- silent = 1;
- break;
-
- case ARGP_KEY_ARG:
- args->argv = realloc (args->argv,
-