From 77e6ae24369e6c7bed85141ae6f7d0c7b0e26c0b Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Wed, 5 May 2021 22:51:23 +0200 Subject: Add envars to the generated systemd unit The with --new generated systemd unit loses the environment variables when the create command only contains the key without the value. Since podman tries to lookup those values from the environment the unit can fail. This commits ensures that we will add the environment variables to the unit file when this is the case. The container environment variables are looked up in the container spec. Fixes #10101 Signed-off-by: Paul Holzinger --- test/system/250-systemd.bats | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test') diff --git a/test/system/250-systemd.bats b/test/system/250-systemd.bats index b42769409..4ea192009 100644 --- a/test/system/250-systemd.bats +++ b/test/system/250-systemd.bats @@ -125,4 +125,27 @@ function service_cleanup() { service_cleanup } +# These tests can fail in dev. environment because of SELinux. +# quick fix: chcon -t container_runtime_exec_t ./bin/podman +@test "podman generate systemd - envar" { + xdg_rootless + + cname=$(random_string) + FOO=value BAR=%s run_podman create --name $cname --env FOO -e BAR --env MYVAR=myval \ + $IMAGE sh -c 'printenv && sleep 100' + + # Start systemd service to run this container + service_setup + + # Give container time to start; make sure output looks top-like + sleep 2 + run_podman logs $cname + is "$output" ".*FOO=value.*" "FOO environment variable set" + is "$output" ".*BAR=%s.*" "BAR environment variable set" + is "$output" ".*MYVAR=myval.*" "MYVAL environment variable set" + + # All good. Stop service, clean up. + service_cleanup +} + # vim: filetype=sh -- cgit v1.2.3-54-g00ecf