summaryrefslogtreecommitdiff
path: root/python/samba/gp_parse/gp_inf.py
AgeCommit message (Collapse)AuthorFilesLines
2023-06-23python:samba:gp_parse: Fix code spellingAndreas Schneider1-1/+1
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2020-02-07python: use raw string for regex with escapeDouglas Bagnall1-1/+1
Python regards 'GPT\.INI$' as a string containing an invalid escape sequence '\.', which is ignored (i.e. treated as the literal sequence of those 2 characters), but only after Python has grumbled to itself, and to you if you enabled DeprecationWarnings. The proper thing to do here is use r-strings, like r'GPT\.INI$', which tell Python that all backslashes are literal. Alternatively (as we do once in this patch), the backslash can itself be escaped ('\\'). There are more problems of this nature in the build scripts. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
2019-07-19gp_inf: Read/write files with a UTF-16LE BOM in GptTmpl.infGarming Sam1-3/+6
Regression caused by 16596842a62bec0a9d974c48d64000e3c079254e [MS-GPSB] 2.2 Message Syntax says that you have to write a BOM which I didn't do up until this patch. UTF-16 as input encoding was marked much higher up in the inheritance tree, which got overriden with the Python 3 fixes. I've now marked the encoding much more obviously for this file. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14004 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> Autobuild-User(master): Gary Lockyer <gary@samba.org> Autobuild-Date(master): Fri Jul 19 02:20:47 UTC 2019 on sn-devel-184
2018-11-05python/samba/gp_parse: Fix mulitple encode step with write_sectionNoel Power1-14/+15
In python2 as far as I can see GptTmplInfParser.write_binary more or less works by accident. write_binary creates a writer for the 'utf8' codec, such a writer should consume unicode and emit utf8 encoded bytes. This writer is passed to each of the sections managed by GptTmplInfParser as follows def write_binary(self, filename): with codecs.open(filename, 'wb+', self.encoding) as f: for s in self.sections: self.sections[s].write_section(s, f) And each section type itself is encoding its result to 'utf-16-le' e.g. class UnicodeParam(AbstractParam): def write_section(self, header, fp): fp.write(u'[Unicode]\r\nUnicode=yes\r\n'.encode(self.encoding) But this makes little sense, it seems like sections are encoded to one encoding but the total file is supposed to be encoded as ut8??? Also having an encoding per ParamType doesn't seem correct. Bizarely in PY2 this works and it actually encodes the whole file as utf-16le In PY3 you can't do this as the writer wants to deal with strings not bytes (after the extra encode phase in 'write_section'. So, changes here are to remove the unnecessary encoding in each 'write_section' method, additionally in GptTmplInfParser.write_binary the codecs.open call now uses the correct codec (e.g. 'utf-16-le') to write Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-11-05python/samba/gp_parse: PY3 file -> openNoel Power1-1/+1
'file' no longer exists in PY3 replace with 'open' Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-10-25python/gp_parse/gp_inf: remove unused variablesDouglas Bagnall1-2/+0
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
2018-10-25python/gp_parse/gp_inf: remove shadowed methodDouglas Bagnall1-9/+0
The 'from_xml()' definition is replaced a few lines down Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
2018-08-16gp_inf: Parse the GptTmpl.inf file which stores security settingsGarming Sam1-0/+385
This is NOT an ini file and CANNOT be parsed by Python ConfigParser without losing information (it would likely eat meaningful whitespace and so should not be done). There are three main types of settings: * Name,Mode,ACL * key = value * registry key and value Note: This appears as key=value, but registry keys in the general case may have = in their names, so we record the entire string in order to be as safe as possible. Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>