summaryrefslogtreecommitdiffstats
path: root/src/sss_client
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2017-04-25 14:00:15 +0000
committerLukas Slebodnik <lslebodn@redhat.com>2017-04-28 19:10:17 +0200
commit5f6232c7e6d9635c1d6b6b09f799309b6094b143 (patch)
tree7132d119421d3f01a4e1e2ef6499bc6587fa988f /src/sss_client
parent08084b1179bb9fc38bc22b464b3d44907107bfd3 (diff)
downloadsssd-5f6232c7e6d9635c1d6b6b09f799309b6094b143.tar.gz
sssd-5f6232c7e6d9635c1d6b6b09f799309b6094b143.tar.xz
sssd-5f6232c7e6d9635c1d6b6b09f799309b6094b143.zip
ssh tools: Fix issues with multiple IP addresses
Cycle through all resolved address until one succeed or all fail. This is needed for dual stack systems where either IPv4 or IPv6 are improperly configured or selectively filtered at some point along the route. Resolves: https://pagure.io/SSSD/sssd/issue/1498 Merges: https://pagure.io/SSSD/sssd/pull-request/3383 Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
Diffstat (limited to 'src/sss_client')
-rw-r--r--src/sss_client/ssh/sss_ssh_knownhostsproxy.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/sss_client/ssh/sss_ssh_knownhostsproxy.c b/src/sss_client/ssh/sss_ssh_knownhostsproxy.c
index 310243c2f..b7b0c3bb6 100644
--- a/src/sss_client/ssh/sss_ssh_knownhostsproxy.c
+++ b/src/sss_client/ssh/sss_ssh_knownhostsproxy.c
@@ -295,7 +295,13 @@ int main(int argc, const char **argv)
if (pc_args) {
ret = connect_proxy_command(discard_const(pc_args));
} else if (ai) {
- ret = connect_socket(ai->ai_family, ai->ai_addr, ai->ai_addrlen);
+ /* Try all IP addresses before giving up */
+ for (struct addrinfo *ti = ai; ti != NULL; ti = ti->ai_next) {
+ ret = connect_socket(ti->ai_family, ti->ai_addr, ti->ai_addrlen);
+ if (ret == 0) {
+ break;
+ }
+ }
} else {
ret = EFAULT;
}