mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
samba-tool: gpo show/load handle utf-16-le strings
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Tested-by: Kees van Vloten <keesvanvloten@gmail.com>
This commit is contained in:
parent
e603270360
commit
3b0d78a3fd
@ -82,6 +82,7 @@ from samba.netcmd.gpcommon import (
|
||||
get_gpo_dn
|
||||
)
|
||||
from samba.policies import RegistryGroupPolicies
|
||||
from samba.dcerpc.misc import REG_MULTI_SZ
|
||||
|
||||
|
||||
def gpo_flags_string(value):
|
||||
@ -669,7 +670,11 @@ class cmd_show(GPOCommand):
|
||||
defs['data'] = entry.data
|
||||
# Bytes aren't JSON serializable
|
||||
if type(defs['data']) == bytes:
|
||||
defs['data'] = list(defs['data'])
|
||||
if entry.type == REG_MULTI_SZ:
|
||||
data = defs['data'].decode('utf-16-le')
|
||||
defs['data'] = data.rstrip('\x00').split('\x00')
|
||||
else:
|
||||
defs['data'] = list(defs['data'])
|
||||
policy_defs.append(defs)
|
||||
self.outf.write("Policies :\n")
|
||||
json.dump(policy_defs, self.outf, indent=4)
|
||||
|
@ -39,7 +39,7 @@ from samba.gp_parse.gp_ini import GPTIniParser
|
||||
from samba.common import get_string
|
||||
from samba.dcerpc import security
|
||||
from samba.ntacls import dsacl2fsacl
|
||||
from samba.dcerpc.misc import GUID
|
||||
from samba.dcerpc.misc import REG_BINARY, REG_MULTI_SZ, REG_SZ, GUID
|
||||
|
||||
GPT_EMPTY = \
|
||||
"""
|
||||
@ -125,8 +125,13 @@ class RegistryGroupPolicies(object):
|
||||
|
||||
def __set_data(self, rtype, data):
|
||||
# JSON can't store bytes, and have to be set via an int array
|
||||
if rtype == 3 and type(data) == list: # REG_BINARY
|
||||
if rtype == REG_BINARY and type(data) == list:
|
||||
return bytes(data)
|
||||
elif rtype == REG_MULTI_SZ and type(data) == list:
|
||||
data = ('\x00').join(data) + '\x00\x00'
|
||||
return data.encode('utf-16-le')
|
||||
elif rtype == REG_SZ and type(data) == str:
|
||||
return data.encode('utf-8')
|
||||
return data
|
||||
|
||||
def __pol_replace(self, pol_data, entry):
|
||||
|
Loading…
Reference in New Issue
Block a user