mirror of
https://github.com/samba-team/samba.git
synced 2025-07-31 20:22:15 +03:00
gpo: Move the file parse function to gp_ext
A file will always be read from the sysvol the same way, but the data will be read differently. This patch moves the parse function to gp_ext, and requires subclasses to implement the read() function to interpret the data. Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
committed by
Douglas Bagnall
parent
1d47ab7e2a
commit
dc41514769
@ -298,9 +298,36 @@ class gp_ext(object):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def parse(self, afile, ldb, conn, gp_db, lp):
|
||||
def read(self, policy):
|
||||
pass
|
||||
|
||||
def parse(self, afile, ldb, conn, gp_db, lp):
|
||||
self.ldb = ldb
|
||||
self.gp_db = gp_db
|
||||
self.lp = lp
|
||||
|
||||
# Fixing the bug where only some Linux Boxes capitalize MACHINE
|
||||
try:
|
||||
blist = afile.split('/')
|
||||
idx = afile.lower().split('/').index('machine')
|
||||
for case in [
|
||||
blist[idx].upper(),
|
||||
blist[idx].capitalize(),
|
||||
blist[idx].lower()
|
||||
]:
|
||||
bfile = '/'.join(blist[:idx]) + '/' + case + '/' + \
|
||||
'/'.join(blist[idx+1:])
|
||||
try:
|
||||
return self.read(conn.loadfile(bfile.replace('/', '\\')))
|
||||
except NTSTATUSError:
|
||||
continue
|
||||
except ValueError:
|
||||
try:
|
||||
return self.read(conn.loadfile(afile.replace('/', '\\')))
|
||||
except Exception as e:
|
||||
self.logger.error(str(e))
|
||||
return None
|
||||
|
||||
@abstractmethod
|
||||
def __str__(self):
|
||||
pass
|
||||
@ -465,11 +492,10 @@ class gp_sec_ext(gp_ext):
|
||||
}
|
||||
}
|
||||
|
||||
def read_inf(self, path, conn):
|
||||
def read(self, policy):
|
||||
ret = False
|
||||
inftable = self.apply_map()
|
||||
|
||||
policy = conn.loadfile(path.replace('/', '\\'))
|
||||
current_section = None
|
||||
|
||||
# So here we would declare a boolean,
|
||||
@ -499,27 +525,3 @@ class gp_sec_ext(gp_ext):
|
||||
self.gp_db.commit()
|
||||
return ret
|
||||
|
||||
def parse(self, afile, ldb, conn, gp_db, lp):
|
||||
self.ldb = ldb
|
||||
self.gp_db = gp_db
|
||||
self.lp = lp
|
||||
|
||||
# Fixing the bug where only some Linux Boxes capitalize MACHINE
|
||||
if afile.endswith('inf'):
|
||||
try:
|
||||
blist = afile.split('/')
|
||||
idx = afile.lower().split('/').index('machine')
|
||||
for case in [blist[idx].upper(), blist[idx].capitalize(),
|
||||
blist[idx].lower()]:
|
||||
bfile = '/'.join(blist[:idx]) + '/' + case + '/' + \
|
||||
'/'.join(blist[idx+1:])
|
||||
try:
|
||||
return self.read_inf(bfile, conn)
|
||||
except NTSTATUSError:
|
||||
continue
|
||||
except ValueError:
|
||||
try:
|
||||
return self.read_inf(afile, conn)
|
||||
except:
|
||||
return None
|
||||
|
||||
|
Reference in New Issue
Block a user