* fetchmailconf -V now prints the fetchmailconf version. Matthias Andree
* Add support for SubjectAltName (RFC-2595 or 2818), to avoid bogus certificate
mismatch errors. Patch by Roland Stigge, Debian Bug#201113. (MA)
+* make fetchmail --silent --quit really silent, Debian Bug #229014 by Dr.
+ Andreas Krüger. Matthias Andree
+* cleanup --quit handling again (so that --silent --quit just kills the
+ existing daemon, rather than continue running), and document it more clearly.
+ Matthias Andree
+* Print an error message if multiple "defaults" records are found in the
+ configuration file. Matthias Andree
# INTERNAL CHANGES
* Switched to automake. Matthias Andree.
struct runctl run; /* global controls for this run */
flag nodetach; /* if TRUE, don't detach daemon process */
flag quitmode; /* if --quit was set */
+int quitind; /* optind after position of last --quit option */
flag check_only; /* if --probe was set */
flag versioninfo; /* emit only version info */
char *user; /* the name of the invoking user */
flag configdump; /* dump control blocks for configurator */
char *fetchmailhost; /* either `localhost' or the host's FQDN */
+static int quitonly; /* if we should quit after killing the running daemon */
+
static int querystatus; /* status of query */
static int successes; /* count number of successful polls */
static int activecount; /* count number of active entries */
}
#endif
- if ((parsecmdline(argc,argv, &cmd_run, &cmd_opts)) < 0)
- exit(PS_SYNTAX);
+ {
+ int i;
+
+ i = parsecmdline(argc, argv, &cmd_run, &cmd_opts);
+ if (i < 0)
+ exit(PS_SYNTAX);
+
+ if (quitmode && quitind == argc)
+ quitonly = 1;
+ }
if (versioninfo)
{
system("uname -a");
}
- /* avoid parsing the config file if all we're doing is killing a daemon */
- if (!(quitmode && argc == 2))
+ /* avoid parsing the config file if all we're doing is killing a daemon */
+ if (!quitonly)
implicitmode = load_params(argc, argv, optind);
#if defined(HAVE_SYSLOG)
pid = bkgd ? -pid : pid;
/* if no mail servers listed and nothing in background, we're done */
- if (!(quitmode && argc == 2) && pid == 0 && querylist == NULL) {
+ if (!quitonly && pid == 0 && querylist == NULL) {
(void)fputs(GT_("fetchmail: no mailservers have been specified.\n"),stderr);
exit(PS_SYNTAX);
}
/* perhaps user asked us to kill the other fetchmail */
if (quitmode)
{
- if (pid == 0)
+ if (pid == 0 || pid == getpid())
+ /* this test enables re-execing on a changed rcfile
+ * for pid == getpid() */
{
- fprintf(stderr,GT_("fetchmail: no other fetchmail is running\n"));
- if (argc == 2)
- exit(PS_EXCLUDE);
- }
- else if (getpid() == pid)
- {
- /* this test enables re-execing on a changed rcfile */
- if (argc == 2)
- {
+ if (quitonly) {
fprintf(stderr,GT_("fetchmail: no other fetchmail is running\n"));
exit(PS_EXCLUDE);
}
}
else
{
- fprintf(stderr,GT_("fetchmail: %s fetchmail at %d killed.\n"),
- bkgd ? GT_("background") : GT_("foreground"), pid);
+ if (outlevel > O_SILENT)
+ fprintf(stderr,GT_("fetchmail: %s fetchmail at %d killed.\n"),
+ bkgd ? GT_("background") : GT_("foreground"), pid);
fm_lock_release();
- if (argc == 2)
+ if (quitonly)
exit(0);
else
pid = 0;
#undef FLAG_MERGE
}
+/** Load configuration files.
+ * \return - true if no servers found on the command line
+ * - false if servers found on the command line */
static int load_params(int argc, char **argv, int optind)
{
int implicitmode, st;
}
/* don't allow a defaults record after the first */
- for (ctl = querylist; ctl; ctl = ctl->next)
- if (ctl != querylist && strcmp(ctl->server.pollname, "defaults") == 0)
+ for (ctl = querylist; ctl; ctl = ctl->next) {
+ if (ctl != querylist && strcmp(ctl->server.pollname, "defaults") == 0) {
+ fprintf(stderr, GT_("fetchmail: Error: multiple \"defaults\" records in config file.\n"));
exit(PS_SYNTAX);
+ }
+ }
/* use localhost if we never fetch the FQDN of this host */
fetchmailhost = "localhost";
authentication or multiple timeouts.
.PP
The option
-.B --quit
+.B \-\-quit
will kill a running daemon process instead of waking it up (if there
-is no such process,
-.I fetchmail
-notifies you). If the --quit option is the only command-line option,
-that's all there is to it.
-.PP
-The quit option may also be mixed with other command-line options; its
-effect is to kill any running daemon before doing what the other
-options specify in combination with the fetchmailrc file.
+is no such process, \fIfetchmail\fP will notify you.
+If the \-\-quit option appears last on the command line, \fIfetchmail\fP
+will kill the running daemon process and then quit. Otherwise,
+\fIfetchmail\fP will first kill a running daemon process and then
+continue running with the other options.
.PP
The
.B \-L <filename>
.PP
The
.B \-N
-or --nodetach option suppresses backgrounding and detachment of the
+or
+.B --nodetach
+option suppresses backgrounding and detachment of the
daemon process from its control terminal. This is useful
for debugging or when fetchmail runs as the child of a supervisor
process such as