Merge pull request #1429 from joelthompson/feature/win_load_password

Ensure ec2_win_password doesn't leak file handle
This commit is contained in:
René Moser 2016-03-19 14:09:49 +01:00
commit 58654cdac1

View file

@ -140,8 +140,11 @@ def main():
if wait and datetime.datetime.now() >= end: if wait and datetime.datetime.now() >= end:
module.fail_json(msg = "wait for password timeout after %d seconds" % wait_timeout) module.fail_json(msg = "wait for password timeout after %d seconds" % wait_timeout)
f = open(key_file, 'r') try:
key = RSA.importKey(f.read(), key_passphrase) f = open(key_file, 'r')
key = RSA.importKey(f.read(), key_passphrase)
finally:
f.close()
cipher = PKCS1_v1_5.new(key) cipher = PKCS1_v1_5.new(key)
sentinel = 'password decryption failed!!!' sentinel = 'password decryption failed!!!'