]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Add a warning about the difference in permissions between existing directories and... 11540/head
authorTaro Yamada <archer_ame@yahoo.co.jp>
Sun, 27 Jan 2019 04:50:04 +0000 (13:50 +0900)
committerTaro Yamada <archer_ame@yahoo.co.jp>
Tue, 29 Jan 2019 00:52:21 +0000 (09:52 +0900)
To follows the intent of 30c81ce, this change does not execute chmod() and just add warnings.

src/core/execute.c

index 07c5a72721b58da24edb3dc6a89b9c370d96032c..a7082310ba6a890921bd7803751a17150107b591 100644 (file)
@@ -2160,8 +2160,21 @@ static int setup_exec_directory(
                         r = mkdir_label(p, context->directories[type].mode);
                         if (r < 0 && r != -EEXIST)
                                 goto fail;
-                        if (r == -EEXIST && !context->dynamic_user)
-                                continue;
+                        if (r == -EEXIST) {
+                                struct stat st;
+
+                                if (stat(p, &st) < 0) {
+                                        r = -errno;
+                                        goto fail;
+                                }
+                                if (((st.st_mode ^ context->directories[type].mode) & 07777) != 0)
+                                        log_warning("%s \'%s\' already exists but the mode is different. "
+                                                    "(filesystem: %o %sMode: %o)",
+                                                    exec_directory_type_to_string(type), *rt,
+                                                    st.st_mode & 07777, exec_directory_type_to_string(type), context->directories[type].mode & 07777);
+                                if (!context->dynamic_user)
+                                        continue;
+                        }
                 }
 
                 /* Don't change the owner of the configuration directory, as in the common case it is not written to by