dracut/backport-fix-dracut-install-copy-files-preserving-ownership-a.patch
hongjinghao 2663ebded8 backport patchs from upstream
(cherry picked from commit e37aecb42764d47b923dd3280385bd5438f466b6)
2024-02-22 14:56:32 +08:00

50 lines
2.5 KiB
Diff

From 9ef73b6ad08c19c3906564e5a15c7908ed9a81c8 Mon Sep 17 00:00:00 2001
From: Antonio Alvarez Feijoo <antonio.feijoo@suse.com>
Date: Mon, 4 Apr 2022 11:55:59 +0200
Subject: [PATCH] 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.
Reference:https://github.com/dracutdevs/dracut/commit/9ef73b6ad08c19c3906564e5a15c7908ed9a81c8
Conflict:Modify context for adaption
---
install/dracut-install.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/install/dracut-install.c b/install/dracut-install.c
index d7a1cd9b..7c6d91c1 100644
--- a/install/dracut-install.c
+++ b/install/dracut-install.c
@@ -312,10 +312,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", src, dst,
+ 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, dst,
+ execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode,timestamps,ownership", "-fL", src, dst,
NULL);
_exit(EXIT_FAILURE);
}
@@ -324,10 +324,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", src,
+ 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", src,
+ log_error("Failed: cp --reflink=auto --sparse=auto --preserve=mode,timestamps,ownership -fL %s %s", src,
dst);
break;
}
--
2.33.0