Skip to content

Commit 11d4ef1

Browse files
committed
compat: Clean up get_errno_from_landlock_status()
Remove an unsafe block. Signed-off-by: Mickaël Salaün <mic@digikod.net>
1 parent 0f4246a commit 11d4ef1

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/compat.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,19 +169,15 @@ pub(crate) fn can_emulate(mock: ABI, partial_support: ABI, full_support: Option<
169169
pub(crate) fn get_errno_from_landlock_status() -> Option<i32> {
170170
use std::io::Error;
171171

172-
if unsafe {
173-
uapi::landlock_create_ruleset(std::ptr::null(), 0, uapi::LANDLOCK_CREATE_RULESET_VERSION)
174-
} < 0
175-
{
176-
match Error::last_os_error().raw_os_error() {
172+
match ABI::new_current() {
173+
ABI::Unsupported => match Error::last_os_error().raw_os_error() {
177174
// Returns ENOSYS when the kernel is not built with Landlock support,
178175
// or EOPNOTSUPP when Landlock is supported but disabled at boot time.
179176
ret @ Some(libc::ENOSYS | libc::EOPNOTSUPP) => ret,
180177
// Other values can only come from bogus seccomp filters or debug tampering.
181178
_ => unreachable!(),
182-
}
183-
} else {
184-
None
179+
},
180+
_ => None,
185181
}
186182
}
187183

0 commit comments

Comments
 (0)