3
0

logging_and_backgrounding.txt 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. Total: 13 applets (+1 obsolete),
  41. 4 log to syslog by default (crond fakeidentd inetd zcip),
  42. 5 never log to syslog (acpid httpd telnetd klogd syslogd, last two
  43. - for obviously correct reasons),
  44. there are no daemons which always log to syslog,
  45. 12 auto-background if not run as inetd services (all except dnsd.
  46. Note that there is no "standard" dnsd AFAIKS). But see below
  47. for daemons (tcpsvd etc) which don't auto-background.
  48. miscutils/crond.c: logmode = LOGMODE_SYSLOG;
  49. networking/dnsd.c: logmode = LOGMODE_SYSLOG;
  50. networking/ftpd.c: logmode = LOGMODE_NONE;
  51. networking/ftpd.c: logmode |= LOGMODE_SYSLOG;
  52. networking/inetd.c: logmode = LOGMODE_SYSLOG;
  53. networking/isrv_identd.c: logmode = LOGMODE_SYSLOG;
  54. networking/telnetd.c: logmode = LOGMODE_SYSLOG;
  55. networking/udhcp/dhcpc.c: logmode = LOGMODE_NONE;
  56. networking/udhcp/dhcpc.c: logmode |= LOGMODE_SYSLOG;
  57. networking/udhcp/dhcpc.c: logmode &= ~LOGMODE_STDIO;
  58. networking/udhcp/dhcpd.c: logmode = LOGMODE_NONE;
  59. networking/udhcp/dhcpd.c: logmode |= LOGMODE_SYSLOG;
  60. networking/zcip.c: logmode |= LOGMODE_SYSLOG;
  61. These daemons never auto-background and never log to syslog:
  62. lpd - inetd service. Has nothing to log so far, though
  63. dhcprelay - standard behavior
  64. inotifyd - standard behavior
  65. runsv - standard behavior
  66. runsvdir - standard behavior
  67. svlogd - standard behavior
  68. tcpsvd, udpsvd - standard behavior
  69. tftpd - standard behavior
  70. Non-daemons (seems to be use syslog for a good reason):
  71. networking/nameif.c: logmode |= LOGMODE_SYSLOG;
  72. loginutils/chpasswd.c: logmode = LOGMODE_BOTH;
  73. loginutils/chpasswd.c: logmode = LOGMODE_STDIO;
  74. loginutils/getty.c: logmode = LOGMODE_BOTH;
  75. loginutils/getty.c: logmode = LOGMODE_NONE;
  76. loginutils/passwd.c: logmode = LOGMODE_STDIO;
  77. loginutils/passwd.c: logmode = LOGMODE_BOTH;
  78. loginutils/sulogin.c: logmode = LOGMODE_SYSLOG; (used if stdio isn't a tty)
  79. loginutils/sulogin.c: logmode = LOGMODE_BOTH;
  80. util-linux/mount.c: logmode = LOGMODE_SYSLOG; (used in a backgrounded NFS mount helper)