From b6fb5ca2dabccaff13dcbdf87c9666d9e3a6e0e9 Mon Sep 17 00:00:00 2001 From: vasilito Date: Sat, 18 Jul 2026 10:43:07 +0900 Subject: [PATCH] login: drop spawn_shell CWD workaround and diagnostics The real fix is in init (no longer leaves an initfs-scheme CWD that is invalid in the restricted login namespace), so spawn_shell can stay minimal again. --- src/lib.rs | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) 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),