Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   CentOS (http://www.linux-archive.org/centos/)
-   -   Bug in dhclient-script for ntp.conf in Centos 5? (http://www.linux-archive.org/centos/108338-bug-dhclient-script-ntp-conf-centos-5-a.html)

Stephen Harris 06-17-2008 02:19 PM

Bug in dhclient-script for ntp.conf in Centos 5?
 
I dunno if this is upstream or not since I don't have any RHEL5

% rpm -qf /sbin/dhclient-script
dhclient-3.0.5-7.el5

This section of code appears to have a bug (around line 411)

elif [ -n "$new_ntp_servers" ] && [ -e /etc/ntp.conf ]; then
save_previous /etc/ntp.conf
/bin/egrep -v '(^[ ]*(server|fudge))|(generated by /sbin/dhclient-script)'< /etc/ntp.conf.predhclient > /etc/ntp.conf
echo '# servers generated by /sbin/dhclient-script' >> /etc/ntp.conf
localClocks=(`/bin/egrep '^[ ]*server[ ]+127.127' /etc/ntp.conf.predhclient | while read s addr rest; do echo $addr; done`)
localClockFudge="`/bin/egrep '^[ ]*fudge[ ]+127.127' /etc/ntp.conf.predhclient`";
for s in $new_ntp_servers ${localClocks[@]};
do
echo 'server '$s >> /etc/ntp.conf;
done
echo "$localClockFudge" >> /etc/ntp.conf;
if [ -x /usr/bin/diff ] && /usr/bin/diff -q /etc/ntp.conf /etc/ntp.conf.predhclient >/dev/null 2>&1; then
: ;
else
/sbin/service ntpd condrestart >/dev/null 2>&1
fi;
fi
fi;


The problem is that if there are no "fudge' lines in the existing ntp.conf
then localClockFudge will be empty, and this will cause a blank line
to be appended to the end of the new ntp.conf; diff will then think the
file has changed and so ntpd will be restarted. Over time a large
number of blank lines will be prepended to the ntp.conf because of the
initial egrep statement.


--

rgds
Stephen
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos


All times are GMT. The time now is 05:45 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.