From: David Mulder Date: Fri, 19 Feb 2021 19:25:00 +0000 (-0700) Subject: samba-tool: Add a gpo command for listing VGP Issue Group Policy X-Git-Tag: tevent-0.11.0~1648 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f5af87fbf8aa4f6a4f95c2e3e85a53846441dd6;p=thirdparty%2Fsamba.git samba-tool: Add a gpo command for listing VGP Issue Group Policy Signed-off-by: David Mulder Reviewed-by: Jeremy Allison --- diff --git a/docs-xml/manpages/samba-tool.8.xml b/docs-xml/manpages/samba-tool.8.xml index e991196143d..2d1920a2c23 100644 --- a/docs-xml/manpages/samba-tool.8.xml +++ b/docs-xml/manpages/samba-tool.8.xml @@ -964,6 +964,11 @@ Sets a VGP MOTD Group Policy to the sysvol + + gpo manage issue list + List VGP Issue Group Policy from the sysvol. + + group Manage groups. diff --git a/python/samba/netcmd/gpo.py b/python/samba/netcmd/gpo.py index bafddfcac59..566f3bf3e9d 100644 --- a/python/samba/netcmd/gpo.py +++ b/python/samba/netcmd/gpo.py @@ -3514,7 +3514,43 @@ samba-tool gpo manage issue list {31B2F340-016D-11D2-945F-00C04FB984F9} takes_args = ["gpo"] def run(self, gpo, H=None, sambaopts=None, credopts=None, versionopts=None): - pass + self.lp = sambaopts.get_loadparm() + self.creds = credopts.get_credentials(self.lp, fallback_machine=True) + + # We need to know writable DC to setup SMB connection + if H and H.startswith('ldap://'): + dc_hostname = H[7:] + self.url = H + else: + dc_hostname = netcmd_finddc(self.lp, self.creds) + self.url = dc_url(self.lp, self.creds, dc=dc_hostname) + + # SMB connect to DC + conn = smb_connection(dc_hostname, + 'sysvol', + lp=self.lp, + creds=self.creds) + + realm = self.lp.get('realm') + vgp_xml = '\\'.join([realm.lower(), 'Policies', gpo, + 'MACHINE\\VGP\\VTLA\\Unix', + 'Issue\\manifest.xml']) + try: + xml_data = ET.fromstring(conn.loadfile(vgp_xml)) + except NTSTATUSError as e: + # STATUS_OBJECT_NAME_INVALID, STATUS_OBJECT_NAME_NOT_FOUND, + # STATUS_OBJECT_PATH_NOT_FOUND + if e.args[0] in [0xC0000033, 0xC0000034, 0xC000003A]: + return # The file doesn't exist, so there is nothing to list + if e.args[0] == 0xC0000022: # STATUS_ACCESS_DENIED + raise CommandError("The authenticated user does " + "not have sufficient privileges") + raise + + policy = xml_data.find('policysetting') + data = policy.find('data') + text = data.find('text') + self.outf.write(text.text) class cmd_issue(SuperCommand): """Manage Issue Group Policy Objects""" diff --git a/selftest/knownfail.d/gpo b/selftest/knownfail.d/gpo deleted file mode 100644 index 03526c6b5cd..00000000000 --- a/selftest/knownfail.d/gpo +++ /dev/null @@ -1 +0,0 @@ -^samba.tests.samba_tool.gpo.samba.tests.samba_tool.gpo.GpoCmdTestCase.test_vgp_issue_list