Password set now works on an empty password file

Password set now works on an empty password file

Change-Id: Icb26a0b2d88e2bfc4593e83787ca06e9ca51b186
This commit is contained in:
Borne Mace 2018-05-02 14:53:52 -07:00
parent 7c0bc714f1
commit edeb5d6483
1 changed files with 3 additions and 0 deletions

View File

@ -204,6 +204,9 @@ def change_password(file_path, pname, pvalue=None, public_key=None,
"""
read_data = sync_read_file(file_path)
file_pwds = yaml.safe_load(read_data)
# if the password file is empty file_pwds will be None after safe_load
if file_pwds is None:
file_pwds = {}
if clear:
# clear
if pname in file_pwds: