Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:42.1:Staging:C
systemd
log-target-null-instead-kmsg.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File log-target-null-instead-kmsg.patch of Package systemd
--- 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(-) Index: systemd-210/src/journal/journald-kmsg.c =================================================================== --- systemd-210.orig/src/journal/journald-kmsg.c +++ systemd-210/src/journal/journald-kmsg.c @@ -391,12 +391,24 @@ static int dispatch_dev_kmsg(sd_event_so return server_read_dev_kmsg(s); } +static int parse_proc_cmdline_word(const char *word) { + 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"); Index: systemd-210/src/libudev/libudev-util.c =================================================================== --- systemd-210.orig/src/libudev/libudev-util.c +++ systemd-210/src/libudev/libudev-util.c @@ -416,6 +416,13 @@ uint64_t util_string_bloom64(const char return bits; } +static int parse_proc_cmdline_word(const char *word) { + 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 +431,12 @@ ssize_t print_kmsg(const char *fmt, ...) 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; Index: systemd-210/src/shared/log.c =================================================================== --- systemd-210.orig/src/shared/log.c +++ systemd-210/src/shared/log.c @@ -92,12 +92,24 @@ void log_close_kmsg(void) { kmsg_fd = -1; } +static int parse_proc_cmdline_word(const char *word) { + 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; Index: systemd-210/src/shared/util.c =================================================================== --- systemd-210.orig/src/shared/util.c +++ systemd-210/src/shared/util.c @@ -6069,7 +6069,11 @@ int parse_proc_cmdline(int (*parse_word) 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; } }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor