diff options
author | Patrick Steinhardt <ps@pks.im> | 2017-07-02 15:42:50 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-18 19:20:58 +0200 |
commit | ee67c9a60ab202cb8f8cc13d8670a90cbfad7963 (patch) | |
tree | 81f49a27e81c0974155ddab827d65122a5229154 | |
parent | 8965e5089efea4fdfc27241967098833f56de060 (diff) | |
download | busybox-w32-ee67c9a60ab202cb8f8cc13d8670a90cbfad7963.tar.gz busybox-w32-ee67c9a60ab202cb8f8cc13d8670a90cbfad7963.tar.bz2 busybox-w32-ee67c9a60ab202cb8f8cc13d8670a90cbfad7963.zip |
setpriv: do not process remaining args
By default, the 'getopt32' call will continue parsing the command line
even after hitting a non-option string. But in setpriv, this should be
avoided, as all parameters following the initial non-option argument are
in fact arguments to the binary that is to be executed by setpriv.
Otherwise, calling e.g. 'busybox setpriv ls -l' would result in an error
due to the unknown parameter "-l".
Fix the issue by passing "+" as the first character in the options
string. This will cause 'getopt32' to stop processing after hitting the
first non-option.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | util-linux/setpriv.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/util-linux/setpriv.c b/util-linux/setpriv.c index 6bd663bf4..686ad45d5 100644 --- a/util-linux/setpriv.c +++ b/util-linux/setpriv.c | |||
@@ -62,7 +62,8 @@ int setpriv_main(int argc UNUSED_PARAM, char **argv) | |||
62 | 62 | ||
63 | opt_complementary = "-1"; | 63 | opt_complementary = "-1"; |
64 | applet_long_options = setpriv_longopts; | 64 | applet_long_options = setpriv_longopts; |
65 | opts = getopt32(argv, ""); | 65 | opts = getopt32(argv, "+"); |
66 | |||
66 | if (opts) { | 67 | if (opts) { |
67 | if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) | 68 | if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) |
68 | bb_simple_perror_msg_and_die("prctl: NO_NEW_PRIVS"); | 69 | bb_simple_perror_msg_and_die("prctl: NO_NEW_PRIVS"); |