Bug 438337

Summary: Wrong usage of hwclock in /etc/rc.d/init.d/halt
Product: [Fedora] Fedora Reporter: Boyan Anastasov <btanastasov>
Component: initscriptsAssignee: Bill Nottingham <notting>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: rawhideCC: rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-03-20 14:51:46 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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)