dovecot: If USER and HOME environments both exists, never do get...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Jan 7 12:42:22 EET 2008
details: http://hg.dovecot.org/dovecot/rev/24526ffec9a2
changeset: 7136:24526ffec9a2
user: Timo Sirainen <tss at iki.fi>
date: Mon Jan 07 12:42:18 2008 +0200
description:
If USER and HOME environments both exists, never do getpwuid() lookup. If
HOME doesn't exist, do the lookup but don't fail unless also USER doesn't
exist.
diffstat:
1 file changed, 7 insertions(+), 4 deletions(-)
src/deliver/deliver.c | 11 +++++++----
diffs (23 lines):
diff -r 9fef306a0d95 -r 24526ffec9a2 src/deliver/deliver.c
--- a/src/deliver/deliver.c Mon Jan 07 07:38:16 2008 +0200
+++ b/src/deliver/deliver.c Mon Jan 07 12:42:18 2008 +0200
@@ -801,12 +801,15 @@ int main(int argc, char *argv[])
/* we're non-root. get our username and possibly our home. */
struct passwd *pw;
- pw = getpwuid(process_euid);
- if (pw != NULL) {
+ user = getenv("USER");
+ home = getenv("HOME");
+ if (user != NULL && home != NULL) {
+ /* no need for a pw lookup */
+ } else if ((pw = getpwuid(process_euid)) != NULL) {
user = t_strdup(pw->pw_name);
- if (getenv("HOME") == NULL)
+ if (home == NULL)
env_put(t_strconcat("HOME=", pw->pw_dir, NULL));
- } else {
+ } else if (user == NULL) {
i_fatal("Couldn't lookup our username (uid=%s)",
dec2str(process_euid));
}
More information about the dovecot-cvs
mailing list