From 1f5dd3c82d369eb4c8e72e912479412e1e8c8c03 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 10 Aug 2024 18:52:13 +0200 Subject: [PATCH] Update to gethostname 0.5 With version 0.5, gethostname now uses rustic on unix to determine the host name. In fact, the code is exactly to identical to what we've been doing ourselves. As such, I am dropping the unix-specific implementation of this and let this just always use gethostname. Signed-off-by: Uli Schlachter --- x11rb/Cargo.toml | 6 ++---- x11rb/src/lib.rs | 13 ------------- x11rb/src/resource_manager/mod.rs | 2 +- x11rb/src/rust_connection/stream.rs | 2 +- 4 files changed, 4 insertions(+), 19 deletions(-) diff --git a/x11rb/Cargo.toml b/x11rb/Cargo.toml index b4981e30..770baa9f 100644 --- a/x11rb/Cargo.toml +++ b/x11rb/Cargo.toml @@ -22,12 +22,10 @@ once_cell = { version = "1.19", optional = true } as-raw-xcb-connection = { version = "1.0", optional = true } tracing = { version = "0.1", optional = true, default-features = false } rustix = { version = "0.38", default-features = false, features = ["std", "event", "fs", "net", "system"] } - -[target.'cfg(not(unix))'.dependencies] -gethostname = "0.4" +gethostname = "0.5" [dev-dependencies] -gethostname = "0.4" +gethostname = "0.5" polling = "3.4" tracing-subscriber = "0.3" diff --git a/x11rb/src/lib.rs b/x11rb/src/lib.rs index 98ec298e..f6afd97a 100644 --- a/x11rb/src/lib.rs +++ b/x11rb/src/lib.rs @@ -183,7 +183,6 @@ mod test; use errors::ConnectError; use protocol::xproto::{Keysym, Timestamp}; -use std::ffi::OsString; /// Establish a new connection to an X11 server. /// @@ -214,15 +213,3 @@ pub const CURRENT_TIME: Timestamp = 0; /// This constant can be used to fill unused entries in `Keysym` tables pub const NO_SYMBOL: Keysym = 0; - -#[cfg(not(unix))] -fn hostname() -> OsString { - gethostname::gethostname() -} - -#[cfg(unix)] -fn hostname() -> OsString { - use std::os::unix::ffi::OsStringExt; - - OsString::from_vec(rustix::system::uname().nodename().to_bytes().to_vec()) -} diff --git a/x11rb/src/resource_manager/mod.rs b/x11rb/src/resource_manager/mod.rs index 80f0a3fa..bc794532 100644 --- a/x11rb/src/resource_manager/mod.rs +++ b/x11rb/src/resource_manager/mod.rs @@ -64,6 +64,6 @@ pub fn new_from_resource_manager(conn: &impl Connection) -> Result Result { Ok(Database::new_from_default( &send_request(conn)?, - crate::hostname(), + gethostname::gethostname(), )) } diff --git a/x11rb/src/rust_connection/stream.rs b/x11rb/src/rust_connection/stream.rs index 1de3e7e7..b38b1c1f 100644 --- a/x11rb/src/rust_connection/stream.rs +++ b/x11rb/src/rust_connection/stream.rs @@ -549,7 +549,7 @@ mod peer_addr { // Get xauth information representing a local connection pub(super) fn local() -> PeerAddr { - let hostname = crate::hostname() + let hostname = gethostname::gethostname() .to_str() .map_or_else(Vec::new, |s| s.as_bytes().to_vec()); (Family::LOCAL, hostname)