Mark Whitley | 6317c4b | 2001-03-12 22:51:50 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* |
| 3 | * Mini klogd implementation for busybox |
| 4 | * |
Glenn L McGrath | 6ed7759 | 2002-12-12 10:54:48 +0000 | [diff] [blame] | 5 | * Copyright (C) 2001 by Gennady Feldman <gfeldman@gena01.com>. |
Mark Whitley | 6317c4b | 2001-03-12 22:51:50 +0000 | [diff] [blame] | 6 | * Changes: Made this a standalone busybox module which uses standalone |
Jeremie Koenig | 63c2e7e | 2010-08-01 03:01:44 +0200 | [diff] [blame] | 7 | * syslog() client interface. |
Mark Whitley | 6317c4b | 2001-03-12 22:51:50 +0000 | [diff] [blame] | 8 | * |
Eric Andersen | c7bda1c | 2004-03-15 08:29:22 +0000 | [diff] [blame] | 9 | * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> |
Mark Whitley | 6317c4b | 2001-03-12 22:51:50 +0000 | [diff] [blame] | 10 | * |
| 11 | * Copyright (C) 2000 by Karl M. Hegbloom <karlheg@debian.org> |
| 12 | * |
Glenn L McGrath | 6ed7759 | 2002-12-12 10:54:48 +0000 | [diff] [blame] | 13 | * "circular buffer" Copyright (C) 2000 by Gennady Feldman <gfeldman@gena01.com> |
Mark Whitley | 6317c4b | 2001-03-12 22:51:50 +0000 | [diff] [blame] | 14 | * |
Glenn L McGrath | 6ed7759 | 2002-12-12 10:54:48 +0000 | [diff] [blame] | 15 | * Maintainer: Gennady Feldman <gfeldman@gena01.com> as of Mar 12, 2001 |
Mark Whitley | 6bff9cc | 2001-03-12 23:41:34 +0000 | [diff] [blame] | 16 | * |
Denys Vlasenko | 0ef64bd | 2010-08-16 20:14:46 +0200 | [diff] [blame] | 17 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
Mark Whitley | 6317c4b | 2001-03-12 22:51:50 +0000 | [diff] [blame] | 18 | */ |
Denys Vlasenko | d34f300 | 2015-10-18 18:42:03 +0200 | [diff] [blame] | 19 | //config:config KLOGD |
Denys Vlasenko | b097a84 | 2018-12-28 03:20:17 +0100 | [diff] [blame] | 20 | //config: bool "klogd (5.7 kb)" |
Denys Vlasenko | d34f300 | 2015-10-18 18:42:03 +0200 | [diff] [blame] | 21 | //config: default y |
| 22 | //config: help |
Denys Vlasenko | 72089cf | 2017-07-21 09:50:55 +0200 | [diff] [blame] | 23 | //config: klogd is a utility which intercepts and logs all |
| 24 | //config: messages from the Linux kernel and sends the messages |
| 25 | //config: out to the 'syslogd' utility so they can be logged. If |
| 26 | //config: you wish to record the messages produced by the kernel, |
| 27 | //config: you should enable this option. |
Denys Vlasenko | d34f300 | 2015-10-18 18:42:03 +0200 | [diff] [blame] | 28 | //config: |
| 29 | //config:comment "klogd should not be used together with syslog to kernel printk buffer" |
| 30 | //config: depends on KLOGD && FEATURE_KMSG_SYSLOG |
| 31 | //config: |
| 32 | //config:config FEATURE_KLOGD_KLOGCTL |
| 33 | //config: bool "Use the klogctl() interface" |
| 34 | //config: default y |
| 35 | //config: depends on KLOGD |
Denys Vlasenko | d34f300 | 2015-10-18 18:42:03 +0200 | [diff] [blame] | 36 | //config: help |
Denys Vlasenko | 72089cf | 2017-07-21 09:50:55 +0200 | [diff] [blame] | 37 | //config: The klogd applet supports two interfaces for reading |
| 38 | //config: kernel messages. Linux provides the klogctl() interface |
| 39 | //config: which allows reading messages from the kernel ring buffer |
| 40 | //config: independently from the file system. |
Denys Vlasenko | d34f300 | 2015-10-18 18:42:03 +0200 | [diff] [blame] | 41 | //config: |
Denys Vlasenko | 72089cf | 2017-07-21 09:50:55 +0200 | [diff] [blame] | 42 | //config: If you answer 'N' here, klogd will use the more portable |
| 43 | //config: approach of reading them from /proc or a device node. |
| 44 | //config: However, this method requires the file to be available. |
Denys Vlasenko | d34f300 | 2015-10-18 18:42:03 +0200 | [diff] [blame] | 45 | //config: |
Denys Vlasenko | 72089cf | 2017-07-21 09:50:55 +0200 | [diff] [blame] | 46 | //config: If in doubt, say 'Y'. |
Denys Vlasenko | d34f300 | 2015-10-18 18:42:03 +0200 | [diff] [blame] | 47 | |
| 48 | //applet:IF_KLOGD(APPLET(klogd, BB_DIR_SBIN, BB_SUID_DROP)) |
| 49 | |
| 50 | //kbuild:lib-$(CONFIG_KLOGD) += klogd.o |
Mark Whitley | 6317c4b | 2001-03-12 22:51:50 +0000 | [diff] [blame] | 51 | |
Pere Orga | 5bc8c00 | 2011-04-11 03:29:49 +0200 | [diff] [blame] | 52 | //usage:#define klogd_trivial_usage |
| 53 | //usage: "[-c N] [-n]" |
| 54 | //usage:#define klogd_full_usage "\n\n" |
Denys Vlasenko | e807351 | 2018-07-31 15:25:00 +0200 | [diff] [blame] | 55 | //usage: "Log kernel messages to syslog\n" |
Denys Vlasenko | aeab42e | 2011-05-25 11:58:56 +0200 | [diff] [blame] | 56 | //usage: "\n -c N Print to console messages more urgent than prio N (1-8)" |
Pere Orga | 5bc8c00 | 2011-04-11 03:29:49 +0200 | [diff] [blame] | 57 | //usage: "\n -n Run in foreground" |
| 58 | |
Denis Vlasenko | b6adbf1 | 2007-05-26 19:00:18 +0000 | [diff] [blame] | 59 | #include "libbb.h" |
Denys Vlasenko | e6a2f4c | 2016-04-21 16:26:30 +0200 | [diff] [blame] | 60 | #include "common_bufsiz.h" |
Bernhard Reutner-Fischer | f470196 | 2008-01-27 12:50:12 +0000 | [diff] [blame] | 61 | #include <syslog.h> |
Eric Andersen | e76c3b0 | 2001-04-05 03:14:39 +0000 | [diff] [blame] | 62 | |
Jeremie Koenig | 63c2e7e | 2010-08-01 03:01:44 +0200 | [diff] [blame] | 63 | |
| 64 | /* The Linux-specific klogctl(3) interface does not rely on the filesystem and |
| 65 | * allows us to change the console loglevel. Alternatively, we read the |
| 66 | * messages from _PATH_KLOG. */ |
| 67 | |
| 68 | #if ENABLE_FEATURE_KLOGD_KLOGCTL |
| 69 | |
| 70 | # include <sys/klog.h> |
| 71 | |
| 72 | static void klogd_open(void) |
| 73 | { |
| 74 | /* "Open the log. Currently a NOP" */ |
| 75 | klogctl(1, NULL, 0); |
| 76 | } |
| 77 | |
| 78 | static void klogd_setloglevel(int lvl) |
| 79 | { |
| 80 | /* "printk() prints a message on the console only if it has a loglevel |
| 81 | * less than console_loglevel". Here we set console_loglevel = lvl. */ |
| 82 | klogctl(8, NULL, lvl); |
| 83 | } |
| 84 | |
| 85 | static int klogd_read(char *bufp, int len) |
| 86 | { |
Denys Vlasenko | e807351 | 2018-07-31 15:25:00 +0200 | [diff] [blame] | 87 | /* "2 -- Read from the log." */ |
Jeremie Koenig | 63c2e7e | 2010-08-01 03:01:44 +0200 | [diff] [blame] | 88 | return klogctl(2, bufp, len); |
| 89 | } |
| 90 | # define READ_ERROR "klogctl(2) error" |
| 91 | |
| 92 | static void klogd_close(void) |
Mark Whitley | 6317c4b | 2001-03-12 22:51:50 +0000 | [diff] [blame] | 93 | { |
Denis Vlasenko | 7bdf0c8 | 2008-06-06 16:08:04 +0000 | [diff] [blame] | 94 | /* FYI: cmd 7 is equivalent to setting console_loglevel to 7 |
| 95 | * via klogctl(8, NULL, 7). */ |
| 96 | klogctl(7, NULL, 0); /* "7 -- Enable printk's to console" */ |
| 97 | klogctl(0, NULL, 0); /* "0 -- Close the log. Currently a NOP" */ |
Mark Whitley | 6317c4b | 2001-03-12 22:51:50 +0000 | [diff] [blame] | 98 | } |
| 99 | |
Jeremie Koenig | 63c2e7e | 2010-08-01 03:01:44 +0200 | [diff] [blame] | 100 | #else |
| 101 | |
Jeremie Koenig | 63c2e7e | 2010-08-01 03:01:44 +0200 | [diff] [blame] | 102 | # ifndef _PATH_KLOG |
| 103 | # ifdef __GNU__ |
| 104 | # define _PATH_KLOG "/dev/klog" |
| 105 | # else |
| 106 | # error "your system's _PATH_KLOG is unknown" |
| 107 | # endif |
| 108 | # endif |
| 109 | # define PATH_PRINTK "/proc/sys/kernel/printk" |
| 110 | |
| 111 | enum { klogfd = 3 }; |
| 112 | |
| 113 | static void klogd_open(void) |
| 114 | { |
| 115 | int fd = xopen(_PATH_KLOG, O_RDONLY); |
| 116 | xmove_fd(fd, klogfd); |
| 117 | } |
| 118 | |
| 119 | static void klogd_setloglevel(int lvl) |
| 120 | { |
| 121 | FILE *fp = fopen_or_warn(PATH_PRINTK, "w"); |
| 122 | if (fp) { |
| 123 | /* This changes only first value: |
| 124 | * "messages with a higher priority than this |
| 125 | * [that is, with numerically lower value] |
| 126 | * will be printed to the console". |
| 127 | * The other three values in this pseudo-file aren't changed. |
| 128 | */ |
| 129 | fprintf(fp, "%u\n", lvl); |
| 130 | fclose(fp); |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | static int klogd_read(char *bufp, int len) |
| 135 | { |
| 136 | return read(klogfd, bufp, len); |
| 137 | } |
| 138 | # define READ_ERROR "read error" |
| 139 | |
| 140 | static void klogd_close(void) |
| 141 | { |
| 142 | klogd_setloglevel(7); |
| 143 | if (ENABLE_FEATURE_CLEAN_UP) |
| 144 | close(klogfd); |
| 145 | } |
| 146 | |
| 147 | #endif |
| 148 | |
Denys Vlasenko | 9de2e5a | 2016-04-21 18:38:51 +0200 | [diff] [blame] | 149 | #define log_buffer bb_common_bufsiz1 |
Denis Vlasenko | 7e3a5f5 | 2007-11-16 20:18:54 +0000 | [diff] [blame] | 150 | enum { |
Denys Vlasenko | 9de2e5a | 2016-04-21 18:38:51 +0200 | [diff] [blame] | 151 | KLOGD_LOGBUF_SIZE = COMMON_BUFSIZE, |
Denis Vlasenko | 7e3a5f5 | 2007-11-16 20:18:54 +0000 | [diff] [blame] | 152 | OPT_LEVEL = (1 << 0), |
| 153 | OPT_FOREGROUND = (1 << 1), |
| 154 | }; |
Bernhard Reutner-Fischer | 595159f | 2006-05-31 12:22:13 +0000 | [diff] [blame] | 155 | |
Jeremie Koenig | 63c2e7e | 2010-08-01 03:01:44 +0200 | [diff] [blame] | 156 | /* TODO: glibc openlog(LOG_KERN) reverts to LOG_USER instead, |
| 157 | * because that's how they interpret word "default" |
| 158 | * in the openlog() manpage: |
| 159 | * LOG_USER (default) |
| 160 | * generic user-level messages |
| 161 | * and the fact that LOG_KERN is a constant 0. |
| 162 | * glibc interprets it as "0 in openlog() call means 'use default'". |
| 163 | * I think it means "if openlog wasn't called before syslog() is called, |
| 164 | * use default". |
| 165 | * Convincing glibc maintainers otherwise is, as usual, nearly impossible. |
| 166 | * Should we open-code syslog() here to use correct facility? |
| 167 | */ |
| 168 | |
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 169 | int klogd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
Denis Vlasenko | a60f84e | 2008-07-05 09:18:54 +0000 | [diff] [blame] | 170 | int klogd_main(int argc UNUSED_PARAM, char **argv) |
Mark Whitley | 6317c4b | 2001-03-12 22:51:50 +0000 | [diff] [blame] | 171 | { |
Denis Vlasenko | 7bdf0c8 | 2008-06-06 16:08:04 +0000 | [diff] [blame] | 172 | int i = 0; |
Denis Vlasenko | 2e7dc5d | 2008-11-19 07:59:49 +0000 | [diff] [blame] | 173 | char *opt_c; |
Denis Vlasenko | 7bdf0c8 | 2008-06-06 16:08:04 +0000 | [diff] [blame] | 174 | int opt; |
Denys Vlasenko | 0016bce | 2010-10-19 23:07:49 +0200 | [diff] [blame] | 175 | int used; |
Mark Whitley | 6317c4b | 2001-03-12 22:51:50 +0000 | [diff] [blame] | 176 | |
Denys Vlasenko | 9de2e5a | 2016-04-21 18:38:51 +0200 | [diff] [blame] | 177 | setup_common_bufsiz(); |
| 178 | |
Denis Vlasenko | 2e7dc5d | 2008-11-19 07:59:49 +0000 | [diff] [blame] | 179 | opt = getopt32(argv, "c:n", &opt_c); |
Denis Vlasenko | 7bdf0c8 | 2008-06-06 16:08:04 +0000 | [diff] [blame] | 180 | if (opt & OPT_LEVEL) { |
Denis Vlasenko | e428e9d | 2007-01-04 03:07:57 +0000 | [diff] [blame] | 181 | /* Valid levels are between 1 and 8 */ |
Denis Vlasenko | 2e7dc5d | 2008-11-19 07:59:49 +0000 | [diff] [blame] | 182 | i = xatou_range(opt_c, 1, 8); |
Denis Vlasenko | e428e9d | 2007-01-04 03:07:57 +0000 | [diff] [blame] | 183 | } |
Denis Vlasenko | 7bdf0c8 | 2008-06-06 16:08:04 +0000 | [diff] [blame] | 184 | if (!(opt & OPT_FOREGROUND)) { |
Denis Vlasenko | 5a14202 | 2007-03-26 13:20:54 +0000 | [diff] [blame] | 185 | bb_daemonize_or_rexec(DAEMON_CHDIR_ROOT, argv); |
Bernhard Reutner-Fischer | 595159f | 2006-05-31 12:22:13 +0000 | [diff] [blame] | 186 | } |
| 187 | |
Jeremie Koenig | 63c2e7e | 2010-08-01 03:01:44 +0200 | [diff] [blame] | 188 | logmode = LOGMODE_SYSLOG; |
| 189 | |
| 190 | /* klogd_open() before openlog(), since it might use fixed fd 3, |
| 191 | * and openlog() also may use the same fd 3 if we swap them: |
| 192 | */ |
| 193 | klogd_open(); |
Eric Andersen | 36adca8 | 2004-06-22 10:07:17 +0000 | [diff] [blame] | 194 | openlog("kernel", 0, LOG_KERN); |
Denys Vlasenko | 8b6b472 | 2011-03-07 10:57:26 +0100 | [diff] [blame] | 195 | /* |
| 196 | * glibc problem: for some reason, glibc changes LOG_KERN to LOG_USER |
| 197 | * above. The logic behind this is that standard |
| 198 | * http://pubs.opengroup.org/onlinepubs/9699919799/functions/syslog.html |
| 199 | * says the following about openlog and syslog: |
| 200 | * "LOG_USER |
| 201 | * Messages generated by arbitrary processes. |
| 202 | * This is the default facility identifier if none is specified." |
| 203 | * |
| 204 | * I believe glibc misinterpreted this text as "if openlog's |
| 205 | * third parameter is 0 (=LOG_KERN), treat it as LOG_USER". |
| 206 | * Whereas it was meant to say "if *syslog* is called with facility |
| 207 | * 0 in its 1st parameter without prior call to openlog, then perform |
| 208 | * implicit openlog(LOG_USER)". |
| 209 | * |
| 210 | * As a result of this, eh, feature, standard klogd was forced |
| 211 | * to open-code its own openlog and syslog implementation (!). |
| 212 | * |
| 213 | * Note that prohibiting openlog(LOG_KERN) on libc level does not |
| 214 | * add any security: any process can open a socket to "/dev/log" |
| 215 | * and write a string "<0>Voila, a LOG_KERN + LOG_EMERG message" |
| 216 | * |
| 217 | * Google code search tells me there is no widespread use of |
| 218 | * openlog("foo", 0, 0), thus fixing glibc won't break userspace. |
| 219 | * |
| 220 | * The bug against glibc was filed: |
| 221 | * bugzilla.redhat.com/show_bug.cgi?id=547000 |
| 222 | */ |
Eric Andersen | 36adca8 | 2004-06-22 10:07:17 +0000 | [diff] [blame] | 223 | |
Denis Vlasenko | 7bdf0c8 | 2008-06-06 16:08:04 +0000 | [diff] [blame] | 224 | if (i) |
Jeremie Koenig | 63c2e7e | 2010-08-01 03:01:44 +0200 | [diff] [blame] | 225 | klogd_setloglevel(i); |
| 226 | |
Jeremie Koenig | 63c2e7e | 2010-08-01 03:01:44 +0200 | [diff] [blame] | 227 | signal(SIGHUP, SIG_IGN); |
Denys Vlasenko | 8b6b472 | 2011-03-07 10:57:26 +0100 | [diff] [blame] | 228 | /* We want klogd_read to not be restarted, thus _norestart: */ |
| 229 | bb_signals_recursive_norestart(BB_FATAL_SIGS, record_signo); |
Glenn L McGrath | e1ad672 | 2002-12-01 11:31:58 +0000 | [diff] [blame] | 230 | |
Denis Vlasenko | ca525b4 | 2007-06-13 12:27:17 +0000 | [diff] [blame] | 231 | syslog(LOG_NOTICE, "klogd started: %s", bb_banner); |
Mark Whitley | 6317c4b | 2001-03-12 22:51:50 +0000 | [diff] [blame] | 232 | |
Denys Vlasenko | 5059653 | 2019-03-17 19:47:52 +0100 | [diff] [blame] | 233 | write_pidfile_std_path_and_ext("klogd"); |
Anthony G. Basile | 12677ac | 2012-12-10 14:49:39 -0500 | [diff] [blame] | 234 | |
Denys Vlasenko | 0016bce | 2010-10-19 23:07:49 +0200 | [diff] [blame] | 235 | used = 0; |
Jeremie Koenig | 63c2e7e | 2010-08-01 03:01:44 +0200 | [diff] [blame] | 236 | while (!bb_got_signal) { |
Bernhard Reutner-Fischer | 8fc4011 | 2007-01-09 15:46:36 +0000 | [diff] [blame] | 237 | int n; |
| 238 | int priority; |
Denis Vlasenko | 2e7dc5d | 2008-11-19 07:59:49 +0000 | [diff] [blame] | 239 | char *start; |
Bernhard Reutner-Fischer | 8fc4011 | 2007-01-09 15:46:36 +0000 | [diff] [blame] | 240 | |
Denis Vlasenko | 2e7dc5d | 2008-11-19 07:59:49 +0000 | [diff] [blame] | 241 | start = log_buffer + used; |
Jeremie Koenig | 63c2e7e | 2010-08-01 03:01:44 +0200 | [diff] [blame] | 242 | n = klogd_read(start, KLOGD_LOGBUF_SIZE-1 - used); |
Mark Whitley | 6317c4b | 2001-03-12 22:51:50 +0000 | [diff] [blame] | 243 | if (n < 0) { |
Mark Whitley | 6317c4b | 2001-03-12 22:51:50 +0000 | [diff] [blame] | 244 | if (errno == EINTR) |
| 245 | continue; |
James Byrne | 6937487 | 2019-07-02 11:35:03 +0200 | [diff] [blame] | 246 | bb_simple_perror_msg(READ_ERROR); |
Denis Vlasenko | e428e9d | 2007-01-04 03:07:57 +0000 | [diff] [blame] | 247 | break; |
Mark Whitley | 6317c4b | 2001-03-12 22:51:50 +0000 | [diff] [blame] | 248 | } |
Denis Vlasenko | 2e7dc5d | 2008-11-19 07:59:49 +0000 | [diff] [blame] | 249 | start[n] = '\0'; |
Denis Vlasenko | 93d0776 | 2008-10-04 16:40:17 +0000 | [diff] [blame] | 250 | |
Denis Vlasenko | 93d0776 | 2008-10-04 16:40:17 +0000 | [diff] [blame] | 251 | /* Process each newline-terminated line in the buffer */ |
Denis Vlasenko | 58a8891 | 2008-11-19 09:35:00 +0000 | [diff] [blame] | 252 | start = log_buffer; |
Denis Vlasenko | 93d0776 | 2008-10-04 16:40:17 +0000 | [diff] [blame] | 253 | while (1) { |
Denis Vlasenko | 2e7dc5d | 2008-11-19 07:59:49 +0000 | [diff] [blame] | 254 | char *newline = strchrnul(start, '\n'); |
Denis Vlasenko | 93d0776 | 2008-10-04 16:40:17 +0000 | [diff] [blame] | 255 | |
Denis Vlasenko | 2e7dc5d | 2008-11-19 07:59:49 +0000 | [diff] [blame] | 256 | if (*newline == '\0') { |
Denys Vlasenko | 0016bce | 2010-10-19 23:07:49 +0200 | [diff] [blame] | 257 | /* This line is incomplete */ |
| 258 | |
| 259 | /* move it to the front of the buffer */ |
| 260 | overlapping_strcpy(log_buffer, start); |
| 261 | used = newline - start; |
| 262 | if (used < KLOGD_LOGBUF_SIZE-1) { |
| 263 | /* buffer isn't full */ |
Denis Vlasenko | 93d0776 | 2008-10-04 16:40:17 +0000 | [diff] [blame] | 264 | break; |
Mark Whitley | 6317c4b | 2001-03-12 22:51:50 +0000 | [diff] [blame] | 265 | } |
Denys Vlasenko | 0016bce | 2010-10-19 23:07:49 +0200 | [diff] [blame] | 266 | /* buffer is full, log it anyway */ |
Denis Vlasenko | 93d0776 | 2008-10-04 16:40:17 +0000 | [diff] [blame] | 267 | used = 0; |
Denis Vlasenko | 2e7dc5d | 2008-11-19 07:59:49 +0000 | [diff] [blame] | 268 | newline = NULL; |
Denis Vlasenko | 93d0776 | 2008-10-04 16:40:17 +0000 | [diff] [blame] | 269 | } else { |
| 270 | *newline++ = '\0'; |
Mark Whitley | 6317c4b | 2001-03-12 22:51:50 +0000 | [diff] [blame] | 271 | } |
Denis Vlasenko | 93d0776 | 2008-10-04 16:40:17 +0000 | [diff] [blame] | 272 | |
| 273 | /* Extract the priority */ |
| 274 | priority = LOG_INFO; |
| 275 | if (*start == '<') { |
| 276 | start++; |
Denys Vlasenko | c16ae46 | 2018-07-31 16:50:26 +0200 | [diff] [blame] | 277 | if (*start) { |
| 278 | char *end; |
| 279 | priority = strtoul(start, &end, 10); |
| 280 | if (*end == '>') |
| 281 | end++; |
| 282 | start = end; |
| 283 | } |
Denis Vlasenko | 93d0776 | 2008-10-04 16:40:17 +0000 | [diff] [blame] | 284 | } |
Denis Vlasenko | 2e7dc5d | 2008-11-19 07:59:49 +0000 | [diff] [blame] | 285 | /* Log (only non-empty lines) */ |
Denis Vlasenko | 93d0776 | 2008-10-04 16:40:17 +0000 | [diff] [blame] | 286 | if (*start) |
| 287 | syslog(priority, "%s", start); |
Denis Vlasenko | 2e7dc5d | 2008-11-19 07:59:49 +0000 | [diff] [blame] | 288 | |
Denis Vlasenko | 93d0776 | 2008-10-04 16:40:17 +0000 | [diff] [blame] | 289 | if (!newline) |
| 290 | break; |
| 291 | start = newline; |
Mark Whitley | 6317c4b | 2001-03-12 22:51:50 +0000 | [diff] [blame] | 292 | } |
| 293 | } |
Glenn L McGrath | 9fef17d | 2002-08-22 18:41:20 +0000 | [diff] [blame] | 294 | |
Jeremie Koenig | 63c2e7e | 2010-08-01 03:01:44 +0200 | [diff] [blame] | 295 | klogd_close(); |
| 296 | syslog(LOG_NOTICE, "klogd: exiting"); |
Denys Vlasenko | 5059653 | 2019-03-17 19:47:52 +0100 | [diff] [blame] | 297 | remove_pidfile_std_path_and_ext("klogd"); |
Jeremie Koenig | 63c2e7e | 2010-08-01 03:01:44 +0200 | [diff] [blame] | 298 | if (bb_got_signal) |
| 299 | kill_myself_with_sig(bb_got_signal); |
Denis Vlasenko | e428e9d | 2007-01-04 03:07:57 +0000 | [diff] [blame] | 300 | return EXIT_FAILURE; |
Mark Whitley | 6317c4b | 2001-03-12 22:51:50 +0000 | [diff] [blame] | 301 | } |