summaryrefslogtreecommitdiff
path: root/src/journal/journald-native.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-11-11 02:31:29 +0100
committerTom Gundersen <teg@jklm.no>2015-11-11 02:31:29 +0100
commit7042fc14ff2bd30648aea6602c95d3cf6946e7be (patch)
tree9990f79bfe80bb0b9c8c6da94f62d66d5c7da97e /src/journal/journald-native.c
parent620b7793fcbb23f6d27d42b0374d3dddb256aa40 (diff)
parentbe6d467c1f9219b2016d556a0a369828d463ca27 (diff)
Merge pull request #1837 from poettering/grabbag2
variety of fixes
Diffstat (limited to 'src/journal/journald-native.c')
-rw-r--r--src/journal/journald-native.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c
index 1e3774dafb..69a685c06f 100644
--- a/src/journal/journald-native.c
+++ b/src/journal/journald-native.c
@@ -22,6 +22,7 @@
#include <stddef.h>
#include <sys/epoll.h>
#include <sys/mman.h>
+#include <sys/statvfs.h>
#include <unistd.h>
#include "alloc-util.h"
@@ -399,8 +400,37 @@ void server_process_native_file(
assert_se(munmap(p, ps) >= 0);
} else {
_cleanup_free_ void *p = NULL;
+ struct statvfs vfs;
ssize_t n;
+ if (fstatvfs(fd, &vfs) < 0) {
+ log_error_errno(errno, "Failed to stat file system of passed file, ignoring: %m");
+ return;
+ }
+
+ /* Refuse operating on file systems that have
+ * mandatory locking enabled, see:
+ *
+ * https://github.com/systemd/systemd/issues/1822
+ */
+ if (vfs.f_flag & ST_MANDLOCK) {
+ log_error("Received file descriptor from file system with mandatory locking enable, refusing.");
+ return;
+ }
+
+ /* Make the fd non-blocking. On regular files this has
+ * the effect of bypassing mandatory locking. Of
+ * course, this should normally not be necessary given
+ * the check above, but let's better be safe than
+ * sorry, after all NFS is pretty confusing regarding
+ * file system flags, and we better don't trust it,
+ * and so is SMB. */
+ r = fd_nonblock(fd, true);
+ if (r < 0) {
+ log_error_errno(r, "Failed to make fd non-blocking, ignoring: %m");
+ return;
+ }
+
/* The file is not sealed, we can't map the file here, since
* clients might then truncate it and trigger a SIGBUS for
* us. So let's stupidly read it */