SHA256
1
0
forked from pool/systemd
systemd/log-target-null-instead-kmsg.patch

115 lines
3.5 KiB
Diff

---
src/journal/journald-kmsg.c | 16 +++++++++++++++-
src/libudev/libudev-util.c | 16 +++++++++++++++-
src/shared/log.c | 16 +++++++++++++++-
src/shared/util.c | 6 +++++-
4 files changed, 50 insertions(+), 4 deletions(-)
--- systemd-210/src/journal/journald-kmsg.c
+++ systemd-210/src/journal/journald-kmsg.c 2014-05-09 07:35:02.880122386 +0000
@@ -391,12 +391,26 @@
return server_read_dev_kmsg(s);
}
+static int parse_proc_cmdline_word(const char *word) {
+ int r;
+
+ if (streq(word, "systemd.log_target=null"))
+ return -115;
+
+ return 0;
+}
+
int server_open_dev_kmsg(Server *s) {
int r;
assert(s);
- s->dev_kmsg_fd = open("/dev/kmsg", O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
+ if (parse_proc_cmdline(parse_proc_cmdline_word) == -115) {
+ s->dev_kmsg_fd = open("/dev/null", O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
+ } else {
+ s->dev_kmsg_fd = open("/dev/kmsg", O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
+ }
+
if (s->dev_kmsg_fd < 0) {
log_full(errno == ENOENT ? LOG_DEBUG : LOG_WARNING,
"Failed to open /dev/kmsg, ignoring: %m");
--- systemd-210/src/libudev/libudev-util.c
+++ systemd-210/src/libudev/libudev-util.c 2014-05-09 07:35:28.304122530 +0000
@@ -416,6 +416,15 @@
return bits;
}
+static int parse_proc_cmdline_word(const char *word) {
+ int r;
+
+ if (streq(word, "systemd.log_target=null"))
+ return -115;
+
+ return 0;
+}
+
ssize_t print_kmsg(const char *fmt, ...)
{
_cleanup_close_ int fd = -1;
@@ -424,7 +433,12 @@
ssize_t len;
ssize_t ret;
- fd = open("/dev/kmsg", O_WRONLY|O_NOCTTY|O_CLOEXEC);
+ if (parse_proc_cmdline(parse_proc_cmdline_word) == -115) {
+ fd = open("/dev/null", O_WRONLY|O_NOCTTY|O_CLOEXEC);
+ } else {
+ fd = open("/dev/kmsg", O_WRONLY|O_NOCTTY|O_CLOEXEC);
+ }
+
if (fd < 0)
return -errno;
--- systemd-210/src/shared/log.c
+++ systemd-210/src/shared/log.c 2014-05-09 07:35:52.900122669 +0000
@@ -92,12 +92,26 @@
kmsg_fd = -1;
}
+static int parse_proc_cmdline_word(const char *word) {
+ int r;
+
+ if (streq(word, "systemd.log_target=null"))
+ return -115;
+
+ return 0;
+}
+
static int log_open_kmsg(void) {
if (kmsg_fd >= 0)
return 0;
- kmsg_fd = open("/dev/kmsg", O_WRONLY|O_NOCTTY|O_CLOEXEC);
+ if (parse_proc_cmdline(parse_proc_cmdline_word) == -115) {
+ kmsg_fd = open("/dev/null", O_WRONLY|O_NOCTTY|O_CLOEXEC);
+ } else {
+ kmsg_fd = open("/dev/kmsg", O_WRONLY|O_NOCTTY|O_CLOEXEC);
+ }
+
if (kmsg_fd < 0)
return -errno;
--- systemd-210/src/shared/util.c
+++ systemd-210/src/shared/util.c 2014-05-09 08:51:55.436148462 +0000
@@ -5975,7 +5975,11 @@
r = parse_word(word);
if (r < 0) {
- log_error("Failed on cmdline argument %s: %s", word, strerror(-r));
+ if (r == -115) {
+ log_error("Warning: %s set, redirecting messages to /dev/null.", word);
+ } else {
+ log_error("Failed on cmdline argument %s: %s", word, strerror(-r));
+ }
return r;
}
}