]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
gp: Fix NameError: free variable 'cron_dir' in Crontab CSE
authorDavid Mulder <dmulder@samba.org>
Tue, 18 Apr 2023 19:34:46 +0000 (13:34 -0600)
committerDavid Mulder <dmulder@samba.org>
Wed, 19 Apr 2023 21:21:10 +0000 (21:21 +0000)
An apply reports the error "NameError: free
variable 'cron_dir' referenced before assignment
in enclosing scope". This only happens when no
policy is defined for this CSE, because existing
policy causes the variable to be defined.

Moved the 'cron_dir' varilable to the correct
scope.

Signed-off-by: David Mulder <dmulder@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): David Mulder <dmulder@samba.org>
Autobuild-Date(master): Wed Apr 19 21:21:10 UTC 2023 on atb-devel-224

python/samba/gp/gp_centrify_crontab_ext.py

index 414cd90aaf794e22967d9470945d7d59dd5d57fa..e8ffd8bec9fbcb358e1bd010665c0672426b711d 100644 (file)
@@ -57,9 +57,9 @@ class gp_centrify_crontab_ext(gp_pol_ext, gp_file_applier):
                 entries = []
                 for e in pol_conf.entries:
                     if e.keyname == section and e.data.strip():
-                        cron_dir = '/etc/cron.d' if not cdir else cdir
                         entries.append(e.data)
                 def applier_func(entries):
+                    cron_dir = '/etc/cron.d' if not cdir else cdir
                     with NamedTemporaryFile(prefix='gp_', mode="w+",
                             delete=False, dir=cron_dir) as f:
                         contents = intro