diff options
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | env.c | 21 | ||||
-rw-r--r-- | fetchmail.c | 15 | ||||
-rw-r--r-- | fetchmail.h | 1 | ||||
-rw-r--r-- | fetchmail.man | 15 |
5 files changed, 40 insertions, 14 deletions
@@ -6,6 +6,8 @@ * Galician translation added, courtesy of Jesus Bravo Alvarez <jba@pobox.com>. * Spanish translation updated, courtesy of Javier Kohen. * Removed an unnecessary Kereberos check that seemed to be causing lossage. +* FETCHMAILHOME environment variable introduced to optionally override the + normal $HOME location of fetchmail's rc, id, and pid files. fetchmail-5.3.6 (Sat Apr 8 03:54:04 EDT 2000), 18947 lines: @@ -75,23 +75,36 @@ void envquery(int argc, char **argv) user = xstrdup(pwp->pw_name); } + /* compute user's home directory */ if (!(home = getenv("HOME"))) home = pwp->pw_dir; + /* compute fetchmail's home directory */ + if (!(fmhome = getenv("FETCHMAILHOME"))) + fmhome = home; + if ((program_name = strrchr(argv[0], '/')) != NULL) ++program_name; else program_name = argv[0]; -#define RCFILE_NAME ".fetchmailrc" - rcfile = (char *) xmalloc(strlen(home)+sizeof(RCFILE_NAME)+1); +#define RCFILE_NAME "fetchmailrc" + /* + * The (fmhome==home) leaves an extra character for a . at the + * beginning of the rc file's name, iff fetchmail is using $HOME + * for its files. We don't want to do that if fetchmail has its + * own home ($FETCHMAILHOME), however. + */ + rcfile = (char *)xmalloc(strlen(fmhome)+sizeof(RCFILE_NAME)+(fmhome==home)+1); /* avoid //.fetchmailrc */ - if (strcmp(home, "/") != 0) { - strcpy(rcfile, home); + if (strcmp(fmhome, "/") != 0) { + strcat(rcfile, fmhome); } else { *rcfile = '\0'; } strcat(rcfile, "/"); + if (fmhome==home) + strcat(rcfile, "."); strcat(rcfile, RCFILE_NAME); } diff --git a/fetchmail.c b/fetchmail.c index f7428211..75f2bf14 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -69,6 +69,7 @@ flag check_only; /* if --probe was set */ flag versioninfo; /* emit only version info */ char *user; /* the name of the invoking user */ char *home; /* invoking user's home directory */ +char *fmhome; /* fetchmail's home directory */ char *program_name; /* the name to prefix error messages with */ flag configdump; /* dump control blocks for configurator */ const char *fetchmailhost; /* either `localhost' or the host's FQDN */ @@ -157,8 +158,8 @@ int main(int argc, char **argv) } #define IDFILE_NAME ".fetchids" - run.idfile = (char *) xmalloc(strlen(home)+sizeof(IDFILE_NAME)+1); - strcpy(run.idfile, home); + run.idfile = (char *) xmalloc(strlen(fmhome)+sizeof(IDFILE_NAME)+1); + strcpy(run.idfile, fmhome); strcat(run.idfile, "/"); strcat(run.idfile, IDFILE_NAME); @@ -261,9 +262,11 @@ int main(int argc, char **argv) sizeof(PID_DIR) + sizeof(FETCHMAIL_PIDFILE)); sprintf(tmpbuf, "%s/%s", PID_DIR, FETCHMAIL_PIDFILE); } else { - xalloca(tmpbuf, char *, strlen(home) + sizeof(FETCHMAIL_PIDFILE) + 2); - strcpy(tmpbuf, home); - strcat(tmpbuf, "/."); + xalloca(tmpbuf, char *, strlen(fmhome) + sizeof(FETCHMAIL_PIDFILE) + 2); + strcpy(tmpbuf, fmhome); + strcat(tmpbuf, "/"); + if (fmhome == home) + strcat(tmpbuf, "."); strcat(tmpbuf, FETCHMAIL_PIDFILE); } #undef FETCHMAIL_PIDFILE @@ -285,7 +288,7 @@ int main(int argc, char **argv) #define NETRC_FILE ".netrc" /* parse the ~/.netrc file (if present) for future password lookups. */ - xalloca(netrc_file, char *, strlen (home) + sizeof(NETRC_FILE) + 1); + xalloca(netrc_file, char *, strlen(home) + sizeof(NETRC_FILE) + 1); strcpy (netrc_file, home); strcat (netrc_file, "/"); strcat (netrc_file, NETRC_FILE); diff --git a/fetchmail.h b/fetchmail.h index 48e2dc63..c91f834d 100644 --- a/fetchmail.h +++ b/fetchmail.h @@ -351,6 +351,7 @@ extern int linelimit; /* limit # lines retrieved per site */ extern flag versioninfo; /* emit only version info */ extern char *user; /* name of invoking user */ extern char *home; /* home directory of invoking user */ +extern char *fmhome; /* fetchmail home directory */ extern int pass; /* number of re-polling pass */ extern flag configdump; /* dump control blocks as Python dictionary */ extern const char *fetchmailhost; diff --git a/fetchmail.man b/fetchmail.man index 49307bb7..4b35fa8a 100644 --- a/fetchmail.man +++ b/fetchmail.man @@ -1911,13 +1911,13 @@ default location of file associating hosts with last message IDs seen (used only with newer RFC1725-compliant POP3 servers supporting the UIDL command). .TP 5 +~/.fetchmail.pid +lock file to help prevent concurrent runs (non-root mode). +.TP 5 ~/.netrc your FTP run control file, which (if present) will be searched for passwords as a last resort before prompting for one interactively. .TP 5 -~/.fetchmail.pid -lock file to help prevent concurrent runs (non-root mode). -.TP 5 /var/run/fetchmail.pid lock file to help prevent concurrent runs (root mode, Linux systems). .TP 5 @@ -1925,13 +1925,20 @@ 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 and the variable is correctly set +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 +\&.fetchmail.pid files are put there instead of in the invoking user's +home directory (and lose the leading dots on theirt names). The +.netrc file is looked for in the the invoking user's home directory +regardless of FETCHMAILHOME's setting. + .SH SIGNALS If a .I fetchmail |