dryang / rpms / systemd

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