dhclient-script patch to preserve resolv.conf.save

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: patrick keshishian
Date: Wednesday, April 7, 2010 - 1:30 am

Hello,

At home I use static IPs, but when I take my laptop to work I
end up using DHCP. Typically there are no issues, however, at
work, if the link goes down, when it comes back up, the saved
resolv.conf file gets clubbered with previous DHCP-ed version
and leaves me to reconstruct my resolv.conf when I return
home and discover things in a broken state.

I believe there is no good reason for dhclient-script to
override an already existing /etc/resolv.conf.save file.
If I'm correct, the following patch[0] solves this issue.

I don't have a way to test the IPv6 edition, but I have been
running a pre 1.16 revision of this script with my patch for
a couple of weeks now.

Open to suggestions and corrections.

Thanks,
--patrick

[0]
Index: dhclient-script
===================================================================
RCS file: /cvs/obsd/src/sbin/dhclient/dhclient-script,v
retrieving revision 1.16
diff -u -p dhclient-script
--- dhclient-script	4 Apr 2010 22:53:50 -0000	1.16
+++ dhclient-script	7 Apr 2010 08:17:07 -0000
@@ -131,8 +131,10 @@ add_new_resolv_conf() {
 		# In case (e.g. during OpenBSD installs) /etc/resolv.conf
 		# is a symbolic link, take care to preserve the link and write
 		# the new data in the correct location.
+		# However, don't override an already existing
+		# /etc/resolv.conf.save file.
 
-		if [ -f /etc/resolv.conf ]; then
+		if [ -f /etc/resolv.conf -a ! -e /etc/resolv.conf.save ]; then
 			cat /etc/resolv.conf > /etc/resolv.conf.save
 		fi
 		cat /etc/resolv.conf.std > /etc/resolv.conf
@@ -172,8 +174,10 @@ ip6_add_new_resolv_conf() {
 		# In case (e.g. during OpenBSD installs) /etc/resolv.conf
 		# is a symbolic link, take care to preserve the link and write
 		# the new data in the correct location.
+		# However, don't override an already existing
+		# /etc/resolv.conf.save file.
 
-		if [ -f /etc/resolv.conf ]; then
+		if [ -f /etc/resolv.conf -a ! -e /etc/resolv.conf.save ]; then
 			cat /etc/resolv.conf > /etc/resolv.conf.save
 		fi
 		cat /etc/resolv.conf.std6 > /etc/resolv.conf
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
dhclient-script patch to preserve resolv.conf.save, patrick keshishian, (Wed Apr 7, 1:30 am)
Re: dhclient-script patch to preserve resolv.conf.save, patrick keshishian, (Wed Apr 14, 11:07 pm)
Re: dhclient-script patch to preserve resolv.conf.save, Stuart Henderson, (Thu Apr 15, 2:28 am)
Re: dhclient-script patch to preserve resolv.conf.save, patrick keshishian, (Thu Apr 15, 10:47 am)