mirror of https://github.com/containers/podman.git
fix port issues for CONTAINER_HOST
if no port is specified for an ssh style url, default to 22 resolves #16509 Signed-off-by: Charlie Doern <cdoern@redhat.com>
This commit is contained in:
parent
a53e152d36
commit
14ef6a91bd
|
@ -91,9 +91,12 @@ func NewConnectionWithIdentity(ctx context.Context, uri string, identity string,
|
||||||
var connection Connection
|
var connection Connection
|
||||||
switch _url.Scheme {
|
switch _url.Scheme {
|
||||||
case "ssh":
|
case "ssh":
|
||||||
port, err := strconv.Atoi(_url.Port())
|
port := 22
|
||||||
if err != nil {
|
if _url.Port() != "" {
|
||||||
return nil, err
|
port, err = strconv.Atoi(_url.Port())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
conn, err := ssh.Dial(&ssh.ConnectionDialOptions{
|
conn, err := ssh.Dial(&ssh.ConnectionDialOptions{
|
||||||
Host: uri,
|
Host: uri,
|
||||||
|
|
|
@ -281,6 +281,15 @@ var _ = Describe("podman system connection", func() {
|
||||||
_, err = Start(cmd, GinkgoWriter, GinkgoWriter)
|
_, err = Start(cmd, GinkgoWriter, GinkgoWriter)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
|
// export the container_host env var and try again
|
||||||
|
err = os.Setenv("CONTAINER_HOST", fmt.Sprintf("ssh://%s@localhost", u.Username))
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
defer os.Unsetenv("CONTAINER_HOST")
|
||||||
|
|
||||||
|
cmd = exec.Command(podmanTest.RemotePodmanBinary, "ps")
|
||||||
|
_, err = Start(cmd, GinkgoWriter, GinkgoWriter)
|
||||||
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
uri := url.URL{
|
uri := url.URL{
|
||||||
Scheme: "ssh",
|
Scheme: "ssh",
|
||||||
User: url.User(u.Username),
|
User: url.User(u.Username),
|
||||||
|
|
Loading…
Reference in New Issue