Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/source/markdown/podman-systemd.unit.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ Valid options for `[Container]` are listed below:
| AddDevice=/dev/foo | --device /dev/foo |
| AddHost=example\.com:192.168.10.11 | --add-host example.com:192.168.10.11 |
| Annotation="XYZ" | --annotation "XYZ" |
| AppArmor="alternate-profile" | --security-opt apparmor=alternate-profile |
| AutoUpdate=registry | --label "io.containers.autoupdate=registry" |
| CgroupsMode=no-conmon | --cgroups=no-conmon |
| ContainerName=name | --name name |
Expand Down Expand Up @@ -428,6 +429,10 @@ similar to `Environment`.

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=`

Indicates whether the container will be auto-updated ([podman-auto-update(1)](podman-auto-update.1.md)). The following values are supported:
Expand Down
7 changes: 7 additions & 0 deletions pkg/systemd/quadlet/quadlet.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const (
KeyAddHost = "AddHost"
KeyAllTags = "AllTags"
KeyAnnotation = "Annotation"
KeyAppArmor = "AppArmor"
KeyArch = "Arch"
KeyArtifact = "Artifact"
KeyAuthFile = "AuthFile"
Expand Down Expand Up @@ -248,6 +249,7 @@ var (
KeyAddDevice: true,
KeyAddHost: true,
KeyAnnotation: true,
KeyAppArmor: true,
KeyAutoUpdate: true,
KeyCgroupsMode: true,
KeyContainerName: true,
Expand Down Expand Up @@ -775,6 +777,11 @@ func ConvertContainer(container *parser.UnitFile, unitsInfoMap map[string]*UnitI
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)
for _, device := range devices {
if device[0] == '-' {
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/quadlet/apparmor.container
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## assert-podman-final-args localhost/imagename
## assert-podman-args "--security-opt" "apparmor=someprofilename"

[Container]
Image=localhost/imagename
AppArmor=someprofilename
1 change: 1 addition & 0 deletions test/e2e/quadlet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,7 @@ BOGUS=foo
runSuccessQuadletTestCase,
Entry("Basic container", "basic.container"),
Entry("annotation.container", "annotation.container"),
Entry("apparmor.container", "apparmor.container"),
Entry("autoupdate.container", "autoupdate.container"),
Entry("basepodman.container", "basepodman.container"),
Entry("capabilities.container", "capabilities.container"),
Expand Down