aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-07-06 23:02:33 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-07-06 23:02:33 +0200
commit5e0987405cb966ec041db96b75169bb992fb710e (patch)
treeed9f12ffa9415416217622ecc1530deec6d900e0
parentf34c701fa8ac90e900488453b8efbe93a1378280 (diff)
downloadbusybox-w32-5e0987405cb966ec041db96b75169bb992fb710e.tar.gz
busybox-w32-5e0987405cb966ec041db96b75169bb992fb710e.tar.bz2
busybox-w32-5e0987405cb966ec041db96b75169bb992fb710e.zip
setpriv: dump ambient capabilities
As with the previous commit, this commit introduces the ability to dump the set of ambient capabilities. function old new delta setpriv_main 982 1129 +147 .rodata 146148 146198 +50 Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--util-linux/setpriv.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/util-linux/setpriv.c b/util-linux/setpriv.c
index c3f9ea153..89fa2fc10 100644
--- a/util-linux/setpriv.c
+++ b/util-linux/setpriv.c
@@ -94,6 +94,11 @@
94#define PR_GET_NO_NEW_PRIVS 39 94#define PR_GET_NO_NEW_PRIVS 39
95#endif 95#endif
96 96
97#ifndef PR_CAP_AMBIENT
98#define PR_CAP_AMBIENT 47
99#define PR_CAP_AMBIENT_IS_SET 1
100#endif
101
97enum { 102enum {
98 IF_FEATURE_SETPRIV_DUMP(OPTBIT_DUMP,) 103 IF_FEATURE_SETPRIV_DUMP(OPTBIT_DUMP,)
99 OPTBIT_NNP, 104 OPTBIT_NNP,
@@ -252,6 +257,27 @@ static int dump(void)
252 if (!fmt[0]) 257 if (!fmt[0])
253 printf("[none]"); 258 printf("[none]");
254 259
260 printf("\nAmbient capabilities: ");
261 fmt = "";
262 for (i = 0; cap_valid(i); i++) {
263 int ret = prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_IS_SET, (unsigned long) i, 0UL, 0UL);
264 if (ret < 0)
265 bb_simple_perror_msg_and_die("prctl: CAP_AMBIENT_IS_SET");
266 if (ret) {
267# if ENABLE_FEATURE_SETPRIV_CAPABILITY_NAMES
268 if (i < ARRAY_SIZE(capabilities))
269 printf("%s%s", fmt, capabilities[i]);
270 else
271# endif
272 printf("%scap_%u", fmt, i);
273 fmt = ",";
274 }
275 }
276 if (i == 0)
277 printf("[unsupported]");
278 else if (!fmt[0])
279 printf("[none]");
280
255 printf("\nCapability bounding set: "); 281 printf("\nCapability bounding set: ");
256 fmt = ""; 282 fmt = "";
257 for (i = 0; cap_valid(i); i++) { 283 for (i = 0; cap_valid(i); i++) {