[PATCH v2] fakeroot: fix to work with glibc 2.33

Philip Prindeville philipp_subx at redfish-solutions.com
Fri Feb 12 02:23:51 EST 2021


Comments...


> On Feb 11, 2021, at 10:42 PM, Ilya Lipnitskiy <ilya.lipnitskiy at gmail.com> wrote:
> 
> The following commit removed _STAT_VER definitions from glibc:
> https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=8ed005daf0ab03e142500324a34087ce179ae78e
> 
> That subsequently broke fakeroot:
> https://bugs.archlinux.org/task/69572
> https://bugzilla.redhat.com/show_bug.cgi?id=1889862#c13
> https://forum.openwrt.org/t/unable-to-build-toolchain-fakeroot-fails-perhaps-others-after-it/87966
> 
> Make the patch based on Jan Pazdziora's suggestion from here:
> https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/SMQ3RYXEYTVZH6PLQMKNB3NM4XLPMNZO/
> 
> Additionally, add wrappers for newly exported symbols in glibc.
> 
> Tested on my x86_64 Arch Linux machine, fakeroot unit tests pass.
> Also tested by building various .ipks and examining the tar contents, to
> ensure that the owner uid/gid was 0/0.
> 
> Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy at gmail.com>
> ---
> .../300-glibc-2.33-compatibility.patch        | 74 +++++++++++++++++++
> 1 file changed, 74 insertions(+)
> create mode 100644 tools/fakeroot/patches/300-glibc-2.33-compatibility.patch
> 
> diff --git a/tools/fakeroot/patches/300-glibc-2.33-compatibility.patch b/tools/fakeroot/patches/300-glibc-2.33-compatibility.patch
> new file mode 100644
> index 0000000000..2e6beab095
> --- /dev/null
> +++ b/tools/fakeroot/patches/300-glibc-2.33-compatibility.patch
> @@ -0,0 +1,74 @@
> +--- a/libfakeroot.c
> ++++ b/libfakeroot.c
> +@@ -90,6 +90,16 @@
> + #define SEND_GET_XATTR64(a,b,c) send_get_xattr64(a,b)
> + #endif
> + 
> ++#ifndef _STAT_VER
> ++ #if defined (__aarch64__)
> ++  #define _STAT_VER 0
> ++ #elif defined (__x86_64__)
> ++  #define _STAT_VER 1
> ++ #else
> ++  #define _STAT_VER 3
> ++ #endif
> ++#endif
> ++
> + /*
> +    These INT_* (which stands for internal) macros should always be used when
> +    the fakeroot library owns the storage of the stat variable.
> +@@ -1358,6 +1368,54 @@ int renameat(int olddir_fd, const char *
> + #endif /* HAVE_FSTATAT */
> + 
> + 
> ++#ifdef __GLIBC__
> ++#if __GLIBC_PREREQ(2,33)

Minor nit, but please combine these into a single line:

#if defined(__GLIBC__) && __GLIBC_PREREQ(2,33)

As that's easier to grep.


> ++/* Glibc 2.33 exports symbols for these functions in the shared lib */
> ++int lstat(const char *file_name, struct stat *statbuf) {
> ++   return WRAP_LSTAT LSTAT_ARG(_STAT_VER, file_name, statbuf);
> ++}
> ++int stat(const char *file_name, struct stat *st) {
> ++   return WRAP_STAT STAT_ARG(_STAT_VER, file_name, st);
> ++}
> ++int fstat(int fd, struct stat *st) {
> ++   return WRAP_FSTAT FSTAT_ARG(_STAT_VER, fd, st);
> ++}
> ++#ifdef HAVE_FSTATAT

Please indent nested #if or #ifdef's.


> ++int fstatat(int dir_fd, const char *path, struct stat *st, int flags) {
> ++   return WRAP_FSTATAT FSTATAT_ARG(_STAT_VER, dir_fd, path, st, flags);
> ++}
> ++#endif
> ++#ifdef STAT64_SUPPORT
> ++int lstat64(const char *file_name, struct stat64 *st) {
> ++   return WRAP_LSTAT64 LSTAT64_ARG(_STAT_VER, file_name, st);
> ++}
> ++int stat64(const char *file_name, struct stat64 *st) {
> ++   return WRAP_STAT64 STAT64_ARG(_STAT_VER, file_name, st);
> ++}
> ++int fstat64(int fd, struct stat64 *st) {
> ++   return WRAP_FSTAT64 FSTAT64_ARG(_STAT_VER, fd, st);
> ++}
> ++#ifdef HAVE_FSTATAT

Ditto.


> ++int fstatat64(int dir_fd, const char *path, struct stat64 *st, int flags) {
> ++   return WRAP_FSTATAT64 FSTATAT64_ARG(_STAT_VER, dir_fd, path, st, flags);
> ++}
> ++#endif
> ++#endif
> ++int mknod(const char *pathname, mode_t mode, dev_t dev) {
> ++   return WRAP_MKNOD MKNOD_ARG(_STAT_VER, pathname, mode, &dev);
> ++}
> ++#ifdef HAVE_FSTATAT
> ++#ifdef HAVE_MKNODAT

Combine as:

#if defined(HAVE_FSTATAT) && defined(HAVE_MKNODAT)


> ++int mknodat(int dir_fd, const char *pathname, mode_t mode, dev_t dev) {
> ++   return WRAP_MKNODAT MKNODAT_ARG(_STAT_VER, dir_fd, pathname, mode, &dev);
> ++}
> ++#endif
> ++#endif

Combined...


> ++
> ++#endif /* __GLIBC_PREPREQ */
> ++#endif /* __GLIBC__ */

Combined...

> ++
> ++
> + #ifdef FAKEROOT_FAKENET
> + pid_t fork(void)
> + {
> -- 
> 2.30.1




More information about the openwrt-devel mailing list