From fdff1da299c4d3dbe9a62cb64fe9b4a3023877b8 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 22 May 2018 22:26:22 +0900 Subject: [PATCH] core: chown RuntimeDirectory= if DynamicUser= is set 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/execute.c b/src/core/execute.c index 9634ef98b1..8cb16eb49b 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -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