diff --git a/cmd/podman/containers/create.go b/cmd/podman/containers/create.go index a3b9e3e143bf..d5b4bbcc435a 100644 --- a/cmd/podman/containers/create.go +++ b/cmd/podman/containers/create.go @@ -154,6 +154,13 @@ func create(cmd *cobra.Command, args []string) error { } imageName = name } + + if cliVals.Authfile != "" { + if _, err := os.Stat(cliVals.Authfile); err != nil { + return err + } + } + s := specgen.NewSpecGenerator(imageName, cliVals.RootFS) if err := specgenutil.FillOutSpecGen(s, &cliVals, args); err != nil { return err diff --git a/test/system/030-run.bats b/test/system/030-run.bats index 2b089f25731e..ac4d932da740 100644 --- a/test/system/030-run.bats +++ b/test/system/030-run.bats @@ -1158,4 +1158,15 @@ EOF run_podman rm -f -t0 $ctr } +@test "podman run --authfile=/tmp/bogus " { + run_podman 125 run --authfile=/tmp/bogus $IMAGE false + is "$output" "Error: stat /tmp/bogus: no such file or directory" "should faile with not such file" + + run_podman 125 create --authfile=/tmp/bogus $IMAGE false + is "$output" "Error: stat /tmp/bogus: no such file or directory" "should faile with not such file" + + run_podman 125 pull --authfile=/tmp/bogus $IMAGE + is "$output" "Error: stat /tmp/bogus: no such file or directory" "should faile with not such file" +} + # vim: filetype=sh diff --git a/test/system/700-play.bats b/test/system/700-play.bats index 2bcea8b7d181..24d00569b4aa 100644 --- a/test/system/700-play.bats +++ b/test/system/700-play.bats @@ -724,3 +724,12 @@ spec: run_podman kube down $pod_file } + +@test "podman kube with --authfile=/tmp/bogus" { + TESTDIR=$PODMAN_TMPDIR/testdir + mkdir -p $TESTDIR + echo "$testYaml" | sed "s|TESTDIR|${TESTDIR}|g" > $PODMAN_TMPDIR/test.yaml + + run_podman 125 kube play --authfile=/tmp/bogus - < $PODMAN_TMPDIR/test.yaml + is "$output" "Error: stat /tmp/bogus: no such file or directory" "should faile with not such file" +}