diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2000-04-16 07:29:42 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2000-04-16 07:29:42 +0000 |
commit | 9445ac66eef95c5d6274c8ca15a8b48c0c015b31 (patch) | |
tree | 6172312155eff03286fb1f00f9665b8f361a3c59 /env.c | |
parent | b9923882dd40ed3bc139ae0cf27bdc7b2d8ff560 (diff) | |
download | fetchmail-9445ac66eef95c5d6274c8ca15a8b48c0c015b31.tar.gz fetchmail-9445ac66eef95c5d6274c8ca15a8b48c0c015b31.tar.bz2 fetchmail-9445ac66eef95c5d6274c8ca15a8b48c0c015b31.zip |
FETCHMAILHOME
svn path=/trunk/; revision=2875
Diffstat (limited to 'env.c')
-rw-r--r-- | env.c | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -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); } |