]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tmpfiles: fix symlink creation when replacing
authorLennart Poettering <lennart@poettering.net>
Wed, 18 Jun 2025 08:23:42 +0000 (10:23 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 18 Jun 2025 08:23:44 +0000 (10:23 +0200)
When we remove an existing inode in order to create a symlink we need to
create the symlink via a pinned directory again, instead of using an
absolute path, otherwise this will not work in the --root= case.

Let's fix this, and switch this over to symlinkat_atomic_full().

src/tmpfiles/tmpfiles.c

index 5a4fcc6117384a19f6ab83a1d1ad2797acc82c46..16e2742fc1fbd237129a69047627ff90d8d2e1bb 100644 (file)
@@ -2477,9 +2477,7 @@ static int create_symlink(Context *c, Item *i) {
                         if (r < 0)
                                 return log_error_errno(r, "rm -rf %s failed: %m", i->path);
 
-                        mac_selinux_create_file_prepare(i->path, S_IFLNK);
-                        r = RET_NERRNO(symlinkat(i->argument, pfd, i->path));
-                        mac_selinux_create_file_clear();
+                        r = symlinkat_atomic_full(i->argument, pfd, bn, SYMLINK_LABEL);
                 }
                 if (r < 0)
                         return log_error_errno(r, "symlink(%s, %s) failed: %m", i->argument, i->path);