>From 901244e97eb138949f80ea305b2fbf3042738659 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 21 Jan 2017 05:30:40 -0500 Subject: [PATCH 2/3] RHEL 5 ONLY DISABLE AUTOMATIC REMOTE PORT ALLOCATION --- p2v/ssh.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/p2v/ssh.c b/p2v/ssh.c index 2dbc109..b1a07fe 100644 --- a/p2v/ssh.c +++ b/p2v/ssh.c @@ -1051,11 +1051,22 @@ open_data_connection (struct config *config, int *local_port, int *remote_port) "-N", NULL }; +#if 0 CLEANUP_FREE char *port_str = NULL; const int ovecsize = 12; int ovector[ovecsize]; +#endif - snprintf (remote_arg, sizeof remote_arg, "0:localhost:%d", nbd_local_port); + /* RHEL 5 hack: ssh does not print the "Allocated port ..." string, + * so we cannot find the remotely allocated port. Instead just + * assign a random port and hope for the best. + */ + static int next_remote_port = 58123; + + snprintf (remote_arg, sizeof remote_arg, "%d:localhost:%d", + next_remote_port, nbd_local_port); + *remote_port = next_remote_port; + next_remote_port++; *local_port = nbd_local_port; nbd_local_port++; @@ -1063,6 +1074,7 @@ open_data_connection (struct config *config, int *local_port, int *remote_port) if (h == NULL) return NULL; +#if 0 switch (mexp_expect (h, (mexp_regexp[]) { { 100, .re = portfwd_re }, @@ -1103,6 +1115,7 @@ open_data_connection (struct config *config, int *local_port, int *remote_port) mexp_close (h); return NULL; } +#endif return h; } -- 1.8.2.3