summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/source/markdown/podman-auto-update.1.md6
-rw-r--r--pkg/autoupdate/autoupdate.go9
-rw-r--r--pkg/varlinkapi/transfers.go2
-rw-r--r--test/system/030-run.bats4
-rw-r--r--test/system/160-volumes.bats13
-rw-r--r--test/system/250-systemd.bats7
6 files changed, 35 insertions, 6 deletions
diff --git a/docs/source/markdown/podman-auto-update.1.md b/docs/source/markdown/podman-auto-update.1.md
index f98b71420..435a767c1 100644
--- a/docs/source/markdown/podman-auto-update.1.md
+++ b/docs/source/markdown/podman-auto-update.1.md
@@ -13,6 +13,8 @@ If the label is present and set to "image", Podman reaches out to the correspond
An image is considered updated if the digest in the local storage is different than the one of the remote image.
If an image must be updated, Podman pulls it down and restarts the systemd unit executing the container.
+If "io.containers.autoupdate.authfile" label is present, Podman reaches out to corresponding authfile when pulling images.
+
At container-creation time, Podman looks up the "PODMAN_SYSTEMD_UNIT" environment variables and stores it verbatim in the container's label.
This variable is now set by all systemd units generated by `podman-generate-systemd` and is set to `%n` (i.e., the name of systemd unit starting the container).
This data is then being used in the auto-update sequence to instruct systemd (via DBUS) to restart the unit and hence to restart the container.
@@ -35,7 +37,9 @@ environment variable. `export REGISTRY_AUTH_FILE=path`
```
# Start a container
-$ podman run --label "io.containers.autoupdate=image" -d busybox:latest top
+$ podman run --label "io.containers.autoupdate=image" \
+ --label "io.containers.autoupdate.autfile=/some/authfile.json" \
+ -d busybox:latest top
bc219740a210455fa27deacc96d50a9e20516492f1417507c13ce1533dbdcd9d
# Generate a systemd unit for this container
diff --git a/pkg/autoupdate/autoupdate.go b/pkg/autoupdate/autoupdate.go
index 1b0419892..eca5c342c 100644
--- a/pkg/autoupdate/autoupdate.go
+++ b/pkg/autoupdate/autoupdate.go
@@ -23,6 +23,10 @@ import (
// container labels.
const Label = "io.containers.autoupdate"
+// Label denotes the container label key to specify authfile in
+// container labels.
+const AuthfileLabel = "io.containers.autoupdate.authfile"
+
// Policy represents an auto-update policy.
type Policy string
@@ -144,6 +148,11 @@ func AutoUpdate(runtime *libpod.Runtime, options Options) ([]string, []error) {
if rawImageName == "" {
errs = append(errs, errors.Errorf("error auto-updating container %q: raw-image name is empty", ctr.ID()))
}
+ labels := ctr.Labels()
+ authFilePath, exists := labels[AuthfileLabel]
+ if exists {
+ options.Authfile = authFilePath
+ }
needsUpdate, err := newerImageAvailable(runtime, image, rawImageName, options)
if err != nil {
errs = append(errs, errors.Wrapf(err, "error auto-updating container %q: image check for %q failed", ctr.ID(), rawImageName))
diff --git a/pkg/varlinkapi/transfers.go b/pkg/varlinkapi/transfers.go
index 9df8ffcdc..aed6e054d 100644
--- a/pkg/varlinkapi/transfers.go
+++ b/pkg/varlinkapi/transfers.go
@@ -39,7 +39,7 @@ func (i *VarlinkAPI) SendFile(call iopodman.VarlinkCall, ftype string, length in
logrus.Debugf("successfully received %s", outputFile.Name())
// Send an ACK to the client
- call.Call.Writer.WriteString(outputFile.Name())
+ call.Call.Writer.WriteString(outputFile.Name() + ":")
call.Call.Writer.Flush()
return nil
diff --git a/test/system/030-run.bats b/test/system/030-run.bats
index ae2e39d6b..1bcf3896f 100644
--- a/test/system/030-run.bats
+++ b/test/system/030-run.bats
@@ -8,8 +8,8 @@ load helpers
# 2019-09 Fedora 31 and rawhide (32) are switching from runc to crun
# because of cgroups v2; crun emits different error messages.
# Default to runc:
- err_no_such_cmd="Error: .*: starting container process caused .*exec:.*stat /no/such/command: no such file or directory"
- err_no_exec_dir="Error: .*: starting container process caused .*exec:.* permission denied"
+ err_no_such_cmd="Error: .*: starting container process caused.*exec:.*stat /no/such/command: no such file or directory"
+ err_no_exec_dir="Error: .*: starting container process caused.*exec:.* permission denied"
# ...but check the configured runtime engine, and switch to crun as needed
run_podman info --format '{{ .Host.OCIRuntime.Path }}'
diff --git a/test/system/160-volumes.bats b/test/system/160-volumes.bats
index cd9f3c8ad..5d65a950f 100644
--- a/test/system/160-volumes.bats
+++ b/test/system/160-volumes.bats
@@ -116,8 +116,17 @@ EOF
chmod 755 $mountpoint/myscript
# By default, volumes are mounted noexec. This should fail.
- run_podman 126 run --rm --volume $myvolume:/vol:z $IMAGE /vol/myscript
- is "$output" ".* OCI runtime permission denied.*" "run on volume, noexec"
+ # ARGH. Unfortunately, runc (used for cgroups v1) produces a different error
+ local expect_rc=126
+ local expect_msg='.* OCI runtime permission denied.*'
+ run_podman info --format '{{ .Host.OCIRuntime.Path }}'
+ if expr "$output" : ".*/runc"; then
+ expect_rc=1
+ expect_msg='.* exec user process caused.*permission denied'
+ fi
+
+ run_podman ${expect_rc} run --rm --volume $myvolume:/vol:z $IMAGE /vol/myscript
+ is "$output" "$expect_msg" "run on volume, noexec"
# With exec, it should pass
run_podman run --rm -v $myvolume:/vol:z,exec $IMAGE /vol/myscript
diff --git a/test/system/250-systemd.bats b/test/system/250-systemd.bats
index cdac43c1c..4bee13414 100644
--- a/test/system/250-systemd.bats
+++ b/test/system/250-systemd.bats
@@ -33,6 +33,13 @@ function teardown() {
# This test can fail in dev. environment because of SELinux.
# quick fix: chcon -t container_runtime_exec_t ./bin/podman
@test "podman generate - systemd - basic" {
+ # podman initializes this if unset, but systemctl doesn't
+ if is_rootless; then
+ if [ -z "$XDG_RUNTIME_DIR" ]; then
+ export XDG_RUNTIME_DIR=/run/user/$(id -u)
+ fi
+ fi
+
cname=$(random_string)
run_podman create --name $cname --detach $IMAGE top