New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dirs,interfaces/apparmor: remove unused apparmor cache entries #770
Conversation
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
This patch just makes access to apparmor cache directory follow standard directory variables so that upcoming support to apparmor cache removal can be easily tested. Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
This patch ensures that we remove the apparmor cache file when removing the profile text. The cache is written by apparmor_parser but is never removed. Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
@@ -70,6 +73,22 @@ apparmor_parser output: | |||
"--replace --write-cache -O no-expr-simplify --cache-loc=/var/cache/apparmor /path/to/snap.samba.smbd"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This context for the diff shows a hard-coded --cache-loc. Please adjust it and any other uses of --cache-loc. With those changes, LGTM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is okay (in this case) because we don't divert the root directory. I can add the diversion to ensure we are indeed using the variable name.
LGTM, but it feels like the logic might be simplified a bit in some cases, per inline comments. |
This patch merges the two function so that LoadProfile is completely undone by UnloadProfile. In addition, it is no longer an error for UnloadProfile to not remove a missing cache entry (for whatever reason, the cache might be missing and this should not be a problem). Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
err = os.MkdirAll(dirs.AppArmorCacheDir, 0700) | ||
c.Assert(err, IsNil) | ||
// Mock away any real apparmor interaction | ||
s.mockCmd = testutil.MockCommand(c, "apparmor_parser", fakeAppArmorParser) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which mock command? This should probably be s.parserCmd
.
This branch ensures we remove entries from
/var/cache/apparmor
corresponding to removed apparmor profiles. We have to do this becauseapparmor_parser
writes the cache but never removes it.