[dovecot-cvs] dovecot/src/master auth-process.c,1.9,1.10 imap-process.c,1.9,1.10 login-process.c,1.12,1.13 main.c,1.13,1.14

cras at procontrol.fi cras at procontrol.fi
Tue Nov 26 21:49:08 EET 2002


Update of /home/cvs/dovecot/src/master
In directory danu:/tmp/cvs-serv2066/master

Modified Files:
	auth-process.c imap-process.c login-process.c main.c 
Log Message:
Created env_put() and env_clean() for a bit easier handling of environment
variables.



Index: auth-process.c
===================================================================
RCS file: /home/cvs/dovecot/src/master/auth-process.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- auth-process.c	26 Nov 2002 13:58:26 -0000	1.9
+++ auth-process.c	26 Nov 2002 19:49:06 -0000	1.10
@@ -2,6 +2,7 @@
 
 #include "common.h"
 #include "ioloop.h"
+#include "env-util.h"
 #include "network.h"
 #include "obuffer.h"
 #include "restrict-access.h"
@@ -237,11 +238,11 @@
 				config->chroot);
 
 	/* set other environment */
-	putenv((char *) t_strdup_printf("AUTH_PROCESS=%d", (int) getpid()));
-	putenv((char *) t_strconcat("METHODS=", config->methods, NULL));
-	putenv((char *) t_strconcat("REALMS=", config->realms, NULL));
-	putenv((char *) t_strconcat("USERINFO=", config->userinfo, NULL));
-	putenv((char *) t_strconcat("USERINFO_ARGS=", config->userinfo_args,
+	env_put(t_strdup_printf("AUTH_PROCESS=%d", (int) getpid()));
+	env_put(t_strconcat("METHODS=", config->methods, NULL));
+	env_put(t_strconcat("REALMS=", config->realms, NULL));
+	env_put(t_strconcat("USERINFO=", config->userinfo, NULL));
+	env_put(t_strconcat("USERINFO_ARGS=", config->userinfo_args,
 				    NULL));
 	/* hide the path, it's ugly */
 	argv[0] = strrchr(config->executable, '/');

Index: imap-process.c
===================================================================
RCS file: /home/cvs/dovecot/src/master/imap-process.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- imap-process.c	21 Nov 2002 20:31:03 -0000	1.9
+++ imap-process.c	26 Nov 2002 19:49:06 -0000	1.10
@@ -1,6 +1,7 @@
 /* Copyright (C) 2002 Timo Sirainen */
 
 #include "common.h"
+#include "env-util.h"
 #include "restrict-access.h"
 
 #include <stdlib.h>
@@ -110,38 +111,36 @@
 
 	/* setup environment */
 	while (env[0] != NULL && env[1] != NULL) {
-		putenv((char *) t_strconcat(env[0], "=", env[1], NULL));
+		env_put(t_strconcat(env[0], "=", env[1], NULL));
 		env += 2;
 	}
 
-	putenv((char *) t_strconcat("HOME=", home, NULL));
-	putenv((char *) t_strconcat("MAIL_CACHE_FIELDS=",
-				    set_mail_cache_fields, NULL));
-	putenv((char *) t_strconcat("MAIL_NEVER_CACHE_FIELDS=",
-				    set_mail_never_cache_fields, NULL));
-	putenv((char *) t_strdup_printf("MAILBOX_CHECK_INTERVAL=%u",
-					set_mailbox_check_interval));
+	env_put(t_strconcat("HOME=", home, NULL));
+	env_put(t_strconcat("MAIL_CACHE_FIELDS=", set_mail_cache_fields, NULL));
+	env_put(t_strconcat("MAIL_NEVER_CACHE_FIELDS=",
+			    set_mail_never_cache_fields, NULL));
+	env_put(t_strdup_printf("MAILBOX_CHECK_INTERVAL=%u",
+				set_mailbox_check_interval));
 
 	if (set_mail_save_crlf)
-		putenv("MAIL_SAVE_CRLF=1");
+		env_put("MAIL_SAVE_CRLF=1");
 	if (set_mail_read_mmaped)
-		putenv("MAIL_READ_MMAPED=1");
+		env_put("MAIL_READ_MMAPED=1");
 	if (set_maildir_copy_with_hardlinks)
-		putenv("MAILDIR_COPY_WITH_HARDLINKS=1");
+		env_put("MAILDIR_COPY_WITH_HARDLINKS=1");
 	if (set_maildir_check_content_changes)
-		putenv("MAILDIR_CHECK_CONTENT_CHANGES=1");
+		env_put("MAILDIR_CHECK_CONTENT_CHANGES=1");
 	if (set_overwrite_incompatible_index)
-		putenv("OVERWRITE_INCOMPATIBLE_INDEX=1");
+		env_put("OVERWRITE_INCOMPATIBLE_INDEX=1");
 	if (umask(set_umask) != set_umask)
 		i_fatal("Invalid umask: %o", set_umask);
 
-	putenv((char *) t_strconcat("MBOX_LOCKS=", set_mbox_locks, NULL));
-	putenv((char *) t_strdup_printf("MBOX_LOCK_TIMEOUT=%u",
-					set_mbox_lock_timeout));
-	putenv((char *) t_strdup_printf("MBOX_DOTLOCK_CHANGE_TIMEOUT=%u",
-					set_mbox_dotlock_change_timeout));
+	env_put(t_strconcat("MBOX_LOCKS=", set_mbox_locks, NULL));
+	env_put(t_strdup_printf("MBOX_LOCK_TIMEOUT=%u", set_mbox_lock_timeout));
+	env_put(t_strdup_printf("MBOX_DOTLOCK_CHANGE_TIMEOUT=%u",
+				set_mbox_dotlock_change_timeout));
 	if (set_mbox_read_dotlock)
-		putenv("MBOX_READ_DOTLOCK=1");
+		env_put("MBOX_READ_DOTLOCK=1");
 
 	if (set_verbose_proctitle && net_ip2host(ip, host) == 0) {
 		i_snprintf(title, sizeof(title), "[%s %s]", user, host);

Index: login-process.c
===================================================================
RCS file: /home/cvs/dovecot/src/master/login-process.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- login-process.c	25 Nov 2002 10:45:40 -0000	1.12
+++ login-process.c	26 Nov 2002 19:49:06 -0000	1.13
@@ -5,12 +5,12 @@
 #include "network.h"
 #include "obuffer.h"
 #include "fdpass.h"
+#include "env-util.h"
 #include "restrict-access.h"
 #include "login-process.h"
 #include "auth-process.h"
 #include "master-interface.h"
 
-#include <stdlib.h>
 #include <unistd.h>
 #include <syslog.h>
 
@@ -303,23 +303,21 @@
 	}
 
 	if (!set_ssl_disable) {
-		putenv((char *) t_strconcat("SSL_CERT_FILE=",
-					    set_ssl_cert_file, NULL));
-		putenv((char *) t_strconcat("SSL_KEY_FILE=",
-					    set_ssl_key_file, NULL));
-		putenv((char *) t_strconcat("SSL_PARAM_FILE=",
-					    set_ssl_parameters_file, NULL));
+		env_put(t_strconcat("SSL_CERT_FILE=", set_ssl_cert_file, NULL));
+		env_put(t_strconcat("SSL_KEY_FILE=", set_ssl_key_file, NULL));
+		env_put(t_strconcat("SSL_PARAM_FILE=",
+				    set_ssl_parameters_file, NULL));
 	}
 
 	if (set_disable_plaintext_auth)
-		putenv("DISABLE_PLAINTEXT_AUTH=1");
+		env_put("DISABLE_PLAINTEXT_AUTH=1");
 
 	if (set_login_process_per_connection) {
-		putenv("PROCESS_PER_CONNECTION=1");
-		putenv("MAX_LOGGING_USERS=1");
+		env_put("PROCESS_PER_CONNECTION=1");
+		env_put("MAX_LOGGING_USERS=1");
 	} else {
-		putenv((char *) t_strdup_printf("MAX_LOGGING_USERS=%d",
-						set_max_logging_users));
+		env_put(t_strdup_printf("MAX_LOGGING_USERS=%d",
+					set_max_logging_users));
 	}
 
 	/* hide the path, it's ugly */

Index: main.c
===================================================================
RCS file: /home/cvs/dovecot/src/master/main.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- main.c	20 Nov 2002 19:20:23 -0000	1.13
+++ main.c	26 Nov 2002 19:49:06 -0000	1.14
@@ -4,6 +4,7 @@
 #include "ioloop.h"
 #include "lib-signals.h"
 #include "network.h"
+#include "env-util.h"
 
 #include "auth-process.h"
 #include "login-process.h"
@@ -46,21 +47,14 @@
 
 void clean_child_process(void)
 {
-	extern char **environ;
-
 	/* remove all environment, we don't need them */
-	if (environ != NULL)
-		*environ = NULL;
+	env_clean();
 
 	/* set the failure log */
-	if (set_log_path != NULL) {
-		putenv((char *) t_strconcat("IMAP_LOGFILE=",
-					    set_log_path, NULL));
-	}
-	if (set_log_timestamp != NULL) {
-		putenv((char *) t_strconcat("IMAP_LOGSTAMP=",
-					    set_log_timestamp, NULL));
-	}
+	if (set_log_path != NULL)
+		env_put(t_strconcat("IMAP_LOGFILE=", set_log_path, NULL));
+	if (set_log_timestamp != NULL)
+		env_put(t_strconcat("IMAP_LOGSTAMP=", set_log_timestamp, NULL));
 
 	(void)close(null_fd);
 	(void)close(imap_fd);




More information about the dovecot-cvs mailing list