From 9445ac66eef95c5d6274c8ca15a8b48c0c015b31 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 16 Apr 2000 07:29:42 +0000 Subject: FETCHMAILHOME svn path=/trunk/; revision=2875 --- env.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'env.c') diff --git a/env.c b/env.c index 6c455d58..8911bc21 100644 --- a/env.c +++ b/env.c @@ -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); } -- cgit v1.2.3