Skip to content

Commit

Permalink
fix(dracut-install): copy files preserving ownership attributes
Browse files Browse the repository at this point in the history
While the "clone copy" operation changes the ownership of the cloned
files, the "normal copy" using cp does not preserve it.
  • Loading branch information
aafeijoo-suse authored and johannbg committed Apr 4, 2022
1 parent 79170aa commit 9ef73b6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/install/dracut-install.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,10 @@ static int cp(const char *src, const char *dst)
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);
}
Expand All @@ -339,10 +339,10 @@ static int cp(const char *src, const char *dst)
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;
}
Expand Down

0 comments on commit 9ef73b6

Please sign in to comment.