From 11b78ce0fb1071bcc1a71bc83f83e95813ac057c Mon Sep 17 00:00:00 2001 From: "Piotr F. Mieszkowski" Date: Fri, 13 May 2022 21:27:50 +0200 Subject: [PATCH] Adjust log entry levels for severe conditions When Lacre is misconfigured or can't proceed, report WARNING or even ERROR level messages. --- gpg-mailgate-web/cron.py | 5 +++-- gpg-mailgate.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gpg-mailgate-web/cron.py b/gpg-mailgate-web/cron.py index 18d080e..48c02e0 100644 --- a/gpg-mailgate-web/cron.py +++ b/gpg-mailgate-web/cron.py @@ -119,14 +119,14 @@ if conf.config_item_equals('database', 'enabled', 'yes') and conf.config_item_se modq = gpgmw_keys.update().where(gpgmw_keys.c.id == row[1]).values(status = 1) LOG.debug(f"Key imported, updating key: {modq}") conn.execute(modq) # mark key as accepted - LOG.info('Imported key from <' + row[2] + '>') + LOG.warning('Imported key from <' + row[2] + '>') if conf.config_item_equals('cron', 'send_email', 'yes'): send_msg( "PGP key registration successful", "registrationSuccess.md", row[2] ) else: delq = delete(gpgmw_keys).where(gpgmw_keys.c.id == row[1]) LOG.debug(f"Cannot confirm key, deleting it: {delq}") conn.execute(delq) # delete key - LOG.info('Import confirmation failed for <' + row[2] + '>') + LOG.warning('Import confirmation failed for <' + row[2] + '>') if conf.config_item_equals('cron', 'send_email', 'yes'): send_msg( "PGP key registration failed", "registrationError.md", row[2] ) else: @@ -149,3 +149,4 @@ if conf.config_item_equals('database', 'enabled', 'yes') and conf.config_item_se LOG.info('Deleted key for <' + row[0] + '>') else: print("Warning: doing nothing since database settings are not configured!") + LOG.error("Warning: doing nothing since database settings are not configured!") diff --git a/gpg-mailgate.py b/gpg-mailgate.py index e01066e..7d45855 100755 --- a/gpg-mailgate.py +++ b/gpg-mailgate.py @@ -47,7 +47,7 @@ def gpg_encrypt( raw_message, recipients ): global LOG if not conf.config_item_set('gpg', 'keyhome'): - LOG.info("No valid entry for gpg keyhome. Encryption aborted.") + LOG.error("No valid entry for gpg keyhome. Encryption aborted.") return recipients keys = GnuPG.public_keys( conf.get_item('gpg', 'keyhome') ) @@ -370,7 +370,7 @@ def send_msg( message, recipients ): recipients = [_f for _f in recipients if _f] if recipients: if not (conf.config_item_set('relay', 'host') and conf.config_item_set('relay', 'port')): - LOG.info("Missing settings for relay. Sending email aborted.") + LOG.warning("Missing settings for relay. Sending email aborted.") return None LOG.info("Sending email to: <%s>" % '> <'.join( recipients )) relay = (conf.get_item('relay', 'host'), int(conf.get_item('relay', 'port')))