]> Pileus Git - ~andy/fetchmail/blobdiff - fetchmail.c
Minor bug fixes for socket.c
[~andy/fetchmail] / fetchmail.c
index e3eebfdd109d12acc37b73d7a865f9b294f0d175..f7bcfd940e1abae19fbc45e9a262db6a3ea65f9e 100644 (file)
@@ -137,12 +137,16 @@ static void printcopyright(FILE *fp) {
        fprintf(fp, GT_("Copyright (C) 2002, 2003 Eric S. Raymond\n"
                   "Copyright (C) 2004 Matthias Andree, Eric S. Raymond,\n"
                   "                   Robert M. Funk, Graham Wilson\n"
-                  "Copyright (C) 2005 - 2006, 2010 Sunil Shetye\n"
-                  "Copyright (C) 2005 - 2010 Matthias Andree\n"
+                  "Copyright (C) 2005 - 2006, 2010 - 2012 Sunil Shetye\n"
+                  "Copyright (C) 2005 - 2012 Matthias Andree\n"
                   ));
        fprintf(fp, GT_("Fetchmail comes with ABSOLUTELY NO WARRANTY. This is free software, and you\n"
                   "are welcome to redistribute it under certain conditions. For details,\n"
                   "please see the file COPYING in the source or documentation directory.\n"));
+#ifdef SSL_ENABLE
+       /* Do not translate this */
+       fprintf(fp, "This product includes software developed by the OpenSSL Project\nfor use in the OpenSSL Toolkit. (http://www.openssl.org/)\n");
+#endif
 }
 
 const char *iana_charset;
@@ -303,9 +307,33 @@ 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 (run.logfile) {
+       /* nodetach -> turn off logfile option */
+       if (nodetach) {
+           if (outlevel >= O_NORMAL) { fprintf(stderr, GT_("The nodetach option is in effect, ignoring logfile option.\n")); }
+           xfree(run.logfile);
+       }
+
+#if 0
+       /* not in daemon mode -> turn off logfile option */
+       if (0 == run.poll_interval) {
+           if (outlevel >= O_NORMAL) { fprintf(stderr, GT_("Not running in daemon mode, ignoring logfile option.\n")); }
+           xfree(run.logfile);
+       }
+#endif
+
+       /* log file not writable -> turn off logfile option */
+       if (run.logfile && 0 != access(run.logfile, F_OK)) {
+           if (outlevel >= O_NORMAL) { fprintf(stderr, GT_("Logfile \"%s\" does not exist, ignoring logfile option.\n"), run.logfile); }
+           xfree(run.logfile);
+       }
+
+       /* log file not writable -> turn off logfile option */
+       if (run.logfile && 0 != access(run.logfile, W_OK)) {
+           fprintf(stderr, GT_("Logfile \"%s\" is not writable, aborting.\n"), run.logfile);
+           xfree(run.logfile);
+           exit(PS_UNDEFINED);
+       }
     }
 
 #if defined(HAVE_SYSLOG)
@@ -318,11 +346,18 @@ int main(int argc, char **argv)
        /* Assume BSD4.2 openlog with two arguments */
        openlog(program_name, LOG_PID);
 #endif
-       report_init(-1);
+       /* precedence: logfile (if effective) overrides syslog. */
+       if (run.logfile) {
+           syslog(LOG_ERR, GT_("syslog and logfile options are both set, ignoring syslog, and logging to %s"), run.logfile);
+           run.use_syslog = 0;
+           report_init((run.poll_interval == 0 || nodetach) && !run.logfile); /* when changing this, change copy below, too */
+       } else {
+           report_init(-1);
+       }
     }
     else
 #endif
-       report_init((run.poll_interval == 0 || nodetach) && !run.logfile);
+       report_init((run.poll_interval == 0 || nodetach) && !run.logfile); /* when changing this, change copy above, too */
 
 #ifdef POP3_ENABLE
     /* initialize UID handling */
@@ -597,14 +632,12 @@ int main(int argc, char **argv)
     else
     {
        /* not in daemon mode */
-       if (run.logfile && !nodetach && access(run.logfile, F_OK) == 0)
-       {
+       if (run.logfile)
+       {
            if (!freopen(run.logfile, "a", stdout))
                    report(stderr, GT_("could not open %s to append logs to\n"), run.logfile);
            if (!freopen(run.logfile, "a", stderr))
                    report(stdout, GT_("could not open %s to append logs to\n"), run.logfile);
-           if (run.use_syslog)
-               report(stdout, GT_("fetchmail: Warning: syslog and logfile are set. Check both for logs!\n"));
        }
     }
 
@@ -1644,7 +1677,7 @@ static void dump_params (struct runctl *runp,
            printf(GT_("  OTP authentication will be forced.\n"));
            break;
        case A_CRAM_MD5:
-           printf(GT_("  CRAM-Md5 authentication will be forced.\n"));
+           printf(GT_("  CRAM-MD5 authentication will be forced.\n"));
            break;
        case A_GSSAPI:
            printf(GT_("  GSSAPI authentication will be forced.\n"));