[dovecot-cvs] dovecot/src/master main.c, 1.73, 1.74 ssl-init.c, 1.20, 1.21 ssl-init.h, 1.3, 1.4

cras at dovecot.org cras at dovecot.org
Sun Jan 22 12:50:56 EET 2006


Update of /var/lib/cvs/dovecot/src/master
In directory talvi:/tmp/cvs-serv25529

Modified Files:
	main.c ssl-init.c ssl-init.h 
Log Message:
Added --build-ssl-parameters option to build them.



Index: main.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/master/main.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- main.c	15 Jan 2006 21:52:44 -0000	1.73
+++ main.c	22 Jan 2006 10:50:54 -0000	1.74
@@ -602,8 +602,9 @@
 
 static void print_help(void)
 {
-	printf("Usage: dovecot [-F] [-c <config file>] "
-	       "[--version] [--build-options]\n");
+	printf(
+"Usage: dovecot [-F] [-c <config file>] [-p] [--build-ssl-parameters]\n"
+"       [--exec-mail <protocol>] [--version] [--build-options]\n");
 }
 
 static void print_build_options(void)
@@ -699,7 +700,7 @@
 {
 	/* parse arguments */
 	const char *exec_protocol = NULL, *exec_section = NULL, *user, *home;
-	bool foreground = FALSE, ask_key_pass = FALSE;
+	bool foreground = FALSE, ask_key_pass = FALSE, build_parameters = FALSE;
 	int i;
 
 #ifdef DEBUG
@@ -729,6 +730,8 @@
 			exec_protocol = argv[i];
 			if (i+1 != argc) 
 				exec_section = argv[++i];
+		} else if (strcmp(argv[i], "--build-ssl-parameters") == 0) {
+			build_parameters = TRUE;
 		} else if (strcmp(argv[i], "--version") == 0) {
 			printf("%s\n", VERSION);
 			return 0;
@@ -768,6 +771,10 @@
 			sizeof(ssl_manual_key_password));
 		t_pop();
 	}
+	if (build_parameters) {
+		ssl_check_parameters_file(TRUE);
+		exit(0);
+	}
 
 	/* save TZ environment. AIX depends on it to get the timezone
 	   correctly. */

Index: ssl-init.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/master/ssl-init.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- ssl-init.c	16 Jan 2006 19:36:57 -0000	1.20
+++ ssl-init.c	22 Jan 2006 10:50:54 -0000	1.21
@@ -70,7 +70,7 @@
 	generating = FALSE;
 }
 
-static bool check_parameters_file_set(struct settings *set)
+static bool check_parameters_file_set(struct settings *set, bool foreground)
 {
 	const char *path;
 	struct stat st;
@@ -100,18 +100,27 @@
 		st.st_mtime + (time_t)(set->ssl_parameters_regenerate*3600);
 	if (regen_time < ioloop_time || st.st_size == 0 ||
 	    st.st_uid != master_uid || st.st_gid != getegid()) {
-		if (st.st_mtime == 0) {
-			i_info("Generating Diffie-Hellman parameters "
-			       "for the first time. This may take a while..");
+		if (foreground) {
+			i_info("Generating Diffie-Hellman parameters. "
+			       "This may take a while..");
+			generate_parameters_file(path);
+		} else {
+			if (st.st_mtime == 0) {
+				i_info("Generating Diffie-Hellman parameters "
+				       "for the first time. This may take "
+				       "a while..");
+			}
+			start_generate_process(path);
 		}
-		start_generate_process(path);
 		return FALSE;
+	} else if (foreground) {
+		i_info("Diffie-Hellman parameter file already exists.");
 	}
 
 	return TRUE;
 }
 
-static void check_parameters_file(void *context __attr_unused__)
+void ssl_check_parameters_file(bool foreground)
 {
 	struct server_settings *server;
 
@@ -119,23 +128,25 @@
 		return;
 
 	for (server = settings_root; server != NULL; server = server->next) {
-		if (server->imap != NULL &&
-		    !check_parameters_file_set(server->imap))
-			break;
-		if (server->pop3 != NULL &&
-		    !check_parameters_file_set(server->pop3))
+		if (server->defaults != NULL &&
+		    !check_parameters_file_set(server->defaults, foreground))
 			break;
 	}
 }
 
+static void check_parameters_file_timeout(void *context __attr_unused__)
+{
+	ssl_check_parameters_file(FALSE);
+}
+
 void ssl_init(void)
 {
 	generating = FALSE;
 
 	/* check every 10 mins */
-	to = timeout_add(600 * 1000, check_parameters_file, NULL);
+	to = timeout_add(600 * 1000, check_parameters_file_timeout, NULL);
 
-	check_parameters_file(NULL);
+        ssl_check_parameters_file(FALSE);
 }
 
 void ssl_deinit(void)

Index: ssl-init.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/master/ssl-init.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ssl-init.h	15 Jan 2006 21:52:44 -0000	1.3
+++ ssl-init.h	22 Jan 2006 10:50:54 -0000	1.4
@@ -5,6 +5,7 @@
 
 void ssl_parameter_process_destroyed(pid_t pid);
 
+void ssl_check_parameters_file(bool foreground);
 void _ssl_generate_parameters(int fd, const char *fname);
 
 void ssl_init(void);



More information about the dovecot-cvs mailing list