bea67c799a
Signed-off-by: Gris Ge <fge@redhat.com>
72 lines
2.4 KiB
Diff
72 lines
2.4 KiB
Diff
From f9d3f0cdcabfa18d465068508d7b69b2a65823bc Mon Sep 17 00:00:00 2001
|
|
From: Gris Ge <fge@redhat.com>
|
|
Date: Thu, 23 Mar 2023 21:35:08 +0800
|
|
Subject: [PATCH] dependency: Upgrade to nix 0.26 and env_logger 0.10
|
|
|
|
Signed-off-by: Gris Ge <fge@redhat.com>
|
|
---
|
|
rust/src/cli/Cargo.toml | 2 +-
|
|
rust/src/lib/Cargo.toml | 2 +-
|
|
rust/src/lib/nispor/hostname.rs | 14 +++++++++-----
|
|
3 files changed, 11 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/rust/src/cli/Cargo.toml b/rust/src/cli/Cargo.toml
|
|
index 350c9fcc..2902804a 100644
|
|
--- a/rust/src/cli/Cargo.toml
|
|
+++ b/rust/src/cli/Cargo.toml
|
|
@@ -21,7 +21,7 @@ nmstate = {path = "../lib", version = "2.2", default-features = false}
|
|
serde_yaml = "0.9"
|
|
clap = { version = "3.1", features = ["cargo"] }
|
|
serde = { version = "1.0", features = ["derive"] }
|
|
-env_logger = "0.9.0"
|
|
+env_logger = "0.10.0"
|
|
log = "0.4.14"
|
|
serde_json = "1.0.75"
|
|
ctrlc = { version = "3.2.1", optional = true }
|
|
diff --git a/rust/src/lib/Cargo.toml b/rust/src/lib/Cargo.toml
|
|
index 721fe6a3..4a6b6b3e 100644
|
|
--- a/rust/src/lib/Cargo.toml
|
|
+++ b/rust/src/lib/Cargo.toml
|
|
@@ -55,7 +55,7 @@ default-features = false
|
|
features = ["derive"]
|
|
|
|
[dependencies.nix]
|
|
-version = "0.24.1"
|
|
+version = "0.26.0"
|
|
optional = true
|
|
default-features = false
|
|
features = ["feature", "hostname"]
|
|
diff --git a/rust/src/lib/nispor/hostname.rs b/rust/src/lib/nispor/hostname.rs
|
|
index 517bf7c7..5e9f1ba8 100644
|
|
--- a/rust/src/lib/nispor/hostname.rs
|
|
+++ b/rust/src/lib/nispor/hostname.rs
|
|
@@ -1,3 +1,5 @@
|
|
+// SPDX-License-Identifier: Apache-2.0
|
|
+
|
|
use std::io::Read;
|
|
|
|
use crate::{ErrorKind, HostNameState, NmstateError};
|
|
@@ -5,12 +7,14 @@ use crate::{ErrorKind, HostNameState, NmstateError};
|
|
const HOST_NAME_MAX: usize = 64;
|
|
|
|
pub(crate) fn get_hostname_state() -> Option<HostNameState> {
|
|
- let mut buffer = [0u8; HOST_NAME_MAX];
|
|
- let running = match nix::unistd::gethostname(&mut buffer) {
|
|
+ let running = match nix::unistd::gethostname() {
|
|
Ok(hostname_cstr) => match hostname_cstr.to_str() {
|
|
- Ok(h) => Some(h.to_string()),
|
|
- Err(e) => {
|
|
- log::error!("Failed to convert hostname to String: {}", e);
|
|
+ Some(h) => Some(h.to_string()),
|
|
+ None => {
|
|
+ log::error!(
|
|
+ "Failed to convert hostname from OsString \
|
|
+ to String: {hostname_cstr:?}"
|
|
+ );
|
|
None
|
|
}
|
|
},
|
|
--
|
|
2.40.0
|
|
|