ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
1ff636
From cf04c51fb2d5ce08a8b8aafec999e2007ef53c83 Mon Sep 17 00:00:00 2001
1ff636
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
1ff636
Date: Sun, 8 Mar 2015 11:04:59 -0400
1ff636
Subject: [PATCH] journalctl: update hint now that we set ACL everywhere
1ff636
1ff636
(cherry picked from commit 05c1853093d8c4e4aa16876b5129b65dac5abd01)
1ff636
---
1ff636
 src/journal/journalctl.c | 25 +++++++++++--------------
1ff636
 1 file changed, 11 insertions(+), 14 deletions(-)
1ff636
1ff636
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
181b3f
index 55c778633..12c869f5a 100644
1ff636
--- a/src/journal/journalctl.c
1ff636
+++ b/src/journal/journalctl.c
1ff636
@@ -1542,10 +1542,17 @@ static int access_check_var_log_journal(sd_journal *j) {
1ff636
         have_access = in_group("systemd-journal") > 0;
1ff636
 
1ff636
         if (!have_access) {
1ff636
+                const char* dir;
1ff636
+
1ff636
+                if (access("/run/log/journal", F_OK) >= 0)
1ff636
+                        dir = "/run/log/journal";
1ff636
+                else
1ff636
+                        dir = "/var/log/journal";
1ff636
+
1ff636
                 /* Let's enumerate all groups from the default ACL of
1ff636
                  * the directory, which generally should allow access
1ff636
                  * to most journal files too */
1ff636
-                r = search_acl_groups(&g, "/var/log/journal/", &have_access);
1ff636
+                r = search_acl_groups(&g, dir, &have_access);
1ff636
                 if (r < 0)
1ff636
                         return r;
1ff636
         }
1ff636
@@ -1571,7 +1578,7 @@ static int access_check_var_log_journal(sd_journal *j) {
1ff636
                                 return log_oom();
1ff636
 
1ff636
                         log_notice("Hint: You are currently not seeing messages from other users and the system.\n"
1ff636
-                                   "      Users in the groups '%s' can see all messages.\n"
1ff636
+                                   "      Users in groups '%s' can see all messages.\n"
1ff636
                                    "      Pass -q to turn off this notice.", s);
1ff636
                 }
1ff636
         }
1ff636
@@ -1595,18 +1602,8 @@ static int access_check(sd_journal *j) {
1ff636
 
1ff636
         if (set_contains(j->errors, INT_TO_PTR(-EACCES))) {
1ff636
 #ifdef HAVE_ACL
1ff636
-                /* If /var/log/journal doesn't even exist,
1ff636
-                 * unprivileged users have no access at all */
1ff636
-                if (access("/var/log/journal", F_OK) < 0 &&
1ff636
-                    geteuid() != 0 &&
1ff636
-                    in_group("systemd-journal") <= 0) {
1ff636
-                        log_error("Unprivileged users cannot access messages, unless persistent log storage is\n"
1ff636
-                                  "enabled. Users in the 'systemd-journal' group may always access messages.");
1ff636
-                        return -EACCES;
1ff636
-                }
1ff636
-
1ff636
-                /* If /var/log/journal exists, try to pring a nice
1ff636
-                   notice if the user lacks access to it */
1ff636
+                /* If /run/log/journal or /var/log/journal exist, try
1ff636
+                   to pring a nice notice if the user lacks access to it. */
1ff636
                 if (!arg_quiet && geteuid() != 0) {
1ff636
                         r = access_check_var_log_journal(j);
1ff636
                         if (r < 0)