aboutsummaryrefslogtreecommitdiff
path: root/sysklogd/syslogd.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-01-04 17:59:59 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-01-04 17:59:59 +0000
commita9b60e93eeb4d2706ebc95bafb18bd4267a03d6f (patch)
tree541b0130abde25c96918f4c0176514c3b29baa9f /sysklogd/syslogd.c
parentceab8700dfa0a4f987c9872e12e57cfba6ddb95c (diff)
downloadbusybox-w32-a9b60e93eeb4d2706ebc95bafb18bd4267a03d6f.tar.gz
busybox-w32-a9b60e93eeb4d2706ebc95bafb18bd4267a03d6f.tar.bz2
busybox-w32-a9b60e93eeb4d2706ebc95bafb18bd4267a03d6f.zip
new libbb func: xmalloc_realpath (+ use it where makes sense)
syslogd, logread: add debugging code (disabled) syslogs: drastically smaller bss; fix "-C n" behaviour
Diffstat (limited to 'sysklogd/syslogd.c')
-rw-r--r--sysklogd/syslogd.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/sysklogd/syslogd.c b/sysklogd/syslogd.c
index 9e4bc63c2..f4644f218 100644
--- a/sysklogd/syslogd.c
+++ b/sysklogd/syslogd.c
@@ -22,19 +22,14 @@
22#include <sys/syslog.h> 22#include <sys/syslog.h>
23#include <sys/uio.h> 23#include <sys/uio.h>
24 24
25#define DEBUG 0
26
25/* Path to the unix socket */ 27/* Path to the unix socket */
26static char dev_log_name[MAXPATHLEN]; 28static char *dev_log_name;
27 29
28/* Path for the file where all log messages are written */ 30/* Path for the file where all log messages are written */
29static const char *logFilePath = "/var/log/messages"; 31static const char *logFilePath = "/var/log/messages";
30 32
31#if ENABLE_FEATURE_ROTATE_LOGFILE
32/* max size of message file before being rotated */
33static int logFileSize = 200 * 1024;
34/* number of rotated message files */
35static int logFileRotate = 1;
36#endif
37
38/* interval between marks in seconds */ 33/* interval between marks in seconds */
39static int markInterval = 20 * 60; 34static int markInterval = 20 * 60;
40 35
@@ -44,6 +39,13 @@ static int logLevel = 8;
44/* localhost's name */ 39/* localhost's name */
45static char localHostName[64]; 40static char localHostName[64];
46 41
42#if ENABLE_FEATURE_ROTATE_LOGFILE
43/* max size of message file before being rotated */
44static int logFileSize = 200 * 1024;
45/* number of rotated message files */
46static int logFileRotate = 1;
47#endif
48
47#if ENABLE_FEATURE_REMOTE_LOG 49#if ENABLE_FEATURE_REMOTE_LOG
48#include <netinet/in.h> 50#include <netinet/in.h>
49/* udp socket for logging to remote host */ 51/* udp socket for logging to remote host */
@@ -142,6 +144,9 @@ static void ipcsyslog_cleanup(void)
142 144
143static void ipcsyslog_init(void) 145static void ipcsyslog_init(void)
144{ 146{
147 if (DEBUG)
148 printf("shmget(%lx, %d,...)\n", KEY_ID, shm_size);
149
145 shmid = shmget(KEY_ID, shm_size, IPC_CREAT | 1023); 150 shmid = shmget(KEY_ID, shm_size, IPC_CREAT | 1023);
146 if (shmid == -1) { 151 if (shmid == -1) {
147 bb_perror_msg_and_die("shmget"); 152 bb_perror_msg_and_die("shmget");
@@ -236,6 +241,8 @@ static void log_to_shmem(const char *msg, int len)
236 if (semop(s_semid, SMwup, 1) == -1) { 241 if (semop(s_semid, SMwup, 1) == -1) {
237 bb_perror_msg_and_die("SMwup"); 242 bb_perror_msg_and_die("SMwup");
238 } 243 }
244 if (DEBUG)
245 printf("head:%d tail:%d\n", shbuf->head, shbuf->tail);
239} 246}
240#else 247#else
241void ipcsyslog_cleanup(void); 248void ipcsyslog_cleanup(void);
@@ -450,10 +457,12 @@ static void do_syslogd(void)
450 signal(SIGALRM, do_mark); 457 signal(SIGALRM, do_mark);
451 alarm(markInterval); 458 alarm(markInterval);
452 459
460 dev_log_name = xmalloc_realpath(_PATH_LOG);
461 if (!dev_log_name)
462 dev_log_name = _PATH_LOG;
463
453 /* Unlink old /dev/log (or object it points to) */ 464 /* Unlink old /dev/log (or object it points to) */
454 if (realpath(_PATH_LOG, dev_log_name) != NULL) { 465 unlink(dev_log_name);
455 unlink(dev_log_name);
456 }
457 466
458 memset(&sunx, 0, sizeof(sunx)); 467 memset(&sunx, 0, sizeof(sunx));
459 sunx.sun_family = AF_UNIX; 468 sunx.sun_family = AF_UNIX;
@@ -520,6 +529,7 @@ int syslogd_main(int argc, char **argv)
520 char *p; 529 char *p;
521 530
522 /* do normal option parsing */ 531 /* do normal option parsing */
532 opt_complementary = "=0"; /* no non-option params */
523 getopt32(argc, argv, OPTION_STR, OPTION_PARAM); 533 getopt32(argc, argv, OPTION_STR, OPTION_PARAM);
524 if (option_mask32 & OPT_mark) // -m 534 if (option_mask32 & OPT_mark) // -m
525 markInterval = xatou_range(opt_m, 0, INT_MAX/60) * 60; 535 markInterval = xatou_range(opt_m, 0, INT_MAX/60) * 60;