[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[patch] fix for missing hostname reconfiguration



Hello,

I have identified an incorrect handling of 'hostname' in the chroot that is being overwritten with a dummy one and never restored, and created a patch fixing the issue. I'm attaching the diff to this message.


Best regards

Luigi
diff --git a/helpers/lh_chroot_hostname b/helpers/lh_chroot_hostname
index 2df0aa2..7ed2147 100755
--- a/helpers/lh_chroot_hostname
+++ b/helpers/lh_chroot_hostname
@@ -41,6 +41,7 @@ case "${1}" in
 
 		# Save hostname
 		mv chroot/bin/hostname chroot/bin/hostname.orig
+		mv chroot/etc/hostname chroot/etc/hostname.orig
 
 		# Create hostname file
 		echo "localhost.localdomain" > chroot/etc/hostname
@@ -62,17 +63,27 @@ EOF
 		;;
 
 	remove)
-		Echo_message "Deconfiguring file /etc/hostname"
-
 		# Checking lock file
 		Check_lockfile .lock
 
 		# Creating lock file
 		Create_lockfile .lock
 
+		Echo_message "Deconfiguring file /etc/hostname"
+
+		if [ -e config/chroot_local-includes/etc/hostname ]
+		then
+			# Copying local hostname
+			cp -a config/chroot_local-includes/etc/hostname chroot/etc/hostname
+			rm -f chroot/etc/hostname.orig
+		elif [ -e chroot/etc/hostname.orig ]
+		then
+			mv chroot/etc/hostname.orig chroot/etc/hostname
+		fi
+
 		Echo_message "Deconfiguring file /bin/hostname"
 
-		# Restore hostname file
+		# Restore hostname files
 		if [ -e chroot/bin/hostname.orig ]
 		then
 			mv chroot/bin/hostname.orig chroot/bin/hostname

Reply to: