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