Bug 438337 - Wrong usage of hwclock in /etc/rc.d/init.d/halt
Summary: Wrong usage of hwclock in /etc/rc.d/init.d/halt
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: initscripts
Version: rawhide
Hardware: i386
OS: Linux
low
medium
Target Milestone: ---
Assignee: Bill Nottingham
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2008-03-20 13:23 UTC by Boyan Anastasov
Modified: 2014-03-17 03:13 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2008-03-20 14:51:46 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Boyan Anastasov 2008-03-20 13:23:34 UTC
Description of problem:
Somewhere at the beginning of March 2008 I've noticed that after boot the time
is not correct, but I'm rebooting rarely to be annoyed too much. Today I've
tried to find what is the reason for this. The time after boot is 2 hours ahead.
In fact GMT+2 hours is my current timezone (EET). It appears that the system
time is set from /etc/rc.d/init.d/halt using options from /etc/sysconfig/clock.
What it shows for me is:
ZONE="Europe/Sofia"
UTC=false
ARC=false

Which means the hardware clock is not in UTC, at least this was the meaning for
long time.

/etc/rc.d/init.d/halt is using this to figure out what time to set:
CLOCKDEF=""
CLOCKFLAGS="$CLOCKFLAGS --systohc"

case "$UTC" in
   yes|true)
        CLOCKFLAGS="$CLOCKFLAGS -u";
        CLOCKDEF="$CLOCKDEF (utc)";
        ;;
   no|false)
        CLOCKFLAGS="$CLOCKFLAGS --localtime";
        CLOCKDEF="$CLOCKDEF (localtime)";
        ;;
esac

which shows that for me the options used will be:

CLOCKFLAGS=" --systohc --localtime"

If I understand correctly from the man page of hwclock this means that hwclock
will think that the hardware clock is kept in UTC which is not correct.
For the proof I've performed couple reboots and the time after every reboot
advanced 2 hours ahead.

I think the case with $UTC must be vice versa, eg:

case "$UTC" in
   yes|true)
        CLOCKFLAGS="$CLOCKFLAGS --localtime";
        CLOCKDEF="$CLOCKDEF (utc)";
        ;;
   no|false)
        CLOCKFLAGS="$CLOCKFLAGS -u";
        CLOCKDEF="$CLOCKDEF (localtime)";
        ;;
esac


Version-Release number of selected component (if applicable):
initscripts-8.65-1.i386 have this problem. I think couple of the last versions
too beginning from March at least.

Comment 1 Bill Nottingham 2008-03-20 14:51:46 UTC
halt shouldn't be using /etc/sysconfig/clock at all.

Fixed in
http://git.fedorahosted.org/git/?p=initscripts.git;a=commitdiff;h=1b76162517a5e742201e7c7974a2d6e0d437f789

You may want to check your /etc/adjtime file to make sure that the right value
is on line 3 (UTC or LOCAL)


Note You need to log in before you can comment on or make changes to this bug.