[Git][NTPsec/ntpsec][master] ntpleapfetch. Fix mistake in last commit. Fix chwn/chmod on BSD.

Gary E. Miller gitlab at mg.gitlab.com
Wed Dec 12 02:18:52 UTC 2018


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


Commits:
793e569d by Gary E. Miller at 2018-12-12T02:17:19Z
ntpleapfetch.  Fix mistake in last commit.  Fix chwn/chmod on BSD.

BSd and osX do not support "chmod --reference=" or "stat -c", so
when "chmod --reference=" fails, just force permissions to root:wheel
744.

- - - - -


1 changed file:

- ntpclients/ntpleapfetch


Changes:

=====================================
ntpclients/ntpleapfetch
=====================================
@@ -294,7 +294,7 @@ verifySHA1() {
 
     # Extract just the data, removing all whitespace
 
-    local DSHA1="`printf \"$DATA\" | $SHASUM | sed -e's/[? *].*$//'`"
+    local DATA="`echo \"$RAW\" | sed -e'/^#h/d' -e's/^#[\$@]//g' | tr -d '[:space:]'`"
 
     # Compute the SHA1 hash of the data, removing the marker and filename
     # Computed in binary mode, which shouldn't matter since whitespace
@@ -302,7 +302,7 @@ verifySHA1() {
     # shasum/sha1sum comes in several flavors;
     # a portable one is available in Perl (with Digest::SHA)
 
-    local DSHA1="`echo -n \"$DATA\" | $SHASUM | sed -e's/[? *].*$//'`"
+    local DSHA1="`printf \"$DATA\" | $SHASUM | sed -e's/[? *].*$//'`"
 
     # Extract the file's hash. Restore any leading zeroes in hash segments.
 
@@ -402,8 +402,16 @@ if [ -n "$FORCE" ] || ! verifySHA1 $LEAPFILE "$VERBOSE" || [ $EXPIRES -lt `date
                 # copy from NTPCONF instead
                 REFFILE="$NTPCONF"
             fi
-            chmod --reference=$REFFILE $TMPFILE
-            chown --reference=$REFFILE $TMPFILE
+            chmod --reference=$REFFILE $TMPFILE > /dev/null 2>&1
+            if  [ $? -ne 0 ] ; then
+                # the above chmod fails on osX and BSD, just force it
+                chmod 644 $TMPFILE
+            fi
+            chown --reference=$REFFILE $TMPFILE > /dev/null 2>&1
+            if  [ $? -ne 0 ] ; then
+                # the above chown fails on osX and BSD, just force it
+                chown root:wheel $TMPFILE
+            fi
             ( which selinuxenabled && selinuxenabled && which chcon ) >/dev/null 2>&1
             if  [ $? -eq 0 ] ; then
                 chcon --reference $REFFILE $TMPFILE



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/793e569da7cc8ace5773cf5fa5e443871f0a923a

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/793e569da7cc8ace5773cf5fa5e443871f0a923a
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/20181212/6a444556/attachment-0001.html>


More information about the vc mailing list