[systemd-commits] 2 commits - src/journal

Lennart Poettering lennart at kemper.freedesktop.org
Wed Jan 11 12:24:11 PST 2012


 src/journal/journal-file.c |    5 +++--
 src/journal/journald.c     |   31 ++++++++++++++++++++++++++-----
 src/journal/journald.h     |    3 +++
 3 files changed, 32 insertions(+), 7 deletions(-)

New commits:
commit 7f120cc6a2eeea1b695222ff6e8e83b4f14ace59
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jan 11 21:24:02 2012 +0100

    journald: don't assume size_t and uint64_t are the same

diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index 419e15e..6ba3d8d 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -640,7 +640,8 @@ int journal_file_find_data_object_with_hash(
 
                 if (o->object.flags & OBJECT_COMPRESSED) {
 #ifdef HAVE_XZ
-                        uint64_t l, rsize;
+                        uint64_t l;
+                        size_t rsize;
 
                         l = le64toh(o->object.size);
                         if (l <= offsetof(Object, data.payload))
@@ -651,7 +652,7 @@ int journal_file_find_data_object_with_hash(
                         if (!uncompress_blob(o->data.payload, l, &f->compress_buffer, &f->compress_buffer_size, &rsize))
                                 return -EBADMSG;
 
-                        if (rsize == size &&
+                        if ((uint64_t) rsize == size &&
                             memcmp(f->compress_buffer, data, size) == 0) {
 
                                 if (ret)

commit 5e41cfec83aa47af12e469bc62e336f8213ee066
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jan 11 21:11:58 2012 +0100

    journald: set group ownership of journal files to 'adm' by default

diff --git a/src/journal/journald.c b/src/journal/journald.c
index 0194a1b..33865b8 100644
--- a/src/journal/journald.c
+++ b/src/journal/journald.c
@@ -183,7 +183,26 @@ finish:
         return avail;
 }
 
-static void fix_perms(JournalFile *f, uid_t uid) {
+static void server_read_file_gid(Server *s) {
+        const char *adm = "adm";
+        int r;
+
+        assert(s);
+
+        if (s->file_gid_valid)
+                return;
+
+        r = get_group_creds(&adm, &s->file_gid);
+        if (r < 0)
+                log_warning("Failed to resolve 'adm' group: %s", 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;
+}
+
+static void server_fix_perms(Server *s, JournalFile *f, uid_t uid) {
         int r;
 #ifdef HAVE_ACL
         acl_t acl;
@@ -193,7 +212,9 @@ static void fix_perms(JournalFile *f, uid_t uid) {
 
         assert(f);
 
-        r = fchmod_and_fchown(f->fd, 0640, 0, 0);
+        server_read_file_gid(s);
+
+        r = fchmod_and_fchown(f->fd, 0640, 0, s->file_gid);
         if (r < 0)
                 log_warning("Failed to fix access mode/rights on %s, ignoring: %s", f->path, strerror(-r));
 
@@ -277,7 +298,7 @@ static JournalFile* find_journal(Server *s, uid_t uid) {
         if (r < 0)
                 return s->system_journal;
 
-        fix_perms(f, uid);
+        server_fix_perms(s, f, uid);
         f->metrics = s->system_metrics;
         f->compress = s->compress;
 
@@ -1733,7 +1754,7 @@ static int system_journal_open(Server *s) {
                         s->system_journal->metrics = s->system_metrics;
                         s->system_journal->compress = s->compress;
 
-                        fix_perms(s->system_journal, 0);
+                        server_fix_perms(s, s->system_journal, 0);
                 } else if (r < 0) {
 
                         if (r != -ENOENT && r != -EROFS)
@@ -1786,7 +1807,7 @@ static int system_journal_open(Server *s) {
                         s->runtime_journal->metrics = s->runtime_metrics;
                         s->runtime_journal->compress = s->compress;
 
-                        fix_perms(s->runtime_journal, 0);
+                        server_fix_perms(s, s->runtime_journal, 0);
                 }
         }
 
diff --git a/src/journal/journald.h b/src/journal/journald.h
index 1f1665b..6160991 100644
--- a/src/journal/journald.h
+++ b/src/journal/journald.h
@@ -73,6 +73,9 @@ typedef struct Server {
 
         uint64_t var_available_timestamp;
 
+        gid_t file_gid;
+        bool file_gid_valid;
+
         LIST_HEAD(StdoutStream, stdout_streams);
         unsigned n_stdout_streams;
 } Server;



More information about the systemd-commits mailing list