Last time I found a bug I waited too long, and I promised to report it early on the next time. Today the timesync made the exact opposite of what it is supposed to do.
bb9f72df-5e84-4dfb-bfaf-8e2cf4e2dce0: Running sdwdate...
bb9f72df-5e84-4dfb-bfaf-8e2cf4e2dce0: sdwdate_preparation: Setting CURL to curl.whonix-orig.
bb9f72df-5e84-4dfb-bfaf-8e2cf4e2dce0: dispatching pre (SDW_MODE: daemon): /usr/lib/whonix/timesync_pre --autostart --mode $SDW_MODE
bb9f72df-5e84-4dfb-bfaf-8e2cf4e2dce0: dispatching prerequisite (SDW_MODE: daemon) (CURL: curl.whonix-orig) (LD_PRELOAD: ): /usr/lib/whonix/timesync_prerequisite
bb9f72df-5e84-4dfb-bfaf-8e2cf4e2dce0: DISPATCH_PREREQUISITE returned 0, continuing...
bb9f72df-5e84-4dfb-bfaf-8e2cf4e2dce0: getUrlDateDiff: https://www.privacyinternational.org
bb9f72df-5e84-4dfb-bfaf-8e2cf4e2dce0: dispatching SDWDATE_CURL_DISPATCH_PRE[SDWDATE_POOL_PAL] (SDW_MODE: daemon) (CURL: curl.whonix-orig): /usr/lib/whonix/msgcollector --icon /usr/share/whonix/icons/timesync.ico --identifier timesync --prog$
bb9f72df-5e84-4dfb-bfaf-8e2cf4e2dce0: dispatching SDWDATE_CURL_DISPATCH_POST[SDWDATE_POOL_PAL]: /usr/lib/whonix/msgcollector --icon /usr/share/whonix/icons/timesync.ico --identifier timesync --progressbaridx timesync --progressx 30
bb9f72df-5e84-4dfb-bfaf-8e2cf4e2dce0: https://www.privacyinternational.org (took 3s) => diff = 1 second(s)
bb9f72df-5e84-4dfb-bfaf-8e2cf4e2dce0: getUrlDateDiff: https://thepiratebay.org
bb9f72df-5e84-4dfb-bfaf-8e2cf4e2dce0: dispatching SDWDATE_CURL_DISPATCH_PRE[SDWDATE_POOL_NEUTRAL] (SDW_MODE: daemon) (CURL: curl.whonix-orig): /usr/lib/whonix/msgcollector --icon /usr/share/whonix/icons/timesync.ico --identifier timesync --$
bb9f72df-5e84-4dfb-bfaf-8e2cf4e2dce0: dispatching SDWDATE_CURL_DISPATCH_POST[SDWDATE_POOL_NEUTRAL]: /usr/lib/whonix/msgcollector --icon /usr/share/whonix/icons/timesync.ico --identifier timesync --progressbaridx timesync --progressx 60
bb9f72df-5e84-4dfb-bfaf-8e2cf4e2dce0: https://thepiratebay.org (took 3s) => diff = 25115 second(s)
bb9f72df-5e84-4dfb-bfaf-8e2cf4e2dce0: getUrlDateDiff: https://encrypted.google.com
bb9f72df-5e84-4dfb-bfaf-8e2cf4e2dce0: dispatching SDWDATE_CURL_DISPATCH_PRE[SDWDATE_POOL_FOE] (SDW_MODE: daemon) (CURL: curl.whonix-orig): /usr/lib/whonix/msgcollector --icon /usr/share/whonix/icons/timesync.ico --identifier timesync --prog$
bb9f72df-5e84-4dfb-bfaf-8e2cf4e2dce0: dispatching SDWDATE_CURL_DISPATCH_POST[SDWDATE_POOL_FOE]: /usr/lib/whonix/msgcollector --icon /usr/share/whonix/icons/timesync.ico --identifier timesync --progressbaridx timesync --progressx 80
bb9f72df-5e84-4dfb-bfaf-8e2cf4e2dce0: https://encrypted.google.com (took 3s) => diff = 2 second(s)
bb9f72df-5e84-4dfb-bfaf-8e2cf4e2dce0: Median diff: 8372 second(s)
bb9f72df-5e84-4dfb-bfaf-8e2cf4e2dce0: Setting time to 1398630421...
bb9f72df-5e84-4dfb-bfaf-8e2cf4e2dce0: dispatching post_success (SDW_MODE: daemon): /usr/lib/whonix/timesync_post_success --autostart --mode $SDW_MODE
bb9f72df-5e84-4dfb-bfaf-8e2cf4e2dce0: Sleeping for 33 minutes.
You can see of the three server the script asked, 2 of them agreed with the time of my machine roughly, but the pirate bay server is way off. And while the log says Median diff it actually calculates the average and it is applying this changed immediatly.
The average is: 8372 seconds, while the median would have been 2.
I heard you have a python developer now? maybe rewriting this script into python would be a first good step. The error handling of Shell Scripts alone should be reason enough to avoid it for security critical applications like this one. And it would also help to make it more readable. Even with grepping I didnt find the method which should do the median calculation.
Is there a clean way to deactivate the automatic timesync? I currenty just return to skip the timesync. And is there a particular reason why whonix is not using ntp?