@@ -197,7 +197,7 @@ fn execute_in_sandbox(
197197 debug ! ( "script: {:?}" , script_path) ;
198198
199199 let cpio_start = std:: time:: Instant :: now ( ) ;
200- let modified_rootfs = inject_script_into_rootfs ( rootfs, & script_path) ?;
200+ let ( modified_rootfs, _rootfs_tmpdir ) = inject_script_into_rootfs ( rootfs, & script_path) ?;
201201 if timing {
202202 info ! ( " cpio inject: {:?}" , cpio_start. elapsed( ) ) ;
203203 }
@@ -228,7 +228,7 @@ fn execute_in_sandbox(
228228 Ok ( vm_output. output )
229229}
230230
231- fn inject_script_into_rootfs ( original_rootfs : & Path , script_path : & Path ) -> Result < PathBuf > {
231+ fn inject_script_into_rootfs ( original_rootfs : & Path , script_path : & Path ) -> Result < ( PathBuf , tempfile :: TempDir ) > {
232232 let temp_dir = tempfile:: tempdir ( ) ?;
233233 let extract_dir = temp_dir. path ( ) . join ( "rootfs" ) ;
234234 let new_cpio = temp_dir. path ( ) . join ( "rootfs_with_script.cpio" ) ;
@@ -270,11 +270,7 @@ fn inject_script_into_rootfs(original_rootfs: &Path, script_path: &Path) -> Resu
270270 anyhow:: bail!( "cpio create failed" ) ;
271271 }
272272
273- // Leak tempdir so file persists
274- let path = new_cpio. clone ( ) ;
275- std:: mem:: forget ( temp_dir) ;
276-
277- Ok ( path)
273+ Ok ( ( new_cpio, temp_dir) )
278274}
279275
280276fn extract_pptx_from_output ( output : & str ) -> Result < Vec < u8 > > {
0 commit comments