diff options
author | Matthias Andree <matthias.andree@gmx.de> | 2019-09-28 11:23:50 +0200 |
---|---|---|
committer | Matthias Andree <matthias.andree@gmx.de> | 2019-09-28 11:25:40 +0200 |
commit | b27a75cd05b681bbdd95396b2874303d6fed4ae0 (patch) | |
tree | 26928d947a780e2ecbc8a3525dfeafdd8d8eb6a8 /env.c | |
parent | 90f5c8459868840a591cb93fa88867705c0e7b24 (diff) | |
download | fetchmail-b27a75cd05b681bbdd95396b2874303d6fed4ae0.tar.gz fetchmail-b27a75cd05b681bbdd95396b2874303d6fed4ae0.tar.bz2 fetchmail-b27a75cd05b681bbdd95396b2874303d6fed4ae0.zip |
6.4.1, regression fix for default file locations.
The fix between 6.4.0-rc4 and 6.4.0 for Debian Bug#941129 caused
a regression in the default file locations, some files were looked
for without dot (.fetchmail.pid, .fetchmailrc).
Reported by Cy Schubert.
Diffstat (limited to 'env.c')
-rw-r--r-- | env.c | 34 |
1 files changed, 31 insertions, 3 deletions
@@ -110,15 +110,43 @@ void envquery(int argc, char **argv) endpwent(); + /* This documentation added to 6.4.1, + * and manual page corrected. + * + * here's the home directory logic: + * 1. we derive home. it is taken from: + * a. HOME_ETC + * b. HOME + * c. the user's passwd entry + * 2. we derive fmhome. It is normally + * a. home. + * b. It can be overridden from FETCHMAILHOME. + * If and only if fmhome != home, then the + * default configuration files will be expected + * without leading dots. + */ + /* compute user's home directory */ home = getenv("HOME_ETC"); - if (!home && !(home = getenv("HOME"))) + if (!home) + home = getenv("HOME"); + if (!home) home = xstrdup(pwp->pw_dir); + /* and make it an absolute path, so we + * can optionally chdir("/") later in daemonize() + * without changing behaviour. + */ + { + static char _home_abs[_POSIX_PATH_MAX]; + char *tmp = realpath(home, _home_abs); + if (tmp) home = _home_abs; + } /* compute fetchmail's home directory */ fmhome = getenv("FETCHMAILHOME"); if (NULL == fmhome) { fmhome = home; + at_home = 1; } /* and make it an absolute path, so we * can optionally chdir("/") later in daemonize() @@ -138,7 +166,7 @@ void envquery(int argc, char **argv) * 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)+2); + rcfile = (char *)xmalloc(strlen(fmhome) + sizeof(RCFILE_NAME) + 3); /* avoid //.fetchmailrc */ if (strcmp(fmhome, "/") != 0) strcpy(rcfile, fmhome); @@ -147,7 +175,7 @@ void envquery(int argc, char **argv) if (rcfile[strlen(rcfile) - 1] != '/') strcat(rcfile, "/"); - if (fmhome==home) + if (at_home) strcat(rcfile, "."); strcat(rcfile, RCFILE_NAME); } |