|
Line
Link Here
|
| 0 |
-- pathnames.h Mon Jul 12 01:48:47 2004 |
0 |
++ pathnames.h Wed Sep 1 00:48:12 2004 |
|
Lines 45-50
Link Here
|
| 45 |
*/ |
45 |
*/ |
| 46 |
#define _PATH_SSH_DAEMON_PID_FILE _PATH_SSH_PIDDIR "/sshd.pid" |
46 |
#define _PATH_SSH_DAEMON_PID_FILE _PATH_SSH_PIDDIR "/sshd.pid" |
|
|
47 |
#define _PATH_SCP_REMOTE_PROGRAM "/usr/bin/scp" |
| 48 |
|
| 47 |
/* |
49 |
/* |
| 48 |
* The directory in user\'s home directory in which the files reside. The |
50 |
* The directory in user\'s home directory in which the files reside. The |
| 49 |
* directory should be world-readable (though not all files are). |
51 |
* directory should be world-readable (though not all files are). |
| 50 |
-- scp.c Thu Aug 12 05:44:32 2004 |
52 |
++ scp.c Wed Sep 1 00:48:51 2004 |
|
Lines 102-107
Link Here
|
| 102 |
/* This is the program to execute for the secured connection. ("ssh" or |
102 |
/* This is the program to execute for the secured connection. ("ssh" or |
| 103 |
S) */ |
|
|
| 104 |
char *ssh_program = _PATH_SSH_PROGRAM; |
103 |
char *ssh_program = _PATH_SSH_PROGRAM; |
|
|
104 |
/* This is the program to execute for the remote scp. ("scp" or -e) */ |
| 105 |
char *scp_remote_program = _PATH_SCP_REMOTE_PROGRAM; |
| 106 |
|
| 105 |
/* This is used to store the pid of ssh_program */ |
107 |
/* This is used to store the pid of ssh_program */ |
| 106 |
pid_t do_cmd_pid = -1; |
108 |
pid_t do_cmd_pid = -1; |
|
Lines 198-205
Link Here
|
| 198 |
int errs, remin, remout; |
201 |
int errs, remin, remout; |
| 199 |
int pflag, iamremote, iamrecursive, targetshouldbedirectory; |
202 |
int pflag, iamremote, iamrecursive, targetshouldbedirectory; |
| 200 |
#define CMDNEEDS 64 |
203 |
char *rscpcmd; /* must hold scp_remote_program + "-r -p -d\0" */ |
| 201 |
char cmd[CMDNEEDS]; /* must hold "rcp -r -p -d\0" */ |
204 |
|
| 202 |
int response(void); |
205 |
int response(void); |
| 203 |
void rsource(char *, struct stat *); |
206 |
void rsource(char *, struct stat *); |
|
Lines 212-223
Link Here
|
| 212 |
int |
215 |
int |
| 213 |
main(int argc, char **argv) |
216 |
main(int argc, char **argv) |
| 214 |
{ |
217 |
{ |
| 215 |
int ch, fflag, tflag, status; |
218 |
int ch, fflag, tflag, status, rscpcmdlen; |
| 216 |
double speed; |
219 |
double speed; |
| 217 |
char *targ, *endp; |
220 |
char *targ, *endp; |
| 218 |
extern char *optarg; |
221 |
extern char *optarg; |
| 219 |
extern int optind; |
222 |
extern int optind; |
|
|
223 |
rscpcmdlen = 1; |
| 220 |
args.list = NULL; |
224 |
args.list = NULL; |
| 221 |
addargs(&args, "ssh"); /* overwritten with ssh_program */ |
225 |
addargs(&args, "ssh"); /* overwritten with ssh_program */ |
| 222 |
addargs(&args, "-x"); |
226 |
addargs(&args, "-x"); |
|
Lines 225-231
Link Here
|
| 225 |
addargs(&args, "-oClearAllForwardings yes"); |
229 |
addargs(&args, "-oClearAllForwardings yes"); |
| 226 |
fflag = tflag = 0; |
230 |
fflag = tflag = 0; |
| 227 |
while ((ch = getopt(argc, argv, "dfl:prtvBCc:i:P:q1246S:o:F:")) != |
231 |
while ((ch = getopt(argc, argv, "dfl:prtvBCc:i:P:q1246S:o:F:e:")) |
| 228 |
1) |
|
|
| 229 |
switch (ch) { |
232 |
switch (ch) { |
| 230 |
/* User-visible flags. */ |
233 |
/* User-visible flags. */ |
| 231 |
case '1': |
234 |
case '1': |
|
Lines 255-263
Link Here
|
| 255 |
break; |
259 |
break; |
| 256 |
case 'p': |
260 |
case 'p': |
| 257 |
pflag = 1; |
261 |
pflag = 1; |
|
|
262 |
rscpcmdlen += 3; |
| 258 |
break; |
263 |
break; |
| 259 |
case 'r': |
264 |
case 'r': |
| 260 |
iamrecursive = 1; |
265 |
iamrecursive = 1; |
|
|
266 |
rscpcmdlen += 3; |
| 267 |
break; |
| 268 |
case 'e': |
| 269 |
scp_remote_program = xstrdup(optarg); |
| 261 |
break; |
270 |
break; |
| 262 |
case 'S': |
271 |
case 'S': |
| 263 |
ssh_program = xstrdup(optarg); |
272 |
ssh_program = xstrdup(optarg); |
|
Lines 265-270
Link Here
|
| 265 |
case 'v': |
274 |
case 'v': |
| 266 |
addargs(&args, "-v"); |
275 |
addargs(&args, "-v"); |
| 267 |
verbose_mode = 1; |
276 |
verbose_mode = 1; |
|
|
277 |
rscpcmdlen += 3; |
| 268 |
break; |
278 |
break; |
| 269 |
case 'q': |
279 |
case 'q': |
| 270 |
addargs(&args, "-q"); |
280 |
addargs(&args, "-q"); |
|
Lines 274-279
Link Here
|
| 274 |
/* Server options. */ |
284 |
/* Server options. */ |
| 275 |
case 'd': |
285 |
case 'd': |
| 276 |
targetshouldbedirectory = 1; |
286 |
targetshouldbedirectory = 1; |
|
|
287 |
rscpcmdlen += 3; |
| 277 |
break; |
288 |
break; |
| 278 |
case 'f': /* "from" */ |
289 |
case 'f': /* "from" */ |
| 279 |
iamremote = 1; |
290 |
iamremote = 1; |
|
Lines 316-323
Link Here
|
| 316 |
remin = remout = -1; |
327 |
remin = remout = -1; |
| 317 |
do_cmd_pid = -1; |
328 |
do_cmd_pid = -1; |
|
|
329 |
rscpcmdlen += strlen(scp_remote_program); |
| 330 |
rscpcmd = xmalloc(rscpcmdlen); |
| 318 |
/* Command to be executed on remote system using "ssh". */ |
331 |
/* Command to be executed on remote system using "ssh". */ |
| 319 |
(void) snprintf(cmd, sizeof cmd, "scp%s%s%s%s", |
332 |
(void) snprintf(rscpcmd, rscpcmdlen, "%s%s%s%s%s", |
|
|
333 |
scp_remote_program, |
| 320 |
verbose_mode ? " -v" : "", |
334 |
verbose_mode ? " -v" : "", |
| 321 |
iamrecursive ? " -r" : "", pflag ? " -p" : "", |
335 |
iamrecursive ? " -r" : "", pflag ? " -p" : "", |
| 322 |
targetshouldbedirectory ? " -d" : ""); |
336 |
targetshouldbedirectory ? " -d" : ""); |
|
Lines 347-352
Link Here
|
| 347 |
errs = 1; |
361 |
errs = 1; |
| 348 |
} |
362 |
} |
| 349 |
} |
363 |
} |
|
|
364 |
xfree(rscpcmd); |
| 350 |
exit(errs != 0); |
365 |
exit(errs != 0); |
| 351 |
} |
366 |
} |
|
Lines 383-389
Link Here
|
| 383 |
len = strlen(ssh_program) + strlen(argv[i]) + |
398 |
len = strlen(ssh_program) + strlen(argv[i]) + |
| 384 |
strlen(src) + (tuser ? strlen(tuser) : 0) + |
399 |
strlen(src) + (tuser ? strlen(tuser) : 0) + |
| 385 |
strlen(thost) + strlen(targ) + |
400 |
strlen(thost) + strlen(targ) + |
| 386 |
strlen(ssh_options) + CMDNEEDS + 20; |
401 |
strlen(ssh_options) + strlen(rscpcmd) + 20; |
| 387 |
bp = xmalloc(len); |
402 |
bp = xmalloc(len); |
| 388 |
if (host) { |
403 |
if (host) { |
| 389 |
*host++ = 0; |
404 |
*host++ = 0; |
|
Lines 403-409
Link Here
|
| 403 |
"%s%s %s -n " |
418 |
"%s%s %s -n " |
| 404 |
"-l %s %s %s %s '%s%s%s:%s'", |
419 |
"-l %s %s %s %s '%s%s%s:%s'", |
| 405 |
ssh_program, verbose_mode ? " -v" : "", |
420 |
ssh_program, verbose_mode ? " -v" : "", |
| 406 |
ssh_options, suser, host, cmd, src, |
421 |
ssh_options, suser, host, rscpcmd, src, |
| 407 |
tuser ? tuser : "", tuser ? "@" : "", |
422 |
tuser ? tuser : "", tuser ? "@" : "", |
| 408 |
thost, targ); |
423 |
thost, targ); |
| 409 |
} else { |
424 |
} else { |
|
Lines 412-418
Link Here
|
| 412 |
"exec %s%s %s -n %s " |
427 |
"exec %s%s %s -n %s " |
| 413 |
"%s %s '%s%s%s:%s'", |
428 |
"%s %s '%s%s%s:%s'", |
| 414 |
ssh_program, verbose_mode ? " -v" : "", |
429 |
ssh_program, verbose_mode ? " -v" : "", |
| 415 |
ssh_options, host, cmd, src, |
430 |
ssh_options, host, rscpcmd, src, |
| 416 |
tuser ? tuser : "", tuser ? "@" : "", |
431 |
tuser ? tuser : "", tuser ? "@" : "", |
| 417 |
thost, targ); |
432 |
thost, targ); |
| 418 |
} |
433 |
} |
|
Lines 423-431
Link Here
|
| 423 |
(void) xfree(bp); |
438 |
(void) xfree(bp); |
| 424 |
} else { /* local to remote */ |
439 |
} else { /* local to remote */ |
| 425 |
if (remin == -1) { |
440 |
if (remin == -1) { |
| 426 |
len = strlen(targ) + CMDNEEDS + 20; |
441 |
len = strlen(targ) + strlen(rscpcmd) + 20; |
| 427 |
bp = xmalloc(len); |
442 |
bp = xmalloc(len); |
| 428 |
(void) snprintf(bp, len, "%s -t %s", cmd, |
443 |
(void) snprintf(bp, len, "%s -t %s", |
| 429 |
host = cleanhostname(thost); |
444 |
host = cleanhostname(thost); |
| 430 |
if (do_cmd(host, tuser, bp, &remin, |
445 |
if (do_cmd(host, tuser, bp, &remin, |
| 431 |
&remout, argc) < 0) |
446 |
&remout, argc) < 0) |
|
Lines 473-481
Link Here
|
| 473 |
suser = pwd->pw_name; |
488 |
suser = pwd->pw_name; |
| 474 |
} |
489 |
} |
| 475 |
host = cleanhostname(host); |
490 |
host = cleanhostname(host); |
| 476 |
len = strlen(src) + CMDNEEDS + 20; |
491 |
len = strlen(src) + strlen(rscpcmd) + 20; |
| 477 |
bp = xmalloc(len); |
492 |
bp = xmalloc(len); |
| 478 |
(void) snprintf(bp, len, "%s -f %s", cmd, src); |
493 |
(void) snprintf(bp, len, "%s -f %s", rscpcmd, src); |
| 479 |
if (do_cmd(host, suser, bp, &remin, &remout, argc) < 0) { |
494 |
if (do_cmd(host, suser, bp, &remin, &remout, argc) < 0) { |
| 480 |
(void) xfree(bp); |
495 |
(void) xfree(bp); |
| 481 |
++errs; |
496 |
++errs; |
|
Lines 1013-1019
Link Here
|
| 1013 |
{ |
1028 |
{ |
| 1014 |
(void) fprintf(stderr, |
1029 |
(void) fprintf(stderr, |
| 1015 |
"usage: scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i |
1030 |
"usage: scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i |
| 1016 |
" [-l limit] [-o ssh_option] [-P port] [-S program]\n" |
1031 |
" [-l limit] [-o ssh_option] [-P port] [-S program] |
| 1017 |
" [[user@]host1:]file1 [...] [[user@]host2:]file2\n"); |
1032 |
" [[user@]host1:]file1 [...] [[user@]host2:]file2\n"); |
| 1018 |
exit(1); |
1033 |
exit(1); |
| 1019 |
} |
1034 |
} |