@@ -224,7 +224,7 @@ int su_client_main(int argc, char *argv[]) {
224224 interactive |= !has_command;
225225 // Determine which one of our streams are attached to a TTY
226226 int atty = 0 ;
227- if (isatty (STDIN_FILENO ) && interactive) atty |= ATTY_IN ;
227+ if (isatty (STDIN_FILENO ) && interactive) atty |= ATTY_IN ;
228228 if (isatty (STDOUT_FILENO ) && interactive) atty |= ATTY_OUT ;
229229 if (isatty (STDERR_FILENO ) && interactive) atty |= ATTY_ERR ;
230230
@@ -410,8 +410,26 @@ void exec_root_shell(int client, int pid, SuRequest &req, MntNsMode mode) {
410410 }
411411
412412 vector<const char *> argv;
413- for (auto &str: req.command ) {
414- argv.push_back (str.c_str ());
413+ string cmd;
414+ if (req.command .size () >= 4 &&
415+ string_view (req.command [1 ].c_str ()) == " -c" &&
416+ string_view (req.command [2 ].c_str ()).find (' ' ) == string::npos) {
417+ LOGD (" su: unsupported command line from pid=[%d]\n " , pid);
418+ cmd = req.command [2 ].c_str ();
419+ for (size_t i = 3 ; i < req.command .size (); ++i) {
420+ cmd += ' ' ;
421+ cmd += req.command [i].c_str ();
422+ }
423+
424+ argv.reserve (4 );
425+ argv.push_back (req.command [0 ].c_str ());
426+ argv.push_back (req.command [1 ].c_str ());
427+ argv.push_back (cmd.c_str ());
428+ } else {
429+ argv.reserve (req.command .size () + 1 );
430+ for (auto &arg: req.command ) {
431+ argv.push_back (arg.c_str ());
432+ }
415433 }
416434 argv.push_back (nullptr );
417435
0 commit comments