diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1996-09-20 01:41:41 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1996-09-20 01:41:41 +0000 |
commit | b2ad72a23f867bcdc9a18802dc7989a8a9ae7ad1 (patch) | |
tree | be4f10a36e809dcd43349e75b016b2a4cd86a435 /fetchmail.c | |
parent | 8cb6a03929d5938918e5f04a805ef7fc3feb9241 (diff) | |
download | fetchmail-b2ad72a23f867bcdc9a18802dc7989a8a9ae7ad1.tar.gz fetchmail-b2ad72a23f867bcdc9a18802dc7989a8a9ae7ad1.tar.bz2 fetchmail-b2ad72a23f867bcdc9a18802dc7989a8a9ae7ad1.zip |
Changed the lockfile location.
svn path=/trunk/; revision=100
Diffstat (limited to 'fetchmail.c')
-rw-r--r-- | fetchmail.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/fetchmail.c b/fetchmail.c index 64321b8a..95e41013 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -93,7 +93,7 @@ char **argv; int mboxfd, st; struct hostrec cmd_opts, def_opts; int parsestatus; - char *servername; + char *servername, *user, *tmpdir, tmpbuf[256]; FILE *tmpfp; pid_t pid; @@ -129,12 +129,26 @@ char **argv; hostlist = hostp; } + /* set up to do lock protocol */ + if ((tmpdir = getenv("TMPDIR")) == (char *)NULL) + tmpdir = "/tmp"; + strcpy(tmpbuf, tmpdir); + strcat(tmpbuf, "/poplock-"); + gethostname(tmpbuf + strlen(tmpbuf), HOSTLEN); + if ((user = getenv("USER")) != (char *)NULL) + { + strcat(tmpbuf, "-"); + strcat(tmpbuf, user); + } + /* perhaps we just want to check options? */ if (versioninfo) { printf("Taking options from command line and %s\n", poprcfile); for (hostp = hostlist; hostp; hostp = hostp->next) { printf("Options for host %s:\n", hostp->servername); dump_params(hostp); + if (outlevel == O_VERBOSE) + printf(" Lockfile at %s\n", tmpbuf); } if (hostlist == NULL) (void) printf("No mailservers set up -- perhaps %s is missing?\n", @@ -146,15 +160,13 @@ char **argv; exit(PS_SYNTAX); } - /* set up to do lock protocol */ - umask(0077); - if ((lockfile = (char *) malloc( strlen(getenv("HOME")) + strlen("/.lockfetch-") + HOSTLEN)) == NULL) { - fprintf(stderr,"popclient: cannot allocate memory for .lockfetch, exiting.\n"); + if ((lockfile = (char *) malloc(strlen(tmpbuf) + 1)) == NULL) + { + fprintf(stderr,"popclient: cannot allocate memory for lock name.\n"); exit(PS_EXCLUDE); } - strcpy(lockfile, getenv("HOME")); - strcat(lockfile,"/.lockfetch-"); - gethostname(lockfile+strlen(lockfile),HOSTLEN); + else + (void) strcpy(lockfile, tmpbuf); /* perhaps user asked us to remove a lock */ if (quitmode) @@ -180,6 +192,7 @@ char **argv; /* beyond here we don't want more than one popclient running per user */ + umask(0077); if ( (tmpfp = fopen(lockfile, "r")) != NULL ) { fscanf(tmpfp,"%d",&pid); fprintf(stderr,"Another session appears to be running at pid %d.\nIf you are sure that this is incorrect, remove %s file.\n",pid,lockfile); |