(&mut self, args: &[String])
| 27 | |
| 28 | impl OpenclawRunner for RealOpenclawRunner { |
| 29 | fn run(&mut self, args: &[String]) -> Result<OpenclawCommandOutput, String> { |
| 30 | let mut command = std::process::Command::new("openclaw"); |
| 31 | command.args(args.iter().map(String::as_str)); |
| 32 | command.env_remove("OPENAI_API_KEY"); |
| 33 | command.env_remove("ANTHROPIC_API_KEY"); |
| 34 | command.env_remove("ANTHROPIC_OAUTH_TOKEN"); |
| 35 | #[cfg(unix)] |
| 36 | { |
| 37 | if nix::unistd::geteuid().is_root() { |
| 38 | let (uid, gid) = resolve_non_root_ids_for_openclaw()?; |
| 39 | command.uid(uid); |
| 40 | command.gid(gid); |
| 41 | let user_env = resolve_non_root_user_env_for_openclaw(uid)?; |
| 42 | command.env("HOME", user_env.home_dir); |
| 43 | command.env("USER", user_env.username.as_str()); |
| 44 | command.env("LOGNAME", user_env.username.as_str()); |
| 45 | } |
| 46 | } |
| 47 | let output = command |
| 48 | .output() |
| 49 | .map_err(|error| format!("failed to spawn command: {error}"))?; |
| 50 | Ok(OpenclawCommandOutput { |
| 51 | success: output.status.success(), |
| 52 | status_code: output.status.code(), |
| 53 | stdout: String::from_utf8_lossy(&output.stdout).to_string(), |
| 54 | stderr: String::from_utf8_lossy(&output.stderr).to_string(), |
| 55 | }) |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | #[cfg(unix)] |
no test coverage detected