From 219a8196590d2fae1b350fc7498e8a66056e186f Mon Sep 17 00:00:00 2001 From: Omar Sandoval Date: Wed, 25 Oct 2023 10:07:14 -0700 Subject: [PATCH] vmtest.vm: quote command arguments from CLI This fixes commands like `python3 -m vmtest.vm python3 -c 'foo; bar'`. Signed-off-by: Omar Sandoval --- vmtest/vm.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vmtest/vm.py b/vmtest/vm.py index c5bc1778..917d8345 100644 --- a/vmtest/vm.py +++ b/vmtest/vm.py @@ -400,7 +400,11 @@ if __name__ == "__main__": args.root_directory = None try: - command = " ".join(args.command) if args.command else "sh -i" + command = ( + " ".join([shlex.quote(arg) for arg in args.command]) + if args.command + else "sh -i" + ) sys.exit(run_in_vm(command, kernel, args.root_directory, args.directory)) except LostVMError as e: print("error:", e, file=sys.stderr)