Bug 1018359 - [PATCH] Pass values of --plugin-option through literal_eval
[PATCH] Pass values of --plugin-option through literal_eval
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: mock (Show other bugs)
rawhide
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Clark Williams
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-11 14:47 EDT by Sandro Mani
Modified: 2016-07-07 08:08 EDT (History)
3 users (show)

See Also:
Fixed In Version: mock-1.1.38-1.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-11-10 01:37:44 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Patch (826 bytes, patch)
2013-10-11 14:47 EDT, Sandro Mani
no flags Details | Diff

  None (edit)
Description Sandro Mani 2013-10-11 14:47:31 EDT
Created attachment 811342 [details]
Patch

Description of problem:
The value of --plugin-option is set to be of type string when adding the option to the OptionParser. The values are then passed as string to the respective option receivers. This makes it impossible to pass i.e. bind_mount:dirs via --plugin-option, since bind_mount.py expects dirs to be an 2d-iterable (i.e. tuple of tuples), but it will get a string.

One possibly clean fix would be to pass all values of --plugin-option though literal_eval. If literal_eval fails, then it is likely an actual string, and it is kept as such. Otherwise, the string is parsed to a python object.
The only risk is that the user passes an argument which should be a string but also is valid python syntax. To avoid these issues, the user should quote the value, i.e.
--plugin-option="myplugin:key='value'"

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

How reproducible:
Always

Steps to Reproduce:
1. Try to pass --plugin-option="bind_mount:dirs=(('/foo','/bar')) to mock
2. The bind_mount plugin will fail parsing the dirs option
Comment 1 Clark Williams 2013-10-27 00:54:38 EDT
Applied for mock-1.1.34 release
Comment 2 Fedora Update System 2013-10-30 10:58:51 EDT
mock-1.1.34-1.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/mock-1.1.34-1.fc18
Comment 3 Fedora Update System 2013-10-30 11:00:47 EDT
mock-1.1.34-1.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/mock-1.1.34-1.el6
Comment 4 Fedora Update System 2013-10-30 11:03:11 EDT
mock-1.1.34-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/mock-1.1.34-1.fc20
Comment 5 Fedora Update System 2013-10-30 11:05:11 EDT
mock-1.1.34-1.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/mock-1.1.34-1.fc19
Comment 6 Fedora Update System 2013-10-30 13:12:54 EDT
Package mock-1.1.34-1.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing mock-1.1.34-1.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-20329/mock-1.1.34-1.fc20
then log in and leave karma (feedback).
Comment 7 Fedora Update System 2013-11-05 00:33:18 EST
mock-1.1.35-1.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/mock-1.1.35-1.fc19
Comment 8 Fedora Update System 2013-11-05 00:34:45 EST
mock-1.1.35-1.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/mock-1.1.35-1.fc18
Comment 9 Fedora Update System 2013-11-05 00:36:05 EST
mock-1.1.35-1.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/mock-1.1.35-1.el6
Comment 10 Fedora Update System 2013-11-05 00:37:20 EST
mock-1.1.35-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/mock-1.1.35-1.fc20
Comment 11 Fedora Update System 2013-11-10 01:37:44 EST
mock-1.1.35-1.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 12 Fedora Update System 2014-02-05 21:10:11 EST
mock-1.1.36-1.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/mock-1.1.36-1.fc19
Comment 13 Fedora Update System 2014-02-05 21:11:43 EST
mock-1.1.36-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/mock-1.1.36-1.fc20
Comment 14 Fedora Update System 2014-02-05 21:13:12 EST
mock-1.1.36-1.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/mock-1.1.36-1.el6
Comment 15 Fedora Update System 2014-02-08 00:04:07 EST
mock-1.1.36-1.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 16 Fedora Update System 2014-03-25 16:26:18 EDT
mock-1.1.37-1.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/mock-1.1.37-1.fc19
Comment 17 Fedora Update System 2014-03-25 16:28:32 EDT
mock-1.1.37-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/mock-1.1.37-1.fc20
Comment 18 Fedora Update System 2014-03-25 16:30:25 EDT
mock-1.1.37-1.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/mock-1.1.37-1.el6
Comment 19 Fedora Update System 2014-03-27 13:48:56 EDT
mock-1.1.37-2.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/mock-1.1.37-2.fc20
Comment 20 Fedora Update System 2014-03-27 13:50:50 EDT
mock-1.1.37-2.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/mock-1.1.37-2.fc19
Comment 21 Fedora Update System 2014-03-27 13:52:49 EDT
mock-1.1.37-2.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/mock-1.1.37-2.el6
Comment 22 Fedora Update System 2014-03-31 15:05:51 EDT
mock-1.1.38-1.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/mock-1.1.38-1.fc19
Comment 23 Fedora Update System 2014-03-31 15:07:55 EDT
mock-1.1.38-1.el6 has been submitted as an update for Fedora EPEL 6.
https://admin.fedoraproject.org/updates/mock-1.1.38-1.el6
Comment 24 Fedora Update System 2014-03-31 15:09:52 EDT
mock-1.1.38-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/mock-1.1.38-1.fc20
Comment 25 Fedora Update System 2014-04-09 09:20:18 EDT
mock-1.1.38-1.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 26 Fedora Update System 2014-04-18 11:38:57 EDT
mock-1.1.38-1.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 27 Fedora Update System 2014-04-19 05:21:11 EDT
mock-1.1.38-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.
Comment 28 Vit Ry 2016-07-07 08:08:46 EDT
Test with mock-1.2.17-1.el7.noarch.

mock with argument
--plugin-option="bind_mount:dirs=(('/foo','/bar'))

still fails like

$ mock --plugin-option="bind_mount:dirs=(('/public','/tmp/t1'))" --shell
INFO: mock.py version 1.2.17 starting (python version = 2.7.5)...
Start: init plugins
ERROR: too many values to unpack
Traceback (most recent call last):
  File "/usr/sbin/mock", line 849, in <module>
    main()
  File "/usr/lib/python2.7/site-packages/mockbuild/trace_decorator.py", line 88, in trace
    result = func(*args, **kw)
  File "/usr/sbin/mock", line 635, in main
    buildroot = Buildroot(config_opts, uidManager, state, plugins)
  File "/usr/lib/python2.7/site-packages/mockbuild/trace_decorator.py", line 88, in trace
    result = func(*args, **kw)
  File "/usr/lib/python2.7/site-packages/mockbuild/buildroot.py", line 68, in __init__
    self.plugins.init_plugins(self)
  File "/usr/lib/python2.7/site-packages/mockbuild/trace_decorator.py", line 88, in trace
    result = func(*args, **kw)
  File "/usr/lib/python2.7/site-packages/mockbuild/plugin.py", line 56, in init_plugins
    module.init(self, self.plugin_conf["{0}_opts".format(plugin)], buildroot)
  File "/usr/lib/python2.7/site-packages/mockbuild/trace_decorator.py", line 88, in trace
    result = func(*args, **kw)
  File "/usr/lib/python2.7/site-packages/mockbuild/plugins/bind_mount.py", line 22, in init
    BindMount(plugins, conf, buildroot)
  File "/usr/lib/python2.7/site-packages/mockbuild/trace_decorator.py", line 88, in trace
    result = func(*args, **kw)
  File "/usr/lib/python2.7/site-packages/mockbuild/plugins/bind_mount.py", line 34, in __init__
    for srcdir, destdir in self.bind_opts['dirs']:
ValueError: too many values to unpack

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