ftpd: stop unconditional logging to syslog. This was the only applet
authorDenis Vlasenko <vda.linux@googlemail.com>
Wed, 11 Mar 2009 15:07:44 +0000 (15:07 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Wed, 11 Mar 2009 15:07:44 +0000 (15:07 -0000)
 which was doing it. Added option -S to enable it when desired.

function                                             old     new   delta
packed_usage                                       25647   25666     +19
ftpd_main                                           1826    1825      -1

docs/logging_and_backgrounding.txt
include/usage.h
networking/ftpd.c

index 39f0158837c2b0b5ff6f7aab8f973fb1d21c5952..62a6d15503281cbaf33e974b89b2b25742ec90dd 100644 (file)
@@ -27,18 +27,16 @@ acpid - auto-backgrounds unless -d
 crond - auto-backgrounds unless -f, logs to syslog unless -d or -L.
     option -d logs to stderr, -L FILE logs to FILE
 devfsd - (obsolete)
-dnsd - option -d makes it auto-background and log to syslog
+dnsd - option -d makes it background and log to syslog
 fakeidentd - inetd service. Auto-backgrounds and logs to syslog
     if no -f and no -i and no -w (-i is "inetd service" flag,
     -w is "inetd-wait service" flag)
-ftpd - inetd service. Logs to syslog always, with -v logs to strerr too
-httpd - auto-backgrounds unless -f or -i
-    (-i is "inetd service" flag)
+ftpd - inetd service. Logs to syslog with -S, with -v logs to strerr too
+httpd - auto-backgrounds unless -f or -i (-i is "inetd service" flag)
 inetd - auto-backgrounds unless -f, logs to syslog unless -e
 klogd - auto-backgrounds unless -n
 syslogd - auto-backgrounds unless -n
-telnetd - auto-backgrounds unless -f or -i
-    (-i is "inetd service" flag)
+telnetd - auto-backgrounds unless -f or -i (-i is "inetd service" flag)
 udhcpc - auto-backgrounds unless -f after lease is obtained,
     option -b makes it background sooner (when lease attempt
     fails and retries start),
@@ -48,9 +46,18 @@ udhcpd - auto-backgrounds and do not log to stderr unless -f,
     otherwise logs to stderr, but option -S makes it log *also* to syslog
 zcip - auto-backgrounds and logs *also* to syslog unless -f
 
+Total: 13 applets (+1 obsolete),
+ 4 log to syslog by default (crond fakeidentd inetd zcip),
+ 5 never log to syslog (acpid httpd telnetd klogd syslogd, last two
+ - for obviously correct reasons),
+ there are no daemons which always log to syslog,
+ 12 auto-background if not run as inetd servies (all except dnsd.
+ Note that there is no "standard" dnsd AFAIKS). But see below
+ for daemons (tcpsvd etc) which don't auto-background.
+
 miscutils/crond.c:            logmode = LOGMODE_SYSLOG;
 networking/dnsd.c:            logmode = LOGMODE_SYSLOG;
-networking/ftpd.c:            logmode = LOGMODE_SYSLOG;
+networking/ftpd.c:            logmode = LOGMODE_NONE;
 networking/ftpd.c:            logmode |= LOGMODE_SYSLOG;
 networking/inetd.c:           logmode = LOGMODE_SYSLOG;
 networking/isrv_identd.c:     logmode = LOGMODE_SYSLOG;
@@ -63,7 +70,7 @@ networking/udhcp/dhcpd.c:     logmode |= LOGMODE_SYSLOG;
 networking/zcip.c:            logmode |= LOGMODE_SYSLOG;
 
 
-These daemons seem to never auto-background/log to syslog:
+These daemons never auto-background and never log to syslog:
 
 lpd - inetd service. Has nothing to log so far, though
 dhcprelay - standard behavior
index b19803dfa37aa48cb23bc27ee306756ade558b37..e945840b846ab28d42049bffd5cadf895764a523 100644 (file)
      "\n       -f      Force file system check" \
 
 #define ftpd_trivial_usage \
-       "[-vw] [DIR]"
+       "[-wvS] [DIR]"
 #define ftpd_full_usage "\n\n" \
        "FTP server\n" \
        "\n" \
        "It also can be ran from tcpsvd:\n" \
        "       tcpsvd -vE 0.0.0.0 21 ftpd /files/to/serve\n" \
      "\nOptions:" \
-     "\n       -v      Log also to stderr" \
      "\n       -w      Allow upload" \
+     "\n       -v      Log to stderr" \
+     "\n       -S      Log to syslog" \
      "\n       DIR     Change root to this directory" \
 
 #define ftpget_trivial_usage \
index 29589d185caaed059904c9f3d5e8bc9138da3b19..3faa3ed7d8d7663834616a49f6b276312a2d166d 100644 (file)
@@ -80,7 +80,8 @@ enum {
        OPT_l = (1 << 0),
        OPT_1 = (1 << 1),
        OPT_v = (1 << 2),
-       OPT_w = (1 << 3),
+       OPT_S = (1 << 3),
+       OPT_w = (1 << 4),
 
 #define mk_const4(a,b,c,d) (((a * 0x100 + b) * 0x100 + c) * 0x100 + d)
 #define mk_const3(a,b,c)    ((a * 0x100 + b) * 0x100 + c)
@@ -806,7 +807,7 @@ int ftpd_main(int argc, char **argv)
 {
        smallint opts;
 
-       opts = getopt32(argv, "l1v" USE_FEATURE_FTP_WRITE("w"));
+       opts = getopt32(argv, "l1vS" USE_FEATURE_FTP_WRITE("w"));
 
        if (opts & (OPT_l|OPT_1)) {
                /* Our secret backdoor to ls */
@@ -828,11 +829,13 @@ int ftpd_main(int argc, char **argv)
                 * failure */
        }
 
-       /* LOG_NDELAY is needed since we may chroot later */
-       openlog(applet_name, LOG_PID | LOG_NDELAY, LOG_DAEMON);
-       logmode |= LOGMODE_SYSLOG;
        if (!(opts & OPT_v))
-               logmode = LOGMODE_SYSLOG;
+               logmode = LOGMODE_NONE;
+       if (opts & OPT_S) {
+               /* LOG_NDELAY is needed since we may chroot later */
+               openlog(applet_name, LOG_PID | LOG_NDELAY, LOG_DAEMON);
+               logmode |= LOGMODE_SYSLOG;
+       }
 
        G.proc_self_fd = xopen("/proc/self", O_RDONLY | O_DIRECTORY);