[PATCH v3 4/6] setpriv: dump ambient capabilities
Patrick Steinhardt
ps at pks.im
Thu Jul 6 13:21:46 UTC 2017
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 at pks.im>
---
util-linux/setpriv.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/util-linux/setpriv.c b/util-linux/setpriv.c
index a958e9a95..161ad3451 100644
--- a/util-linux/setpriv.c
+++ b/util-linux/setpriv.c
@@ -94,6 +94,11 @@
#define PR_GET_NO_NEW_PRIVS 39
#endif
+#ifndef PR_CAP_AMBIENT
+#define PR_CAP_AMBIENT 47
+#define PR_CAP_AMBIENT_IS_SET 1
+#endif
+
enum {
IF_FEATURE_SETPRIV_DUMP(OPTBIT_DUMP,)
OPTBIT_NNP,
@@ -265,6 +270,24 @@ static int dump(void)
if (!n)
printf("[none]");
+ printf("\nAmbient capabilities: ");
+ fmt = ",%s" + 1;
+ for (n = 0, i = 0; cap_valid(i); i++) {
+ int ret = prctl(PR_CAP_AMBIENT, PR_CAP_AMBIENT_IS_SET, (unsigned long) i, 0UL, 0UL);
+ if (ret < 0)
+ bb_simple_perror_msg_and_die("prctl: CAP_AMBIENT_IS_SET");
+
+ if (ret) {
+ printf(fmt, getcapname(buf, sizeof(buf), i));
+ n++;
+ fmt = ",%s";
+ }
+ }
+ if (!n && !i)
+ printf("[unsupported]");
+ else if (!n)
+ printf("[none]");
+
printf("\nCapability bounding set: ");
fmt = ",%s" + 1;
for (n = 0, i = 0; cap_valid(i); i++) {
--
2.13.2
More information about the busybox
mailing list