mirror of
https://github.com/containers/podman.git
synced 2025-05-21 00:56:36 +08:00
Use current user if no user specified
Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
This commit is contained in:
@ -9,6 +9,7 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
|
"os/user"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -151,6 +152,13 @@ func sshClient(_url *url.URL, uri string, identity string, machine bool) (Connec
|
|||||||
URI: _url,
|
URI: _url,
|
||||||
}
|
}
|
||||||
userinfo := _url.User
|
userinfo := _url.User
|
||||||
|
if _url.User == nil {
|
||||||
|
u, err := user.Current()
|
||||||
|
if err != nil {
|
||||||
|
return connection, fmt.Errorf("current user could not be determined: %w", err)
|
||||||
|
}
|
||||||
|
userinfo = url.User(u.Username)
|
||||||
|
}
|
||||||
port := 22
|
port := 22
|
||||||
if _url.Port() != "" {
|
if _url.Port() != "" {
|
||||||
port, err = strconv.Atoi(_url.Port())
|
port, err = strconv.Atoi(_url.Port())
|
||||||
|
Reference in New Issue
Block a user