11use nix:: unistd:: { dup, dup2} ;
22use std:: { fs:: OpenOptions , os:: fd:: RawFd } ;
33
4- use anyhow:: { anyhow, Result } ;
4+ use anyhow:: { anyhow, Result , Context } ;
55use containerd_shim_wasm:: sandbox:: oci;
66use libc:: { STDERR_FILENO , STDIN_FILENO , STDOUT_FILENO } ;
77use libcontainer:: workload:: { Executor , ExecutorError } ;
@@ -24,7 +24,7 @@ pub struct WasmtimeExecutor {
2424impl Executor for WasmtimeExecutor {
2525 fn exec ( & self , spec : & Spec ) -> Result < ( ) , ExecutorError > {
2626 let args = oci:: get_args ( spec) ;
27- if args. is_empty ( ) {
27+ if args. len ( ) != 1 {
2828 return Err ( ExecutorError :: InvalidArg ) ;
2929 }
3030
@@ -82,8 +82,10 @@ impl WasmtimeExecutor {
8282 let wctx = wasi_builder. build ( ) ;
8383
8484 log:: info!( "wasi context ready" ) ;
85- let start = args[ 0 ] . clone ( ) ;
86- let mut iterator = start. split ( '#' ) ;
85+ let mut iterator = args
86+ . first ( )
87+ . context ( "args must have at least one argument." ) ?
88+ . split ( '#' ) ;
8789 let mut cmd = iterator. next ( ) . unwrap ( ) . to_string ( ) ;
8890 let stripped = cmd. strip_prefix ( std:: path:: MAIN_SEPARATOR ) ;
8991 if let Some ( strpd) = stripped {
0 commit comments