Add fallback for hostname determination

Resolves: #1952331
This commit is contained in:
Pavel Zhukov 2021-07-16 12:04:52 +02:00
parent 2e5a55c40c
commit 7f1f5438b4
2 changed files with 65 additions and 2 deletions

58
setup-hostname.patch Normal file
View File

@ -0,0 +1,58 @@
commit ddd74b5d971a734c7e88cda3764f7e059f163b51
Author: Pavel Zhukov <pzhukov@redhat.com>
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 <pzhukov@redhat.com>
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

View File

@ -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 <pzhukov@redhat.com> - 2.13.7-5
- Add fallback for hostname determination (#1958745)
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 2.13.7-4
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937