Skip to content

Commit 55eda46

Browse files
committed
expose hostSupportsAppArmor()
Signed-off-by: Akihiro Suda <[email protected]>
1 parent 59a0667 commit 55eda46

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
limitations under the License.
1717
*/
1818

19-
package server
19+
package apparmor
2020

2121
import (
2222
"io/ioutil"
@@ -29,12 +29,12 @@ var (
2929
checkAppArmor sync.Once
3030
)
3131

32-
// hostSupportsAppArmor returns true if apparmor is enabled for the host, if
32+
// HostSupports returns true if apparmor is enabled for the host, if
3333
// apparmor_parser is enabled, and if we are not running docker-in-docker.
3434
//
3535
// It is a modified version of libcontainer/apparmor.IsEnabled(), which does not
3636
// check for apparmor_parser to be present, or if we're running docker-in-docker.
37-
func hostSupportsAppArmor() bool {
37+
func HostSupports() bool {
3838
checkAppArmor.Do(func() {
3939
// see https://github.com/docker/docker/commit/de191e86321f7d3136ff42ff75826b8107399497
4040
if _, err := os.Stat("/sys/kernel/security/apparmor"); err == nil && os.Getenv("container") == "" {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
limitations under the License.
1717
*/
1818

19-
package server
19+
package apparmor
2020

2121
//nolint: deadcode, unused
22-
func hostSupportsAppArmor() bool {
22+
func HostSupports() bool {
2323
return false
2424
}

pkg/cri/server/helpers_linux.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030

3131
"github.com/containerd/containerd/log"
3232
"github.com/containerd/containerd/mount"
33+
"github.com/containerd/containerd/pkg/apparmor"
3334
"github.com/containerd/containerd/pkg/seccomp"
3435
"github.com/containerd/containerd/pkg/seutil"
3536
"github.com/opencontainers/runtime-spec/specs-go"
@@ -146,7 +147,7 @@ func (c *criService) apparmorEnabled() bool {
146147
if c.config.DisableApparmor {
147148
return false
148149
}
149-
return hostSupportsAppArmor()
150+
return apparmor.HostSupports()
150151
}
151152

152153
func (c *criService) seccompEnabled() bool {

0 commit comments

Comments
 (0)