[dovecot-cvs] dovecot-lda/src deliver.c,1.29,1.30

cras at dovecot.org cras at dovecot.org
Sat Oct 15 16:54:27 EEST 2005


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

Modified Files:
	deliver.c 
Log Message:
Sieve script path can now be set from config file or userdb by returning
"sieve" setting. Relative to home directory. Empty path disables sieve.



Index: deliver.c
===================================================================
RCS file: /var/lib/cvs/dovecot-lda/src/deliver.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- deliver.c	14 Oct 2005 21:26:18 -0000	1.29
+++ deliver.c	15 Oct 2005 13:54:24 -0000	1.30
@@ -416,6 +416,40 @@
 	i_set_failure_timestamp_format(getenv("LOGSTAMP"));
 }
 
+static const char *get_sieve_path(void)
+{
+	const char *script_path;
+	struct stat st;
+
+	/* userdb may specify Sieve path */
+	script_path = getenv("SIEVE");
+	if (script_path != NULL) {
+		if (*script_path == '\0') {
+			/* disabled */
+			return NULL;
+		}
+
+		script_path = home_expand(SIEVE_SCRIPT_PATH);
+		if (*script_path != '/' && *script_path != '\0') {
+			/* relative path. change to absolute. */
+			script_path = t_strconcat(getenv("HOME"), "/",
+						  script_path, NULL);
+		}
+	} else {
+		script_path = home_expand(SIEVE_SCRIPT_PATH);
+	}
+
+	if (stat(script_path, &st) < 0) {
+		if (errno != ENOENT)
+			i_error("stat(%s) failed: %m", script_path);
+
+		/* use global script instead, if one exists */
+		script_path = getenv("GLOBAL_SCRIPT_PATH");
+	}
+
+	return script_path;
+}
+
 static void print_help(void)
 {
 	printf("Usage: deliver [-c <config file>] [-d <destination user>]\n");
@@ -434,7 +468,6 @@
 	struct istream *input;
 	struct mailbox_transaction_context *t;
 	struct mail *mail;
-	struct stat st;
 	int i, ret;
 
 	lib_init();
@@ -580,14 +613,7 @@
 	if (mail_set_seq(mail, 1) < 0)
 		i_fatal("mail_set_seq() failed");
 
-	script_path = home_expand(SIEVE_SCRIPT_PATH);
-	if (stat(script_path, &st) < 0) {
-		if (errno != ENOENT)
-			i_error("stat(%s) failed: %m", script_path);
-
-		/* use global script instead, if one exists */
-		script_path = getenv("GLOBAL_SCRIPT_PATH");
-	}
+	script_path = get_sieve_path();
 
 	ret = dovecot_sieve_run(storage, mail, script_path, destination);
 	if (ret <= 0) {



More information about the dovecot-cvs mailing list