From 1e0e7c7411ecb7dc1c6f4d7d6e6a2aa14f6f2395 Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sun, 22 Jun 2025 14:17:08 +0200 Subject: [PATCH] home: Make sure we resolve /etc/skel symlink Otherwise copy_tree_at() will try to copy the symlink which we obviously don't want. --- src/home/homework.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/home/homework.c b/src/home/homework.c index d26d4529e55..689267d8191 100644 --- a/src/home/homework.c +++ b/src/home/homework.c @@ -7,6 +7,7 @@ #include "blockdev-util.h" #include "bus-unit-util.h" +#include "chase.h" #include "chown-recursive.h" #include "copy.h" #include "cryptsetup-util.h" @@ -1067,16 +1068,25 @@ static int home_deactivate(UserRecord *h, bool force) { } static int copy_skel(UserRecord *h, int root_fd, const char *skel) { + _cleanup_close_ int skel_fd = -EBADF; int r; assert(h); assert(root_fd >= 0); - r = copy_tree_at(AT_FDCWD, skel, root_fd, ".", h->uid, user_record_gid(h), COPY_MERGE|COPY_REPLACE, NULL, NULL); + r = chase(skel, /* root= */ NULL, CHASE_MUST_BE_DIRECTORY, /* ret_path= */ NULL, &skel_fd); if (r == -ENOENT) { log_info("Skeleton directory %s missing, ignoring.", skel); return 0; } + + r = copy_tree_at( + skel_fd, /* from= */ NULL, + root_fd, ".", + h->uid, user_record_gid(h), + COPY_MERGE|COPY_REPLACE, + /* denylist= */ NULL, + /* subvolumes= */ NULL); if (r < 0) return log_error_errno(r, "Failed to copy in %s: %m", skel); -- 2.47.3