diff options
author | David Mulder <dmulder@suse.com> | 2021-02-08 13:08:02 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2021-02-24 20:51:30 +0000 |
commit | 329b6c397b988839d73e18968dbdec855a471877 (patch) | |
tree | f3968e1f2cc8f450c1bc8f9b22f75a1d75841e04 | |
parent | 15cec2ac4d7af0fa82c21d0109607aa63c86c15a (diff) | |
download | samba-329b6c397b988839d73e18968dbdec855a471877.tar.gz |
samba-tool: Test gpo manage script startup list command
Signed-off-by: David Mulder <dmulder@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
-rw-r--r-- | python/samba/netcmd/gpo.py | 38 | ||||
-rw-r--r-- | python/samba/tests/samba_tool/gpo.py | 41 | ||||
-rw-r--r-- | selftest/knownfail.d/gpo | 1 |
3 files changed, 80 insertions, 0 deletions
diff --git a/python/samba/netcmd/gpo.py b/python/samba/netcmd/gpo.py index 24ecf664ecf..566fa8b5d9f 100644 --- a/python/samba/netcmd/gpo.py +++ b/python/samba/netcmd/gpo.py @@ -3039,6 +3039,43 @@ class cmd_openssh(SuperCommand): subcommands["list"] = cmd_list_openssh() subcommands["set"] = cmd_set_openssh() +class cmd_list_startup(Command): + """List VGP Startup Script Group Policy from the sysvol + +This command lists the startup script policies currently set on the sysvol. + +Example: +samba-tool gpo manage scripts startup list {31B2F340-016D-11D2-945F-00C04FB984F9} + """ + + synopsis = "%prog <gpo> [options]" + + takes_optiongroups = { + "sambaopts": options.SambaOptions, + "versionopts": options.VersionOptions, + "credopts": options.CredentialsOptions, + } + + takes_options = [ + Option("-H", "--URL", help="LDB URL for database or target server", type=str, + metavar="URL", dest="H"), + ] + + takes_args = ["gpo"] + + def run(self, gpo, H=None, sambaopts=None, credopts=None, versionopts=None): + pass + +class cmd_startup(SuperCommand): + """Manage Startup Scripts Group Policy Objects""" + subcommands = {} + subcommands["list"] = cmd_list_startup() + +class cmd_scripts(SuperCommand): + """Manage Scripts Group Policy Objects""" + subcommands = {} + subcommands["startup"] = cmd_startup() + class cmd_manage(SuperCommand): """Manage Group Policy Objects""" subcommands = {} @@ -3048,6 +3085,7 @@ class cmd_manage(SuperCommand): subcommands["symlink"] = cmd_symlink() subcommands["files"] = cmd_files() subcommands["openssh"] = cmd_openssh() + subcommands["scripts"] = cmd_scripts() class cmd_gpo(SuperCommand): """Group Policy Object (GPO) management.""" diff --git a/python/samba/tests/samba_tool/gpo.py b/python/samba/tests/samba_tool/gpo.py index c57c6786d79..4ecb7a70a39 100644 --- a/python/samba/tests/samba_tool/gpo.py +++ b/python/samba/tests/samba_tool/gpo.py @@ -1120,6 +1120,47 @@ class GpoCmdTestCase(SambaToolCmdTest): os.environ["PASSWORD"])) self.assertNotIn(openssh, out, 'The test entry was still found!') + def test_startup_script_list(self): + lp = LoadParm() + lp.load(os.environ['SERVERCONFFILE']) + local_path = lp.get('path', 'sysvol') + vgp_xml = os.path.join(local_path, lp.get('realm').lower(), 'Policies', + self.gpo_guid, 'Machine/VGP/VTLA/Unix', + 'Scripts/Startup/manifest.xml') + stage = etree.Element('vgppolicy') + policysetting = etree.SubElement(stage, 'policysetting') + pv = etree.SubElement(policysetting, 'version') + pv.text = '1' + name = etree.SubElement(policysetting, 'name') + name.text = 'Unix Scripts' + description = etree.SubElement(policysetting, 'description') + description.text = 'Represents Unix scripts to run on Group Policy clients' + data = etree.SubElement(policysetting, 'data') + listelement = etree.SubElement(data, 'listelement') + script = etree.SubElement(listelement, 'script') + script.text = 'test.sh' + parameters = etree.SubElement(listelement, 'parameters') + parameters.text = '-e' + ret = stage_file(vgp_xml, etree.tostring(stage, 'utf-8')) + self.assertTrue(ret, 'Could not create the target %s' % vgp_xml) + + script_path = '\\'.join(['\\', lp.get('realm').lower(), 'Policies', + self.gpo_guid, 'MACHINE\\VGP\\VTLA\\Unix', + 'Scripts\\Startup', script.text]) + entry = '@reboot root %s %s' % (script_path, parameters.text) + (result, out, err) = self.runsublevelcmd("gpo", ("manage", "scripts", + "startup", "list"), + self.gpo_guid, "-H", + "ldap://%s" % + os.environ["SERVER"], + "-U%s%%%s" % + (os.environ["USERNAME"], + os.environ["PASSWORD"])) + self.assertIn(entry, out, 'The test entry was not found!') + + # Unstage the manifest.xml file + unstage_file(vgp_xml) + def setUp(self): """set up a temporary GPO to work with""" super(GpoCmdTestCase, self).setUp() diff --git a/selftest/knownfail.d/gpo b/selftest/knownfail.d/gpo new file mode 100644 index 00000000000..dcc44cd1bf9 --- /dev/null +++ b/selftest/knownfail.d/gpo @@ -0,0 +1 @@ +^samba.tests.samba_tool.gpo.samba.tests.samba_tool.gpo.GpoCmdTestCase.test_startup_script_list |