]> Pileus Git - ~andy/fetchmail/commitdiff
FETCHMAILUSER implemented.
authorEric S. Raymond <esr@thyrsus.com>
Sun, 23 Jul 2000 17:11:52 +0000 (17:11 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Sun, 23 Jul 2000 17:11:52 +0000 (17:11 -0000)
svn path=/trunk/; revision=2933

env.c
fetchmail.man
pop3.c

diff --git a/env.c b/env.c
index 2ca72cf37406813418a2c664e5bc74667891085d..1ea8895c86f1913b4081a6b55b51802b4001ff96 100644 (file)
--- 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);
     }
 
index c800276b7036ccc33a26de2c09706edf3eca38be..5937a9b8311cc99304d6975f4a14f510fccb897f 100644 (file)
@@ -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 9eae1441888758c9a2fee28872af495834552e47..a325496cbe219487f4e9714bec69c0a6e25273e1 100644 (file)
--- 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);
 }