aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichel Stam <m.stam@fugro.nl>2014-11-04 12:19:04 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2014-11-04 12:19:04 +0100
commitd3fabf89d7d38a436672ac2deea7904351b1b12a (patch)
treebaae6201eb8c0b2b74a1732762c3034efcb4a00e
parentfdd957bdc9981cc2c1efb4452f55bb44a88cbfe0 (diff)
downloadbusybox-w32-d3fabf89d7d38a436672ac2deea7904351b1b12a.tar.gz
busybox-w32-d3fabf89d7d38a436672ac2deea7904351b1b12a.tar.bz2
busybox-w32-d3fabf89d7d38a436672ac2deea7904351b1b12a.zip
zcip: Add environment variable for overriding log functionality
function old new delta bb_logenv_override - 70 +70 packed_usage 29969 30033 +64 zcip_main 1426 1431 +5 ------------------------------------------------------------------------------ (add/remove: 2/0 grow/shrink: 2/0 up/down: 139/0) Total: 139 bytes Signed-off-by: Michel Stam <m.stam@fugro.nl> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--docs/logging_and_backgrounding.txt2
-rw-r--r--include/libbb.h1
-rw-r--r--libbb/Kbuild.src3
-rw-r--r--libbb/logenv.c24
-rw-r--r--networking/zcip.c5
5 files changed, 35 insertions, 0 deletions
diff --git a/docs/logging_and_backgrounding.txt b/docs/logging_and_backgrounding.txt
index 7e6885560..c76cd3653 100644
--- a/docs/logging_and_backgrounding.txt
+++ b/docs/logging_and_backgrounding.txt
@@ -45,6 +45,8 @@ udhcpc - auto-backgrounds unless -f after lease is obtained,
45udhcpd - auto-backgrounds and do not log to stderr unless -f, 45udhcpd - auto-backgrounds and do not log to stderr unless -f,
46 otherwise logs to stderr, but option -S makes it log *also* to syslog 46 otherwise logs to stderr, but option -S makes it log *also* to syslog
47zcip - auto-backgrounds and logs *also* to syslog unless -f 47zcip - auto-backgrounds and logs *also* to syslog unless -f
48 behaviour can be overridden with experimental LOGGING env.var
49 (can be set to either "none" or "syslog")
48 50
49Total: 13 applets (+1 obsolete), 51Total: 13 applets (+1 obsolete),
50 4 log to syslog by default (crond fakeidentd inetd zcip), 52 4 log to syslog by default (crond fakeidentd inetd zcip),
diff --git a/include/libbb.h b/include/libbb.h
index d57f00e0e..cc2bea32d 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1104,6 +1104,7 @@ extern void bb_perror_nomsg_and_die(void) NORETURN FAST_FUNC;
1104extern void bb_perror_nomsg(void) FAST_FUNC; 1104extern void bb_perror_nomsg(void) FAST_FUNC;
1105extern void bb_info_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))) FAST_FUNC; 1105extern void bb_info_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))) FAST_FUNC;
1106extern void bb_verror_msg(const char *s, va_list p, const char *strerr) FAST_FUNC; 1106extern void bb_verror_msg(const char *s, va_list p, const char *strerr) FAST_FUNC;
1107extern void bb_logenv_override(void) FAST_FUNC;
1107 1108
1108/* We need to export XXX_main from libbusybox 1109/* We need to export XXX_main from libbusybox
1109 * only if we build "individual" binaries 1110 * only if we build "individual" binaries
diff --git a/libbb/Kbuild.src b/libbb/Kbuild.src
index 0a9e803d7..f204816c5 100644
--- a/libbb/Kbuild.src
+++ b/libbb/Kbuild.src
@@ -187,3 +187,6 @@ lib-$(CONFIG_PGREP) += xregcomp.o
187lib-$(CONFIG_PKILL) += xregcomp.o 187lib-$(CONFIG_PKILL) += xregcomp.o
188lib-$(CONFIG_DEVFSD) += xregcomp.o 188lib-$(CONFIG_DEVFSD) += xregcomp.o
189lib-$(CONFIG_FEATURE_FIND_REGEX) += xregcomp.o 189lib-$(CONFIG_FEATURE_FIND_REGEX) += xregcomp.o
190
191# Add the experimental logging functionality, only used by zcip
192lib-$(CONFIG_ZCIP) += logenv.o
diff --git a/libbb/logenv.c b/libbb/logenv.c
new file mode 100644
index 000000000..66c60bd4e
--- /dev/null
+++ b/libbb/logenv.c
@@ -0,0 +1,24 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Utility routines.
4 *
5 * Copyright (C) 2014 by Fugro Intersite B.V. <m.stam@fugro.nl>
6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */
9#include "libbb.h"
10
11void FAST_FUNC bb_logenv_override(void)
12{
13 const char* mode = getenv("LOGGING");
14
15 if (!mode)
16 return;
17
18 if (strcmp(mode, "none") == 0)
19 logmode = LOGMODE_NONE;
20#if ENABLE_FEATURE_SYSLOG
21 else if (strcmp(mode, "syslog") == 0)
22 logmode = LOGMODE_SYSLOG;
23#endif
24}
diff --git a/networking/zcip.c b/networking/zcip.c
index 635d660b3..a3307c5c9 100644
--- a/networking/zcip.c
+++ b/networking/zcip.c
@@ -33,6 +33,9 @@
33//usage: "\n -l x.x.0.0 Use this range instead of 169.254" 33//usage: "\n -l x.x.0.0 Use this range instead of 169.254"
34//usage: "\n -v Verbose" 34//usage: "\n -v Verbose"
35//usage: "\n" 35//usage: "\n"
36//usage: "\n$LOGGING=none Suppress logging"
37//usage: "\n$LOGGING=syslog Log to syslog"
38//usage: "\n"
36//usage: "\nWith no -q, runs continuously monitoring for ARP conflicts," 39//usage: "\nWith no -q, runs continuously monitoring for ARP conflicts,"
37//usage: "\nexits only on I/O errors (link down etc)" 40//usage: "\nexits only on I/O errors (link down etc)"
38 41
@@ -249,6 +252,8 @@ int zcip_main(int argc UNUSED_PARAM, char **argv)
249 openlog(applet_name, 0, LOG_DAEMON); 252 openlog(applet_name, 0, LOG_DAEMON);
250 logmode |= LOGMODE_SYSLOG; 253 logmode |= LOGMODE_SYSLOG;
251 } 254 }
255 bb_logenv_override();
256
252 { // -l n.n.n.n 257 { // -l n.n.n.n
253 struct in_addr net; 258 struct in_addr net;
254 if (inet_aton(l_opt, &net) == 0 259 if (inet_aton(l_opt, &net) == 0