File tree Expand file tree Collapse file tree 4 files changed +11
-8
lines changed Expand file tree Collapse file tree 4 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ crossbeam = "0.8.1"
3131futures = " 0.3.19"
3232libc = " 0.2.112"
3333log = {version = " 0.4.2" , features =[" kv_unstable" ]}
34- nix = " 0.29 "
34+ nix = " 0.30 "
3535oci-spec = " 0.7"
3636os_pipe = " 1.1"
3737prctl = " 1.0.0"
Original file line number Diff line number Diff line change 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
1919use async_trait:: async_trait;
2020use 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 }
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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 } ) ?;
You can’t perform that action at this time.
0 commit comments