mirror of https://github.com/containers/podman.git
				
				
				
			Fix crash for when remote host IP or Username is not set in conf file & conf file exists.
When Host IP is not set in podman-remote.conf, error is printed out. When Username is not set in podman-remote.conf, default username is used. Signed-off-by: Ashley Cui <ashleycui16@gmail.com>
This commit is contained in:
		
							parent
							
								
									21978c9908
								
							
						
					
					
						commit
						bf5686739c
					
				|  | @ -22,7 +22,7 @@ func ReadRemoteConfig(reader io.Reader) (*RemoteConfig, error) { | ||||||
| 	// We need to validate each remote connection has fields filled out
 | 	// We need to validate each remote connection has fields filled out
 | ||||||
| 	for name, conn := range remoteConfig.Connections { | 	for name, conn := range remoteConfig.Connections { | ||||||
| 		if len(conn.Destination) < 1 { | 		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 | 	return &remoteConfig, err | ||||||
|  |  | ||||||
|  | @ -15,8 +15,10 @@ import ( | ||||||
| var remoteEndpoint *Endpoint | var remoteEndpoint *Endpoint | ||||||
| 
 | 
 | ||||||
| func (r RemoteRuntime) RemoteEndpoint() (remoteEndpoint *Endpoint, err error) { | 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
 | 	// If the user defines an env variable for podman_varlink_bridge
 | ||||||
| 	// we use that as passed.
 | 	// we use that as passed.
 | ||||||
| 	if bridge := os.Getenv("PODMAN_VARLINK_BRIDGE"); bridge != "" { | 	if bridge := os.Getenv("PODMAN_VARLINK_BRIDGE"); bridge != "" { | ||||||
|  | @ -47,6 +49,10 @@ func (r RemoteRuntime) RemoteEndpoint() (remoteEndpoint *Endpoint, err error) { | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return nil, err | 			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) | 		remoteEndpoint, err = newBridgeConnection("", rc, r.cmd.LogLevel) | ||||||
| 		//	last resort is to make a socket connection with the default varlink address for root user
 | 		//	last resort is to make a socket connection with the default varlink address for root user
 | ||||||
| 	} else { | 	} else { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue