[Git][NTPsec/ntpsec][master] 2 commits: ntpleapfile: fix parsing of ntp.conf on osX and FreeBSD.

Gary E. Miller gitlab at mg.gitlab.com
Fri Dec 7 04:51:49 UTC 2018


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
5aa6ba4c by Gary E. Miller at 2018-12-07T04:21:02Z
ntpleapfile: fix parsing of ntp.conf on osX and FreeBSD.

Both osX and FreeBSD use a copy of sed that is not gnu sed
compatible.  So finesse.

- - - - -
7c253cb9 by Gary E. Miller at 2018-12-07T04:49:17Z
ntpleapfetch: fix for current leap file.

The last line used to be "#h\t ".  Now it is "#h \t".  Fix code
so we don't care.

- - - - -


1 changed file:

- ntpclients/ntpleapfetch


Changes:

=====================================
ntpclients/ntpleapfetch
=====================================
@@ -301,12 +301,10 @@ verifySHA1() {
     # Extract the file's hash. Restore any leading zeroes in hash segments.
 
     # The sed [] includes a tab (\t) and space; #h is followed by a tab and space
-    # The file of 8-Jul-2016 uses \r\n as line delimiters.  This must
-    # be corrected on UNIX systems, else the extra \r is read from the
-    # last line.  I am not clear if this is an error in the NIST file,
-    # or intentional.  Nevertheless - Sanjeev Gupta 20180105
+    # or maybe a space and a tab.  remove the tab, whereever it may be.  Add some 0x
+    # so it can be run throught printf to restore missing leading zeros.
     #
-    local FSHA1="`echo \"$RAW\" | sed -e's/\r//' | sed -e'/^#h/!d' -e's/^#h//' -e's/[ 	] */ 0x/g'`"
+    local FSHA1="`grep '^#h' $1 | tr -d '[:cntrl:]' | sed -e's/^#h//' -e's/ / 0x/g'`"
     FSHA1=`printf '%08x%08x%08x%08x%08x' $FSHA1`
 
     if [ -n "$FSHA1" -a \( "$FSHA1" = "$DSHA1" \) ]; then
@@ -341,8 +339,7 @@ if ! [ -f "$NTPCONF" ]; then
 fi
 
 # Parse ntp.conf for leapfile directive
-# FIXME broken on MacOS/macports
-LEAPFILE="`sed $NTPCONF -e'/^ *leapfile  *.*$/!d' -e's/^ *leapfile  *//'`"
+LEAPFILE="`grep -x 'leapfile *.*' $NTPCONF | grep -o ' [^ ]*.*'`"
 if [ -z "$LEAPFILE" ]; then
     log "warning" "$NTPCONF does not specify a leapfile"
 fi



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/462a3b10e5170f2e113ece14194451851ed03dfc...7c253cb97ac8712a3067728682691c479eaade0a

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/462a3b10e5170f2e113ece14194451851ed03dfc...7c253cb97ac8712a3067728682691c479eaade0a
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20181207/a968d11c/attachment-0001.html>


More information about the vc mailing list