Skip to content

Commit 171cd72

Browse files
MarkusPettersson98cathay4t
authored andcommitted
Bump minimum nix version to 0.30.0
Get rid of `unsafe` when passing file descriptor to `setns` syscall.
1 parent e28f321 commit 171cd72

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ netlink-sys = { version = "0.8" }
2525
netlink-packet-route = { version = "0.25" }
2626
netlink-packet-core = { version = "0.8" }
2727
netlink-proto = { default-features = false, version = "0.12.0" }
28-
nix = { version = "0.29.0", default-features = false, features = ["fs", "mount", "sched", "signal"] }
28+
nix = { version = "0.30.0", default-features = false, features = ["fs", "mount", "sched", "signal"] }
2929
tokio = { version = "1.0.1", features = ["rt"], optional = true}
3030
async-global-executor = { version = "2.0.2", optional = true }
3131

src/ns.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: MIT
22

3-
use std::{os::fd::BorrowedFd, path::Path, process::exit};
3+
use std::{path::Path, process::exit};
44

55
use nix::{
66
fcntl::OFlag,
@@ -331,10 +331,7 @@ impl NetworkNamespace {
331331
}
332332

333333
setns_flags.insert(CloneFlags::CLONE_NEWNET);
334-
if let Err(e) = nix::sched::setns(
335-
unsafe { BorrowedFd::borrow_raw(fd) },
336-
setns_flags,
337-
) {
334+
if let Err(e) = nix::sched::setns(fd, setns_flags) {
338335
log::error!("setns error: {}", e);
339336
let err_msg = format!("setns error: {e}");
340337
let _ = nix::unistd::unlink(ns_path);

0 commit comments

Comments
 (0)