diff options
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | fetchmail-features.html | 8 | ||||
-rw-r--r-- | fetchmail.c | 50 | ||||
-rw-r--r-- | fetchmail.man | 17 |
4 files changed, 63 insertions, 14 deletions
@@ -9,6 +9,8 @@ a Certifying Authority we recognize?). (The `lines' figures total .c, .h, .l, and .y files under version control.) +* Arrange for fetchmail to restart itself quietly when the rc file is touched. + fetchmail-5.2.1 (Sun Dec 19 23:08:53 EST 1999), 18330 lines: * Added FAQ item R10 on timeouts during messages. * Fixed indentation problem in fetchmailconf. diff --git a/fetchmail-features.html b/fetchmail-features.html index 68d745f8..4f24b622 100644 --- a/fetchmail-features.html +++ b/fetchmail-features.html @@ -10,7 +10,7 @@ <table width="100%" cellpadding=0><tr> <td width="30%">Back to <a href="index.html">Fetchmail Home Page</a> <td width="30%" align=center>To <a href="/~esr/sitemap.html">Site Map</a> -<td width="30%" align=right>$Date: 1999/12/19 20:11:48 $ +<td width="30%" align=right>$Date: 1999/12/21 03:45:26 $ </table> <HR> @@ -18,6 +18,10 @@ <H2>Since 5.0:</H2> <UL> +<LI> +Fetchmail running in daemon mode now restarts itself quietly when the +rc file is touched. + <LI>Following recent court decisions and changes in U.S. federal regulatory policy, hooks for Secure Sockets Layer (SSL) are now part of the main fetchmail distribution. The distribution still contains @@ -184,7 +188,7 @@ get-mail, gwpop, pimp-1.0, pop-perl5-1.2, popc, popmail-1.6 and upop.<P> <table width="100%" cellpadding=0><tr> <td width="30%">Back to <a href="index.html">Fetchmail Home Page</a> <td width="30%" align=center>To <a href="/~esr/sitemap.html">Site Map</a> -<td width="30%" align=right>$Date: 1999/12/19 20:11:48 $ +<td width="30%" align=right>$Date: 1999/12/21 03:45:26 $ </table> <P><ADDRESS>Eric S. Raymond <A HREF="mailto:esr@thyrsus.com"><esr@snark.thyrsus.com></A></ADDRESS> diff --git a/fetchmail.c b/fetchmail.c index f491e92e..174e80b6 100644 --- a/fetchmail.c +++ b/fetchmail.c @@ -83,6 +83,7 @@ static char *lockfile; /* name of lockfile */ static int querystatus; /* status of query */ static int successes; /* count number of successful polls */ static struct runctl cmd_run; /* global options set from command line */ +static time_t parsetime; /* time of last parse */ static void termhook(int); /* forward declaration of exit hook */ @@ -229,9 +230,7 @@ int main(int argc, char **argv) printf("+NETSEC"); #endif /* NET_SECURITY */ #ifdef HAVE_SOCKS - #if HAVE_SOCKS printf("+SOCKS"); - #endif #endif /* HAVE_SOCKS */ #if ENABLE_NLS printf("+NLS"); @@ -427,9 +426,13 @@ int main(int argc, char **argv) } else if (argc > 1) { - fprintf(stderr, - _("fetchmail: can't accept options while a background fetchmail is running.\n")); - return(PS_EXCLUDE); + /* this test enables re-execing on a changed rcfile */ + if (getpid() != pid) + { + fprintf(stderr, + _("fetchmail: can't accept options while a background fetchmail is running.\n")); + return(PS_EXCLUDE); + } } else if (kill(pid, SIGUSR1) == 0) { @@ -474,15 +477,13 @@ int main(int argc, char **argv) } } -/* Time to initiate the SOCKS library (this is not mandatory: it just - registers the correct application name for logging purpose. If you - have some problem, comment these lines). */ + /* + * Time to initiate the SOCKS library (this is not mandatory: it just + * registers the correct application name for logging purpose. If you + * have some problem, comment out these lines). + */ #ifdef HAVE_SOCKS - #if HAVE_SOCKS -/* Mmmh... I don't like hardcoded application names, - but "fetchmail" is everywhere... */ SOCKSinit("fetchmail"); - #endif #endif /* HAVE_SOCKS */ /* @@ -550,6 +551,24 @@ int main(int argc, char **argv) * reflect the status of that transaction. */ do { + /* + * Check to see if the rcfile has been touched. If so, + * re-exec so the file will be reread. Doing it this way + * avoids all the complications of trying to deallocate the + * in-core control structures -- and the potential memory + * leaks... + */ + struct stat rcstat; + + if (stat(rcfile, &rcstat) == -1) + report(stderr, _("couldn't time-check the run-control file\n")); + else if (rcstat.st_mtime > parsetime) + { + report(stdout, _("restarting fetchmail (rc file changed)\n")); + execvp("fetchmail", argv); + report(stderr, _("attempt to re-exec fetchmail failed\n")); + } + #if defined(HAVE_RES_SEARCH) && defined(USE_TCPIP_FOR_DNS) /* * This was an efficiency hack that backfired. The theory @@ -895,6 +914,7 @@ static int load_params(int argc, char **argv, int optind) int implicitmode, st; struct passwd *pw; struct query def_opts, *ctl; + struct stat rcstat; run.bouncemail = TRUE; @@ -914,6 +934,12 @@ static int load_params(int argc, char **argv, int optind) def_opts.remotename = user; def_opts.listener = SMTP_MODE; + /* note the parse time, so we can pick up on modifications */ + if (stat(rcfile, &rcstat) == -1) + report(stderr, _("couldn't time-check the run-control file\n")); + else + parsetime = rcstat.st_mtime; + /* this builds the host list */ if ((st = prc_parse_file(rcfile, !versioninfo)) != 0) exit(st); diff --git a/fetchmail.man b/fetchmail.man index 39e58312..edc08fd1 100644 --- a/fetchmail.man +++ b/fetchmail.man @@ -842,6 +842,18 @@ fetched (and thus marked seen by the mailserver) but not delivered locally due to some transient error, it will be re-fetched during the next poll cycle. (The IMAP logic doesn't delete messages until they're delivered, so this problem does not arise.) +.PP +If you touch or change the +.I .fetchmailrc +file while fetchmail is running in daemon mode, this will be detected +at the beginning of the next poll cycle. When a changed +.I .fetchmailrc +is detected, fetchmail rereads it and restarts from scratch (using +exec(2); no state information is retained in the new instance). Note also +that if you break the +.I .fetchmailrc +file's syntax, the new instance will softly and silently vanish away +on startup. .SH ADMINISTRATIVE OPTIONS .PP @@ -909,6 +921,11 @@ messages are appended to the end of the mailbox; when this is not true it may treat some old messages as new and vice versa. The only real fix for this problem is to switch to IMAP. .PP +Yet another POP3 problem is that if they can't make tempfiles in the +user's home directory, some POP3 servers will hand back an +undocumented response that causes fetchmail to spuriously report "No +mail". +.PP The IMAP code uses the presence or absence of the server flag \eSeen to decide whether or not a message is new. Under Unix, it counts on your IMAP server to notice the BSD-style Status flags set by mail user |