Skip to content

Commit 8ebd297

Browse files
committed
Better landlock usage
1 parent 4e9bd04 commit 8ebd297

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

build_system/landlock.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::env;
22
use std::path::Path;
33

44
use landlock::{
5-
path_beneath_rules, Access, AccessFs, Compatible, RulesetAttr, RulesetCreated,
5+
path_beneath_rules, Access, AccessFs, CompatLevel, Compatible, RulesetAttr, RulesetCreated,
66
RulesetCreatedAttr, ABI,
77
};
88

@@ -12,11 +12,14 @@ use crate::rustc_info::get_cargo_home;
1212
///
1313
/// This allows access to various essential system locations.
1414
pub(super) fn base_ruleset() -> RulesetCreated {
15-
let abi = ABI::V2;
15+
let abi = ABI::V4;
1616
let access_all = AccessFs::from_all(abi);
1717
let access_read = AccessFs::from_read(abi);
1818
landlock::Ruleset::default()
19-
.set_compatibility(landlock::CompatLevel::BestEffort)
19+
.set_compatibility(CompatLevel::SoftRequirement)
20+
.handle_access(AccessFs::Refer)
21+
.unwrap()
22+
.set_compatibility(CompatLevel::BestEffort)
2023
.handle_access(access_all)
2124
.unwrap()
2225
.create()
@@ -28,7 +31,7 @@ pub(super) fn base_ruleset() -> RulesetCreated {
2831
}
2932

3033
pub(super) fn lock_fetch() {
31-
let abi = ABI::V2;
34+
let abi = ABI::V4;
3235
let access_all = AccessFs::from_all(abi);
3336
base_ruleset()
3437
.add_rules(path_beneath_rules([env::current_dir().unwrap().join("download")], access_all))
@@ -38,7 +41,7 @@ pub(super) fn lock_fetch() {
3841
}
3942

4043
pub(super) fn lock_build(cargo: &Path) {
41-
let abi = ABI::V2;
44+
let abi = ABI::V4;
4245
let access_all = AccessFs::from_all(abi);
4346
base_ruleset()
4447
.add_rules(path_beneath_rules(

0 commit comments

Comments
 (0)