Ignore:
Timestamp:
Jan 1, 2014, 12:47:38 AM (10 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.21.1
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi-busybox/sysklogd/syslogd.c

    r2725 r3232  
    1414 */
    1515
     16//usage:#define syslogd_trivial_usage
     17//usage:       "[OPTIONS]"
     18//usage:#define syslogd_full_usage "\n\n"
     19//usage:       "System logging utility\n"
     20//usage:    IF_NOT_FEATURE_SYSLOGD_CFG(
     21//usage:       "(this version of syslogd ignores /etc/syslog.conf)\n"
     22//usage:    )
     23//usage:     "\n    -n      Run in foreground"
     24//usage:     "\n    -O FILE     Log to FILE (default:/var/log/messages)"
     25//usage:     "\n    -l N        Log only messages more urgent than prio N (1-8)"
     26//usage:     "\n    -S      Smaller output"
     27//usage:    IF_FEATURE_ROTATE_LOGFILE(
     28//usage:     "\n    -s SIZE     Max size (KB) before rotation (default:200KB, 0=off)"
     29//usage:     "\n    -b N        N rotated logs to keep (default:1, max=99, 0=purge)"
     30//usage:    )
     31//usage:    IF_FEATURE_REMOTE_LOG(
     32//usage:     "\n    -R HOST[:PORT]  Log to IP or hostname on PORT (default PORT=514/UDP)"
     33//usage:     "\n    -L      Log locally and via network (default is network only if -R)"
     34//usage:    )
     35//usage:    IF_FEATURE_SYSLOGD_DUP(
     36//usage:     "\n    -D      Drop duplicates"
     37//usage:    )
     38//usage:    IF_FEATURE_IPC_SYSLOG(
     39/* NB: -Csize shouldn't have space (because size is optional) */
     40//usage:     "\n    -C[size_kb] Log to shared mem buffer (use logread to read it)"
     41//usage:    )
     42//usage:    IF_FEATURE_SYSLOGD_CFG(
     43//usage:     "\n    -f FILE     Use FILE as config (default:/etc/syslog.conf)"
     44//usage:    )
     45/* //usage:  "\n    -m MIN      Minutes between MARK lines (default:20, 0=off)" */
     46//usage:    IF_FEATURE_KMSG_SYSLOG(
     47//usage:     "\n    -K      Log to kernel printk buffer (use dmesg to read it)"
     48//usage:    )
     49//usage:
     50//usage:#define syslogd_example_usage
     51//usage:       "$ syslogd -R masterlog:514\n"
     52//usage:       "$ syslogd -R 192.168.1.1:601\n"
     53
    1654/*
    1755 * Done in syslogd_and_logger.c:
     
    67105#endif
    68106
     107typedef struct logFile_t {
     108    const char *path;
     109    int fd;
     110#if ENABLE_FEATURE_ROTATE_LOGFILE
     111    unsigned size;
     112    uint8_t isRegular;
     113#endif
     114} logFile_t;
     115
     116#if ENABLE_FEATURE_SYSLOGD_CFG
     117typedef struct logRule_t {
     118    uint8_t enabled_facility_priomap[LOG_NFACILITIES];
     119    struct logFile_t *file;
     120    struct logRule_t *next;
     121} logRule_t;
     122#endif
     123
    69124/* Allows us to have smaller initializer. Ugly. */
    70125#define GLOBALS \
    71     const char *logFilePath;                \
    72     int logFD;                              \
     126    logFile_t logFile;                      \
    73127    /* interval between marks in seconds */ \
    74128    /*int markInterval;*/                   \
     
    80134    /* number of rotated message files */   \
    81135    unsigned logFileRotate;                 \
    82     unsigned curFileSize;                   \
    83     smallint isRegular;                     \
    84136) \
    85137IF_FEATURE_IPC_SYSLOG( \
     
    89141    struct sembuf SMwup[1];                 \
    90142    struct sembuf SMwdn[3];                 \
     143) \
     144IF_FEATURE_SYSLOGD_CFG( \
     145    logRule_t *log_rules; \
     146) \
     147IF_FEATURE_KMSG_SYSLOG( \
     148    int kmsgfd; \
     149    int primask; \
    91150)
    92151
     
    120179
    121180static const struct init_globals init_data = {
    122     .logFilePath = "/var/log/messages",
    123     .logFD = -1,
     181    .logFile = {
     182        .path = "/var/log/messages",
     183        .fd = -1,
     184    },
    124185#ifdef SYSLOGD_MARK
    125186    .markInterval = 20 * 60,
     
    133194    .shmid = -1,
    134195    .s_semid = -1,
    135     .shm_size = ((CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE)*1024), // default shm size
     196    .shm_size = ((CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE)*1024), /* default shm size */
    136197    .SMwup = { {1, -1, IPC_NOWAIT} },
    137198    .SMwdn = { {0, 0}, {1, 0}, {1, +1} },
     
    158219    IF_FEATURE_IPC_SYSLOG(    OPTBIT_circularlog,)  // -C
    159220    IF_FEATURE_SYSLOGD_DUP(   OPTBIT_dup        ,)  // -D
     221    IF_FEATURE_SYSLOGD_CFG(   OPTBIT_cfg        ,)  // -f
     222    IF_FEATURE_KMSG_SYSLOG(   OPTBIT_kmsg       ,)  // -K
    160223
    161224    OPT_mark        = 1 << OPTBIT_mark    ,
     
    170233    OPT_circularlog = IF_FEATURE_IPC_SYSLOG(    (1 << OPTBIT_circularlog)) + 0,
    171234    OPT_dup         = IF_FEATURE_SYSLOGD_DUP(   (1 << OPTBIT_dup        )) + 0,
     235    OPT_cfg         = IF_FEATURE_SYSLOGD_CFG(   (1 << OPTBIT_cfg        )) + 0,
     236    OPT_kmsg        = IF_FEATURE_KMSG_SYSLOG(   (1 << OPTBIT_kmsg       )) + 0,
     237
    172238};
    173239#define OPTION_STR "m:nO:l:S" \
     
    177243    IF_FEATURE_REMOTE_LOG(    "L"  ) \
    178244    IF_FEATURE_IPC_SYSLOG(    "C::") \
    179     IF_FEATURE_SYSLOGD_DUP(   "D"  )
     245    IF_FEATURE_SYSLOGD_DUP(   "D"  ) \
     246    IF_FEATURE_SYSLOGD_CFG(   "f:" ) \
     247    IF_FEATURE_KMSG_SYSLOG(   "K"  )
    180248#define OPTION_DECL *opt_m, *opt_l \
    181249    IF_FEATURE_ROTATE_LOGFILE(,*opt_s) \
    182250    IF_FEATURE_ROTATE_LOGFILE(,*opt_b) \
    183     IF_FEATURE_IPC_SYSLOG(    ,*opt_C = NULL)
    184 #define OPTION_PARAM &opt_m, &G.logFilePath, &opt_l \
     251    IF_FEATURE_IPC_SYSLOG(    ,*opt_C = NULL) \
     252    IF_FEATURE_SYSLOGD_CFG(   ,*opt_f = NULL)
     253#define OPTION_PARAM &opt_m, &(G.logFile.path), &opt_l \
    185254    IF_FEATURE_ROTATE_LOGFILE(,&opt_s) \
    186255    IF_FEATURE_ROTATE_LOGFILE(,&opt_b) \
    187     IF_FEATURE_REMOTE_LOG(    ,&remoteAddrList) \
    188     IF_FEATURE_IPC_SYSLOG(    ,&opt_C)
    189 
     256    IF_FEATURE_REMOTE_LOG(    ,&remoteAddrList) \
     257    IF_FEATURE_IPC_SYSLOG(    ,&opt_C) \
     258    IF_FEATURE_SYSLOGD_CFG(   ,&opt_f)
     259
     260
     261#if ENABLE_FEATURE_SYSLOGD_CFG
     262static const CODE* find_by_name(char *name, const CODE* c_set)
     263{
     264    for (; c_set->c_name; c_set++) {
     265        if (strcmp(name, c_set->c_name) == 0)
     266            return c_set;
     267    }
     268    return NULL;
     269}
     270#endif
     271static const CODE* find_by_val(int val, const CODE* c_set)
     272{
     273    for (; c_set->c_name; c_set++) {
     274        if (c_set->c_val == val)
     275            return c_set;
     276    }
     277    return NULL;
     278}
     279
     280#if ENABLE_FEATURE_SYSLOGD_CFG
     281static void parse_syslogdcfg(const char *file)
     282{
     283    char *t;
     284    logRule_t **pp_rule;
     285    /* tok[0] set of selectors */
     286    /* tok[1] file name */
     287    /* tok[2] has to be NULL */
     288    char *tok[3];
     289    parser_t *parser;
     290
     291    parser = config_open2(file ? file : "/etc/syslog.conf",
     292                file ? xfopen_for_read : fopen_for_read);
     293    if (!parser)
     294        /* didn't find default /etc/syslog.conf */
     295        /* proceed as if we built busybox without config support */
     296        return;
     297
     298    /* use ptr to ptr to avoid checking whether head was initialized */
     299    pp_rule = &G.log_rules;
     300    /* iterate through lines of config, skipping comments */
     301    while (config_read(parser, tok, 3, 2, "# \t", PARSE_NORMAL | PARSE_MIN_DIE)) {
     302        char *cur_selector;
     303        logRule_t *cur_rule;
     304
     305        /* unexpected trailing token? */
     306        if (tok[2])
     307            goto cfgerr;
     308
     309        cur_rule = *pp_rule = xzalloc(sizeof(*cur_rule));
     310
     311        cur_selector = tok[0];
     312        /* iterate through selectors: "kern.info;kern.!err;..." */
     313        do {
     314            const CODE *code;
     315            char *next_selector;
     316            uint8_t negated_prio; /* "kern.!err" */
     317            uint8_t single_prio;  /* "kern.=err" */
     318            uint32_t facmap; /* bitmap of enabled facilities */
     319            uint8_t primap;  /* bitmap of enabled priorities */
     320            unsigned i;
     321
     322            next_selector = strchr(cur_selector, ';');
     323            if (next_selector)
     324                *next_selector++ = '\0';
     325
     326            t = strchr(cur_selector, '.');
     327            if (!t)
     328                goto cfgerr;
     329            *t++ = '\0'; /* separate facility from priority */
     330
     331            negated_prio = 0;
     332            single_prio = 0;
     333            if (*t == '!') {
     334                negated_prio = 1;
     335                ++t;
     336            }
     337            if (*t == '=') {
     338                single_prio = 1;
     339                ++t;
     340            }
     341
     342            /* parse priority */
     343            if (*t == '*')
     344                primap = 0xff; /* all 8 log levels enabled */
     345            else {
     346                uint8_t priority;
     347                code = find_by_name(t, prioritynames);
     348                if (!code)
     349                    goto cfgerr;
     350                primap = 0;
     351                priority = code->c_val;
     352                if (priority == INTERNAL_NOPRI) {
     353                    /* ensure we take "enabled_facility_priomap[fac] &= 0" branch below */
     354                    negated_prio = 1;
     355                } else {
     356                    priority = 1 << priority;
     357                    do {
     358                        primap |= priority;
     359                        if (single_prio)
     360                            break;
     361                        priority >>= 1;
     362                    } while (priority);
     363                    if (negated_prio)
     364                        primap = ~primap;
     365                }
     366            }
     367
     368            /* parse facility */
     369            if (*cur_selector == '*')
     370                facmap = (1<<LOG_NFACILITIES) - 1;
     371            else {
     372                char *next_facility;
     373                facmap = 0;
     374                t = cur_selector;
     375                /* iterate through facilities: "kern,daemon.<priospec>" */
     376                do {
     377                    next_facility = strchr(t, ',');
     378                    if (next_facility)
     379                        *next_facility++ = '\0';
     380                    code = find_by_name(t, facilitynames);
     381                    if (!code)
     382                        goto cfgerr;
     383                    /* "mark" is not a real facility, skip it */
     384                    if (code->c_val != INTERNAL_MARK)
     385                        facmap |= 1<<(LOG_FAC(code->c_val));
     386                    t = next_facility;
     387                } while (t);
     388            }
     389
     390            /* merge result with previous selectors */
     391            for (i = 0; i < LOG_NFACILITIES; ++i) {
     392                if (!(facmap & (1<<i)))
     393                    continue;
     394                if (negated_prio)
     395                    cur_rule->enabled_facility_priomap[i] &= primap;
     396                else
     397                    cur_rule->enabled_facility_priomap[i] |= primap;
     398            }
     399
     400            cur_selector = next_selector;
     401        } while (cur_selector);
     402
     403        /* check whether current file name was mentioned in previous rules or
     404         * as global logfile (G.logFile).
     405         */
     406        if (strcmp(G.logFile.path, tok[1]) == 0) {
     407            cur_rule->file = &G.logFile;
     408            goto found;
     409        }
     410        /* temporarily use cur_rule as iterator, but *pp_rule still points
     411         * to currently processing rule entry.
     412         * NOTE: *pp_rule points to the current (and last in the list) rule.
     413         */
     414        for (cur_rule = G.log_rules; cur_rule != *pp_rule; cur_rule = cur_rule->next) {
     415            if (strcmp(cur_rule->file->path, tok[1]) == 0) {
     416                /* found - reuse the same file structure */
     417                (*pp_rule)->file = cur_rule->file;
     418                cur_rule = *pp_rule;
     419                goto found;
     420            }
     421        }
     422        cur_rule->file = xzalloc(sizeof(*cur_rule->file));
     423        cur_rule->file->fd = -1;
     424        cur_rule->file->path = xstrdup(tok[1]);
     425 found:
     426        pp_rule = &cur_rule->next;
     427    }
     428    config_close(parser);
     429    return;
     430
     431 cfgerr:
     432    bb_error_msg_and_die("error in '%s' at line %d",
     433            file ? file : "/etc/syslog.conf",
     434            parser->lineno);
     435}
     436#endif
    190437
    191438/* circular buffer variables/structures */
     
    232479    /*G.shbuf->tail = 0;*/
    233480
    234     // we'll trust the OS to set initial semval to 0 (let's hope)
     481    /* we'll trust the OS to set initial semval to 0 (let's hope) */
    235482    G.s_semid = semget(KEY_ID, 2, IPC_CREAT | IPC_EXCL | 1023);
    236483    if (G.s_semid == -1) {
     
    245492
    246493/* Write message to shared mem buffer */
    247 static void log_to_shmem(const char *msg, int len)
     494static void log_to_shmem(const char *msg)
    248495{
    249496    int old_tail, new_tail;
     497    int len;
    250498
    251499    if (semop(G.s_semid, G.SMwdn, 3) == -1) {
     
    259507     * Last byte of buffer is never used and remains NUL.
    260508     */
    261     len++; /* length with NUL included */
     509    len = strlen(msg) + 1; /* length with NUL included */
    262510 again:
    263511    old_tail = G.shbuf->tail;
     
    284532}
    285533#else
    286 void ipcsyslog_cleanup(void);
    287 void ipcsyslog_init(void);
     534static void ipcsyslog_cleanup(void) {}
     535static void ipcsyslog_init(void) {}
    288536void log_to_shmem(const char *msg);
    289537#endif /* FEATURE_IPC_SYSLOG */
    290538
     539#if ENABLE_FEATURE_KMSG_SYSLOG
     540static void kmsg_init(void)
     541{
     542    G.kmsgfd = xopen("/dev/kmsg", O_WRONLY);
     543
     544    /*
     545     * kernel < 3.5 expects single char printk KERN_* priority prefix,
     546     * from 3.5 onwards the full syslog facility/priority format is supported
     547     */
     548    if (get_linux_version_code() < KERNEL_VERSION(3,5,0))
     549        G.primask = LOG_PRIMASK;
     550    else
     551        G.primask = -1;
     552}
     553
     554static void kmsg_cleanup(void)
     555{
     556    if (ENABLE_FEATURE_CLEAN_UP)
     557        close(G.kmsgfd);
     558}
     559
     560/* Write message to /dev/kmsg */
     561static void log_to_kmsg(int pri, const char *msg)
     562{
     563    /*
     564     * kernel < 3.5 expects single char printk KERN_* priority prefix,
     565     * from 3.5 onwards the full syslog facility/priority format is supported
     566     */
     567    pri &= G.primask;
     568
     569    write(G.kmsgfd, G.printbuf, sprintf(G.printbuf, "<%d>%s\n", pri, msg));
     570}
     571#else
     572static void kmsg_init(void) {}
     573static void kmsg_cleanup(void) {}
     574static void log_to_kmsg(int pri UNUSED_PARAM, const char *msg UNUSED_PARAM) {}
     575#endif /* FEATURE_KMSG_SYSLOG */
    291576
    292577/* Print a message to the log file. */
    293 static void log_locally(time_t now, char *msg)
     578static void log_locally(time_t now, char *msg, logFile_t *log_file)
    294579{
    295580#ifdef SYSLOGD_WRLOCK
     
    298583    int len = strlen(msg);
    299584
    300 #if ENABLE_FEATURE_IPC_SYSLOG
    301     if ((option_mask32 & OPT_circularlog) && G.shbuf) {
    302         log_to_shmem(msg, len);
    303         return;
    304     }
    305 #endif
    306     if (G.logFD >= 0) {
     585    if (log_file->fd >= 0) {
    307586        /* Reopen log file every second. This allows admin
    308587         * to delete the file and not worry about restarting us.
     
    314593        if (G.last_log_time != now) {
    315594            G.last_log_time = now;
    316             close(G.logFD);
     595            close(log_file->fd);
    317596            goto reopen;
    318597        }
    319598    } else {
    320599 reopen:
    321         G.logFD = open(G.logFilePath, O_WRONLY | O_CREAT
     600        log_file->fd = open(log_file->path, O_WRONLY | O_CREAT
    322601                    | O_NOCTTY | O_APPEND | O_NONBLOCK,
    323602                    0666);
    324         if (G.logFD < 0) {
     603        if (log_file->fd < 0) {
    325604            /* cannot open logfile? - print to /dev/console then */
    326605            int fd = device_open(DEV_CONSOLE, O_WRONLY | O_NOCTTY | O_NONBLOCK);
     
    335614        {
    336615            struct stat statf;
    337             G.isRegular = (fstat(G.logFD, &statf) == 0 && S_ISREG(statf.st_mode));
     616            log_file->isRegular = (fstat(log_file->fd, &statf) == 0 && S_ISREG(statf.st_mode));
    338617            /* bug (mostly harmless): can wrap around if file > 4gb */
    339             G.curFileSize = statf.st_size;
     618            log_file->size = statf.st_size;
    340619        }
    341620#endif
     
    347626    fl.l_len = 1;
    348627    fl.l_type = F_WRLCK;
    349     fcntl(G.logFD, F_SETLKW, &fl);
     628    fcntl(log_file->fd, F_SETLKW, &fl);
    350629#endif
    351630
    352631#if ENABLE_FEATURE_ROTATE_LOGFILE
    353     if (G.logFileSize && G.isRegular && G.curFileSize > G.logFileSize) {
     632    if (G.logFileSize && log_file->isRegular && log_file->size > G.logFileSize) {
    354633        if (G.logFileRotate) { /* always 0..99 */
    355             int i = strlen(G.logFilePath) + 3 + 1;
     634            int i = strlen(log_file->path) + 3 + 1;
    356635            char oldFile[i];
    357636            char newFile[i];
     
    359638            /* rename: f.8 -> f.9; f.7 -> f.8; ... */
    360639            while (1) {
    361                 sprintf(newFile, "%s.%d", G.logFilePath, i);
     640                sprintf(newFile, "%s.%d", log_file->path, i);
    362641                if (i == 0) break;
    363                 sprintf(oldFile, "%s.%d", G.logFilePath, --i);
     642                sprintf(oldFile, "%s.%d", log_file->path, --i);
    364643                /* ignore errors - file might be missing */
    365644                rename(oldFile, newFile);
    366645            }
    367646            /* newFile == "f.0" now */
    368             rename(G.logFilePath, newFile);
     647            rename(log_file->path, newFile);
     648            /* Incredibly, if F and F.0 are hardlinks, POSIX
     649             * _demands_ that rename returns 0 but does not
     650             * remove F!!!
     651             * (hardlinked F/F.0 pair was observed after
     652             * power failure during rename()).
     653             * Ensure old file is gone:
     654             */
     655            unlink(log_file->path);
    369656#ifdef SYSLOGD_WRLOCK
    370657            fl.l_type = F_UNLCK;
    371             fcntl(G.logFD, F_SETLKW, &fl);
    372 #endif
    373             close(G.logFD);
     658            fcntl(log_file->fd, F_SETLKW, &fl);
     659#endif
     660            close(log_file->fd);
    374661            goto reopen;
    375662        }
    376         ftruncate(G.logFD, 0);
    377     }
    378     G.curFileSize +=
    379 #endif
    380             full_write(G.logFD, msg, len);
     663        ftruncate(log_file->fd, 0);
     664    }
     665    log_file->size +=
     666#endif
     667            full_write(log_file->fd, msg, len);
    381668#ifdef SYSLOGD_WRLOCK
    382669    fl.l_type = F_UNLCK;
    383     fcntl(G.logFD, F_SETLKW, &fl);
     670    fcntl(log_file->fd, F_SETLKW, &fl);
    384671#endif
    385672}
     
    389676    const CODE *c_pri, *c_fac;
    390677
    391     if (pri != 0) {
    392         c_fac = facilitynames;
    393         while (c_fac->c_name) {
    394             if (c_fac->c_val != (LOG_FAC(pri) << 3)) {
    395                 c_fac++;
    396                 continue;
    397             }
    398             /* facility is found, look for prio */
    399             c_pri = prioritynames;
    400             while (c_pri->c_name) {
    401                 if (c_pri->c_val != LOG_PRI(pri)) {
    402                     c_pri++;
    403                     continue;
    404                 }
    405                 snprintf(res20, 20, "%s.%s",
    406                         c_fac->c_name, c_pri->c_name);
    407                 return;
    408             }
    409             /* prio not found, bail out */
    410             break;
    411         }
    412         snprintf(res20, 20, "<%d>", pri);
    413     }
     678    c_fac = find_by_val(LOG_FAC(pri) << 3, facilitynames);
     679    if (c_fac) {
     680        c_pri = find_by_val(LOG_PRI(pri), prioritynames);
     681        if (c_pri) {
     682            snprintf(res20, 20, "%s.%s", c_fac->c_name, c_pri->c_name);
     683            return;
     684        }
     685    }
     686    snprintf(res20, 20, "<%d>", pri);
    414687}
    415688
     
    436709    timestamp[15] = '\0';
    437710
     711    if (option_mask32 & OPT_kmsg) {
     712        log_to_kmsg(pri, msg);
     713        return;
     714    }
     715
    438716    if (option_mask32 & OPT_small)
    439717        sprintf(G.printbuf, "%s %s\n", timestamp, msg);
     
    445723
    446724    /* Log message locally (to file or shared mem) */
    447     log_locally(now, G.printbuf);
     725#if ENABLE_FEATURE_SYSLOGD_CFG
     726    {
     727        bool match = 0;
     728        logRule_t *rule;
     729        uint8_t facility = LOG_FAC(pri);
     730        uint8_t prio_bit = 1 << LOG_PRI(pri);
     731
     732        for (rule = G.log_rules; rule; rule = rule->next) {
     733            if (rule->enabled_facility_priomap[facility] & prio_bit) {
     734                log_locally(now, G.printbuf, rule->file);
     735                match = 1;
     736            }
     737        }
     738        if (match)
     739            return;
     740    }
     741#endif
     742    if (LOG_PRI(pri) < G.logLevel) {
     743#if ENABLE_FEATURE_IPC_SYSLOG
     744        if ((option_mask32 & OPT_circularlog) && G.shbuf) {
     745            log_to_shmem(G.printbuf);
     746            return;
     747        }
     748#endif
     749        log_locally(now, G.printbuf, &G.logFile);
     750    }
    448751}
    449752
     
    490793
    491794        /* Now log it */
    492         if (LOG_PRI(pri) < G.logLevel)
    493             timestamp_and_log(pri, G.parsebuf, q - G.parsebuf);
     795        timestamp_and_log(pri, G.parsebuf, q - G.parsebuf);
    494796    }
    495797}
     
    512814    int sock_fd;
    513815    char *dev_log_name;
     816
     817#if ENABLE_FEATURE_SYSTEMD
     818    if (sd_listen_fds() == 1)
     819        return SD_LISTEN_FDS_START;
     820#endif
    514821
    515822    memset(&sunx, 0, sizeof(sunx));
     
    577884    sock_fd = create_socket();
    578885
    579     if (ENABLE_FEATURE_IPC_SYSLOG && (option_mask32 & OPT_circularlog)) {
     886    if (option_mask32 & OPT_circularlog)
    580887        ipcsyslog_init();
    581     }
     888
     889    if (option_mask32 & OPT_kmsg)
     890        kmsg_init();
    582891
    583892    timestamp_and_log_internal("syslogd started: BusyBox v" BB_VER);
     
    666975    timestamp_and_log_internal("syslogd exiting");
    667976    puts("syslogd exiting");
    668     if (ENABLE_FEATURE_IPC_SYSLOG)
    669         ipcsyslog_cleanup();
     977    remove_pidfile(CONFIG_PID_FILE_PATH "/syslogd.pid");
     978    ipcsyslog_cleanup();
     979    if (option_mask32 & OPT_kmsg)
     980        kmsg_cleanup();
    670981    kill_myself_with_sig(bb_got_signal);
    671982#undef recvbuf
     
    7151026        G.shm_size = xatoul_range(opt_C, 4, INT_MAX/1024) * 1024;
    7161027#endif
    717 
    7181028    /* If they have not specified remote logging, then log locally */
    7191029    if (ENABLE_FEATURE_REMOTE_LOG && !(opts & OPT_remotelog)) // -R
    7201030        option_mask32 |= OPT_locallog;
     1031#if ENABLE_FEATURE_SYSLOGD_CFG
     1032    parse_syslogdcfg(opt_f);
     1033#endif
    7211034
    7221035    /* Store away localhost's name before the fork */
     
    7271040        bb_daemonize_or_rexec(DAEMON_CHDIR_ROOT, argv);
    7281041    }
     1042
    7291043    //umask(0); - why??
    730     write_pidfile("/var/run/syslogd.pid");
     1044    write_pidfile(CONFIG_PID_FILE_PATH "/syslogd.pid");
     1045
    7311046    do_syslogd();
    7321047    /* return EXIT_SUCCESS; */
Note: See TracChangeset for help on using the changeset viewer.