mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
gpo: Initialize gp_ext variables in constructor
Initialize variables for the gp_ext in the constructor instead of passing them via the parse function. This is a dependency of the "gpo: Implement process_group_policy() gp_ext func" patch, since the parse() function is now called by the ext, instead of by gpupdate within apply_gp(). The parse() function should only take the path variable, to simplify writing Client Side Extensions. Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Aurelien Aptel <aaptel@suse.com>
This commit is contained in:
parent
f702ad943e
commit
4354071b7a
@ -298,8 +298,11 @@ class GPOStorage:
|
||||
class gp_ext(object):
|
||||
__metaclass__ = ABCMeta
|
||||
|
||||
def __init__(self, logger):
|
||||
def __init__(self, logger, lp, creds, store):
|
||||
self.logger = logger
|
||||
self.lp = lp
|
||||
self.creds = creds
|
||||
self.gp_db = store.get_gplog(creds.get_username())
|
||||
|
||||
@abstractmethod
|
||||
def list(self, rootpath):
|
||||
@ -313,11 +316,7 @@ class gp_ext(object):
|
||||
def read(self, policy):
|
||||
pass
|
||||
|
||||
def parse(self, afile, gp_db, lp, creds):
|
||||
self.gp_db = gp_db
|
||||
self.lp = lp
|
||||
self.creds = creds
|
||||
|
||||
def parse(self, afile):
|
||||
local_path = self.lp.cache_path('gpo_cache')
|
||||
data_file = os.path.join(local_path, check_safe_path(afile).upper())
|
||||
if os.path.exists(data_file):
|
||||
@ -483,7 +482,7 @@ def apply_gp(lp, creds, logger, store, gp_extensions):
|
||||
store.start()
|
||||
for ext in gp_extensions:
|
||||
try:
|
||||
ext.parse(ext.list(path), gp_db, lp, creds)
|
||||
ext.parse(ext.list(path))
|
||||
except Exception as e:
|
||||
logger.error('Failed to parse gpo %s for extension %s' %
|
||||
(guid, str(ext)))
|
||||
|
@ -77,12 +77,12 @@ if __name__ == "__main__":
|
||||
lp.configfile)
|
||||
gp_extensions = []
|
||||
if opts.target == 'Computer':
|
||||
gp_extensions.append(gp_sec_ext(logger))
|
||||
gp_extensions.append(gp_sec_ext(logger, lp, creds, store))
|
||||
for ext in machine_exts:
|
||||
gp_extensions.append(ext(logger))
|
||||
gp_extensions.append(ext(logger, lp, creds, store))
|
||||
elif opts.target == 'User':
|
||||
for ext in user_exts:
|
||||
gp_extensions.append(ext(logger))
|
||||
gp_extensions.append(ext(logger, lp, creds, store))
|
||||
|
||||
if not opts.unapply:
|
||||
apply_gp(lp, creds, logger, store, gp_extensions)
|
||||
|
Loading…
Reference in New Issue
Block a user