From: David Mulder Date: Thu, 25 Jun 2020 20:14:09 +0000 (-0600) Subject: gpo: Apply Group Policy Hourly Scripts X-Git-Tag: talloc-2.3.2~938 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=42f043ab5154e4c53a6b940c764ccade688ff439;p=thirdparty%2Fsamba.git gpo: Apply Group Policy Hourly Scripts Signed-off-by: David Mulder Reviewed-by: Douglas Bagnall --- diff --git a/libgpo/admx/en-US/samba.adml b/libgpo/admx/en-US/samba.adml index b5fc5098638..55dae86199d 100755 --- a/libgpo/admx/en-US/samba.adml +++ b/libgpo/admx/en-US/samba.adml @@ -8,12 +8,17 @@ Samba Unix Settings Daily Scripts + Hourly Scripts This policy setting allows you to execute commands, either local or on remote storage, daily. + This policy setting allows you to execute commands, either local or on remote storage, hourly. Script and arguments + + Script and arguments + diff --git a/libgpo/admx/samba.admx b/libgpo/admx/samba.admx index f2921ff1885..1a67bddf809 100755 --- a/libgpo/admx/samba.admx +++ b/libgpo/admx/samba.admx @@ -19,5 +19,12 @@ + + + + + + + diff --git a/python/samba/gp_scripts_ext.py b/python/samba/gp_scripts_ext.py index f83f367a5d7..93a5ef778cb 100644 --- a/python/samba/gp_scripts_ext.py +++ b/python/samba/gp_scripts_ext.py @@ -21,9 +21,9 @@ from tempfile import NamedTemporaryFile class gp_scripts_ext(gp_pol_ext): def __str__(self): - return 'Unix Settings/Daily Scripts' + return 'Unix Settings/Scripts' - def process_group_policy(self, deleted_gpo_list, changed_gpo_list, cdir='/etc/cron.daily'): + def process_group_policy(self, deleted_gpo_list, changed_gpo_list, cdir=None): for gpo in deleted_gpo_list: self.gp_db.set_guid(gpo[0]) if str(self) in gpo[1]: @@ -34,7 +34,9 @@ class gp_scripts_ext(gp_pol_ext): for gpo in changed_gpo_list: if gpo.file_sys_path: - section_name = 'Software\\Policies\\Samba\\Unix Settings\\Daily Scripts' + reg_key = 'Software\\Policies\\Samba\\Unix Settings' + sections = { '%s\\Daily Scripts' % reg_key : '/etc/cron.daily', + '%s\\Hourly Scripts' % reg_key : '/etc/cron.hourly' } self.gp_db.set_guid(gpo.name) pol_file = 'MACHINE/Registry.pol' path = os.path.join(gpo.file_sys_path, pol_file) @@ -42,11 +44,14 @@ class gp_scripts_ext(gp_pol_ext): if not pol_conf: continue for e in pol_conf.entries: - if e.keyname == section_name and e.data.strip(): - attribute = b64encode(e.data.encode()).decode() + if e.keyname in sections.keys() and e.data.strip(): + cron_dir = sections[e.keyname] if not cdir else cdir + attribute = '%s:%s' % (e.keyname, + b64encode(e.data.encode()).decode()) old_val = self.gp_db.retrieve(str(self), attribute) if not old_val: - with NamedTemporaryFile(mode="w+", delete=False, dir=cdir) as f: + with NamedTemporaryFile(mode="w+", delete=False, + dir=cron_dir) as f: f.write('#!/bin/sh\n%s' % e.data) os.chmod(f.name, 0o700) self.gp_db.store(str(self), attribute, f.name) diff --git a/selftest/knownfail.d/gpo b/selftest/knownfail.d/gpo deleted file mode 100644 index 27f3459db8b..00000000000 --- a/selftest/knownfail.d/gpo +++ /dev/null @@ -1 +0,0 @@ -^samba.tests.gpo.samba.tests.gpo.GPOTests.test_gp_scripts