Bug 629041 - selinux plugin expects that yum cache directory exists
Summary: selinux plugin expects that yum cache directory exists
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: mock
Version: 12
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Clark Williams
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-08-31 18:45 UTC by Dan Horák
Modified: 2013-01-10 06:11 UTC (History)
4 users (show)

Fixed In Version: mock-1.1.10-1.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-10-28 22:22:15 UTC
Type: ---
Embargoed:


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

Description Dan Horák 2010-08-31 18:45:33 UTC
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 20:13:19 UTC
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 20:48:55 UTC
(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 21:06:16 UTC
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 13:36:42 UTC
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 13:29:16 UTC
Clark, you are right. Creating fake 'filesystems' in tmpdir instead of cachedir seems much more reasonable to me.

Comment 6 Clark Williams 2010-10-15 03:20:19 UTC
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 15:41:08 UTC
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 15:41:38 UTC
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 15:43:45 UTC
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 15:46:09 UTC
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 05:56:13 UTC
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 22:21:49 UTC
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 20:58:21 UTC
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 16:13:54 UTC
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 20:04:05 UTC
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-20 02:26:15 UTC
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-20 02:29:25 UTC
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-20 02:32:18 UTC
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-20 02:35:11 UTC
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 08:24:51 UTC
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 08:33:45 UTC
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 20:33:56 UTC
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 20:38:38 UTC
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 20:42:55 UTC
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 20:47:13 UTC
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 20:51:25 UTC
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 04:35:18 UTC
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-25 02:42:42 UTC
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-25 03:17:04 UTC
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 19:06:52 UTC
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 19:16:49 UTC
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.