diff options
author | Eric Andersen <andersen@codepoet.org> | 2000-12-08 19:52:01 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2000-12-08 19:52:01 +0000 |
commit | bf2b8ae49aa885929bcb20983dd98196416bcc12 (patch) | |
tree | b33a6a54e6dff87eea8db758a7aab9027aef1206 | |
parent | 76fef0a5d02800afa368b79abf4393eda46abc4c (diff) | |
download | busybox-w32-bf2b8ae49aa885929bcb20983dd98196416bcc12.tar.gz busybox-w32-bf2b8ae49aa885929bcb20983dd98196416bcc12.tar.bz2 busybox-w32-bf2b8ae49aa885929bcb20983dd98196416bcc12.zip |
Make no local logging a runtime option for network logging...
-rw-r--r-- | applets/usage.c | 1 | ||||
-rw-r--r-- | docs/busybox.pod | 7 | ||||
-rw-r--r-- | docs/busybox.sgml | 1 | ||||
-rw-r--r-- | sysklogd/syslogd.c | 57 | ||||
-rw-r--r-- | syslogd.c | 57 | ||||
-rw-r--r-- | usage.c | 1 |
6 files changed, 69 insertions, 55 deletions
diff --git a/applets/usage.c b/applets/usage.c index 35d69df42..75c421a09 100644 --- a/applets/usage.c +++ b/applets/usage.c | |||
@@ -1176,6 +1176,7 @@ const char syslogd_usage[] = | |||
1176 | "\t-O FILE\t\tUse an alternate log file (default=/var/log/messages)\n" | 1176 | "\t-O FILE\t\tUse an alternate log file (default=/var/log/messages)\n" |
1177 | #ifdef BB_FEATURE_REMOTE_LOG | 1177 | #ifdef BB_FEATURE_REMOTE_LOG |
1178 | "\t-R HOST[:PORT]\t\tLog remotely to IP or hostname on PORT (default PORT=514/UDP)\n" | 1178 | "\t-R HOST[:PORT]\t\tLog remotely to IP or hostname on PORT (default PORT=514/UDP)\n" |
1179 | "\t-N\t\tDo not log anything locally -- network logging only.\n" | ||
1179 | #endif | 1180 | #endif |
1180 | #endif | 1181 | #endif |
1181 | ; | 1182 | ; |
diff --git a/docs/busybox.pod b/docs/busybox.pod index d518c550c..9b92d1981 100644 --- a/docs/busybox.pod +++ b/docs/busybox.pod | |||
@@ -1702,11 +1702,12 @@ Note that this version of syslogd/klogd ignores /etc/syslog.conf. | |||
1702 | 1702 | ||
1703 | Options: | 1703 | Options: |
1704 | 1704 | ||
1705 | -m NUM Interval between MARK lines (default=20min, 0=off) | 1705 | -m NUM Interval between MARK lines (default=20min, 0=off) |
1706 | -n Run as a foreground process | 1706 | -n Run as a foreground process |
1707 | -K Do not start up the klogd process | 1707 | -K Do not start up the klogd process |
1708 | -O FILE Use an alternate log file (default=/var/log/messages) | 1708 | -O FILE Use an alternate log file (default=/var/log/messages) |
1709 | -R HOST[:PORT] Log messages to HOST on PORT (default=514) over UDP. | 1709 | -R HOST[:PORT] Log messages to HOST on PORT (default=514) over UDP. |
1710 | -N Do not log anything locally -- network logging only | ||
1710 | 1711 | ||
1711 | Example: | 1712 | Example: |
1712 | 1713 | ||
@@ -2261,4 +2262,4 @@ Enrique Zanardi <ezanardi@ull.es> | |||
2261 | 2262 | ||
2262 | =cut | 2263 | =cut |
2263 | 2264 | ||
2264 | # $Id: busybox.pod,v 1.77 2000/11/17 17:23:16 andersen Exp $ | 2265 | # $Id: busybox.pod,v 1.78 2000/12/08 19:52:01 andersen Exp $ |
diff --git a/docs/busybox.sgml b/docs/busybox.sgml index 530629b4d..1542337dd 100644 --- a/docs/busybox.sgml +++ b/docs/busybox.sgml | |||
@@ -2991,6 +2991,7 @@ | |||
2991 | -K Do not start up the klogd process | 2991 | -K Do not start up the klogd process |
2992 | -O FILE Use an alternate log file (default=/var/log/messages) | 2992 | -O FILE Use an alternate log file (default=/var/log/messages) |
2993 | -R HOST[:PORT] Log messages to HOST on PORT (default=514) over UDP. | 2993 | -R HOST[:PORT] Log messages to HOST on PORT (default=514) over UDP. |
2994 | -N Do not log anything locally -- network logging only | ||
2994 | </screen> | 2995 | </screen> |
2995 | </para> | 2996 | </para> |
2996 | 2997 | ||
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c index bb0df8c51..75d73e322 100644 --- a/sysklogd/syslogd.c +++ b/sysklogd/syslogd.c | |||
@@ -79,13 +79,14 @@ static char LocalHostName[32]; | |||
79 | #ifdef BB_FEATURE_REMOTE_LOG | 79 | #ifdef BB_FEATURE_REMOTE_LOG |
80 | #include <netinet/in.h> | 80 | #include <netinet/in.h> |
81 | /* udp socket for logging to remote host */ | 81 | /* udp socket for logging to remote host */ |
82 | static int remotefd = -1; | 82 | static int remotefd = -1; |
83 | /* where do we log? */ | 83 | /* where do we log? */ |
84 | static char *RemoteHost; | 84 | static char *RemoteHost; |
85 | /* what port to log to? */ | 85 | /* what port to log to? */ |
86 | static int RemotePort = 514; | 86 | static int RemotePort = 514; |
87 | /* To remote log or not to remote log, that is the question. */ | 87 | /* To remote log or not to remote log, that is the question. */ |
88 | static int doRemoteLog = FALSE; | 88 | static int doRemoteLog = FALSE; |
89 | static int local_logging = TRUE; | ||
89 | #endif | 90 | #endif |
90 | 91 | ||
91 | /* Note: There is also a function called "message()" in init.c */ | 92 | /* Note: There is also a function called "message()" in init.c */ |
@@ -139,9 +140,9 @@ static void logMessage (int pri, char *msg) | |||
139 | 140 | ||
140 | if (pri != 0) { | 141 | if (pri != 0) { |
141 | for (c_fac = facilitynames; | 142 | for (c_fac = facilitynames; |
142 | c_fac->c_name && !(c_fac->c_val == LOG_FAC(pri) << 3); c_fac++); | 143 | c_fac->c_name && !(c_fac->c_val == LOG_FAC(pri) << 3); c_fac++); |
143 | for (c_pri = prioritynames; | 144 | for (c_pri = prioritynames; |
144 | c_pri->c_name && !(c_pri->c_val == LOG_PRI(pri)); c_pri++); | 145 | c_pri->c_name && !(c_pri->c_val == LOG_PRI(pri)); c_pri++); |
145 | if (*c_fac->c_name == '\0' || *c_pri->c_name == '\0') | 146 | if (*c_fac->c_name == '\0' || *c_pri->c_name == '\0') |
146 | snprintf(res, sizeof(res), "<%d>", pri); | 147 | snprintf(res, sizeof(res), "<%d>", pri); |
147 | else | 148 | else |
@@ -149,7 +150,7 @@ static void logMessage (int pri, char *msg) | |||
149 | } | 150 | } |
150 | 151 | ||
151 | if (strlen(msg) < 16 || msg[3] != ' ' || msg[6] != ' ' || | 152 | if (strlen(msg) < 16 || msg[3] != ' ' || msg[6] != ' ' || |
152 | msg[9] != ':' || msg[12] != ':' || msg[15] != ' ') { | 153 | msg[9] != ':' || msg[12] != ':' || msg[15] != ' ') { |
153 | time(&now); | 154 | time(&now); |
154 | timestamp = ctime(&now) + 4; | 155 | timestamp = ctime(&now) + 4; |
155 | timestamp[15] = '\0'; | 156 | timestamp[15] = '\0'; |
@@ -163,28 +164,29 @@ static void logMessage (int pri, char *msg) | |||
163 | 164 | ||
164 | #ifdef BB_FEATURE_REMOTE_LOG | 165 | #ifdef BB_FEATURE_REMOTE_LOG |
165 | /* send message to remote logger */ | 166 | /* send message to remote logger */ |
166 | if ( -1 != remotefd){ | 167 | if ( -1 != remotefd){ |
167 | #define IOV_COUNT 2 | 168 | #define IOV_COUNT 2 |
168 | struct iovec iov[IOV_COUNT]; | 169 | struct iovec iov[IOV_COUNT]; |
169 | struct iovec *v = iov; | 170 | struct iovec *v = iov; |
170 | 171 | ||
171 | bzero(&res, sizeof(res)); | 172 | bzero(&res, sizeof(res)); |
172 | snprintf(res, sizeof(res), "<%d>", pri); | 173 | snprintf(res, sizeof(res), "<%d>", pri); |
173 | v->iov_base = res ; | 174 | v->iov_base = res ; |
174 | v->iov_len = strlen(res); | 175 | v->iov_len = strlen(res); |
175 | v++; | 176 | v++; |
176 | 177 | ||
177 | v->iov_base = msg; | 178 | v->iov_base = msg; |
178 | v->iov_len = strlen(msg); | 179 | v->iov_len = strlen(msg); |
179 | 180 | ||
180 | if ( -1 == writev(remotefd,iov, IOV_COUNT)){ | 181 | if ( -1 == writev(remotefd,iov, IOV_COUNT)){ |
181 | error_msg_and_die("syslogd: cannot write to remote file handle on" | 182 | error_msg_and_die("syslogd: cannot write to remote file handle on" |
182 | "%s:%d\n",RemoteHost,RemotePort); | 183 | "%s:%d\n",RemoteHost,RemotePort); |
183 | } | 184 | } |
184 | } else | 185 | } |
186 | if (local_logging == TRUE) | ||
185 | #endif | 187 | #endif |
186 | /* now spew out the message to wherever it is supposed to go */ | 188 | /* now spew out the message to wherever it is supposed to go */ |
187 | message("%s %s %s %s\n", timestamp, LocalHostName, res, msg); | 189 | message("%s %s %s %s\n", timestamp, LocalHostName, res, msg); |
188 | 190 | ||
189 | 191 | ||
190 | } | 192 | } |
@@ -529,6 +531,9 @@ extern int syslogd_main(int argc, char **argv) | |||
529 | doRemoteLog = TRUE; | 531 | doRemoteLog = TRUE; |
530 | stopDoingThat = TRUE; | 532 | stopDoingThat = TRUE; |
531 | break; | 533 | break; |
534 | case 'N': | ||
535 | local_logging = FALSE; | ||
536 | break; | ||
532 | #endif | 537 | #endif |
533 | default: | 538 | default: |
534 | usage(syslogd_usage); | 539 | usage(syslogd_usage); |
@@ -79,13 +79,14 @@ static char LocalHostName[32]; | |||
79 | #ifdef BB_FEATURE_REMOTE_LOG | 79 | #ifdef BB_FEATURE_REMOTE_LOG |
80 | #include <netinet/in.h> | 80 | #include <netinet/in.h> |
81 | /* udp socket for logging to remote host */ | 81 | /* udp socket for logging to remote host */ |
82 | static int remotefd = -1; | 82 | static int remotefd = -1; |
83 | /* where do we log? */ | 83 | /* where do we log? */ |
84 | static char *RemoteHost; | 84 | static char *RemoteHost; |
85 | /* what port to log to? */ | 85 | /* what port to log to? */ |
86 | static int RemotePort = 514; | 86 | static int RemotePort = 514; |
87 | /* To remote log or not to remote log, that is the question. */ | 87 | /* To remote log or not to remote log, that is the question. */ |
88 | static int doRemoteLog = FALSE; | 88 | static int doRemoteLog = FALSE; |
89 | static int local_logging = TRUE; | ||
89 | #endif | 90 | #endif |
90 | 91 | ||
91 | /* Note: There is also a function called "message()" in init.c */ | 92 | /* Note: There is also a function called "message()" in init.c */ |
@@ -139,9 +140,9 @@ static void logMessage (int pri, char *msg) | |||
139 | 140 | ||
140 | if (pri != 0) { | 141 | if (pri != 0) { |
141 | for (c_fac = facilitynames; | 142 | for (c_fac = facilitynames; |
142 | c_fac->c_name && !(c_fac->c_val == LOG_FAC(pri) << 3); c_fac++); | 143 | c_fac->c_name && !(c_fac->c_val == LOG_FAC(pri) << 3); c_fac++); |
143 | for (c_pri = prioritynames; | 144 | for (c_pri = prioritynames; |
144 | c_pri->c_name && !(c_pri->c_val == LOG_PRI(pri)); c_pri++); | 145 | c_pri->c_name && !(c_pri->c_val == LOG_PRI(pri)); c_pri++); |
145 | if (*c_fac->c_name == '\0' || *c_pri->c_name == '\0') | 146 | if (*c_fac->c_name == '\0' || *c_pri->c_name == '\0') |
146 | snprintf(res, sizeof(res), "<%d>", pri); | 147 | snprintf(res, sizeof(res), "<%d>", pri); |
147 | else | 148 | else |
@@ -149,7 +150,7 @@ static void logMessage (int pri, char *msg) | |||
149 | } | 150 | } |
150 | 151 | ||
151 | if (strlen(msg) < 16 || msg[3] != ' ' || msg[6] != ' ' || | 152 | if (strlen(msg) < 16 || msg[3] != ' ' || msg[6] != ' ' || |
152 | msg[9] != ':' || msg[12] != ':' || msg[15] != ' ') { | 153 | msg[9] != ':' || msg[12] != ':' || msg[15] != ' ') { |
153 | time(&now); | 154 | time(&now); |
154 | timestamp = ctime(&now) + 4; | 155 | timestamp = ctime(&now) + 4; |
155 | timestamp[15] = '\0'; | 156 | timestamp[15] = '\0'; |
@@ -163,28 +164,29 @@ static void logMessage (int pri, char *msg) | |||
163 | 164 | ||
164 | #ifdef BB_FEATURE_REMOTE_LOG | 165 | #ifdef BB_FEATURE_REMOTE_LOG |
165 | /* send message to remote logger */ | 166 | /* send message to remote logger */ |
166 | if ( -1 != remotefd){ | 167 | if ( -1 != remotefd){ |
167 | #define IOV_COUNT 2 | 168 | #define IOV_COUNT 2 |
168 | struct iovec iov[IOV_COUNT]; | 169 | struct iovec iov[IOV_COUNT]; |
169 | struct iovec *v = iov; | 170 | struct iovec *v = iov; |
170 | 171 | ||
171 | bzero(&res, sizeof(res)); | 172 | bzero(&res, sizeof(res)); |
172 | snprintf(res, sizeof(res), "<%d>", pri); | 173 | snprintf(res, sizeof(res), "<%d>", pri); |
173 | v->iov_base = res ; | 174 | v->iov_base = res ; |
174 | v->iov_len = strlen(res); | 175 | v->iov_len = strlen(res); |
175 | v++; | 176 | v++; |
176 | 177 | ||
177 | v->iov_base = msg; | 178 | v->iov_base = msg; |
178 | v->iov_len = strlen(msg); | 179 | v->iov_len = strlen(msg); |
179 | 180 | ||
180 | if ( -1 == writev(remotefd,iov, IOV_COUNT)){ | 181 | if ( -1 == writev(remotefd,iov, IOV_COUNT)){ |
181 | error_msg_and_die("syslogd: cannot write to remote file handle on" | 182 | error_msg_and_die("syslogd: cannot write to remote file handle on" |
182 | "%s:%d\n",RemoteHost,RemotePort); | 183 | "%s:%d\n",RemoteHost,RemotePort); |
183 | } | 184 | } |
184 | } else | 185 | } |
186 | if (local_logging == TRUE) | ||
185 | #endif | 187 | #endif |
186 | /* now spew out the message to wherever it is supposed to go */ | 188 | /* now spew out the message to wherever it is supposed to go */ |
187 | message("%s %s %s %s\n", timestamp, LocalHostName, res, msg); | 189 | message("%s %s %s %s\n", timestamp, LocalHostName, res, msg); |
188 | 190 | ||
189 | 191 | ||
190 | } | 192 | } |
@@ -529,6 +531,9 @@ extern int syslogd_main(int argc, char **argv) | |||
529 | doRemoteLog = TRUE; | 531 | doRemoteLog = TRUE; |
530 | stopDoingThat = TRUE; | 532 | stopDoingThat = TRUE; |
531 | break; | 533 | break; |
534 | case 'N': | ||
535 | local_logging = FALSE; | ||
536 | break; | ||
532 | #endif | 537 | #endif |
533 | default: | 538 | default: |
534 | usage(syslogd_usage); | 539 | usage(syslogd_usage); |
@@ -1176,6 +1176,7 @@ const char syslogd_usage[] = | |||
1176 | "\t-O FILE\t\tUse an alternate log file (default=/var/log/messages)\n" | 1176 | "\t-O FILE\t\tUse an alternate log file (default=/var/log/messages)\n" |
1177 | #ifdef BB_FEATURE_REMOTE_LOG | 1177 | #ifdef BB_FEATURE_REMOTE_LOG |
1178 | "\t-R HOST[:PORT]\t\tLog remotely to IP or hostname on PORT (default PORT=514/UDP)\n" | 1178 | "\t-R HOST[:PORT]\t\tLog remotely to IP or hostname on PORT (default PORT=514/UDP)\n" |
1179 | "\t-N\t\tDo not log anything locally -- network logging only.\n" | ||
1179 | #endif | 1180 | #endif |
1180 | #endif | 1181 | #endif |
1181 | ; | 1182 | ; |