Bug 629041 - selinux plugin expects that yum cache directory exists
selinux plugin expects that yum cache directory exists
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: mock (Show other bugs)
12
All Linux
low Severity medium
: ---
: ---
Assigned To: Clark Williams
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2010-08-31 14:45 EDT by Dan Horák
Modified: 2013-01-10 01:11 EST (History)
4 users (show)

See Also:
Fixed In Version: mock-1.1.10-1.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2010-10-28 18:22:15 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
modification to the fake '/proc/filesystems' file generated by the selinux plugin (1.22 KB, patch)
2010-09-01 09:36 EDT, Clark Williams
no flags Details | Diff

  None (edit)
Description Dan Horák 2010-08-31 14:45:33 EDT
Koji builder creates mock configs on the fly and sends them to mock. These config have all caches disabled because the configs are used only once. And it makes problem in the selinux plugin which expects that the $yum_cache_dir/$buildroot directory exists and it wants to create the "filesystem" file there.

Version-Release number of selected component (if applicable):
mock-1.0.11-1.fc12.noarch

and if I've seen correctly in the sources the same problem should be present also in the 1.1.x version

the returned traceback when run manually with a koji prepared config file:
[dan@eagle py]$ sudo ./mock.py --config /etc/mock -r koji/dist-f15-build-558-598 init
INFO: mock.py version unreleased_version starting...
State Changed: init plugins
INFO: selinux enabled
State Changed: start
State Changed: lock buildroot
State Changed: clean
State Changed: init
State Changed: lock buildroot
Mock Version: unreleased_version
INFO: Mock Version: unreleased_version
_selinuxPreInitHook
_selinuxPostBuildHook
Traceback (most recent call last):
  File "./mock.py", line 736, in <module>
    main(retParams)
  File "./mock.py", line 604, in main
    chroot.init()
  File "<peak.util.decorators.rewrap wrapping mock.backend.init at 0x01901668>", line 3, in init
  File "/opt2/src/mock/py/mock/trace_decorator.py", line 70, in trace
    result = func(*args, **kw)
  File "/opt2/src/mock/py/mock/backend.py", line 195, in init
    self._callHooks('initfailed')
  File "<peak.util.decorators.rewrap wrapping mock.backend._callHooks at 0x018F70C8>", line 3, in _callHooks
  File "/opt2/src/mock/py/mock/trace_decorator.py", line 70, in trace
    result = func(*args, **kw)
  File "/opt2/src/mock/py/mock/backend.py", line 609, in _callHooks
    hook()
  File "<peak.util.decorators.rewrap wrapping selinux._selinuxPostBuildHook at 0x01967758>", line 3, in _selinuxPostBuildHook
  File "/opt2/src/mock/py/mock/trace_decorator.py", line 70, in trace
    result = func(*args, **kw)
  File "/opt2/src/mock/py/mock/plugins/selinux.py", line 69, in _selinuxPostBuildHook
    os.unlink(self.filesystems)
OSError: [Errno 2] No such file or directory: '/var/lib/mock/cache/dist-f15-build-558-598/filesystems'
Comment 1 Clark Williams 2010-08-31 16:13:19 EDT
Does this patch fix the error?

diff --git a/py/mock/plugins/selinux.py b/py/mock/plugins/selinux.py
index fd4bf2e..2af41a5 100644
--- a/py/mock/plugins/selinux.py
+++ b/py/mock/plugins/selinux.py
@@ -35,6 +35,7 @@ class SELinux(object):
         self.rootObj = rootObj
         self.conf = conf
 
+        mock.util.mkdirIfAbsent(conf["cachedir"])
         self.filesystems = os.path.join(conf["cachedir"], "filesystems")
         self.chrootFilesystems = rootObj.makeChrootPath("/proc/filesystems")
Comment 2 Dan Horák 2010-08-31 16:48:55 EDT
(In reply to comment #1)
> Does this patch fix the error?
> 
> diff --git a/py/mock/plugins/selinux.py b/py/mock/plugins/selinux.py
> index fd4bf2e..2af41a5 100644
> --- a/py/mock/plugins/selinux.py
> +++ b/py/mock/plugins/selinux.py
> @@ -35,6 +35,7 @@ class SELinux(object):
>          self.rootObj = rootObj
>          self.conf = conf
> 
> +        mock.util.mkdirIfAbsent(conf["cachedir"])
>          self.filesystems = os.path.join(conf["cachedir"], "filesystems")
>          self.chrootFilesystems = rootObj.makeChrootPath("/proc/filesystems")

Thanks, it helps. The only downside I can see now is that it will create empty directories that won't be removed and another mechanism like tmpwatch will be needed. Although mock should be convinced to remove the "cachedir" when it has caching disabled.
Comment 3 Clark Williams 2010-08-31 17:06:16 EDT
Adding Jan to the CC

Actually I think we should fix this in a different way. Rather than creating
the fake /proc/filesystems file in the cache dir, I think we should create it
in a tmpdir. It's just bind-mounted into the chroot and then deleted so there's
no reason to save it. 

So I think we should rework the selinux plugin to ues the tempfile module, create a temp file, use that for the bind-mount, then remove the file when unloaded.
Comment 4 Clark Williams 2010-09-01 09:36:42 EDT
Created attachment 442411 [details]
modification to the fake '/proc/filesystems' file generated by the selinux plugin

I was thinking that we could change the selinux plugin to use tempfile rather than putting the data file in the cachedir (which might not be there)
Comment 5 Jan Vcelak 2010-09-06 09:29:16 EDT
Clark, you are right. Creating fake 'filesystems' in tmpdir instead of cachedir seems much more reasonable to me.
Comment 6 Clark Williams 2010-10-14 23:20:19 EDT
New build (mock-1.1.6) that does this and also sets appropriate permissions for the fake /proc/filesystems

https://koji.fedoraproject.org/koji/buildinfo?buildID=200570
Comment 7 Fedora Update System 2010-10-20 11:41:08 EDT
mock-1.1.6-1.fc13 has been submitted as an update for Fedora 13.
https://admin.fedoraproject.org/updates/mock-1.1.6-1.fc13
Comment 8 Fedora Update System 2010-10-20 11:41:38 EDT
mock-1.1.6-1.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/mock-1.1.6-1.fc14
Comment 9 Fedora Update System 2010-10-20 11:43:45 EDT
mock-1.0.13-1.el5 has been submitted as an update for Fedora EPEL 5.
https://admin.fedoraproject.org/updates/mock-1.0.13-1.el5
Comment 10 Fedora Update System 2010-10-20 11:46:09 EDT
mock-1.0.13-1.fc12 has been submitted as an update for Fedora 12.
https://admin.fedoraproject.org/updates/mock-1.0.13-1.fc12
Comment 11 Fedora Update System 2010-10-21 01:56:13 EDT
mock-1.1.6-1.fc13 has been pushed to the Fedora 13 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update mock'.  You can provide feedback for this update here: https://admin.fedoraproject.org/updates/mock-1.1.6-1.fc13
Comment 12 Fedora Update System 2010-10-28 18:21:49 EDT
mock-1.1.6-1.fc13 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 13 Fedora Update System 2010-11-01 16:58:21 EDT
mock-1.1.6-1.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 14 Fedora Update System 2010-12-14 11:13:54 EST
mock-1.0.14-1.el5 has been submitted as an update for Fedora EPEL 5.
https://admin.fedoraproject.org/updates/mock-1.0.14-1.el5
Comment 15 Fedora Update System 2011-01-18 15:04:05 EST
mock-1.0.15-1.el5 has been submitted as an update for Fedora EPEL 5.
https://admin.fedoraproject.org/updates/mock-1.0.15-1.el5
Comment 16 Fedora Update System 2011-02-19 21:26:15 EST
mock-1.1.9-1.fc13 has been submitted as an update for Fedora 13.
https://admin.fedoraproject.org/updates/mock-1.1.9-1.fc13
Comment 17 Fedora Update System 2011-02-19 21:29:25 EST
mock-1.0.16-1.el5 has been submitted as an update for Fedora EPEL 5.
https://admin.fedoraproject.org/updates/mock-1.0.16-1.el5
Comment 18 Fedora Update System 2011-02-19 21:32:18 EST
mock-1.1.9-1.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/mock-1.1.9-1.el6
Comment 19 Fedora Update System 2011-02-19 21:35:11 EST
mock-1.1.9-1.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/mock-1.1.9-1.fc14
Comment 20 Fedora Update System 2011-03-03 03:24:51 EST
mock-1.1.9-1.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 21 Fedora Update System 2011-03-03 03:33:45 EST
mock-1.1.9-1.fc13 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 22 Fedora Update System 2011-05-13 16:33:56 EDT
mock-1.1.10-1.fc15 has been submitted as an update for Fedora 15.
https://admin.fedoraproject.org/updates/mock-1.1.10-1.fc15
Comment 23 Fedora Update System 2011-05-13 16:38:38 EDT
mock-1.1.10-1.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/mock-1.1.10-1.fc14
Comment 24 Fedora Update System 2011-05-13 16:42:55 EDT
mock-1.0.17-1.el5 has been submitted as an update for Fedora EPEL 5.
https://admin.fedoraproject.org/updates/mock-1.0.17-1.el5
Comment 25 Fedora Update System 2011-05-13 16:47:13 EDT
mock-1.1.10-1.fc13 has been submitted as an update for Fedora 13.
https://admin.fedoraproject.org/updates/mock-1.1.10-1.fc13
Comment 26 Fedora Update System 2011-05-13 16:51:25 EDT
mock-1.1.10-1.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/mock-1.1.10-1.el6
Comment 27 Fedora Update System 2011-05-19 00:35:18 EDT
mock-1.1.10-1.fc15 has been pushed to the Fedora 15 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 28 Fedora Update System 2011-05-24 22:42:42 EDT
mock-1.1.10-1.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 29 Fedora Update System 2011-05-24 23:17:04 EDT
mock-1.1.10-1.fc13 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 30 Fedora Update System 2011-06-02 15:06:52 EDT
mock-1.0.17-1.el5 has been pushed to the Fedora EPEL 5 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 31 Fedora Update System 2011-06-02 15:16:49 EDT
mock-1.1.10-1.el6 has been pushed to the Fedora EPEL 6 stable repository.  If problems still persist, please make note of it in this bug report.

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