diff options
author | Andrew Morgan <morgan@kernel.org> | 2007-07-21 22:18:02 -0700 |
---|---|---|
committer | Jorge Lucangeli Obes <jorgelo@google.com> | 2015-09-03 14:13:03 -0700 |
commit | ed81ba2ae0fbcd36a6f10c2ed59984643a1778e7 (patch) | |
tree | ae1ac515ffb749ccf39abb0990ce6f9f040c515d /libcap/cap_file.c | |
parent | 7ad0c9424a86470cd62687c6666ad1c878de9393 (diff) | |
download | libcap-ed81ba2ae0fbcd36a6f10c2ed59984643a1778e7.tar.gz |
Revived old setcap/getcap manual pages and added support for removing file caps
Diffstat (limited to 'libcap/cap_file.c')
-rw-r--r-- | libcap/cap_file.c | 10 |
1 files changed, 8 insertions, 2 deletions
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; } |