Bug 824033

Summary: RFE: Make /etc/localtime a symlink
Product: [Fedora] Fedora Reporter: Avi Kivity <avi>
Component: system-config-dateAssignee: Nils Philippsen <nphilipp>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: unspecified    
Version: 18CC: awilliam, jonstanley, knoel, kparal, lpoetter, nphilipp, robatino, stephent98
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard: AcceptedNTH
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-11-02 03:16:32 EDT Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Bug Depends On:    
Bug Blocks: 752661, 752664    
Attachments:
Description Flags
screenshot showing timestamps on /etc/adjtime, /etc/localtime before and after running firstboot/s-c-d none

Description Avi Kivity 2012-05-22 11:37:20 EDT
Description of problem:

See Bug #822200 - this needs to be resolved both in glibc and system-config-date.
Comment 1 Nils Philippsen 2012-05-30 09:40:23 EDT
Yes, with a minor caveat:
Comment 2 Nils Philippsen 2012-05-30 12:07:08 EDT
Oops. Not as minor as (empty string) :-). Anyway, I'll have to think if and if yes how I want to support separate /usr without initramfs mounting it.
Comment 3 Jon Stanley 2012-07-30 20:10:54 EDT
Fedora no longer supports /usr without initramfs mounting it, so why would s-c-d? Is there any use case you can think of?
Comment 4 Steve Tyler 2012-10-06 11:20:23 EDT
See also:
Bug 863676 - /etc/localtime link overwritten with incorrect timezone file during firstboot
Comment 5 Nils Philippsen 2012-10-22 08:25:42 EDT
*** Bug 863676 has been marked as a duplicate of this bug. ***
Comment 6 Nils Philippsen 2012-10-22 08:27:43 EDT
*** Bug 859214 has been marked as a duplicate of this bug. ***
Comment 7 Steve Tyler 2012-10-22 08:58:17 EDT
read/write /etc/localtime as symbolic link (#824033)
only fall back to using /etc/sysconfig/clock if it is present 
http://git.fedorahosted.org/cgit/system-config-date.git/commit/?id=bf4da651992bc62f5249527aa438d2dab031b924

Thanks, Nils.
Comment 8 Kamil Páral 2012-10-22 10:29:32 EDT
Nils, please transfer Blocks: and Whiteboard, when duping. Thanks.
Comment 9 Fedora Update System 2012-10-22 11:57:30 EDT
system-config-date-1.10.0-1.fc18,python-slip-0.2.21-1.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/system-config-date-1.10.0-1.fc18,python-slip-0.2.21-1.fc18
Comment 10 Steve Tyler 2012-10-22 14:24:51 EDT
(In reply to comment #9)
> system-config-date-1.10.0-1.fc18,python-slip-0.2.21-1.fc18 has been
> submitted as an update for Fedora 18.
> https://admin.fedoraproject.org/updates/system-config-date-1.10.0-1.fc18,
> python-slip-0.2.21-1.fc18

Works great.  After firstboot/s-c-d runs, /etc/localtime is still a link to the timezone file I configured during installation. The date command shows the expected time and timezone. Thanks.

The timestamp on the link changed. Is that expected?
/etc/localtime Oct 22 10:38
/etc/localtime Oct 22 11:03

/etc/sysconfig/clock was absent.

karma to follow.

Tested with:
$ qemu-kvm -m 2048 -hda f18-test-1.img -cdrom ~/xfr/fedora/F18/F18-Beta/TC6/Fedora-18-Beta-TC6-x86_64-DVD.iso -usb -vga qxl -boot menu=on -usbdevice mouse

Updated to stable after installing and before rebooting from the installer.
Comment 11 Fedora Update System 2012-10-23 02:45:03 EDT
Package system-config-date-1.10.0-1.fc18, python-slip-0.2.21-1.fc18:
* should fix your issue,
* was pushed to the Fedora 18 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing system-config-date-1.10.0-1.fc18 python-slip-0.2.21-1.fc18'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-16696/system-config-date-1.10.0-1.fc18,python-slip-0.2.21-1.fc18
then log in and leave karma (feedback).
Comment 12 Steve Tyler 2012-10-23 08:04:40 EDT
The link created by system-config-date is an absolute path.

The installer creates a relative path (example copied from Bug 863676):

[root@localhost xfr]# ls -lF /etc/localtime
lrwxrwxrwx. 1 root root 41 Oct  6 07:51 /etc/localtime -> ../usr/share/zoneinfo/America/Los_Angeles

$ less -N anaconda-18.19-1/pyanaconda/timezone.py
...
     51     # we want to create a relative symlink
     52     tz_file = "/usr/share/zoneinfo/" + timezone.timezone
     53     rooted_tz_file = os.path.normpath(root + tz_file)
     54     relative_path = os.path.normpath("../" + tz_file)
     55     link_path = os.path.normpath(root + "/etc/localtime")
...
Comment 13 Steve Tyler 2012-10-23 08:33:10 EDT
(In reply to comment #12)
> The link created by system-config-date is an absolute path.
> 
> The installer creates a relative path (example copied from Bug 863676):

That change was introduced here:

Use ksdata.timezone and timezone module instead of anaconda.timezone
http://git.fedorahosted.org/cgit/anaconda.git/commit/pyanaconda/timezone.py?id=73db213960514beb254eb9298955d41831ede3bc

Posted to anaconda-patches here:

[master] Rebased patches removing scdate usage
https://lists.fedorahosted.org/pipermail/anaconda-patches/2012-August/000723.html
Comment 14 Fedora Update System 2012-10-23 15:45:49 EDT
Package system-config-date-1.10.1-1.fc18, python-slip-0.2.21-1.fc18:
* should fix your issue,
* was pushed to the Fedora 18 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing system-config-date-1.10.1-1.fc18 python-slip-0.2.21-1.fc18'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-16696/system-config-date-1.10.1-1.fc18,python-slip-0.2.21-1.fc18
then log in and leave karma (feedback).
Comment 15 Fedora Update System 2012-10-26 15:24:43 EDT
Package system-config-date-1.10.2-1.fc18, python-slip-0.2.21-1.fc18:
* should fix your issue,
* was pushed to the Fedora 18 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing system-config-date-1.10.2-1.fc18 python-slip-0.2.21-1.fc18'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-16696/system-config-date-1.10.2-1.fc18,python-slip-0.2.21-1.fc18
then log in and leave karma (feedback).
Comment 16 Steve Tyler 2012-10-26 17:12:32 EDT
(In reply to comment #12)
> The link created by system-config-date is an absolute path.
> 
> The installer creates a relative path (example copied from Bug 863676):
> 
> [root@localhost xfr]# ls -lF /etc/localtime
> lrwxrwxrwx. 1 root root 41 Oct  6 07:51 /etc/localtime ->
> ../usr/share/zoneinfo/America/Los_Angeles

Gnome control center also creates a relative path.

Verified with:
control-center-1:3.6.1-1.fc18.x86_64
systemd-0:194-1.fc18.x86_64
Fedora-18-Beta-TC6-x86_64-DVD.iso updated to stable.

Command-line:
$ qemu-kvm -m 2048 -hda f18-test-1.img -cdrom ~/xfr/fedora/F18/F18-Beta/TC6/Fedora-18-Beta-TC6-x86_64-DVD.iso -usb -vga qxl -boot menu=on -usbdevice mouse
Comment 17 Nils Philippsen 2012-10-29 10:30:50 EDT
(In reply to comment #12)
> The link created by system-config-date is an absolute path.

Is that a problem?
Comment 18 Steve Tyler 2012-10-29 11:56:09 EDT
(In reply to comment #17)
> (In reply to comment #12)
> > The link created by system-config-date is an absolute path.
> 
> Is that a problem?

During firstboot, s-c-d is overwriting, for no apparent reason, the /etc/localtime link created by the installer. That is a problem in itself.

As for why it is a relative link, this is the best I could find:

[systemd-devel] [PATCH 1/2] timedated: gather timezone from /etc/localtime sym target
http://lists.freedesktop.org/archives/systemd-devel/2012-August/006329.html

"man 5 localtime" shows a relative link, although the text says it can be either absolute or relative.

The bottom line is that what s-c-d does is inconsistent with what the installer and systemd do. That has the potential for causing bugs ...
Comment 19 Steve Tyler 2012-10-29 12:13:19 EDT
(In reply to comment #18)
...
> "man 5 localtime" shows a relative link, although the text says it can be
> either absolute or relative.

Here's a link:
http://www.freedesktop.org/software/systemd/man/localtime.html

Name
localtime — Local time zone configuration file

Synopsis
/etc/localtime -> ../usr/share/zoneinfo/…

...
Comment 20 Steve Tyler 2012-10-29 12:27:10 EDT
(In reply to comment #18)
...
> During firstboot, s-c-d is overwriting, for no apparent reason, the
> /etc/localtime link created by the installer. That is a problem in itself.
...

During firstboot, the s-c-d "Time Zone" tab is not displayed, so why would s-c-d change any files associated with it?
Comment 21 Steve Tyler 2012-10-29 12:38:08 EDT
Created attachment 635080 [details]
screenshot showing timestamps on /etc/adjtime, /etc/localtime before and after running firstboot/s-c-d

(In reply to comment #20)
> (In reply to comment #18)
> ...
> > During firstboot, s-c-d is overwriting, for no apparent reason, the
> > /etc/localtime link created by the installer. That is a problem in itself.
> ...
> 
> During firstboot, the s-c-d "Time Zone" tab is not displayed, so why would
> s-c-d change any files associated with it?

From the timestamps, s-c-d also appears to be writing to /etc/adjtime during firstboot.
Comment 22 Steve Tyler 2012-10-29 14:58:35 EDT
systemd has a command-line utility, timedatectl, that can set the timezone. Afer it is run, /etc/localtime links to a relative path:

$ sudo timedatectl set-timezone 'America/Los_Angeles'

NB: You may need to set selinux to permissive mode to get the command to actually work:

$ sudo setenforce permissive

man page:
http://www.freedesktop.org/software/systemd/man/timedatectl.html

Name

timedatectl — Control the system time and date
Synopsis

timedatectl [OPTIONS...] {COMMAND}
Description

timedatectl may be used to query and change the system clock and its settings.
...

Tested with:
selinux-policy-3.11.1-46.fc18.noarch
selinux-policy-devel-3.11.1-46.fc18.noarch
selinux-policy-targeted-3.11.1-46.fc18.noarch
systemd-195-2.fc18.x86_64
Comment 23 Lennart Poettering 2012-10-30 10:18:59 EDT
(In reply to comment #18)

> The bottom line is that what s-c-d does is inconsistent with what the
> installer and systemd do. That has the potential for causing bugs ...

It doesn't really matter whether the link is relative or absolute. Relative is just a tiny bit nicer since installing Fedora into a subdirectory somehwere will result in a link that actually points to the zoneinfo inside the subdirectory rather than into the host OS.
Comment 24 Steve Tyler 2012-10-30 11:54:35 EDT
(In reply to comment #23)
> (In reply to comment #18)
> 
> > The bottom line is that what s-c-d does is inconsistent with what the
> > installer and systemd do. That has the potential for causing bugs ...
> 
> It doesn't really matter whether the link is relative or absolute. Relative
> is just a tiny bit nicer since installing Fedora into a subdirectory
> somehwere will result in a link that actually points to the zoneinfo inside
> the subdirectory rather than into the host OS.

Thanks, Lennart. Is there a use-case where the user would not be chrooted to the subdirectory?
Comment 25 Adam Williamson 2012-11-02 03:16:32 EDT
Update was pushed stable, closing.
Comment 26 Fedora Update System 2012-12-11 06:12:12 EST
system-config-date-1.10.5-1.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/system-config-date-1.10.5-1.fc16
Comment 27 Fedora Update System 2012-12-11 06:12:49 EST
system-config-date-1.10.5-1.fc17 has been submitted as an update for Fedora 17.
https://admin.fedoraproject.org/updates/system-config-date-1.10.5-1.fc17
Comment 28 Fedora Update System 2013-01-03 02:28:56 EST
system-config-date-1.10.5-1.fc16, python-slip-0.2.24-1.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 30 Fedora Update System 2013-01-12 10:01:26 EST
system-config-date-1.10.5-1.fc17, python-slip-0.2.24-1.fc17 has been pushed to the Fedora 17 stable repository.  If problems still persist, please make note of it in this bug report.