Create Registry.pol group policy extension parser
authorDavid Mulder <dmulder@suse.com>
Thu, 9 Aug 2018 15:47:38 +0000 (09:47 -0600)
committerDavid Mulder <dmulder@samba.org>
Tue, 23 Jun 2020 16:32:30 +0000 (16:32 +0000)
Create a parent class for parsing Registry.pol
files by group policy extensions.

Signed-off-by: David Mulder <dmulder@suse.com>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
python/samba/gpclass.py

index 0040f235e6e3d1accc5209794516976fe08686a6..cc574e12a425266577ba13282b48f173ef9bcb56 100644 (file)
@@ -35,6 +35,9 @@ import samba.gpo as gpo
 from samba.param import LoadParm
 from uuid import UUID
 from tempfile import NamedTemporaryFile
+from samba.dcerpc import preg
+from samba.dcerpc import misc
+from samba.ndr import ndr_pack, ndr_unpack
 
 try:
     from enum import Enum
@@ -307,7 +310,7 @@ class gp_ext(object):
         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):
-            return self.read(open(data_file, 'r').read())
+            return self.read(data_file)
         return None
 
     @abstractmethod
@@ -347,7 +350,8 @@ class gp_ext_setter(object):
 
 
 class gp_inf_ext(gp_ext):
-    def read(self, policy):
+    def read(self, data_file):
+        policy = open(data_file, 'r').read()
         inf_conf = ConfigParser()
         inf_conf.optionxform = str
         try:
@@ -357,6 +361,12 @@ class gp_inf_ext(gp_ext):
         return inf_conf
 
 
+class gp_pol_ext(gp_ext):
+    def read(self, data_file):
+        raw = open(data_file, 'rb').read()
+        return ndr_unpack(preg.file, raw)
+
+
 ''' Fetch the hostname of a writable DC '''