summaryrefslogtreecommitdiffstats
path: root/src/core/execute.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-06-24 16:18:49 +0200
committerLennart Poettering <lennart@poettering.net>2019-06-24 16:20:34 +0200
commit5c6d40d13238e56699074fc1b01f4ac929ba62b8 (patch)
tree11b49e2fc81e939cac086047b836a63e85c061ff /src/core/execute.c
parentcore: add missing space to DynamicUser=1 directory comment (diff)
downloadsystemd-5c6d40d13238e56699074fc1b01f4ac929ba62b8.tar.xz
systemd-5c6d40d13238e56699074fc1b01f4ac929ba62b8.zip
core: migrate service directories back from private if needed
Fixes: #12131
Diffstat (limited to '')
-rw-r--r--src/core/execute.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/core/execute.c b/src/core/execute.c
index 2da978e406..202e3b31a5 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -2171,6 +2171,38 @@ static int setup_exec_directory(
goto fail;
} else {
+ _cleanup_free_ char *target = NULL;
+
+ if (type != EXEC_DIRECTORY_CONFIGURATION &&
+ readlink_and_make_absolute(p, &target) >= 0) {
+ _cleanup_free_ char *q = NULL;
+
+ /* This already exists and is a symlink? Interesting. Maybe it's one created
+ * by DynamicUser=1 (see above)? */
+
+ q = path_join(params->prefix[type], "private", *rt);
+ if (!q) {
+ r = -ENOMEM;
+ goto fail;
+ }
+
+ if (path_equal(q, target)) {
+
+ /* Hmm, apparently DynamicUser= was once turned on for this service,
+ * but is no longer. Let's move the directory back up. */
+
+ if (unlink(p) < 0) {
+ r = -errno;
+ goto fail;
+ }
+
+ if (rename(q, p) < 0) {
+ r = -errno;
+ goto fail;
+ }
+ }
+ }
+
r = mkdir_label(p, context->directories[type].mode);
if (r < 0) {
if (r != -EEXIST)