gnu: Add kafs-client
[jackhill/guix/guix.git] / gnu / packages / patches / elfutils-tests-ptrace.patch
1 This patch allows us to skip tests that require PTRACE_ATTACH in situations
2 where PTRACE_ATTACH is only allowed when CAP_SYS_PTRACE is held (i.e., for
3 root, by default.)
4
5 Reported at <https://bugzilla.redhat.com/show_bug.cgi?id=1210966>.
6
7 --- elfutils-0.161/tests/run-deleted.sh 2015-04-11 16:38:33.028556235 +0200
8 +++ elfutils-0.161/tests/run-deleted.sh 2015-04-11 16:46:15.012442185 +0200
9 @@ -17,6 +17,15 @@
10
11 . $srcdir/backtrace-subr.sh
12
13 +# Check whether the Yama policy allows us to use PTRACE_ATTACH.
14 +if [ -f /proc/sys/kernel/yama/ptrace_scope ]
15 +then
16 + if [ `cat /proc/sys/kernel/yama/ptrace_scope` -ne 0 ]
17 + then
18 + exit 77
19 + fi
20 +fi
21 +
22 tempfiles deleted deleted-lib.so
23 cp -p ${abs_builddir}/deleted ${abs_builddir}/deleted-lib.so .
24
25 --- elfutils-0.161/tests/vdsosyms.c 2015-04-11 16:40:20.633461110 +0200
26 +++ elfutils-0.161/tests/vdsosyms.c 2015-04-11 16:45:06.611866677 +0200
27 @@ -23,6 +23,8 @@
28 #include <stdio.h>
29 #include <string.h>
30 #include <sys/types.h>
31 +#include <sys/stat.h>
32 +#include <fcntl.h>
33 #include <unistd.h>
34 #include ELFUTILS_HEADER(dwfl)
35
36 @@ -68,6 +70,7 @@ module_callback (Dwfl_Module *mod, void
37 int
38 main (int argc __attribute__ ((unused)), char **argv __attribute__ ((unused)))
39 {
40 + static const char ptrace_scope_file[] = "/proc/sys/kernel/yama/ptrace_scope";
41 static char *debuginfo_path;
42 static const Dwfl_Callbacks proc_callbacks =
43 {
44 @@ -76,6 +79,20 @@ main (int argc __attribute__ ((unused)),
45
46 .find_elf = dwfl_linux_proc_find_elf,
47 };
48 +
49 + /* Check whether the Yama policy allows us to use PTRACE_ATTACH. */
50 + int ptrace_scope = open (ptrace_scope_file, O_RDONLY);
51 + if (ptrace_scope >= 0)
52 + {
53 + char buf[10];
54 + int count = read (ptrace_scope, buf, sizeof buf);
55 + assert (count > 0);
56 + if (buf[0] != '0')
57 + /* We're not allowed, so skip this test. */
58 + return 77;
59 + close (ptrace_scope);
60 + }
61 +
62 Dwfl *dwfl = dwfl_begin (&proc_callbacks);
63 if (dwfl == NULL)
64 error (2, 0, "dwfl_begin: %s", dwfl_errmsg (-1));