diff options
-rw-r--r-- | env.c | 18 | ||||
-rw-r--r-- | fetchmail.man | 14 | ||||
-rw-r--r-- | pop3.c | 6 |
3 files changed, 20 insertions, 18 deletions
@@ -37,8 +37,9 @@ void envquery(int argc, char **argv) { struct passwd by_name, by_uid, *pwp; - if (!(user = getenv("LOGNAME"))) - user = getenv("USER"); + (user = getenv("FETCHMAILUSER")) + || (user = getenv("LOGNAME")) + || (user = getenv("USER")); if (!(pwp = getpwuid(getuid()))) { @@ -50,13 +51,13 @@ void envquery(int argc, char **argv) else { memcpy(&by_uid, pwp, sizeof(struct passwd)); - if (!user) + if (!user || !(pwp = getpwnam(user))) pwp = &by_uid; - else if ((pwp = getpwnam(user))) + else { /* * This logic is needed to handle gracefully the possibility - * that multiple names might be mapped to one UID + * that multiple names might be mapped to one UID. */ memcpy(&by_name, pwp, sizeof(struct passwd)); @@ -65,13 +66,6 @@ void envquery(int argc, char **argv) else pwp = &by_uid; } - else - { - fprintf(stderr, - _("%s: can't find your name and home directory!\n"), - program_name); - exit(PS_UNDEFINED); - } user = xstrdup(pwp->pw_name); } diff --git a/fetchmail.man b/fetchmail.man index c800276b..5937a9b8 100644 --- a/fetchmail.man +++ b/fetchmail.man @@ -1946,12 +1946,14 @@ lock file to help prevent concurrent runs (root mode, Linux systems). lock file to help prevent concurrent runs (root mode, systems without /var/run). .SH ENVIRONMENT -If either the LOGNAME or USER variable is correctly set -(e.g. the corresponding UID matches the session user ID) then that -name is used as the default local name. Otherwise \fBgetpwuid\fR(3) -must be able to retrieve a password entry for the session ID (this -elaborate logic is designed to handle the case of multiple names per -userid gracefully). +If the FETCHMAILUSER variable is set, it is used as the name of the +calling user (default local name) for purposes such as mailing error +notifications. Otherwise, if either the LOGNAME or USER variable is +correctly set (e.g. the corresponding UID matches the session user ID) +then that name is used as the default local name. Otherwise +\fBgetpwuid\fR(3) must be able to retrieve a password entry for the +session ID (this elaborate logic is designed to handle the case of +multiple names per userid gracefully). If the environment variable FETCHMAILHOME is set to a valid and existing directory name, the .fetchmailrc and .fetchids and @@ -630,6 +630,12 @@ static int pop3_logout(int sock, struct query *ctl) if (!ok) expunge_uids(ctl); + if (ctl->lastid) + { + free(ctl->lastid); + ctl->lastid = NULL; + } + return(ok); } |