Fix password lookup when password file exists and the password is not encrypted

pull/12723/head
Toshio Kuratomi 9 years ago
parent cd2cb178ae
commit 8277747a04

@ -135,20 +135,19 @@ class LookupModule(LookupBase):
else: else:
content = open(path).read().rstrip() content = open(path).read().rstrip()
password = content
salt = None
if params['encrypt'] is not None: if params['encrypt'] is not None:
try: try:
sep = content.rindex(' ') sep = content.rindex(' ')
except ValueError: except ValueError:
password = content # No salt
salt = None pass
else: else:
salt_field = content[sep + 1:] salt_field = content[sep + 1:]
if salt_field.startswith('salt='): if salt_field.startswith('salt='):
password = content[:sep] password = content[:sep]
salt = salt_field[len('salt='):] salt = salt_field[len('salt='):]
else:
password = content
salt = None
# crypt requested, add salt if missing # crypt requested, add salt if missing
if not salt: if not salt:

Loading…
Cancel
Save