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 /sysklogd/syslogd.c | |
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...
Diffstat (limited to 'sysklogd/syslogd.c')
-rw-r--r-- | sysklogd/syslogd.c | 57 |
1 files changed, 31 insertions, 26 deletions
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); |