diff mbox series

fakeroot: fix to work with glibc 2.33

Message ID 20210211031441.628215-1-ilya.lipnitskiy@gmail.com
State Superseded
Headers show
Series fakeroot: fix to work with glibc 2.33 | expand

Commit Message

Ilya Lipnitskiy Feb. 11, 2021, 3:14 a.m. UTC
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/

Tested on my x86_64 Arch Linux machine, fakeroot unit tests pass.

Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
---
 tools/fakeroot/patches/100-portability.patch | 27 ++++++++++++++++----
 1 file changed, 22 insertions(+), 5 deletions(-)

Comments

Felix Fietkau Feb. 11, 2021, 10:39 a.m. UTC | #1
Hi Ilya,

On 2021-02-11 04:14, Ilya Lipnitskiy 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/
> 
> Tested on my x86_64 Arch Linux machine, fakeroot unit tests pass.
> 
> Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
If I'm not misreading the code, it seems to me that this patch might be
incomplete. The old glibc version was carrying inline wrappers for stat,
stat64, etc. Because binaries compiled against the old glibc version
were only containing references to the wrapped internal functions and
never the main functions directly, fakeroot seems to be handling only
the __ prefixed internal functions.
Defining _STAT_VER fixes the compile error and should work with binaries
compiled against old glibc, but I wonder if this also works with newer
binaries that now reference different functions.
Did you explicitly test that?

Thanks for looking into this,

- Felix
Ilya Lipnitskiy Feb. 12, 2021, 5:30 a.m. UTC | #2
Hi Felix,

On Thu, Feb 11, 2021 at 2:39 AM Felix Fietkau <nbd@nbd.name> wrote:
> Defining _STAT_VER fixes the compile error and should work with binaries
> compiled against old glibc, but I wonder if this also works with newer
> binaries that now reference different functions.
> Did you explicitly test that?
Good catch, I did some more work and added wrappers for the newly
exported symbols. I'll post the v2 patch soon.

Ilya
diff mbox series

Patch

diff --git a/tools/fakeroot/patches/100-portability.patch b/tools/fakeroot/patches/100-portability.patch
index 7ba12996be..edf63d3ff4 100644
--- a/tools/fakeroot/patches/100-portability.patch
+++ b/tools/fakeroot/patches/100-portability.patch
@@ -1,6 +1,23 @@ 
 --- a/libfakeroot.c
 +++ b/libfakeroot.c
-@@ -112,8 +112,16 @@
+@@ -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.
+@@ -112,8 +122,16 @@
  #define INT_SEND_STAT(a,b) SEND_STAT(a,b,_STAT_VER)
  #define INT_SEND_GET_XATTR(a,b) SEND_GET_XATTR(a,b,_STAT_VER)
  #define INT_SEND_GET_STAT(a,b) SEND_GET_STAT(a,b)
@@ -17,7 +34,7 @@ 
  #include <stdlib.h>
  #include <sys/ipc.h>
  #include <sys/msg.h>
-@@ -125,7 +133,6 @@
+@@ -125,7 +143,6 @@
  #include <unistd.h>
  #include <dirent.h>
  #include <errno.h>
@@ -25,7 +42,7 @@ 
  #ifdef HAVE_SYS_ACL_H
  #include <sys/acl.h>
  #endif /* HAVE_SYS_ACL_H */
-@@ -188,6 +195,15 @@ extern int unsetenv (const char *name);
+@@ -188,6 +205,15 @@ extern int unsetenv (const char *name);
  #undef __lxstat64
  #undef _FILE_OFFSET_BITS
  
@@ -41,7 +58,7 @@ 
  /*
  // next_wrap_st:
  // this structure is used in next_wrap, which is defined in
-@@ -1911,7 +1927,7 @@ ssize_t fremovexattr(int fd, const char
+@@ -1911,7 +1937,7 @@ ssize_t fremovexattr(int fd, const char
  }
  #endif /* HAVE_FREMOVEXATTR */
  
@@ -50,7 +67,7 @@ 
    if (fakeroot_disabled)
      return next_setpriority(which, who, prio);
    next_setpriority(which, who, prio);
-@@ -2520,3 +2536,19 @@ int sysinfo(int command, char *buf, long
+@@ -2520,3 +2546,19 @@ int sysinfo(int command, char *buf, long
      }
  }
  #endif