Merge lp:~mdeslaur/apport/machooks into lp:~apport-hackers/apport/trunk

Proposed by Marc Deslauriers
Status: Merged
Merged at revision: 1915
Proposed branch: lp:~mdeslaur/apport/machooks
Merge into: lp:~apport-hackers/apport/trunk
Diff against target: 55 lines (+33/-2)
1 file modified
apport/hookutils.py (+33/-2)
To merge this branch: bzr merge lp:~mdeslaur/apport/machooks
Reviewer Review Type Date Requested Status
Martin Pitt (community) Approve
Review via email: mp+67716@code.launchpad.net

Description of the change

This adds MAC (AppArmor) hooks into Apport so they can be removed from each individual package that ships an AppArmor profile.

To post a comment you must log in.
Revision history for this message
Martin Pitt (pitti) wrote :

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'apport/hookutils.py'
--- apport/hookutils.py 2011-06-30 10:00:29 +0000
+++ apport/hookutils.py 2011-07-12 15:33:13 +0000
@@ -335,12 +335,19 @@
335335
336def recent_syslog(pattern):336def recent_syslog(pattern):
337 '''Extract recent messages from syslog which match a regex.337 '''Extract recent messages from syslog which match a regex.
338 338
339 pattern should be a "re" object.
340 '''
341 return recent_logfile('/var/log/syslog', pattern)
342
343def recent_logfile(logfile, pattern):
344 '''Extract recent messages from a logfile which match a regex.
345
339 pattern should be a "re" object.346 pattern should be a "re" object.
340 '''347 '''
341 lines = ''348 lines = ''
342 try:349 try:
343 for line in open('/var/log/syslog'):350 for line in open(logfile):
344 if pattern.search(line):351 if pattern.search(line):
345 lines += line352 lines += line
346 except IOError:353 except IOError:
@@ -512,6 +519,30 @@
512 'cupsys-driver-gutenprint', 'gimp-gutenprint', 'gutenprint-doc',519 'cupsys-driver-gutenprint', 'gimp-gutenprint', 'gutenprint-doc',
513 'gutenprint-locales', 'system-config-printer-common', 'kdeprint')520 'gutenprint-locales', 'system-config-printer-common', 'kdeprint')
514521
522def attach_mac_events(report):
523 '''Attach MAC information and events to the report.'''
524 mac_regex = 'audit\(|apparmor|selinux|security'
525 mac_re = re.compile(mac_regex, re.IGNORECASE)
526 aa_denied_regex = 'apparmor="DENIED"'
527 aa_denied_re = re.compile(aa_denied_regex, re.IGNORECASE)
528
529 if os.path.exists('/var/log/kern.log'):
530 report['KernLog'] = recent_logfile('/var/log/kern.log',mac_re)
531 elif os.path.exists('/var/log/messages'):
532 report['KernLog'] = recent_logfile('/var/log/messages',mac_re)
533
534 if os.path.exists('/var/log/audit/audit.log'):
535 attach_root_command_outputs(report, {'AuditLog': 'grep "' + mac_regex + '" /var/log/audit/audit.log'})
536
537 attach_file(report, '/proc/version_signature', 'ProcVersionSignature')
538 attach_file(report, '/proc/cmdline', 'ProcCmdline')
539
540 if re.search(aa_denied_re, report.get('KernLog', '')) or re.search(aa_denied_re, report.get('AuditLog', '')):
541 tags = report.get('Tags', '')
542 if tags:
543 tags += ' '
544 report['Tags'] = tags + 'apparmor'
545
515def attach_related_packages(report, packages):546def attach_related_packages(report, packages):
516 '''Attach version information for related packages547 '''Attach version information for related packages
517548

Subscribers

People subscribed via source and target branches