@@ -463,12 +463,8 @@ impl Env {
463463 . map_err ( |err| JailerError :: Chmod ( folder_path. to_owned ( ) , err) ) ?;
464464
465465 let c_path = CString :: new ( folder_path. to_str ( ) . unwrap ( ) ) . unwrap ( ) ;
466- #[ cfg( target_arch = "x86_64" ) ]
467- let folder_bytes_ptr = c_path. as_ptr ( ) . cast :: < i8 > ( ) ;
468- #[ cfg( target_arch = "aarch64" ) ]
469- let folder_bytes_ptr = c_path. as_ptr ( ) ;
470466 // SAFETY: This is safe because folder was checked for a null-terminator.
471- SyscallReturnCode ( unsafe { libc:: chown ( folder_bytes_ptr , self . uid ( ) , self . gid ( ) ) } )
467+ SyscallReturnCode ( unsafe { libc:: chown ( c_path . as_ptr ( ) , self . uid ( ) , self . gid ( ) ) } )
472468 . into_empty_result ( )
473469 . map_err ( |err| JailerError :: ChangeFileOwner ( folder_path. to_owned ( ) , err) )
474470 }
@@ -478,26 +474,23 @@ impl Env {
478474 . exec_file_path
479475 . file_name ( )
480476 . ok_or_else ( || JailerError :: ExtractFileName ( self . exec_file_path . clone ( ) ) ) ?;
481- // We do a quick push here to get the global path of the executable inside the chroot,
482- // without having to create a new PathBuf. We'll then do a pop to revert to the actual
483- // chroot_dir right after the copy.
484- // TODO: just now wondering ... is doing a push()/pop() thing better than just creating
485- // a new PathBuf, with something like chroot_dir.join(exec_file_name) ?!
486- self . chroot_dir . push ( exec_file_name) ;
477+ let jailer_exec_file_path = self . chroot_dir . join ( exec_file_name) ;
487478
488479 // We do a copy instead of a hard-link for 2 reasons
489480 // 1. hard-linking is not possible if the file is in another device
490481 // 2. while hardlinking would save up disk space and also memory by sharing parts of the
491482 // Firecracker binary (like the executable .text section), this latter part is not
492483 // desirable in Firecracker's threat model. Copying prevents 2 Firecracker processes from
493484 // sharing memory.
494- fs:: copy ( & self . exec_file_path , & self . chroot_dir ) . map_err ( |err| {
495- JailerError :: Copy ( self . exec_file_path . clone ( ) , self . chroot_dir . clone ( ) , err)
485+ fs:: copy ( & self . exec_file_path , & jailer_exec_file_path) . map_err ( |err| {
486+ JailerError :: Copy (
487+ self . exec_file_path . clone ( ) ,
488+ jailer_exec_file_path. clone ( ) ,
489+ err,
490+ )
496491 } ) ?;
497492
498- // Pop exec_file_name.
499- self . chroot_dir . pop ( ) ;
500- Ok ( exec_file_name. to_os_string ( ) )
493+ Ok ( exec_file_name. to_owned ( ) )
501494 }
502495
503496 fn join_netns ( path : & str ) -> Result < ( ) , JailerError > {
0 commit comments