summaryrefslogtreecommitdiffstats
path: root/crates
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2024-04-02 22:40:59 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2024-04-02 22:40:59 +0200
commit89e193c1ab8184f74b2b40f3822e544d5e0d5163 (patch)
treedae862e629bd499c3d7f344ebeab938781e913a6 /crates
parent1e8875b6437f3b3a1505e25dde8e352d232b09fa (diff)
downloadrebel-89e193c1ab8184f74b2b40f3822e544d5e0d5163.tar
rebel-89e193c1ab8184f74b2b40f3822e544d5e0d5163.zip
Update dependencies
Diffstat (limited to 'crates')
-rw-r--r--crates/driver/Cargo.toml4
-rw-r--r--crates/driver/src/driver.rs4
-rw-r--r--crates/runner/Cargo.toml2
-rw-r--r--crates/runner/src/jobserver.rs15
-rw-r--r--crates/runner/src/lib.rs15
-rw-r--r--crates/runner/src/util/fs.rs2
-rw-r--r--crates/runner/src/util/unix.rs11
7 files changed, 28 insertions, 25 deletions
diff --git a/crates/driver/Cargo.toml b/crates/driver/Cargo.toml
index ecea8b8..683ebbe 100644
--- a/crates/driver/Cargo.toml
+++ b/crates/driver/Cargo.toml
@@ -14,10 +14,10 @@ runner = { path = "../runner", package = "rebel-runner" }
clap = { version = "4.0.0", features = ["derive"] }
deb-version = "0.1.1"
enum-kinds = "0.5.1"
-handlebars = "4.1.3"
+handlebars = "5.1.2"
indoc = "2.0.4"
lazy_static = "1.4.0"
-nix = { version = "0.27.1", features = ["poll"] }
+nix = { version = "0.28.0", features = ["poll"] }
nom = "7.1.0"
scoped-tls-hkt = "0.1.2"
serde = { version = "1", features = ["derive", "rc"] }
diff --git a/crates/driver/src/driver.rs b/crates/driver/src/driver.rs
index d0abbcb..8acf50a 100644
--- a/crates/driver/src/driver.rs
+++ b/crates/driver/src/driver.rs
@@ -352,10 +352,10 @@ impl<'ctx> Driver<'ctx> {
let mut pollfds: Vec<_> = self
.tasks_running
.values()
- .map(|(socket, _)| poll::PollFd::new(socket, poll::PollFlags::POLLIN))
+ .map(|(socket, _)| poll::PollFd::new(socket.as_fd(), poll::PollFlags::POLLIN))
.collect();
- while poll::poll(&mut pollfds, -1).context("poll()")? == 0 {}
+ while poll::poll(&mut pollfds, poll::PollTimeout::NONE).context("poll()")? == 0 {}
let pollevents: Vec<_> = pollfds
.into_iter()
diff --git a/crates/runner/Cargo.toml b/crates/runner/Cargo.toml
index bd1287e..ed2716b 100644
--- a/crates/runner/Cargo.toml
+++ b/crates/runner/Cargo.toml
@@ -15,7 +15,7 @@ blake3 = { version = "1.3.0", features = ["traits-preview"] }
capctl = "0.2.0"
digest = "0.10.1"
libc = "0.2.84"
-nix = { version = "0.27.1", features = ["user", "fs", "process", "mount", "sched", "poll", "signal", "hostname"] }
+nix = { version = "0.28.0", features = ["user", "fs", "process", "mount", "sched", "poll", "signal", "hostname"] }
olpc-cjson = "0.1.0"
serde = { version = "1", features = ["derive"] }
serde_json = "1.0.62"
diff --git a/crates/runner/src/jobserver.rs b/crates/runner/src/jobserver.rs
index 2422a75..b0b88cd 100644
--- a/crates/runner/src/jobserver.rs
+++ b/crates/runner/src/jobserver.rs
@@ -1,5 +1,5 @@
use std::{
- os::fd::{AsRawFd, FromRawFd, OwnedFd},
+ os::fd::{AsFd, AsRawFd, OwnedFd},
slice,
};
@@ -18,13 +18,10 @@ pub struct Jobserver {
impl Jobserver {
pub fn new(tokens: usize) -> Result<Jobserver> {
- let (piper, pipew) =
- unistd::pipe2(OFlag::O_CLOEXEC | OFlag::O_NONBLOCK).context("pipe()")?;
- let r = unsafe { OwnedFd::from_raw_fd(piper) };
- let w = unsafe { OwnedFd::from_raw_fd(pipew) };
+ let (r, w) = unistd::pipe2(OFlag::O_CLOEXEC | OFlag::O_NONBLOCK).context("pipe()")?;
for _ in 0..tokens {
- if unistd::write(w.as_raw_fd(), b"+").is_err() {
+ if unistd::write(w.as_fd(), b"+").is_err() {
break;
}
}
@@ -36,8 +33,8 @@ impl Jobserver {
pub fn wait(&mut self) -> u8 {
loop {
poll::poll(
- &mut [poll::PollFd::new(&self.r, poll::PollFlags::POLLIN)],
- -1,
+ &mut [poll::PollFd::new(self.r.as_fd(), poll::PollFlags::POLLIN)],
+ poll::PollTimeout::NONE,
)
.expect("poll()");
@@ -59,7 +56,7 @@ impl Jobserver {
}
pub fn post(&mut self, token: u8) {
- let n = unistd::write(self.w.as_raw_fd(), slice::from_ref(&token)).expect("write()");
+ let n = unistd::write(self.w.as_fd(), slice::from_ref(&token)).expect("write()");
assert!(n == 1);
}
diff --git a/crates/runner/src/lib.rs b/crates/runner/src/lib.rs
index 308b54c..bcaa9db 100644
--- a/crates/runner/src/lib.rs
+++ b/crates/runner/src/lib.rs
@@ -17,6 +17,7 @@ use std::{
use capctl::prctl;
use nix::{
errno::Errno,
+ fcntl::Flock,
poll,
sched::CloneFlags,
sys::{
@@ -99,7 +100,13 @@ fn borrow_socket_fd(socket: &UnixSeqpacketConn) -> BorrowedFd<'_> {
unsafe { BorrowedFd::borrow_raw(socket.as_raw_fd()) }
}
-fn runner(uid: Uid, gid: Gid, socket: UnixSeqpacketConn, _lockfile: File, options: &Options) -> ! {
+fn runner(
+ uid: Uid,
+ gid: Gid,
+ socket: UnixSeqpacketConn,
+ _lockfile: Flock<File>,
+ options: &Options,
+) -> ! {
ns::mount_proc();
ns::setup_userns(Uid::from_raw(0), Gid::from_raw(0), uid, gid);
@@ -127,10 +134,10 @@ fn runner(uid: Uid, gid: Gid, socket: UnixSeqpacketConn, _lockfile: File, option
loop {
let socket_fd = borrow_socket_fd(&ctx.socket);
let mut pollfds = [
- poll::PollFd::new(&signal_fd, poll::PollFlags::POLLIN),
- poll::PollFd::new(&socket_fd, poll::PollFlags::POLLIN),
+ poll::PollFd::new(signal_fd.as_fd(), poll::PollFlags::POLLIN),
+ poll::PollFd::new(socket_fd.as_fd(), poll::PollFlags::POLLIN),
];
- poll::poll(&mut pollfds, -1).expect("poll()");
+ poll::poll(&mut pollfds, poll::PollTimeout::NONE).expect("poll()");
let signal_events = pollfds[0]
.revents()
diff --git a/crates/runner/src/util/fs.rs b/crates/runner/src/util/fs.rs
index 9e16648..5efd159 100644
--- a/crates/runner/src/util/fs.rs
+++ b/crates/runner/src/util/fs.rs
@@ -123,5 +123,5 @@ pub fn mount<P1: AsRef<Path>, P2: AsRef<Path>>(
pub fn pipe() -> Result<(File, File)> {
unistd::pipe2(OFlag::O_CLOEXEC)
.context("pipe2()")
- .map(|(piper, pipew)| unsafe { (File::from_raw_fd(piper), File::from_raw_fd(pipew)) })
+ .map(|(piper, pipew)| (File::from(piper), File::from(pipew)))
}
diff --git a/crates/runner/src/util/unix.rs b/crates/runner/src/util/unix.rs
index 156e441..08884ec 100644
--- a/crates/runner/src/util/unix.rs
+++ b/crates/runner/src/util/unix.rs
@@ -1,7 +1,7 @@
use std::{fs::File, os::unix::prelude::*, path::Path};
use nix::{
- fcntl::{self, FcntlArg, FdFlag, OFlag},
+ fcntl::{self, FcntlArg, FdFlag, Flock, OFlag},
sched,
unistd::Pid,
};
@@ -65,7 +65,7 @@ pub fn nproc() -> Result<usize> {
Ok(count)
}
-pub fn lock<P: AsRef<Path>>(path: P, exclusive: bool, blocking: bool) -> Result<File> {
+pub fn lock<P: AsRef<Path>>(path: P, exclusive: bool, blocking: bool) -> Result<Flock<File>> {
use fcntl::FlockArg::*;
if let Some(parent) = path.as_ref().parent() {
@@ -80,8 +80,7 @@ pub fn lock<P: AsRef<Path>>(path: P, exclusive: bool, blocking: bool) -> Result<
};
let file = fs::create(path.as_ref())?;
- fcntl::flock(file.as_raw_fd(), arg)
- .with_context(|| format!("flock failed on {:?}", path.as_ref()))?;
-
- Ok(file)
+ fcntl::Flock::lock(file, arg)
+ .map_err(|(_, errno)| errno)
+ .with_context(|| format!("flock failed on {:?}", path.as_ref()))
}