logging_and_backgrounding.txt 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. Logging and backgrounding
  2. By default, bb_[p]error_msg[_and_die] messages go to stderr,
  3. and of course, usually applets do not auto-background. :)
  4. Historically, daemons and inetd services are different.
  5. Busybox is trying to provide compatible behavior, thus if an applet
  6. is emulating an existing utility, it should mimic it. If utility
  7. auto-backgrounds itself, busybox applet should do the same.
  8. If utility normally logs to syslog, busybox applet should do
  9. the same too.
  10. However, busybox should not needlessly restrict the freedom
  11. of the users. And users have different needs and different preferences.
  12. Some might like logging everything from daemons to syslog.
  13. Others prefer running stuff under runsv/svlogd and thus would like
  14. logging to stderr and no daemonization.
  15. To help with that, busybox applets should have options to override
  16. default behavior, whatever that is for a given applet.
  17. Current situation is a bit of a mess:
  18. acpid - auto-backgrounds unless -d
  19. crond - auto-backgrounds unless -f, logs to syslog unless -d or -L.
  20. option -d logs to stderr, -L FILE logs to FILE
  21. devfsd - (obsolete)
  22. dnsd - option -d makes it background and log to syslog
  23. fakeidentd - inetd service. Auto-backgrounds and logs to syslog
  24. if no -f and no -i and no -w (-i is "inetd service" flag,
  25. -w is "inetd-wait service" flag)
  26. ftpd - inetd service. Logs to syslog with -S, with -v logs to strerr too
  27. httpd - auto-backgrounds unless -f or -i (-i is "inetd service" flag)
  28. inetd - auto-backgrounds unless -f, logs to syslog unless -e
  29. klogd - auto-backgrounds unless -n
  30. syslogd - auto-backgrounds unless -n
  31. telnetd - auto-backgrounds unless -f or -i (-i is "inetd service" flag)
  32. udhcpc - auto-backgrounds unless -f after lease is obtained,
  33. option -b makes it background sooner (when lease attempt
  34. fails and retries start),
  35. after backgrounding it stops logging to stderr;
  36. logs to stderr, but option -S makes it log *also* to syslog
  37. udhcpd - auto-backgrounds and do not log to stderr unless -f,
  38. otherwise logs to stderr, but option -S makes it log *also* to syslog
  39. zcip - auto-backgrounds and logs *also* to syslog unless -f
  40. behaviour can be overridden with experimental LOGGING env.var
  41. (can be set to either "none" or "syslog")
  42. Total: 13 applets (+1 obsolete),
  43. 4 log to syslog by default (crond fakeidentd inetd zcip),
  44. 5 never log to syslog (acpid httpd telnetd klogd syslogd, last two
  45. - for obviously correct reasons),
  46. there are no daemons which always log to syslog,
  47. 12 auto-background if not run as inetd services (all except dnsd.
  48. Note that there is no "standard" dnsd AFAIKS). But see below
  49. for daemons (tcpsvd etc) which don't auto-background.
  50. miscutils/crond.c: logmode = LOGMODE_SYSLOG;
  51. networking/dnsd.c: logmode = LOGMODE_SYSLOG;
  52. networking/ftpd.c: logmode = LOGMODE_NONE;
  53. networking/ftpd.c: logmode |= LOGMODE_SYSLOG;
  54. networking/inetd.c: logmode = LOGMODE_SYSLOG;
  55. networking/isrv_identd.c: logmode = LOGMODE_SYSLOG;
  56. networking/telnetd.c: logmode = LOGMODE_SYSLOG;
  57. networking/udhcp/dhcpc.c: logmode = LOGMODE_NONE;
  58. networking/udhcp/dhcpc.c: logmode |= LOGMODE_SYSLOG;
  59. networking/udhcp/dhcpc.c: logmode &= ~LOGMODE_STDIO;
  60. networking/udhcp/dhcpd.c: logmode = LOGMODE_NONE;
  61. networking/udhcp/dhcpd.c: logmode |= LOGMODE_SYSLOG;
  62. networking/zcip.c: logmode |= LOGMODE_SYSLOG;
  63. These daemons never auto-background and never log to syslog:
  64. lpd - inetd service. Has nothing to log so far, though
  65. dhcprelay - standard behavior
  66. inotifyd - standard behavior
  67. runsv - standard behavior
  68. runsvdir - standard behavior
  69. svlogd - standard behavior
  70. tcpsvd, udpsvd - standard behavior
  71. tftpd - standard behavior
  72. Non-daemons (seems to be use syslog for a good reason):
  73. networking/nameif.c: logmode |= LOGMODE_SYSLOG;
  74. loginutils/chpasswd.c: logmode = LOGMODE_BOTH;
  75. loginutils/chpasswd.c: logmode = LOGMODE_STDIO;
  76. loginutils/getty.c: logmode = LOGMODE_BOTH;
  77. loginutils/getty.c: logmode = LOGMODE_NONE;
  78. loginutils/passwd.c: logmode = LOGMODE_STDIO;
  79. loginutils/passwd.c: logmode = LOGMODE_BOTH;
  80. loginutils/sulogin.c: logmode = LOGMODE_SYSLOG; (used if stdio isn't a tty)
  81. loginutils/sulogin.c: logmode = LOGMODE_BOTH;
  82. util-linux/mount.c: logmode = LOGMODE_SYSLOG; (used in a backgrounded NFS mount helper)