From: David Mulder Date: Tue, 9 Mar 2021 16:16:27 +0000 (-0700) Subject: samba-tool: gpo manage sudoers handle missing and dispersed principal names X-Git-Tag: tevent-0.11.0~1567 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=88c9c291b0b928fc404d9f19eb55c5fa62266f93;p=thirdparty%2Fsamba.git samba-tool: gpo manage sudoers handle missing and dispersed principal names 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 Reviewed-by: Björn Baumbach --- diff --git a/python/samba/netcmd/gpo.py b/python/samba/netcmd/gpo.py index cb70367509e..30563431874 100644 --- a/python/samba/netcmd/gpo.py +++ b/python/samba/netcmd/gpo.py @@ -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 index 1c578f3bc2c..00000000000 --- a/selftest/knownfail.d/gpo +++ /dev/null @@ -1 +0,0 @@ -^samba.tests.samba_tool.gpo.samba.tests.samba_tool.gpo.GpoCmdTestCase.test_sudoers_list