]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: Don't copy root directory mode from source file
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 4 Oct 2024 19:33:52 +0000 (21:33 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 4 Oct 2024 19:33:52 +0000 (21:33 +0200)
If the source is a file, don't copy the mode and such from it to
the root directory, even if the target is /.

src/partition/repart.c

index 95ae0a3158e304a500c919d9a3bc0e0b85c59d53..c87cceb4da36d659f905a9a6fb477b5c59ecbf9a 100644 (file)
@@ -5518,6 +5518,8 @@ static int do_copy_files(Context *context, Partition *p, const char *root) {
                         return -errno;
 
                 sfd = chase_and_open(*source, arg_copy_source, CHASE_PREFIX_ROOT, O_PATH|O_DIRECTORY|O_CLOEXEC|O_NOCTTY, NULL);
+                if (sfd == -ENOTDIR)
+                        continue;
                 if (sfd < 0)
                         return log_error_errno(sfd, "Failed to open source file '%s%s': %m", strempty(arg_copy_source), *source);