Skip to content

Commit

Permalink
Merge pull request #337 from cea-sec/dependabot/cargo/nix-0.28.0
Browse files Browse the repository at this point in the history
build(deps): bump nix from 0.27.1 to 0.28.0
  • Loading branch information
losynix authored Mar 5, 2024
2 parents 32ef1cc + 60fada0 commit 72cfa2f
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 26 deletions.
11 changes: 6 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 7 additions & 10 deletions usbsas-comm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ use std::{
fs::File,
io::{self, Read, Write},
marker::PhantomData,
os::unix::io::{AsRawFd, FromRawFd, RawFd},
os::{
fd::OwnedFd,
unix::io::{AsRawFd, FromRawFd, RawFd},
},
str::FromStr,
};
use usbsas_utils::{INPUT_PIPE_FD_VAR, OUTPUT_PIPE_FD_VAR};
Expand Down Expand Up @@ -72,16 +75,10 @@ impl<R> Comm<R> {
})
}

pub fn from_raw_fd(read: RawFd, write: RawFd) -> Self {
let output;
let input;
unsafe {
input = File::from_raw_fd(read);
output = File::from_raw_fd(write);
}
pub fn from_fd(read: OwnedFd, write: OwnedFd) -> Self {
Comm {
input,
output,
input: File::from(read),
output: File::from(write),
req: PhantomData,
}
}
Expand Down
2 changes: 1 addition & 1 deletion usbsas-process/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license = "GPL-3.0"
[dependencies]
libc = "0.2"
log = "0.4"
nix = { version = "0.27", features = ["fs", "process"] }
nix = { version = "0.28", features = ["fs", "process"] }
thiserror = "1.0"
usbsas-comm = { path = "../usbsas-comm" }
usbsas-utils = { path = "../usbsas-utils" }
22 changes: 14 additions & 8 deletions usbsas-process/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use nix::{
};
use std::{
io::{self, Write},
os::unix::io::RawFd,
os::unix::io::{AsRawFd, RawFd},
path, process,
};
use thiserror::Error;
Expand Down Expand Up @@ -88,12 +88,18 @@ impl<'a> UsbsasChildSpawner<'a> {

let (child_to_parent_rd, child_to_parent_wr) = unistd::pipe()?;
let (parent_to_child_rd, parent_to_child_wr) = unistd::pipe()?;
set_cloexec(child_to_parent_rd)?;
set_cloexec(parent_to_child_wr)?;
set_cloexec(child_to_parent_rd.as_raw_fd())?;
set_cloexec(parent_to_child_wr.as_raw_fd())?;

command.env_clear();
command.env(INPUT_PIPE_FD_VAR, parent_to_child_rd.to_string());
command.env(OUTPUT_PIPE_FD_VAR, child_to_parent_wr.to_string());
command.env(
INPUT_PIPE_FD_VAR,
parent_to_child_rd.as_raw_fd().to_string(),
);
command.env(
OUTPUT_PIPE_FD_VAR,
child_to_parent_wr.as_raw_fd().to_string(),
);
DEFAULT_ENV_VARS
.iter()
.map(|k| std::env::var(k).map(|v| (k, v)))
Expand All @@ -104,12 +110,12 @@ impl<'a> UsbsasChildSpawner<'a> {

let child = command.spawn()?;

unistd::close(parent_to_child_rd)?;
unistd::close(child_to_parent_wr)?;
drop(parent_to_child_rd);
drop(child_to_parent_wr);

Ok(UsbsasChild {
child,
comm: Comm::from_raw_fd(child_to_parent_rd, parent_to_child_wr),
comm: Comm::from_fd(child_to_parent_rd, parent_to_child_wr),
locked: self.wait_on_startup,
})
}
Expand Down
2 changes: 1 addition & 1 deletion usbsas-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ futures = "0.3"
hmac = { version = "0.12", features = ["reset"] }
log = "0.4"
mac_address = "1.1"
nix = { version = "0.27", features = ["process", "signal"] }
nix = { version = "0.28", features = ["process", "signal"] }
rand = "0.8"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion usbsas-tools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fuse_mt = { version = "0.6", optional = true }
indicatif = { version = "0.17", optional = true }
libc = { version = "0.2", optional = true }
log = "0.4"
nix = { version = "0.27", optional = true, features = ["user"] }
nix = { version = "0.28", optional = true, features = ["user"] }
tempfile = { version = "3.10", optional = true }
serde_json = { version = "1.0", optional = true}
thiserror = "1.0"
Expand Down

0 comments on commit 72cfa2f

Please sign in to comment.