Bug 1416813

Summary: mock-scm fails to build srpm with selinux enabled when run in docker
Product: [Fedora] Fedora Reporter: clime
Component: mockAssignee: Miroslav Suchý <msuchy>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 25CC: jdisnard, mebrown, msimacek, msuchy, praiskup, vrutkovs, williams
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-12-12 10:40:20 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
relevant output from audit.log none

Description clime 2017-01-26 14:12:18 UTC
Description of problem:

The following command gives an error:

docker run --cap-add=SYS_ADMIN --name 7-f23-d41d8cd98f00b204e9800998ecf8427e -v /tmp/tmplCbW9M:/tmp/tmplCbW9M -w /tmp/tmplCbW9M 8dad1bfbf15d /usr/bin/mock -r fedora-rawhide-x86_64 --uniqueext 7-f23 --scm-enable --scm-option method=git --scm-option package=example --scm-option branch= --scm-option write_tar=True --scm-option spec=subpkg/example.spec --scm-option git_get=git clone --depth 1 https://github.com/clime/example2.git example --buildsrpm --resultdir=/tmp/tmplCbW9M

The error is:

mock.py version 1.3.3 starting (python version = 3.5.1)...
Start: init plugins
INFO: selinux disabled
Finish: init plugins
Start: run
INFO: Start(/tmp/tmprx9ydejp.mock-scm.example/example/subpkg/example.spec)  Config(fedora-rawhide-x86_64)
Start: clean chroot
Finish: clean chroot
Start: chroot init
INFO: calling preinit hooks
INFO: enabled root cache
INFO: enabled dnf cache
Start: cleaning dnf metadata
Finish: cleaning dnf metadata
Mock Version: 1.3.3
INFO: Mock Version: 1.3.3
ERROR: Exception(/tmp/tmprx9ydejp.mock-scm.example/example/subpkg/example.spec) Config(fedora-rawhide-x86_64) 0 minutes 0 seconds
INFO: Results and/or logs in: /tmp/tmplCbW9M
INFO: Cleaning up build root ('cleanup_on_failure=True')
Start: clean chroot
Finish: clean chroot
ERROR: Command failed. See logs for output.
 # /bin/mount -n -t proc proc /var/lib/mock/fedora-rawhide-x86_64-7-f23/root/proc

With selinux disabled, the error no longer occurs.

Version-Release number of selected component (if applicable):
Name        : docker
Arch        : x86_64
Epoch       : 2
Version     : 1.12.6
Release     : 5.git037a2f5.fc25

Name        : mock
Arch        : noarch
Epoch       : 0
Version     : 1.3.3
Release     : 1.fc25

How reproducible:
Always


Actual results:
The command fails to build srpm.

Expected results:
The command builds srpm.

Additional info:
The command is run from a service on a machine providing dist-git repos. That machine has currently selinux disabled so this is not a critical issue. When trying to reproduce the issue in shell I encountered another error that also disappeared after disabling SELinux:

Traceback (most recent call last):
  File "/usr/libexec/mock/mock", line 885, in <module>
    main()
  File "/usr/lib/python3.5/site-packages/mockbuild/trace_decorator.py", line 89, in trace
    result = func(*args, **kw)
  File "/usr/libexec/mock/mock", line 701, in main
    run_command(options, args, config_opts, commands, buildroot, state)
  File "/usr/lib/python3.5/site-packages/mockbuild/trace_decorator.py", line 89, in trace
    result = func(*args, **kw)
  File "/usr/libexec/mock/mock", line 786, in run_command
    do_buildsrpm(config_opts, commands, buildroot, options, args)
  File "/usr/lib/python3.5/site-packages/mockbuild/trace_decorator.py", line 89, in trace
    result = func(*args, **kw)
  File "/usr/libexec/mock/mock", line 538, in do_buildsrpm
    cmd=cmd, post=None, clean=clean)
  File "/usr/lib/python3.5/site-packages/mockbuild/trace_decorator.py", line 89, in trace
    result = func(*args, **kw)
  File "/usr/libexec/mock/mock", line 464, in rebuild_generic
    commands.init(prebuild=not config_opts.get('short_circuit'))
  File "/usr/lib/python3.5/site-packages/mockbuild/trace_decorator.py", line 89, in trace
    result = func(*args, **kw)
  File "/usr/lib/python3.5/site-packages/mockbuild/backend.py", line 124, in init
    self.buildroot.initialize(**kwargs)
  File "/usr/lib/python3.5/site-packages/mockbuild/trace_decorator.py", line 89, in trace
    result = func(*args, **kw)
  File "/usr/lib/python3.5/site-packages/mockbuild/buildroot.py", line 90, in initialize
    self._init(prebuild=prebuild, do_log=do_log)
  File "/usr/lib/python3.5/site-packages/mockbuild/trace_decorator.py", line 89, in trace
    result = func(*args, **kw)
  File "/usr/lib/python3.5/site-packages/mockbuild/buildroot.py", line 128, in _init
    self._resetLogging()
  File "/usr/lib/python3.5/site-packages/mockbuild/trace_decorator.py", line 89, in trace
    result = func(*args, **kw)
  File "/usr/lib/python3.5/site-packages/mockbuild/buildroot.py", line 312, in _resetLogging
    fh = logging.FileHandler(fullPath, "a+")
  File "/usr/lib64/python3.5/logging/__init__.py", line 1008, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/lib64/python3.5/logging/__init__.py", line 1037, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
PermissionError: [Errno 13] Permission denied: '/tmp/tmpXYj2jX/state.log'

Comment 1 clime 2017-01-26 14:29:56 UTC
Created attachment 1244788 [details]
relevant output from audit.log

Comment 2 Pavel Raiskup 2017-01-26 15:25:23 UTC
Minimal example (from docker POV):
docker run  --cap-add=SYS_ADMIN  --rm -ti fedora bash -c 'mkdir /mnt/proc && mount -n -t proc proc /mnt/proc'

Comment 3 Pavel Raiskup 2017-01-26 15:36:37 UTC
--privileged helps, but that's not what we want in copr

Comment 4 Vadim Rutkovsky 2017-06-20 08:11:37 UTC
Does adding '--tmpfs /run --tmpfs /tmp' to the parameters list help?

Comment 5 Pavel Raiskup 2017-06-22 10:10:34 UTC
See reproducer in comment #2.  Mock needs to mount /mnt/proc.

Comment 6 Fedora End Of Life 2017-11-16 19:53:30 UTC
This message is a reminder that Fedora 25 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 25. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '25'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not
able to fix it before Fedora 25 is end of life. If you would still like
to see this bug fixed and are able to reproduce it against a later version
of Fedora, you are encouraged  change the 'version' to a later Fedora
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.

Comment 7 Fedora End Of Life 2017-12-12 10:40:20 UTC
Fedora 25 changed to end-of-life (EOL) status on 2017-12-12. Fedora 25 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.