Skip to content

Commit

Permalink
fix: PrivateDevices=true denies mknod and makes /dev noexec
Browse files Browse the repository at this point in the history
  • Loading branch information
desbma committed Jan 31, 2025
1 parent 39e2aa4 commit 7f5b3d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/systemd/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,11 @@ pub(crate) fn build_options(
.collect(),
}),
OptionValueEffect::DenySyscalls(DenySyscalls::Class("raw-io")),
OptionValueEffect::DenyAction(ProgramAction::MknodSpecial),
OptionValueEffect::DenyExec(PathDescription::Base {
base: "/dev/".into(),
exceptions: vec![],
}),
])),
}],
updater: None,
Expand Down
2 changes: 1 addition & 1 deletion tests/cl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ fn run_mknod() {
.stdout(predicate::str::contains("ProtectSystem=strict\n").count(1))
.stdout(predicate::str::contains("ProtectHome=tmpfs\n").count(1))
.stdout(predicate::str::contains("PrivateTmp=true\n").count(1).or(predicate::str::contains("PrivateTmp=disconnected\n").count(1)))
.stdout(predicate::str::contains("PrivateDevices=true\n").count(1))
.stdout(predicate::str::contains("PrivateDevices=").not())
.stdout(predicate::str::contains("ProtectKernelTunables=true\n").count(1))
.stdout(predicate::str::contains("ProtectKernelModules=true\n").count(1))
.stdout(predicate::str::contains("ProtectKernelLogs=true\n").count(1))
Expand Down

0 comments on commit 7f5b3d5

Please sign in to comment.