Skip to content

Commit

Permalink
Fix password lookup when password file exists and the password is not…
Browse files Browse the repository at this point in the history
… encrypted
  • Loading branch information
abadger committed Oct 12, 2015
1 parent cd2cb17 commit 8277747
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/ansible/plugins/lookup/password.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,19 @@ def run(self, terms, variables, **kwargs):
else:
content = open(path).read().rstrip()

password = content
salt = None
if params['encrypt'] is not None:
try:
sep = content.rindex(' ')
except ValueError:
password = content
salt = None
# No salt
pass
else:
salt_field = content[sep + 1:]
if salt_field.startswith('salt='):
password = content[:sep]
salt = salt_field[len('salt='):]
else:
password = content
salt = None

# crypt requested, add salt if missing
if not salt:
Expand Down

0 comments on commit 8277747

Please sign in to comment.