Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/rcp Add mechanism for escaping IPv6 address strings, sin...
details: https://anonhg.NetBSD.org/src/rev/445110562665
branches: trunk
changeset: 574736:445110562665
user: ginsbach <ginsbach%NetBSD.org@localhost>
date: Fri Mar 11 02:55:23 2005 +0000
description:
Add mechanism for escaping IPv6 address strings, since they already
contain colons. Idea from Solaris rcp(1).
diffstat:
bin/rcp/extern.h | 3 ++-
bin/rcp/rcp.1 | 23 ++++++++++++++++++++---
bin/rcp/rcp.c | 11 ++++++++---
bin/rcp/util.c | 19 +++++++++++++++++--
4 files changed, 47 insertions(+), 9 deletions(-)
diffs (151 lines):
diff -r 74208c3cf41f -r 445110562665 bin/rcp/extern.h
--- a/bin/rcp/extern.h Fri Mar 11 02:45:24 2005 +0000
+++ b/bin/rcp/extern.h Fri Mar 11 02:55:23 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.h,v 1.5 2005/02/17 15:25:02 xtraeme Exp $ */
+/* $NetBSD: extern.h,v 1.6 2005/03/11 02:55:23 ginsbach Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -45,4 +45,5 @@
int okname(char *);
void run_err(const char *, ...);
int susystem(char *);
+char *unbracket(char *);
void verifydir(char *);
diff -r 74208c3cf41f -r 445110562665 bin/rcp/rcp.1
--- a/bin/rcp/rcp.1 Fri Mar 11 02:45:24 2005 +0000
+++ b/bin/rcp/rcp.1 Fri Mar 11 02:55:23 2005 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: rcp.1,v 1.19 2005/03/09 03:11:22 ginsbach Exp $
+.\" $NetBSD: rcp.1,v 1.20 2005/03/11 02:55:23 ginsbach Exp $
.\"
.\" Copyright (c) 1983, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -51,9 +51,26 @@
or
.Ar directory
argument is either a remote file name of the
-form ``rname@rhost:path'', or a local file name (containing no `:' characters,
-or a `/' before any `:'s).
+form ``rname@rhost:path'', or a local file name (containing no `:'
+(colon) characters,
+or a `/' (slash) before any `:' (colon) characters).
.Pp
+The
+.Ar rhost
+can be an IPv4 or an IPv6 address string.
+Since IPv6 addresses already contain `:' (colon) characters,
+an IPv6 address string must be enclosed between `[' (left square bracket)
+and `]' (right square bracket) characters.
+Otherwise, the first occurrence of a `:' (colon) character would be
+interpreted as the separator between the
+.Ar rhost
+and the
+.Ar path.
+For example,
+.Pp
+.Dl [2001:DB8::800:200C:417A]:tmp/file
+.Pp
+Options:
.Bl -tag -width flag
.It Fl 4
Use IPv4 addresses only.
diff -r 74208c3cf41f -r 445110562665 bin/rcp/rcp.c
--- a/bin/rcp/rcp.c Fri Mar 11 02:45:24 2005 +0000
+++ b/bin/rcp/rcp.c Fri Mar 11 02:55:23 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rcp.c,v 1.38 2005/03/09 17:09:39 wiz Exp $ */
+/* $NetBSD: rcp.c,v 1.39 2005/03/11 02:55:23 ginsbach Exp $ */
/*
* Copyright (c) 1983, 1990, 1992, 1993
@@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)rcp.c 8.2 (Berkeley) 4/2/94";
#else
-__RCSID("$NetBSD: rcp.c,v 1.38 2005/03/09 17:09:39 wiz Exp $");
+__RCSID("$NetBSD: rcp.c,v 1.39 2005/03/11 02:55:23 ginsbach Exp $");
#endif
#endif /* not lint */
@@ -267,6 +267,7 @@
thost = argv[argc - 1];
tuser = NULL;
}
+ thost = unbracket(thost);
for (i = 0; i < argc - 1; i++) {
src = colon(argv[i]);
@@ -282,6 +283,7 @@
err(1, NULL);
if (host) {
*host++ = 0;
+ host = unbracket(host);
suser = argv[i];
if (*suser == '\0')
suser = pwname;
@@ -292,12 +294,14 @@
_PATH_RSH, host, suser, cmd, src,
tuser ? tuser : "", tuser ? "@" : "",
thost, targ);
- } else
+ } else {
+ host = unbracket(argv[i]);
(void)snprintf(bp, len,
"exec %s %s -n %s %s '%s%s%s:%s'",
_PATH_RSH, argv[i], cmd, src,
tuser ? tuser : "", tuser ? "@" : "",
thost, targ);
+ }
(void)susystem(bp);
(void)free(bp);
} else { /* local to remote */
@@ -361,6 +365,7 @@
else if (!okname(suser))
continue;
}
+ host = unbracket(host);
len = strlen(src) + CMDNEEDS + 20;
if ((bp = malloc(len)) == NULL)
err(1, NULL);
diff -r 74208c3cf41f -r 445110562665 bin/rcp/util.c
--- a/bin/rcp/util.c Fri Mar 11 02:45:24 2005 +0000
+++ b/bin/rcp/util.c Fri Mar 11 02:55:23 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: util.c,v 1.8 2005/02/17 15:25:02 xtraeme Exp $ */
+/* $NetBSD: util.c,v 1.9 2005/03/11 02:55:23 ginsbach Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)util.c 8.2 (Berkeley) 4/2/94";
#else
-__RCSID("$NetBSD: util.c,v 1.8 2005/02/17 15:25:02 xtraeme Exp $");
+__RCSID("$NetBSD: util.c,v 1.9 2005/03/11 02:55:23 ginsbach Exp $");
#endif
#endif /* not lint */
@@ -69,6 +69,21 @@
return (0);
}
+char *
+unbracket(char *cp)
+{
+ char *ep;
+
+ if (*cp == '[') {
+ ep = cp + (strlen(cp) - 1);
+ if (*ep == ']') {
+ *ep = '\0';
+ ++cp;
+ }
+ }
+ return (cp);
+}
+
void
verifydir(char *cp)
{
Home |
Main Index |
Thread Index |
Old Index