From 1f4786db19bf869de35fdc136ccc46ecf5c5b19f Mon Sep 17 00:00:00 2001 From: Sashanoraa Date: Sun, 23 Mar 2025 13:40:07 -0400 Subject: [PATCH] Have rootshell print errors and exit 1 if exec fails Previously was ignoring the possible error retuned by exec, this commit has rootshell print the error if exec returns and have the process exit with a code of 1 instead of 0. --- rootshell/src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rootshell/src/main.rs b/rootshell/src/main.rs index c380272..9ed5fe6 100644 --- a/rootshell/src/main.rs +++ b/rootshell/src/main.rs @@ -25,9 +25,12 @@ fn main() { // discard argv[0] let _ = args.next(); - Command::new("/bin/bash") + // This call will only return if there is an error + let error = Command::new("/bin/bash") .args(args) .uid(0) .gid(0) .exec(); + eprintln!("Error running command: {error}"); + std::process::exit(1); }