From c56bab68a86f27959d02604210b86b129e297c95 Mon Sep 17 00:00:00 2001 From: Chunmei Xu Date: Tue, 2 Apr 2024 17:37:53 +0800 Subject: [PATCH] fix rsync lchmod Signed-off-by: Chunmei Xu --- 1000-rsync-lchmod.patch | 53 +++++++++++++++++++++++++++++++++++++++++ rsync.spec | 9 ++++++- 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 1000-rsync-lchmod.patch diff --git a/1000-rsync-lchmod.patch b/1000-rsync-lchmod.patch new file mode 100644 index 0000000..813c6b5 --- /dev/null +++ b/1000-rsync-lchmod.patch @@ -0,0 +1,53 @@ +diff --git a/syscall.c b/syscall.c +index b9c3b4ef..11d10e4a 100644 +--- a/syscall.c ++++ b/syscall.c +@@ -227,27 +227,35 @@ int do_open(const char *pathname, int flags, mode_t mode) + #ifdef HAVE_CHMOD + int do_chmod(const char *path, mode_t mode) + { ++ static int switch_step = 0; + int code; + if (dry_run) return 0; + RETURN_ERROR_IF_RO_OR_LO; ++ switch (switch_step) { + #ifdef HAVE_LCHMOD +- code = lchmod(path, mode & CHMOD_BITS); +-#else +- if (S_ISLNK(mode)) { ++#include "case_N.h" ++ if ((code = lchmod(path, mode & CHMOD_BITS)) == 0 || errno != ENOTSUP) ++ break; ++ switch_step++; ++#endif ++ ++#include "case_N.h" ++ if (S_ISLNK(mode)) { + # if defined HAVE_SETATTRLIST +- struct attrlist attrList; +- uint32_t m = mode & CHMOD_BITS; /* manpage is wrong: not mode_t! */ ++ struct attrlist attrList; ++ uint32_t m = mode & CHMOD_BITS; /* manpage is wrong: not mode_t! */ + +- memset(&attrList, 0, sizeof attrList); +- attrList.bitmapcount = ATTR_BIT_MAP_COUNT; +- attrList.commonattr = ATTR_CMN_ACCESSMASK; +- code = setattrlist(path, &attrList, &m, sizeof m, FSOPT_NOFOLLOW); ++ memset(&attrList, 0, sizeof attrList); ++ attrList.bitmapcount = ATTR_BIT_MAP_COUNT; ++ attrList.commonattr = ATTR_CMN_ACCESSMASK; ++ code = setattrlist(path, &attrList, &m, sizeof m, FSOPT_NOFOLLOW); + # else +- code = 1; ++ code = 1; + # endif +- } else +- code = chmod(path, mode & CHMOD_BITS); /* DISCOURAGED FUNCTION */ +-#endif /* !HAVE_LCHMOD */ ++ } else ++ code = chmod(path, mode & CHMOD_BITS); /* DISCOURAGED FUNCTION */ ++ break; ++ } + if (code != 0 && (preserve_perms || preserve_executability)) + return code; + return 0; diff --git a/rsync.spec b/rsync.spec index 7a35118..6103917 100644 --- a/rsync.spec +++ b/rsync.spec @@ -1,4 +1,4 @@ -%define anolis_release .0.1 +%define anolis_release .0.2 %global _hardened_build 1 %define isprerelease 0 @@ -46,6 +46,9 @@ Patch11: rsync-3.1.3-cve-2022-29154.patch Patch12: rsync-3.1.3-cve-2022-37434.patch Patch13: rsync-3.1.3-filtering-rules.patch Patch14: rsync-3.1.3-missing-xattr-filter.patch +# https://github.com/WayneD/rsync/commit/9dd62525f3b98d692e031f22c02be8f775966503 +# https://github.com/WayneD/rsync/issues/109 +Patch1000: 1000-rsync-lchmod.patch %description Rsync uses a reliable algorithm to bring remote and host files into @@ -106,6 +109,7 @@ patch -p1 -i patches/copy-devices.diff %patch12 -p1 -b .cve-2022-37434 %patch13 -p1 -b .filtering-rules %patch14 -p1 -b .xattr-filter +%patch1000 -p1 %build %configure @@ -154,6 +158,9 @@ chmod -x support/* %doc NEWS OLDNEWS README support/ tech_report.tex %changelog +* Tue Apr 02 2024 Chunmei Xu - 3.1.3-19.0.2.1 +- fix rsync lchmod + * Tue Jul 04 2023 Xiaoping Liu - 3.1.3-19.0.1.1 - Add doc sub package -- Gitee