capabilities: Add function to check if a capability is held, without keeping it

This can be useful if capabilities are not required anymore after
dropping privileges.
This commit is contained in:
Tobias Brunner
2013-07-18 15:25:35 +02:00
parent 56b753ca04
commit 027676f750
2 changed files with 80 additions and 50 deletions
+12
View File
@@ -54,12 +54,24 @@ struct capabilities_t {
* Register a capability to keep while calling drop(). Verifies that the
* capability is currently held.
*
* @note CAP_CHOWN is handled specially as it might not be required.
*
* @param cap capability to keep
* @return FALSE if the capability is currently not held
*/
bool (*keep)(capabilities_t *this,
u_int cap) __attribute__((warn_unused_result));
/**
* Check if the given capability is currently held.
*
* @note CAP_CHOWN is handled specially as it might not be required.
*
* @param cap capability to check
* @return TRUE if the capability is currently held
*/
bool (*check)(capabilities_t *this, u_int cap);
/**
* Get the user ID set through set_uid/resolve_uid.
*