Skip to content

Commit

Permalink
Remove systemd's device filter configuration if any
Browse files Browse the repository at this point in the history
We remove systemd's filter but it might be added back by systemd if we
don't get rid of these config completely.
  • Loading branch information
nbdd0121 committed Dec 1, 2024
1 parent 7059bf7 commit 6849399
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/runc/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,22 @@ impl Container {
}
});

// runc configures systemd to also perform device filtering.
// The removal of systemd's filtering is insufficient since after daemon-reload (or maybe
// some other triggers as well), systemd will reconcile and add it back, which disrupts
// container-hotplug's operation.
// So we'll also go ahead and remove these configuration files. Ignore errors if any since
// the cgroup might be handled by runc directly if `--cgroup-manager=cgroupfs` is used.
let cgroup_name = state
.cgroup_paths
.unified
.file_name()
.context("cgroup doesn't have file name")?
.to_str()
.context("cgroup name is not UTF-8")?;
let _ = std::fs::remove_file(format!("/run/systemd/transient/{cgroup_name}.d/50-DeviceAllow.conf"));
let _ = std::fs::remove_file(format!("/run/systemd/transient/{cgroup_name}.d/50-DevicePolicy.conf"));

let cgroup_device_filter: Box<dyn DeviceAccessController + Send> =
if let Some(device_cgroup) = &state.cgroup_paths.devices {
Box::new(DeviceAccessControllerV1::new(device_cgroup)?)
Expand Down

0 comments on commit 6849399

Please sign in to comment.