From 513d019ac38224171acf44b07b570ce12ddff761 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 19 Jul 2021 16:32:48 +0200 Subject: [PATCH] issue banner: avoid depending on proxmox crate for hostname While this slightly duplicates code we just do not profit from the central, lazy static variant here, as that is only really useful in daemons to avoid doing frequent syscalls there. proxmox just pull in far to much (e.g., tokio) and duplicating that one line of simple code has no real maintenance cost, so just go for that and use the nix crate directly. Signed-off-by: Thomas Lamprecht --- proxmox-backup-banner/Cargo.toml | 2 +- proxmox-backup-banner/src/main.rs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/proxmox-backup-banner/Cargo.toml b/proxmox-backup-banner/Cargo.toml index a78f6a070..5c9f52d1d 100644 --- a/proxmox-backup-banner/Cargo.toml +++ b/proxmox-backup-banner/Cargo.toml @@ -5,4 +5,4 @@ authors = ["Proxmox Support Team "] edition = "2018" [dependencies] -proxmox = { version = "0.11.5", default-features = false, features = [] } +nix = "0.19.1" diff --git a/proxmox-backup-banner/src/main.rs b/proxmox-backup-banner/src/main.rs index ad9ef2590..564b2f7f0 100644 --- a/proxmox-backup-banner/src/main.rs +++ b/proxmox-backup-banner/src/main.rs @@ -2,10 +2,12 @@ use std::fmt::Write; use std::fs; use std::net::ToSocketAddrs; -use proxmox::tools; +use nix::sys::utsname::uname; fn main() { - let nodename = tools::nodename(); + let uname = uname(); // save on stack to avoid to_owned() allocation below + let nodename = uname.nodename().split('.').next().unwrap(); + let addr = format!("{}:8007", nodename); let mut banner = format!(