mirror of
https://github.com/containers/podman.git
synced 2025-06-21 17:38:12 +08:00
Merge pull request #3420 from ashley-cui/remoteconf
Fix crash for when remote host IP or Username is not set in conf file…
This commit is contained in:
@ -22,7 +22,7 @@ func ReadRemoteConfig(reader io.Reader) (*RemoteConfig, error) {
|
||||
// We need to validate each remote connection has fields filled out
|
||||
for name, conn := range remoteConfig.Connections {
|
||||
if len(conn.Destination) < 1 {
|
||||
return nil, errors.Errorf("connection %s has no destination defined", name)
|
||||
return nil, errors.Errorf("connection %q has no destination defined", name)
|
||||
}
|
||||
}
|
||||
return &remoteConfig, err
|
||||
|
@ -15,8 +15,10 @@ import (
|
||||
var remoteEndpoint *Endpoint
|
||||
|
||||
func (r RemoteRuntime) RemoteEndpoint() (remoteEndpoint *Endpoint, err error) {
|
||||
remoteConfigConnections, _ := remoteclientconfig.ReadRemoteConfig(r.config)
|
||||
|
||||
remoteConfigConnections, err := remoteclientconfig.ReadRemoteConfig(r.config)
|
||||
if errors.Cause(err) != remoteclientconfig.ErrNoConfigationFile {
|
||||
return nil, err
|
||||
}
|
||||
// If the user defines an env variable for podman_varlink_bridge
|
||||
// we use that as passed.
|
||||
if bridge := os.Getenv("PODMAN_VARLINK_BRIDGE"); bridge != "" {
|
||||
@ -47,6 +49,10 @@ func (r RemoteRuntime) RemoteEndpoint() (remoteEndpoint *Endpoint, err error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(rc.Username) < 1 {
|
||||
logrus.Debugf("Connection has no username, using current user %q", r.cmd.RemoteUserName)
|
||||
rc.Username = r.cmd.RemoteUserName
|
||||
}
|
||||
remoteEndpoint, err = newBridgeConnection("", rc, r.cmd.LogLevel)
|
||||
// last resort is to make a socket connection with the default varlink address for root user
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user