changeset 5155:facdf5823359 HEAD

If USER environment is set, return it in "user" field and not "userdb_user". Also don't require that the USER environment exists.
author Timo Sirainen <tss@iki.fi>
date Fri, 16 Feb 2007 19:28:16 +0200
parents b9cb27ecee98
children 644342a79f15
files src/auth/checkpassword-reply.c
diffstat 1 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/auth/checkpassword-reply.c	Fri Feb 16 19:26:19 2007 +0200
+++ b/src/auth/checkpassword-reply.c	Fri Feb 16 19:28:16 2007 +0200
@@ -17,18 +17,14 @@
 	str = t_str_new(1024);
 
 	user = getenv("USER");
-	if (user == NULL)
-		i_fatal("checkpassword: USER environment missing");
-	if (strchr(user, '\t') != NULL) {
-		i_error("checkpassword: USER contains TAB");
-		return 1;
+	if (user != NULL) {
+		if (strchr(user, '\t') != NULL) {
+			i_error("checkpassword: USER contains TAB");
+			return 1;
+		}
+		str_printfa(str, "user=%s\t", user);
 	}
 
-	str_printfa(str, "userdb_user=%s\t"
-		    "userdb_uid=%s\t"
-		    "userdb_gid=%s\t",
-		    user, dec2str(getuid()), dec2str(getgid()));
-
 	home = getenv("HOME");
 	if (home != NULL) {
 		if (strchr(home, '\t') != NULL) {
@@ -38,6 +34,9 @@
 		str_printfa(str, "userdb_home=%s\t", home);
 	}
 
+	str_printfa(str, "userdb_uid=%s\tuserdb_gid=%s\t",
+		    dec2str(getuid()), dec2str(getgid()));
+
 	extra_env = getenv("EXTRA");
 	if (extra_env != NULL) {
 		for (tmp = t_strsplit(extra_env, " "); *tmp != NULL; tmp++) {