[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: [PATCH 4/9] setpriv: dump no-new-privs info
From: Patrick Steinhardt <ps () pks ! im>
Date: 2017-06-29 17:34:31
Message-ID: 1624e2870abafce0eddca6728e2efb8c90501166.1498757023.git.ps () pks ! im
[Download RAW message or body]
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 ca31c0a77..c7be492a2 100644
--- a/util-linux/setpriv.c
+++ b/util-linux/setpriv.c
@@ -53,6 +53,10 @@
#define PR_SET_NO_NEW_PRIVS 38
#endif
+#ifndef PR_GET_NO_NEW_PRIVS
+#define PR_GET_NO_NEW_PRIVS 39
+#endif
+
enum {
OPT_DUMP = (1 << 0),
OPT_NNP = (1 << 1),
@@ -63,7 +67,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");
@@ -77,6 +81,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);
@@ -95,6 +102,8 @@ static int dump(void)
}
putchar('\n');
+ printf("no_new_privs: %d\n", nnp);
+
free(gids);
return 0;
}
--
2.13.2
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic