anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0084-journalctl-update-hint-now-that-we-set-ACL-everywher.patch

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