From 936a01e08895270ef7cd97faab21ceca35cf0319 Mon Sep 17 00:00:00 2001 From: Ygal Blum Date: Tue, 9 Sep 2025 10:25:17 -0400 Subject: [PATCH] Quadlet build - consider File path that starts with a systemd specifier as absolute Fixes https://github.com/containers/podman/issues/26746 Signed-off-by: Ygal Blum --- pkg/systemd/quadlet/quadlet.go | 2 +- test/e2e/quadlet/no-workingdirectory-systemd-specifier.build | 3 +++ test/e2e/quadlet_test.go | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 test/e2e/quadlet/no-workingdirectory-systemd-specifier.build diff --git a/pkg/systemd/quadlet/quadlet.go b/pkg/systemd/quadlet/quadlet.go index 71b198223d..575abe0774 100644 --- a/pkg/systemd/quadlet/quadlet.go +++ b/pkg/systemd/quadlet/quadlet.go @@ -1428,7 +1428,7 @@ func ConvertBuild(build *parser.UnitFile, unitsInfoMap map[string]*UnitInfo, isU // Context or WorkingDirectory has to be last argument if len(context) > 0 { podman.add(context) - } else if !filepath.IsAbs(filePath) && !isURL(filePath) { + } else if !startsWithSystemdSpecifier(filePath) && !filepath.IsAbs(filePath) && !isURL(filePath) { // Special handling for relative filePaths if len(workingDirectory) == 0 { return nil, warnings, fmt.Errorf("relative path in File key requires SetWorkingDirectory key to be set") diff --git a/test/e2e/quadlet/no-workingdirectory-systemd-specifier.build b/test/e2e/quadlet/no-workingdirectory-systemd-specifier.build new file mode 100644 index 0000000000..3ad14d992f --- /dev/null +++ b/test/e2e/quadlet/no-workingdirectory-systemd-specifier.build @@ -0,0 +1,3 @@ +[Build] +ImageTag=localhost/example +File=%h/images/example.Containerfile diff --git a/test/e2e/quadlet_test.go b/test/e2e/quadlet_test.go index f3c1dda2ce..c214bd7881 100644 --- a/test/e2e/quadlet_test.go +++ b/test/e2e/quadlet_test.go @@ -1074,6 +1074,7 @@ BOGUS=foo Entry("Build - Variant Key", "variant.build"), Entry("Build - No Default Dependencies", "no_deps.build"), Entry("Build - Retry", "retry.build"), + Entry("Build - No WorkingDirectory with systemd specifier", "no-workingdirectory-systemd-specifier.build"), Entry("Pod - Basic", "basic.pod"), Entry("Pod - DNS", "dns.pod"),