MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / spawn_pipe_exec

Function spawn_pipe_exec

crates/openshell-supervisor-process/src/ssh.rs:905–1066  ·  view source on GitHub ↗
(
    policy: &SandboxPolicy,
    workdir: Option<String>,
    command: Option<String>,
    handle: Handle,
    channel: ChannelId,
    netns_fd: Option<RawFd>,
    proxy_url: Option<String>,
    ca_f

Source from the content-addressed store, hash-verified

903/// expect. Output retains clean LF line endings (no CRLF translation).
904#[allow(clippy::too_many_arguments)]
905fn spawn_pipe_exec(
906 policy: &SandboxPolicy,
907 workdir: Option<String>,
908 command: Option<String>,
909 handle: Handle,
910 channel: ChannelId,
911 netns_fd: Option<RawFd>,
912 proxy_url: Option<String>,
913 ca_file_paths: Option<Arc<(PathBuf, PathBuf)>>,
914 provider_env: &HashMap<String, String>,
915 user_environment: &HashMap<String, String>,
916) -> anyhow::Result<mpsc::Sender<Vec<u8>>> {
917 let mut cmd = command.map_or_else(
918 || {
919 // No command — read from stdin. Do *not* pass `-i`; interactive
920 // mode reads .bashrc, writes prompts to stderr, and can introduce
921 // just enough latency for VS Code Remote-SSH's platform detection
922 // to time out and fall back to "windows". Plain `bash` with piped
923 // stdin already reads commands line-by-line (script mode), which is
924 // exactly what VS Code's local server expects.
925 Command::new("/bin/bash")
926 },
927 |command| {
928 let mut c = Command::new("/bin/bash");
929 // Use login shell (-l) so that .profile/.bashrc are sourced and
930 // tool-specific env vars (VIRTUAL_ENV, UV_PYTHON_INSTALL_DIR, etc.)
931 // are available without hardcoding them here.
932 c.arg("-lc").arg(command);
933 c
934 },
935 );
936
937 let (session_user, session_home) = session_user_and_home(policy);
938 apply_child_env(
939 &mut cmd,
940 &session_home,
941 &session_user,
942 "dumb",
943 proxy_url.as_deref(),
944 ca_file_paths.as_deref(),
945 provider_env,
946 user_environment,
947 );
948 cmd.stdin(Stdio::piped())
949 .stdout(Stdio::piped())
950 .stderr(Stdio::piped());
951
952 if let Some(dir) = workdir.as_deref() {
953 cmd.current_dir(dir);
954 }
955
956 // Probe Landlock availability from the parent process where tracing works.
957 #[cfg(target_os = "linux")]
958 sandbox::linux::log_sandbox_readiness(policy, workdir.as_deref());
959
960 // Phase 1 (as root): Prepare Landlock ruleset before drop_privileges.
961 #[cfg(target_os = "linux")]
962 let prepared_sandbox = sandbox::linux::prepare(policy, workdir.as_deref())

Callers 2

subsystem_requestMethod · 0.85
start_shellMethod · 0.85

Calls 15

session_user_and_homeFunction · 0.85
apply_child_envFunction · 0.85
log_sandbox_readinessFunction · 0.85
install_pre_exec_no_ptyFunction · 0.85
registerFunction · 0.85
unregisterFunction · 0.85
dataMethod · 0.80
waitMethod · 0.80
codeMethod · 0.80
spawnFunction · 0.70
prepareFunction · 0.50
spawnMethod · 0.45

Tested by

no test coverage detected