mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
fix: restore chown on /proc/self/fd/* for subcontainer exec
The pipe-wrap binary guarantees FDs are always pipes (not sockets), making the chown safe. The chown is still needed because anonymous pipes have mode 0600 — without it, non-root users cannot re-open /dev/stderr via /proc/self/fd/2.
This commit is contained in:
@@ -269,6 +269,13 @@ impl ExecParams {
|
||||
|
||||
std::os::unix::fs::chroot(chroot)
|
||||
.with_ctx(|_| (ErrorKind::Filesystem, lazy_format!("chroot {chroot:?}")))?;
|
||||
if let Ok(uid) = uid {
|
||||
if uid != 0 {
|
||||
std::os::unix::fs::chown("/proc/self/fd/0", Some(uid), gid.ok()).ok();
|
||||
std::os::unix::fs::chown("/proc/self/fd/1", Some(uid), gid.ok()).ok();
|
||||
std::os::unix::fs::chown("/proc/self/fd/2", Some(uid), gid.ok()).ok();
|
||||
}
|
||||
}
|
||||
// Handle credential changes in pre_exec to control the order:
|
||||
// setgroups must happen before setgid/setuid (requires CAP_SETGID)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user