Mercurial > dovecot > original-hg > dovecot-1.2
changeset 8255:a38778911fa9 HEAD
checkpassword: Allow setting uid/gid in userdb_uid and userdb_gid environment.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 08 Oct 2008 22:44:20 +0300 |
parents | c465b10a76fd |
children | 6e1d0ae97963 |
files | src/auth/checkpassword-reply.c |
diffstat | 1 files changed, 12 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/auth/checkpassword-reply.c Wed Oct 08 22:09:59 2008 +0300 +++ b/src/auth/checkpassword-reply.c Wed Oct 08 22:44:20 2008 +0300 @@ -11,7 +11,8 @@ { 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 @@ 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");