@@ -29,6 +29,7 @@ pub struct LocalBoundaryExec {
2929 ca_file_paths : Option < Arc < ( std:: path:: PathBuf , std:: path:: PathBuf ) > > ,
3030 provider_credentials : ProviderCredentialState ,
3131 user_environment : HashMap < String , String > ,
32+ repair_standard_sbin : bool ,
3233 runtime : Arc < crate :: boundary_io:: BoundaryRuntimeState > ,
3334 #[ cfg( target_os = "linux" ) ]
3435 launcher : openshell_isolation_interface:: linux:: workload_launcher:: WorkloadLauncher ,
@@ -53,22 +54,36 @@ impl LocalBoundaryExec {
5354 ca_file_paths,
5455 provider_credentials,
5556 user_environment,
57+ repair_standard_sbin : false ,
5658 runtime,
5759 #[ cfg( target_os = "linux" ) ]
5860 launcher,
5961 }
6062 }
6163
64+ /// Configure whether workload paths should include the standard sbin directories.
65+ #[ must_use]
66+ pub fn with_standard_sbin_path_repair ( mut self , enabled : bool ) -> Self {
67+ self . repair_standard_sbin = enabled;
68+ self
69+ }
70+
6271 fn command ( & self , spec : & ExecSpec ) -> Result < Command , BackendError > {
6372 if spec. program . is_empty ( ) {
6473 return Err ( BackendError :: Process ( "exec program is empty" . to_string ( ) ) ) ;
6574 }
75+ let repair_standard_sbin = self . repair_standard_sbin ;
76+ let args = crate :: process:: process_args_with_standard_sbin_paths (
77+ & spec. program ,
78+ & spec. args ,
79+ repair_standard_sbin,
80+ ) ;
6681 let mut command = Command :: new ( & spec. program ) ;
67- command. args ( & spec . args ) ;
82+ command. args ( args) ;
6883 let effective_workdir = spec. workdir . as_deref ( ) . or ( self . base_workdir . as_deref ( ) ) ;
6984 let ( session_user, session_home) =
7085 crate :: process:: session_user_and_home ( & self . policy , effective_workdir) ;
71- let path = std :: env :: var ( "PATH" ) . unwrap_or_else ( |_| "/usr/local/bin:/usr/bin:/bin" . into ( ) ) ;
86+ let path = crate :: child_env :: child_path_from_env ( repair_standard_sbin ) ;
7287 command
7388 . env_clear ( )
7489 . env ( openshell_core:: sandbox_env:: SANDBOX , "1" )
@@ -79,7 +94,17 @@ impl LocalBoundaryExec {
7994 . env ( "TERM" , if spec. pty { "xterm-256color" } else { "dumb" } ) ;
8095 for ( key, value) in & self . user_environment {
8196 if !key. starts_with ( "OPENSHELL_" ) {
82- command. env ( key, value) ;
97+ if key == "PATH" {
98+ command. env (
99+ key,
100+ crate :: child_env:: maybe_path_with_standard_sbin_paths (
101+ value,
102+ repair_standard_sbin,
103+ ) ,
104+ ) ;
105+ } else {
106+ command. env ( key, value) ;
107+ }
83108 }
84109 }
85110 if let Some ( ( ca_cert_path, combined_bundle_path) ) = self . ca_file_paths . as_deref ( ) {
@@ -89,13 +114,33 @@ impl LocalBoundaryExec {
89114 }
90115 for ( key, value) in self . provider_credentials . child_env_with_gcp_resolved ( ) {
91116 if !crate :: process:: is_supervisor_only_env_var ( & key) {
92- command. env ( key, value) ;
117+ if key == "PATH" {
118+ command. env (
119+ key,
120+ crate :: child_env:: maybe_path_with_standard_sbin_paths (
121+ & value,
122+ repair_standard_sbin,
123+ ) ,
124+ ) ;
125+ } else {
126+ command. env ( key, value) ;
127+ }
93128 }
94129 }
95130 crate :: process:: strip_proxy_env_std ( & mut command) ;
96131 for ( key, value) in & spec. env {
97132 if !key. starts_with ( "OPENSHELL_" ) {
98- command. env ( key, value) ;
133+ if key == "PATH" {
134+ command. env (
135+ key,
136+ crate :: child_env:: maybe_path_with_standard_sbin_paths (
137+ value,
138+ repair_standard_sbin,
139+ ) ,
140+ ) ;
141+ } else {
142+ command. env ( key, value) ;
143+ }
99144 }
100145 }
101146 if let Some ( workdir) = spec. workdir . as_deref ( ) . or ( self . base_workdir . as_deref ( ) ) {
0 commit comments