Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sssd: disable interpolation for configparser #124

Merged
merged 1 commit into from
Sep 23, 2024
Merged

Conversation

pbrezina
Copy link
Member

Otherwise using percent sign will raise an error, e.g.:

client.sssd.domain["override_homedir"] = "/home/%u"
self = <configparser.BasicInterpolation object at 0x7fe0fcb46810>
parser = <configparser.ConfigParser object at 0x7fe0fca92fd0>
section = 'domain/test', option = 'override_homedir', value = '/home/%u'

    def before_set(self, parser, section, option, value):
        tmp_value = value.replace('%%', '') # escaped percent signs
        tmp_value = self._KEYCRE.sub('', tmp_value) # valid syntax
        if '%' in tmp_value:
>           raise ValueError("invalid interpolation syntax in %r at "
                             "position %d" % (value, tmp_value.find('%')))
E           ValueError: invalid interpolation syntax in '/home/%u' at position 6

/usr/lib64/python3.11/configparser.py:403: ValueError

Otherwise using percent sign will raise an error, e.g.:

```
client.sssd.domain["override_homedir"] = "/home/%u"
```

```
self = <configparser.BasicInterpolation object at 0x7fe0fcb46810>
parser = <configparser.ConfigParser object at 0x7fe0fca92fd0>
section = 'domain/test', option = 'override_homedir', value = '/home/%u'

    def before_set(self, parser, section, option, value):
        tmp_value = value.replace('%%', '') # escaped percent signs
        tmp_value = self._KEYCRE.sub('', tmp_value) # valid syntax
        if '%' in tmp_value:
>           raise ValueError("invalid interpolation syntax in %r at "
                             "position %d" % (value, tmp_value.find('%')))
E           ValueError: invalid interpolation syntax in '/home/%u' at position 6

/usr/lib64/python3.11/configparser.py:403: ValueError
```
@pbrezina
Copy link
Member Author

@danlavu this should help

@danlavu danlavu self-requested a review September 23, 2024 11:50
@danlavu danlavu self-assigned this Sep 23, 2024
@danlavu
Copy link

danlavu commented Sep 23, 2024

Works

>               assert ssh.run("pwd").stdout == f"/home/{i[1]}"
E               AssertionError: assert '/' == '/home/user1@TEST'

Thank you.

@pbrezina pbrezina merged commit 497ef20 into SSSD:master Sep 23, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants