diff options
author | David Mulder <dmulder@suse.com> | 2018-07-13 14:45:06 -0600 |
---|---|---|
committer | Aurélien Aptel <aaptel@samba.org> | 2018-10-08 18:17:14 +0200 |
commit | 5dddb784f8214e2b6753b7544cf4cb9eb3829a90 (patch) | |
tree | d5801ee7c840114c221bdfb4a47270d632e5f046 | |
parent | f5c6bd5c843ce519170a16f885bfb0d742af6b97 (diff) | |
download | samba-5dddb784f8214e2b6753b7544cf4cb9eb3829a90.tar.gz |
gpo: Initialize SamDB in the gp_sec_ext
The SamDB is only used by the gp_sec_ext, and
isn't needed elsewhere, so initialize it where
we need it and avoid passing it around
everywhere.
It makes the most sense to put this in the setter
class that uses it, so pass our creds down so we
have access to it, then initialize it there.
Signed-off-by: David Mulder <dmulder@suse.com>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Aurelien Aptel <aaptel@suse.com>
-rw-r--r-- | python/samba/gpclass.py | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/python/samba/gpclass.py b/python/samba/gpclass.py index db388fa9755..048b25b4105 100644 --- a/python/samba/gpclass.py +++ b/python/samba/gpclass.py @@ -313,10 +313,10 @@ class gp_ext(object): def read(self, policy): pass - def parse(self, afile, ldb, gp_db, lp): - self.ldb = ldb + def parse(self, afile, gp_db, lp, creds): self.gp_db = gp_db self.lp = lp + self.creds = creds local_path = self.lp.cache_path('gpo_cache') data_file = os.path.join(local_path, check_safe_path(afile).upper()) @@ -329,15 +329,15 @@ class gp_ext(object): pass -class gp_ext_setter(): +class gp_ext_setter(object): __metaclass__ = ABCMeta - def __init__(self, logger, ldb, gp_db, lp, attribute, val): + def __init__(self, logger, gp_db, lp, creds, attribute, val): self.logger = logger - self.ldb = ldb self.attribute = attribute self.val = val self.lp = lp + self.creds = creds self.gp_db = gp_db def explicit(self): @@ -385,8 +385,8 @@ class gp_inf_ext(gp_ext): (att, setter) = current_section.get(key) value = value.encode('ascii', 'ignore') ret = True - setter(self.logger, self.ldb, self.gp_db, self.lp, att, - value).update_samba() + setter(self.logger, self.gp_db, self.lp, + self.creds, att, value).update_samba() self.gp_db.commit() return ret @@ -457,7 +457,7 @@ def gpo_version(lp, path): return int(gpo.gpo_get_sysvol_gpt_version(gpt_path)[1]) -def apply_gp(lp, creds, test_ldb, logger, store, gp_extensions): +def apply_gp(lp, creds, logger, store, gp_extensions): gp_db = store.get_gplog(creds.get_username()) dc_hostname = get_dc_hostname(creds, lp) gpos = get_gpo_list(dc_hostname, creds, lp) @@ -483,7 +483,7 @@ def apply_gp(lp, creds, test_ldb, logger, store, gp_extensions): store.start() for ext in gp_extensions: try: - ext.parse(ext.list(path), test_ldb, gp_db, lp) + ext.parse(ext.list(path), gp_db, lp, creds) except Exception as e: logger.error('Failed to parse gpo %s for extension %s' % (guid, str(ext))) @@ -503,14 +503,14 @@ def unapply_log(gp_db): break -def unapply_gp(lp, creds, test_ldb, logger, store, gp_extensions): +def unapply_gp(lp, creds, logger, store, gp_extensions): gp_db = store.get_gplog(creds.get_username()) gp_db.state(GPOSTATE.UNAPPLY) for gpo_guid in unapply_log(gp_db): gp_db.set_guid(gpo_guid) unapply_attributes = gp_db.list(gp_extensions) for attr in unapply_attributes: - attr_obj = attr[-1](logger, test_ldb, gp_db, lp, attr[0], attr[1]) + attr_obj = attr[-1](logger, gp_db, lp, attr[0], attr[1]) attr_obj.mapper()[attr[0]][0](attr[1]) # Set the old value gp_db.delete(str(attr_obj), attr[0]) gp_db.commit() |