Adjust log entry levels for severe conditions

When Lacre is misconfigured or can't proceed, report WARNING or even ERROR
level messages.
This commit is contained in:
Piotr F. Mieszkowski 2022-05-13 21:27:50 +02:00
parent acdb2dd5c8
commit 11b78ce0fb
2 changed files with 5 additions and 4 deletions

View File

@ -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) modq = gpgmw_keys.update().where(gpgmw_keys.c.id == row[1]).values(status = 1)
LOG.debug(f"Key imported, updating key: {modq}") LOG.debug(f"Key imported, updating key: {modq}")
conn.execute(modq) # mark key as accepted 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'): if conf.config_item_equals('cron', 'send_email', 'yes'):
send_msg( "PGP key registration successful", "registrationSuccess.md", row[2] ) send_msg( "PGP key registration successful", "registrationSuccess.md", row[2] )
else: else:
delq = delete(gpgmw_keys).where(gpgmw_keys.c.id == row[1]) delq = delete(gpgmw_keys).where(gpgmw_keys.c.id == row[1])
LOG.debug(f"Cannot confirm key, deleting it: {delq}") LOG.debug(f"Cannot confirm key, deleting it: {delq}")
conn.execute(delq) # delete key 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'): if conf.config_item_equals('cron', 'send_email', 'yes'):
send_msg( "PGP key registration failed", "registrationError.md", row[2] ) send_msg( "PGP key registration failed", "registrationError.md", row[2] )
else: 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] + '>') LOG.info('Deleted key for <' + row[0] + '>')
else: else:
print("Warning: doing nothing since database settings are not configured!") print("Warning: doing nothing since database settings are not configured!")
LOG.error("Warning: doing nothing since database settings are not configured!")

View File

@ -47,7 +47,7 @@ def gpg_encrypt( raw_message, recipients ):
global LOG global LOG
if not conf.config_item_set('gpg', 'keyhome'): 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 return recipients
keys = GnuPG.public_keys( conf.get_item('gpg', 'keyhome') ) 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] recipients = [_f for _f in recipients if _f]
if recipients: if recipients:
if not (conf.config_item_set('relay', 'host') and conf.config_item_set('relay', 'port')): 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 return None
LOG.info("Sending email to: <%s>" % '> <'.join( recipients )) LOG.info("Sending email to: <%s>" % '> <'.join( recipients ))
relay = (conf.get_item('relay', 'host'), int(conf.get_item('relay', 'port'))) relay = (conf.get_item('relay', 'host'), int(conf.get_item('relay', 'port')))