Merge branch 'bugfix/aa-always-logfile-fallback' into 'master'

Fix error 'KeyError: 'logfiles'' when no logprof.conf exists

See merge request apparmor/apparmor!365

Acked-by: Christian Boltz <apparmor@cboltz.de> for 2.12..master
This commit is contained in:
Christian Boltz 2019-04-21 16:48:34 +00:00
commit cece787182

View file

@ -1761,14 +1761,18 @@ def set_logfile(filename):
if filename:
logfile = filename
else:
elif 'logfiles' in cfg['settings']:
# This line can only run if the 'logfile' exists in settings, otherwise
# it will yield a Python KeyError
logfile = conf.find_first_file(cfg['settings']['logfiles']) or '/var/log/syslog'
else:
logfile = '/var/log/syslog'
if not os.path.exists(logfile):
if filename:
raise AppArmorException(_('The logfile %s does not exist. Please check the path') % logfile)
raise AppArmorException(_('The logfile %s does not exist. Please check the path.') % logfile)
else:
raise AppArmorException('Can\'t find system log "%s".' % (logfile))
raise AppArmorException('Can\'t find system log "%s". Please check permissions.' % (logfile))
elif os.path.isdir(logfile):
raise AppArmorException(_('%s is a directory. Please specify a file as logfile') % logfile)