StratusLab / client

Command Line Interface (CLI) for StratusLab cloud services
Apache License 2.0
2 stars 1 forks source link

passwords with percent signs cause client to fail #135

Closed loomis closed 10 years ago

loomis commented 10 years ago

If the password of a user contains a percent sign, then the client fails with an interpolation error:

$ stratus-describe-instance -vvv
Traceback (most recent call last):
  File "/Users/loomis/Library/Python/2.7/bin/stratus-describe-instance", line 99, in <module>
    MainProgram()
  File "/Users/loomis/Library/Python/2.7/bin/stratus-describe-instance", line 45, in __init__
    super(MainProgram, self).__init__()
  File "/Users/loomis/Library/Python/2.7/lib/python/site-packages/stratuslab/CommandBase.py", line 51, in __init__
    self.raiseOrDisplayError(str(ex))
  File "/Users/loomis/Library/Python/2.7/lib/python/site-packages/stratuslab/CommandBase.py", line 49, in __init__
    self, self._loadConfigFileAndUpdateOptions()
  File "/Users/loomis/Library/Python/2.7/lib/python/site-packages/stratuslab/CommandBase.py", line 164, in _loadConfigFileAndUpdateOptions
    self._loadConfigFile()
  File "/Users/loomis/Library/Python/2.7/lib/python/site-packages/stratuslab/CommandBase.py", line 186, in _loadConfigFile
    selected_section=selected_section)
  File "/Users/loomis/Library/Python/2.7/lib/python/site-packages/stratuslab/ConfigHolder.py", line 196, in configFileToDictWithFormattedKeys
    return UserConfigurator.userConfiguratorToDictWithFormattedKeys(usercfg, withMap, selected_section)
  File "/Users/loomis/Library/Python/2.7/lib/python/site-packages/stratuslab/ConfigHolder.py", line 200, in userConfiguratorToDictWithFormattedKeys
    config = usercfg.getDict(selected_section)
  File "/Users/loomis/Library/Python/2.7/lib/python/site-packages/stratuslab/ConfigHolder.py", line 265, in getDict
    self._loadDefaults()
  File "/Users/loomis/Library/Python/2.7/lib/python/site-packages/stratuslab/ConfigHolder.py", line 223, in _loadDefaults
    self._loadSection('default')
  File "/Users/loomis/Library/Python/2.7/lib/python/site-packages/stratuslab/ConfigHolder.py", line 226, in _loadSection
    self._dict.update(dict(self._parser.items(section)))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ConfigParser.py", line 655, in items
    for option in options]
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ConfigParser.py", line 691, in _interpolate
    self._interpolate_some(option, L, rawval, section, vars, 1)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ConfigParser.py", line 732, in _interpolate_some
    "'%%' must be followed by '%%' or '(', found: %r" % (rest,))
ConfigParser.InterpolationSyntaxError: '%' must be followed by '%' or '(', found: '%x'
loomis commented 10 years ago

This is because the SafeConfigParser used in the client tries to interpolate values in the configuration file that contain a percent sign. In Python 2, there is no way to turn off this behavior except for using the RawConfigParser instead.

loomis commented 10 years ago

This unfortunately cannot be fixed within the code because the SafeConfigParser is deeply embedded into all parts of the python code. The workaround is to escape any percent signs in the configuration file by doubling them. This must be throughly documented in the user and administrator guides.

loomis commented 10 years ago

See issue StratusLab/documentation#9.