diff --git a/convert2rhel/toolopts/config.py b/convert2rhel/toolopts/config.py index 8c6cac6635..73c50c38e3 100644 --- a/convert2rhel/toolopts/config.py +++ b/convert2rhel/toolopts/config.py @@ -20,6 +20,7 @@ import copy import logging import os +from sys import version_info import six @@ -151,7 +152,14 @@ def _parse_options_from_config(self, paths): them. :type paths: list[str] """ - config_file = configparser.ConfigParser() + + # The reason for using the RawConfigParser and ConfigParser with interpolation set to None is to prevent + # interpreting % as a sign for string replacement. This interpolation feature would cause convert2rhel to fail + # if the user enters the % character in the config file, for example in the RHSM password. + if version_info.major < 3: + config_file = configparser.RawConfigParser() + else: + config_file = configparser.ConfigParser(interpolation=None) found_opts = {} for path in reversed(paths): diff --git a/convert2rhel/unit_tests/toolopts/config_test.py b/convert2rhel/unit_tests/toolopts/config_test.py index 5762669014..26a6ac51f6 100644 --- a/convert2rhel/unit_tests/toolopts/config_test.py +++ b/convert2rhel/unit_tests/toolopts/config_test.py @@ -86,9 +86,9 @@ def test_options_from_config_files_invalid_head_and_options(self, content, expec ( """\ [subscription_manager] -password = correct_password +password = %correct_password% """, - {"password": "correct_password"}, + {"password": "%correct_password%"}, ), ( """\