]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
samba-tool: gpo manage sudoers handle missing and dispersed principal names
authorDavid Mulder <dmulder@suse.com>
Tue, 9 Mar 2021 16:16:27 +0000 (09:16 -0700)
committerBjörn Baumbach <bb@sernet.de>
Thu, 11 Mar 2021 20:29:41 +0000 (20:29 +0000)
If we don't anticipate a missing principal name,
samba-tool crashes. Also, principal names could
be in dispersed listelements.

Signed-off-by: David Mulder <dmulder@suse.com>
Reviewed-by: Björn Baumbach <bb@sernet.de>
python/samba/netcmd/gpo.py
selftest/knownfail.d/gpo [deleted file]

index cb70367509ed5ab19ec0970854f8d4594e88dac7..305634318740b828ea8922e11770f5762c81bc46 100644 (file)
@@ -1859,7 +1859,10 @@ samba-tool gpo manage sudoers list {31B2F340-016D-11D2-945F-00C04FB984F9}
         for entry in data.findall('sudoers_entry'):
             command = entry.find('command').text
             user = entry.find('user').text
-            principals = entry.find('listelement').findall('principal')
+            listelements = entry.findall('listelement')
+            principals = []
+            for listelement in listelements:
+                principals.extend(listelement.findall('principal'))
             if len(principals) > 0:
                 uname = ','.join([u.text if u.attrib['type'] == 'user' \
                     else '%s%%' % u.text for u in principals])
@@ -1935,7 +1938,10 @@ samba-tool gpo manage sudoers remove {31B2F340-016D-11D2-945F-00C04FB984F9} 'fak
         for e in data.findall('sudoers_entry'):
             command = e.find('command').text
             user = e.find('user').text
-            principals = e.find('listelement').findall('principal')
+            listelements = e.findall('listelement')
+            principals = []
+            for listelement in listelements:
+                principals.extend(listelement.findall('principal'))
             if len(principals) > 0:
                 uname = ','.join([u.text if u.attrib['type'] == 'user' \
                     else '%s%%' % u.text for u in principals])
diff --git a/selftest/knownfail.d/gpo b/selftest/knownfail.d/gpo
deleted file mode 100644 (file)
index 1c578f3..0000000
+++ /dev/null
@@ -1 +0,0 @@
-^samba.tests.samba_tool.gpo.samba.tests.samba_tool.gpo.GpoCmdTestCase.test_sudoers_list