[PATCH v2 4/9] setpriv: dump no-new-privs info
Patrick Steinhardt
ps at pks.im
Sun Jul 2 13:42:53 UTC 2017
Introduce the ability to dump the state of the no-new-privs flag, which
states whethere it is allowed to grant new privileges.
---
util-linux/setpriv.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/util-linux/setpriv.c b/util-linux/setpriv.c
index dabc6d355..740b51610 100644
--- a/util-linux/setpriv.c
+++ b/util-linux/setpriv.c
@@ -63,6 +63,10 @@
#define PR_SET_NO_NEW_PRIVS 38
#endif
+#ifndef PR_GET_NO_NEW_PRIVS
+#define PR_GET_NO_NEW_PRIVS 39
+#endif
+
enum {
IF_FEATURE_SETPRIV_DUMP(OPTBIT_DUMP,)
OPTBIT_NNP,
@@ -77,7 +81,7 @@ static int dump(void)
uid_t ruid, euid, suid;
gid_t rgid, egid, sgid;
gid_t *gids;
- int ngids;
+ int ngids, nnp;
if (getresuid(&ruid, &euid, &suid) < 0)
bb_simple_perror_msg_and_die("getresgid");
@@ -91,6 +95,9 @@ static int dump(void)
if ((ngids = getgroups(ngids, gids)) < 0)
bb_simple_perror_msg_and_die("getgroups");
+ if ((nnp = prctl(PR_GET_NO_NEW_PRIVS, 0, 0, 0, 0)) < 0)
+ bb_simple_perror_msg_and_die("prctl: GET_NO_NEW_PRIVS");
+
printf("uid: %d\n", ruid);
printf("euid: %d\n", euid);
printf("gid: %d\n", rgid);
@@ -109,6 +116,8 @@ static int dump(void)
}
putchar('\n');
+ printf("no_new_privs: %d\n", nnp);
+
free(gids);
return 0;
}
--
2.13.2
More information about the busybox
mailing list