ipalib: Handle percent signs in saved values

Turn off string interpolation on the FileStore class to avoid
exceptions when a value to be saved contains a percent sign (%).
The underlying SafeConfigParser that is used interprets percent
signs as placeholders to be interpolated which then causes an
exception as the placeholder isn't properly formatted.

ipa-client-install uses the FileStore class to backup certain
values that it overwrites as part of the installation. If those
pre-existing, backed-up values contained a percent sign,
ipa-client-install would throw an exception and thus prevent
installation.

https://pagure.io/freeipa/issue/9085

Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
Brian Turek authored and Alexander Bokovoy committed 2022-02-11 13:35:32 +02:00
1 parent a78f9f7fc9
commit ba796e389b
1 file changed
+4 -4
+4 -4
View File
@@ -82,7 +82,7 @@ class FileStore:
self.files = {}
p = SafeConfigParser()
p = SafeConfigParser(interpolation=None)
p.optionxform = str
p.read(self._index)
@@ -103,7 +103,7 @@ class FileStore:
os.remove(self._index)
return
p = SafeConfigParser()
p = SafeConfigParser(interpolation=None)
p.optionxform = str
p.add_section('files')
@@ -344,7 +344,7 @@ class StateFile:
self.modules = {}
p = SafeConfigParser()
p = SafeConfigParser(interpolation=None)
p.optionxform = str
p.read(self._path)
@@ -373,7 +373,7 @@ class StateFile:
os.remove(self._path)
return
p = SafeConfigParser()
p = SafeConfigParser(interpolation=None)
p.optionxform = str
for module in self.modules: