[CentOS] Bug in dhclient-script for ntp.conf in Centos 5?

Stephen Harris lists at spuddy.org
Tue Jun 17 14:19:49 UTC 2008


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



More information about the CentOS mailing list