aa-enforce does not handle empty profile consistently with parser
Bug #1815295 reported by
Vincas Dargis
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
AppArmor |
New
|
Undecided
|
Unassigned |
Bug Description
If we have this empty dummy profile:
```
profile foobar {}
```
And run aa-enforce, we get error:
```
$ sudo aa-enforce /etc/apparmor.d/*
ERROR: Syntax Error: Unknown line found in file /etc/apparmor.d/foo line 1:
profile foobar {}
```
Meanwhile, `apparmor_parser` parses this file without error:
```
$ sudo apparmor_parser -r /etc/apparmor.d/foo && echo $?
0
```
It works fine if I move "}" to the new line:
```
$ cat /etc/apparmor.d/foo ; sudo aa-enforce /etc/apparmor.d/*
profile foobar {
}
Profile for /etc/apparmor.
...
Setting /etc/apparmor.d/foo to enforce mode.
Profile for /etc/apparmor.
...
```
To post a comment you must log in.
Original issue actually is that aa-enforce does not like completely empty profile, like, with only comments, for example:
``` d/abstractions not found, skipping d/apache2. d not found, skipping d/bin.ping to enforce mode. d/disable not found, skipping
$ cat /etc/apparmor.d/foo ; sudo aa-enforce /etc/apparmor.d/*
# foo bar
Profile for /etc/apparmor.
Profile for /etc/apparmor.
Setting /etc/apparmor.
Profile for /etc/apparmor.
Setting /etc/apparmor.d/foo to enforce mode.
ERROR: /etc/apparmor.d/foo doesn't contain a valid profile (syntax error?)
```
This was discovered with this empty mariadb-server-10.3 profile in Debian Sid: /sources. debian. org/src/ mariadb- 10.3/1: 10.3.12- 2/debian/ apparmor- profile/
https:/