website: manual: refresh qi.html to be reflected on the website
[dragora.git] / patches / attr / 14adc898a36948267bfe5c63b399996879e94c98
blob5691b15420ce78f39749777b748110ef68cbdd72
1 From 14adc898a36948267bfe5c63b399996879e94c98 Mon Sep 17 00:00:00 2001
2 From: Andreas Gruenbacher <agruenba@redhat.com>
3 Date: Fri, 17 Aug 2018 14:07:31 +0200
4 Subject: Switch back to syscall()
6 Switch back to syscall() for the *xattr system calls.  The current
7 mechanism of forwarding those calls to glibc breaks libraries like
8 libfakeroot (fakeroot) and libasan (the gcc address sanitizer; gcc
9 -fsanitize=address).
11 Those libraries provide wrappers for functions defined in other shared
12 libraries, usually glibc, do their own processing, and forward calls to
13 the original symbols looke dup via dlsym(RTLD_NEXT, "symbol_name").  In
14 our case, dlsym returns the libattr_*xattr wrappers.  However, when our
15 wrappers try calling glibc, they end up calling the libfakeroot /
16 libasan wrappers instead because those override the original symbols =>
17 recursion.
19 The libattr_*xattr wrappers will only be used when symbols are looked up
20 at runtime (dlopen / dlsym).  Programs linking against libattr will
21 directly use the glibc provided symbols.  Therefore, the slightly worse
22 performance of syscall() won't affect any of the "normal" users of
23 libattr.
24 ---
25  libattr/syscalls.c | 26 ++++++++++++++------------
26  1 file changed, 14 insertions(+), 12 deletions(-)
28 diff --git a/libattr/syscalls.c b/libattr/syscalls.c
29 index 3013aa0..721ad7f 100644
30 --- a/libattr/syscalls.c
31 +++ b/libattr/syscalls.c
32 @@ -22,6 +22,8 @@
34  #include "config.h"
36 +#include <unistd.h>
37 +#include <sys/syscall.h>
38  #include <sys/xattr.h>
40  #ifdef HAVE_VISIBILITY_ATTRIBUTE
41 @@ -31,67 +33,67 @@
42  int libattr_setxattr(const char *path, const char *name,
43                      void *value, size_t size, int flags)
44  {
45 -       return setxattr(path, name, value, size, flags);
46 +       return syscall(__NR_setxattr, path, name, value, size, flags);
47  }
49  int libattr_lsetxattr(const char *path, const char *name,
50                       void *value, size_t size, int flags)
51  {
52 -       return lsetxattr(path, name, value, size, flags);
53 +       return syscall(__NR_lsetxattr, path, name, value, size, flags);
54  }
56  int libattr_fsetxattr(int filedes, const char *name,
57                       void *value, size_t size, int flags)
58  {
59 -       return fsetxattr(filedes, name, value, size, flags);
60 +       return syscall(__NR_fsetxattr, filedes, name, value, size, flags);
61  }
63  ssize_t libattr_getxattr(const char *path, const char *name,
64                          void *value, size_t size)
65  {
66 -       return getxattr(path, name, value, size);
67 +       return syscall(__NR_getxattr, path, name, value, size);
68  }
70  ssize_t libattr_lgetxattr(const char *path, const char *name,
71                           void *value, size_t size)
72  {
73 -       return lgetxattr(path, name, value, size);
74 +       return syscall(__NR_lgetxattr, path, name, value, size);
75  }
77  ssize_t libattr_fgetxattr(int filedes, const char *name,
78                           void *value, size_t size)
79  {
80 -       return fgetxattr(filedes, name, value, size);
81 +       return syscall(__NR_fgetxattr, filedes, name, value, size);
82  }
84  ssize_t libattr_listxattr(const char *path, char *list, size_t size)
85  {
86 -       return listxattr(path, list, size);
87 +       return syscall(__NR_listxattr, path, list, size);
88  }
90  ssize_t libattr_llistxattr(const char *path, char *list, size_t size)
91  {
92 -       return llistxattr(path, list, size);
93 +       return syscall(__NR_llistxattr, path, list, size);
94  }
96  ssize_t libattr_flistxattr(int filedes, char *list, size_t size)
97  {
98 -       return flistxattr(filedes, list, size);
99 +       return syscall(__NR_flistxattr, filedes, list, size);
102  int libattr_removexattr(const char *path, const char *name)
104 -       return removexattr(path, name);
105 +       return syscall(__NR_removexattr, path, name);
108  int libattr_lremovexattr(const char *path, const char *name)
110 -       return lremovexattr(path, name);
111 +       return syscall(__NR_lremovexattr, path, name);
114  int libattr_fremovexattr(int filedes, const char *name)
116 -       return fremovexattr(filedes, name);
117 +       return syscall(__NR_fremovexattr, filedes, name);
120  #ifdef HAVE_VISIBILITY_ATTRIBUTE
121 -- 
122 cgit v1.0-41-gc330