From d8291aae2a1e531d3ae40e9553a258cbebe6fb58 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Sun, 4 May 2008 03:00:32 +0300 Subject: [PATCH] mail_uid and mail_gid settings weren't handled correctly. --HG-- branch : HEAD --- src/deliver/auth-client.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/deliver/auth-client.c b/src/deliver/auth-client.c index c27a678abd..568c5bd42d 100644 --- a/src/deliver/auth-client.c +++ b/src/deliver/auth-client.c @@ -110,10 +110,6 @@ static void auth_parse_input(struct auth_connection *conn, const char *args) 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_connection *conn, const char *args) 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_connection *conn, const char *args) } } - 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_connection *conn, const char *args) 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; @@ -164,6 +155,11 @@ static void auth_parse_input(struct auth_connection *conn, const char *args) 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)); -- 2.47.3