--- etc/rc.initdiskless 2011-01-23 05:59:54.000000000 -0600 +++ etc/rc.initdiskless 2011-05-06 12:40:10.940259210 -0500 @@ -337,9 +337,30 @@ # NFS remount handle_remount $j + + # Keep track of the most recent timestamp for clockskew detection + stamp="$(/usr/bin/stat -f %Um "$j")" + [ "${stamp}" -gt "${newest:-0}" ] && newest="${stamp}" + # done done +# +# Check for clock skew, to make sure the local timestamp is newer than +# the last saveconfig or the date of the image +stamp="$(/usr/bin/stat -f %Um "/COPYRIGHT")" +[ "${stamp}" -gt "${newest:-0}" ] && newest="${stamp}" +if [ "${newest}" -gt "$(/bin/date +%s)" ] +then + # Clock skew detected! Attempt to correct + correction="$(( ${newest} + 60 ))" + printf "Clock skew detected!\n" >&2 + printf " Now (%s) is before newest (%s)\n" "$(/bin/date)" "$(/bin/date -jf %s "${newest}")" >&2 + printf "Clock reset to %s\n" "$(/bin/date -f %s "${correction}")" >&2 + printf "Run ntpd or ntpdate or manually set correct time!\n" >&2 +fi +# + # - Create all required MFS filesystems and populate them from # our templates. Support both a direct template and a dir.cpio.gz # archive. Support dir.remove files containing a list of relative