From 7f1f5438b43ce939c6e5d4bdc30cf85ac28be6e1 Mon Sep 17 00:00:00 2001 From: Pavel Zhukov Date: Fri, 16 Jul 2021 12:04:52 +0200 Subject: [PATCH] Add fallback for hostname determination Resolves: #1952331 --- setup-hostname.patch | 58 ++++++++++++++++++++++++++++++++++++++++++++ setup.spec | 9 +++++-- 2 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 setup-hostname.patch diff --git a/setup-hostname.patch b/setup-hostname.patch new file mode 100644 index 0000000..2033a83 --- /dev/null +++ b/setup-hostname.patch @@ -0,0 +1,58 @@ +commit ddd74b5d971a734c7e88cda3764f7e059f163b51 +Author: Pavel Zhukov +Date: Wed Jul 14 11:43:39 2021 +0200 + + Add fallback to hostname determination + + Use hostname in case if hostnamectl is not available/not functional. + fallback to uname in case if both hostname and hostnamectl are + missed (in containers) + +diff --git a/profile b/profile +index 783fe17..542add4 100644 +--- a/profile ++++ b/profile +@@ -42,7 +42,10 @@ else + pathmunge /usr/sbin after + fi + +-HOSTNAME=`/usr/bin/hostnamectl --transient 2>/dev/null` ++HOSTNAME=$(/usr/bin/hostnamectl --transient 2>/dev/null) || \ ++HOSTNAME=$(/usr/bin/hostname 2>/dev/null) || \ ++HOSTNAME=$(/usr/bin/uname -n) ++ + HISTSIZE=1000 + if [ "$HISTCONTROL" = "ignorespace" ] ; then + export HISTCONTROL=ignoreboth +commit f20b64fc99267d2343aa9141cf709ac1131bc178 +Author: Pavel Zhukov +Date: Thu Jul 15 10:31:57 2021 +0200 + + Do not use hostnamectl in csh + +diff --git a/csh.cshrc b/csh.cshrc +index c3a37a3..eda4aa7 100644 +--- a/csh.cshrc ++++ b/csh.cshrc +@@ -20,7 +20,7 @@ if ($?prompt) then + # make completion work better by default + set autolist + else +- set prompt=\[$user@`/usr/bin/hostnamectl --transient | cut -d'.' -f1`\]\$\ ++ set prompt=\[$user@`/usr/bin/hostname`\]\$\ + endif + endif + +diff --git a/csh.login b/csh.login +index 2da86c9..e4b1990 100644 +--- a/csh.login ++++ b/csh.login +@@ -25,7 +25,7 @@ else + end + endif + +-setenv HOSTNAME `/usr/bin/hostnamectl --transient` ++setenv HOSTNAME `/usr/bin/hostname` + set history=1000 + + if ( -d /etc/profile.d ) then diff --git a/setup.spec b/setup.spec index e901866..e47016d 100644 --- a/setup.spec +++ b/setup.spec @@ -1,7 +1,7 @@ Summary: A set of system configuration and setup files Name: setup Version: 2.13.7 -Release: 4%{?dist} +Release: 5%{?dist} License: Public Domain Group: System Environment/Base URL: https://pagure.io/setup/ @@ -15,12 +15,14 @@ Requires: system-release Conflicts: filesystem < 3 Conflicts: initscripts < 4.26, bash <= 2.0.4-21 +Patch0: setup-hostname.patch + %description The setup package contains a set of important system configuration and setup files, such as passwd, group, and profile. %prep -%setup -q +%autosetup -p1 ./shadowconvert.sh %build @@ -116,6 +118,9 @@ end %{_tmpfilesdir}/%{name}.conf %changelog +* Fri Jul 16 2021 Pavel Zhukov - 2.13.7-5 +- Add fallback for hostname determination (#1958745) + * Fri Apr 16 2021 Mohan Boddu - 2.13.7-4 - Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937