version 1.180, 2017/06/10 06:33:34 |
version 1.181, 2017/10/21 23:06:24 |
|
|
"[-i identity_file] [-l limit]\n" |
"[-i identity_file] [-l limit]\n" |
" [-o ssh_option] [-P port] [-R num_requests] " |
" [-o ssh_option] [-P port] [-R num_requests] " |
"[-S program]\n" |
"[-S program]\n" |
" [-s subsystem | sftp_server] host\n" |
" [-s subsystem | sftp_server] destination\n", |
" %s [user@]host[:file ...]\n" |
__progname); |
" %s [user@]host[:dir[/]]\n" |
|
" %s -b batchfile [user@]host\n", |
|
__progname, __progname, __progname, __progname); |
|
exit(1); |
exit(1); |
} |
} |
|
|
int |
int |
main(int argc, char **argv) |
main(int argc, char **argv) |
{ |
{ |
int in, out, ch, err; |
int in, out, ch, err, tmp, port = -1; |
char *host = NULL, *userhost, *cp, *file2 = NULL; |
char *host = NULL, *user, *cp, *file2 = NULL; |
int debug_level = 0, sshver = 2; |
int debug_level = 0, sshver = 2; |
char *file1 = NULL, *sftp_server = NULL; |
char *file1 = NULL, *sftp_server = NULL; |
char *ssh_program = _PATH_SSH_PROGRAM, *sftp_direct = NULL; |
char *ssh_program = _PATH_SSH_PROGRAM, *sftp_direct = NULL; |
|
|
addargs(&args, "-%c", ch); |
addargs(&args, "-%c", ch); |
break; |
break; |
case 'P': |
case 'P': |
addargs(&args, "-oPort %s", optarg); |
port = a2port(optarg); |
|
if (port <= 0) |
|
fatal("Bad port \"%s\"\n", optarg); |
break; |
break; |
case 'v': |
case 'v': |
if (debug_level < 3) { |
if (debug_level < 3) { |
|
|
if (sftp_direct == NULL) { |
if (sftp_direct == NULL) { |
if (optind == argc || argc > (optind + 2)) |
if (optind == argc || argc > (optind + 2)) |
usage(); |
usage(); |
|
argv += optind; |
|
|
userhost = xstrdup(argv[optind]); |
switch (parse_uri("sftp", *argv, &user, &host, &tmp, &file1)) { |
file2 = argv[optind+1]; |
case -1: |
|
usage(); |
if ((host = strrchr(userhost, '@')) == NULL) |
break; |
host = userhost; |
case 0: |
else { |
if (tmp != -1) |
*host++ = '\0'; |
port = tmp; |
if (!userhost[0]) { |
break; |
fprintf(stderr, "Missing username\n"); |
default: |
usage(); |
if (parse_user_host_path(*argv, &user, &host, |
|
&file1) == -1) { |
|
/* Treat as a plain hostname. */ |
|
host = xstrdup(*argv); |
|
host = cleanhostname(host); |
} |
} |
addargs(&args, "-l"); |
break; |
addargs(&args, "%s", userhost); |
|
} |
} |
|
file2 = *(argv + 1); |
|
|
if ((cp = colon(host)) != NULL) { |
|
*cp++ = '\0'; |
|
file1 = cp; |
|
} |
|
|
|
host = cleanhostname(host); |
|
if (!*host) { |
if (!*host) { |
fprintf(stderr, "Missing hostname\n"); |
fprintf(stderr, "Missing hostname\n"); |
usage(); |
usage(); |
} |
} |
|
|
|
if (port != -1) |
|
addargs(&args, "-oPort %d", port); |
|
if (user != NULL) { |
|
addargs(&args, "-l"); |
|
addargs(&args, "%s", user); |
|
} |
addargs(&args, "-oProtocol %d", sshver); |
addargs(&args, "-oProtocol %d", sshver); |
|
|
/* no subsystem if the server-spec contains a '/' */ |
/* no subsystem if the server-spec contains a '/' */ |