summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/scp.c
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2000-01-04 00:08:02 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2000-01-04 00:08:02 +0000
commit573f387ec119d78734faf0f7bcb79a160ba603b7 (patch)
tree4fc970b6fb7642a6058e608f9887735328a35a7c /usr.bin/ssh/scp.c
parentb2e854e4813087bf22e3c8885da9db9fef77ce3b (diff)
ipv6 support: mostly gethostbyname->getaddrinfo/getnameinfo, new features:
sshd allows multiple ListenAddress and Port options. note that libwrap is not IPv6-ready. (based on patches from <kick@kyoto.wide.ad.jp> and fujiwara@rcac.tdi.co.jp)
Diffstat (limited to 'usr.bin/ssh/scp.c')
-rw-r--r--usr.bin/ssh/scp.c54
1 files changed, 47 insertions, 7 deletions
diff --git a/usr.bin/ssh/scp.c b/usr.bin/ssh/scp.c
index 51cb2eb5409..e898f23ff49 100644
--- a/usr.bin/ssh/scp.c
+++ b/usr.bin/ssh/scp.c
@@ -45,7 +45,7 @@
*/
#include "includes.h"
-RCSID("$Id: scp.c,v 1.22 1999/12/06 20:15:28 deraadt Exp $");
+RCSID("$Id: scp.c,v 1.23 2000/01/04 00:07:59 markus Exp $");
#include "ssh.h"
#include "xmalloc.h"
@@ -74,6 +74,12 @@ off_t totalbytes = 0;
/* Name of current file being transferred. */
char *curfile;
+/* This is set to non-zero if IPv4 is desired. */
+int IPv4 = 0;
+
+/* This is set to non-zero if IPv6 is desired. */
+int IPv6 = 0;
+
/* This is set to non-zero to enable verbose mode. */
int verbose_mode = 0;
@@ -145,6 +151,11 @@ do_cmd(char *host, char *remuser, char *cmd, int *fdin, int *fdout)
args[i++] = SSH_PROGRAM;
args[i++] = "-x";
args[i++] = "-oFallBackToRsh no";
+ if (IPv4)
+ args[i++] = "-4";
+ if (IPv6)
+ args[i++] = "-6";
+ args[i++] = "-oFallBackToRsh no";
if (verbose_mode)
args[i++] = "-v";
if (compress)
@@ -242,9 +253,15 @@ main(argc, argv)
extern int optind;
fflag = tflag = 0;
- while ((ch = getopt(argc, argv, "dfprtvBCc:i:P:q")) != EOF)
+ while ((ch = getopt(argc, argv, "dfprtvBCc:i:P:q46")) != EOF)
switch (ch) {
/* User-visible flags. */
+ case '4':
+ IPv4 = 1;
+ break;
+ case '6':
+ IPv6 = 1;
+ break;
case 'p':
pflag = 1;
break;
@@ -334,6 +351,17 @@ main(argc, argv)
exit(errs != 0);
}
+char *
+cleanhostname(host)
+ char *host;
+{
+ if (*host == '[' && host[strlen(host) - 1] == ']') {
+ host[strlen(host) - 1] = '\0';
+ return (host + 1);
+ } else
+ return host;
+}
+
void
toremote(targ, argc, argv)
char *targ, *argv[];
@@ -372,6 +400,7 @@ toremote(targ, argc, argv)
bp = xmalloc(len);
if (host) {
*host++ = 0;
+ host = cleanhostname(host);
suser = argv[i];
if (*suser == '\0')
suser = pwd->pw_name;
@@ -383,13 +412,15 @@ toremote(targ, argc, argv)
suser, host, cmd, src,
tuser ? tuser : "", tuser ? "@" : "",
thost, targ);
- } else
+ } else {
+ host = cleanhostname(argv[i]);
(void) sprintf(bp,
"exec %s%s -x -o'FallBackToRsh no' -n %s %s %s '%s%s%s:%s'",
SSH_PROGRAM, verbose_mode ? " -v" : "",
- argv[i], cmd, src,
+ host, cmd, src,
tuser ? tuser : "", tuser ? "@" : "",
thost, targ);
+ }
if (verbose_mode)
fprintf(stderr, "Executing: %s\n", bp);
(void) system(bp);
@@ -399,7 +430,7 @@ toremote(targ, argc, argv)
len = strlen(targ) + CMDNEEDS + 20;
bp = xmalloc(len);
(void) sprintf(bp, "%s -t %s", cmd, targ);
- host = thost;
+ host = cleanhostname(thost);
if (do_cmd(host, tuser,
bp, &remin, &remout) < 0)
exit(1);
@@ -449,6 +480,7 @@ tolocal(argc, argv)
else if (!okname(suser))
continue;
}
+ host = cleanhostname(host);
len = strlen(src) + CMDNEEDS + 20;
bp = xmalloc(len);
(void) sprintf(bp, "%s -f %s", cmd, src);
@@ -974,18 +1006,26 @@ run_err(const char *fmt,...)
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: scp.c,v 1.22 1999/12/06 20:15:28 deraadt Exp $
+ * $Id: scp.c,v 1.23 2000/01/04 00:07:59 markus Exp $
*/
char *
colon(cp)
char *cp;
{
+ int flag = 0;
+
if (*cp == ':') /* Leading colon is part of file name. */
return (0);
+ if (*cp == '[')
+ flag = 1;
for (; *cp; ++cp) {
- if (*cp == ':')
+ if (*cp == '@' && *(cp+1) == '[')
+ flag = 1;
+ if (*cp == ']' && *(cp+1) == ':' && flag)
+ return (cp+1);
+ if (*cp == ':' && !flag)
return (cp);
if (*cp == '/')
return (0);