changeset 4763:8bbed82738ec HEAD

If we're executing as a normal system user, get the HOME environment from passwd if it's not set. This makes it possible to run deliver from .forward.
author Timo Sirainen <tss@iki.fi>
date Sun, 05 Nov 2006 22:47:16 +0200
parents 9bc48d105ac5
children 2ab821630a45
files src/deliver/deliver.c
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/deliver/deliver.c	Sun Nov 05 22:12:28 2006 +0200
+++ b/src/deliver/deliver.c	Sun Nov 05 22:47:16 2006 +0200
@@ -462,13 +462,15 @@
 	if (destination != NULL)
 		user = destination;
 	else if (process_euid != 0) {
-		/* we're non-root. get our username. */
+		/* we're non-root. get our username and possibly our home. */
 		struct passwd *pw;
 
 		pw = getpwuid(process_euid);
-		if (pw != NULL)
+		if (pw != NULL) {
 			user = t_strdup(pw->pw_name);
-		else {
+			if (getenv("HOME") == NULL)
+				env_put(t_strconcat("HOME=", pw->pw_dir, NULL));
+		} else {
 			i_fatal("Couldn't lookup our username (uid=%s)",
 				dec2str(process_euid));
 		}