Skip to content

Commit

Permalink
s/apparmor: improve testing and documentation of NotifySocketPath
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver Calder <[email protected]>
  • Loading branch information
olivercalder committed Feb 28, 2025
1 parent ea2bf42 commit ba6dff8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
16 changes: 12 additions & 4 deletions sandbox/apparmor/apparmor.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,19 @@ const (
)

var (
ConfDir string
CacheDir string
SystemCacheDir string
// ConfDir is the path to the directory holding AppArmor configuration.
ConfDir string
// CacheDir is the path to the cache directory for AppArmor.
CacheDir string
// SystemCacheDir is the path to the system cache directory for AppArmor,
// which may or may not be different from CacheDir.
SystemCacheDir string
// SnapConfineAppArmorDir is the path to the AppArmor snap confine
// directory.
SnapConfineAppArmorDir string
NotifySocketPath string
// NotifySocketPath is the path to the socket over which listeners can
// communicate with AppArmor in the kernel.
NotifySocketPath string
)

func setupConfCacheDirs(newrootdir string) {
Expand Down
4 changes: 4 additions & 0 deletions sandbox/apparmor/apparmor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,10 @@ func (s *apparmorSuite) TestSetupConfCacheDirsWithInternalApparmor(c *C) {
func (s *apparmorSuite) TestSetupNotifySocketPath(c *C) {
apparmor.SetupNotifySocketPath("/newdir")
c.Check(apparmor.NotifySocketPath, Equals, "/newdir/sys/kernel/security/apparmor/.notify")

newRoot := c.MkDir()
dirs.SetRootDir(newRoot)
c.Check(apparmor.NotifySocketPath, Equals, filepath.Join(newRoot, "/sys/kernel/security/apparmor/.notify"))
}

func (s *apparmorSuite) TestSystemAppArmorLoadsSnapPolicyErr(c *C) {
Expand Down

0 comments on commit ba6dff8

Please sign in to comment.