From: Lennart Poettering Date: Sat, 30 Dec 2017 14:17:39 +0000 (+0100) Subject: journald: introduce new uid_for_system_journal() helper X-Git-Tag: v237~146^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2fce06b0d6da5c8a6e100db77ab47c44cc0047cb;p=thirdparty%2Fsystemd.git journald: introduce new uid_for_system_journal() helper We use the same check at two places, let's add a tiny helper function for it, since it's not entirely trivialy, and we changes this before multiple times, and it's a good thing if we can change it at one place only instead of multiple. --- diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index d68e3a8d519..278f38f24e7 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -241,6 +241,13 @@ void server_space_usage_message(Server *s, JournalStorage *storage) { NULL); } +static bool uid_for_system_journal(uid_t uid) { + + /* Returns true if the specified UID shall get its data stored in the system journal*/ + + return uid_is_system(uid) || uid_is_dynamic(uid) || uid == UID_NOBODY; +} + static void server_add_acls(JournalFile *f, uid_t uid) { #if HAVE_ACL int r; @@ -248,7 +255,7 @@ static void server_add_acls(JournalFile *f, uid_t uid) { assert(f); #if HAVE_ACL - if (uid_is_system(uid) || uid_is_dynamic(uid) || uid == UID_NOBODY) + if (uid_for_system_journal(uid)) return; r = add_acls_for_user(f->fd, uid); @@ -406,7 +413,7 @@ static JournalFile* find_journal(Server *s, uid_t uid) { if (s->runtime_journal) return s->runtime_journal; - if (uid_is_system(uid) || uid_is_dynamic(uid) || uid == UID_NOBODY) + if (uid_for_system_journal(uid)) return s->system_journal; r = sd_id128_get_machine(&machine);