mirror of
https://github.com/containers/podman.git
synced 2025-11-30 18:18:18 +08:00
api: auth: fix nil deref
By pulling in the fixes from c/common. Add regression tests to make sure it's not happening another time. The error messages are not ideal and should probably be optimized in the `/auth` endpoints directly but it's already an improvement over a nil deref. Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
7
vendor/github.com/containers/common/pkg/auth/auth.go
generated
vendored
7
vendor/github.com/containers/common/pkg/auth/auth.go
generated
vendored
@@ -242,14 +242,19 @@ func replaceURLByHostPort(repository string) (string, error) {
|
||||
// using the -u and -p flags. If the username prompt is left empty, the
|
||||
// displayed userFromAuthFile will be used instead.
|
||||
func getUserAndPass(opts *LoginOptions, password, userFromAuthFile string) (user, pass string, err error) {
|
||||
reader := bufio.NewReader(opts.Stdin)
|
||||
username := opts.Username
|
||||
if username == "" {
|
||||
if opts.Stdin == nil {
|
||||
return "", "", fmt.Errorf("cannot prompt for username without stdin")
|
||||
}
|
||||
|
||||
if userFromAuthFile != "" {
|
||||
fmt.Fprintf(opts.Stdout, "Username (%s): ", userFromAuthFile)
|
||||
} else {
|
||||
fmt.Fprint(opts.Stdout, "Username: ")
|
||||
}
|
||||
|
||||
reader := bufio.NewReader(opts.Stdin)
|
||||
username, err = reader.ReadString('\n')
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("reading username: %w", err)
|
||||
|
||||
2
vendor/github.com/containers/common/version/version.go
generated
vendored
2
vendor/github.com/containers/common/version/version.go
generated
vendored
@@ -1,4 +1,4 @@
|
||||
package version
|
||||
|
||||
// Version is the version of the build.
|
||||
const Version = "0.52.0"
|
||||
const Version = "0.53.0-dev"
|
||||
|
||||
Reference in New Issue
Block a user