Bug 1136040 - /etc/localtime is not a symlink
Summary: /etc/localtime is not a symlink
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: mock
Version: 20
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Miroslav Suchý
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-09-01 13:43 UTC by Petr Pisar
Modified: 2014-10-12 21:18 UTC (History)
6 users (show)

Fixed In Version: mock-1.2.0
Clone Of:
Environment:
Last Closed: 2014-10-12 21:18:16 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Naive patch (1.59 KB, patch)
2014-09-01 18:49 UTC, Miroslav Suchý
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1135981 0 unspecified CLOSED DateTime::TimeZone::Local->TimeZone does not use /etc/locatime content (Cannot determine local time zone) 2021-02-22 00:41:40 UTC
Red Hat Bugzilla 1136219 0 unspecified CLOSED RFE: Embed time zone name into compiled tzfile (cannot determine local time zone name) 2021-02-22 00:41:40 UTC

Internal Links: 1135981 1136219

Description Petr Pisar 2014-09-01 13:43:40 UTC
Using mock to rebuild a package (e.g. in a koji) results in a /etc/localtime being a normal file. That breaks other program's expectation that it's a symlink whose value can be used to retrieve the time zone name (see bug #1135981).

According to localtime(5), /etc/localtime may not be a normal file:

       Because the timezone identifier is extracted from the symlink target
       name of /etc/localtime, this file may not be a normal file or hardlink.

Comment 1 Miroslav Suchý 2014-09-01 18:49:13 UTC
Created attachment 933502 [details]
Naive patch

I wrote naïve solution. But then I find that those data files are owned by tzdata package, which is *not* in minimal buildroot. Which is problematic for me.

> /etc/localtime may not be a normal file
English is not my mother tongue, therefore pardon me if I'm wrong. I undestand this sentence as "There is high chance that the file can be symlink or hardlink.", however that it *can* be normal file as well.

In this light, I hesitate to do a change in mock.

Comment 2 Petr Pisar 2014-09-02 07:02:47 UTC
(In reply to Miroslav Suchý from comment #1)
> Created attachment 933502 [details]
> Naive patch
> 
> I wrote naïve solution. But then I find that those data files are owned by
> tzdata package, which is *not* in minimal buildroot. Which is problematic
> for me.
> 
I know. What about replacing the file with a symlink after installing minimal build root if the /usr/share/zoneinfo is there?

> > /etc/localtime may not be a normal file
> English is not my mother tongue, therefore pardon me if I'm wrong. I
> undestand this sentence as "There is high chance that the file can be
> symlink or hardlink.", however that it *can* be normal file as well.
> 
> In this light, I hesitate to do a change in mock.

There is no way how to get to know the time zone name from the chrooted system. The file has to be a symlink, or TZ environement variable has to be exported there. Or some Fedora specific mean has to be employed (e.g. setting /etc/sysconfig/something and then calling an updater.)

The problem is who else should to do that than mock?

tzadata refuses to run any postscripts. Allegedly, glibc run an updater. However it cannot know create the symlink if there is no time zone name saved.

Comment 3 Petr Pisar 2014-09-04 06:13:09 UTC
tzdata maintainer says in bug #1136219 comment 5:

> I see that much has changed since I was around.  The tzdata updating logic and
> ownership of /etc/localtime was moved to systemd since bug 858735.
> /etc/sysconfig/clock is not used anymore, as you pointed out in the text that
> I snipped out.  It also seems to have become a symbolic link.
>
> So let's recap.  The problem is due to systemd not being installed in a build
> root, _and_ mock copying the contents instead of symlink.  But there's no other
> way to do it, otherwise mock would create a dangling symlink that would
> potentially remain dangling if the in-mock tzdata doesn't have the zone the
> host system has.  Hmm.
>
> Outside mock you shouldn't see this problem, as tzdata never drops zones (that
> sacred cow of compatibility again).  It's really only mock that exposes this.

If you conclude that a time zone should be set properly in a mock environment, either @build should involve needed packages (sub-package the timedatectl) and mock should run timedatectl to set the /etc/localtime properly, or mock should use reimplement the logic and create a symlink if tzdata appears in the chroot at the end of initialization.

Comment 4 Jeff Fearn 🐞 2014-09-26 04:09:57 UTC
Just to clarify

(In reply to Miroslav Suchý from comment #1)
> > /etc/localtime may not be a normal file
> English is not my mother tongue, therefore pardon me if I'm wrong. I
> undestand this sentence as "There is high chance that the file can be
> symlink or hardlink.", however that it *can* be normal file as well.

"may not" without qualifying text is generally definitive.

i.e. the common reading of the sentence is:

Because the timezone identifier is extracted from the symlink target name of /etc/localtime, this file is not allowed be a normal file or hardlink.

Comment 5 Miroslav Suchý 2014-10-01 19:33:37 UTC
This should be fixed as side effect of bug 1132762.
Now, mock does not touch /etc/localtime at all.

Comment 6 Miroslav Suchý 2014-10-12 21:18:16 UTC
Fixed in mock-1.2.0, which just landed in rawhide.


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