aa-status: AttributeError: 'NoneType' object has no attribute 'group'
I generated an incorrect profile, loaded it, and aa-status began to error. Restarting the systemd service does not help, a reboot does.
~ > sudo aa-status
apparmor module is loaded.
Traceback (most recent call last):
File "/nix/store/6dzklci7w2b4pfs36hcw0m3d545impwx-apparmor-utils-2.13.1/bin/.aa-status-wrapped", line 261, in <module>
commands[cmd]()
File "/nix/store/6dzklci7w2b4pfs36hcw0m3d545impwx-apparmor-utils-2.13.1/bin/.aa-status-wrapped", line 59, in cmd_verbose
profiles = get_profiles()
File "/nix/store/6dzklci7w2b4pfs36hcw0m3d545impwx-apparmor-utils-2.13.1/bin/.aa-status-wrapped", line 152, in get_profiles
profiles[match.group(1)] = match.group(2)
AttributeError: 'NoneType' object has no attribute 'group'
An unexpected error occoured!
For details, see /tmp/apparmor-bugreport-15y_sa1f.txt
Please consider reporting a bug at https://bugs.launchpad.net/apparmor/
and attach this file.
Here's the mentioned file:
AttributeError
Python 3.7.4: /nix/store/96p42644i76jqgdkxjgyl3f0c8n8k16j-python3-3.7.4/bin/python3
Fri Aug 16 19:22:43 2019
A problem occurred in a Python script. Here is the sequence of
function calls leading up to the error, in the order they occurred.
/nix/store/6dzklci7w2b4pfs36hcw0m3d545impwx-apparmor-utils-2.13.1/bin/.aa-status-wrapped in <module>()
256 '--help' : print_usage,
257 '-h' : print_usage
258 }
259
260 if cmd in commands:
261 commands[cmd]()
262 sys.exit(0)
263 else:
264 sys.stderr.write("Error: Invalid command.\n")
265 print_usage()
commands = {'--complaining': <function cmd_complaining>, '--enabled': <function cmd_enabled>, '--enforced': <function cmd_enforced>, '--help': <function print_usage>, '--json': <function cmd_json>, '--pretty-json': <function cmd_pretty_json>, '--profiled': <function cmd_profiled>, '--verbose': <function cmd_verbose>, '-h': <function print_usage>, '-v': <function cmd_verbose>}
cmd = '--verbose'
/nix/store/6dzklci7w2b4pfs36hcw0m3d545impwx-apparmor-utils-2.13.1/bin/.aa-status-wrapped in cmd_verbose()
54
55 def cmd_verbose():
56 '''Displays multiple data points about loaded profile set'''
57 global verbose
58 verbose = True
59 profiles = get_profiles()
60 processes = get_processes(profiles)
61
62 stdmsg("%d profiles are loaded." % len(profiles))
63 for status in ('enforce', 'complain'):
profiles undefined
global get_profiles = <function get_profiles>
/nix/store/6dzklci7w2b4pfs36hcw0m3d545impwx-apparmor-utils-2.13.1/bin/.aa-status-wrapped in get_profiles()
147 errormsg("Could not open %s: %s" % (apparmor_profiles, os.strerror(e.errno)))
148 sys.exit(4)
149
150 for p in f.readlines():
151 match = re.search("^([^\(]+)\s+\((\w+)\)$", p)
152 profiles[match.group(1)] = match.group(2)
153
154 f.close()
155
156 return profiles
profiles = {}
match = None
match.group undefined
AttributeError: 'NoneType' object has no attribute 'group'
__cause__ = None
__class__ = <class 'AttributeError'>
__context__ = None
__delattr__ = <method-wrapper '__delattr__' of AttributeError object>
__dict__ = {}
__dir__ = <built-in method __dir__ of AttributeError object>
__doc__ = 'Attribute not found.'
__eq__ = <method-wrapper '__eq__' of AttributeError object>
__format__ = <built-in method __format__ of AttributeError object>
__ge__ = <method-wrapper '__ge__' of AttributeError object>
__getattribute__ = <method-wrapper '__getattribute__' of AttributeError object>
__gt__ = <method-wrapper '__gt__' of AttributeError object>
__hash__ = <method-wrapper '__hash__' of AttributeError object>
__init__ = <method-wrapper '__init__' of AttributeError object>
__init_subclass__ = <built-in method __init_subclass__ of type object>
__le__ = <method-wrapper '__le__' of AttributeError object>
__lt__ = <method-wrapper '__lt__' of AttributeError object>
__ne__ = <method-wrapper '__ne__' of AttributeError object>
__new__ = <built-in method __new__ of type object>
__reduce__ = <built-in method __reduce__ of AttributeError object>
__reduce_ex__ = <built-in method __reduce_ex__ of AttributeError object>
__repr__ = <method-wrapper '__repr__' of AttributeError object>
__setattr__ = <method-wrapper '__setattr__' of AttributeError object>
__setstate__ = <built-in method __setstate__ of AttributeError object>
__sizeof__ = <built-in method __sizeof__ of AttributeError object>
__str__ = <method-wrapper '__str__' of AttributeError object>
__subclasshook__ = <built-in method __subclasshook__ of type object>
__suppress_context__ = False
__traceback__ = <traceback object>
args = ("'NoneType' object has no attribute 'group'",)
with_traceback = <built-in method with_traceback of AttributeError object>
The above is a description of an error in a Python program. Here is
the original traceback:
Traceback (most recent call last):
File "/nix/store/6dzklci7w2b4pfs36hcw0m3d545impwx-apparmor-utils-2.13.1/bin/.aa-status-wrapped", line 261, in <module>
commands[cmd]()
File "/nix/store/6dzklci7w2b4pfs36hcw0m3d545impwx-apparmor-utils-2.13.1/bin/.aa-status-wrapped", line 59, in cmd_verbose
profiles = get_profiles()
File "/nix/store/6dzklci7w2b4pfs36hcw0m3d545impwx-apparmor-utils-2.13.1/bin/.aa-status-wrapped", line 152, in get_profiles
profiles[match.group(1)] = match.group(2)
AttributeError: 'NoneType' object has no attribute 'group'
Please consider reporting a bug at https://bugs.launchpad.net/apparmor/
and attach this file.
Attached is the profile that caused this. It was generated, and has a syntax error by not separating flags=(complain)
from the pathglob with a space.
24m5np1dkb34vb6v61p5lwiax3yzd6jd-pb-dir.profile
Replacing the broken profile with a correct one does not resolve the issue, until a reboot happens.
Edited by tilpner