aboutsummaryrefslogtreecommitdiff
path: root/pkgs/development/libraries/attr
diff options
context:
space:
mode:
authorMatthew Bauer <mjbauer95@gmail.com>2020-06-26 16:19:40 -0400
committerFrederik Rietdijk <freddyrietdijk@fridh.nl>2020-07-31 08:56:53 +0200
commitf36899e11826b18fdd60496b28af692afbea8b85 (patch)
tree2bdee63138ef562e41df64a438eeaffc8e9cbf69 /pkgs/development/libraries/attr
parent50a5c1853d571c26bab9f22e49e94ff13e1ffc92 (diff)
attr: inline syscall patch
Unfortunately the output of git.savannah.nongnu.org changes with each gitweb update. This means that the current has “0gja54fz79a9ma6b4mprnjxq77l5yg2z9xknlwhmkcrfnam02qxp” is no longer correct: $ nix-prefetch-url https://git.savannah.nongnu.org/cgit/attr.git/patch/\?id=14adc898a36948267bfe5c63b399996879e94c98 1g8sky52rjg9fpmrddza1af89s9qd4bzsbxqb7mc5bv8gyh10s1k Normally, we use fetchpatch to strip this out, but unfortunately attr cannot use fetchpatch due to being used in bootstrapping fetchurl. That is, it can’t use a custom postFetch since <nix/fetchurl.nix> doesn’t support that. To solve this problem, just inline the patch for now.
Diffstat (limited to 'pkgs/development/libraries/attr')
-rw-r--r--pkgs/development/libraries/attr/default.nix5
-rw-r--r--pkgs/development/libraries/attr/syscall.patch120
2 files changed, 121 insertions, 4 deletions
diff --git a/pkgs/development/libraries/attr/default.nix b/pkgs/development/libraries/attr/default.nix
index 497262c04d71..44eab6bc53ca 100644
--- a/pkgs/development/libraries/attr/default.nix
+++ b/pkgs/development/libraries/attr/default.nix
@@ -14,10 +14,7 @@ stdenv.mkDerivation rec {
patches = [
# fix fakechroot: https://github.com/dex4er/fakechroot/issues/57
- (fetchurl {
- url = "https://git.savannah.nongnu.org/cgit/attr.git/patch/?id=14adc898a36948267bfe5c63b399996879e94c98";
- sha256 = "0gja54fz79a9ma6b4mprnjxq77l5yg2z9xknlwhmkcrfnam02qxp";
- })
+ ./syscall.patch
];
postPatch = ''
diff --git a/pkgs/development/libraries/attr/syscall.patch b/pkgs/development/libraries/attr/syscall.patch
new file mode 100644
index 000000000000..be2cfb3928b4
--- /dev/null
+++ b/pkgs/development/libraries/attr/syscall.patch
@@ -0,0 +1,120 @@
+From 14adc898a36948267bfe5c63b399996879e94c98 Mon Sep 17 00:00:00 2001
+From: Andreas Gruenbacher <agruenba@redhat.com>
+Date: Fri, 17 Aug 2018 14:07:31 +0200
+Subject: Switch back to syscall()
+
+Switch back to syscall() for the *xattr system calls. The current
+mechanism of forwarding those calls to glibc breaks libraries like
+libfakeroot (fakeroot) and libasan (the gcc address sanitizer; gcc
+-fsanitize=address).
+
+Those libraries provide wrappers for functions defined in other shared
+libraries, usually glibc, do their own processing, and forward calls to
+the original symbols looke dup via dlsym(RTLD_NEXT, "symbol_name"). In
+our case, dlsym returns the libattr_*xattr wrappers. However, when our
+wrappers try calling glibc, they end up calling the libfakeroot /
+libasan wrappers instead because those override the original symbols =>
+recursion.
+
+The libattr_*xattr wrappers will only be used when symbols are looked up
+at runtime (dlopen / dlsym). Programs linking against libattr will
+directly use the glibc provided symbols. Therefore, the slightly worse
+performance of syscall() won't affect any of the "normal" users of
+libattr.
+---
+ libattr/syscalls.c | 26 ++++++++++++++------------
+ 1 file changed, 14 insertions(+), 12 deletions(-)
+
+diff --git a/libattr/syscalls.c b/libattr/syscalls.c
+index 3013aa0..721ad7f 100644
+--- a/libattr/syscalls.c
++++ b/libattr/syscalls.c
+@@ -22,6 +22,8 @@
+
+ #include "config.h"
+
++#include <unistd.h>
++#include <sys/syscall.h>
+ #include <sys/xattr.h>
+
+ #ifdef HAVE_VISIBILITY_ATTRIBUTE
+@@ -31,67 +33,67 @@
+ int libattr_setxattr(const char *path, const char *name,
+ void *value, size_t size, int flags)
+ {
+- return setxattr(path, name, value, size, flags);
++ return syscall(__NR_setxattr, path, name, value, size, flags);
+ }
+
+ int libattr_lsetxattr(const char *path, const char *name,
+ void *value, size_t size, int flags)
+ {
+- return lsetxattr(path, name, value, size, flags);
++ return syscall(__NR_lsetxattr, path, name, value, size, flags);
+ }
+
+ int libattr_fsetxattr(int filedes, const char *name,
+ void *value, size_t size, int flags)
+ {
+- return fsetxattr(filedes, name, value, size, flags);
++ return syscall(__NR_fsetxattr, filedes, name, value, size, flags);
+ }
+
+ ssize_t libattr_getxattr(const char *path, const char *name,
+ void *value, size_t size)
+ {
+- return getxattr(path, name, value, size);
++ return syscall(__NR_getxattr, path, name, value, size);
+ }
+
+ ssize_t libattr_lgetxattr(const char *path, const char *name,
+ void *value, size_t size)
+ {
+- return lgetxattr(path, name, value, size);
++ return syscall(__NR_lgetxattr, path, name, value, size);
+ }
+
+ ssize_t libattr_fgetxattr(int filedes, const char *name,
+ void *value, size_t size)
+ {
+- return fgetxattr(filedes, name, value, size);
++ return syscall(__NR_fgetxattr, filedes, name, value, size);
+ }
+
+ ssize_t libattr_listxattr(const char *path, char *list, size_t size)
+ {
+- return listxattr(path, list, size);
++ return syscall(__NR_listxattr, path, list, size);
+ }
+
+ ssize_t libattr_llistxattr(const char *path, char *list, size_t size)
+ {
+- return llistxattr(path, list, size);
++ return syscall(__NR_llistxattr, path, list, size);
+ }
+
+ ssize_t libattr_flistxattr(int filedes, char *list, size_t size)
+ {
+- return flistxattr(filedes, list, size);
++ return syscall(__NR_flistxattr, filedes, list, size);
+ }
+
+ int libattr_removexattr(const char *path, const char *name)
+ {
+- return removexattr(path, name);
++ return syscall(__NR_removexattr, path, name);
+ }
+
+ int libattr_lremovexattr(const char *path, const char *name)
+ {
+- return lremovexattr(path, name);
++ return syscall(__NR_lremovexattr, path, name);
+ }
+
+ int libattr_fremovexattr(int filedes, const char *name)
+ {
+- return fremovexattr(filedes, name);
++ return syscall(__NR_fremovexattr, filedes, name);
+ }
+
+ #ifdef HAVE_VISIBILITY_ATTRIBUTE