Commit graph

9 commits

Author SHA1 Message Date
intrigeri
56dd267a24 Mark variables as dummy in a way that shellcheck 0.7.0 supports
The "_" prefix is only supported in shellcheck > 0.7.2.
2022-02-13 19:43:48 +00:00
intrigeri
825f761c77 aa-decode, aa-remove-unknown: fix remaining shellcheck info-level violations
For details, see:

- https://www.shellcheck.net/wiki/SC2086
- https://www.shellcheck.net/wiki/SC2162
2022-02-13 19:43:48 +00:00
intrigeri
8d219e1f31 aa-remove-unknown: mark dummy variable as such
For details, see https://www.shellcheck.net/wiki/SC2034.
2022-02-13 19:43:48 +00:00
intrigeri
cfcc271b3c aa-remove-unknown: prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
For details, see https://www.shellcheck.net/wiki/SC2166.
2022-02-13 19:43:48 +00:00
Christian Boltz
5053a01d84
aa-remove-unknown: abort on parser failure
If apparmor_parser -N (in profiles_names_list()) fails,
aa-remove-unknown possibly gets an incomplete list of profiles in
/etc/apparmor.d/ and therefore might remove more profiles than it
should.

Replace the profiles_names_list() call with a direct apparmor_parser
call, and abort aa-remove-unknown if it exits with $? != 0

Before:
```
aa-remove-unknown -n
AppArmor parser error for /etc/apparmor.d/broken in profile /etc/apparmor.d/broken at line 1: syntax error, unexpected TOK_ID, expecting TOK_OPEN
Would remove 'delete_me'
```

After:
```
./aa-remove-unknown -n
AppArmor parser error for /etc/apparmor.d in profile /etc/apparmor.d/zbroken at line 1: syntax error, unexpected TOK_ID, expecting TOK_OPEN
apparmor_parser exited with failure, aborting.
```

And of course, after fixing the broken profile:
```
./aa-remove-unknown -n
Would remove 'delete_me'
```
2022-02-11 22:59:01 +01:00
Christian Boltz
8cecc14d2d
aa-remove-unknown: Drop superfluous $0 parameter from usage()
$0 is always the name of the script, even if using it inside a function.
Therefore use $0 directly, and no longer hand it over as a parameter.
2021-08-16 19:59:34 +02:00
Christian Boltz
169d305b2b
chmod +x aa-remove-unknown 2021-08-16 19:59:34 +02:00
Christian Boltz
4d4228d157
Don't print a literal '\n' in aa-remove-unknown help 2017-12-01 00:26:56 +01:00
Tyler Hicks
e04b50ce95 utils: Add aa-remove-unknown utility to unload unknown profiles
https://launchpad.net/bugs/1668892

This patch creates a new utility, with the code previously used in the
init script 'restart' action, that removes unknown profiles which are
not found in /etc/apparmor.d/. The functionality was removed from the
common init script code in the fix for CVE-2017-6507.

The new utility prints a message containing the name of each unknown
profile before the profiles are removed. It also supports a dry run mode
so that an administrator can check which profiles will be removed before
unloading any unknown profiles.

If you backport this utility with the fix for CVE-2017-6507 to an
apparmor 2.10 release and your backported aa-remove-unknown utility is
sourcing the upstream rc.apparmor.functions file, you'll want to include
the following bug fix to prevent the aa-remove-unknown utility from
removing child profiles that it shouldn't remove:

  r3440 - Fix: parser: incorrect output of child profile names

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
2017-03-24 05:08:01 +00:00