diff --git a/src/lib.rs b/src/lib.rs index e6c31d5f4a..2789547063 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -72,35 +72,9 @@ impl AllGroupsExt for AllGroups { /// spawn_shell(user).unwrap(); /// ``` pub fn spawn_shell(user: &User) -> IoResult { - // Ensure the process has a working directory that is valid in the current - // (possibly restricted) login namespace before spawning the shell. After - // `apply_login_schemes` swaps to a namespace that only contains the schemes - // in DEFAULT_SCHEMES, the CWD inherited from init (e.g. `/scheme/initfs` on - // the live image) is no longer resolvable, and file operations that consult - // the CWD fd (including the child's exec) then hang. Point the CWD at the - // user's home (falling back to `/`), both of which live on the `file` - // scheme that is always present in the login namespace. - let chdir_ok = std::env::set_current_dir(&user.home).is_ok() - || std::env::set_current_dir("/").is_ok(); - eprintln!( - "spawn-diag: chdir_ok={} cwd={:?}; about to spawn {:?}", - chdir_ok, - std::env::current_dir().ok(), - user.shell - ); - let mut command = user.shell_cmd(); - let mut child = match command.spawn() { - Ok(c) => { - eprintln!("spawn-diag: command.spawn() returned Ok (child created)"); - c - } - Err(e) => { - eprintln!("spawn-diag: command.spawn() FAILED: {} ({:?})", e, e.raw_os_error()); - return Err(e); - } - }; + let mut child = command.spawn()?; match child.wait()?.code() { Some(code) => Ok(code), None => Ok(1),