Bug 1018359 - [PATCH] Pass values of --plugin-option through literal_eval
Summary: [PATCH] Pass values of --plugin-option through literal_eval
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: mock
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Clark Williams
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-10-11 18:47 UTC by Sandro Mani
Modified: 2016-07-07 12:08 UTC (History)
3 users (show)

(edit)
Clone Of:
(edit)
Last Closed: 2013-11-10 06:37:44 UTC


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

Description Sandro Mani 2013-10-11 18:47:31 UTC
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 04:54:38 UTC
Applied for mock-1.1.34 release

Comment 2 Fedora Update System 2013-10-30 14:58:51 UTC
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 15:00:47 UTC
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 15:03:11 UTC
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 15:05:11 UTC
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 17:12:54 UTC
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 05:33:18 UTC
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 05:34:45 UTC
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 05:36:05 UTC
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 05:37:20 UTC
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 06:37:44 UTC
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-06 02:10:11 UTC
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-06 02:11:43 UTC
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-06 02:13:12 UTC
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 05:04:07 UTC
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 20:26:18 UTC
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 20:28:32 UTC
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 20:30:25 UTC
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 17:48:56 UTC
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 17:50:50 UTC
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 17:52:49 UTC
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 19:05:51 UTC
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 19:07:55 UTC
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 19:09:52 UTC
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 13:20:18 UTC
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 15:38:57 UTC
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 09:21:11 UTC
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 12:08:46 UTC
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.