SHA256
1
0
forked from pool/systemd
Dr. Werner Fink 2013-12-20 12:23:11 +00:00 committed by Git OBS Bridge
parent 79a7f6981e
commit 28da91939e
4 changed files with 48 additions and 42 deletions

View File

@ -6,65 +6,57 @@ Avoid a busy systemd-journald due polling a broken /dec/kmsg in lxc
environments. environments.
--- ---
journald-kmsg.c | 27 ++++++++++++++++++++++++++- journald-kmsg.c | 18 +++++++++++++++---
1 file changed, 26 insertions(+), 1 deletion(-) 1 file changed, 15 insertions(+), 3 deletions(-)
Index: systemd-208/src/journal/journald-kmsg.c Index: systemd-208/src/journal/journald-kmsg.c
=================================================================== ===================================================================
--- systemd-208/src/journal/journald-kmsg.c --- systemd-208/src/journal/journald-kmsg.c
+++ systemd-208/src/journal/journald-kmsg.c 2013-11-21 13:30:22.930735683 +0000 +++ systemd-208/src/journal/journald-kmsg.c 2013-12-20 11:34:39.762236175 +0000
@@ -23,7 +23,9 @@ @@ -377,15 +377,18 @@ int server_flush_dev_kmsg(Server *s) {
#include <sys/epoll.h>
#include <fcntl.h>
#include <sys/mman.h>
+#include <sys/stat.h>
#include <sys/socket.h>
+#include <sys/types.h>
#include <systemd/sd-messages.h>
#include <libudev.h>
@@ -377,20 +379,43 @@ int server_flush_dev_kmsg(Server *s) {
int server_open_dev_kmsg(Server *s) { int server_open_dev_kmsg(Server *s) {
struct epoll_event ev; struct epoll_event ev;
+ struct stat st; + int r;
assert(s); assert(s);
s->dev_kmsg_fd = open("/dev/kmsg", O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY); s->dev_kmsg_fd = open("/dev/kmsg", O_RDWR|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
if (s->dev_kmsg_fd < 0) { if (s->dev_kmsg_fd < 0) {
- log_warning("Failed to open /dev/kmsg, ignoring: %m"); - log_warning("Failed to open /dev/kmsg, ignoring: %m");
+ /* Do not warn as it may not exists in LXC environments */ + log_full(errno == ENOENT ? LOG_DEBUG : LOG_WARNING,
+ if (errno != ENOENT) + "Failed to open /dev/kmsg, ignoring: %m");
+ log_warning("Failed to open /dev/kmsg, ignoring: %m");
return 0; return 0;
} }
+ if (fstat(s->dev_kmsg_fd, &st) < 0) { + r = 0;
+ log_error("Failed to stat /dev/kmsg fd, ignoring: %m");
+ close_nointr_nofail(s->dev_kmsg_fd);
+ s->dev_kmsg_fd = -1;
+ return 0;
+ }
+
+ if (!S_ISCHR(st.st_mode) || major(st.st_rdev) != 1 || minor(st.st_rdev) != 11) {
+ int old_errno = errno;
+ errno = ENODEV;
+ log_warning("Irregular device /dev/kmsg, ignoring: %m");
+ errno = old_errno;
+ close_nointr_nofail(s->dev_kmsg_fd);
+ s->dev_kmsg_fd = -1;
+ return 0;
+ }
+
zero(ev); zero(ev);
ev.events = EPOLLIN; ev.events = EPOLLIN;
ev.data.fd = s->dev_kmsg_fd; ev.data.fd = s->dev_kmsg_fd;
if (epoll_ctl(s->epoll_fd, EPOLL_CTL_ADD, s->dev_kmsg_fd, &ev) < 0) { @@ -394,15 +397,24 @@ int server_open_dev_kmsg(Server *s) {
+ close_nointr_nofail(s->dev_kmsg_fd);
+ s->dev_kmsg_fd = -1;
+
/* This will fail with EPERM on older kernels where /* This will fail with EPERM on older kernels where
* /dev/kmsg is not readable. */ * /dev/kmsg is not readable. */
if (errno == EPERM) if (errno == EPERM)
- return 0;
+ goto fail;
log_error("Failed to add /dev/kmsg fd to epoll object: %m");
- return -errno;
+ r = -errno;
+ goto fail;
}
s->dev_kmsg_readable = true;
return 0;
+
+fail:
+ if (s->dev_kmsg_fd >= 0) {
+ close_nointr_nofail(s->dev_kmsg_fd);
+ s->dev_kmsg_fd = -1;
+ }
+
+ return r;
}
int server_open_kernel_seqnum(Server *s) {

View File

@ -157,12 +157,12 @@ Based on upstream baae0358f349870544884e405e82e4be7d8add9f
+ pam_syslog(handle, LOG_ERR, "Failed to set runtime dir."); + pam_syslog(handle, LOG_ERR, "Failed to set runtime dir.");
+ goto finish; + goto finish;
+ } + }
+ } else { + } else if (getenv("XDG_RUNTIME_DIR")) {
+ (void) unsetenv("XDG_RUNTIME_DIR");
+ r = pam_putenv(handle, "XDG_RUNTIME_DIR"); + r = pam_putenv(handle, "XDG_RUNTIME_DIR");
+ if (r != PAM_SUCCESS && r != PAM_BAD_ITEM) { + if (r != PAM_SUCCESS && r != PAM_BAD_ITEM) {
+ pam_syslog(handle, LOG_ERR, "Failed to unset runtime dir."); + pam_syslog(handle, LOG_ERR, "Failed to unset runtime dir.");
+ } + }
+ (void) unsetenv("XDG_RUNTIME_DIR");
} }
if (!isempty(seat)) { if (!isempty(seat)) {

View File

@ -588,6 +588,9 @@ export V=1
--with-debug-shell=/bin/bash \ --with-debug-shell=/bin/bash \
--disable-smack \ --disable-smack \
--disable-ima \ --disable-ima \
%if 0%{?suse_version} > 1310
--disable-multi-seat-x \
%endif
CFLAGS="%{optflags}" CFLAGS="%{optflags}"
make %{?_smp_mflags} make %{?_smp_mflags}

View File

@ -1,3 +1,14 @@
-------------------------------------------------------------------
Fri Dec 20 12:06:18 UTC 2013 - werner@suse.de
- Adapt patch
1011-check-4-valid-kmsg-device.patch
to fit current upstream version maybe related to bnc#854884
- Change patch
1012-pam_systemd_do_override_XDG_RUNTIME_DIR_of_the_original_user.patch
to check if XDG_RUNTIME_DIR is set before the call of pam_putenv()
may fix bnc#855160
------------------------------------------------------------------- -------------------------------------------------------------------
Fri Dec 20 09:40:01 UTC 2013 - lbsousajr@gmail.com Fri Dec 20 09:40:01 UTC 2013 - lbsousajr@gmail.com