tmpfiles: fix symlink creation when replacing

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().
This commit is contained in:
Lennart Poettering
2025-06-18 10:23:44 +02:00
parent f6e213e86a
commit ee8e7000f2
+1 -3
View 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);