]> granicus.if.org Git - strace/commitdiff
Make parsers of capget and capset syscalls self-contained
authorDmitry V. Levin <ldv@altlinux.org>
Wed, 3 Dec 2014 20:39:20 +0000 (20:39 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sat, 6 Dec 2014 03:41:39 +0000 (03:41 +0000)
Various versions of <linux/capability.h> used to require different
workarounds to avoid conflicts with types defined by libc headers.
Define all required types and constants locally to fix this issue.

* configure.ac (AC_CHECK_HEADERS): Remove linux/capability.h.
* capability.c: Do not include <linux/capability.h>, remove workarounds
for problematic versions of <linux/capability.h> file.
Define CAP_* and _LINUX_CAPABILITY_VERSION_* constants as enums.
(struct __user_cap_header_struct, struct __user_cap_data_struct): Define.
* xlat/cap_version.in: Add #unconditional.
* xlat/capabilities.in: Likewise.

capability.c
configure.ac
xlat/cap_version.in
xlat/capabilities.in

index 18a5691caef02d7d9331e9637bdaca6fc07d83c6..3c7666fc202177852a7c6de183c7efbbd6930447 100644 (file)
@@ -1,31 +1,61 @@
 #include "defs.h"
 
-#define _LINUX_SOCKET_H
-#define _LINUX_FS_H
-
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#ifdef HAVE_LINUX_CAPABILITY_H
-# include <linux/capability.h>
-#endif
-
-#ifdef SYS_capget
+enum {
+       CAP_CHOWN,
+       CAP_DAC_OVERRIDE,
+       CAP_DAC_READ_SEARCH,
+       CAP_FOWNER,
+       CAP_FSETID,
+       CAP_KILL,
+       CAP_SETGID,
+       CAP_SETUID,
+       CAP_SETPCAP,
+       CAP_LINUX_IMMUTABLE,
+       CAP_NET_BIND_SERVICE,
+       CAP_NET_BROADCAST,
+       CAP_NET_ADMIN,
+       CAP_NET_RAW,
+       CAP_IPC_LOCK,
+       CAP_IPC_OWNER,
+       CAP_SYS_MODULE,
+       CAP_SYS_RAWIO,
+       CAP_SYS_CHROOT,
+       CAP_SYS_PTRACE,
+       CAP_SYS_PACCT,
+       CAP_SYS_ADMIN,
+       CAP_SYS_BOOT,
+       CAP_SYS_NICE,
+       CAP_SYS_RESOURCE,
+       CAP_SYS_TIME,
+       CAP_SYS_TTY_CONFIG,
+       CAP_MKNOD,
+       CAP_LEASE,
+       CAP_AUDIT_WRITE,
+       CAP_AUDIT_CONTROL,
+       CAP_SETFCAP
+};
 
 #include "xlat/capabilities.h"
 
-#ifndef _LINUX_CAPABILITY_VERSION_1
-# define _LINUX_CAPABILITY_VERSION_1 0x19980330
-#endif
-#ifndef _LINUX_CAPABILITY_VERSION_2
-# define _LINUX_CAPABILITY_VERSION_2 0x20071026
-#endif
-#ifndef _LINUX_CAPABILITY_VERSION_3
-# define _LINUX_CAPABILITY_VERSION_3 0x20080522
-#endif
+enum {
+       _LINUX_CAPABILITY_VERSION_1 = 0x19980330,
+       _LINUX_CAPABILITY_VERSION_2 = 0x20071026,
+       _LINUX_CAPABILITY_VERSION_3 = 0x20080522
+};
 
 #include "xlat/cap_version.h"
 
+typedef struct user_cap_header_struct {
+       uint32_t version;
+       int pid;
+} *cap_user_header_t;
+
+typedef struct user_cap_data_struct {
+       uint32_t effective;
+       uint32_t permitted;
+       uint32_t inheritable;
+} *cap_user_data_t;
+
 static void
 print_cap_header(struct tcb *tcp, unsigned long addr)
 {
@@ -92,17 +122,3 @@ sys_capset(struct tcb *tcp)
        }
        return 0;
 }
-
-#else
-
-int sys_capget(struct tcb *tcp)
-{
-       return printargs(tcp);
-}
-
-int sys_capset(struct tcb *tcp)
-{
-       return printargs(tcp);
-}
-
-#endif
index aec1d47d9f8a89cd2ccc2de2066817a58de4ea9d..8dba8afd7c24564c6cdbbd5563d9b9c5c753bfb0 100644 (file)
@@ -232,7 +232,6 @@ AC_CHECK_HEADERS(m4_normalize([
        elf.h
        inttypes.h
        ioctls.h
-       linux/capability.h
        linux/perf_event.h
        linux/ptrace.h
        linux/utsname.h
index 70d6caee3ab3197396439488d72e93db1c6bf97f..3d5b7446430c921676a7690270415285f87d7a1b 100644 (file)
@@ -1,3 +1,4 @@
+#unconditional
 _LINUX_CAPABILITY_VERSION_1
 _LINUX_CAPABILITY_VERSION_2
 _LINUX_CAPABILITY_VERSION_3
index 59f24f749cc6a3c3a90c8696a79db774f3b3d095..4c48b847cd87ed0e60e84599a39cac169b3608fd 100644 (file)
@@ -1,3 +1,4 @@
+#unconditional
 1<<CAP_CHOWN
 1<<CAP_DAC_OVERRIDE
 1<<CAP_DAC_READ_SEARCH