Skip to content

Commit

Permalink
Set raw=True when reading passwords from ConfigParser files. (ansib…
Browse files Browse the repository at this point in the history
…le#35582)

* Set `raw=True` when reading passwords from ConfigParser files.

The assumption is that no one is actually doing interpolation on the
password value, even if they may for other configuration values, and
passwords are far more likely to contain '%'.

* Add vmware_inventory as well.
  • Loading branch information
wenottingham authored and bcoca committed Apr 5, 2018
1 parent d5cfc54 commit 15b6ec6
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion contrib/inventory/cloudforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def read_settings(self):
warnings.warn("No username specified, you need to specify a CloudForms username.")

if config.has_option('cloudforms', 'password'):
self.cloudforms_pw = config.get('cloudforms', 'password')
self.cloudforms_pw = config.get('cloudforms', 'password', raw=True)
else:
self.cloudforms_pw = None

Expand Down
2 changes: 1 addition & 1 deletion contrib/inventory/foreman.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def read_settings(self):
try:
self.foreman_url = config.get('foreman', 'url')
self.foreman_user = config.get('foreman', 'user')
self.foreman_pw = config.get('foreman', 'password')
self.foreman_pw = config.get('foreman', 'password', raw=True)
self.foreman_ssl_verify = config.getboolean('foreman', 'ssl_verify')
except (ConfigParser.NoOptionError, ConfigParser.NoSectionError) as e:
print("Error parsing configuration: %s" % e, file=sys.stderr)
Expand Down
2 changes: 1 addition & 1 deletion contrib/inventory/ovirt4.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def create_connection():
return sdk.Connection(
url=config.get('ovirt', 'ovirt_url'),
username=config.get('ovirt', 'ovirt_username'),
password=config.get('ovirt', 'ovirt_password'),
password=config.get('ovirt', 'ovirt_password', raw=True),
ca_file=config.get('ovirt', 'ovirt_ca_file'),
insecure=config.get('ovirt', 'ovirt_ca_file') is None,
)
Expand Down
2 changes: 1 addition & 1 deletion contrib/inventory/vmware_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def read_settings(self):
self.port = int(os.environ.get('VMWARE_PORT', config.get('vmware', 'port')))
self.username = os.environ.get('VMWARE_USERNAME', config.get('vmware', 'username'))
self.debugl('username is %s' % self.username)
self.password = os.environ.get('VMWARE_PASSWORD', config.get('vmware', 'password'))
self.password = os.environ.get('VMWARE_PASSWORD', config.get('vmware', 'password', raw=True))
self.validate_certs = os.environ.get('VMWARE_VALIDATE_CERTS', config.get('vmware', 'validate_certs'))
if self.validate_certs in ['no', 'false', 'False', False]:
self.validate_certs = False
Expand Down

0 comments on commit 15b6ec6

Please sign in to comment.