mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-13 11:15:08 +00:00
Don't hardcode ssh port 22, use VIR_FREE, initialize pointers to NULL not 0.
This commit is contained in:
parent
4a5dfb847b
commit
e69b20d616
@ -1,3 +1,8 @@
|
|||||||
|
Sat Jan 31 14:45:58 CET 2009 Guido Günther<agx@sigxcpu.org>
|
||||||
|
|
||||||
|
* src/remote_internal.c (doRemoteOpen): Don't hardcode ssh port 22,
|
||||||
|
use VIR_FREE, initialize pointers to NULL not 0.
|
||||||
|
|
||||||
Sat Jan 31 11:43:21 CET 2009 Daniel Veillard <veillard@redhat.com>
|
Sat Jan 31 11:43:21 CET 2009 Daniel Veillard <veillard@redhat.com>
|
||||||
|
|
||||||
* configure.in docs/* NEWS: release of 0.6.0
|
* configure.in docs/* NEWS: release of 0.6.0
|
||||||
|
@ -370,8 +370,8 @@ doRemoteOpen (virConnectPtr conn,
|
|||||||
/* Local variables which we will initialise. These can
|
/* Local variables which we will initialise. These can
|
||||||
* get freed in the failed: path.
|
* get freed in the failed: path.
|
||||||
*/
|
*/
|
||||||
char *name = 0, *command = 0, *sockname = 0, *netcat = 0, *username = 0;
|
char *name = NULL, *command = NULL, *sockname = NULL, *netcat = NULL;
|
||||||
char *port = 0, *authtype = 0;
|
char *port = NULL, *authtype = NULL, *username = NULL;
|
||||||
int no_verify = 0, no_tty = 0;
|
int no_verify = 0, no_tty = 0;
|
||||||
char **cmd_argv = NULL;
|
char **cmd_argv = NULL;
|
||||||
|
|
||||||
@ -387,11 +387,8 @@ doRemoteOpen (virConnectPtr conn,
|
|||||||
} else if (transport == trans_tcp) {
|
} else if (transport == trans_tcp) {
|
||||||
port = strdup (LIBVIRTD_TCP_PORT);
|
port = strdup (LIBVIRTD_TCP_PORT);
|
||||||
if (!port) goto out_of_memory;
|
if (!port) goto out_of_memory;
|
||||||
} else if (transport == trans_ssh) {
|
|
||||||
port = strdup ("22");
|
|
||||||
if (!port) goto out_of_memory;
|
|
||||||
} else
|
} else
|
||||||
port = NULL; /* Port not used for unix, ext. */
|
port = NULL; /* Port not used for unix, ext., default for ssh */
|
||||||
|
|
||||||
|
|
||||||
priv->hostname = strdup (conn->uri && conn->uri->server ?
|
priv->hostname = strdup (conn->uri && conn->uri->server ?
|
||||||
@ -673,24 +670,27 @@ doRemoteOpen (virConnectPtr conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
case trans_ssh: {
|
case trans_ssh: {
|
||||||
int j, nr_args = 8;
|
int j, nr_args = 6;
|
||||||
|
|
||||||
if (username) nr_args += 2; /* For -l username */
|
if (username) nr_args += 2; /* For -l username */
|
||||||
if (no_tty) nr_args += 5; /* For -T -o BatchMode=yes -e none */
|
if (no_tty) nr_args += 5; /* For -T -o BatchMode=yes -e none */
|
||||||
|
if (port) nr_args += 2; /* For -p port */
|
||||||
|
|
||||||
command = command ? command : strdup ("ssh");
|
command = command ? command : strdup ("ssh");
|
||||||
if (command == NULL)
|
if (command == NULL)
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
|
|
||||||
// Generate the final command argv[] array.
|
// Generate the final command argv[] array.
|
||||||
// ssh -p $port [-l $username] $hostname $netcat -U $sockname [NULL]
|
// ssh [-p $port] [-l $username] $hostname $netcat -U $sockname [NULL]
|
||||||
if (VIR_ALLOC_N(cmd_argv, nr_args) < 0)
|
if (VIR_ALLOC_N(cmd_argv, nr_args) < 0)
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
cmd_argv[j++] = strdup (command);
|
cmd_argv[j++] = strdup (command);
|
||||||
cmd_argv[j++] = strdup ("-p");
|
if (port) {
|
||||||
cmd_argv[j++] = strdup (port);
|
cmd_argv[j++] = strdup ("-p");
|
||||||
|
cmd_argv[j++] = strdup (port);
|
||||||
|
}
|
||||||
if (username) {
|
if (username) {
|
||||||
cmd_argv[j++] = strdup ("-l");
|
cmd_argv[j++] = strdup ("-l");
|
||||||
cmd_argv[j++] = strdup (username);
|
cmd_argv[j++] = strdup (username);
|
||||||
@ -843,20 +843,20 @@ doRemoteOpen (virConnectPtr conn,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
/* Free up the URL and strings. */
|
/* Free up the URL and strings. */
|
||||||
free (name);
|
VIR_FREE(name);
|
||||||
free (command);
|
VIR_FREE(command);
|
||||||
free (sockname);
|
VIR_FREE(sockname);
|
||||||
free (authtype);
|
VIR_FREE(authtype);
|
||||||
free (netcat);
|
VIR_FREE(netcat);
|
||||||
free (username);
|
VIR_FREE(username);
|
||||||
free (port);
|
VIR_FREE(port);
|
||||||
if (cmd_argv) {
|
if (cmd_argv) {
|
||||||
char **cmd_argv_ptr = cmd_argv;
|
char **cmd_argv_ptr = cmd_argv;
|
||||||
while (*cmd_argv_ptr) {
|
while (*cmd_argv_ptr) {
|
||||||
free (*cmd_argv_ptr);
|
VIR_FREE(*cmd_argv_ptr);
|
||||||
cmd_argv_ptr++;
|
cmd_argv_ptr++;
|
||||||
}
|
}
|
||||||
free (cmd_argv);
|
VIR_FREE(cmd_argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
return retcode;
|
return retcode;
|
||||||
@ -884,11 +884,7 @@ doRemoteOpen (virConnectPtr conn,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->hostname) {
|
VIR_FREE(priv->hostname);
|
||||||
free (priv->hostname);
|
|
||||||
priv->hostname = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user