From ba796e389b061f03636958e81fade5bc6a207df2 Mon Sep 17 00:00:00 2001 From: Brian Turek Date: Thu, 27 Jan 2022 00:07:26 +0000 Subject: [PATCH] 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 --- ipalib/sysrestore.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ipalib/sysrestore.py b/ipalib/sysrestore.py index 21a69e4c7..7057ec7de 100644 --- a/ipalib/sysrestore.py +++ b/ipalib/sysrestore.py @@ -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: