Skip to content

Commit 9ef73b6

Browse files
aafeijoo-susejohannbg
authored andcommitted
fix(dracut-install): copy files preserving ownership attributes
While the "clone copy" operation changes the ownership of the cloned files, the "normal copy" using cp does not preserve it.
1 parent 79170aa commit 9ef73b6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Diff for: src/install/dracut-install.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,10 @@ static int cp(const char *src, const char *dst)
327327
pid = fork();
328328
if (pid == 0) {
329329
if (geteuid() == 0 && no_xattr == false)
330-
execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode,xattr,timestamps", "-fL",
330+
execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode,xattr,timestamps,ownership", "-fL",
331331
src, dst, NULL);
332332
else
333-
execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode,timestamps", "-fL", src,
333+
execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode,timestamps,ownership", "-fL", src,
334334
dst, NULL);
335335
_exit(EXIT_FAILURE);
336336
}
@@ -339,10 +339,10 @@ static int cp(const char *src, const char *dst)
339339
if (errno != EINTR) {
340340
ret = -1;
341341
if (geteuid() == 0 && no_xattr == false)
342-
log_error("Failed: cp --reflink=auto --sparse=auto --preserve=mode,xattr,timestamps -fL %s %s",
342+
log_error("Failed: cp --reflink=auto --sparse=auto --preserve=mode,xattr,timestamps,ownership -fL %s %s",
343343
src, dst);
344344
else
345-
log_error("Failed: cp --reflink=auto --sparse=auto --preserve=mode,timestamps -fL %s %s",
345+
log_error("Failed: cp --reflink=auto --sparse=auto --preserve=mode,timestamps,ownership -fL %s %s",
346346
src, dst);
347347
break;
348348
}

0 commit comments

Comments
 (0)