pub struct SecurityConfig {
pub userns: bool,
pub drop_caps: Vec<String>,
pub add_caps: Vec<String>,
pub no_new_privileges: bool,
pub read_only: bool,
pub system_call_filter: Vec<String>,
pub apparmor_profile: Option<String>,
}Expand description
Security configuration for containers.
All fields are optional; unset fields mean “use nspawn defaults”.
§Examples
let sec = SecurityConfig {
drop_caps: vec!["CAP_SYS_PTRACE".into()],
no_new_privileges: true,
..Default::default()
};
assert!(!sec.is_empty());
assert!(SecurityConfig::default().is_empty());Fields§
§userns: boolEnable user namespace isolation (--private-users=pick).
drop_caps: Vec<String>Capabilities to drop (e.g. CAP_SYS_PTRACE).
add_caps: Vec<String>Capabilities to add back (e.g. CAP_NET_ADMIN).
no_new_privileges: boolPrevent gaining privileges via setuid/file capabilities.
read_only: boolMount the rootfs read-only.
system_call_filter: Vec<String>Seccomp system call filter (e.g. @system-service, ~@mount).
apparmor_profile: Option<String>AppArmor profile name (applied as systemd unit directive).
Implementations§
Source§impl SecurityConfig
impl SecurityConfig
Sourcepub fn from_state(state: &State) -> Self
pub fn from_state(state: &State) -> Self
Read security config from a container’s state file.
Sourcepub fn write_to_state(&self, state: &mut State)
pub fn write_to_state(&self, state: &mut State)
Write security config into a container’s state file.
Sourcepub fn to_nspawn_args(&self, systemd_version: u32) -> Vec<String>
pub fn to_nspawn_args(&self, systemd_version: u32) -> Vec<String>
Generate systemd-nspawn arguments for security options.
systemd_version controls which --private-users-ownership mode
is used: systemd >= 256 supports map (idmapped rootfs mount,
zero-overhead), older versions fall back to auto (recursive
chown on first boot).
Does NOT include AppArmor: that goes into the systemd unit drop-in
as AppArmorProfile=, not as an nspawn flag.
Trait Implementations§
Source§impl Clone for SecurityConfig
impl Clone for SecurityConfig
Source§fn clone(&self) -> SecurityConfig
fn clone(&self) -> SecurityConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more