Skip to content

Commit 91fbc7a

Browse files
committed
Enforce frozen flag through landlock
1 parent 8ebd297 commit 91fbc7a

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

build_system/landlock.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,27 @@ pub(super) fn lock_fetch() {
4040
.unwrap();
4141
}
4242

43-
pub(super) fn lock_build(cargo: &Path) {
43+
pub(super) fn lock_build(cargo: &Path, frozen: bool) {
4444
let abi = ABI::V4;
4545
let access_all = AccessFs::from_all(abi);
46-
base_ruleset()
47-
.add_rules(path_beneath_rules(
48-
&[get_cargo_home(cargo).join("git"), get_cargo_home(cargo).join("registry")],
49-
access_all,
50-
))
51-
.unwrap()
46+
47+
let ruleset = base_ruleset()
5248
.add_rules(path_beneath_rules(
5349
&[env::current_dir().unwrap().join("build"), env::current_dir().unwrap().join("dist")],
5450
access_all,
5551
))
56-
.unwrap()
57-
.restrict_self()
5852
.unwrap();
53+
54+
let ruleset = if frozen {
55+
ruleset
56+
} else {
57+
ruleset
58+
.add_rules(path_beneath_rules(
59+
&[get_cargo_home(cargo).join("git"), get_cargo_home(cargo).join("registry")],
60+
access_all,
61+
))
62+
.unwrap()
63+
};
64+
65+
ruleset.restrict_self().unwrap();
5966
}

build_system/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ fn main() {
195195
path::RelPath::BUILD.ensure_exists(&dirs);
196196
path::RelPath::DIST.ensure_exists(&dirs);
197197

198+
landlock::lock_build(&bootstrap_host_compiler.cargo, frozen);
199+
198200
{
199201
// Make sure we always explicitly specify the target dir
200202
let target =
@@ -204,8 +206,6 @@ fn main() {
204206
std::fs::File::create(target).unwrap();
205207
}
206208

207-
landlock::lock_build(&bootstrap_host_compiler.cargo);
208-
209209
env::set_var("RUSTC", "rustc_should_be_set_explicitly");
210210
env::set_var("RUSTDOC", "rustdoc_should_be_set_explicitly");
211211

0 commit comments

Comments
 (0)