aboutsummaryrefslogtreecommitdiff
path: root/util-linux/setpriv.c
diff options
context:
space:
mode:
Diffstat (limited to 'util-linux/setpriv.c')
-rw-r--r--util-linux/setpriv.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/util-linux/setpriv.c b/util-linux/setpriv.c
index 686ad45d5..d15e0d84e 100644
--- a/util-linux/setpriv.c
+++ b/util-linux/setpriv.c
@@ -51,6 +51,12 @@
51#define PR_SET_NO_NEW_PRIVS 38 51#define PR_SET_NO_NEW_PRIVS 38
52#endif 52#endif
53 53
54enum {
55 OPTBIT_NNP,
56
57 OPT_NNP = (1 << OPTBIT_NNP),
58};
59
54int setpriv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 60int setpriv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
55int setpriv_main(int argc UNUSED_PARAM, char **argv) 61int setpriv_main(int argc UNUSED_PARAM, char **argv)
56{ 62{
@@ -60,15 +66,17 @@ int setpriv_main(int argc UNUSED_PARAM, char **argv)
60 ; 66 ;
61 int opts; 67 int opts;
62 68
63 opt_complementary = "-1";
64 applet_long_options = setpriv_longopts; 69 applet_long_options = setpriv_longopts;
65 opts = getopt32(argv, "+"); 70 opts = getopt32(argv, "+");
66 71
67 if (opts) { 72 argv += optind;
73
74 if (opts & OPT_NNP) {
68 if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) 75 if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0))
69 bb_simple_perror_msg_and_die("prctl: NO_NEW_PRIVS"); 76 bb_simple_perror_msg_and_die("prctl: NO_NEW_PRIVS");
70 } 77 }
71 78
72 argv += optind; 79 if (!argv[0])
80 bb_show_usage();
73 BB_EXECVP_or_die(argv); 81 BB_EXECVP_or_die(argv);
74} 82}