gp_ini: Add a scripts ini parser for better generalization
authorGarming Sam <garming@catalyst.net.nz>
Wed, 6 Jun 2018 00:57:12 +0000 (12:57 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 16 Aug 2018 21:42:22 +0000 (23:42 +0200)
We mark the command path argument as a network path.

Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/gp_parse/gp_ini.py
python/samba/netcmd/gpo.py

index f0ef0b2358cfa06cc3fc3d43e9e11f209e84f7b6..4bd00c8ccf17c7e2e5d026c8ca4e98368b9d4472 100644 (file)
@@ -19,6 +19,7 @@
 
 import codecs
 import collections
+import re
 
 from ConfigParser import ConfigParser
 from xml.etree.ElementTree import Element, SubElement
@@ -105,6 +106,20 @@ class GPTIniParser(GPIniParser):
     encoding = 'utf-8'
 
 
+class GPScriptsIniParser(GPIniParser):
+    def build_xml_parameter(self, section_xml, section, key_ini, val_ini):
+        parent_return = super(GPScriptsIniParser,
+                              self).build_xml_parameter(section_xml, section,
+                                                        key_ini, val_ini)
+
+        cmdline = re.match('\\d+CmdLine$', key_ini)
+        if cmdline is not None:
+            value = parent_return.find('Value')
+            value.attrib['network_path'] = 'TRUE'
+
+        return parent_return
+
+
 class GPFDeploy1IniParser(GPIniParser):
     def build_xml_parameter(self, section_xml, section, key_ini, val_ini):
         parent_return = super(GPFDeploy1IniParser,
index c4d1bd9a1f5afcf71a7d74badc22dadb10cd2ffe..9706ca8a83331290b415e03da9a47bf4337f052b 100644 (file)
@@ -50,7 +50,12 @@ from samba.dcerpc import nbt
 from samba.net import Net
 from samba.gp_parse import GPParser, GPNoParserException
 from samba.gp_parse.gp_pol import GPPolParser
-from samba.gp_parse.gp_ini import GPIniParser, GPTIniParser, GPFDeploy1IniParser
+from samba.gp_parse.gp_ini import (
+    GPIniParser,
+    GPTIniParser,
+    GPFDeploy1IniParser,
+    GPScriptsIniParser
+)
 from samba.gp_parse.gp_csv import GPAuditCsvParser
 from samba.gp_parse.gp_inf import GptTmplInfParser
 from samba.gp_parse.gp_aas import GPAasParser
@@ -251,6 +256,10 @@ def find_parser(name, flags=re.IGNORECASE):
         return GptTmplInfParser()
     if re.match('GPT\.INI$', name, flags=flags):
         return GPTIniParser()
+    if re.match('scripts.ini$', name, flags=flags):
+        return GPScriptsIniParser()
+    if re.match('psscripts.ini$', name, flags=flags):
+        return GPScriptsIniParser()
     if re.match('.*\.ini$', name, flags=flags):
         return GPIniParser()
     if re.match('.*\.pol$', name, flags=flags):