Skip to content

Commit

Permalink
Verify authfile exists if user specifies it
Browse files Browse the repository at this point in the history
Fixes: containers#18938

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
  • Loading branch information
rhatdan committed Jul 24, 2023
1 parent a81bf57 commit 2ca5f73
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/podman/containers/create.go
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions test/system/030-run.bats
Expand Up @@ -1158,4 +1158,12 @@ 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"
}

# vim: filetype=sh

0 comments on commit 2ca5f73

Please sign in to comment.