From ed81ba2ae0fbcd36a6f10c2ed59984643a1778e7 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Sat, 21 Jul 2007 22:18:02 -0700 Subject: Revived old setcap/getcap manual pages and added support for removing file caps --- libcap/cap_file.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'libcap/cap_file.c') diff --git a/libcap/cap_file.c b/libcap/cap_file.c index b452b9c..90a2c40 100644 --- a/libcap/cap_file.c +++ b/libcap/cap_file.c @@ -134,7 +134,10 @@ int cap_set_fd(int fildes, cap_t cap_d) { struct vfs_cap_data rawvfscap; - if (_fcaps_save(&rawvfscap, cap_d) != 0) { + if (cap_d == NULL) { + _cap_debug("deleting fildes capabilities"); + return fremovexattr(fildes, XATTR_NAME_CAPS); + } else if (_fcaps_save(&rawvfscap, cap_d) != 0) { return -1; } @@ -152,7 +155,10 @@ int cap_set_file(const char *filename, cap_t cap_d) { struct vfs_cap_data rawvfscap; - if (_fcaps_save(&rawvfscap, cap_d) != 0) { + if (cap_d == NULL) { + _cap_debug("removing filename capabilities"); + return removexattr(filename, XATTR_NAME_CAPS); + } else if (_fcaps_save(&rawvfscap, cap_d) != 0) { return -1; } -- cgit v1.2.3