py3: upgradeinstance: decode data before storing them as backup...

...and vice versa
backup requires string not bytes, but ldap provide bytes thus data must
be decoded and encoded from restore

https://fedorahosted.org/freeipa/ticket/4985

Reviewed-By: Jan Cholasta <jcholast@redhat.com>
This commit is contained in:
Martin Basti 2017-01-31 18:53:47 +01:00 committed by Jan Cholasta
parent f31d73b79a
commit 7fd36e4d36

View File

@ -134,21 +134,22 @@ class IPAUpgrade(service.Service):
self.filename)
try:
port = config_entry['nsslapd-port'][0]
port = config_entry['nsslapd-port'][0].decode('utf-8')
except KeyError:
pass
else:
self.backup_state('nsslapd-port', port)
try:
security = config_entry['nsslapd-security'][0]
security = config_entry['nsslapd-security'][0].decode('utf-8')
except KeyError:
pass
else:
self.backup_state('nsslapd-security', security)
try:
global_lock = config_entry['nsslapd-global-backend-lock'][0]
global_lock = config_entry[
'nsslapd-global-backend-lock'][0].decode('utf-8')
except KeyError:
pass
else:
@ -177,16 +178,17 @@ class IPAUpgrade(service.Service):
parser = installutils.ModifyLDIF(in_file, out_file)
if port is not None:
parser.replace_value("cn=config", "nsslapd-port", [port])
parser.replace_value(
"cn=config", "nsslapd-port", [port.encode('utf-8')])
if security is not None:
parser.replace_value("cn=config", "nsslapd-security",
[security])
[security.encode('utf-8')])
# disable global lock by default
parser.remove_value("cn=config", "nsslapd-global-backend-lock")
if global_lock is not None:
parser.add_value("cn=config", "nsslapd-global-backend-lock",
[global_lock])
[global_lock.encode('utf-8')])
parser.parse()