36 lines
1.3 KiB
Diff
36 lines
1.3 KiB
Diff
From b2482a4f7d9a06a9c10a26eb1fb2b855d83e94c7 Mon Sep 17 00:00:00 2001
|
|
From: Christian Hesse <mail@eworm.de>
|
|
Date: Thu, 4 Aug 2022 12:15:46 +0200
|
|
Subject: [PATCH] [!99] replace `hostname` with `uname -n` & `sysctl`
|
|
|
|
The former belongs to package `inetutils`, which has some security
|
|
implications, so let's use `uname` from `coreutils` to get the hostname.
|
|
|
|
For *setting* the hostname things are more limited. Let's use `sysctl`.
|
|
---
|
|
client/scripts/linux | 4 ++--
|
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/client/scripts/linux b/client/scripts/linux
|
|
index c4e51f6d..fe4da445 100755
|
|
--- a/client/scripts/linux
|
|
+++ b/client/scripts/linux
|
|
@@ -113,7 +113,7 @@ set_hostname() {
|
|
local current_hostname
|
|
|
|
if [ -n "$new_host_name" ]; then
|
|
- current_hostname=$(hostname)
|
|
+ current_hostname=$(uname -n)
|
|
|
|
# current host name is empty, '(none)' or 'localhost' or differs from new one from DHCP
|
|
if [ -z "$current_hostname" ] ||
|
|
@@ -121,7 +121,7 @@ set_hostname() {
|
|
[ "$current_hostname" = 'localhost' ] ||
|
|
[ "$current_hostname" = "$old_host_name" ]; then
|
|
if [ "$new_host_name" != "$old_host_name" ]; then
|
|
- hostname "$new_host_name"
|
|
+ sysctl -w kernel/hostname="$new_host_name"
|
|
fi
|
|
fi
|
|
fi
|