From aed535c7d67ceac277822f247523432559e638f0 Mon Sep 17 00:00:00 2001 From: Zach van Rijn Date: Tue, 18 Jan 2022 18:04:04 +0000 Subject: system/fakeroot: add two patches for ppc64. fixes #438. --- system/fakeroot/APKBUILD | 7 ++- system/fakeroot/also-wrap-stat-library-call.patch | 63 +++++++++++++++++++++++ system/fakeroot/fix-prototype-generation.patch | 59 +++++++++++++++++++++ 3 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 system/fakeroot/also-wrap-stat-library-call.patch create mode 100644 system/fakeroot/fix-prototype-generation.patch (limited to 'system') diff --git a/system/fakeroot/APKBUILD b/system/fakeroot/APKBUILD index 4728af5f5..0bb278cf7 100644 --- a/system/fakeroot/APKBUILD +++ b/system/fakeroot/APKBUILD @@ -17,6 +17,9 @@ source="https://snapshot.debian.org/archive/debian/20210907T092512Z/pool/main/f/ fakeroot-no64.patch fakeroot-stdint.patch xstatjunk.patch + + fix-prototype-generation.patch + also-wrap-stat-library-call.patch " build() { @@ -48,4 +51,6 @@ package() { sha512sums="dad193b283b48a25806c5bcd06d1f5bbd183ccd40a3fc25f3e7bb88fd6579024f958321f8336654348a1d0a547d4ad19ed11aab5ec9441d6ef493ee6e4c78081 fakeroot_1.26.orig.tar.gz 7a832e6bed3838c7c488e0e12ba84b8d256e84bbb06d6020247452a991de505fa5c6bd7bcb84dce8753eb242e0fcab863b5461301cd56695f2b003fe8d6ff209 fakeroot-no64.patch ed7a58b0d201139545420f9e5429f503c00e00f36dea84473e77ea99b23bb8d421da1a8a8ce98ff90e72e378dff4cb9ea3c1a863a969899a5f50dfac3b9c5fac fakeroot-stdint.patch -5efd33fd778bd94a529ed7e439fb8fea25ff865dda3f6f9e431264e942b37f3b5d7a0ad14107b55c5fa81b86efd5a82aedb3803cfab08ec57f27f5b229d2fe88 xstatjunk.patch" +5efd33fd778bd94a529ed7e439fb8fea25ff865dda3f6f9e431264e942b37f3b5d7a0ad14107b55c5fa81b86efd5a82aedb3803cfab08ec57f27f5b229d2fe88 xstatjunk.patch +63db66b0d883495151f817c4e57bdaaff992667416f2f5b03c9b66b65f1fba1762f709dd5153717aa4008d7be0fbc58bf1f41eb2b35dc61047b0cc0b762e145b fix-prototype-generation.patch +0c391ac657518a17af776d804a93efb82e950900e084822c3c04acfcf46a4b1321dbdc878343b68742882a2088a9542889bab561a64efc4638c5a6ec5948081d also-wrap-stat-library-call.patch" diff --git a/system/fakeroot/also-wrap-stat-library-call.patch b/system/fakeroot/also-wrap-stat-library-call.patch new file mode 100644 index 000000000..40c830a36 --- /dev/null +++ b/system/fakeroot/also-wrap-stat-library-call.patch @@ -0,0 +1,63 @@ +Subject: Also wrap the "stat" library call +Author: Christoph Biedl +Date: 2021-12-20 +Bug-Debian: https://bugs.debian.org/1001961 +Forwarded: Yes + + Seems changes in glibc 2.33 caused the stat() function to be mapped + into a stat() library call instead of __xstat() as it used to be. + + However, fakeroot does not wrap this, causing files to be reported + with the real owner, not 0 as expected. + + The fix for this got a bit ugly as the abstraction in configure.ac + would not allow wrapping both "stat" and "__xstat". So enhance the + search list capabilities with an optional symbol how the wrapped + function is named internally. Also hack the parser so "stat" gets + actually probed and not mistaken for __xstat. + + Using "realstat" as a symbol is not the best choice as it might be + confusing, but "statstat" seemed even worse. + +--- a/configure.ac ++++ b/configure.ac +@@ -353,9 +353,13 @@ + + :>fakerootconfig.h.tmp + +-for SEARCH in %stat f%stat l%stat f%statat %stat64 f%stat64 l%stat64 f%statat64 %mknod %mknodat; do +- FUNC=`echo $SEARCH|sed -e 's/.*%//'` ++for SEARCH in %stat s%tat@realstat f%stat l%stat f%statat %stat64 f%stat64 l%stat64 f%statat64 %mknod %mknodat; do ++ FUNC=`echo $SEARCH|sed -e 's/.*%// ; s/@.*//'` + PRE=`echo $SEARCH|sed -e 's/%.*//'` ++ SYMBOL=`echo $SEARCH|sed -e 's/.*@//'` ++ if test "$SYMBOL" = "$SEARCH" ; then ++ SYMBOL="${PRE}${FUNC}" ++ fi + FOUND= + for WRAPPED in __${PRE}x${FUNC} _${PRE}x${FUNC} __${PRE}${FUNC}13 ${PRE}${FUNC}; do + AC_CHECK_FUNCS($WRAPPED,FOUND=$WRAPPED) +@@ -366,8 +370,8 @@ + dnl for WRAPPED in _${PRE}${FUNC}; do + dnl FOUND=$WRAPPED + if test -n "$FOUND"; then +- PF=[`echo ${PRE}${FUNC}| tr '[a-z]' '[A-Z]'`] +- DEFINE_WRAP=[`echo wrap_${PRE}${FUNC}| tr '[a-z]' '[A-Z]'`] ++ PF=[`echo $SYMBOL | tr '[a-z]' '[A-Z]'`] ++ DEFINE_WRAP=[`echo wrap_${SYMBOL}| tr '[a-z]' '[A-Z]'`] + DEFINE_NEXT=[`echo wrap_${FOUND}| tr '[a-z]' '[A-Z]'`] + DEFINE_ARG=[`echo wrap_${FOUND}| tr '[a-z]' '[A-Z]'`] + AC_DEFINE_UNQUOTED(WRAP_${PF}, $FOUND) +@@ -509,6 +513,12 @@ + #define TMP_STAT __astat + #define NEXT_STAT_NOARG next___astat + ++#define WRAP_REALSTAT __astat ++#define WRAP_REALSTAT_QUOTE __astat ++#define WRAP_REALSTAT_RAW __astat ++#define TMP_REALSTAT __astat ++#define NEXT_REALSTAT_NOARG next___astat ++ + #define WRAP_LSTAT_QUOTE __astat + #define WRAP_LSTAT __astat + #define WRAP_LSTAT_RAW __astat diff --git a/system/fakeroot/fix-prototype-generation.patch b/system/fakeroot/fix-prototype-generation.patch new file mode 100644 index 000000000..38d32ff3b --- /dev/null +++ b/system/fakeroot/fix-prototype-generation.patch @@ -0,0 +1,59 @@ +Subject: Fix prototype generation for openat +Author: Christoph Biedl +Date: 2021-12-30 +Bug-Debian: https://bugs.debian.org/995393 +Forwarded: Yes (implicitely) + + As jrtc27 pointed out in IRC, ppc64el is more strict than other + architectures when it comes to va_arg handling: + + it's that ppc64le uses the elfv2 abi, and for variadic calls you + must reserve space for a parameter save area + + So enhance wrapawk to create a proper prototype and argument + handling although it's specific to the openat call. Also add the + missing documentation for the sixth column to wrapfunc.inp. + +--- a/wrapawk ++++ b/wrapawk +@@ -37,7 +37,25 @@ + argtype=$3; + argname=$4; + MACRO=$5; +- if(MACRO){ ++ openat_extra=$6; ++ if(openat_extra){ ++ print " {(void(*))&next_" name ", \"" name "\"}," > structfile; ++ print "extern " ret " (*next_" name ")" openat_extra ";" > headerfile; ++ print ret " (*next_" name ")" openat_extra "=tmp_" name ";"> deffile; ++ ++ print ret " tmp_" name, openat_extra "{" > tmpffile; ++ print " mode_t mode = 0;" > tmpffile; ++ print " if (flags & O_CREAT) {" > tmpffile; ++ print " va_list args;" > tmpffile; ++ print " va_start(args, flags);" > tmpffile; ++ print " mode = va_arg(args, int);" > tmpffile; ++ print " va_end(args);" > tmpffile; ++ print " }" > tmpffile; ++ print " load_library_symbols();" > tmpffile; ++ print " return next_" name, argname ";" > tmpffile; ++ print "}" > tmpffile; ++ print "" > tmpffile; ++ } else if(MACRO){ + print " {(void(*))&NEXT_" MACRO "_NOARG, " name "_QUOTE}," > structfile; + print "extern " ret " (*NEXT_" MACRO "_NOARG)" argtype ";" > headerfile; + print ret " (*NEXT_" MACRO "_NOARG)" argtype "=TMP_" MACRO ";"> deffile; +--- a/wrapfunc.inp ++++ b/wrapfunc.inp +@@ -9,8 +9,10 @@ + /**/ */ + /* each line of this file lists 4 fields, seperated by a ";". */ + /* The first field is the name of the wrapped function, then it's return */ +-/* value. After that come the function arguments with types, and the last */ ++/* value. After that come the function arguments with types, and the fifth */ + /* field contains the function arguments without types. */ ++/* A sixth field is a special needed when wrapping the openat syscall. */ ++/* Otherwise it's like the third (function arguments with types). */ + /**/ + + /* __*xstat are used on glibc systems instead of just *xstat. */ -- cgit v1.2.3-70-g09d2