@@ -2447,9 +2447,13 @@ def parse_context(operation):
24472447 output = 'Logrotate removal failed with error: {0}\n Stacktrace: {1}' .format (ex , traceback .format_exc ())
24482448 hutil_log_info (output )
24492449 else :
2450- if not os .path .exists (AMAExtensionLogRotateFilePath ):
2451- logrotateFilePath = os .path .join (os .getcwd (), 'azuremonitoragentextension.logrotate' )
2452- copyfile (logrotateFilePath ,AMAExtensionLogRotateFilePath )
2450+ if not os .path .exists (AMAExtensionLogRotateFilePath ):
2451+ try :
2452+ logrotateFilePath = os .path .join (os .getcwd (), 'azuremonitoragentextension.logrotate' )
2453+ copyfile (logrotateFilePath ,AMAExtensionLogRotateFilePath )
2454+ except Exception as ex :
2455+ output = 'Logrotate config copy failed with error: {0}\n Stacktrace: {1}' .format (ex , traceback .format_exc ())
2456+ hutil_log_info (output )
24532457
24542458 # parse_context may throw KeyError if necessary JSON key is not
24552459 # present in settings
@@ -3060,9 +3064,13 @@ def get_settings():
30603064 protected_settings_str = None
30613065 for decrypt_cmd in [cms_cmd , smime_cmd ]:
30623066 try :
3067+ # stderr is intentionally captured separately from stdout (and never
3068+ # logged verbatim) so that non-fatal openssl warnings (e.g. a missing
3069+ # openssl.cnf) can't get concatenated with the decrypted output, corrupt the
3070+ # JSON payload, and risk the decrypted secret being echoed in error handling.
30633071 session = subprocess .Popen ([decrypt_cmd ], shell = True ,
30643072 stdin = subprocess .PIPE ,
3065- stderr = subprocess .STDOUT ,
3073+ stderr = subprocess .PIPE ,
30663074 stdout = subprocess .PIPE )
30673075 output = session .communicate (decoded_settings )
30683076 # success only if return code is 0 and we have output
0 commit comments