From 16f2180c9720ef2473f42538fde9df340c72c92a Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 23 Jul 2000 17:11:52 +0000 Subject: FETCHMAILUSER implemented. svn path=/trunk/; revision=2933 --- env.c | 18 ++++++------------ fetchmail.man | 14 ++++++++------ pop3.c | 6 ++++++ 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/env.c b/env.c index 2ca72cf3..1ea8895c 100644 --- a/env.c +++ b/env.c @@ -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 diff --git a/pop3.c b/pop3.c index 9eae1441..a325496c 100644 --- a/pop3.c +++ b/pop3.c @@ -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); } -- cgit v1.2.3