aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Andree <matthias.andree@gmx.de>2009-05-29 07:53:59 +0000
committerMatthias Andree <matthias.andree@gmx.de>2009-05-29 07:53:59 +0000
commite168a13ce589300db74c09e82bbe63c1297a1274 (patch)
tree7d64b648a2ce43783c0a8945c591e1dbd1c89240
parent01c9b0afb3e30324f2984cece695f79b925d7a9f (diff)
downloadfetchmail-e168a13ce589300db74c09e82bbe63c1297a1274.tar.gz
fetchmail-e168a13ce589300db74c09e82bbe63c1297a1274.tar.bz2
fetchmail-e168a13ce589300db74c09e82bbe63c1297a1274.zip
Let logfile take precedence over syslog if and only if logfile is effective.
svn path=/branches/BRANCH_6-3/; revision=5349
-rw-r--r--NEWS4
-rw-r--r--fetchmail.c12
-rw-r--r--fetchmail.man14
-rw-r--r--report.c9
4 files changed, 24 insertions, 15 deletions
diff --git a/NEWS b/NEWS
index be8d6e0f..4c179773 100644
--- a/NEWS
+++ b/NEWS
@@ -97,6 +97,10 @@ fetchmail 6.3.10 (not yet released):
errors. Partially taken from Petr Cerny's patch in Novell Bugzilla #246829.
The 501 part of said patch was not added, as the maintainer is not convinced
501 is a temporary condition, and softbounce takes care of this anyways.
+* Proper precedence ordering for the syslog and logfile options. If the logfile
+ option is effective (i. e. we're not in daemon mode and nodetach isn't used),
+ kill the syslog option. If logfile is ineffective (we're not in daemon mode,
+ or nodetach is set), syslog takes precedence.
# CHANGES
* Make the comparison of the SSL fingerprints case insensitive, to
diff --git a/fetchmail.c b/fetchmail.c
index 7fa836b4..ad02b700 100644
--- a/fetchmail.c
+++ b/fetchmail.c
@@ -302,6 +302,11 @@ int main(int argc, char **argv)
if (!quitonly)
implicitmode = load_params(argc, argv, optind);
+ /* precedence: logfile (if effective) overrides syslog. */
+ if (run.logfile && run.poll_interval && !nodetach) {
+ run.use_syslog = 0;
+ }
+
#if defined(HAVE_SYSLOG)
/* logging should be set up early in case we were restarted from exec */
if (run.use_syslog)
@@ -556,8 +561,13 @@ int main(int argc, char **argv)
/* avoid zombies from plugins */
deal_with_sigchld();
+ /* Fix up log destination - if the if() is true, the precedence rule
+ * above hasn't killed off the syslog option, because the logfile
+ * option is ineffective (because we're not detached or not in
+ * deamon mode), so kill it for the benefit of other parts of the
+ * code. */
if (run.logfile && run.use_syslog)
- fprintf(stderr, GT_("fetchmail: Warning: syslog and logfile are set. Check both for logs!\n"));
+ run.logfile = 0;
/*
* Maybe time to go to demon mode...
diff --git a/fetchmail.man b/fetchmail.man
index da05a51e..9db9d1e8 100644
--- a/fetchmail.man
+++ b/fetchmail.man
@@ -1224,9 +1224,8 @@ The
or
.B \-\-logfile <filename>
option (keyword: set logfile) is only effective when fetchmail is
-detached and in daemon mode. Note that the logfile must exist BEFORE
-fetchmail is run, you
-can use the
+detached and in daemon mode. Note that \fBthe logfile must exist
+before\fP fetchmail is run, you can use the
.BR touch (1)
command with the filename as its sole argument to create it.
.br
@@ -1255,11 +1254,7 @@ The
.B \-\-nosyslog
option turns off use of
.BR syslog (3),
-assuming it's turned on in the \fI~/.fetchmailrc\fP file, or that the
-.B \-L
-or
-.B \-\-logfile <file>
-option was used.
+assuming it's turned on in the \fI~/.fetchmailrc\fP file.
.PP
The
.B \-N
@@ -2112,7 +2107,8 @@ There are some global option statements: 'set logfile'
followed by a string sets the same global specified by \-\-logfile. A
command-line \-\-logfile option will override this. Note that \-\-logfile is
only effective if fetchmail detaches itself from the terminal and the
-logfile already exists before fetchmail is run. Also,
+logfile already exists before fetchmail is run, and it overrides
+\-\-syslog in this case. Also,
\&'set daemon' sets the poll interval as \-\-daemon does. This can be
overridden by a command-line \-\-daemon option; in particular \-\-daemon\~0
can be used to force foreground operation. The 'set postmaster'
diff --git a/report.c b/report.c
index fa1ce4ad..f8f2187f 100644
--- a/report.c
+++ b/report.c
@@ -149,12 +149,11 @@ report (FILE *errfp, message, va_alist)
}
}
-/*
- * Calling report_init(1) causes report_build and report_complete to write
- * to errfp without buffering. This is needed for the ticker dots to
- * work correctly.
+/**
+ * Configure the report module. The output is set according to
+ * \a mode.
*/
-void report_init(int mode)
+void report_init(int mode /** 0: regular output, 1: unbuffered output, -1: syslog */)
{
switch(mode)
{