summaryrefslogtreecommitdiffstats
path: root/patches/fakeroot-1.28/0001-Also-wrap-the-stat-library-call.patch
blob: daff7f3477445549ab168b8d0b0b48637b529a0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
From: Christian Melki <christian.melki@t2data.com>
Date: Wed, 11 May 2022 10:23:40 +0200
Subject: [PATCH] Also wrap the "stat" library call

Patch by: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
Bug-Debian: https://bugs.debian.org/1001961

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.

Signed-off-by: Christian Melki <christian.melki@t2data.com>
---
 configure.ac | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index e7c1c7c484f3..3fa4756557af 100644
--- a/configure.ac
+++ b/configure.ac
@@ -362,9 +362,13 @@ dnl  Digital Unix: stat
 
 :>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)
@@ -375,8 +379,8 @@ dnl
 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)
@@ -518,6 +522,12 @@ AH_VERBATIM([WRAP_STAT],
 #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