From 11ca8343171b96814be4505ffd0458ea28a5daad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= Date: Thu, 2 Jun 2022 13:10:33 +0200 Subject: [PATCH] update to nix 0.24 / rustyline 9 / proxmox-sys 0.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabian Grünbichler --- Cargo.toml | 6 +++--- debian/control | 17 ++++++++------- pbs-client/Cargo.toml | 6 +++--- pbs-client/src/pxar/create.rs | 15 ++++++------- pbs-client/src/pxar/extract.rs | 4 ++-- pbs-client/src/pxar/metadata.rs | 6 +++--- pbs-client/src/vsock_client.rs | 2 +- pbs-config/Cargo.toml | 4 ++-- pbs-config/src/acl.rs | 2 +- pbs-config/src/user.rs | 2 +- pbs-datastore/Cargo.toml | 4 ++-- pbs-datastore/src/backup_info.rs | 2 +- pbs-datastore/src/chunk_store.rs | 4 ++-- pbs-datastore/src/datastore.rs | 6 +++--- pbs-datastore/src/hierarchy.rs | 2 +- pbs-fuse-loop/Cargo.toml | 4 ++-- pbs-fuse-loop/src/fuse_loop.rs | 4 ++-- pbs-tape/Cargo.toml | 4 ++-- pbs-tape/src/sgutils2.rs | 4 ++-- pbs-tools/Cargo.toml | 4 ++-- proxmox-backup-banner/Cargo.toml | 3 ++- proxmox-backup-banner/src/main.rs | 21 +++++++++++++++++-- proxmox-backup-client/Cargo.toml | 4 ++-- proxmox-file-restore/Cargo.toml | 4 ++-- proxmox-rest-server/Cargo.toml | 4 ++-- proxmox-restore-daemon/Cargo.toml | 4 ++-- proxmox-restore-daemon/src/main.rs | 2 +- .../src/proxmox_restore_daemon/disk.rs | 4 ++-- proxmox-rrd/Cargo.toml | 4 ++-- pxar-bin/Cargo.toml | 4 ++-- src/api2/node/apt.rs | 3 ++- src/api2/node/status.rs | 10 ++++----- src/config/mod.rs | 2 +- src/tools/subscription.rs | 2 +- 34 files changed, 95 insertions(+), 78 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9776a5ee..4b7e37a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,7 +61,7 @@ hyper = { version = "0.14", features = [ "full" ] } lazy_static = "1.4" libc = "0.2" log = "0.4.17" -nix = "0.19.1" +nix = "0.24" num-traits = "0.2" once_cell = "1.3.1" openssl = "0.10.38" # currently patched! @@ -69,7 +69,7 @@ pam = "0.7" pam-sys = "0.5" percent-encoding = "2.1" regex = "1.5.5" -rustyline = "7" +rustyline = "9" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" siphasher = "0.3" @@ -104,7 +104,7 @@ proxmox-time = "1.1.2" proxmox-uuid = "1" proxmox-serde = "0.1" proxmox-shared-memory = "0.2" -proxmox-sys = { version = "0.2", features = [ "sortable-macro" ] } +proxmox-sys = { version = "0.3", features = [ "sortable-macro" ] } proxmox-compression = "0.1" diff --git a/debian/control b/debian/control index 47be1df2..dbd3d14a 100644 --- a/debian/control +++ b/debian/control @@ -31,7 +31,7 @@ Build-Depends: debhelper (>= 12), librust-lazy-static-1+default-dev (>= 1.4-~~), librust-libc-0.2+default-dev, librust-log-0.4+default-dev (>= 0.4.17-~~) , - librust-nix-0.19+default-dev (>= 0.19.1-~~), + librust-nix-0.24+default-dev, librust-nom-5+default-dev (>= 5.1-~~), librust-num-traits-0.2+default-dev, librust-once-cell-1+default-dev (>= 1.3.1-~~), @@ -47,10 +47,10 @@ Build-Depends: debhelper (>= 12), librust-proxmox-borrow-1+default-dev, librust-proxmox-compression-0.1+default-dev (>= 0.1.1-~~), librust-proxmox-fuse-0.1+default-dev (>= 0.1.1-~~), - librust-proxmox-http-0.6.1+client-dev, - librust-proxmox-http-0.6.1+default-dev, - librust-proxmox-http-0.6.1+http-helpers-dev, - librust-proxmox-http-0.6.1+websocket-dev, + librust-proxmox-http-0.6+client-dev (>= 0.6.1-~~), + librust-proxmox-http-0.6+default-dev (>= 0.6.1-~~), + librust-proxmox-http-0.6+http-helpers-dev (>= 0.6.1-~~), + librust-proxmox-http-0.6+websocket-dev (>= 0.6.1-~~), librust-proxmox-io-1+default-dev (>= 1.0.1-~~), librust-proxmox-io-1+tokio-dev (>= 1.0.1-~~), librust-proxmox-lang-1+default-dev (>= 1.1-~~), @@ -63,8 +63,9 @@ Build-Depends: debhelper (>= 12), librust-proxmox-section-config-1+default-dev, librust-proxmox-serde-0.1+default-dev, librust-proxmox-shared-memory-0.2+default-dev, - librust-proxmox-sys-0.2+default-dev (>= 0.2.1-~~), - librust-proxmox-sys-0.2+sortable-macro-dev (>= 0.2.1-~~), + librust-proxmox-sys-0.3+default-dev, + librust-proxmox-sys-0.3+logrotate-dev, + librust-proxmox-sys-0.3+sortable-macro-dev, librust-proxmox-tfa-2+api-dev, librust-proxmox-tfa-2+api-types-dev, librust-proxmox-tfa-2+default-dev, @@ -74,7 +75,7 @@ Build-Depends: debhelper (>= 12), librust-pxar-0.10+default-dev (>= 0.10.1-~~), librust-pxar-0.10+tokio-io-dev (>= 0.10.1-~~), librust-regex-1+default-dev (>= 1.5.5-~~), - librust-rustyline-7+default-dev, + librust-rustyline-9+default-dev, librust-serde-1+default-dev, librust-serde-1+derive-dev, librust-serde-cbor-0.11+default-dev (>= 0.11.1-~~), diff --git a/pbs-client/Cargo.toml b/pbs-client/Cargo.toml index 65f36419..5b746b8f 100644 --- a/pbs-client/Cargo.toml +++ b/pbs-client/Cargo.toml @@ -16,12 +16,12 @@ http = "0.2" hyper = { version = "0.14", features = [ "full" ] } lazy_static = "1.4" libc = "0.2" -nix = "0.19.1" +nix = "0.24" openssl = "0.10" percent-encoding = "2.1" pin-project-lite = "0.2" regex = "1.5" -rustyline = "7" +rustyline = "9" serde = "1.0" serde_json = "1.0" tokio = { version = "1.6", features = [ "fs", "signal" ] } @@ -41,7 +41,7 @@ proxmox-lang = "1.1" proxmox-router = { version = "1.2", features = [ "cli" ] } proxmox-schema = "1.3.1" proxmox-time = "1" -proxmox-sys = "0.2" +proxmox-sys = "0.3" pxar = { version = "0.10.1", features = [ "tokio-io" ] } diff --git a/pbs-client/src/pxar/create.rs b/pbs-client/src/pxar/create.rs index c055107e..d58bab20 100644 --- a/pbs-client/src/pxar/create.rs +++ b/pbs-client/src/pxar/create.rs @@ -329,13 +329,13 @@ impl Archiver { Mode::empty(), ) { Ok(fd) => Ok(Some(fd)), - Err(nix::Error::Sys(Errno::ENOENT)) => { + Err(Errno::ENOENT) => { if existed { self.report_vanished_file()?; } Ok(None) } - Err(nix::Error::Sys(Errno::EACCES)) => { + Err(Errno::EACCES) => { writeln!( self.errors, "failed to open file: {:?}: access denied", @@ -343,7 +343,7 @@ impl Archiver { )?; Ok(None) } - Err(nix::Error::Sys(Errno::EPERM)) if !noatime.is_empty() => { + Err(Errno::EPERM) if !noatime.is_empty() => { // Retry without O_NOATIME: noatime = OFlag::empty(); continue; @@ -899,7 +899,7 @@ fn get_chattr(metadata: &mut Metadata, fd: RawFd) -> Result<(), Error> { match unsafe { fs::read_attr_fd(fd, &mut attr) } { Ok(_) => (), - Err(nix::Error::Sys(errno)) if errno_is_unsupported(errno) => { + Err(errno) if errno_is_unsupported(errno) => { return Ok(()); } Err(err) => bail!("failed to read file attributes: {}", err), @@ -921,7 +921,7 @@ fn get_fat_attr(metadata: &mut Metadata, fd: RawFd, fs_magic: i64) -> Result<(), match unsafe { fs::read_fat_attr_fd(fd, &mut attr) } { Ok(_) => (), - Err(nix::Error::Sys(errno)) if errno_is_unsupported(errno) => { + Err(errno) if errno_is_unsupported(errno) => { return Ok(()); } Err(err) => bail!("failed to read fat attributes: {}", err), @@ -959,10 +959,7 @@ fn get_quota_project_id( // On some FUSE filesystems it can happen that ioctl is not supported. // For these cases projid is set to 0 while the error is ignored. - if let Err(err) = res { - let errno = err - .as_errno() - .ok_or_else(|| format_err!("error while reading quota project id"))?; + if let Err(errno) = res { if errno_is_unsupported(errno) { return Ok(()); } else { diff --git a/pbs-client/src/pxar/extract.rs b/pbs-client/src/pxar/extract.rs index f18fc7d4..67460352 100644 --- a/pbs-client/src/pxar/extract.rs +++ b/pbs-client/src/pxar/extract.rs @@ -428,7 +428,7 @@ impl Extractor { if result.seeked_last { while match nix::unistd::ftruncate(file.as_raw_fd(), size as i64) { Ok(_) => false, - Err(nix::Error::Sys(errno)) if errno == nix::errno::Errno::EINTR => true, + Err(errno) if errno == nix::errno::Errno::EINTR => true, Err(err) => bail!("error setting file size: {}", err), } {} } @@ -485,7 +485,7 @@ impl Extractor { if result.seeked_last { while match nix::unistd::ftruncate(file.as_raw_fd(), size as i64) { Ok(_) => false, - Err(nix::Error::Sys(errno)) if errno == nix::errno::Errno::EINTR => true, + Err(errno) if errno == nix::errno::Errno::EINTR => true, Err(err) => bail!("error setting file size: {}", err), } {} } diff --git a/pbs-client/src/pxar/metadata.rs b/pbs-client/src/pxar/metadata.rs index 8dba06da..415922ef 100644 --- a/pbs-client/src/pxar/metadata.rs +++ b/pbs-client/src/pxar/metadata.rs @@ -372,7 +372,7 @@ fn apply_chattr(fd: RawFd, chattr: libc::c_long, mask: libc::c_long) -> Result<( let mut fattr: libc::c_long = 0; match unsafe { fs::read_attr_fd(fd, &mut fattr) } { Ok(_) => (), - Err(nix::Error::Sys(errno)) if errno_is_unsupported(errno) => { + Err(errno) if errno_is_unsupported(errno) => { return Ok(()); } Err(err) => bail!("failed to read file attributes: {}", err), @@ -386,7 +386,7 @@ fn apply_chattr(fd: RawFd, chattr: libc::c_long, mask: libc::c_long) -> Result<( match unsafe { fs::write_attr_fd(fd, &attr) } { Ok(_) => Ok(()), - Err(nix::Error::Sys(errno)) if errno_is_unsupported(errno) => Ok(()), + Err(errno) if errno_is_unsupported(errno) => Ok(()), Err(err) => bail!("failed to set file attributes: {}", err), } } @@ -400,7 +400,7 @@ fn apply_flags(flags: Flags, fd: RawFd, entry_flags: u64) -> Result<(), Error> { if fatattr != 0 { match unsafe { fs::write_fat_attr_fd(fd, &fatattr) } { Ok(_) => (), - Err(nix::Error::Sys(errno)) if errno_is_unsupported(errno) => (), + Err(errno) if errno_is_unsupported(errno) => (), Err(err) => bail!("failed to set file FAT attributes: {}", err), } } diff --git a/pbs-client/src/vsock_client.rs b/pbs-client/src/vsock_client.rs index 07e9125a..57a46d57 100644 --- a/pbs-client/src/vsock_client.rs +++ b/pbs-client/src/vsock_client.rs @@ -72,7 +72,7 @@ impl tower_service::Service for VsockConnector { )?; let sock_addr = VsockAddr::new(cid, port as u32); - connect(sock_fd, &SockAddr::Vsock(sock_addr))?; + connect(sock_fd, &sock_addr)?; // connect sync, but set nonblock after (tokio requires it) let std_stream = unsafe { std::os::unix::net::UnixStream::from_raw_fd(sock_fd) }; diff --git a/pbs-config/Cargo.toml b/pbs-config/Cargo.toml index 1e43bd9f..9af1144c 100644 --- a/pbs-config/Cargo.toml +++ b/pbs-config/Cargo.toml @@ -10,7 +10,7 @@ anyhow = "1.0" hex = "0.4.3" lazy_static = "1.4" libc = "0.2" -nix = "0.19.1" +nix = "0.24" once_cell = "1.3.1" openssl = "0.10" regex = "1.5" @@ -24,7 +24,7 @@ proxmox-section-config = "1" proxmox-time = "1" proxmox-serde = "0.1" proxmox-shared-memory = "0.2" -proxmox-sys = "0.2" +proxmox-sys = "0.3" pbs-api-types = { path = "../pbs-api-types" } pbs-buildcfg = { path = "../pbs-buildcfg" } diff --git a/pbs-config/src/acl.rs b/pbs-config/src/acl.rs index 61cdc12e..47a0852e 100644 --- a/pbs-config/src/acl.rs +++ b/pbs-config/src/acl.rs @@ -667,7 +667,7 @@ pub fn cached_config() -> Result, Error> { let stat = match nix::sys::stat::stat(ACL_CFG_FILENAME) { Ok(stat) => Some(stat), - Err(nix::Error::Sys(nix::errno::Errno::ENOENT)) => None, + Err(nix::errno::Errno::ENOENT) => None, Err(err) => bail!("unable to stat '{}' - {}", ACL_CFG_FILENAME, err), }; diff --git a/pbs-config/src/user.rs b/pbs-config/src/user.rs index 523abb96..1400914b 100644 --- a/pbs-config/src/user.rs +++ b/pbs-config/src/user.rs @@ -90,7 +90,7 @@ pub fn cached_config() -> Result, Error> { let stat = match nix::sys::stat::stat(USER_CFG_FILENAME) { Ok(stat) => Some(stat), - Err(nix::Error::Sys(nix::errno::Errno::ENOENT)) => None, + Err(nix::errno::Errno::ENOENT) => None, Err(err) => bail!("unable to stat '{}' - {}", USER_CFG_FILENAME, err), }; diff --git a/pbs-datastore/Cargo.toml b/pbs-datastore/Cargo.toml index 4adf56c1..03818433 100644 --- a/pbs-datastore/Cargo.toml +++ b/pbs-datastore/Cargo.toml @@ -15,7 +15,7 @@ hex = { version = "0.4.3", features = [ "serde" ] } lazy_static = "1.4" libc = "0.2" log = "0.4.17" -nix = "0.19.1" +nix = "0.24" openssl = "0.10" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" @@ -32,7 +32,7 @@ proxmox-lang = "1.1" proxmox-schema = { version = "1.3.1", features = [ "api-macro" ] } proxmox-time = "1" proxmox-uuid = "1" -proxmox-sys = "0.2" +proxmox-sys = "0.3" pbs-api-types = { path = "../pbs-api-types" } pbs-buildcfg = { path = "../pbs-buildcfg" } diff --git a/pbs-datastore/src/backup_info.rs b/pbs-datastore/src/backup_info.rs index 7fddc716..10320a35 100644 --- a/pbs-datastore/src/backup_info.rs +++ b/pbs-datastore/src/backup_info.rs @@ -147,7 +147,7 @@ impl BackupGroup { /* close else this leaks! */ nix::unistd::close(rawfd)?; } - Err(nix::Error::Sys(nix::errno::Errno::ENOENT)) => { + Err(nix::errno::Errno::ENOENT) => { return Ok(()); } Err(err) => { diff --git a/pbs-datastore/src/chunk_store.rs b/pbs-datastore/src/chunk_store.rs index 5bfe9fac..c142c05a 100644 --- a/pbs-datastore/src/chunk_store.rs +++ b/pbs-datastore/src/chunk_store.rs @@ -221,7 +221,7 @@ impl ChunkStore { })?; if let Err(err) = res { - if !assert_exists && err.as_errno() == Some(nix::errno::Errno::ENOENT) { + if !assert_exists && err == nix::errno::Errno::ENOENT { return Ok(false); } bail!("update atime failed for chunk/file {path:?} - {err}"); @@ -304,7 +304,7 @@ impl ChunkStore { // start reading: continue; } - Err(ref err) if err.as_errno() == Some(nix::errno::Errno::ENOENT) => { + Err(ref err) if err == &nix::errno::Errno::ENOENT => { // non-existing directories are okay, just keep going: continue; } diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs index ef21cad0..8bf09ca2 100644 --- a/pbs-datastore/src/datastore.rs +++ b/pbs-datastore/src/datastore.rs @@ -433,7 +433,7 @@ impl DataStore { ty_dir.push(ty.to_string()); // best effort only, but we probably should log the error if let Err(err) = unlinkat(Some(base_fd), &ty_dir, UnlinkatFlags::RemoveDir) { - if err.as_errno() != Some(nix::errno::Errno::ENOENT) { + if err != nix::errno::Errno::ENOENT { log::error!("failed to remove backup type {ty} in {ns} - {err}"); } } @@ -483,10 +483,10 @@ impl DataStore { if !ns.is_root() { match unlinkat(Some(base_fd), &ns.path(), UnlinkatFlags::RemoveDir) { Ok(()) => log::debug!("removed namespace {ns}"), - Err(nix::Error::Sys(nix::errno::Errno::ENOENT)) => { + Err(nix::errno::Errno::ENOENT) => { log::debug!("namespace {ns} already removed") } - Err(nix::Error::Sys(nix::errno::Errno::ENOTEMPTY)) if !delete_groups => { + Err(nix::errno::Errno::ENOTEMPTY) if !delete_groups => { removed_all_requested = false; log::debug!("skip removal of non-empty namespace {ns}") } diff --git a/pbs-datastore/src/hierarchy.rs b/pbs-datastore/src/hierarchy.rs index 670f0546..a5cc8f13 100644 --- a/pbs-datastore/src/hierarchy.rs +++ b/pbs-datastore/src/hierarchy.rs @@ -196,7 +196,7 @@ impl Iterator for ListNamespaces { let ns_dirfd = match proxmox_sys::fs::read_subdir(libc::AT_FDCWD, &base_path) { Ok(dirfd) => dirfd, - Err(nix::Error::Sys(nix::errno::Errno::ENOENT)) => return None, + Err(nix::errno::Errno::ENOENT) => return None, Err(err) => return Some(Err(err.into())), }; // found a ns directory, descend into it to scan all it's namespaces diff --git a/pbs-fuse-loop/Cargo.toml b/pbs-fuse-loop/Cargo.toml index b6ed46da..6adbea89 100644 --- a/pbs-fuse-loop/Cargo.toml +++ b/pbs-fuse-loop/Cargo.toml @@ -10,10 +10,10 @@ anyhow = "1.0" futures = "0.3" lazy_static = "1.4" libc = "0.2" -nix = "0.19.1" +nix = "0.24" regex = "1.5" tokio = { version = "1.6", features = [] } proxmox-time = "1" proxmox-fuse = "0.1.1" -proxmox-sys = "0.2" \ No newline at end of file +proxmox-sys = "0.3" \ No newline at end of file diff --git a/pbs-fuse-loop/src/fuse_loop.rs b/pbs-fuse-loop/src/fuse_loop.rs index 966e532b..c92a5390 100644 --- a/pbs-fuse-loop/src/fuse_loop.rs +++ b/pbs-fuse-loop/src/fuse_loop.rs @@ -330,7 +330,7 @@ fn unmap_from_backing(backing_file: &Path, loopdev: Option<&str>) -> Result<(), // send SIGINT to trigger cleanup and exit in target process match signal::kill(pid, Signal::SIGINT) { Ok(()) => {} - Err(nix::Error::Sys(nix::errno::Errno::ESRCH)) => { + Err(nix::errno::Errno::ESRCH) => { emerg_cleanup(loopdev, backing_file.to_owned()); return Ok(()); } @@ -348,7 +348,7 @@ fn unmap_from_backing(backing_file: &Path, loopdev: Option<&str>) -> Result<(), } std::thread::sleep(std::time::Duration::from_millis(100)); } - Err(nix::Error::Sys(nix::errno::Errno::ESRCH)) => { + Err(nix::errno::Errno::ESRCH) => { break; } Err(e) => return Err(e.into()), diff --git a/pbs-tape/Cargo.toml b/pbs-tape/Cargo.toml index 3906f25a..511c6bbe 100644 --- a/pbs-tape/Cargo.toml +++ b/pbs-tape/Cargo.toml @@ -12,7 +12,7 @@ anyhow = "1.0" thiserror = "1.0" endian_trait = { version = "0.6", features = ["arrays"] } hex = "0.4.3" -nix = "0.19.1" +nix = "0.24" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" bitflags = "1.2.1" @@ -28,7 +28,7 @@ proxmox-uuid = "1" # router::cli is only used by binaries, so maybe we should split them out proxmox-router = "1.2" -proxmox-sys = "0.2" +proxmox-sys = "0.3" pbs-api-types = { path = "../pbs-api-types" } pbs-config = { path = "../pbs-config" } diff --git a/pbs-tape/src/sgutils2.rs b/pbs-tape/src/sgutils2.rs index 9c0ca723..c405f0df 100644 --- a/pbs-tape/src/sgutils2.rs +++ b/pbs-tape/src/sgutils2.rs @@ -442,7 +442,7 @@ impl<'a, F: AsRawFd> SgRaw<'a, F> { SCSI_PT_DO_TIMEOUT => return Err(format_err!("do_scsi_pt failed - timeout").into()), code if code < 0 => { let errno = unsafe { get_scsi_pt_os_err(ptvp.as_ptr()) }; - let err = nix::Error::from_errno(nix::errno::Errno::from_i32(errno)); + let err = nix::errno::Errno::from_i32(errno); return Err(format_err!("do_scsi_pt failed with err {}", err).into()); } unknown => { @@ -524,7 +524,7 @@ impl<'a, F: AsRawFd> SgRaw<'a, F> { } SCSI_PT_RESULT_OS_ERR => { let errno = unsafe { get_scsi_pt_os_err(ptvp.as_ptr()) }; - let err = nix::Error::from_errno(nix::errno::Errno::from_i32(errno)); + let err = nix::errno::Errno::from_i32(errno); return Err(format_err!("scsi command failed with err {}", err).into()); } unknown => { diff --git a/pbs-tools/Cargo.toml b/pbs-tools/Cargo.toml index db93b024..2a62d6da 100644 --- a/pbs-tools/Cargo.toml +++ b/pbs-tools/Cargo.toml @@ -19,7 +19,7 @@ hex = "0.4.3" lazy_static = "1.4" libc = "0.2" log = "0.4.17" -nix = "0.19.1" +nix = "0.24" nom = "5.1" openssl = "0.10" percent-encoding = "2.1" @@ -38,7 +38,7 @@ proxmox-borrow = "1" proxmox-io = { version = "1", features = [ "tokio" ] } proxmox-lang = { version = "1.1" } proxmox-time = { version = "1" } -proxmox-sys = "0.2" +proxmox-sys = "0.3" pbs-buildcfg = { path = "../pbs-buildcfg" } pbs-api-types = { path = "../pbs-api-types" } diff --git a/proxmox-backup-banner/Cargo.toml b/proxmox-backup-banner/Cargo.toml index 5c9f52d1..23ecb98e 100644 --- a/proxmox-backup-banner/Cargo.toml +++ b/proxmox-backup-banner/Cargo.toml @@ -5,4 +5,5 @@ authors = ["Proxmox Support Team "] edition = "2018" [dependencies] -nix = "0.19.1" +anyhow = "1" +nix = "0.24" diff --git a/proxmox-backup-banner/src/main.rs b/proxmox-backup-banner/src/main.rs index 564b2f7f..ad6ccd0e 100644 --- a/proxmox-backup-banner/src/main.rs +++ b/proxmox-backup-banner/src/main.rs @@ -1,12 +1,29 @@ +use anyhow::{format_err, Error}; + use std::fmt::Write; use std::fs; use std::net::ToSocketAddrs; +use std::os::unix::prelude::OsStrExt; use nix::sys::utsname::uname; +fn nodename() -> Result { + let uname = uname().map_err(|err| format_err!("uname() failed - {err}"))?; // save on stack to avoid to_owned() allocation below + std::str::from_utf8(uname.nodename().as_bytes())? + .split('.') + .next() + .ok_or_else(|| format_err!("Failed to split FQDN to get hostname")) + .map(|s| s.to_owned()) +} + fn main() { - let uname = uname(); // save on stack to avoid to_owned() allocation below - let nodename = uname.nodename().split('.').next().unwrap(); + let nodename = match nodename() { + Ok(value) => value, + Err(err) => { + eprintln!("Failed to retrieve hostname: {err}"); + "INVALID".to_string() + } + }; let addr = format!("{}:8007", nodename); diff --git a/proxmox-backup-client/Cargo.toml b/proxmox-backup-client/Cargo.toml index 961c10e9..5142719d 100644 --- a/proxmox-backup-client/Cargo.toml +++ b/proxmox-backup-client/Cargo.toml @@ -9,7 +9,7 @@ anyhow = "1.0" futures = "0.3" hyper = { version = "0.14", features = [ "full" ] } libc = "0.2" -nix = "0.19.1" +nix = "0.24" openssl = "0.10" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" @@ -27,7 +27,7 @@ proxmox-io = "1.0.1" proxmox-router = { version = "1.2", features = [ "cli" ] } proxmox-schema = { version = "1.3.1", features = [ "api-macro" ] } proxmox-time = "1" -proxmox-sys = { version = "0.2.1", features = [ "sortable-macro" ] } +proxmox-sys = { version = "0.3", features = [ "sortable-macro" ] } pbs-api-types = { path = "../pbs-api-types" } pbs-buildcfg = { path = "../pbs-buildcfg" } diff --git a/proxmox-file-restore/Cargo.toml b/proxmox-file-restore/Cargo.toml index 81eb7299..de719b46 100644 --- a/proxmox-file-restore/Cargo.toml +++ b/proxmox-file-restore/Cargo.toml @@ -9,7 +9,7 @@ anyhow = "1.0" base64 = "0.13" futures = "0.3" libc = "0.2" -nix = "0.19.1" +nix = "0.24" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" tokio = { version = "1.6", features = [ "io-std", "rt", "rt-multi-thread", "time" ] } @@ -23,7 +23,7 @@ proxmox-router = { version = "1.2", features = [ "cli" ] } proxmox-schema = { version = "1.3.1", features = [ "api-macro" ] } proxmox-time = "1" proxmox-uuid = "1" -proxmox-sys = "0.2" +proxmox-sys = "0.3" pbs-api-types = { path = "../pbs-api-types" } pbs-buildcfg = { path = "../pbs-buildcfg" } diff --git a/proxmox-rest-server/Cargo.toml b/proxmox-rest-server/Cargo.toml index a182bf04..528270f7 100644 --- a/proxmox-rest-server/Cargo.toml +++ b/proxmox-rest-server/Cargo.toml @@ -19,7 +19,7 @@ hyper = { version = "0.14.5", features = [ "full" ] } lazy_static = "1.4" libc = "0.2" log = "0.4.17" -nix = "0.19.1" +nix = "0.24" once_cell = "1.3.1" percent-encoding = "2.1" regex = "1.5" @@ -40,4 +40,4 @@ proxmox-http = { version = "0.6", features = [ "client" ] } proxmox-router = "1.2" proxmox-schema = { version = "1.3.1", features = [ "api-macro", "upid-api-impl" ] } proxmox-time = "1" -proxmox-sys = "0.2" +proxmox-sys = { version = "0.3", features = [ "logrotate" ] } diff --git a/proxmox-restore-daemon/Cargo.toml b/proxmox-restore-daemon/Cargo.toml index 4cdbadb6..ff67331e 100644 --- a/proxmox-restore-daemon/Cargo.toml +++ b/proxmox-restore-daemon/Cargo.toml @@ -15,7 +15,7 @@ hyper = { version = "0.14", features = [ "full" ] } lazy_static = "1.4" libc = "0.2" log = "0.4.17" -nix = "0.19.1" +nix = "0.24" regex = "1.5" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" @@ -31,7 +31,7 @@ proxmox-compression = "0.1.1" proxmox-router = { version = "1.2", features = [ "cli" ] } proxmox-schema = { version = "1.3.1", features = [ "api-macro" ] } proxmox-time = "1" -proxmox-sys = { version = "0.2", features = [ "sortable-macro" ] } +proxmox-sys = { version = "0.3", features = [ "sortable-macro" ] } pbs-api-types = { path = "../pbs-api-types" } pbs-tools = { path = "../pbs-tools" } diff --git a/proxmox-restore-daemon/src/main.rs b/proxmox-restore-daemon/src/main.rs index 03eb2344..b2c809fa 100644 --- a/proxmox-restore-daemon/src/main.rs +++ b/proxmox-restore-daemon/src/main.rs @@ -171,7 +171,7 @@ fn get_vsock_fd() -> Result { None, )?; let sock_addr = VsockAddr::new(libc::VMADDR_CID_ANY, DEFAULT_VSOCK_PORT as u32); - bind(sock_fd, &SockAddr::Vsock(sock_addr))?; + bind(sock_fd, &sock_addr)?; listen(sock_fd, MAX_PENDING)?; Ok(sock_fd) } diff --git a/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs b/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs index 9aa849ac..1957b143 100644 --- a/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs +++ b/proxmox-restore-daemon/src/proxmox_restore_daemon/disk.rs @@ -336,8 +336,8 @@ impl Filesystems { info!("mounting '{}' succeeded, fstype: '{}'", source, fs); return Ok(()); } - Err(nix::Error::Sys(nix::errno::Errno::EINVAL)) => {} - Err(nix::Error::Sys(nix::errno::Errno::EBUSY)) => return Ok(()), + Err(nix::errno::Errno::EINVAL) => {} + Err(nix::errno::Errno::EBUSY) => return Ok(()), Err(err) => { warn!("mount error on '{}' ({}) - {}", source, fs, err); } diff --git a/proxmox-rrd/Cargo.toml b/proxmox-rrd/Cargo.toml index 93af86b5..b9ef4ee4 100644 --- a/proxmox-rrd/Cargo.toml +++ b/proxmox-rrd/Cargo.toml @@ -14,7 +14,7 @@ bitflags = "1.2.1" crossbeam-channel = "0.5" libc = "0.2" log = "0.4.17" -nix = "0.19.1" +nix = "0.24" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" serde_cbor = "0.11.1" @@ -22,4 +22,4 @@ serde_cbor = "0.11.1" #proxmox = { version = "0.15.3" } proxmox-time = "1" proxmox-schema = { version = "1.3.1", features = [ "api-macro" ] } -proxmox-sys = "0.2" \ No newline at end of file +proxmox-sys = "0.3" \ No newline at end of file diff --git a/pxar-bin/Cargo.toml b/pxar-bin/Cargo.toml index 5773d96f..a5ecb039 100644 --- a/pxar-bin/Cargo.toml +++ b/pxar-bin/Cargo.toml @@ -11,7 +11,7 @@ path = "src/main.rs" [dependencies] anyhow = "1.0" futures = "0.3" -nix = "0.19.1" +nix = "0.24" serde_json = "1.0" tokio = { version = "1.6", features = [ "rt", "rt-multi-thread" ] } @@ -20,7 +20,7 @@ pathpatterns = "0.1.2" proxmox-async = "0.4" proxmox-schema = { version = "1.3.1", features = [ "api-macro" ] } proxmox-router = "1.2" -proxmox-sys = "0.2" +proxmox-sys = "0.3" pxar = { version = "0.10.1", features = [ "tokio-io" ] } pbs-client = { path = "../pbs-client" } diff --git a/src/api2/node/apt.rs b/src/api2/node/apt.rs index 28c38470..0267e103 100644 --- a/src/api2/node/apt.rs +++ b/src/api2/node/apt.rs @@ -1,6 +1,7 @@ use anyhow::{bail, format_err, Error}; use serde_json::{json, Value}; use std::collections::HashMap; +use std::os::unix::prelude::OsStrExt; use proxmox_router::{ list_subdirs_api_method, Permission, Router, RpcEnvironment, RpcEnvironmentType, SubdirMap, @@ -360,7 +361,7 @@ pub fn get_versions() -> Result, Error> { let running_kernel = format!( "running kernel: {}", - nix::sys::utsname::uname().release().to_owned() + std::str::from_utf8(nix::sys::utsname::uname()?.release().as_bytes())?.to_owned() ); if let Some(proxmox_backup) = pbs_packages .iter() diff --git a/src/api2/node/status.rs b/src/api2/node/status.rs index da394625..b76aa0b7 100644 --- a/src/api2/node/status.rs +++ b/src/api2/node/status.rs @@ -1,5 +1,5 @@ -use std::path::Path; use std::process::Command; +use std::{os::unix::prelude::OsStrExt, path::Path}; use anyhow::{bail, format_err, Error}; use serde_json::Value; @@ -69,12 +69,12 @@ fn get_status( let cpuinfo = procfs::read_cpuinfo()?; let cpuinfo = cpuinfo.into(); - let uname = nix::sys::utsname::uname(); + let uname = nix::sys::utsname::uname()?; let kversion = format!( "{} {} {}", - uname.sysname(), - uname.release(), - uname.version() + std::str::from_utf8(uname.sysname().as_bytes())?, + std::str::from_utf8(uname.release().as_bytes())?, + std::str::from_utf8(uname.version().as_bytes())? ); Ok(NodeStatus { diff --git a/src/config/mod.rs b/src/config/mod.rs index a3e184e0..e86802ab 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -60,7 +60,7 @@ pub fn create_configdir() -> Result<(), Error> { match nix::unistd::mkdir(cfgdir, Mode::from_bits_truncate(0o700)) { Ok(()) => {} - Err(nix::Error::Sys(nix::errno::Errno::EEXIST)) => { + Err(nix::errno::Errno::EEXIST) => { check_configdir_permissions()?; return Ok(()); } diff --git a/src/tools/subscription.rs b/src/tools/subscription.rs index 94a62675..01a9a70e 100644 --- a/src/tools/subscription.rs +++ b/src/tools/subscription.rs @@ -382,7 +382,7 @@ pub fn update_apt_auth(key: Option, password: Option) -> Result< } _ => match nix::unistd::unlink(auth_conf) { Ok(()) => Ok(()), - Err(nix::Error::Sys(nix::errno::Errno::ENOENT)) => Ok(()), // ignore not existing + Err(nix::errno::Errno::ENOENT) => Ok(()), // ignore not existing Err(err) => Err(err), } .map_err(|e| format_err!("Error clearing apt auth config - {}", e))?,