Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src ftpd(8): Copy sin6_scope_id from control connection to activ...



details:   https://anonhg.NetBSD.org/src/rev/e7bf1c12e937
branches:  trunk
changeset: 475970:e7bf1c12e937
user:      itojun <itojun%NetBSD.org@localhost>
date:      Wed Sep 01 05:03:41 1999 +0000

description:
ftpd(8): Copy sin6_scope_id from control connection to active data
connection destination, hoping this to help ftpd's behavior with
scoped IPv6 addresses.
I'm not sure if it is the right way, but it is the best way available to us.
LPRT or EPRT command gives no information about which interface (or scope)
to be used for new data connection.

ftp(1): On data connection establishment, warn if scoped address is used.
If peer (ftp daemon) does not handle scoped address, data connection
may not work right.

This seems to be sort of protocol spec hole, not implementation issue.

diffstat:

 libexec/ftpd/ftpcmd.y |  15 +++++++++++++--
 usr.bin/ftp/ftp.c     |   9 +++++++--
 2 files changed, 20 insertions(+), 4 deletions(-)

diffs (73 lines):

diff -r d7ac0bb88134 -r e7bf1c12e937 libexec/ftpd/ftpcmd.y
--- a/libexec/ftpd/ftpcmd.y     Wed Sep 01 03:10:04 1999 +0000
+++ b/libexec/ftpd/ftpcmd.y     Wed Sep 01 05:03:41 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ftpcmd.y,v 1.36 1999/08/25 16:23:52 christos Exp $     */
+/*     $NetBSD: ftpcmd.y,v 1.37 1999/09/01 05:03:41 itojun Exp $       */
 
 /*
  * Copyright (c) 1985, 1988, 1993, 1994
@@ -47,7 +47,7 @@
 #if 0
 static char sccsid[] = "@(#)ftpcmd.y   8.3 (Berkeley) 4/6/94";
 #else
-__RCSID("$NetBSD: ftpcmd.y,v 1.36 1999/08/25 16:23:52 christos Exp $");
+__RCSID("$NetBSD: ftpcmd.y,v 1.37 1999/09/01 05:03:41 itojun Exp $");
 #endif
 #endif /* not lint */
 
@@ -370,6 +370,12 @@
                        if (getaddrinfo(result[1], result[2], &hints, &res))
                                goto parsefail;
                        memcpy(&data_dest, res->ai_addr, res->ai_addrlen);
+                       if (his_addr.su_family == AF_INET6
+                        && data_dest.su_family == AF_INET6) {
+                               /* XXX more sanity checks! */
+                               data_dest.su_sin6.sin6_scope_id =
+                                       his_addr.su_sin6.sin6_scope_id;
+                       }
                        /* be paranoid, if told so */
                        if (curclass.checkportcmd) {
                                int fail;
@@ -966,6 +972,11 @@
                         a[4] = $13;  a[5] = $15;  a[6] = $17;  a[7] = $19;
                         a[8] = $21;  a[9] = $23; a[10] = $25; a[11] = $27;
                        a[12] = $29; a[13] = $31; a[14] = $33; a[15] = $35;
+                       if (his_addr.su_family == AF_INET6) {
+                               /* XXX more sanity checks! */
+                               data_dest.su_sin6.sin6_scope_id =
+                                       his_addr.su_sin6.sin6_scope_id;
+                       }
 
                        /* reject invalid LPRT command */
                        if ($1 != 6 || $3 != 16 || $37 != 2)
diff -r d7ac0bb88134 -r e7bf1c12e937 usr.bin/ftp/ftp.c
--- a/usr.bin/ftp/ftp.c Wed Sep 01 03:10:04 1999 +0000
+++ b/usr.bin/ftp/ftp.c Wed Sep 01 05:03:41 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ftp.c,v 1.58 1999/08/29 22:21:57 christos Exp $        */
+/*     $NetBSD: ftp.c,v 1.59 1999/09/01 05:03:42 itojun Exp $  */
 
 /*
  * Copyright (C) 1997 and 1998 WIDE Project.
@@ -67,7 +67,7 @@
 #if 0
 static char sccsid[] = "@(#)ftp.c      8.6 (Berkeley) 10/27/94";
 #else
-__RCSID("$NetBSD: ftp.c,v 1.58 1999/08/29 22:21:57 christos Exp $");
+__RCSID("$NetBSD: ftp.c,v 1.59 1999/09/01 05:03:42 itojun Exp $");
 #endif
 #endif /* not lint */
 
@@ -1347,6 +1347,11 @@
        u_int af, hal, pal;
        char *pasvcmd = NULL;
 
+       if (myctladdr.su_family == AF_INET6
+        && (IN6_IS_ADDR_LINKLOCAL(&myctladdr.su_sin6.sin6_addr)
+         || IN6_IS_ADDR_SITELOCAL(&myctladdr.su_sin6.sin6_addr))) {
+               warnx("use of scoped address can be troublesome");
+       }
 reinit:
        if (passivemode) {
                data_addr = myctladdr;



Home | Main Index | Thread Index | Old Index