Skip to content

Commit cad809b

Browse files
committed
Update nix to 0.30
Signed-off-by: Maksym Pavlenko <[email protected]>
1 parent f74cf74 commit cad809b

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ crossbeam = "0.8.1"
3131
futures = "0.3.19"
3232
libc = "0.2.112"
3333
log = {version = "0.4.2", features=["kv_unstable"]}
34-
nix = "0.29"
34+
nix = "0.30"
3535
oci-spec = "0.7"
3636
os_pipe = "1.1"
3737
prctl = "1.0.0"

crates/runc/src/asynchronous/io.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
limitations under the License.
1515
*/
1616

17-
use std::{fmt::Debug, io::Result, os::unix::io::AsRawFd, process::Stdio};
17+
use std::{fmt::Debug, io::Result, process::Stdio};
1818

1919
use async_trait::async_trait;
2020
use nix::unistd::{Gid, Uid};
@@ -67,10 +67,10 @@ impl PipedIo {
6767
let gid = Some(Gid::from_raw(gid));
6868
if stdin {
6969
let rd = pipe.rd.try_clone()?;
70-
nix::unistd::fchown(rd.as_raw_fd(), uid, gid)?;
70+
nix::unistd::fchown(rd, uid, gid)?;
7171
} else {
7272
let wr = pipe.wr.try_clone()?;
73-
nix::unistd::fchown(wr.as_raw_fd(), uid, gid)?;
73+
nix::unistd::fchown(wr, uid, gid)?;
7474
}
7575
Ok(Some(pipe))
7676
}

crates/runc/src/synchronous/io.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::{
1818
fmt::Debug,
1919
fs::{File, OpenOptions},
2020
io::Result,
21-
os::unix::{fs::OpenOptionsExt, io::AsRawFd},
21+
os::unix::fs::OpenOptionsExt,
2222
process::Stdio,
2323
sync::Mutex,
2424
};
@@ -72,10 +72,10 @@ impl PipedIo {
7272
let gid = Some(Gid::from_raw(gid));
7373
if stdin {
7474
let rd = pipe.rd.try_clone()?;
75-
nix::unistd::fchown(rd.as_raw_fd(), uid, gid)?;
75+
nix::unistd::fchown(rd, uid, gid)?;
7676
} else {
7777
let wr = pipe.wr.try_clone()?;
78-
nix::unistd::fchown(wr.as_raw_fd(), uid, gid)?;
78+
nix::unistd::fchown(wr, uid, gid)?;
7979
}
8080
Ok(Some(pipe))
8181
}

crates/shim/src/util.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,11 @@ pub fn connect(address: impl AsRef<str>) -> Result<RawFd> {
120120
// so there is a chance of leak if fork + exec happens in between of these calls.
121121
#[cfg(not(target_os = "linux"))]
122122
{
123+
use std::os::fd::BorrowedFd;
123124
use nix::fcntl::{fcntl, FcntlArg, FdFlag};
124-
fcntl(fd, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC)).map_err(|e| {
125+
// SAFETY: fd is a valid file descriptor that we just created
126+
let borrowed_fd = unsafe { BorrowedFd::borrow_raw(fd) };
127+
fcntl(borrowed_fd, FcntlArg::F_SETFD(FdFlag::FD_CLOEXEC)).map_err(|e| {
125128
let _ = close(fd);
126129
e
127130
})?;

0 commit comments

Comments
 (0)