about summary refs log tree commit diff
path: root/ops/posix_mq.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-02-04T12·30+0300
committerclbot <clbot@tvl.fyi>2022-02-04T15·58+0000
commit91ef2b671e18680de6b135910491466498896bdb (patch)
tree959fac6c9774f90354f7db8baa601a3ed40b3116 /ops/posix_mq.rs
parenta2ecd53f5822ae07fabfc7d2fac7fa929eb7f795 (diff)
chore(ops/posix_mq.rs): upgrade to nix 0.23 r/3769
The previous version had a CVE.

As part of this upgrade, the handling of errors inside of the Nix
crate changed, which we now accommodate.

Change-Id: Iad9a473c1782e0d79919cb5dc3f76316852d8a16
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5226
Tested-by: BuildkiteCI
Autosubmit: tazjin <tazjin@tvl.su>
Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'ops/posix_mq.rs')
-rw-r--r--ops/posix_mq.rs/Cargo.lock55
-rw-r--r--ops/posix_mq.rs/Cargo.toml2
-rw-r--r--ops/posix_mq.rs/src/error.rs42
3 files changed, 50 insertions, 49 deletions
diff --git a/ops/posix_mq.rs/Cargo.lock b/ops/posix_mq.rs/Cargo.lock
index fdd0086c4d..7afe319aef 100644
--- a/ops/posix_mq.rs/Cargo.lock
+++ b/ops/posix_mq.rs/Cargo.lock
@@ -1,54 +1,63 @@
 # This file is automatically @generated by Cargo.
 # It is not intended for manual editing.
+version = 3
+
+[[package]]
+name = "autocfg"
+version = "1.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
+
 [[package]]
 name = "bitflags"
 version = "1.2.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
 
 [[package]]
 name = "cc"
 version = "1.0.50"
 source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd"
 
 [[package]]
 name = "cfg-if"
-version = "0.1.10"
+version = "1.0.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
 
 [[package]]
 name = "libc"
-version = "0.2.66"
+version = "0.2.117"
 source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e74d72e0f9b65b5b4ca49a346af3976df0f9c61d550727f349ecd559f251a26c"
+
+[[package]]
+name = "memoffset"
+version = "0.6.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce"
+dependencies = [
+ "autocfg",
+]
 
 [[package]]
 name = "nix"
-version = "0.16.1"
+version = "0.23.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9f866317acbd3a240710c63f065ffb1e4fd466259045ccb504130b7f668f35c6"
 dependencies = [
- "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
- "cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)",
- "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
- "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags",
+ "cc",
+ "cfg-if",
+ "libc",
+ "memoffset",
 ]
 
 [[package]]
 name = "posix_mq"
 version = "0.9.0"
 dependencies = [
- "libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
- "nix 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc",
+ "nix",
 ]
-
-[[package]]
-name = "void"
-version = "1.0.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-
-[metadata]
-"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
-"checksum cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)" = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd"
-"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
-"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
-"checksum nix 0.16.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dd0eaf8df8bab402257e0a5c17a254e4cc1f72a93588a1ddfb5d356c801aa7cb"
-"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
diff --git a/ops/posix_mq.rs/Cargo.toml b/ops/posix_mq.rs/Cargo.toml
index d72e87a3dc..81b448c691 100644
--- a/ops/posix_mq.rs/Cargo.toml
+++ b/ops/posix_mq.rs/Cargo.toml
@@ -7,5 +7,5 @@ license = "MIT"
 repository = "https://git.tazj.in/tree/ops/posix_mq.rs"
 
 [dependencies]
-nix = "0.16"
+nix = "0.23"
 libc = "0.2"
diff --git a/ops/posix_mq.rs/src/error.rs b/ops/posix_mq.rs/src/error.rs
index c509d45c28..84be154bee 100644
--- a/ops/posix_mq.rs/src/error.rs
+++ b/ops/posix_mq.rs/src/error.rs
@@ -47,7 +47,7 @@ pub enum Error {
 
     // Some other unexpected / unknown error occured. This is probably an error from
     // the nix crate. Bug reports also welcome for this!
-    UnknownInternalError(Option<nix::Error>),
+    UnknownInternalError(),
 }
 
 impl fmt::Display for Error {
@@ -74,7 +74,7 @@ impl fmt::Display for Error {
                 "maximum number of system file descriptors reached"
             }
             UnknownForeignError(_) => "unknown foreign error occured: please report a bug!",
-            UnknownInternalError(_) => "unknown internal error occured: please report a bug!",
+            UnknownInternalError() => "unknown internal error occured: please report a bug!",
         })
     }
 }
@@ -91,11 +91,20 @@ impl error::Error for Error {
 
 /// This from implementation is used to translate errors from the lower-level
 /// C-calls into sensible Rust errors.
-impl From<nix::Error> for Error {
-    fn from(e: nix::Error) -> Self {
-        match e {
-            nix::Error::Sys(e) => match_errno(e),
-            _ => Error::UnknownInternalError(Some(e)),
+impl From<nix::errno::Errno> for Error {
+    fn from(err: nix::Error) -> Self {
+        use nix::errno::Errno::*;
+        match err {
+            EACCES => Error::PermissionDenied(),
+            EBADF => Error::InvalidQueueDescriptor(),
+            EINTR => Error::QueueCallInterrupted(),
+            EEXIST => Error::QueueAlreadyExists(),
+            EMFILE => Error::ProcessFileDescriptorLimitReached(),
+            ENFILE => Error::SystemFileDescriptorLimitReached(),
+            ENOENT => Error::QueueNotFound(),
+            ENOMEM => Error::InsufficientMemory(),
+            ENOSPC => Error::InsufficientSpace(),
+            _ => Error::UnknownForeignError(err),
         }
     }
 }
@@ -111,23 +120,6 @@ impl From<io::Error> for Error {
 // here because the system is probably seriously broken if those files don't contain numbers.
 impl From<num::ParseIntError> for Error {
     fn from(_: num::ParseIntError) -> Self {
-        Error::UnknownInternalError(None)
-    }
-}
-
-fn match_errno(err: nix::errno::Errno) -> Error {
-    use nix::errno::Errno::*;
-
-    match err {
-        EACCES => Error::PermissionDenied(),
-        EBADF => Error::InvalidQueueDescriptor(),
-        EINTR => Error::QueueCallInterrupted(),
-        EEXIST => Error::QueueAlreadyExists(),
-        EMFILE => Error::ProcessFileDescriptorLimitReached(),
-        ENFILE => Error::SystemFileDescriptorLimitReached(),
-        ENOENT => Error::QueueNotFound(),
-        ENOMEM => Error::InsufficientMemory(),
-        ENOSPC => Error::InsufficientSpace(),
-        _ => Error::UnknownForeignError(err),
+        Error::UnknownInternalError()
     }
 }