Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 253654 - mock does not create /etc/hosts
mock does not create /etc/hosts
Product: Fedora
Classification: Fedora
Component: mock (Show other bugs)
All Linux
low Severity low
: ---
: ---
Assigned To: Michael E Brown
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2007-08-20 20:14 EDT by Radu Greab
Modified: 2007-11-30 17:12 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2007-08-20 21:38:33 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
make mock create /etc/hosts or other files that use an absolute path (470 bytes, patch)
2007-08-20 20:14 EDT, Radu Greab
no flags Details | Diff

  None (edit)
Description Radu Greab 2007-08-20 20:14:23 EDT
Description of problem:
mock doesn't create /etc/hosts because the following code that would build the
path to /etc/hosts and write it inside the chroot-ed environment

        for key in filedict:
            p = os.path.join(self.rootdir, key)
            if not os.path.exists(p):
                # write file

refers to /etc/hosts from the host environment, not to /etc/hosts from the
chroot-ed environment.

I learned that os.path.join ignores the arguments that appear before absolute
paths. In this case 'key' contains the value '/etc/hosts', so self.rootdir is
ignored and the path returned is /etc/hosts.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. mock -r fedora-7-i386 init

Actual results:
$ ls -l /var/lib/mock/fedora-7-i386/root/etc/hosts
ls: cannot access /var/lib/mock/fedora-7-i386/root/etc/hosts: No such file or

Expected results:
$ ls -l /var/lib/mock/fedora-7-i386/root/etc/hosts
-rw-rw-r-- 1 rpmb mock 49 2007-08-21 03:05

Additional info:
A workaround is to use config_opts['files']['etc/hosts'], but even mock uses
'/etc/hosts' when it sets the default.

Although I don't know Python, I found that the code be changed to work in both
cases, when either '/etc/hosts' or 'etc/hosts' is used.
Comment 1 Radu Greab 2007-08-20 20:14:24 EDT
Created attachment 161936 [details]
make mock create /etc/hosts or other files that use an absolute path
Comment 2 Michael E Brown 2007-08-20 21:38:33 EDT
Thanks for the bug report.

Fix pushed to main git repo. 

What does this affect. Need to know if this breaks any builds and if I need to
schedule a new release for fedora soon.
Comment 3 Radu Greab 2007-08-21 09:00:12 EDT
Some packages that need to use 'localhost' or 'localhost.localdomain' during
build will not be built if the nameserver specified in /etc/resolv.conf is not
available or is not configured to serve the 'localhost' zone. I've seen this
problem in the past with some perl packages, but currently I cannot remember
their name.

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