mirror of
https://github.com/containers/podman.git
synced 2025-11-28 17:18:58 +08:00
Add AppArmor key to quadlet .container files
Fixes: #27095 Signed-off-by: givensuman <givensuman@duck.com>
This commit is contained in:
@@ -305,6 +305,7 @@ Valid options for `[Container]` are listed below:
|
|||||||
| AddDevice=/dev/foo | --device /dev/foo |
|
| AddDevice=/dev/foo | --device /dev/foo |
|
||||||
| AddHost=example\.com:192.168.10.11 | --add-host example.com:192.168.10.11 |
|
| AddHost=example\.com:192.168.10.11 | --add-host example.com:192.168.10.11 |
|
||||||
| Annotation="XYZ" | --annotation "XYZ" |
|
| Annotation="XYZ" | --annotation "XYZ" |
|
||||||
|
| AppArmor="alternate-profile" | --security-opt apparmor=alternate-profile |
|
||||||
| AutoUpdate=registry | --label "io.containers.autoupdate=registry" |
|
| AutoUpdate=registry | --label "io.containers.autoupdate=registry" |
|
||||||
| CgroupsMode=no-conmon | --cgroups=no-conmon |
|
| CgroupsMode=no-conmon | --cgroups=no-conmon |
|
||||||
| ContainerName=name | --name name |
|
| ContainerName=name | --name name |
|
||||||
@@ -428,6 +429,10 @@ similar to `Environment`.
|
|||||||
|
|
||||||
This key can be listed multiple times.
|
This key can be listed multiple times.
|
||||||
|
|
||||||
|
### `AppArmor=`
|
||||||
|
|
||||||
|
Sets the apparmor confinement profile for the container. A value of `unconfined` turns off apparmor confinement.
|
||||||
|
|
||||||
### `AutoUpdate=`
|
### `AutoUpdate=`
|
||||||
|
|
||||||
Indicates whether the container will be auto-updated ([podman-auto-update(1)](podman-auto-update.1.md)). The following values are supported:
|
Indicates whether the container will be auto-updated ([podman-auto-update(1)](podman-auto-update.1.md)). The following values are supported:
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ const (
|
|||||||
KeyAddHost = "AddHost"
|
KeyAddHost = "AddHost"
|
||||||
KeyAllTags = "AllTags"
|
KeyAllTags = "AllTags"
|
||||||
KeyAnnotation = "Annotation"
|
KeyAnnotation = "Annotation"
|
||||||
|
KeyAppArmor = "AppArmor"
|
||||||
KeyArch = "Arch"
|
KeyArch = "Arch"
|
||||||
KeyArtifact = "Artifact"
|
KeyArtifact = "Artifact"
|
||||||
KeyAuthFile = "AuthFile"
|
KeyAuthFile = "AuthFile"
|
||||||
@@ -248,6 +249,7 @@ var (
|
|||||||
KeyAddDevice: true,
|
KeyAddDevice: true,
|
||||||
KeyAddHost: true,
|
KeyAddHost: true,
|
||||||
KeyAnnotation: true,
|
KeyAnnotation: true,
|
||||||
|
KeyAppArmor: true,
|
||||||
KeyAutoUpdate: true,
|
KeyAutoUpdate: true,
|
||||||
KeyCgroupsMode: true,
|
KeyCgroupsMode: true,
|
||||||
KeyContainerName: true,
|
KeyContainerName: true,
|
||||||
@@ -775,6 +777,11 @@ func ConvertContainer(container *parser.UnitFile, unitsInfoMap map[string]*UnitI
|
|||||||
podman.add("--security-opt", fmt.Sprintf("label=level:%s", securityLabelLevel))
|
podman.add("--security-opt", fmt.Sprintf("label=level:%s", securityLabelLevel))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apparmor, hasApparmor := container.Lookup(ContainerGroup, KeyAppArmor)
|
||||||
|
if hasApparmor && len(apparmor) > 0 {
|
||||||
|
podman.add("--security-opt", fmt.Sprintf("apparmor=%s", apparmor))
|
||||||
|
}
|
||||||
|
|
||||||
devices := container.LookupAllStrv(ContainerGroup, KeyAddDevice)
|
devices := container.LookupAllStrv(ContainerGroup, KeyAddDevice)
|
||||||
for _, device := range devices {
|
for _, device := range devices {
|
||||||
if device[0] == '-' {
|
if device[0] == '-' {
|
||||||
|
|||||||
6
test/e2e/quadlet/apparmor.container
Normal file
6
test/e2e/quadlet/apparmor.container
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
## assert-podman-final-args localhost/imagename
|
||||||
|
## assert-podman-args "--security-opt" "apparmor=someprofilename"
|
||||||
|
|
||||||
|
[Container]
|
||||||
|
Image=localhost/imagename
|
||||||
|
AppArmor=someprofilename
|
||||||
@@ -896,6 +896,7 @@ BOGUS=foo
|
|||||||
runSuccessQuadletTestCase,
|
runSuccessQuadletTestCase,
|
||||||
Entry("Basic container", "basic.container"),
|
Entry("Basic container", "basic.container"),
|
||||||
Entry("annotation.container", "annotation.container"),
|
Entry("annotation.container", "annotation.container"),
|
||||||
|
Entry("apparmor.container", "apparmor.container"),
|
||||||
Entry("autoupdate.container", "autoupdate.container"),
|
Entry("autoupdate.container", "autoupdate.container"),
|
||||||
Entry("basepodman.container", "basepodman.container"),
|
Entry("basepodman.container", "basepodman.container"),
|
||||||
Entry("capabilities.container", "capabilities.container"),
|
Entry("capabilities.container", "capabilities.container"),
|
||||||
|
|||||||
Reference in New Issue
Block a user