1 Star 0 Fork 22

Kaihao Bai/coreutils

forked from src-anolis-os/coreutils 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
coreutils-8.30-cp-preserve-xattr-NFSv4-ACL.patch 2.60 KB
一键复制 编辑 原始数据 按行查看 历史
张彬琛 提交于 2021-01-20 13:29 . import coreutils-8.30-6.el8.src.rpm
From ce137aaf4b0d62b3e4c88816485a3ab0f5c4b3f3 Mon Sep 17 00:00:00 2001
From: Kamil Dudka <kdudka@redhat.com>
Date: Thu, 6 Dec 2018 13:14:00 +0100
Subject: [PATCH] cp --preserve=xattr: preserve NFSv4 ACL extended attributes
... that cannot be preserved by other means
---
src/copy.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/src/copy.c b/src/copy.c
index 1a9cdd1..d227e3e 100644
--- a/src/copy.c
+++ b/src/copy.c
@@ -640,6 +640,17 @@ copy_attr_free (struct error_context *ctx _GL_UNUSED,
{
}
+/* Include NFSv4 ACL extended attributes that cannot be preserved by
+ other means. Otherwise honor attributes configured for exclusion
+ in /etc/xattr.conf. Return zero to skip. */
+static int
+check_not_nfs4_acl (const char *name, struct error_context *ctx)
+{
+ return attr_copy_check_permissions(name, ctx)
+ || !STRNCMP_LIT (name, "system.nfs4_acl")
+ || !STRNCMP_LIT (name, "system.nfs4acl");
+}
+
/* Exclude SELinux extended attributes that are otherwise handled,
and are problematic to copy again. Also honor attributes
configured for exclusion in /etc/xattr.conf.
@@ -649,7 +660,7 @@ static int
check_selinux_attr (const char *name, struct error_context *ctx)
{
return STRNCMP_LIT (name, "security.selinux")
- && attr_copy_check_permissions (name, ctx);
+ && check_not_nfs4_acl (name, ctx);
}
/* If positive SRC_FD and DST_FD descriptors are passed,
@@ -663,6 +674,9 @@ copy_attr (char const *src_path, int src_fd,
bool all_errors = (!x->data_copy_required || x->require_preserve_xattr);
bool some_errors = (!all_errors && !x->reduce_diagnostics);
bool selinux_done = (x->preserve_security_context || x->set_security_context);
+ int (*check) (const char *, struct error_context *) = (selinux_done)
+ ? check_selinux_attr
+ : check_not_nfs4_acl;
struct error_context ctx =
{
.error = all_errors ? copy_attr_allerror : copy_attr_error,
@@ -670,12 +684,10 @@ copy_attr (char const *src_path, int src_fd,
.quote_free = copy_attr_free
};
if (0 <= src_fd && 0 <= dst_fd)
- ret = attr_copy_fd (src_path, src_fd, dst_path, dst_fd,
- selinux_done ? check_selinux_attr : NULL,
+ ret = attr_copy_fd (src_path, src_fd, dst_path, dst_fd, check,
(all_errors || some_errors ? &ctx : NULL));
else
- ret = attr_copy_file (src_path, dst_path,
- selinux_done ? check_selinux_attr : NULL,
+ ret = attr_copy_file (src_path, dst_path, check,
(all_errors || some_errors ? &ctx : NULL));
return ret == 0;
--
2.17.2
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/carlo_bai/coreutils.git
git@gitee.com:carlo_bai/coreutils.git
carlo_bai
coreutils
coreutils
a8

搜索帮助