Bug 1148794

Summary: Running domainname in unprivileged container fails with "you must be root"
Product: Red Hat Enterprise Linux 7 Reporter: Jan Pazdziora <jpazdziora>
Component: dockerAssignee: Daniel Walsh <dwalsh>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: jpazdziora
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-10-03 15:57:32 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:

Description Jan Pazdziora 2014-10-02 11:36:30 UTC
Description of problem:

Running domainname in unprivileged container fails with

domainname: you must be root to change the domain name

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

docker-1.2.0-1.5.el7.x86_64 on the host

How reproducible:

Deterministic

Steps to Reproduce:
1. docker run -ti rhel7 bash -c 'yum install -y hostname ; domainname example.test'
2. echo $?

Actual results:

# docker run -ti rhel7 bash -c 'yum install -y hostname ; domainname example.test'
rhel-7-server-rpms                                      | 3.7 kB  00:00:00     
rhel-7-server-rpms/7Server/x86_64/primary_db            | 6.7 MB  00:00:02     
[...]
Complete!
domainname: you must be root to change the domain name
# echo $?
1
#

Expected results:

# docker run -ti rhel7 bash -c 'yum install -y hostname ; domainname example.test'
rhel-7-server-rpms                                      | 3.7 kB  00:00:00     
rhel-7-server-rpms/7Server/x86_64/primary_db            | 6.7 MB  00:00:02     
[...]
Complete!
# echo $?
0
#

Additional info:

Comment 1 Jan Pazdziora 2014-10-02 11:38:34 UTC
Strace shows

brk(0)                                  = 0xd4b000
setdomainname("example.test", 12)       = -1 EPERM (Operation not permitted)
write(2, "domainname: ", 12domainname: )            = 12
write(2, "you must be root to change the d"..., 42you must be root to change the domain name) = 42

Comment 3 Daniel Walsh 2014-10-03 15:57:32 UTC
This is not a bug.  You are not allowed to change the domainname or hostname from within a container.

Comment 4 Jan Pazdziora 2014-10-03 16:10:45 UTC
(In reply to Daniel Walsh from comment #3)
> This is not a bug.  You are not allowed to change the domainname or hostname
> from within a container.

Does it apply to the NIS/YP domain name as well? That's what domainname changes. It's not dealing with DNS hostname/domain name.

Comment 5 Daniel Walsh 2014-10-11 15:33:06 UTC
Yes, you would need to set these domains outside of the container, in the docker command. Or run with the sys_admin or maybe net_admin capability.