dovecot-2.1: dsync: Fixed handling -u parameter in backwards com...

dovecot at dovecot.org dovecot at dovecot.org
Thu Jan 12 23:09:31 EET 2012


details:   http://hg.dovecot.org/dovecot-2.1/rev/1a722c7676bb
changeset: 13934:1a722c7676bb
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Jan 12 23:09:25 2012 +0200
description:
dsync: Fixed handling -u parameter in backwards compatibility dsync mode.

diffstat:

 src/doveadm/dsync/doveadm-dsync.c |  20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diffs (67 lines):

diff -r 957e74f0d60f -r 1a722c7676bb src/doveadm/dsync/doveadm-dsync.c
--- a/src/doveadm/dsync/doveadm-dsync.c	Thu Jan 12 21:53:31 2012 +0200
+++ b/src/doveadm/dsync/doveadm-dsync.c	Thu Jan 12 23:09:25 2012 +0200
@@ -389,10 +389,10 @@
 	int argc = *_argc;
 	const char *getopt_str;
 	char **argv = *_argv;
-	char **new_argv, *mailbox = NULL, *alt_char = NULL;
+	char **new_argv, *mailbox = NULL, *alt_char = NULL, *username = NULL;
 	char *p, *dup, new_flags[6];
 	int max_argc, src, dest, i, j;
-	bool flag_f = FALSE, flag_R = FALSE, flag_m, flag_C, has_arg;
+	bool flag_f = FALSE, flag_R = FALSE, flag_m, flag_u, flag_C, has_arg;
 	bool backup_flag = FALSE;
 
 	p = strrchr(argv[0], '/');
@@ -402,7 +402,7 @@
 
 	/* @UNSAFE: this is called when the "doveadm" binary is called as
 	   "dsync" (for backwards compatibility) */
-	max_argc = argc + 5;
+	max_argc = argc + 7;
 	new_argv = calloc(sizeof(char *), max_argc);
 	new_argv[0] = argv[0];
 	dest = 1;
@@ -413,7 +413,7 @@
 		if (argv[src][0] != '-')
 			break;
 
-		flag_m = FALSE; flag_C = FALSE; has_arg = FALSE;
+		flag_m = FALSE; flag_C = FALSE; has_arg = FALSE; flag_u = FALSE;
 		dup = strdup(argv[src]);
 		for (i = j = 1; argv[src][i] != '\0'; i++) {
 			switch (argv[src][i]) {
@@ -429,6 +429,9 @@
 			case 'm':
 				flag_m = TRUE;
 				break;
+			case 'u':
+				flag_u = TRUE;
+				break;
 			default:
 				p = strchr(getopt_str, argv[src][i]);
 				if (p != NULL && p[1] == ':')
@@ -448,6 +451,11 @@
 				i_fatal("-m missing parameter");
 			mailbox = argv[++src];
 		}
+		if (flag_u) {
+			if (src+1 == argc)
+				i_fatal("-u missing parameter");
+			username = argv[++src];
+		}
 		if (flag_C) {
 			if (src+1 == argc)
 				i_fatal("-C missing parameter");
@@ -504,6 +512,10 @@
 		if (mailbox != NULL)
 			new_argv[dest++] = mailbox;
 	}
+	if (username != NULL) {
+		new_argv[dest++] = "-u";
+		new_argv[dest++] = username;
+	}
 
 	/* rest of the parameters */
 	for (; src < argc; src++)


More information about the dovecot-cvs mailing list