[dovecot-cvs] dovecot-lda/src deliver.c, 1.52, 1.53 sieve-cmu.c, 1.13, 1.14

cras at dovecot.org cras at dovecot.org
Fri May 12 22:01:00 EEST 2006


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

Modified Files:
	deliver.c sieve-cmu.c 
Log Message:
Do some more logging.



Index: deliver.c
===================================================================
RCS file: /var/lib/cvs/dovecot-lda/src/deliver.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- deliver.c	12 May 2006 18:24:40 -0000	1.52
+++ deliver.c	12 May 2006 19:00:58 -0000	1.53
@@ -450,15 +450,18 @@
 	return input;
 }
 
-static void open_logfile(void)
+static void open_logfile(const char *username)
 {
+	const char *prefix;
+
+	prefix = t_strdup_printf("deliver(%s)", username);
 	if (getenv("LOG_PATH") == NULL) {
 		const char *env = getenv("SYSLOG_FACILITY");
-		i_set_failure_syslog("deliver", LOG_NDELAY,
+		i_set_failure_syslog(prefix, LOG_NDELAY,
 				     env == NULL ? LOG_MAIL : atoi(env));
 	} else {
 		/* log to file or stderr */
-		i_set_failure_file(getenv("LOG_PATH"), "deliver");
+		i_set_failure_file(getenv("LOG_PATH"), prefix);
 	}
 
 	if (getenv("INFO_LOG_PATH") != NULL)
@@ -510,7 +513,7 @@
 	const char *config_path = DEFAULT_CONFIG_FILE;
 	const char *mailbox = "INBOX";
 	const char *auth_socket, *env_tz;
-	const char *home, *destination, *mail_env, *str, *script_path;
+	const char *home, *destination, *user, *mail_env, *str, *script_path;
         const struct var_expand_table *table;
         enum mail_storage_flags flags;
         enum mail_storage_lock_method lock_method;
@@ -574,9 +577,26 @@
 				       "Unknown argument: %s", argv[1]);
 		}
 	}
+	if (destination != NULL)
+		user = destination;
+	else if (geteuid() != 0) {
+		/* we're non-root. get our username. */
+		struct passwd *pw;
+
+		pw = getpwuid(geteuid());
+		if (pw != NULL)
+			user = t_strdup(pw->pw_name);
+		else {
+			i_fatal("Couldn't lookup our username (uid=%s)",
+				dec2str(geteuid()));
+		}
+	} else {
+		i_fatal_status(EX_USAGE,
+			"destination user parameter (-d user) not given");
+	}
 
 	config_file_init(config_path);
-	open_logfile();
+	open_logfile(user);
 
 	if (destination != NULL) {
 		auth_socket = getenv("AUTH_SOCKET_PATH");
@@ -593,18 +613,8 @@
 			   could be written. If it fails, don't worry. */
 			(void)chdir(home);
 		}
-	} else if (geteuid() != 0) {
-		/* we're non-root. get our username. */
-		struct passwd *pw;
-
-		pw = getpwuid(geteuid());
-		if (pw != NULL)
-			destination = t_strdup(pw->pw_name);
-	} 
-
-	if (destination == NULL) {
-		i_fatal_status(EX_USAGE,
-			"destination user parameter (-d user) not given");
+	} else {
+		destination = user;
 	}
 
 	sieve_set = i_new(struct sieve_settings, 1);

Index: sieve-cmu.c
===================================================================
RCS file: /var/lib/cvs/dovecot-lda/src/sieve-cmu.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- sieve-cmu.c	8 Feb 2006 11:39:29 -0000	1.13
+++ sieve-cmu.c	12 May 2006 19:00:58 -0000	1.14
@@ -106,14 +106,17 @@
 	/* ok, let's see if we've redirected this message before */
 	if (duplicate_check(dupeid, strlen(dupeid), sd->username)) {
 	    /*duplicate_log(m->id, sd->username, "redirect");*/
-            i_info("Duplicated redirection (%s: %s -> %s)", m->id,
-                   sd->username, rc->addr);
+            i_info("discarded duplicate forward (%s -> %s)",
+		   str_sanitize(m->id, 80), str_sanitize(rc->addr, 80));
             return SIEVE_OK;
 	}
     }
 
     if ((res = mail_send_forward(m->mail, rc->addr)) == 0) {
 	/* mark this message as redirected */
+	i_info("forwarded id %s to <%s>",
+	       m->id == NULL ? "" : str_sanitize(m->id, 80),
+	       str_sanitize(rc->addr, 80));
         if (dupeid != NULL) {
             duplicate_mark(dupeid, strlen(dupeid), sd->username,
                            ioloop_time + DUPLICATE_DEFAULT_KEEP);
@@ -131,22 +134,13 @@
 
 static int sieve_discard(void *ac __attribute__((unused)), 
 			 void *ic __attribute__((unused)), 
-			 void *sc, void *mc, 
+			 void *sc __attribute__((unused)), void *mc,
 			 const char **errmsg __attribute__((unused)))
 {
-    script_data_t *sd = (script_data_t *) sc;
     sieve_msgdata_t *md = mc;
 
     /* ok, we won't file it, but log it */
-    if (md->id && strlen(md->id) < 80) {
-	i_info("sieve: discarded message to %s id %s",
-	       sd->username, str_sanitize(md->id, 80));
-    }
-    else {
-	i_info("sieve: discarded message to %s",
-	       sd->username);
-    }	
-
+    i_info("discarded id %s", md->id == NULL ? "" : str_sanitize(md->id, 80));
     return SIEVE_OK;
 }
 
@@ -166,12 +160,14 @@
     }
 
     if (strlen(md->return_path) == 0) {
-	i_info("sieve: discarded reject to <> for %s id %s",
-	       sd->username, str_sanitize(md->id, 80));
+	i_info("discarded reject to <> id %s",
+	       md->id == NULL ? "" : str_sanitize(md->id, 80));
         return SIEVE_OK;
     }
 
     if ((res = mail_send_rejection(md->mail, sd->username, rc->msg)) == 0) {
+	i_info("rejected id %s",
+	       md->id == NULL ? "" : str_sanitize(md->id, 80));
 	return SIEVE_OK;
     } else {
 	if (res == -1) {
@@ -238,6 +234,8 @@
 
     if (save_mail(sd->storage, fc->mailbox, md->mail, flags, keywords) < 0)
 	    return SIEVE_FAIL;
+
+    i_info("saved mail to %s", md->mailbox);
     return SIEVE_OK;
 }
 
@@ -256,6 +254,7 @@
     if (save_mail(sd->storage, md->mailbox, md->mail, flags, keywords) < 0)
 	    return SIEVE_FAIL;
 
+    i_info("saved mail to %s", md->mailbox);
     return SIEVE_OK;
 }
 
@@ -398,8 +397,7 @@
 
     if (sd->errors == NULL) {
 	    sd->errors = str_new(default_pool, 1024);
-	    i_info("sieve parse error for %s: line %d: %s",
-		   sd->username, lineno, msg);
+	    i_info("sieve parse error: line %d: %s", lineno, msg);
     }
 
     str_printfa(sd->errors, "line %d: %s\n", lineno, msg);
@@ -408,13 +406,10 @@
 
 static int sieve_execute_error_handler(const char *msg, 
 				       void *ic __attr_unused__,
-				       void *sc, void *mc __attr_unused__)
+				       void *sc __attr_unused__,
+				       void *mc __attr_unused__)
 {
-    script_data_t *sd = (script_data_t *) sc;
-    
-    i_info("sieve runtime error for %s: %s",
-	   sd->username, msg);
-    
+    i_info("sieve runtime error: %s", msg);
     return SIEVE_OK;
 }
  



More information about the dovecot-cvs mailing list