Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub enum ErrorCode {
SetNs = 12,
CapSet = 13,
PreExec = 14,
SetGroupsDeny = 15,
}

/// Error runnning process
Expand Down Expand Up @@ -93,6 +94,8 @@ pub enum Error {
BeforeUnfreeze(Box<dyn (::std::error::Error) + Send + Sync + 'static>),
/// Before exec callback error
PreExec(i32),
/// Writing /proc/self/setgroups < deny failed
SetGroupsDeny(i32)
}

impl Error {
Expand Down Expand Up @@ -120,6 +123,7 @@ impl Error {
&CapSet(x) => Some(x),
&BeforeUnfreeze(..) => None,
&PreExec(x) => Some(x),
&SetGroupsDeny(x) => Some(x),
}
}
}
Expand Down Expand Up @@ -148,6 +152,7 @@ impl Error {
&CapSet(_) => "error when setting capabilities",
&BeforeUnfreeze(_) => "error in before_unfreeze callback",
&PreExec(_) => "error in pre_exec callback",
&SetGroupsDeny(_) => "error setting /proc/self/setgroups < deny"
}
}
}
Expand Down Expand Up @@ -240,6 +245,7 @@ impl ErrorCode {
C::SetNs => E::SetNs(errno),
C::CapSet => E::CapSet(errno),
C::PreExec => E::PreExec(errno),
C::SetGroupsDeny => E::SetGroupsDeny(errno),
}
}
pub fn from_i32(code: i32, errno: i32) -> Error {
Expand Down
8 changes: 8 additions & 0 deletions src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,14 @@ impl Command {
result(Err::SetIdMap,
File::create(format!("/proc/{}/uid_map", pid))
.and_then(|mut f| f.write_all(&buf[..])))?;


let buf = "deny".as_bytes();

result(Err::SetGroupsDeny,
File::create(format!("/proc/{}/setgroups", pid))
.and_then(|mut f| f.write_all(&buf[..])))?;

let mut buf = Vec::new();
for map in gids {
writeln!(&mut buf, "{} {} {}",
Expand Down