]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: chown RuntimeDirectory= if DynamicUser= is set
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 22 May 2018 13:26:22 +0000 (22:26 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 22 May 2018 13:26:22 +0000 (22:26 +0900)
When DynamicUser= is set, then RuntimeDirectory= should be always
chowned, as the service unit may enable RuntimeDirectoryPreserve=,
and the uid or gid may changed from the last run.
This also makes easier to migrate the service to use DynamicUser=.

src/core/execute.c

index 9634ef98b10fb02e76ae941f0a9aef2ec37d1f86..8cb16eb49b4b92e0e4d5294f0505ba46367e058e 100644 (file)
@@ -2089,10 +2089,10 @@ static int setup_exec_directory(
                         }
                 } else {
                         r = mkdir_label(p, context->directories[type].mode);
-                        if (r == -EEXIST)
-                                continue;
-                        if (r < 0)
+                        if (r < 0 && r != -EEXIST)
                                 goto fail;
+                        if (r == -EEXIST && !context->dynamic_user)
+                                continue;
                 }
 
                 /* Don't change the owner of the configuration directory, as in the common case it is not written to by