aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1996-09-20 01:41:41 +0000
committerEric S. Raymond <esr@thyrsus.com>1996-09-20 01:41:41 +0000
commitb2ad72a23f867bcdc9a18802dc7989a8a9ae7ad1 (patch)
treebe4f10a36e809dcd43349e75b016b2a4cd86a435
parent8cb6a03929d5938918e5f04a805ef7fc3feb9241 (diff)
downloadfetchmail-b2ad72a23f867bcdc9a18802dc7989a8a9ae7ad1.tar.gz
fetchmail-b2ad72a23f867bcdc9a18802dc7989a8a9ae7ad1.tar.bz2
fetchmail-b2ad72a23f867bcdc9a18802dc7989a8a9ae7ad1.zip
Changed the lockfile location.
svn path=/trunk/; revision=100
-rw-r--r--NEWS2
-rw-r--r--fetchmail.c29
-rw-r--r--fetchmail.man11
3 files changed, 33 insertions, 9 deletions
diff --git a/NEWS b/NEWS
index f9ab2387..7a815aef 100644
--- a/NEWS
+++ b/NEWS
@@ -57,6 +57,8 @@ driver to SMTP. (This requires that we find a POP2 server to test with.)
* Add Michael Scwendt's code for improved sizeticker.
+* Move the per-user lockfile to /tmp so it gets cleared at reboot time.
+
* Warn users that running concurrent instances of popclient is a bad idea.
3.1:
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);
diff --git a/fetchmail.man b/fetchmail.man
index 9ddbb514..04a748d1 100644
--- a/fetchmail.man
+++ b/fetchmail.man
@@ -255,6 +255,11 @@ file specifies an RPOP id and a connection port in the privileged
range (1..1024),
.I popclient will
ship the id with an RPOP command rather than sending a password.
+(Note: you'll need to be running popclient setuid root for RPOP to
+work --
+.I popclient
+has to bind to a privileged port locally in order for the mail
+server to believe it's allowed to bind to a privileged remote port.)
.PP
.SH OUTPUT OPTIONS
The default behavior of
@@ -555,9 +560,13 @@ by Eric S. Raymond <esr@snark.thyrsus.com> and is now maintained by esr.
.TP 5
~/.poprc
default configuration file
+.TP 5
~/.popids
default location of file associating hosts with last message IDs seen
(used only with newer RFC1725-compliant servers supporting the UIDL command).
+.TP 5
+${TMPDIR}/poplock-${HOST}-${USER}
+lock file to help prevent concurrent runs.
.SH BUGS
Running more than one concurrent instance of
.I popclient
@@ -572,7 +581,7 @@ The --remotefolder option doesn't work with POP3, the protocol won't
support it.
.PP
The RPOP support, and the UIDL support for RFC1725-compliant servers
-without LAST, are not yet very well tested.
+without LAST, are not yet well tested.
.PP
Send comments, bug reports, gripes, and the like to Eric S. Raymond
<esr@thyrsus.com>.