-char **
-make_ssh_args(char *add_arg)
-{
- static char **args = NULL;
- static int nargs = 0;
- char debug_buf[4096];
- int i;
-
- /* Init args array */
- if (args == NULL) {
- nargs = 2;
- i = 0;
- args = xmalloc(sizeof(*args) * nargs);
- args[i++] = "ssh";
- args[i++] = NULL;
- }
-
- /* If asked to add args, then do so and return */
- if (add_arg) {
- i = nargs++ - 1;
- args = xrealloc(args, sizeof(*args) * nargs);
- args[i++] = add_arg;
- args[i++] = NULL;
- return(NULL);
- }
-
- /* no subsystem if the server-spec contains a '/' */
- if (sftp_server == NULL || strchr(sftp_server, '/') == NULL)
- make_ssh_args("-s");
- make_ssh_args("-oForwardX11=no");
- make_ssh_args("-oForwardAgent=no");
- make_ssh_args(use_ssh1 ? "-oProtocol=1" : "-oProtocol=2");
-
- /* Otherwise finish up and return the arg array */
- if (sftp_server != NULL)
- make_ssh_args(sftp_server);
- else
- make_ssh_args("sftp");
-
- /* XXX: overflow - doesn't grow debug_buf */
- debug_buf[0] = '\0';
- for(i = 0; args[i]; i++) {
- if (i)
- strlcat(debug_buf, " ", sizeof(debug_buf));
-
- strlcat(debug_buf, args[i], sizeof(debug_buf));
- }
- debug("SSH args \"%s\"", debug_buf);
-
- return(args);
-}
-
-void