dovecot-1.1: mail_uid and mail_gid settings weren't handled corr...

dovecot at dovecot.org dovecot at dovecot.org
Sun May 4 03:00:37 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.1/rev/1b15881ed93b
changeset: 7473:1b15881ed93b
user:      Timo Sirainen <tss at iki.fi>
date:      Sun May 04 03:00:32 2008 +0300
description:
mail_uid and mail_gid settings weren't handled correctly.

diffstat:

1 file changed, 7 insertions(+), 11 deletions(-)
src/deliver/auth-client.c |   18 +++++++-----------

diffs (56 lines):

diff -r aa41caaf8e0b -r 1b15881ed93b src/deliver/auth-client.c
--- a/src/deliver/auth-client.c	Sun May 04 02:53:55 2008 +0300
+++ b/src/deliver/auth-client.c	Sun May 04 03:00:32 2008 +0300
@@ -110,10 +110,6 @@ static void auth_parse_input(struct auth
 					conn->user);
 				return_value = EX_TEMPFAIL;
 			}
-			if (conn->euid != uid) {
-				env_put(t_strconcat("RESTRICT_SETUID=",
-						    dec2str(uid), NULL));
-			}
 		} else if (strncmp(*tmp, "gid=", 4) == 0) {
 			gid = strtoul(*tmp + 4, NULL, 10);
 
@@ -122,11 +118,6 @@ static void auth_parse_input(struct auth
 					conn->user);
 				return_value = EX_TEMPFAIL;
 			}
-
-			if (conn->euid == 0 || getegid() != gid) {
-				env_put(t_strconcat("RESTRICT_SETGID=",
-						    *tmp + 4, NULL));
-			}
 		} else if (strncmp(*tmp, "chroot=", 7) == 0) {
 			chroot = *tmp + 7;
 		} else {
@@ -139,7 +130,7 @@ static void auth_parse_input(struct auth
 		}
 	}
 
-	if (uid == 0 && getenv("MAIL_UID")) {
+	if (uid == 0 && getenv("MAIL_UID") != NULL) {
 		if (!parse_uid(getenv("MAIL_UID"), &uid) || uid == 0) {
 			i_error("mail_uid setting is invalid");
 			return_value = EX_TEMPFAIL;
@@ -151,7 +142,7 @@ static void auth_parse_input(struct auth
 		return_value = EX_TEMPFAIL;
 		return;
 	}
-	if (gid == 0 && getenv("MAIL_GID")) {
+	if (gid == 0 && getenv("MAIL_GID") != NULL) {
 		if (!parse_gid(getenv("MAIL_GID"), &gid) || gid == 0) {
 			i_error("mail_gid setting is invalid");
 			return_value = EX_TEMPFAIL;
@@ -163,6 +154,11 @@ static void auth_parse_input(struct auth
 		return_value = EX_TEMPFAIL;
 		return;
 	}
+
+	if (conn->euid != uid)
+		env_put(t_strconcat("RESTRICT_SETUID=", dec2str(uid), NULL));
+	if (conn->euid == 0 || getegid() != gid)
+		env_put(t_strconcat("RESTRICT_SETGID=", dec2str(gid), NULL));
 
 	if (chroot != NULL)
 		env_put(t_strconcat("RESTRICT_CHROOT=", chroot, NULL));


More information about the dovecot-cvs mailing list