| ︙ | | | ︙ | |
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
static int preserve = 0;
static int targetshouldbedirectory = 0;
static int statistics = 1;
static int prev_stats_len = 0;
static int scp_unsafe_mode = 0;
static int errs = 0;
static int gui_mode = 0;
static int using_sftp = 0;
static Backend *back;
static void *backhandle;
static Config cfg;
static void source(char *src);
|
>
>
>
>
|
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
static int preserve = 0;
static int targetshouldbedirectory = 0;
static int statistics = 1;
static int prev_stats_len = 0;
static int scp_unsafe_mode = 0;
static int errs = 0;
static int gui_mode = 0;
static int try_scp = 1;
static int try_sftp = 1;
static int main_cmd_is_sftp = 0;
static int fallback_cmd_is_sftp = 0;
static int using_sftp = 0;
static Backend *back;
static void *backhandle;
static Config cfg;
static void source(char *src);
|
| ︙ | | | ︙ | |
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
|
*/
static void ssh_scp_init(void)
{
while (!back->sendok(backhandle)) {
if (ssh_sftp_loop_iteration() < 0)
return; /* doom */
}
using_sftp = !ssh_fallback_cmd(backhandle);
if (verbose) {
if (using_sftp)
tell_user(stderr, "Using SFTP");
else
tell_user(stderr, "Using SCP1");
}
}
|
>
>
|
>
>
>
>
|
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
|
*/
static void ssh_scp_init(void)
{
while (!back->sendok(backhandle)) {
if (ssh_sftp_loop_iteration() < 0)
return; /* doom */
}
/* Work out which backend we ended up using. */
if (!ssh_fallback_cmd(backhandle))
using_sftp = main_cmd_is_sftp;
else
using_sftp = fallback_cmd_is_sftp;
if (verbose) {
if (using_sftp)
tell_user(stderr, "Using SFTP");
else
tell_user(stderr, "Using SCP1");
}
}
|
| ︙ | | | ︙ | |
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
|
* X forwarding.
*/
cfg.x11_forward = 0;
cfg.agentfwd = 0;
cfg.portfwd[0] = cfg.portfwd[1] = '\0';
/*
* Attempt to start the SFTP subsystem as a first choice,
* falling back to the provided scp command if that fails.
*/
strcpy(cfg.remote_cmd, "sftp");
cfg.ssh_subsys = TRUE;
cfg.remote_cmd_ptr2 = cmd;
cfg.ssh_subsys2 = FALSE;
cfg.nopty = TRUE;
back = &ssh_backend;
err = back->init(NULL, &backhandle, &cfg, cfg.host, cfg.port, &realhost,0);
if (err != NULL)
bump("ssh_init: %s", err);
|
>
>
>
>
>
>
|
|
>
>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
|
* X forwarding.
*/
cfg.x11_forward = 0;
cfg.agentfwd = 0;
cfg.portfwd[0] = cfg.portfwd[1] = '\0';
/*
* Set up main and possibly fallback command depending on
* options specified by user.
* Attempt to start the SFTP subsystem as a first choice,
* falling back to the provided scp command if that fails.
*/
cfg.remote_cmd_ptr2 = NULL;
if (try_sftp) {
/* First choice is SFTP subsystem. */
main_cmd_is_sftp = 1;
strcpy(cfg.remote_cmd, "sftp");
cfg.ssh_subsys = TRUE;
if (try_scp) {
/* Fallback is to use the provided scp command. */
fallback_cmd_is_sftp = 0;
cfg.remote_cmd_ptr2 = cmd;
cfg.ssh_subsys2 = FALSE;
} else {
/* Since we're not going to try SCP, we may as well try
* harder to find an SFTP server, since in the current
* implementation we have a spare slot. */
fallback_cmd_is_sftp = 1;
/* see psftp.c for full explanation of this kludge */
cfg.remote_cmd_ptr2 =
"test -x /usr/lib/sftp-server && exec /usr/lib/sftp-server\n"
"test -x /usr/local/lib/sftp-server && exec /usr/local/lib/sftp-server\n"
"exec sftp-server";
cfg.ssh_subsys2 = FALSE;
}
} else {
/* Don't try SFTP at all; just try the scp command. */
main_cmd_is_sftp = 0;
cfg.remote_cmd_ptr = cmd;
cfg.ssh_subsys = FALSE;
}
cfg.nopty = TRUE;
back = &ssh_backend;
err = back->init(NULL, &backhandle, &cfg, cfg.host, cfg.port, &realhost,0);
if (err != NULL)
bump("ssh_init: %s", err);
|
| ︙ | | | ︙ | |
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
|
printf(" -pw passw login with specified password\n");
printf(" -1 -2 force use of particular SSH protocol version\n");
printf(" -C enable compression\n");
printf(" -i key private key file for authentication\n");
printf(" -batch disable all interactive prompts\n");
printf(" -unsafe allow server-side wildcards (DANGEROUS)\n");
printf(" -V print version information\n");
#if 0
/*
* -gui is an internal option, used by GUI front ends to get
* pscp to pass progress reports back to them. It's not an
* ordinary user-accessible option, so it shouldn't be part of
* the command-line help. The only people who need to know
* about it are programmers, and they can read the source.
|
>
>
|
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
|
printf(" -pw passw login with specified password\n");
printf(" -1 -2 force use of particular SSH protocol version\n");
printf(" -C enable compression\n");
printf(" -i key private key file for authentication\n");
printf(" -batch disable all interactive prompts\n");
printf(" -unsafe allow server-side wildcards (DANGEROUS)\n");
printf(" -V print version information\n");
printf(" -sftp force use of SFTP protocol\n");
printf(" -scp force use of SCP protocol\n");
#if 0
/*
* -gui is an internal option, used by GUI front ends to get
* pscp to pass progress reports back to them. It's not an
* ordinary user-accessible option, so it shouldn't be part of
* the command-line help. The only people who need to know
* about it are programmers, and they can read the source.
|
| ︙ | | | ︙ | |
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
|
console_batch_mode = TRUE;
} else if (strcmp(argv[i], "-ls") == 0) {
list = 1;
} else if (strcmp(argv[i], "-batch") == 0) {
console_batch_mode = 1;
} else if (strcmp(argv[i], "-unsafe") == 0) {
scp_unsafe_mode = 1;
} else if (strcmp(argv[i], "--") == 0) {
i++;
break;
} else {
cmdline_error("unknown option \"%s\"", argv[i]);
}
}
|
>
>
>
>
|
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
|
console_batch_mode = TRUE;
} else if (strcmp(argv[i], "-ls") == 0) {
list = 1;
} else if (strcmp(argv[i], "-batch") == 0) {
console_batch_mode = 1;
} else if (strcmp(argv[i], "-unsafe") == 0) {
scp_unsafe_mode = 1;
} else if (strcmp(argv[i], "-sftp") == 0) {
try_scp = 0; try_sftp = 1;
} else if (strcmp(argv[i], "-scp") == 0) {
try_scp = 1; try_sftp = 0;
} else if (strcmp(argv[i], "--") == 0) {
i++;
break;
} else {
cmdline_error("unknown option \"%s\"", argv[i]);
}
}
|
| ︙ | | | ︙ | |