Skip to content

Commit 269179b

Browse files
committed
fix(docker): satisfy isolation prototype lints
Signed-off-by: Drew Newberry <385+drew@users.noreply.github.com>
1 parent afcdd70 commit 269179b

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎crates/openshell-driver-docker/src/isolation.rs‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ fn acquire_listener_lock(path: &Path) -> Result<File, BackendError> {
458458
.create(true)
459459
.read(true)
460460
.write(true)
461+
.truncate(false)
461462
.open(path)
462463
.map_err(|error| BackendError::Attach(format!("open Docker listener lock: {error}")))?;
463464
std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o600))
@@ -819,6 +820,9 @@ const IOC_DIRSHIFT: u32 = IOC_SIZESHIFT + IOC_SIZEBITS;
819820
const IOC_WRITE: u32 = 1;
820821
const IOC_READ: u32 = 2;
821822

823+
// Linux reserves IOC_SIZEBITS for the payload size. Both fixed seccomp
824+
// notification structs are far smaller than u32::MAX on supported targets.
825+
#[allow(clippy::cast_possible_truncation)]
822826
const fn ioctl_read_write<T>(kind: u8, number: u8) -> libc::c_ulong {
823827
((IOC_READ | IOC_WRITE) << IOC_DIRSHIFT
824828
| (kind as u32) << IOC_TYPESHIFT
@@ -843,7 +847,7 @@ fn deny_notifications(listener_fd: OwnedFd) {
843847
};
844848
if received != 0 {
845849
let error = std::io::Error::last_os_error();
846-
if matches!(error.raw_os_error(), Some(libc::EINTR) | Some(libc::ENOENT)) {
850+
if matches!(error.raw_os_error(), Some(libc::EINTR | libc::ENOENT)) {
847851
continue;
848852
}
849853
break;
@@ -969,9 +973,7 @@ mod tests {
969973
let directory = tempfile::tempdir().expect("tempdir");
970974
let path = directory.path().join("seccomp.lock");
971975
let guard = acquire_listener_lock(&path).expect("first listener lock");
972-
let second = acquire_listener_lock(&path)
973-
.err()
974-
.expect("active listener must be denied");
976+
let second = acquire_listener_lock(&path).expect_err("active listener must be denied");
975977
assert!(matches!(second, BackendError::Denied(_)));
976978
drop(guard);
977979
let _recovered_guard =

0 commit comments

Comments
 (0)