[dovecot-cvs] dovecot-lda/src deliver.c,1.33,1.34

cras at dovecot.org cras at dovecot.org
Mon Jan 2 15:39:34 EET 2006


Update of /var/lib/cvs/dovecot-lda/src
In directory talvi:/tmp/cvs-serv28873

Modified Files:
	deliver.c 
Log Message:
Read dovecot.conf directly.



Index: deliver.c
===================================================================
RCS file: /var/lib/cvs/dovecot-lda/src/deliver.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- deliver.c	2 Jan 2006 13:39:07 -0000	1.33
+++ deliver.c	2 Jan 2006 13:39:32 -0000	1.34
@@ -33,7 +33,7 @@
 
 #define SIEVE_SCRIPT_PATH "~/.dovecot.sieve"
 
-#define DEFAULT_CONFIG_FILE SYSCONFDIR"/dovecot-deliver.conf"
+#define DEFAULT_CONFIG_FILE SYSCONFDIR"/dovecot.conf"
 #define DEFAULT_AUTH_SOCKET_PATH "/var/run/dovecot-auth-master"
 
 /* After buffer grows larger than this, create a temporary file to /tmp
@@ -283,11 +283,15 @@
 	return return_value;
 }
 
+#define IS_WHITE(c) ((c) == ' ' || (c) == '\t')
+
 static void config_file_init(const char *path)
 {
 	struct istream *input;
-	const char *line, *p, *key, *value;
-	int fd;
+	const char *key, *value;
+	char *line, *p, quote;
+	int fd, sections = 0, lda_section = FALSE;
+	size_t len;
 
 	fd = open(path, O_RDONLY);
 	if (fd < 0)
@@ -296,12 +300,53 @@
 	t_push();
 	input = i_stream_create_file(fd, default_pool, 1024, TRUE);
 	while ((line = i_stream_read_next_line(input)) != NULL) {
-		while (*line == ' ') line++;
-		if (*line == '#')
+		/* @UNSAFE: line is modified */
+
+		/* skip whitespace */
+		while (IS_WHITE(*line))
+			line++;
+
+		/* ignore comments or empty lines */
+		if (*line == '#' || *line == '\0')
 			continue;
 
+		/* strip away comments. pretty kludgy way really.. */
+		for (p = line; *p != '\0'; p++) {
+			if (*p == '\'' || *p == '"') {
+				quote = *p;
+				for (p++; *p != quote && *p != '\0'; p++) {
+					if (*p == '\\' && p[1] != '\0')
+						p++;
+				}
+				if (*p == '\0')
+					break;
+			} else if (*p == '#') {
+				*p = '\0';
+				break;
+			}
+		}
+
+		/* remove whitespace from end of line */
+		len = strlen(line);
+		while (IS_WHITE(line[len-1]))
+			len--;
+		line[len] = '\0';
+
 		value = p = strchr(line, '=');
-		if (value == NULL)
+		if (value == NULL) {
+			if (strchr(line, '{') != NULL) {
+				if (strcmp(line, "protocol lda {") == 0)
+					lda_section = TRUE;
+				sections++;
+			}
+			if (*line == '}') {
+				sections--;
+				lda_section = FALSE;
+			}
+			continue;
+		}
+
+		if (sections > 0 && !lda_section)
 			continue;
 
 		while (p > line && p[-1] == ' ') p--;
@@ -559,7 +604,7 @@
 	mail_storage_register_all();
         duplicate_init();
 
-	mail_env = getenv("MAIL");
+	mail_env = getenv("DEFAULT_MAIL_ENV");
 	if (mail_env == NULL)
 		i_fatal_status(EX_CONFIG, "mail setting not given");
 



More information about the dovecot-cvs mailing list