diff options
author | Andrew G. Morgan <morgan@kernel.org> | 2008-07-08 06:59:01 -0700 |
---|---|---|
committer | Jorge Lucangeli Obes <jorgelo@google.com> | 2015-09-03 14:13:03 -0700 |
commit | 2481202d5e1f94f6f8191e2a10d21730b4f5a135 (patch) | |
tree | cc2d0ddc88773f90325e68c43dda67fb245e6be6 /libcap/cap_proc.c | |
parent | 67703d39deb904531823ee4a9bb6d0c09644832e (diff) | |
download | libcap-2481202d5e1f94f6f8191e2a10d21730b4f5a135.tar.gz |
Fix cap_copy_int(), add two functions cap_get_pid() and cap_compare()
Test new and old function with modified test.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
Diffstat (limited to 'libcap/cap_proc.c')
-rw-r--r-- | libcap/cap_proc.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libcap/cap_proc.c b/libcap/cap_proc.c index 61c5b12..7a6af39 100644 --- a/libcap/cap_proc.c +++ b/libcap/cap_proc.c @@ -62,6 +62,27 @@ int capgetp(pid_t pid, cap_t cap_d) return error; } +/* allocate space for and return capabilities of target process */ + +cap_t cap_get_pid(pid_t pid) +{ + cap_t result; + + result = cap_init(); + if (result) { + if (capgetp(pid, result) != 0) { + int my_errno; + + my_errno = errno; + cap_free(result); + errno = my_errno; + result = NULL; + } + } + + return result; +} + /* set the caps on a specific process/pg etc.. */ int capsetp(pid_t pid, cap_t cap_d) |