diff options
author | Andrew G. Morgan <morgan@kernel.org> | 2016-01-30 15:45:28 -0800 |
---|---|---|
committer | Andrew G. Morgan <morgan@kernel.org> | 2016-01-30 15:45:28 -0800 |
commit | 85f38a573fc47472ab792e813b6f6b6f0b1df112 (patch) | |
tree | bf1bde2d318bacb6df84c4fed24fc125ae2e471f | |
parent | 0ee94211e95096750ede752acd13b163aa6d5046 (diff) | |
download | libcap-85f38a573fc47472ab792e813b6f6b6f0b1df112.tar.gz |
Drop use of libattr for our trivial use case of kernel API.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
-rw-r--r-- | Make.Rules | 3 | ||||
-rw-r--r-- | libcap/Makefile | 10 | ||||
-rw-r--r-- | libcap/cap_file.c | 17 | ||||
-rw-r--r-- | progs/Makefile | 5 |
4 files changed, 18 insertions, 17 deletions
@@ -70,7 +70,6 @@ CFLAGS += -Dlinux $(WARNINGS) $(DEBUG) PAM_CAP := $(shell if [ -f /usr/include/security/pam_modules.h ]; then echo yes ; else echo no ; fi) INDENT := $(shell if [ -n "$$(which indent 2>/dev/null)" ]; then echo "| indent -kr" ; fi) DYNAMIC := $(shell if [ ! -d "$(topdir)/.git" ]; then echo yes; fi) -LIBATTR := yes # When installing setcap, set its inheritable bit to be able to place # capabilities on files. It can be used in conjunction with pam_cap @@ -80,7 +79,7 @@ LIBATTR := yes # # make RAISE_SETFCAP=no install # -RAISE_SETFCAP := $(LIBATTR) +RAISE_SETFCAP := yes # Global cleanup stuff diff --git a/libcap/Makefile b/libcap/Makefile index 0ccd2e7..d189777 100644 --- a/libcap/Makefile +++ b/libcap/Makefile @@ -10,15 +10,7 @@ LIBNAME=$(LIBTITLE).so STALIBNAME=$(LIBTITLE).a # -FILES=cap_alloc cap_proc cap_extint cap_flag cap_text - -# make including file support something you can override (no libattr -# no support). -ifeq ($(LIBATTR),yes) -FILES += cap_file -LDFLAGS += -lattr -DEPS = -lattr -endif +FILES=cap_alloc cap_proc cap_extint cap_flag cap_text cap_file INCLS=libcap.h cap_names.h $(INCS) OBJS=$(addsuffix .o, $(FILES)) diff --git a/libcap/cap_file.c b/libcap/cap_file.c index 553c2d2..3acafb2 100644 --- a/libcap/cap_file.c +++ b/libcap/cap_file.c @@ -5,14 +5,27 @@ */ #include <sys/types.h> -#include <sys/xattr.h> #include <byteswap.h> #include <sys/stat.h> #include <unistd.h> - #include <linux/xattr.h> +/* + * We hardcode the prototypes for the Linux system calls here since + * there are no libcap library APIs that expose the user to these + * details, and that way we don't need to foce clients to link any + * other libraries to access them. + */ +#ifndef XATTR_SECURITY_PREFIX #define XATTR_SECURITY_PREFIX "security." +#endif /* ndef XATTR_SECURITY_PREFIX */ + +extern ssize_t getxattr(const char *, const char *, void *, size_t); +extern ssize_t fgetxattr(int, const char *, void *, size_t); +extern int setxattr(const char *, const char *, const void *, size_t, int); +extern int fsetxattr(int, const char *, const void *, size_t, int); +extern int removexattr(const char *, const char *); +extern int fremovexattr(int, const char *); #include "libcap.h" diff --git a/progs/Makefile b/progs/Makefile index 778149e..c094a24 100644 --- a/progs/Makefile +++ b/progs/Makefile @@ -4,10 +4,7 @@ include $(topdir)/Make.Rules # # Programs: all of the examples that we will compile # -PROGS=getpcaps capsh -ifeq ($(LIBATTR),yes) -PROGS += getcap setcap -endif +PROGS=getpcaps capsh getcap setcap BUILD=$(PROGS) |