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
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)
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))
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))
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
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
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