[dovecot-cvs] dovecot/src/deliver deliver.c,1.20.2.33,1.20.2.34
tss at dovecot.org
tss at dovecot.org
Sat Mar 17 14:07:38 EET 2007
Update of /var/lib/cvs/dovecot/src/deliver
In directory talvi:/tmp/cvs-serv30321
Modified Files:
Tag: branch_1_0
deliver.c
Log Message:
Ignore -m "" parameter. Added -n option to not autocreate the mailbox. If
saving to given mailbox fails, fallback to saving to INBOX.
Index: deliver.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/deliver/deliver.c,v
retrieving revision 1.20.2.33
retrieving revision 1.20.2.34
diff -u -d -r1.20.2.33 -r1.20.2.34
--- deliver.c 15 Mar 2007 15:52:55 -0000 1.20.2.33
+++ deliver.c 17 Mar 2007 12:07:35 -0000 1.20.2.34
@@ -50,6 +50,7 @@
/* FIXME: these two should be in some context struct instead of as globals.. */
static const char *default_mailbox_name = NULL;
static bool tried_default_save = FALSE;
+static bool no_mailbox_autocreate = FALSE;
static struct module *modules;
static struct ioloop *ioloop;
@@ -83,7 +84,7 @@
box = mailbox_open(storage, name, NULL, MAILBOX_OPEN_FAST |
MAILBOX_OPEN_KEEP_RECENT);
- if (box != NULL)
+ if (box != NULL || no_mailbox_autocreate)
return box;
(void)mail_storage_get_last_error(storage, &syntax, &temp);
@@ -450,7 +451,7 @@
{
printf(
"Usage: deliver [-c <config file>] [-d <destination user>] [-m <mailbox>]\n"
-" [-f <envelope sender>]\n");
+" [-n] [-f <envelope sender>]\n");
}
int main(int argc, char *argv[])
@@ -517,7 +518,13 @@
i_fatal_status(EX_USAGE,
"Missing mailbox argument");
}
- mailbox = argv[i];
+ /* Ignore -m "". This allows doing -m ${extension}
+ in Postfix to handle user+mailbox */
+ if (*argv[i] != '\0')
+ mailbox = argv[i];
+ } else if (strcmp(argv[i], "-n") == 0) {
+ /* destination mailbox */
+ no_mailbox_autocreate = TRUE;
} else if (strcmp(argv[i], "-f") == 0) {
/* envelope sender address */
i++;
@@ -675,6 +682,12 @@
/* plugins didn't handle this. save into the default mailbox. */
i_stream_seek(input, 0);
ret = deliver_save(storage, mailbox, mail, 0, NULL);
+ if (ret < 0 && strcasecmp(mailbox, "INBOX") != 0) {
+ /* still didn't work. try once more to save it
+ to INBOX. */
+ i_stream_seek(input, 0);
+ ret = deliver_save(storage, "INBOX", mail, 0, NULL);
+ }
}
if (ret < 0) {
More information about the dovecot-cvs
mailing list