Bug 253654 - mock does not create /etc/hosts
Summary: mock does not create /etc/hosts
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: mock (Show other bugs)
(Show other bugs)
Version: 7
Hardware: All Linux
low
low
Target Milestone: ---
Assignee: Michael E Brown
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2007-08-21 00:14 UTC by Radu Greab
Modified: 2007-11-30 22:12 UTC (History)
1 user (show)

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: ---


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

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.



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