Includes several fixes for config parsing and AppArmor.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
Valentin Rothberg
2020-06-25 17:53:49 +02:00
parent 7766192293
commit e4dcb3e31c
7 changed files with 21 additions and 11 deletions

View File

@@ -2,14 +2,16 @@ package apparmor
import (
"errors"
"github.com/containers/common/version"
)
const (
// ProfilePrefix is used for version-independent presence checks.
ProfilePrefix = "apparmor_profile"
ProfilePrefix = "containers-default-"
// Profile default name
Profile = "container-default"
Profile = ProfilePrefix + version.Version
)
var (

View File

@@ -255,9 +255,11 @@ func CheckProfileAndLoadDefault(name string) (string, error) {
}
}
// If the specified name is not empty or is not a default libpod one,
// ignore it and return the name.
if name != "" && !strings.HasPrefix(name, ProfilePrefix) {
if name == "" {
name = Profile
} else if !strings.HasPrefix(name, ProfilePrefix) {
// If the specified name is not a default one, ignore it and return the
// name.
isLoaded, err := IsLoaded(name)
if err != nil {
return "", err
@@ -268,7 +270,6 @@ func CheckProfileAndLoadDefault(name string) (string, error) {
return name, nil
}
name = Profile
// To avoid expensive redundant loads on each invocation, check
// if it's loaded before installing it.
isLoaded, err := IsLoaded(name)

View File

@@ -822,6 +822,7 @@ func stringsEq(a, b []string) bool {
var (
configOnce sync.Once
configErr error
config *Config
)
@@ -837,11 +838,10 @@ var (
// The system defaults container config files can be overwritten using the
// CONTAINERS_CONF environment variable. This is usually done for testing.
func Default() (*Config, error) {
var err error
configOnce.Do(func() {
config, err = NewConfig("")
config, configErr = NewConfig("")
})
return config, err
return config, configErr
}
func Path() string {

View File

@@ -0,0 +1,4 @@
package version
// Version is the version of the build.
const Version = "0.14.3"