Univention Bugzilla – Bug 53828
load_default fails with shares which have consecutive whitespaces
Last modified: 2021-10-06 16:48:58 CEST
+++ This bug was initially created as a clone of Bug #53799 +++ This bug was initially filed in ucsschool. If any share-name includes consecutive whitespaces, this code fails: from samba.param import LoadParm lp.load_default() Reproduce this by creating a class (which will create a share) with the following name: DEMOSCHOOL-Ch GK We think this has to be fixed upstream in samba. In school we will write a diagnose module in 53464 and - if needed - prevent classes / workgroups with consecutive whitespaces.
services/univention-samba/python/share_restrictions.py|42 col 1 error| 'urllib' imported but unused [F401] [python/flake8]
The code change looks wrong. Quoting/Encoding should be done at the place where values are inserted into a format/protocol/etc.
Here is a correct fix: diff --git services/univention-samba/python/share_restrictions.py services/univention-samba/python/share_restrictions.py index 9ae457e39e..e2151d6afb 100644 --- services/univention-samba/python/share_restrictions.py +++ services/univention-samba/python/share_restrictions.py @@ -39,7 +39,6 @@ from six.moves.urllib_parse import quote import os import re import shlex -import urllib # defaults ucr = ConfigRegistry() @@ -174,7 +173,6 @@ class ShareConfiguration(object): except IndexError: continue - share.name = quote(share.name, safe='') if cfg.has_option(share.name, Restrictions.INVALID_USERS): share.invalid_users = shlex.split(cfg.get(share.name, Restrictions.INVALID_USERS)) if cfg.has_option(share.name, Restrictions.HOSTS_DENY): @@ -353,7 +351,7 @@ class ShareConfiguration(object): # write share conf only if we have ucr settings if not share.ucr: continue - share_filename = os.path.join(ShareConfiguration.SHARES_DIR, share.name + ShareConfiguration.POSTFIX) + share_filename = os.path.join(ShareConfiguration.SHARES_DIR, quote(share.name, safe='') + ShareConfiguration.POSTFIX) with open(share_filename, "w") as fd: fd.write("[" + share.name + "]\n") for option in share:
Thanks for the comment! new fix was built with Package: univention-samba Version: 14.0.4-6A~5.0.0.202109241043 Branch: ucs_5.0-0 Scope: errata5.0-0
Jenkins -> OK yaml -> OK As discussed, this fixes parsing samba share settings using python. It does not fix accessing shares with consecutive whitespaces, see bug 53880.
<https://errata.software-univention.de/#/?erratum=5.0x113>