Univention Bugzilla – Bug 34215
Undefined variables and insufficient tests of user input in share_restrictions.py
Last modified: 2019-10-16 10:38:03 CEST
I tried to set the following UCR variable to alter the sysvol configuration: ucr set 'samba/share/sysvol/options/root preexec=/usr/bin/logon-logger %U %m %M on' This resulted in multiple tracebacks because of the undefined variables options and match. Once I fixed the issues, the script had problems setting options for the sysvol share which isn't defined. The attached patch works around the issues by correcting the variables and defining any non-existing share. First traceback: Script: /etc/univention/templates/scripts/samba.local.config.py Traceback (most recent call last): File "/etc/univention/templates/scripts/samba.local.config.py", line 40, in <module> conf.read() File "/usr/lib/pymodules/python2.6/univention/lib/share_restrictions.py", line 336, in read self.read_ucr() File "/usr/lib/pymodules/python2.6/univention/lib/share_restrictions.py", line 326, in read_ucr func( ucr[ key ], *match.groups() ) File "/usr/lib/pymodules/python2.6/univention/lib/share_restrictions.py", line 301, in _set_options if match and share and options and value: NameError: global name 'match' is not defined Second traceback after removing match: Script: /etc/univention/templates/scripts/samba.local.config.py Traceback (most recent call last): File "/etc/univention/templates/scripts/samba.local.config.py", line 40, in <module> conf.read() File "/usr/lib/pymodules/python2.6/univention/lib/share_restrictions.py", line 336, in read self.read_ucr() File "/usr/lib/pymodules/python2.6/univention/lib/share_restrictions.py", line 326, in read_ucr func( ucr[ key ], *match.groups() ) File "/usr/lib/pymodules/python2.6/univention/lib/share_restrictions.py", line 301, in _set_options if share and options and value: NameError: global name 'options' is not defined Third traceback after correcting option variable: Script: /etc/univention/templates/scripts/samba.local.config.py Traceback (most recent call last): File "/etc/univention/templates/scripts/samba.local.config.py", line 40, in <module> conf.read() File "/usr/lib/pymodules/python2.6/univention/lib/share_restrictions.py", line 336, in read self.read_ucr() File "/usr/lib/pymodules/python2.6/univention/lib/share_restrictions.py", line 326, in read_ucr func( ucr[ key ], *match.groups() ) File "/usr/lib/pymodules/python2.6/univention/lib/share_restrictions.py", line 302, in _set_options if not option in self._shares[ share ]: KeyError: 'sysvol'
Created attachment 5809 [details] Fix variable definitions and non-existing shares
Still a problem. I've added a simple test case for this (r67683): tests/53_samba-common/49share_local_conf
*** Bug 41508 has been marked as a duplicate of this bug. ***
This was fixed in Bug #46975 git:ff0cee9959c14fc8e3ca7295a0178fb2108e1e6c *** This bug has been marked as a duplicate of bug 46975 ***
Reenable test case: ucs-test (9.0.3-78) ea1a6cb425cc | Bug #34215: reenable test case ucs-test (6.0.33-22) r67683 | 53_samba-common/49share_local_conf: Added new test case which checks