richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
4fbe94
From 5df63c2ddf93bab5e7f13e09dfb1f97a011b3451 Mon Sep 17 00:00:00 2001
4fbe94
From: Taro Yamada <archer_ame@yahoo.co.jp>
4fbe94
Date: Sun, 27 Jan 2019 13:50:04 +0900
4fbe94
Subject: [PATCH] Add a warning about the difference in permissions between
4fbe94
 existing directories and unit settings.
4fbe94
4fbe94
To follows the intent of 30c81ce, this change does not execute chmod() and just add warnings.
4fbe94
4fbe94
(cherry picked from commit 6cff72eb0a18d8547f005a481cd0622d3bc78483)
4fbe94
4fbe94
Related: #1778384
4fbe94
---
4fbe94
 src/core/execute.c | 17 +++++++++++++++--
4fbe94
 1 file changed, 15 insertions(+), 2 deletions(-)
4fbe94
4fbe94
diff --git a/src/core/execute.c b/src/core/execute.c
4fbe94
index 8293c522bc..9ddba00421 100644
4fbe94
--- a/src/core/execute.c
4fbe94
+++ b/src/core/execute.c
4fbe94
@@ -2099,8 +2099,21 @@ static int setup_exec_directory(
4fbe94
                         r = mkdir_label(p, context->directories[type].mode);
4fbe94
                         if (r < 0 && r != -EEXIST)
4fbe94
                                 goto fail;
4fbe94
-                        if (r == -EEXIST && !context->dynamic_user)
4fbe94
-                                continue;
4fbe94
+                        if (r == -EEXIST) {
4fbe94
+                                struct stat st;
4fbe94
+
4fbe94
+                                if (stat(p, &st) < 0) {
4fbe94
+                                        r = -errno;
4fbe94
+                                        goto fail;
4fbe94
+                                }
4fbe94
+                                if (((st.st_mode ^ context->directories[type].mode) & 07777) != 0)
4fbe94
+                                        log_warning("%s \'%s\' already exists but the mode is different. "
4fbe94
+                                                    "(filesystem: %o %sMode: %o)",
4fbe94
+                                                    exec_directory_type_to_string(type), *rt,
4fbe94
+                                                    st.st_mode & 07777, exec_directory_type_to_string(type), context->directories[type].mode & 07777);
4fbe94
+                                if (!context->dynamic_user)
4fbe94
+                                        continue;
4fbe94
+                        }
4fbe94
                 }
4fbe94
 
4fbe94
                 /* Don't change the owner of the configuration directory, as in the common case it is not written to by