switch-to-configuration-ng: fix running on WSL
The switch-to-configuration-ng program is able to be called in two different contexts, (1) when being called as root by as the entrypoint to NixOS switching (often from nixos-rebuild), and (2) when performing user activation. On WSL, calling the child process for the latter context appears to not work without also setting the GID of the child. Setting the GID for the child process is likely the right thing to do regardless of the host system being WSL.
This commit is contained in:
parent
6a6b710fbf
commit
3d1ecbd9c8
@ -1656,7 +1656,16 @@ won't take effect until you reboot the system.
|
||||
die();
|
||||
}
|
||||
Ok(users) => {
|
||||
for (uid, name, _) in users {
|
||||
for (uid, name, user_dbus_path) in users {
|
||||
let gid: u32 = dbus_conn
|
||||
.with_proxy(
|
||||
"org.freedesktop.login1",
|
||||
&user_dbus_path,
|
||||
Duration::from_millis(5000),
|
||||
)
|
||||
.get("org.freedesktop.login1.User", "GID")
|
||||
.with_context(|| format!("Failed to get GID for {name}"))?;
|
||||
|
||||
eprintln!("reloading user units for {}...", name);
|
||||
let myself = Path::new("/proc/self/exe")
|
||||
.canonicalize()
|
||||
@ -1664,10 +1673,12 @@ won't take effect until you reboot the system.
|
||||
|
||||
std::process::Command::new(&myself)
|
||||
.uid(uid)
|
||||
.gid(gid)
|
||||
.env("XDG_RUNTIME_DIR", format!("/run/user/{}", uid))
|
||||
.env("__NIXOS_SWITCH_TO_CONFIGURATION_PARENT_EXE", &myself)
|
||||
.spawn()
|
||||
.map(|mut child| _ = child.wait())
|
||||
.with_context(|| format!("Failed to spawn user activation for {name}"))?
|
||||
.wait()
|
||||
.with_context(|| format!("Failed to run user activation for {name}"))?;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user