mirror of
https://github.com/samba-team/samba.git
synced 2025-12-14 20:23:54 +03:00
fdeploy_ini: Generalize the share name SIDs
This overrides the custom entity handler defined in the top level parser. Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
committed by
Andrew Bartlett
parent
abff0c4f4d
commit
3ff695fd36
@@ -20,6 +20,7 @@
|
||||
from xml.dom import minidom
|
||||
from io import BytesIO
|
||||
from xml.etree.ElementTree import ElementTree, fromstring, tostring
|
||||
from hashlib import md5
|
||||
|
||||
|
||||
ENTITY_USER_ID = 0
|
||||
@@ -79,8 +80,8 @@ class GPParser(object):
|
||||
minidom_parsed = minidom.parseString(temporary_bytes.getvalue())
|
||||
handle.write(minidom_parsed.toprettyxml(encoding=self.output_encoding))
|
||||
|
||||
def new_xml_entity(self, global_entities, ent_type):
|
||||
identifier = str(len(global_entities)).zfill(4)
|
||||
def new_xml_entity(self, name, ent_type):
|
||||
identifier = md5(name).hexdigest()
|
||||
|
||||
type_str = entity_type_to_string(ent_type)
|
||||
|
||||
@@ -109,7 +110,7 @@ class GPParser(object):
|
||||
elem.text = global_entities[old_text]
|
||||
entities.append((elem.text, old_text))
|
||||
else:
|
||||
elem.text = self.new_xml_entity(global_entities,
|
||||
elem.text = self.new_xml_entity(old_text,
|
||||
ENTITY_USER_ID)
|
||||
|
||||
entities.append((elem.text, old_text))
|
||||
@@ -128,7 +129,7 @@ class GPParser(object):
|
||||
elem.text = global_entities[old_text]
|
||||
entities.append((elem.text, old_text))
|
||||
else:
|
||||
elem.text = self.new_xml_entity(global_entities,
|
||||
elem.text = self.new_xml_entity(old_text,
|
||||
ENTITY_SDDL_ACL)
|
||||
|
||||
entities.append((elem.text, old_text))
|
||||
@@ -156,7 +157,7 @@ class GPParser(object):
|
||||
to_put = global_entities[old_text]
|
||||
entities.append((to_put, old_text))
|
||||
else:
|
||||
to_put = self.new_xml_entity(global_entities,
|
||||
to_put = self.new_xml_entity(old_text,
|
||||
ENTITY_NETWORK_PATH)
|
||||
elem.text = to_put + remaining
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ from ConfigParser import ConfigParser
|
||||
from xml.etree.ElementTree import Element, SubElement
|
||||
from StringIO import StringIO
|
||||
|
||||
from samba.gp_parse import GPParser
|
||||
from samba.gp_parse import GPParser, ENTITY_USER_ID
|
||||
|
||||
# [MS-GPFR] Group Policy Folder Redirection
|
||||
# [MS-GPSCR] Scripts Extension
|
||||
@@ -195,3 +195,23 @@ class GPFDeploy1IniParser(GPIniParser):
|
||||
|
||||
self.ini_conf.add_section(section_name)
|
||||
return section_name
|
||||
|
||||
def custom_entities(self, root, global_entities):
|
||||
entities = []
|
||||
fdeploy_sids = root.findall('.//Section[@fdeploy_SID]')
|
||||
fdeploy_sids.sort()
|
||||
|
||||
for sid in fdeploy_sids:
|
||||
old_attrib = sid.attrib['fdeploy_SID']
|
||||
|
||||
if old_attrib in global_entities:
|
||||
new_attrib = global_entities[old_attrib]
|
||||
else:
|
||||
new_attrib = self.new_xml_entity(old_attrib, ENTITY_USER_ID)
|
||||
entities.append((new_attrib, old_attrib))
|
||||
|
||||
global_entities.update([(old_attrib, new_attrib)])
|
||||
|
||||
sid.attrib['fdeploy_SID'] = new_attrib
|
||||
|
||||
return entities
|
||||
|
||||
Reference in New Issue
Block a user