From: David Mulder Date: Tue, 18 Apr 2023 19:34:46 +0000 (-0600) Subject: gp: Fix NameError: free variable 'cron_dir' in Crontab CSE X-Git-Tag: talloc-2.4.1~888 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6e525d55d98568ac6f0f89b78de5a4cebedb0dc2;p=thirdparty%2Fsamba.git gp: Fix NameError: free variable 'cron_dir' in Crontab CSE 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 Reviewed-by: Andreas Schneider Autobuild-User(master): David Mulder Autobuild-Date(master): Wed Apr 19 21:21:10 UTC 2023 on atb-devel-224 --- diff --git a/python/samba/gp/gp_centrify_crontab_ext.py b/python/samba/gp/gp_centrify_crontab_ext.py index 414cd90aaf7..e8ffd8bec9f 100644 --- a/python/samba/gp/gp_centrify_crontab_ext.py +++ b/python/samba/gp/gp_centrify_crontab_ext.py @@ -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