Bad NTP in Fedora repository?

Bob Arendt rda at rincon.com
Thu Nov 20 00:12:27 UTC 2003


Mike Klinke wrote:
> 22:17:28 # rpm -Uvh ntp-4.1.2-5.i386.rpm
> Preparing...      #################### [100%]
>    1:ntp                   
>  warning: /etc/ntp.conf created as /etc/ntp.conf.rpmnew
>                     ###################### [100%]
> error: %post(ntp-4.1.2-5) scriptlet failed, exit status 1
> 
> 22:17:52 # rpm -qa | grep ntp-
> ntp-4.1.2-0.rc1.2
> ntp-4.1.2-5
> ===================================
> 
> 
> Ay! The RPM, I think she's broke cap'n!
> 
> Regards,  Mike Klinke

Good work Mike - I've repeated it here.  I ran rpm using "rpm -U -vv " to
get diagnostic output.  Excluding a lot, we see the error:

D:   install: %post(ntp-4.1.2-5) synchronous scriptlet start
D:   install: %post(ntp-4.1.2-5)        execv(/bin/sh) pid 2714
+ /sbin/chkconfig --add ntpd
+ grep /etc/ntp/drift /etc/ntp.conf
+ olddrift=0
+ '[' 2 -ge 1 -a 0 -eq 0 ']'
+ service ntpd status
+ wasrunning=3
+ '[' 3 -eq 0 ']'
+ '[' -f /etc/ntp/drift ']'
+ cp /etc/ntp/drift /var/lib/ntp/drift
+ sed -e s#/etc/ntp/drift#/var/lib/ntp/drift#g /etc/ntp.conf
+ mv /etc/ntp.conf.rpmupdate /etc/ntp.conf
+ rm -f /etc/ntp.conf.rpmupdate
+ '[' 3 -eq 0 ']'
D:   install: waitpid(2714) rc 2714 status 100
error: %post(ntp-4.1.2-5) scriptlet failed, exit status 1
D: ========== --- ntp-4.1.2-0.rc1.2 i386-linux 0x1


 From rpm -q --scripts ntp-4.1.2-5   we see:
preinstall scriptlet (using /bin/sh):
/usr/sbin/groupadd -g 38 ntp  2> /dev/null || :
/usr/sbin/useradd -u 38 -g 38 -s /sbin/nologin -M -r -d /etc/ntp ntp 2>/dev/null || :


postinstall scriptlet (using /bin/sh):
/sbin/chkconfig --add ntpd
grep /etc/ntp/drift /etc/ntp.conf > /dev/null 2>&1
olddrift=$?
if [ "$1" -ge "1" -a $olddrift -eq 0 ]; then
   service ntpd status > /dev/null 2>&1
   wasrunning=$?
   # let ntp save the actual drift
   [ $wasrunning -eq 0 ] && service ntpd stop > /dev/null 2>&1
   # copy the driftfile to the new location
   [ -f /etc/ntp/drift ] && cp /etc/ntp/drift /var/lib/ntp/drift
   # change the path in the config file
   sed -e 's#/etc/ntp/drift#/var/lib/ntp/drift#g' /etc/ntp.conf > /etc/ntp.conf.rpmupdate \
   && mv /etc/ntp.conf.rpmupdate /etc/ntp.conf
   # remove the temp file
   rm -f /etc/ntp.conf.rpmupdate
   # start ntp if it was running previously
   [ $wasrunning -eq 0 ] && service ntpd start > /dev/null 2>&1
fi

The problem is if $wasrunning is non-zero, the test status is 1, indicating failure.
(man 3 exit - success == 0 !).  The rpm packager could fix their postinstall
script by adding some trivial final line like
    echo "ntp postinstall complete"
which will result in a 0 exit status, so that rpm completes successfully.


Here's the *real* kicker - if ntpd is running, the update succeeds.
In this case:

D:   install: %post(ntp-4.1.2-5) synchronous scriptlet start
D:   install: %post(ntp-4.1.2-5)        execv(/bin/sh) pid 2895
+ /sbin/chkconfig --add ntpd
+ grep /etc/ntp/drift /etc/ntp.conf
+ olddrift=1
+ '[' 2 -ge 1 -a 1 -eq 0 ']'
D:   install: waitpid(2895) rc 2895 status 0
D: opening  db index       /var/lib/rpm/Triggername create mode=0x42
D: ========== --- ntp-4.1.2-0.rc1.2 i386-linux 0x1

% rpm -q ntp
ntp-4.1.2-5

The problem case only arises if ntpd isn't running prior to upgrade AND
a previous version was installed.

I've added this to the bugzilla.

Cheers,
-Bob Arendt






More information about the users mailing list