diff options
author | Andrew Morgan <morgan@kernel.org> | 2007-07-19 22:55:00 -0700 |
---|---|---|
committer | Andrew Morgan <morgan@kernel.org> | 2007-08-13 23:33:40 -0700 |
commit | 4ede6982a479daecd2ac313b10cebfb7e07f40fa (patch) | |
tree | 93ad627f453ae303597d2bffbde613cfaa45aa9b | |
parent | 3f8d684a534530716a6a70bf9b6c0d23c09f2146 (diff) | |
download | libcap-4ede6982a479daecd2ac313b10cebfb7e07f40fa.tar.gz |
Cleanup output; and permit setcap e value to be superset of ip.
This means one can say:
setcap "all=e cap_net_raw=p" ping
which is equivalent to
setcap "cap_net_raw=ep" ping
-rw-r--r-- | Make.Rules | 3 | ||||
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | libcap/Makefile | 4 | ||||
-rw-r--r-- | libcap/cap_file.c | 4 | ||||
-rw-r--r-- | libcap/cap_sys.c | 2 | ||||
-rw-r--r-- | progs/getcap.c | 7 | ||||
-rw-r--r-- | progs/setcap.c | 7 |
7 files changed, 17 insertions, 16 deletions
@@ -56,7 +56,8 @@ WARNINGS=-fPIC -D_POSIX_SOURCE -Wall -Wwrite-strings \ LD=ld LDFLAGS=-s #-g -IPATH=-I$(topdir)/libcap/include +KERNEL_HEADERS = /usr/include +IPATH += -I$(topdir)/libcap/include INCS=$(topdir)/libcap/include/sys/capability.h LIBS=-L$(topdir)/libcap -lcap CFLAGS=-Dlinux $(WARNINGS) $(DEBUG) $(COPTFLAG) $(IPATH) @@ -11,9 +11,9 @@ include Make.Rules # all install clean: %: %-here - make -C libcap $(MAKE_DEFS) $@ - make -C progs $(MAKE_DEFS) $@ - make -C doc $(MAKE_DEFS) $@ + $(MAKE) -C libcap $(MAKE_DEFS) $@ + $(MAKE) -C progs $(MAKE_DEFS) $@ + $(MAKE) -C doc $(MAKE_DEFS) $@ all-here: diff --git a/libcap/Makefile b/libcap/Makefile index 61aab78..c492559 100644 --- a/libcap/Makefile +++ b/libcap/Makefile @@ -26,9 +26,9 @@ _makenames: _makenames.c cap_names.sed cap_names.h: _makenames ./_makenames > cap_names.h -cap_names.sed: Makefile /usr/include/linux/capability.h +cap_names.sed: Makefile $(KERNEL_HEADERS)/linux/capability.h @echo "=> making cap_names.c from <linux/capability.h>" - @sed -ne '/^#define[ \t]CAP[_A-Z]\+[ \t]\+[0-9]\+/{s/^#define \([^ \t]*\)[ \t]*\([^ \t]*\)/ \{ \2, \"\1\" \},/;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/;p;}' < /usr/include/linux/capability.h | fgrep -v 0x > cap_names.sed + @sed -ne '/^#define[ \t]CAP[_A-Z]\+[ \t]\+[0-9]\+/{s/^#define \([^ \t]*\)[ \t]*\([^ \t]*\)/ \{ \2, \"\1\" \},/;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/;p;}' < $(KERNEL_HEADERS)/linux/capability.h | fgrep -v 0x > cap_names.sed # @sed -ne '/^#define[ \t]CAP[_A-Z]\+[ \t]\+[0-9]\+/{s/^#define CAP_\([^ \t]*\)[ \t]*\([^ \t]*\)/ \{ \2, \"\1\" \},/;y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/;p;}' < /usr/include/linux/capability.h | fgrep -v 0x > cap_names.sed $(STALIBNAME): $(OBJS) diff --git a/libcap/cap_file.c b/libcap/cap_file.c index d5c8aa7..b452b9c 100644 --- a/libcap/cap_file.c +++ b/libcap/cap_file.c @@ -53,8 +53,8 @@ static int _fcaps_save(struct vfs_cap_data *rawvfscap, cap_t cap_d) if (cap_d->set.effective == 0) { rawvfscap->magic_etc = FIXUP_32BITS(VFS_CAP_REVISION); - } else if (cap_d->set.effective - ^ (cap_d->set.inheritable|cap_d->set.permitted)) { + } else if ((~(cap_d->set.effective)) + & (cap_d->set.inheritable|cap_d->set.permitted)) { errno = EINVAL; return -1; } else { diff --git a/libcap/cap_sys.c b/libcap/cap_sys.c index 1aadef2..8a486b0 100644 --- a/libcap/cap_sys.c +++ b/libcap/cap_sys.c @@ -10,6 +10,8 @@ #include <linux/unistd.h> #include <sys/capability.h> +#define user + _syscall2(int, capget, cap_user_header_t, header, cap_user_data_t, data) diff --git a/progs/getcap.c b/progs/getcap.c index a647b61..1fbf5d2 100644 --- a/progs/getcap.c +++ b/progs/getcap.c @@ -35,15 +35,14 @@ int main(int argc, char **argv) cap_d = cap_get_file(argv[0]); if (cap_d == NULL) { - fprintf(stderr, - "Failed to get capabilities for file `%s'\n" - " (%s)\n", argv[0], strerror(errno)); + fprintf(stderr, "Failed to get capabilities for file `%s' (%s)\n", + argv[0], strerror(errno)); continue; } result = cap_to_text(cap_d, &length); - fprintf(stderr, "Capabilities for `%s':\n%s\n", *argv, result); + printf("%s: %s\n", *argv, result); cap_free(result); cap_free(cap_d); diff --git a/progs/setcap.c b/progs/setcap.c index d4a2ee4..14e6307 100644 --- a/progs/setcap.c +++ b/progs/setcap.c @@ -90,7 +90,7 @@ int main(int argc, char **argv) const char *result; result = cap_to_text(cap_d, &length); - fprintf(stderr, "[caps set to:\n%s\n]\n", result); + fprintf(stderr, "caps set to: [%s]\n", result); } #endif @@ -99,9 +99,8 @@ int main(int argc, char **argv) retval = cap_set_file(*++argv, cap_d); if (retval != 0) { - fprintf(stderr, - "Failed to set capabilities on file `%s'\n" - " (%s)\n", argv[0], strerror(errno)); + fprintf(stderr, "Failed to set capabilities on file `%s' (%s)\n", + argv[0], strerror(errno)); usage(); } |