Browse Source

Adjust log entry levels for severe conditions

When Lacre is misconfigured or can't proceed, report WARNING or even ERROR
level messages.
pull/65/head
Piotr F. Mieszkowski 2 weeks ago
parent
commit
11b78ce0fb
  1. 5
      gpg-mailgate-web/cron.py
  2. 4
      gpg-mailgate.py

5
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!")

4
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')))

Loading…
Cancel
Save