summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--man/journald.conf.xml8
-rw-r--r--src/journal/journald-gperf.gperf1
-rw-r--r--src/journal/journald-kmsg.c11
-rw-r--r--src/journal/journald-server.c3
-rw-r--r--src/journal/journald-server.h1
5 files changed, 22 insertions, 2 deletions
diff --git a/man/journald.conf.xml b/man/journald.conf.xml
index 209d857234..e4dc5862d9 100644
--- a/man/journald.conf.xml
+++ b/man/journald.conf.xml
@@ -358,6 +358,14 @@
</varlistentry>
<varlistentry>
+ <term><varname>ReadKMsg=</varname></term>
+
+ <listitem><para>Takes a boolean value. If enabled (the
+ default), journal reads <filename>/dev/kmsg</filename>
+ messages generated by the kernel.</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><varname>TTYPath=</varname></term>
<listitem><para>Change the console TTY to use if
diff --git a/src/journal/journald-gperf.gperf b/src/journal/journald-gperf.gperf
index 654fd76a4b..522ad30cf3 100644
--- a/src/journal/journald-gperf.gperf
+++ b/src/journal/journald-gperf.gperf
@@ -18,6 +18,7 @@ struct ConfigPerfItem;
Journal.Storage, config_parse_storage, 0, offsetof(Server, storage)
Journal.Compress, config_parse_bool, 0, offsetof(Server, compress)
Journal.Seal, config_parse_bool, 0, offsetof(Server, seal)
+Journal.ReadKMsg, config_parse_bool, 0, offsetof(Server, read_kmsg)
Journal.SyncIntervalSec, config_parse_sec, 0, offsetof(Server, sync_interval_usec)
# The following is a legacy name for compatibility
Journal.RateLimitInterval, config_parse_sec, 0, offsetof(Server, rate_limit_interval)
diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c
index 8afaec0ced..70ea562062 100644
--- a/src/journal/journald-kmsg.c
+++ b/src/journal/journald-kmsg.c
@@ -397,17 +397,26 @@ static int dispatch_dev_kmsg(sd_event_source *es, int fd, uint32_t revents, void
}
int server_open_dev_kmsg(Server *s) {
+ mode_t mode;
int r;
assert(s);
- s->dev_kmsg_fd = open("/dev/kmsg", O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
+ if (s->read_kmsg)
+ mode = O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY;
+ else
+ mode = O_WRONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY;
+
+ s->dev_kmsg_fd = open("/dev/kmsg", mode);
if (s->dev_kmsg_fd < 0) {
log_full(errno == ENOENT ? LOG_DEBUG : LOG_WARNING,
"Failed to open /dev/kmsg, ignoring: %m");
return 0;
}
+ if (!s->read_kmsg)
+ return 0;
+
r = sd_event_add_io(s->event, &s->dev_kmsg_event_source, s->dev_kmsg_fd, EPOLLIN, dispatch_dev_kmsg, s);
if (r < 0) {
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index 05a1254d4a..6eb19e8866 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -1915,6 +1915,7 @@ int server_init(Server *s) {
s->syslog_fd = s->native_fd = s->stdout_fd = s->dev_kmsg_fd = s->audit_fd = s->hostname_fd = s->notify_fd = -1;
s->compress = true;
s->seal = true;
+ s->read_kmsg = true;
s->watchdog_usec = USEC_INFINITY;
@@ -2051,7 +2052,7 @@ int server_init(Server *s) {
if (r < 0)
return r;
- /* /dev/ksmg */
+ /* /dev/kmsg */
r = server_open_dev_kmsg(s);
if (r < 0)
return r;
diff --git a/src/journal/journald-server.h b/src/journal/journald-server.h
index 203460c50a..882bcead8d 100644
--- a/src/journal/journald-server.h
+++ b/src/journal/journald-server.h
@@ -112,6 +112,7 @@ struct Server {
bool compress;
bool seal;
+ bool read_kmsg;
bool forward_to_kmsg;
bool forward_to_syslog;