aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-07-06 15:21:43 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-07-06 22:27:22 +0200
commit10c53b85c992afca47e7a70f05379a5038bdaeb9 (patch)
tree4c223f16f0e178451e863ada1595b32333759282
parent111cdcf295b4cab78521480f52b295d9ae719263 (diff)
downloadbusybox-w32-10c53b85c992afca47e7a70f05379a5038bdaeb9.tar.gz
busybox-w32-10c53b85c992afca47e7a70f05379a5038bdaeb9.tar.bz2
busybox-w32-10c53b85c992afca47e7a70f05379a5038bdaeb9.zip
setpriv: dump no-new-privs info
Introduce the ability to dump the state of the no-new-privs flag, which states whethere it is allowed to grant new privileges. function old new delta setpriv_main 419 467 +48 .rodata 145926 145969 +43 Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--util-linux/setpriv.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/util-linux/setpriv.c b/util-linux/setpriv.c
index f21ce6632..8d3f25875 100644
--- a/util-linux/setpriv.c
+++ b/util-linux/setpriv.c
@@ -62,6 +62,10 @@
62#define PR_SET_NO_NEW_PRIVS 38 62#define PR_SET_NO_NEW_PRIVS 38
63#endif 63#endif
64 64
65#ifndef PR_GET_NO_NEW_PRIVS
66#define PR_GET_NO_NEW_PRIVS 39
67#endif
68
65enum { 69enum {
66 IF_FEATURE_SETPRIV_DUMP(OPTBIT_DUMP,) 70 IF_FEATURE_SETPRIV_DUMP(OPTBIT_DUMP,)
67 OPTBIT_NNP, 71 OPTBIT_NNP,
@@ -76,13 +80,17 @@ static int dump(void)
76 uid_t ruid, euid, suid; 80 uid_t ruid, euid, suid;
77 gid_t rgid, egid, sgid; 81 gid_t rgid, egid, sgid;
78 gid_t *gids; 82 gid_t *gids;
79 int ngids; 83 int ngids, nnp;
80 84
81 getresuid(&ruid, &euid, &suid); /* never fails in Linux */ 85 getresuid(&ruid, &euid, &suid); /* never fails in Linux */
82 getresgid(&rgid, &egid, &sgid); /* never fails in Linux */ 86 getresgid(&rgid, &egid, &sgid); /* never fails in Linux */
83 ngids = 0; 87 ngids = 0;
84 gids = bb_getgroups(&ngids, NULL); /* never fails in Linux */ 88 gids = bb_getgroups(&ngids, NULL); /* never fails in Linux */
85 89
90 nnp = prctl(PR_GET_NO_NEW_PRIVS, 0, 0, 0, 0);
91 if (nnp < 0)
92 bb_simple_perror_msg_and_die("prctl: GET_NO_NEW_PRIVS");
93
86 printf("uid: %u\n", (unsigned)ruid); 94 printf("uid: %u\n", (unsigned)ruid);
87 printf("euid: %u\n", (unsigned)euid); 95 printf("euid: %u\n", (unsigned)euid);
88 printf("gid: %u\n", (unsigned)rgid); 96 printf("gid: %u\n", (unsigned)rgid);
@@ -99,7 +107,7 @@ static int dump(void)
99 fmt = ",%u"; 107 fmt = ",%u";
100 } 108 }
101 } 109 }
102 bb_putchar('\n'); 110 printf("\nno_new_privs: %d\n", nnp);
103 111
104 if (ENABLE_FEATURE_CLEAN_UP) 112 if (ENABLE_FEATURE_CLEAN_UP)
105 free(gids); 113 free(gids);