]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(dracut-install): copy files preserving ownership attributes
authorAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Mon, 4 Apr 2022 09:55:59 +0000 (11:55 +0200)
committerJóhann B. Guðmundsson <johannbg@gmail.com>
Mon, 4 Apr 2022 18:21:18 +0000 (18:21 +0000)
While the "clone copy" operation changes the ownership of the cloned
files, the "normal copy" using cp does not preserve it.

src/install/dracut-install.c

index d7a1cd9b6367c342d426fb2a04ed8530d746c09d..7c6d91c1543edc1c920669293d21958cde7d4b58 100644 (file)
@@ -327,10 +327,10 @@ normal_copy:
         pid = fork();
         if (pid == 0) {
                 if (geteuid() == 0 && no_xattr == false)
-                        execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode,xattr,timestamps", "-fL",
+                        execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode,xattr,timestamps,ownership", "-fL",
                                src, dst, NULL);
                 else
-                        execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode,timestamps", "-fL", src,
+                        execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode,timestamps,ownership", "-fL", src,
                                dst, NULL);
                 _exit(EXIT_FAILURE);
         }
@@ -339,10 +339,10 @@ normal_copy:
                 if (errno != EINTR) {
                         ret = -1;
                         if (geteuid() == 0 && no_xattr == false)
-                                log_error("Failed: cp --reflink=auto --sparse=auto --preserve=mode,xattr,timestamps -fL %s %s",
+                                log_error("Failed: cp --reflink=auto --sparse=auto --preserve=mode,xattr,timestamps,ownership -fL %s %s",
                                           src, dst);
                         else
-                                log_error("Failed: cp --reflink=auto --sparse=auto --preserve=mode,timestamps -fL %s %s",
+                                log_error("Failed: cp --reflink=auto --sparse=auto --preserve=mode,timestamps,ownership -fL %s %s",
                                           src, dst);
                         break;
                 }