From bb83753fe35286af1ef8801787f0a86ab9d51bdb Mon Sep 17 00:00:00 2001 From: David Mulder Date: Tue, 9 Mar 2021 12:30:14 -0700 Subject: [PATCH 1/2] samba-gpupdate: Test that sysvol paths download in case-insensitive way MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: https://bugzilla.samba.org/show_bug.cgi?id=14665 Signed-off-by: David Mulder Reviewed-by: Björn Baumbach (cherry picked from commit 554f2134a9f9638ebd8ac2500e5b6c94b74c27d5) --- python/samba/tests/gpo.py | 10 ++++++++++ selftest/knownfail.d/gpo | 1 + 2 files changed, 11 insertions(+) create mode 100644 selftest/knownfail.d/gpo diff --git a/python/samba/tests/gpo.py b/python/samba/tests/gpo.py index a0dce8d96d7..0afc2091b3e 100644 --- a/python/samba/tests/gpo.py +++ b/python/samba/tests/gpo.py @@ -181,6 +181,16 @@ class GPOTests(tests.TestCase): self.assertEqual(result, after, 'check_safe_path() didn\'t' ' correctly convert \\ to /') + def test_check_safe_path_typesafe_name(self): + path = '\\\\toady.suse.de\\SysVol\\toady.suse.de\\Policies\\' \ + '{31B2F340-016D-11D2-945F-00C04FB984F9}\\GPT.INI' + expected_path = 'toady.suse.de/Policies/' \ + '{31B2F340-016D-11D2-945F-00C04FB984F9}/GPT.INI' + + result = check_safe_path(path) + self.assertEqual(result, expected_path, + 'check_safe_path unable to detect variable case sysvol components') + def test_gpt_ext_register(self): this_path = os.path.dirname(os.path.realpath(__file__)) samba_path = os.path.realpath(os.path.join(this_path, '../../../')) diff --git a/selftest/knownfail.d/gpo b/selftest/knownfail.d/gpo new file mode 100644 index 00000000000..a1c0ac474df --- /dev/null +++ b/selftest/knownfail.d/gpo @@ -0,0 +1 @@ +^samba.tests.gpo.samba.tests.gpo.GPOTests.test_check_safe_path_typesafe_name -- 2.26.2 From 6d2e8014240041baba1694d381e92eefa9d2253a Mon Sep 17 00:00:00 2001 From: David Mulder Date: Tue, 9 Mar 2021 11:13:40 -0700 Subject: [PATCH 2/2] samba-gpupdate: Check sysvol download paths in case-insensitive way MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://bugzilla.samba.org/show_bug.cgi?id=14665 Signed-off-by: David Mulder Reviewed-by: Björn Baumbach (cherry picked from commit 2d6bed495e14349e19ba680bd72c3f110f1c397b) --- python/samba/gpclass.py | 5 +++-- selftest/knownfail.d/gpo | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) delete mode 100644 selftest/knownfail.d/gpo diff --git a/python/samba/gpclass.py b/python/samba/gpclass.py index 1b29711f245..838ef50ac3c 100644 --- a/python/samba/gpclass.py +++ b/python/samba/gpclass.py @@ -393,8 +393,9 @@ def cache_gpo_dir(conn, cache, sub_dir): def check_safe_path(path): dirs = re.split('/|\\\\', path) - if 'sysvol' in path: - dirs = dirs[dirs.index('sysvol') + 1:] + if 'sysvol' in path.lower(): + ldirs = re.split('/|\\\\', path.lower()) + dirs = dirs[ldirs.index('sysvol') + 1:] if '..' not in dirs: return os.path.join(*dirs) raise OSError(path) diff --git a/selftest/knownfail.d/gpo b/selftest/knownfail.d/gpo deleted file mode 100644 index a1c0ac474df..00000000000 --- a/selftest/knownfail.d/gpo +++ /dev/null @@ -1 +0,0 @@ -^samba.tests.gpo.samba.tests.gpo.GPOTests.test_check_safe_path_typesafe_name -- 2.26.2