summaryrefslogtreecommitdiffhomepage
path: root/docs/logging_and_backgrounding.txt
blob: 7e6885560847429b30fbccc889a299cf387b738d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
	Logging and backgrounding

By default, bb_[p]error_msg[_and_die] messages go to stderr,
and of course, usually applets do not auto-background. :)

Historically, daemons and inetd services are different.

Busybox is trying to provide compatible behavior, thus if an applet
is emulating an existing utility, it should mimic it. If utility
auto-backgrounds itself, busybox applet should do the same.
If utility normally logs to syslog, busybox applet should do
the same too.

However, busybox should not needlessly restrict the freedom
of the users. And users have different needs and different preferences.
Some might like logging everything from daemons to syslog.
Others prefer running stuff under runsv/svlogd and thus would like
logging to stderr and no daemonization.

To help with that, busybox applets should have options to override
default behavior, whatever that is for a given applet.


Current situation is a bit of a mess:

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 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 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)
udhcpc - auto-backgrounds unless -f after lease is obtained,
    option -b makes it background sooner (when lease attempt
    fails and retries start),
    after backgrounding it stops logging to stderr;
    logs to stderr, but option -S makes it log *also* to syslog
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 services (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_NONE;
networking/ftpd.c:            logmode |= LOGMODE_SYSLOG;
networking/inetd.c:           logmode = LOGMODE_SYSLOG;
networking/isrv_identd.c:     logmode = LOGMODE_SYSLOG;
networking/telnetd.c:         logmode = LOGMODE_SYSLOG;
networking/udhcp/dhcpc.c:     logmode = LOGMODE_NONE;
networking/udhcp/dhcpc.c:     logmode |= LOGMODE_SYSLOG;
networking/udhcp/dhcpc.c:     logmode &= ~LOGMODE_STDIO;
networking/udhcp/dhcpd.c:     logmode = LOGMODE_NONE;
networking/udhcp/dhcpd.c:     logmode |= LOGMODE_SYSLOG;
networking/zcip.c:            logmode |= LOGMODE_SYSLOG;


These daemons never auto-background and never log to syslog:

lpd - inetd service. Has nothing to log so far, though
dhcprelay - standard behavior
inotifyd - standard behavior
runsv - standard behavior
runsvdir - standard behavior
svlogd - standard behavior
tcpsvd, udpsvd - standard behavior
tftpd - standard behavior


Non-daemons (seems to be use syslog for a good reason):

networking/nameif.c:          logmode |= LOGMODE_SYSLOG;
loginutils/chpasswd.c:        logmode = LOGMODE_BOTH;
loginutils/chpasswd.c:        logmode = LOGMODE_STDIO;
loginutils/getty.c:           logmode = LOGMODE_BOTH;
loginutils/getty.c:           logmode = LOGMODE_NONE;
loginutils/passwd.c:          logmode = LOGMODE_STDIO;
loginutils/passwd.c:          logmode = LOGMODE_BOTH;
loginutils/sulogin.c:         logmode = LOGMODE_SYSLOG; (used if stdio isn't a tty)
loginutils/sulogin.c:         logmode = LOGMODE_BOTH;
util-linux/mount.c:           logmode = LOGMODE_SYSLOG; (used in a backgrounded NFS mount helper)