Bug 1136040

Summary: /etc/localtime is not a symlink
Product: [Fedora] Fedora Reporter: Petr Pisar <ppisar>
Component: mockAssignee: Miroslav Suchý <msuchy>
Status: CLOSED NEXTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 20CC: jdisnard, mebrown, msimacek, msuchy, praiskup, williams
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: mock-1.2.0 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-10-12 21:18:16 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Naive patch none

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.