Package: fake-hwclock
Version: 0.9

Upon first use of fake-hwclock, if the device does not have a
battery-backed clock (and has not saved fake-hwclock.data yet), the clock
will typically start at Jan 1, 1970 UTC.  This has the following
repercussions:
- Before manually adjusting the time, it will be behind other files on the
system
- Manual adjustment of the clock via a UI with a mouse will require several
clicks to increment the year from 1970 to the current
- If the user does not adjust the time, website certificates will be
rejected as not yet valid

While a fake clock is never perfect, we can get closer to reality by keying
off of the modification time of a file or directory, so that on first boot
the clock will effectively be set to a time that is no earlier than the
time at which the file system was built.  Using the root directory (/)
seems safest as it is a directory that can be assumed to always exist.

Below is a proposed change to the "load" case of the fake-hwclock script:

    load)
        if [ -e $FILE ] ; then
            SAVED="$(cat $FILE)"
            SAVED_SEC=$(date -u -d "$SAVED" '+%s')
        else
            echo "Unable to read saved clock information: $FILE does not
exist"
            echo "Using modification time of root directory (/) as saved
time"
            SAVED_SEC=$(stat -c %Y /)
            SAVED=$(date -u -d "@$SAVED_SEC" '+%Y-%m-%d %H:%M:%S')
        fi
        NOW_SEC=$(date -u '+%s')
        if $FORCE || [ $NOW_SEC -le $SAVED_SEC ] ; then
            date -u -s "$SAVED"
        else
            echo "Current system time: $(date -u '+%Y-%m-%d %H:%M:%S')"
            echo "fake-hwclock saved clock information is in the past:
$SAVED"
            echo "To set system time to this saved clock anyway, use
\"force\""
        fi
        ;;


-- 
............................................................................

*Roddy Shuler*  |  +1.585.530.7960  |  Endless

Reply via email to