Bug 253654

Summary: mock does not create /etc/hosts
Product: [Fedora] Fedora Reporter: Radu Greab <radu>
Component: mockAssignee: Michael E Brown <mebrown>
Status: CLOSED NEXTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: 7CC: mebrown
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-08-21 01:38:33 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:
Attachments:
Description Flags
make mock create /etc/hosts or other files that use an absolute path none

Description Radu Greab 2007-08-21 00:14:23 UTC
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):
mock-0.7.4-1.fc7


How reproducible:
Always


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
directory


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
/var/lib/mock/fedora-7-i386/root/etc/hosts


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-21 00:14:24 UTC
Created attachment 161936 [details]
make mock create /etc/hosts or other files that use an absolute path

Comment 2 Michael E Brown 2007-08-21 01:38:33 UTC
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 13:00:12 UTC
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.