Skip to content

Commit aa5701b

Browse files
committed
add additional comments and error handling
1 parent 42b00ac commit aa5701b

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Utils/HandlerUtil.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,16 +204,18 @@ def _parse_config(self, ctxt):
204204
protected_settings_str = ''
205205
for decrypt_cmd in [cms_cmd, smime_cmd]:
206206
try:
207+
# waagent.RunSendStdin returns a tuple (return code, stdout)
207208
output = waagent.RunSendStdin(decrypt_cmd, unencodedSettings)
208-
if output[0] == 0 and output[1]:
209+
if output and output[0] == 0 and output[1]:
209210
protected_settings_str = output[1]
210211
if decrypt_cmd == cms_cmd:
211212
self.log('Decrypted protectedSettings using openssl cms.')
212213
else:
213214
self.log('Decrypted protectedSettings using openssl smime fallback.')
214215
break
215216
else:
216-
self.log('Attempt to decrypt protectedSettings with "{0}" failed (rc={1}).'.format(decrypt_cmd, output[0]))
217+
rc = output[0] if output else 'N/A'
218+
self.log('Attempt to decrypt protectedSettings with "{0}" failed (rc={1}).'.format(decrypt_cmd, rc))
217219
except OSError:
218220
pass
219221

0 commit comments

Comments
 (0)