Expose the bwrap command line at /run/agent-sandbox inside every sandbox
This commit is contained in:
+3
-12
@@ -32,7 +32,7 @@
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::io::{Seek, SeekFrom, Write};
|
||||
use std::os::fd::{FromRawFd, IntoRawFd, RawFd};
|
||||
use std::os::fd::{IntoRawFd, RawFd};
|
||||
use std::str::FromStr;
|
||||
|
||||
use seccompiler::{
|
||||
@@ -42,6 +42,7 @@ use seccompiler::{
|
||||
use syscalls::Sysno;
|
||||
|
||||
use crate::SandboxError;
|
||||
use crate::memfd;
|
||||
|
||||
/// Syscall allowlist. Includes Podman's unconditional allow set (minus syscalls
|
||||
/// we deny on top, see module docs) plus arch-specific syscalls for the targets
|
||||
@@ -55,17 +56,7 @@ const ALLOWED_SYSCALLS: &[&str] = &include!("seccomp_allowlist.in");
|
||||
pub fn write_program_to_memfd() -> Result<RawFd, SandboxError> {
|
||||
let bytes = build_program_bytes()?;
|
||||
|
||||
// Safety: memfd_create is a normal Linux syscall. We pass a valid C string
|
||||
// and flags=0, so the fd is created without MFD_CLOEXEC and survives exec
|
||||
// into bwrap. The name is only a debugging label (shows up as the symlink
|
||||
// target in /proc/<pid>/fd/<n>).
|
||||
let raw_fd = unsafe { libc::memfd_create(c"agent-sandbox-seccomp".as_ptr(), 0) };
|
||||
if raw_fd < 0 {
|
||||
return Err(SandboxError::Io(std::io::Error::last_os_error()));
|
||||
}
|
||||
|
||||
// Safety: raw_fd is owned by us and currently uniquely held.
|
||||
let mut file = unsafe { std::fs::File::from_raw_fd(raw_fd) };
|
||||
let mut file = memfd::create_inheritable(c"agent-sandbox-seccomp")?;
|
||||
file.write_all(&bytes)?;
|
||||
file.seek(SeekFrom::Start(0))?;
|
||||
// into_raw_fd consumes the File without closing the underlying fd.
|
||||
|
||||
Reference in New Issue
Block a user