diff options
author | Patrick Steinhardt <ps@pks.im> | 2017-07-06 22:59:23 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-06 22:59:23 +0200 |
commit | f34c701fa8ac90e900488453b8efbe93a1378280 (patch) | |
tree | 5b52d30f72325c2aa800a58d14b21adea8d7eb5d /util-linux | |
parent | ad63102943d3f648b37b65f5c734b2c345a3b280 (diff) | |
download | busybox-f34c701fa8ac90e900488453b8efbe93a1378280.tar.gz |
setpriv: dump capability bounding set
As with the previous commit, this one implements the ability to dump the
capability bounding set.
function old new delta
setpriv_main 838 982 +144
.rodata 146101 146148 +47
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux')
-rw-r--r-- | util-linux/setpriv.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/util-linux/setpriv.c b/util-linux/setpriv.c index a509204a2..c3f9ea153 100644 --- a/util-linux/setpriv.c +++ b/util-linux/setpriv.c @@ -82,6 +82,10 @@ #include <sys/prctl.h> #include "libbb.h" +#ifndef PR_CAPBSET_READ +#define PR_CAPBSET_READ 23 +#endif + #ifndef PR_SET_NO_NEW_PRIVS #define PR_SET_NO_NEW_PRIVS 38 #endif @@ -247,6 +251,25 @@ static int dump(void) } if (!fmt[0]) printf("[none]"); + + printf("\nCapability bounding set: "); + fmt = ""; + for (i = 0; cap_valid(i); i++) { + int ret = prctl(PR_CAPBSET_READ, (unsigned long) i, 0UL, 0UL, 0UL); + if (ret < 0) + bb_simple_perror_msg_and_die("prctl: CAPBSET_READ"); + if (ret) { +# if ENABLE_FEATURE_SETPRIV_CAPABILITY_NAMES + if (i < ARRAY_SIZE(capabilities)) + printf("%s%s", fmt, capabilities[i]); + else +# endif + printf("%scap_%u", fmt, i); + fmt = ","; + } + } + if (!fmt[0]) + printf("[none]"); bb_putchar('\n'); # endif |