diff src/master/main.c @ 9528:142c935e44d6 HEAD

dovecot -a|-n: Log a warning if Dovecot was last started using a different config file.
author Timo Sirainen <tss@iki.fi>
date Fri, 22 Jan 2010 18:58:51 +0200
parents 0f04c7da33f1
children 3237519b73f4
line wrap: on
line diff
--- a/src/master/main.c	Fri Jan 22 17:06:57 2010 +0200
+++ b/src/master/main.c	Fri Jan 22 18:58:51 2010 +0200
@@ -193,7 +193,7 @@
 	/* see if hostname changed */
 	hostpid_init();
 
-	if (!master_settings_read(configfile, FALSE, FALSE))
+	if (!master_settings_read(configfile, FALSE, FALSE, FALSE))
 		i_warning("Invalid configuration, keeping old one");
 	else {
 		if (!IS_INETD())
@@ -309,6 +309,8 @@
 
 static void main_init(bool log_error)
 {
+	const char *base_config_path;
+
 	drop_capabilities();
 
 	/* deny file access from everyone else except owner */
@@ -348,6 +350,13 @@
 
 	create_pid_file(t_strconcat(settings_root->defaults->base_dir,
 				    "/master.pid", NULL));
+	base_config_path = t_strconcat(settings_root->defaults->base_dir,
+				       "/"PACKAGE".conf", NULL);
+	(void)unlink(base_config_path);
+	if (symlink(configfile, base_config_path) < 0) {
+		i_error("symlink(%s, %s) failed: %m",
+			configfile, base_config_path);
+	}
 }
 
 static void main_deinit(void)
@@ -518,6 +527,7 @@
 	const char *exec_protocol = NULL, **exec_args = NULL, *user, *home;
 	bool foreground = FALSE, ask_key_pass = FALSE, log_error = FALSE;
 	bool dump_config = FALSE, dump_config_nondefaults = FALSE;
+	bool config_path_given = FALSE;
 	int i;
 
 #ifdef DEBUG
@@ -538,6 +548,7 @@
 			i++;
 			if (i == argc) i_fatal("Missing config file argument");
 			configfile = argv[i];
+			config_path_given = TRUE;
 		} else if (strcmp(argv[i], "-n") == 0) {
 			dump_config_nondefaults = dump_config = TRUE;
 		} else if (strcmp(argv[i], "-p") == 0) {
@@ -579,7 +590,6 @@
 	}
 
 	if (dump_config) {
-
 		/* print the config file path before parsing it, so in case
 		   of errors it's still shown */
 		printf("# "VERSION": %s\n", configfile);
@@ -589,7 +599,8 @@
 	T_BEGIN {
 		master_settings_init();
 		if (!master_settings_read(configfile, exec_protocol != NULL,
-					  dump_config || log_error))
+					  dump_config || log_error,
+					  !config_path_given))
 			i_fatal("Invalid configuration in %s", configfile);
 	} T_END;