Commit 6d490ce1 6d490ce129c98caddf5db5601094497a375f47e7 by Sergey Poznyakoff

* NEWS: Update.

* configure.ac (MU_LIB_REMOTE): New substitution variable.
(AC_CONFIG_FILES): Add libproto/remote/Makefile.
* imap4d/copy.c, imap4d/create.c, imap4d/delete.c, imap4d/fetch.c,
imap4d/imap4d.c, imap4d/list.c, imap4d/lsub.c, imap4d/rename.c,
imap4d/subscribe.c, imap4d/unsubscribe.c, imap4d/util.c: Spelling
fixes.
* include/mailutils/cfg.h (mu_cfg_error_count): New variable.
* include/mailutils/gocs.h (struct mu_gocs_mailbox):  New member
mailbox_pattern
* include/mailutils/libargp.h (mu_rcfile_lint): New variable.
* include/mailutils/mailbox.h (mu_set_mailbox_pattern): New
function.
(mu_mail_directory): Removed.
(mu_mailbox_url): New function.
* include/mailutils/mutil.h (mu_normalize_mailbox_url): Remove.
* include/mailutils/registrar.h (mu_0_6_registrar_lookup): Remove.

* libargp/common.c: New options --rcfile-lint and
--mailbox-pattern.
* libargp/muinit.c: Handle --rcfile-lint.
* libcfg/common.c: New statement mailbox-pattern
* libmu_scm/mu_mailbox.c (mu-mail-directory): Deprecated.
(mu-user-mailbox-url): New function.

* libproto/remote: New directory.
* libproto/remote/folder.c: New file.
* libproto/remote/mbox.c: New file.
* libproto/remote/.cvsignore: New file.

* libproto/Makefile.am (SUBDIRS): Add remote
* libproto/mbox/folder.c, libproto/mbox/url.c: Indentation and
spelling fixes.
* maidag/Makefile.am (maidag_LDADD): Add MU_LIB_REMOTE.
* maidag/maidag.c: Register mu_remote_mbox_record.
* mailbox/cfg_parser.y (mu_cfg_error_count): New variable.
(mu_cfg_format_error,_mu_cfg_vperror): Increment
mu_cfg_error_count.
* mailbox/debug.c (mu_debug_check_level): Do not mask out
inheritance bit.
* mailbox/gocs.c (mu_gocs_mailbox_init): Set mailbox pattern.
* mailbox/mailbox.c (_create_mailbox): Bugfix.
* mailbox/mbx_default.c (mu_set_mailbox_pattern): New finction.
(mu_set_mail_directory): Rewrite.
(user_mailbox_name): Rewrite.
* mailbox/mutil.c (mu_normalize_mailbox_url): Remove.
* mailbox/registrar.c (mu_0_6_registrar_lookup): Remove.
* guimb/scm/sieve-core.scm (sieve-main): Use mu-user-mailbox-url.
1 parent 5a30e7b2
2007-12-19 Sergey Poznyakoff <gray@gnu.org.ua>
* NEWS: Update.
* configure.ac (MU_LIB_REMOTE): New substitution variable.
(AC_CONFIG_FILES): Add libproto/remote/Makefile.
* imap4d/copy.c, imap4d/create.c, imap4d/delete.c, imap4d/fetch.c,
imap4d/imap4d.c, imap4d/list.c, imap4d/lsub.c, imap4d/rename.c,
imap4d/subscribe.c, imap4d/unsubscribe.c, imap4d/util.c: Spelling
fixes.
* include/mailutils/cfg.h (mu_cfg_error_count): New variable.
* include/mailutils/gocs.h (struct mu_gocs_mailbox): New member
mailbox_pattern
* include/mailutils/libargp.h (mu_rcfile_lint): New variable.
* include/mailutils/mailbox.h (mu_set_mailbox_pattern): New
function.
(mu_mail_directory): Removed.
(mu_mailbox_url): New function.
* include/mailutils/mutil.h (mu_normalize_mailbox_url): Remove.
* include/mailutils/registrar.h (mu_0_6_registrar_lookup): Remove.
* libargp/common.c: New options --rcfile-lint and
--mailbox-pattern.
* libargp/muinit.c: Handle --rcfile-lint.
* libcfg/common.c: New statement mailbox-pattern
* libmu_scm/mu_mailbox.c (mu-mail-directory): Deprecated.
(mu-user-mailbox-url): New function.
* libproto/remote: New directory.
* libproto/remote/folder.c: New file.
* libproto/remote/mbox.c: New file.
* libproto/remote/.cvsignore: New file.
* libproto/Makefile.am (SUBDIRS): Add remote
* libproto/mbox/folder.c, libproto/mbox/url.c: Indentation and
spelling fixes.
* maidag/Makefile.am (maidag_LDADD): Add MU_LIB_REMOTE.
* maidag/maidag.c: Register mu_remote_mbox_record.
* mailbox/cfg_parser.y (mu_cfg_error_count): New variable.
(mu_cfg_format_error,_mu_cfg_vperror): Increment
mu_cfg_error_count.
* mailbox/debug.c (mu_debug_check_level): Do not mask out
inheritance bit.
* mailbox/gocs.c (mu_gocs_mailbox_init): Set mailbox pattern.
* mailbox/mailbox.c (_create_mailbox): Bugfix.
* mailbox/mbx_default.c (mu_set_mailbox_pattern): New finction.
(mu_set_mail_directory): Rewrite.
(user_mailbox_name): Rewrite.
* mailbox/mutil.c (mu_normalize_mailbox_url): Remove.
* mailbox/registrar.c (mu_0_6_registrar_lookup): Remove.
* guimb/scm/sieve-core.scm (sieve-main): Use mu-user-mailbox-url.
2007-12-15 Sergey Poznyakoff <gray@gnu.org.ua>
* libcfg/acl.c (getword): Bugfix.
......
GNU mailutils NEWS -- history of user-visible changes. 2007-12-07
GNU mailutils NEWS -- history of user-visible changes. 2007-12-19
Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
See the end of file for copying conditions.
......@@ -30,10 +30,14 @@ affect the given program.
Maidag is a MAIl Delivery AGent. It is a general-purpose MDA able to
run in both traditional and LMTP mode and to deliver mails to various
mailbox formats. It is also able to process incoming messages using
Sieve or Scheme scripts and, based on results of this processing,
to take a decision on whether to actually deliver and where to
deliver them.
mailbox formats. These formats, among others, include remote+smtp and
remote+sendmail (see `New mailbox types.', below), which are
equivalent to forwarding a message over SMTP. Thus, maidag supercedes
both `mail.local' and `mail.remote' (both of which are still included
for backward compatibility). Maidag is also able to process incoming
messages using Sieve or Scheme scripts and, based on results of this
processing, to take a decision on whether to actually deliver and
where to deliver them.
** New Sieve action `pipe'
......@@ -215,6 +219,14 @@ Any mu_url_get_.* accessors return MU_ERR_ENOENT if the corresponding
field is not present in the object. Previous versions in that case
returned 0 and stored empty string in the output buffer.
** New mailbox types.
Two new mailbox types, "remote+smtp" and "remote+sendmail", are
supported. These are `append-only' mailboxes, i.e. the only operation
that can be done over them is mu_mailbox_append_message. E.g.,
appending to the URL `remote+smtp://127.0.0.1:24' is equivalent to
sending a message using mailer `smtp://127.0.0.1:24'.
** Fixed parsing of URLs similar to file:///a/b.
It is parsed as an absolute file name `/a/b'.
......@@ -224,6 +236,10 @@ Previous versions incorrectly understood such an URL as `a/b'
** Remove v0.6 compatibility layer.
** Function mu_mail_directory is removed.
** New function mu_mailbox_url.
Version 1.2:
......
......@@ -41,6 +41,7 @@ AC_SUBST(MU_LIB_MBOX,'${top_builddir}/libproto/mbox/libmu_mbox.la')
AC_SUBST(MU_LIB_MH,'${top_builddir}/libproto/mh/libmu_mh.la')
AC_SUBST(MU_LIB_NNTP,'${top_builddir}/libproto/nntp/libmu_nntp.la')
AC_SUBST(MU_LIB_POP,'${top_builddir}/libproto/pop/libmu_pop.la')
AC_SUBST(MU_LIB_REMOTE,'${top_builddir}/libproto/remote/libmu_remotembox.la')
AC_SUBST(MU_LIB_SIEVE,'${top_builddir}/libsieve/libsieve.la')
AC_SUBST(MU_LIB_SCM,'${top_builddir}/libmu_scm/libmu_scm.la')
AC_SUBST(MU_LIB_CPP,'${top_builddir}/libmu_cpp/libmu_cpp.la')
......@@ -1194,6 +1195,7 @@ AC_CONFIG_FILES([Makefile
libproto/nntp/Makefile
libproto/imap/Makefile
libproto/include/Makefile
libproto/remote/Makefile
libsieve/Makefile
libsieve/extensions/Makefile
libargp/Makefile
......
......@@ -492,7 +492,7 @@
(name (if (and (not (null? (cdr cl)))
(string? (cadr cl)))
(cadr cl)
(string-append (mu-mail-directory) "/"
(mu-user-mailbox-url
(passwd:name (mu-getpwuid (getuid)))))))
(set! sieve-mailbox (mu-mailbox-open name "rw"))
......
......@@ -109,7 +109,7 @@ imap4d_copy0 (char *arg, int isuid, char *resp, size_t resplen)
return RESP_OK;
}
/* Unless it is certain that the destination mailbox can not be created,
/* Unless it is certain that the destination mailbox cannot be created,
the server MUST send the response code "[TRYCREATE]" as the prefix
of the text of the tagged NO response. This gives a hint to the
client that it can attempt a CREATE command and retry the copy if
......
......@@ -71,7 +71,7 @@ imap4d_create (struct imap4d_command *command, char *arg)
name = namespace_getfullpath (name, delim);
if (!name)
return util_finish (command, RESP_NO, "Can not create mailbox");
return util_finish (command, RESP_NO, "Cannot create mailbox");
/* It will fail if the mailbox already exists. */
if (access (name, F_OK) != 0)
......@@ -98,7 +98,7 @@ imap4d_create (struct imap4d_command *command, char *arg)
else
{
rc = RESP_NO;
msg = "Can not create mailbox";
msg = "Cannot create mailbox";
break;
}
}
......@@ -113,7 +113,7 @@ imap4d_create (struct imap4d_command *command, char *arg)
else
{
rc = RESP_NO;
msg = "Can not create mailbox";
msg = "Cannot create mailbox";
}
}
}
......
......@@ -44,12 +44,12 @@ imap4d_delete (struct imap4d_command *command, char *arg)
/* Allocates memory. */
name = namespace_getfullpath (name, delim);
if (!name)
return util_finish (command, RESP_NO, "Can not remove");
return util_finish (command, RESP_NO, "Cannot remove");
if (remove (name) != 0)
{
rc = RESP_NO;
msg = "Can not remove";
msg = "Cannot remove";
}
free (name);
return util_finish (command, rc, msg);
......
......@@ -1031,7 +1031,7 @@ fetch_operation (mu_message_t msg, char **arg, int silent)
{
if (!silent)
{
/* NOTE: We violate the RFC here: Header can not take a prefix for
/* NOTE: We violate the RFC here: Header cannot take a prefix for
section messages it only referes to the RFC822 header .. ok
see it as an extension. But according to IMAP4 we should
have send an empty string: util_send (" \"\"");
......
......@@ -59,9 +59,10 @@ size_t children;
const char *program_version = "imap4d (" PACKAGE_STRING ")";
static char doc[] = N_("GNU imap4d -- the IMAP4D daemon");
#define ARG_LOGIN_DISABLED 1
#define ARG_TLS_REQUIRED 2
#define ARG_CREATE_HOME_DIR 3
#define ARG_LOGIN_DISABLED 256
#define ARG_TLS_REQUIRED 257
#define ARG_CREATE_HOME_DIR 258
#define ARG_OPTION_PREAUTH 259
static struct argp_option options[] = {
{"other-namespace", 'O', N_("PATHLIST"), OPTION_HIDDEN,
......@@ -73,6 +74,8 @@ static struct argp_option options[] = {
{"create-home-dir", ARG_CREATE_HOME_DIR, N_("MODE"),
OPTION_ARG_OPTIONAL|OPTION_HIDDEN,
N_("Create home directory, if it does not exist")},
{"preauth", ARG_OPTION_PREAUTH, NULL, 0,
N_("Start in preauth mode") },
#ifdef WITH_TLS
{"tls-required", ARG_TLS_REQUIRED, NULL, OPTION_HIDDEN,
N_("Always require STARTTLS before entering authentication phase")},
......@@ -140,6 +143,10 @@ imap4d_parse_opt (int key, char *arg, struct argp_state *state)
break;
#endif
case ARG_OPTION_PREAUTH:
preauth_mode = preauth_stdio;
break;
case ARGP_KEY_INIT:
mu_argp_node_list_init (&lst);
break;
......
......@@ -36,7 +36,7 @@ struct inode_list
};
/*
1- IMAP4 insists: the reference argument that is include in the
1- IMAP4 insists: the reference argument present in the
interpreted form SHOULD prefix the interpreted form. It SHOULD
also be in the same form as the reference name argument. This
rule permits the client to determine if the returned mailbox name
......@@ -52,7 +52,7 @@ struct inode_list
2- The character "*" is a wildcard, and matches zero or more characters
at this position. The charcater "%" is similar to "*",
but it does not match ahierarchy delimiter. */
but it does not match a hierarchy delimiter. */
static int match (const char *, const char *, const char *);
static void list_file (const char *, const char *, const char *, const char *, struct inode_list *);
......
......@@ -74,5 +74,5 @@ imap4d_lsub (struct imap4d_command *command, char *arg)
}
else if (errno == ENOENT)
return util_finish (command, RESP_OK, "Completed");
return util_finish (command, RESP_NO, "Can not list subscriber");
return util_finish (command, RESP_NO, "Cannot list subscriber");
}
......
......@@ -75,7 +75,7 @@ imap4d_rename (struct imap4d_command *command, char *arg)
if (S_ISDIR(newst.st_mode))
{
free (newname);
return util_finish (command, RESP_NO, "Can not be a directory");
return util_finish (command, RESP_NO, "Cannot be a directory");
}
name = calloc (strlen ("mbox:") + strlen (newname) + 1, 1);
sprintf (name, "mbox:%s", newname);
......@@ -84,7 +84,7 @@ imap4d_rename (struct imap4d_command *command, char *arg)
{
free (name);
free (newname);
return util_finish (command, RESP_NO, "Can not create new mailbox");
return util_finish (command, RESP_NO, "Cannot create new mailbox");
}
free (name);
free (newname);
......
......@@ -45,5 +45,5 @@ imap4d_subscribe (struct imap4d_command *command, char *arg)
fclose (fp);
return util_finish (command, RESP_OK, "Completed");
}
return util_finish (command, RESP_NO, "Can not subscribe");
return util_finish (command, RESP_NO, "Cannot subscribe");
}
......
......@@ -112,7 +112,7 @@ imap4d_unsubscribe (struct imap4d_command *command, char *arg)
free (file);
if (rc)
return util_finish (command, RESP_NO, "Can not unsubscribe");
return util_finish (command, RESP_NO, "Cannot unsubscribe");
return util_finish (command, RESP_OK, "Completed");
}
......
......@@ -26,7 +26,7 @@ static int add2set (size_t **, int *, unsigned long);
static const char *sc2string (int);
/* Get the next space/CR/NL separated word, some words are between double
quotes, strtok() can not handle it. */
quotes, strtok() cannot handle it. */
char *
util_getword (char *s, char **save)
{
......
......@@ -231,6 +231,7 @@ int mu_parse_config (const char *file, const char *progname,
int mu_cfg_parse_boolean (const char *str, int *res);
extern int mu_cfg_parser_verbose;
extern size_t mu_cfg_error_count;
void mu_cfg_format_docstring (mu_stream_t stream, const char *docstring,
int level);
......
......@@ -52,6 +52,7 @@ struct mu_gocs_debug
struct mu_gocs_mailbox
{
char *mail_spool;
char *mailbox_pattern;
char *mailbox_type;
};
......
......@@ -43,6 +43,7 @@ struct mu_cmdline_capa
};
extern int mu_help_config_mode;
extern int mu_rcfile_lint;
extern struct mu_cmdline_capa mu_common_cmdline;
extern struct mu_cmdline_capa mu_logging_cmdline;
......
......@@ -29,8 +29,9 @@ extern "C" {
#endif
int mu_set_mail_directory (const char *p);
int mu_set_mailbox_pattern (const char *pat);
void mu_set_folder_directory (const char *p);
const char *mu_mail_directory (void);
const char *mu_mailbox_url (void);
const char *mu_folder_directory (void);
int mu_construct_user_mailbox_url (char **pout, const char *name);
......
......@@ -97,7 +97,6 @@ extern int mu_get_user_email_domain (const char** domain);
extern char *mu_get_user_email (const char *name);
extern char *mu_normalize_path (char *path, const char *delim);
extern int mu_normalize_mailbox_url (char **out, const char *dir);
extern int mu_tempfile (const char *tmpdir, char **namep);
extern char *mu_tempname (const char *tmpdir);
......
......@@ -51,8 +51,6 @@ extern int mu_registrar_get_list (mu_list_t *) __attribute__ ((deprecated));
extern int mu_registrar_lookup (const char *name, int flags,
mu_record_t *precord, int *pflags);
extern int mu_0_6_registrar_lookup (const char *name, mu_record_t *precord,
int flags);
extern int mu_registrar_record (mu_record_t);
extern int mu_unregistrar_record (mu_record_t);
......@@ -103,6 +101,8 @@ extern mu_record_t mu_path_record;
extern mu_record_t mu_mh_record;
/* Maildir, "maildir:" */
extern mu_record_t mu_maildir_record;
/* Remote mailbox */
extern mu_record_t mu_remote_mbox_record;
#define MU_IMAP_PRIO 100
#define MU_POP_PRIO 200
......@@ -112,6 +112,7 @@ extern mu_record_t mu_maildir_record;
#define MU_NNTP_PRIO 600
#define MU_PATH_PRIO 1000
#define MU_REMOTE_MBOX_PRIO 10000
#define MU_SMTP_PRIO 10000
#define MU_SENDMAIL_PRIO 10000
......
......@@ -34,6 +34,7 @@ enum {
OPT_NO_USER_RCFILE,
OPT_NO_SITE_RCFILE,
OPT_RCFILE,
OPT_RCFILE_LINT,
OPT_RCFILE_VERBOSE,
OPT_LOG_FACILITY,
OPT_LOCK_FLAGS,
......@@ -42,6 +43,7 @@ enum {
OPT_LOCK_EXPIRE_TIMEOUT,
OPT_LOCK_EXTERNAL_PROGRAM,
OPT_LICENSE,
OPT_MAILBOX_PATTERN,
OPT_MAILBOX_TYPE,
OPT_DEBUG_LEVEL,
OPT_LINE_INFO,
......@@ -63,6 +65,8 @@ static struct argp_option mu_common_argp_options[] =
N_("Load this configuration file"), 0, },
{ "rcfile-verbose", OPT_RCFILE_VERBOSE, NULL, 0,
N_("Verbosely log parsing of the configuration files"), 0 },
{ "rcfile-lint", OPT_RCFILE_LINT, NULL, 0,
N_("Check configuration file syntax and exit"), 0 },
{ NULL, 0, NULL, 0, NULL, 0 }
};
......@@ -87,6 +91,11 @@ mu_common_argp_parser (int key, char *arg, struct argp_state *state)
mu_load_rcfile = arg;
break;
case OPT_RCFILE_LINT:
mu_cfg_parser_verbose++;
mu_rcfile_lint = 1;
break;
case OPT_RCFILE_VERBOSE:
mu_cfg_parser_verbose++;
break;
......@@ -222,6 +231,8 @@ struct mu_cmdline_capa mu_license_cmdline = {
static struct argp_option mu_mailbox_argp_option[] = {
{ "mail-spool", 'm', N_("URL"), OPTION_HIDDEN,
N_("Use specified URL as a mailspool directory"), 0 },
{ "mailbox-pattern", OPT_MAILBOX_PATTERN, N_("pat"), OPTION_HIDDEN,
"", 0 },
{ "mailbox-type", OPT_MAILBOX_TYPE, N_("PROTO"), OPTION_HIDDEN,
N_("Default mailbox type to use"), 0 },
{ NULL }
......@@ -239,6 +250,10 @@ mu_mailbox_argp_parser (int key, char *arg, struct argp_state *state)
mu_argp_node_list_new (&lst, "mail-spool", arg);
break;
case OPT_MAILBOX_PATTERN:
mu_argp_node_list_new (&lst, "mailbox-pattern", arg);
break;
case OPT_MAILBOX_TYPE:
mu_argp_node_list_new (&lst, "mailbox-type", arg);
break;
......
......@@ -49,6 +49,7 @@ get_canonical_name ()
}
int mu_help_config_mode;
int mu_rcfile_lint;
int
mu_app_init (struct argp *myargp, const char **capa,
......@@ -115,6 +116,8 @@ mu_app_init (struct argp *myargp, const char **capa,
cfgflags |= MU_PARSE_CONFIG_DUMP;
rc = mu_cfg_tree_reduce (mu_argp_tree, mu_program_name, cfg_param,
cfgflags, data);
if (mu_rcfile_lint)
exit ((rc || mu_cfg_error_count) ? 1 : 0);
mu_gocs_flush ();
mu_cfg_destroy_tree (&mu_argp_tree);
......
......@@ -43,6 +43,10 @@ static struct mu_cfg_param mu_mailbox_param[] = {
{ "mail-spool", mu_cfg_string, &mailbox_settings.mail_spool, 0, NULL,
N_("Use specified URL as a mailspool directory."),
N_("url") },
{ "mailbox-pattern", mu_cfg_string, &mailbox_settings.mailbox_pattern,
0, NULL,
N_("Create mailbox URL using <pattern>."),
N_("pattern") },
{ "mailbox-type", mu_cfg_string, &mailbox_settings.mailbox_type, 0, NULL,
N_("Default mailbox type."), N_("protocol") },
{ NULL }
......
......@@ -106,16 +106,34 @@ mu_scm_is_mailbox (SCM scm)
SCM_DEFINE (scm_mu_mail_directory, "mu-mail-directory", 0, 1, 0,
(SCM URL),
"If URL is given, sets it as a name of the user's mail directory.\n"
"Returns the current value of the mail directory.")
"Do not use this function. Use mu-user-mailbox-url instead.")
#define FUNC_NAME s_scm_mu_mail_directory
{
if (!SCM_UNBNDP (URL))
{
SCM_ASSERT (scm_is_string (URL), URL, SCM_ARG1, FUNC_NAME);
mu_set_mail_directory (scm_i_string_chars (URL));
}
return scm_makfrom0str (mu_mail_directory ());
mu_scm_error (FUNC_NAME, ENOSYS,
"This function is deprecated. Use mu-user-mailbox-url instead.",
scm_list_1 (URL));
return SCM_EOL;
}
#undef FUNC_NAME
SCM_DEFINE (scm_mu_user_mailbox_url, "mu-user-mailbox-url", 1, 0, 0,
(SCM USER),
"")
#define FUNC_NAME s_scm_mu_user_mailbox_url
{
int rc;
char *p;
SCM ret;
SCM_ASSERT (scm_is_string (USER), USER, SCM_ARG1, FUNC_NAME);
rc = mu_construct_user_mailbox_url (&p, scm_i_string_chars (USER));
if (rc)
mu_scm_error (FUNC_NAME, rc,
"Cannot construct mailbox URL for ~A",
scm_list_1 (USER));
ret = scm_makfrom0str (p);
free (p);
return ret;
}
#undef FUNC_NAME
......
......@@ -17,5 +17,5 @@
## Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301 USA
SUBDIRS = include mbox pop nntp imap mh maildir mailer
SUBDIRS = include mbox pop nntp imap mh maildir mailer remote
......
......@@ -114,8 +114,7 @@ static int folder_mbox_close (mu_folder_t);
static int folder_mbox_delete (mu_folder_t, const char *);
static int folder_mbox_rename (mu_folder_t , const char *, const char *);
static int folder_mbox_list (mu_folder_t, const char *, const char *,
size_t,
mu_list_t);
size_t, mu_list_t);
static int folder_mbox_subscribe (mu_folder_t, const char *);
static int folder_mbox_unsubscribe (mu_folder_t, const char *);
static int folder_mbox_lsub (mu_folder_t, const char *, const char *,
......@@ -380,9 +379,9 @@ list_helper (struct search_data *data,
return status;
}
/* The listing is not recursif and we use glob() some expansion for us.
/* The listing is not recursive and we use glob() some expansion for us.
Unfortunately glob() does not expand the '~'. We also return
The full pathname so it can be use to create other folders. */
the full pathname so it can be use to create other folders. */
static int
folder_mbox_list (mu_folder_t folder, const char *dirname, const char *pattern,
size_t max_level,
......
......@@ -178,7 +178,7 @@ _url_mbox_init (mu_url_t url)
/* reject the obvious */
if (name == NULL || strncmp (MU_MBOX_SCHEME, name, MU_MBOX_SCHEME_LEN) != 0
|| len < (MU_MBOX_SCHEME_LEN + 1) /* (scheme)+1(path)*/)
|| len < (MU_MBOX_SCHEME_LEN + 1) /* (scheme)+1+(path)*/)
return EINVAL;
/* do I need to decode url encoding '% hex hex' ? */
......
*.la
*.lo
.deps
.libs
Makefile
Makefile.in
T
_*
.gdbinit
## Process this file with GNU Automake to create Makefile.in
## Copyright (C) 2007 Free Software Foundation, Inc.
##
## GNU Mailutils is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 3, or (at
## your option) any later version.
##
## This program is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301 USA
INCLUDES = @MU_COMMON_INCLUDES@ -I${top_srcdir}/libproto/include
lib_LTLIBRARIES = libmu_remotembox.la
libmu_remotembox_la_LDFLAGS=-version-info @VI_CURRENT@:@VI_REVISION@:@VI_AGE@
libmu_remotembox_la_LIBADD = ${MU_LIB_MAILUTILS} ${MU_LIB_MAILER}
libmu_remotembox_la_SOURCES = \
folder.c\
mbox.c
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2007 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <mailutils/errno.h>
#include <mailutils/error.h>
#include <mailutils/url.h>
#include <mailbox0.h>
#include <url0.h>
#include <folder0.h>
#include <registrar0.h>
#define MU_REMOTE_MBOX_PREFIX "remote+"
#define MU_REMOTE_MBOX_PREFIX_LEN (sizeof (MU_REMOTE_MBOX_PREFIX) - 1)
extern int remote_mbox_init (mu_mailbox_t mailbox);
int
remote_url_init (mu_url_t url)
{
const char *name = mu_url_to_string (url);
const char *p;
size_t len = strlen (name);
int rc;
if (!name)
return 0;
/* reject the obvious */
if (name == NULL
|| len < MU_REMOTE_MBOX_PREFIX_LEN
|| strncmp (MU_REMOTE_MBOX_PREFIX, name, MU_REMOTE_MBOX_PREFIX_LEN) != 0)
return EINVAL;
rc = mu_registrar_lookup (name + MU_REMOTE_MBOX_PREFIX_LEN, 0, NULL, NULL);
if (rc)
return rc;
p = strchr (name, ':');
if (!p)
return EINVAL;
p++;
len = p - name;
url->scheme = malloc (len + 1);
if (!url->scheme)
return ENOMEM;
memcpy (url->scheme, name, len);
url->scheme[len] = 0;
return 0;
}
static int
remote_folder_init (mu_folder_t folder MU_ARG_UNUSED)
{
return 0;
}
static struct _mu_record _remote_mbox_record =
{
MU_REMOTE_MBOX_PRIO,
MU_REMOTE_MBOX_PREFIX,
remote_url_init, /* Mailbox init. */
remote_mbox_init, /* Mailbox init. */
NULL, /* Mailer init. */
remote_folder_init, /* Folder init. */
NULL, /* No need for back pointer. */
NULL, /* _is_scheme method. */
NULL, /* _get_url method. */
NULL, /* _get_mailbox method. */
NULL, /* _get_mailer method. */
NULL /* _get_folder method. */
};
mu_record_t mu_remote_mbox_record = &_remote_mbox_record;
/* GNU Mailutils -- a suite of utilities for electronic mail
Copyright (C) 2007 Free Software Foundation, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301 USA */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <mailutils/address.h>
#include <mailutils/debug.h>
#include <mailutils/errno.h>
#include <mailutils/error.h>
#include <mailutils/property.h>
#include <mailutils/mailer.h>
#include <mailutils/url.h>
#include <mailbox0.h>
struct remote_mbox_data
{
mu_mailer_t mailer;
};
static void
remote_mbox_destroy (mu_mailbox_t mailbox)
{
if (mailbox->data)
{
struct remote_mbox_data *dat = mailbox->data;
mu_mailer_destroy (&dat->mailer);
free (dat);
mailbox->data = NULL;
}
}
static int
remote_mbox_open (mu_mailbox_t mbox, int flags)
{
struct remote_mbox_data *dat = mbox->data;
int status;
int mflags = 0;
mu_log_level_t lev = 0;
if (!dat->mailer)
return EINVAL;
mu_debug_get_level (mbox->debug, &lev);
if (lev & MU_DEBUG_TRACE7)
mflags = MAILER_FLAG_DEBUG_DATA;
status = mu_mailer_open (dat->mailer, mflags);
if (status)
{
MU_DEBUG1 (mbox->debug, MU_DEBUG_ERROR,
"cannot open mailer: %s\n", mu_strerror (status));
return status;
}
if (lev & MU_DEBUG_INHERIT)
{
mu_debug_t debug;
if (mu_mailer_get_debug (dat->mailer, &debug) == 0)
mu_debug_set_level (debug, lev);
}
mbox->flags = flags;
return 0;
}
static int
remote_mbox_close (mu_mailbox_t mbox)
{
struct remote_mbox_data *dat = mbox->data;
int status;
MU_DEBUG (mbox->debug, MU_DEBUG_TRACE1, "remote_mbox_close\n");
status = mu_mailer_close (dat->mailer);
if (status)
MU_DEBUG1 (mbox->debug, MU_DEBUG_ERROR, "closing mailer failed: %s\n",
mu_strerror (status));
return status;
}
static int
mkaddr (mu_mailbox_t mbox, mu_property_t property,
const char *key, mu_address_t *addr)
{
const char *str = NULL;
mu_property_sget_value (property, key, &str);
if (str && *str)
{
int status = mu_address_create (addr, str);
if (status)
{
MU_DEBUG3 (mbox->debug, MU_DEBUG_ERROR,
"%s: %s mu_address_create failed: %s\n",
str, key, mu_strerror (status));
return status;
}
}
else
*addr = NULL;
return 0;
}
static int
remote_mbox_append_message (mu_mailbox_t mbox, mu_message_t msg)
{
struct remote_mbox_data *dat = mbox->data;
int status;
mu_property_t property = NULL;
mu_address_t from, to;
if (!dat->mailer)
return EINVAL;
status = mu_mailbox_get_property (mbox, &property);
if (status)
MU_DEBUG1 (mbox->debug, MU_DEBUG_ERROR, "failed to get property: %s\n",
mu_strerror (status));
mkaddr (mbox, property, "FROM", &from);
mkaddr (mbox, property, "TO", &to);
status = mu_mailer_send_message (dat->mailer, msg, from, to);
if (status)
MU_DEBUG1 (mbox->debug, MU_DEBUG_ERROR,
"Sending message failed: %s\n", mu_strerror (status));
return status;
}
static int
remote_mbox_scan (mu_mailbox_t mbox, size_t offset, size_t *pcount)
{
if (pcount)
*pcount = 0;
return 0;
}
static int
remote_get_size (mu_mailbox_t mbox, mu_off_t *psize)
{
if (psize)
*psize = 0;
return 0;
}
static int
remote_sync (mu_mailbox_t mbox)
{
return 0;
}
int
remote_mbox_init (mu_mailbox_t mailbox)
{
struct remote_mbox_data *dat;
const char *s, *p;
int rc;
mu_mailer_t mailer;
if (mailbox == NULL)
return EINVAL;
s = mu_url_to_string (mailbox->url);
if (rc)
{
MU_DEBUG1 (mailbox->debug, MU_DEBUG_ERROR,
"remote_mbox_init: cannot get url: %s\n", mu_strerror (rc));
return rc;
}
MU_DEBUG1 (mailbox->debug, MU_DEBUG_TRACE1, "remote_mbox_init (%s)\n", s);
p = strchr (s, '+');
if (!p)
{
MU_DEBUG2 (mailbox->debug, MU_DEBUG_ERROR,
"remote_mbox_init(%s): invalid url: %s\n", s,
mu_strerror (rc));
return MU_ERR_MAILER_BAD_URL;
}
p++;
rc = mu_mailer_create (&mailer, p);
if (rc)
{
MU_DEBUG2 (mailbox->debug, MU_DEBUG_ERROR,
"remote_mbox_init(%s): cannot create mailer: %s\n",
s, mu_strerror (rc));
return rc;
}
dat = mailbox->data = calloc (1, sizeof (*dat));
if (dat == NULL)
{
mu_mailer_destroy (&mailer);
return ENOMEM;
}
dat->mailer = mailer;
mailbox->_destroy = remote_mbox_destroy;
mailbox->_open = remote_mbox_open;
mailbox->_close = remote_mbox_close;
mailbox->_append_message = remote_mbox_append_message;
mailbox->_scan = remote_mbox_scan;
mailbox->_get_size = remote_get_size;
mailbox->_sync = remote_sync;
return 0;
}
......@@ -41,6 +41,7 @@ maidag_LDADD = \
${MU_LIB_MAILDIR}\
${MU_LIB_AUTH}\
${MU_LIB_MAILER}\
${MU_LIB_REMOTE}\
@MU_AUTHLIBS@\
${MU_LIB_MAILUTILS} \
@MU_COMMON_LIBRARIES@\
......
......@@ -449,13 +449,13 @@ main (int argc, char *argv[])
/* Register needed modules */
MU_AUTH_REGISTER_ALL_MODULES ();
/* Register mailbox formats */
/* Register all supported mailbox and mailer formats */
mu_register_all_formats ();
/* Register the supported mailers. */
mu_registrar_record (mu_sendmail_record);
mu_registrar_record (mu_smtp_record);
/* Register a special mailbox */
mu_registrar_record (mu_remote_mbox_record);
mu_gocs_register ("sieve", mu_sieve_module_init);
mu_gocs_daemon = daemon_param;
......
......@@ -36,6 +36,7 @@ int mu_cfg_parser_verbose;
static mu_cfg_node_t *parse_tree;
mu_cfg_locus_t mu_cfg_locus;
int mu_cfg_tie_in;
size_t mu_cfg_error_count;
static int _mu_cfg_errcnt;
static mu_cfg_lexer_t _mu_cfg_lexer;
......@@ -100,6 +101,7 @@ mu_cfg_format_error (mu_debug_t debug, size_t level, const char *fmt, ...)
mu_debug_vprintf (debug, 0, fmt, ap);
mu_debug_printf (debug, 0, "\n");
va_end (ap);
mu_cfg_error_count++;
}
static void
......@@ -114,6 +116,7 @@ _mu_cfg_vperror (mu_debug_t debug, const mu_cfg_locus_t *loc,
mu_debug_vprintf (debug, 0, fmt, ap);
mu_debug_printf (debug, 0, "\n");
mu_debug_set_locus (debug, NULL, 0);
mu_cfg_error_count++;
}
static void
......
......@@ -252,7 +252,7 @@ mu_debug_check_level (mu_debug_t debug, mu_log_level_t level)
{
if (!debug)
return 0;
return debug->level & MU_DEBUG_LEVEL_MASK (level);
return debug->level & level;
}
int
......
......@@ -61,7 +61,15 @@ mu_gocs_mailbox_init (void *data)
free (p->mail_spool);
p->mail_spool = NULL;
}
if (p->mailbox_pattern)
{
rc = mu_set_mailbox_pattern (p->mailbox_pattern);
if (rc)
mu_error (_("Cannot set mailbox pattern to `%s': %s"),
p->mailbox_pattern, mu_strerror (rc));
free (p->mailbox_pattern);
p->mailbox_pattern = NULL;
}
if (p->mailbox_type)
{
if (mu_mailbox_set_default_proto (p->mailbox_type))
......
......@@ -137,6 +137,7 @@ _create_mailbox (mu_mailbox_t *pmbox, const char *name)
if (status != 0)
mu_mailbox_destroy (&mbox);
else
{
*pmbox = mbox;
level = mu_global_debug_level ("mailbox");
......@@ -145,12 +146,13 @@ _create_mailbox (mu_mailbox_t *pmbox, const char *name)
int status = mu_debug_create (&mbox->debug, mbox);
if (status)
return 0; /* FIXME: don't want to bail out just because I
failed to create a *debug* object. But maybe
I'm wrong... */
failed to create a *debug* object. But I may
be wrong... */
mu_debug_set_level (mbox->debug, level);
if (level & MU_DEBUG_INHERIT)
mu_folder_set_debug (mbox->folder, mbox->debug);
}
}
return status;
}
......
......@@ -37,18 +37,61 @@
#include <mailutils/error.h>
#include <mailutils/errno.h>
#include <mailutils/mu_auth.h>
#include <mailutils/vartab.h>
static char *_mu_mailbox_pattern;
static char *_default_mail_dir = MU_PATH_MAILDIR;
static char *_mu_mail_dir;
static char *_default_folder_dir = "Mail";
static char *_mu_folder_dir;
static int
mu_normalize_mailbox_url (char **pout, const char *dir)
{
int len;
int addslash = 0;
#define USERSUFFIX "${user}"
if (!pout)
return MU_ERR_OUT_PTR_NULL;
len = strlen (dir);
if (strncasecmp (dir, "mbox:", 5) == 0 && dir[len-1] == '=')
{
if (len > 5 && strcmp (dir + len - 5, "user=") == 0)
*pout = strdup (dir);
else
return MU_ERR_BAD_FILENAME;
}
else if (dir[len-1] != '/')
addslash = 1;
*pout = malloc (strlen (dir) + (addslash ? 1 : 0) + sizeof USERSUFFIX);
if (!*pout)
return ENOMEM;
strcpy (*pout, dir);
if (addslash)
strcat (*pout, "/");
strcat (*pout, USERSUFFIX);
#undef USERSUFFIX
return 0;
}
int
mu_set_mail_directory (const char *p)
{
if (_mu_mail_dir != _default_mail_dir)
free (_mu_mail_dir);
return mu_normalize_mailbox_url (&_mu_mail_dir, p);
if (_mu_mailbox_pattern)
free (_mu_mailbox_pattern);
return mu_normalize_mailbox_url (&_mu_mailbox_pattern, p);
}
int
mu_set_mailbox_pattern (const char *pat)
{
if (_mu_mailbox_pattern)
free (_mu_mailbox_pattern);
_mu_mailbox_pattern = strdup (pat);
return _mu_mailbox_pattern ? 0 : ENOMEM;
}
void
......@@ -60,11 +103,11 @@ mu_set_folder_directory (const char *p)
}
const char *
mu_mail_directory ()
mu_mailbox_url ()
{
if (!_mu_mail_dir)
_mu_mail_dir = _default_mail_dir;
return _mu_mail_dir;
if (!_mu_mailbox_pattern)
mu_set_mail_directory (MU_PATH_MAILDIR);
return _mu_mailbox_pattern;
}
const char *
......@@ -78,12 +121,15 @@ mu_folder_directory ()
int
mu_construct_user_mailbox_url (char **pout, const char *name)
{
const char *p = mu_mail_directory ();
*pout = malloc (strlen (p) + strlen (name) + 1);
if (!*pout)
return errno;
strcat (strcpy (*pout, p), name);
return 0;
int rc;
const char *pat = mu_mailbox_url ();
mu_vartab_t vtab;
mu_vartab_create (&vtab);
mu_vartab_define (vtab, "user", name, 1);
rc = mu_vartab_expand (vtab, pat, pout);
mu_vartab_destroy (&vtab);
return rc;
}
/* Is this a security risk? */
......@@ -177,16 +223,6 @@ get_homedir (const char *user)
static int
user_mailbox_name (const char *user, char **mailbox_name)
{
char *p;
const char *url = mu_mail_directory ();
p = strchr (url, ':');
if (p && strncmp (url, "mbox", p - url))
{
*mailbox_name = strdup (url);
return 0;
}
#ifdef USE_ENVIRON
if (!user)
user = (getenv ("LOGNAME")) ? getenv ("LOGNAME") : getenv ("USER");
......@@ -204,7 +240,7 @@ user_mailbox_name (const char *user, char **mailbox_name)
if (!auth)
{
mu_error ("Who am I ?\n");
mu_error ("Who am I?");
return EINVAL;
}
*mailbox_name = strdup (auth->mailbox);
......
......@@ -552,35 +552,6 @@ mu_normalize_path (char *path, const char *delim)
return path;
}
int
mu_normalize_mailbox_url (char **pout, const char *dir)
{
int len;
if (!pout)
return MU_ERR_OUT_PTR_NULL;
len = strlen (dir);
if (dir[len-1] == '/')
*pout = strdup (dir);
else if (strncasecmp (dir, "mbox:", 5) == 0 && dir[len-1] == '=')
{
if (len > 5 && strcmp (dir + len - 5, "user=") == 0)
*pout = strdup (dir);
else
return MU_ERR_BAD_FILENAME;
}
else
{
*pout = malloc (strlen (dir) + 2);
if (*pout)
strcat (strcpy (*pout, dir), "/");
}
/* Final check */
return (*pout == NULL) ? errno : 0;
}
/* Create and open a temporary file. Be very careful about it, since we
may be running with extra privilege i.e setgid().
Returns file descriptor of the open file.
......
......@@ -118,15 +118,6 @@ mu_registrar_lookup (const char *name, int flags,
return status;
}
/* For compatibility with earlier versions */
int
mu_0_6_registrar_lookup (const char *name, mu_record_t *precord, int flags)
{
int status = mu_registrar_lookup (name, flags, precord, &flags);
return (status == 0) ? flags : 0;
}
static int
_compare_prio (const void *item, const void *value)
{
......