dovecot-2.0: dovecot: Fixed handling --parameters with some OSes.

dovecot at dovecot.org dovecot at dovecot.org
Thu May 13 13:47:59 EEST 2010


details:   http://hg.dovecot.org/dovecot-2.0/rev/5b628ee2888d
changeset: 11303:5b628ee2888d
user:      Timo Sirainen <tss at iki.fi>
date:      Thu May 13 12:47:56 2010 +0200
description:
dovecot: Fixed handling --parameters with some OSes.

diffstat:

 src/master/main.c |  22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

diffs (62 lines):

diff -r da5096512d54 -r 5b628ee2888d src/master/main.c
--- a/src/master/main.c	Thu May 13 12:47:24 2010 +0200
+++ b/src/master/main.c	Thu May 13 12:47:56 2010 +0200
@@ -635,7 +635,7 @@
 	const char *error, *env_tz, *doveconf_arg = NULL;
 	failure_callback_t *orig_info_callback, *orig_debug_callback;
 	bool foreground = FALSE, ask_key_pass = FALSE, log_error = FALSE;
-	int c, send_signal = 0;
+	int i, c, send_signal = 0;
 
 #ifdef DEBUG
 	if (getenv("GDB") == NULL)
@@ -643,10 +643,18 @@
 	else
 		child_process_env[child_process_env_idx++] = "GDB=1";
 #endif
+	/* drop -- prefix from all --args */
+	for (i = 1; i < argc; i++) {
+		if (strncmp(argv[i], "--", 2) == 0) {
+			if (argv[i][2] == '\0')
+				break;
+			argv[i] += 2;
+		}
+	}
 	master_service = master_service_init(MASTER_SERVICE_NAME,
 				MASTER_SERVICE_FLAG_STANDALONE |
 				MASTER_SERVICE_FLAG_DONT_LOG_TO_STDERR,
-				&argc, &argv, "Fanp-");
+				&argc, &argv, "Fanp");
 	i_set_failure_prefix("");
 
 	io_loop_set_time_moved_callback(current_ioloop, master_time_moved);
@@ -655,8 +663,6 @@
 	master_gid = getegid();
 
 	while ((c = master_getopt(master_service)) > 0) {
-		if (c == '-')
-			break;
 		switch (c) {
 		case 'F':
 			foreground = TRUE;
@@ -694,16 +700,16 @@
 	}
 
 	while (optind < argc) {
-		if (strcmp(argv[optind], "--version") == 0) {
+		if (strcmp(argv[optind], "version") == 0) {
 			printf("%s\n", DOVECOT_VERSION_FULL);
 			return 0;
-		} else if (strcmp(argv[optind], "--build-options") == 0) {
+		} else if (strcmp(argv[optind], "build-options") == 0) {
 			print_build_options();
 			return 0;
-		} else if (strcmp(argv[optind], "--log-error") == 0) {
+		} else if (strcmp(argv[optind], "log-error") == 0) {
 			log_error = TRUE;
 			foreground = TRUE;
-		} else if (strcmp(argv[optind], "--help") == 0) {
+		} else if (strcmp(argv[optind], "help") == 0) {
 			print_help();
 			return 0;
 		} else if (strcmp(argv[optind], "reload") == 0) {


More information about the dovecot-cvs mailing list