version 1.33, 2000/07/13 23:19:31 |
version 1.34, 2000/08/19 02:26:08 |
|
|
/* This is the port to use in contacting the remote site (is non-NULL). */ |
/* This is the port to use in contacting the remote site (is non-NULL). */ |
char *port = NULL; |
char *port = NULL; |
|
|
|
/* This is the program to execute for the secured connection. ("ssh" or -S) */ |
|
char *ssh_program = SSH_PROGRAM; |
|
|
/* |
/* |
* This function executes the given command as the specified user on the |
* This function executes the given command as the specified user on the |
* given host. This returns < 0 if execution fails, and >= 0 otherwise. This |
* given host. This returns < 0 if execution fails, and >= 0 otherwise. This |
|
|
close(pout[1]); |
close(pout[1]); |
|
|
i = 0; |
i = 0; |
args[i++] = SSH_PROGRAM; |
args[i++] = ssh_program; |
args[i++] = "-x"; |
args[i++] = "-x"; |
args[i++] = "-oFallBackToRsh no"; |
args[i++] = "-oFallBackToRsh no"; |
if (IPv4) |
if (IPv4) |
|
|
args[i++] = cmd; |
args[i++] = cmd; |
args[i++] = NULL; |
args[i++] = NULL; |
|
|
execvp(SSH_PROGRAM, args); |
execvp(ssh_program, args); |
perror(SSH_PROGRAM); |
perror(ssh_program); |
exit(1); |
exit(1); |
} |
} |
/* Parent. Close the other side, and return the local side. */ |
/* Parent. Close the other side, and return the local side. */ |
|
|
extern int optind; |
extern int optind; |
|
|
fflag = tflag = 0; |
fflag = tflag = 0; |
while ((ch = getopt(argc, argv, "dfprtvBCc:i:P:q46")) != EOF) |
while ((ch = getopt(argc, argv, "dfprtvBCc:i:P:q46S")) != EOF) |
switch (ch) { |
switch (ch) { |
/* User-visible flags. */ |
/* User-visible flags. */ |
case '4': |
case '4': |
|
|
case 'r': |
case 'r': |
iamrecursive = 1; |
iamrecursive = 1; |
break; |
break; |
|
case 'S': |
|
ssh_program = optarg; |
|
break; |
|
|
/* Server options. */ |
/* Server options. */ |
case 'd': |
case 'd': |
targetshouldbedirectory = 1; |
targetshouldbedirectory = 1; |
|
|
if (*src == 0) |
if (*src == 0) |
src = "."; |
src = "."; |
host = strchr(argv[i], '@'); |
host = strchr(argv[i], '@'); |
len = strlen(SSH_PROGRAM) + strlen(argv[i]) + |
len = strlen(ssh_program) + strlen(argv[i]) + |
strlen(src) + (tuser ? strlen(tuser) : 0) + |
strlen(src) + (tuser ? strlen(tuser) : 0) + |
strlen(thost) + strlen(targ) + CMDNEEDS + 32; |
strlen(thost) + strlen(targ) + CMDNEEDS + 32; |
bp = xmalloc(len); |
bp = xmalloc(len); |
|
|
else if (!okname(suser)) |
else if (!okname(suser)) |
continue; |
continue; |
(void) sprintf(bp, |
(void) sprintf(bp, |
"%s%s -x -o'FallBackToRsh no' -n -l %s %s %s %s '%s%s%s:%s'", |
"%s%s -x -o'FallBackToRsh no' -n -l %s %s %s %s '%s%s%s:%s'", |
SSH_PROGRAM, verbose_mode ? " -v" : "", |
ssh_program, verbose_mode ? " -v" : "", |
suser, host, cmd, src, |
suser, host, cmd, src, |
tuser ? tuser : "", tuser ? "@" : "", |
tuser ? tuser : "", tuser ? "@" : "", |
thost, targ); |
thost, targ); |
} else { |
} else { |
host = cleanhostname(argv[i]); |
host = cleanhostname(argv[i]); |
(void) sprintf(bp, |
(void) sprintf(bp, |
"exec %s%s -x -o'FallBackToRsh no' -n %s %s %s '%s%s%s:%s'", |
"exec %s%s -x -o'FallBackToRsh no' -n %s %s %s '%s%s%s:%s'", |
SSH_PROGRAM, verbose_mode ? " -v" : "", |
ssh_program, verbose_mode ? " -v" : "", |
host, cmd, src, |
host, cmd, src, |
tuser ? tuser : "", tuser ? "@" : "", |
tuser ? tuser : "", tuser ? "@" : "", |
thost, targ); |
thost, targ); |
} |
} |
if (verbose_mode) |
if (verbose_mode) |
fprintf(stderr, "Executing: %s\n", bp); |
fprintf(stderr, "Executing: %s\n", bp); |
|
|
void |
void |
usage() |
usage() |
{ |
{ |
(void) fprintf(stderr, |
(void) fprintf(stderr, "usage: scp " |
"usage: scp [-pqrvC46] [-P port] [-c cipher] [-i identity] f1 f2; or:\n scp [options] f1 ... fn directory\n"); |
"[-pqrvC46] [-S ssh] [-P port] [-c cipher] [-i identity] f1 f2; or:\n" |
|
" scp [options] f1 ... fn directory\n"); |
exit(1); |
exit(1); |
} |
} |
|
|