diff options
author | Andrew G. Morgan <morgan@kernel.org> | 2008-05-24 14:43:53 -0700 |
---|---|---|
committer | Andrew G. Morgan <morgan@kernel.org> | 2008-05-24 14:43:53 -0700 |
commit | 85aaecf6a816ebcf01d76772677ea156d26887c3 (patch) | |
tree | 00182f64ae7b189a663a4b0d4d5db7b45c2177c5 | |
parent | 16ad468ebfe8954701ec6b57689448a12bd70176 (diff) | |
download | libcap-85aaecf6a816ebcf01d76772677ea156d26887c3.tar.gz |
Drop dependency on current value of _LINUX_CAPABILITY_VERSION
Be more explicit with a local definition of _LIBCAP_CAPABILITY_* to
indicate the libraries preferred capability revision.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
-rw-r--r-- | libcap/cap_alloc.c | 2 | ||||
-rw-r--r-- | libcap/cap_flag.c | 2 | ||||
-rw-r--r-- | libcap/cap_proc.c | 2 | ||||
-rw-r--r-- | libcap/libcap.h | 29 |
4 files changed, 23 insertions, 12 deletions
diff --git a/libcap/cap_alloc.c b/libcap/cap_alloc.c index 78df97c..c44c7b8 100644 --- a/libcap/cap_alloc.c +++ b/libcap/cap_alloc.c @@ -28,7 +28,7 @@ cap_t cap_init(void) result = (cap_t) (raw_data + 1); memset(result, 0, sizeof(*result)); - result->head.version = _LINUX_CAPABILITY_VERSION; + result->head.version = _LIBCAP_CAPABILITY_VERSION; capget(&result->head, NULL); /* load the kernel-capability version */ switch (result->head.version) { diff --git a/libcap/cap_flag.c b/libcap/cap_flag.c index 536f655..78e83a5 100644 --- a/libcap/cap_flag.c +++ b/libcap/cap_flag.c @@ -106,7 +106,7 @@ int cap_clear_flag(cap_t cap_d, cap_flag_t flag) if (good_cap_t(cap_d)) { unsigned i; - for (i=0; i<_LINUX_CAPABILITY_U32S; i++) { + for (i=0; i<_LIBCAP_CAPABILITY_U32S; i++) { cap_d->u[i].flat[flag] = 0; } return 0; diff --git a/libcap/cap_proc.c b/libcap/cap_proc.c index 40793b4..61c5b12 100644 --- a/libcap/cap_proc.c +++ b/libcap/cap_proc.c @@ -76,7 +76,7 @@ int capsetp(pid_t pid, cap_t cap_d) _cap_debug("setting process capabilities for proc %d", pid); cap_d->head.pid = pid; error = capset(&cap_d->head, &cap_d->u[0].set); - cap_d->head.version = _LINUX_CAPABILITY_VERSION; + cap_d->head.version = _LIBCAP_CAPABILITY_VERSION; cap_d->head.pid = 0; return error; diff --git a/libcap/libcap.h b/libcap/libcap.h index d250aac..c763b84 100644 --- a/libcap/libcap.h +++ b/libcap/libcap.h @@ -25,6 +25,10 @@ /* include the names for the caps and a definition of __CAP_BITS */ #include "cap_names.h" +#ifndef _LINUX_CAPABILITY_U32S_1 +# define _LINUX_CAPABILITY_U32S_1 1 +#endif /* ndef _LINUX_CAPABILITY_U32S */ + /* * Do we match the local kernel? */ @@ -34,7 +38,7 @@ # error Kernel <linux/capability.h> does not support library # error file "libcap.h" --> fix and recompile libcap -#elif (_LINUX_CAPABILITY_VERSION == 0x19980330) +#elif !defined(_LINUX_CAPABILITY_VERSION_2) # warning Kernel <linux/capability.h> does not support 64-bit capabilities # warning and libcap is being built with no support for 64-bit capabilities @@ -43,13 +47,24 @@ # define _LINUX_CAPABILITY_VERSION_1 0x19980330 # endif -#elif (_LINUX_CAPABILITY_VERSION != 0x20071026) +# _LIBCAP_CAPABILITY_VERSION _LINUX_CAPABILITY_VERSION_1 +# _LIBCAP_CAPABILITY_U32S _LINUX_CAPABILITY_U32S_1 + +#elif (_LINUX_CAPABILITY_VERSION_2 != 0x20071026) # error Kernel <linux/capability.h> does not match library # error file "libcap.h" --> fix and recompile libcap +#else + +#define _LIBCAP_CAPABILITY_VERSION _LINUX_CAPABILITY_VERSION_2 +#define _LIBCAP_CAPABILITY_U32S _LINUX_CAPABILITY_U32S_2 + #endif +#undef _LINUX_CAPABILITY_VERSION +#undef _LINUX_CAPABILITY_U32S + /* * This is a pointer to a struct containing three consecutive * capability sets in the order of the cap_flag_t type: the are @@ -59,10 +74,6 @@ * to processes. */ -#ifndef _LINUX_CAPABILITY_U32S -# define _LINUX_CAPABILITY_U32S 1 -#endif /* ndef _LINUX_CAPABILITY_U32S */ - #if defined(VFS_CAP_REVISION_MASK) && !defined(VFS_CAP_U32) # define VFS_CAP_U32_1 1 # define XATTR_CAPS_SZ_1 (sizeof(__le32)*(1 + 2*VFS_CAP_U32_1)) @@ -86,7 +97,7 @@ struct _cap_vfs_cap_data { #endif /* ndef CAP_TO_MASK */ #define NUMBER_OF_CAP_SETS 3 /* effective, inheritable, permitted */ -#define __CAP_BLKS (_LINUX_CAPABILITY_U32S) +#define __CAP_BLKS (_LIBCAP_CAPABILITY_U32S) #define CAP_SET_SIZE (__CAP_BLKS * sizeof(__u32)) #define CAP_T_MAGIC 0xCA90D0 @@ -95,7 +106,7 @@ struct _cap_struct { union { struct __user_cap_data_struct set; __u32 flat[NUMBER_OF_CAP_SETS]; - } u[_LINUX_CAPABILITY_U32S]; + } u[_LIBCAP_CAPABILITY_U32S]; }; /* the maximum bits supportable */ @@ -135,7 +146,7 @@ struct _cap_struct { # define _cap_debugcap(s, c, set) do { \ unsigned _cap_index; \ fprintf(stderr, __FUNCTION__ "(" __FILE__ ":%d): " s, __LINE__); \ - for (_cap_index=_LINUX_CAPABILITY_U32S; _cap_index-- > 0; ) { \ + for (_cap_index=_LIBCAP_CAPABILITY_U32S; _cap_index-- > 0; ) { \ fprintf(stderr, "%08x", (c).u[_cap_index].flat[set]); \ } \ fprintf(stderr, "\n"); \ |