chiark / gitweb /
journald: avoid NSS in journald
authorLennart Poettering <lennart@poettering.net>
Tue, 17 Sep 2013 21:42:36 +0000 (16:42 -0500)
committerLennart Poettering <lennart@poettering.net>
Tue, 17 Sep 2013 21:55:37 +0000 (16:55 -0500)
In order to avoid a deadlock between journald looking up the
"systemd-journal" group name, and nscd (or anyother NSS backing daemon)
logging something back to the journal avoid all NSS in journald the same
way as we avoid it from PID 1.

With this change we rely on the kernel file system logic to adjust the
group of created journal files via the SETGID bit on the journal
directory. To ensure that it is always set, even after the user created
it with a simply "mkdir" on the shell we fix it up via tmpfiles on boot.

src/journal/journald-server.c
src/journal/journald-server.h
tmpfiles.d/systemd.conf

index 709fa8b7d09921eadc246775d13461c963681729..cc8ce0dc0dd85de2e4f9d9755478c3d2f17f436d 100644 (file)
@@ -180,25 +180,6 @@ static uint64_t available_space(Server *s, bool verbose) {
         return s->cached_available_space;
 }
 
-static void server_read_file_gid(Server *s) {
-        const char *g = "systemd-journal";
-        int r;
-
-        assert(s);
-
-        if (s->file_gid_valid)
-                return;
-
-        r = get_group_creds(&g, &s->file_gid);
-        if (r < 0)
-                log_warning("Failed to resolve '%s' group: %s", g, strerror(-r));
-
-        /* if we couldn't read the gid, then it will be 0, but that's
-         * fine and we shouldn't try to resolve the group again, so
-         * let's just pretend it worked right-away. */
-        s->file_gid_valid = true;
-}
-
 void server_fix_perms(Server *s, JournalFile *f, uid_t uid) {
         int r;
 #ifdef HAVE_ACL
@@ -209,11 +190,9 @@ void server_fix_perms(Server *s, JournalFile *f, uid_t uid) {
 
         assert(f);
 
-        server_read_file_gid(s);
-
-        r = fchmod_and_fchown(f->fd, 0640, 0, s->file_gid);
+        r = fchmod(f->fd, 0640);
         if (r < 0)
-                log_warning("Failed to fix access mode/rights on %s, ignoring: %s", f->path, strerror(-r));
+                log_warning("Failed to fix access mode on %s, ignoring: %s", f->path, strerror(-r));
 
 #ifdef HAVE_ACL
         if (uid <= 0)
index 238fc8c3fb757015d574ed4acea332d3154a4661..10e9958be0221e896a7ec088d54baca08833524d 100644 (file)
@@ -97,9 +97,6 @@ typedef struct Server {
         usec_t max_file_usec;
         usec_t oldest_file_usec;
 
-        gid_t file_gid;
-        bool file_gid_valid;
-
         LIST_HEAD(StdoutStream, stdout_streams);
         unsigned n_stdout_streams;
 
index 4924b4ec70b7a8dc964a5ed9f7a5e93c827841e1..c397c71b75406841e50cdb1c3713e91f3678b49e 100644 (file)
@@ -23,3 +23,6 @@ d /run/systemd/machines 0755 root root -
 d /run/systemd/shutdown 0755 root root -
 
 F /run/nologin 0644 - - - "System is booting up."
+
+m /var/log/journal 2755 root systemd-journal - -
+m /var/log/journal/%m 2755 root systemd-journal - -