Package: fake-hwclock
Version: 0.14
Severity: important
Tags: patch

Since version 0.14, calling `fake-hwclock load` *without* the `force` parameter will actually always force loading the saved clock even if older than the system clock. This is very annoying as this forces the system to an older incorrect clock at boot time even after the system clock was properly set to the correct time from the RTC by the kernel.

This is due the an inverted logic test introduced by commit 83537e2 (Tweak handling of parameters) and easily fixed with the following patch:

commit bb7d2c1a0f45905267064b376c812ec53c829286 (HEAD -> master)
Author: Aurelien Jacobs <au...@gnuage.org>
Date:   Thu Jan 16 19:15:11 2025 +0100

Fix an inverted logic issue for the force parameter of the load command

   The bug was introduced in the following commit:
   83537e2  Tweak handling of parameters.

diff --git a/fake-hwclock b/fake-hwclock
index 641c49f..d83afc8 100755
--- a/fake-hwclock
+++ b/fake-hwclock
@@ -56,7 +56,7 @@ case $COMMAND in
            SAVED="$(cat $FILE)"
            SAVED_SEC=$(date -u -d "$SAVED" '+%s')
            NOW_SEC=$(date -u '+%s')
- if [ "$FORCE"x = "false"x ] || [ $NOW_SEC -le $SAVED_SEC ] ; then + if [ "$FORCE"x != "false"x ] || [ $NOW_SEC -le $SAVED_SEC ] ; then
                date -u -s "$SAVED"
            else
echo "Current system time: $(date -u '+%Y-%m-%d %H:%M:%S')"


commit bb7d2c1a0f45905267064b376c812ec53c829286
Author: Aurelien Jacobs <au...@gnuage.org>
Date:   Thu Jan 16 19:15:11 2025 +0100

    Fix an inverted logic issue for the force parameter of the load command
    
    The bug was introduced in the following commit:
    83537e2  Tweak handling of parameters.

diff --git a/fake-hwclock b/fake-hwclock
index 641c49f..d83afc8 100755
--- a/fake-hwclock
+++ b/fake-hwclock
@@ -56,7 +56,7 @@ case $COMMAND in
             SAVED="$(cat $FILE)"
             SAVED_SEC=$(date -u -d "$SAVED" '+%s')
             NOW_SEC=$(date -u '+%s')
-            if [ "$FORCE"x = "false"x ] || [ $NOW_SEC -le $SAVED_SEC ] ; then
+            if [ "$FORCE"x != "false"x ] || [ $NOW_SEC -le $SAVED_SEC ] ; then
                 date -u -s "$SAVED"
             else
                 echo "Current system time: $(date -u '+%Y-%m-%d %H:%M:%S')"

Reply via email to