From: Timo Sirainen Date: Wed, 8 Oct 2008 19:44:20 +0000 (+0300) Subject: checkpassword: Allow setting uid/gid in userdb_uid and userdb_gid environment. X-Git-Tag: 1.2.alpha3~60 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6838cf40d72a712c5381cf966a56c6299afe1b74;p=thirdparty%2Fdovecot%2Fcore.git checkpassword: Allow setting uid/gid in userdb_uid and userdb_gid environment. --HG-- branch : HEAD --- diff --git a/src/auth/checkpassword-reply.c b/src/auth/checkpassword-reply.c index f7b55205de..c27ebdf3b3 100644 --- a/src/auth/checkpassword-reply.c +++ b/src/auth/checkpassword-reply.c @@ -11,7 +11,8 @@ int main(void) { string_t *str; const char *user, *home; - const char *extra_env, *value, *const *tmp; + const char *extra_env, *key, *value, *const *tmp; + bool uid_found = FALSE, gid_found = FALSE; lib_init(); str = t_str_new(1024); @@ -34,19 +35,24 @@ int main(void) 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++) { value = getenv(*tmp); if (value != NULL) { - str_printfa(str, "%s=%s\t", - t_str_lcase(*tmp), value); + key = t_str_lcase(*tmp); + if (strcmp(key, "userdb_uid") == 0) + uid_found = TRUE; + else if (strcmp(key, "userdb_gid") == 0) + gid_found = TRUE; + str_printfa(str, "%s=%s\t", key, value); } } } + if (!uid_found) + str_printfa(str, "userdb_uid=%s\t", dec2str(getuid())); + if (!gid_found) + str_printfa(str, "userdb_gid=%s\t", dec2str(getgid())); if (write_full(4, str_data(str), str_len(str)) < 0) { i_error("checkpassword: write_full() failed: %m");