NetBSD Problem Report #24940

Received: (qmail 10012 invoked by uid 605); 27 Mar 2004 20:14:39 -0000
Message-Id: <200403272013.i2RKD8cU000828@baladeur.antioche.eu.org>
Date: Sat, 27 Mar 2004 21:13:08 +0100 (CET)
From: bouyer@antioche.eu.org (Manuel Bouyer)
Sender: gnats-bugs-owner@NetBSD.org
Reply-To: bouyer@antioche.eu.org (Manuel Bouyer)
To: gnats-bugs@gnats.NetBSD.org
Subject: rcp doesn't like ipv6-only hosts
X-Send-Pr-Version: 3.95

>Number:         24940
>Category:       bin
>Synopsis:       rcp doesn't like ipv6-only hosts
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Mar 27 20:15:00 +0000 2004
>Closed-Date:    
>Last-Modified:  Thu Sep 28 16:35:00 +0000 2006
>Originator:     Manuel Bouyer
>Release:        NetBSD 1.6ZL, binaries from the 200403200000 releng build
>Organization:
>Environment:

System: NetBSD baladeur 1.6ZL NetBSD 1.6ZL (IBM600E) #1: Sat Mar 27 19:04:17 CET 2004 bouyer@pop:/local/pop1/bouyer/tmp/i386/obj/local/pop1/bouyer/current/src/sys/arch/i386/compile/IBM600E i386
Architecture: i386
Machine: i386
>Description:
	rcp(1) can't make use of a IPv6-only DNS record, while rsh(1) has
	no problems with it:
baladeur:/home/bouyer>rsh rochebonne ls /tmp
diff
baladeur:/home/bouyer>rcp rochebonne:/tmp/diff /tmp
rcp: rochebonne: No address associated with hostname
baladeur:/home/bouyer>nslookup -type=any rochebonne
Server:  chassiron-dhcp
Address:  10.0.2.254

rochebonne.antioche.eu.org      IPv6 address = 2001:7a8:242c:0:240:95ff:fe45:4702
rochebonne.antioche.eu.org      CPU = i386      OS = NetBSD
rochebonne.antioche.eu.org      preference = 5, mail exchanger = chassiron.antioche.eu.org
antioche.eu.org nameserver = ns.antioche.eu.org
antioche.eu.org nameserver = ns2.antioche.eu.org
chassiron.antioche.eu.org       internet address = 62.212.96.44
chassiron.antioche.eu.org       IPv6 address = 2001:7a8:242c:0:a00:20ff:fe1c:276e
chassiron.antioche.eu.org       IPv6 address = 2001:7a8:242c:1::1
ns.antioche.eu.org      internet address = 132.227.74.11
ns2.antioche.eu.org     internet address = 62.212.96.44
baladeur:/home/bouyer>

	With a name wich has both A and AAAA records (e.g.
	chassiron.antioche.eu.org) rcp(1) is happy and will try IPv6 first.
>How-To-Repeat:
	Try rcp using a DNS name with only AAAA records.
>Fix:
	unknown
>Release-Note:
>Audit-Trail:

From: Julian Coleman <jdc@coris.org.uk>
To: Manuel Bouyer <bouyer@antioche.eu.org>
Cc: gnats-bugs@gnats.NetBSD.org
Subject: Re: bin/24940: rcp doesn't like ipv6-only hosts
Date: Sat, 27 Mar 2004 23:06:02 +0000

 > >Synopsis:       rcp doesn't like ipv6-only hosts

 > >How-To-Repeat:
 > 	Try rcp using a DNS name with only AAAA records.

 Same with a /etc/hosts entry with just an IPv6 address.  I see that rcp.c
 uses rcmd() and its manual page states:

   "While rcmd() and orcmd() can only handle IPv4 address in the first
    argument, rcmd_af() and orcmd_af() can handle other cases as well."

 With the appended patch, rcp does the right thing for a v6 only host for me.

 J

  ---8<---------------------------- Cut here ---------------------------->8---
 --- /usr/src/bin/rcp/rcp.c	2003-08-08 04:04:49.000000000 +0100
 +++ rcp.c	2004-03-27 23:03:39.000000000 +0000
 @@ -312,9 +312,9 @@
  					    tuser ? tuser : pwname);
  				else
  #endif
 -					rem = rcmd(&host, port, pwname,
 +					rem = rcmd_af(&host, port, pwname,
  					    tuser ? tuser : pwname,
 -					    bp, 0);
 +					    bp, 0 ,PF_UNSPEC);
  				if (rem < 0)
  					exit(1);
  				if (response() < 0)
 @@ -371,7 +371,7 @@
  		    use_kerberos ? 
  			kerberos(&host, bp, pwname, suser) : 
  #endif
 -			rcmd(&host, port, pwname, suser, bp, 0);
 +			rcmd_af(&host, port, pwname, suser, bp, 0 ,PF_UNSPEC);
  		(void)free(bp);
  		if (rem < 0) {
  			++errs;
 @@ -831,7 +831,7 @@
  			errx(1,
  			   "the -x option requires Kerberos authentication");
  #endif
 -		rem = rcmd(host, port, locuser, user, bp, 0);
 +		rem = rcmd_af(host, port, locuser, user, bp, 0 ,PF_UNSPEC));
  	}
  	return (rem);
  }
  ---8<---------------------------- Cut here ---------------------------->8---
 -- 
   My other computer also runs NetBSD    /        Sailing at Newbiggin
         http://www.netbsd.org/        /   http://www.newbigginsailingclub.org/

From: Manuel Bouyer <bouyer@antioche.eu.org>
To: Julian Coleman <jdc@coris.org.uk>
Cc: gnats-bugs@gnats.NetBSD.org
Subject: Re: bin/24940: rcp doesn't like ipv6-only hosts
Date: Sun, 28 Mar 2004 01:00:44 +0100

 On Sat, Mar 27, 2004 at 11:06:02PM +0000, Julian Coleman wrote:
 > > >Synopsis:       rcp doesn't like ipv6-only hosts
 > 
 > > >How-To-Repeat:
 > > 	Try rcp using a DNS name with only AAAA records.
 > 
 > Same with a /etc/hosts entry with just an IPv6 address.  I see that rcp.c
 > uses rcmd() and its manual page states:
 > 
 >   "While rcmd() and orcmd() can only handle IPv4 address in the first
 >    argument, rcmd_af() and orcmd_af() can handle other cases as well."
 > 
 > With the appended patch, rcp does the right thing for a v6 only host for me.

 Yes, for me too. But now there's an issue for dual-protocol hosts,
 when rshd isn't listening on ipv6:
 rochebonne:/usr/src/current/src/bin/rcp>rsh chassiron ls /tmp
 rcmd: rcmd: connect to address 2001:7a8:242c:0:a00:20ff:fe1c:276e
 Connection refused
 Trying 10.0.0.254...
 sa.out
 spam
 rochebonne:/usr/src/current/src/bin/rcp>rcp chassiron:/tmp/spam /tmp
 rcp: rcmd: rcmd: connect to address 2001:7a8:242c:0:a00:20ff:fe1c:276e

 Any idea ?

 -- 
 Manuel Bouyer <bouyer@antioche.eu.org>
      NetBSD: 26 ans d'experience feront toujours la difference
 --

From: jdolecek@NetBSD.org (Jaromir Dolecek)
To: Manuel Bouyer <bouyer@antioche.eu.org>
Cc: gnats-bugs@gnats.NetBSD.org
Subject: Re: bin/24940: rcp doesn't like ipv6-only hosts
Date: Sun, 28 Mar 2004 10:10:23 +0200 (CEST)

 Manuel Bouyer wrote:
 > 	rcp(1) can't make use of a IPv6-only DNS record, while rsh(1) has
 > 	no problems with it:

 This is because rcp(1) hasn't been converted to use rcmd_af(3)
 yet.

 Jaromir
 -- 
 Jaromir Dolecek <jdolecek@NetBSD.org>            http://www.NetBSD.cz/
 -=- We should be mindful of the potential goal, but as the Buddhist -=-
 -=- masters say, ``You may notice during meditation that you        -=-
 -=- sometimes levitate or glow.   Do not let this distract you.''   -=-
State-Changed-From-To: open->feedback 
State-Changed-By: jdolecek 
State-Changed-When: Sun Mar 28 08:18:54 UTC 2004 
State-Changed-Why:  
rcp(1) compiled with rcp.c rev. 1.34 should work with IPv6. 
Can you confirm it works? I don't have IPv6 connectivity, so I only 
confirmed rcp(1) not returns 'No route to host' rather than 
'No address associated with hostname'. 


Responsible-Changed-From-To: bin-bug-people->jdolecek 
Responsible-Changed-By: jdolecek 
Responsible-Changed-When: Sun Mar 28 08:18:54 UTC 2004 
Responsible-Changed-Why:  
I made the fix to rcp(1). 

From: Jaromir Dolecek <jdolecek@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:  
Subject: pr/24940 CVS commit: src/bin/rcp
Date: Sun, 28 Mar 2004 08:18:25 +0000 (UTC)

 Module Name:	src
 Committed By:	jdolecek
 Date:		Sun Mar 28 08:18:25 UTC 2004

 Modified Files:
 	src/bin/rcp: rcp.c

 Log Message:
 IPv6 support, based on src/usr.bin/rsh/rsh.c rev. 1.13
 fixes PR bin/24940 by Manuel Bouyer


 To generate a diff of this commit:
 cvs rdiff -r1.33 -r1.34 src/bin/rcp/rcp.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.


From: Manuel Bouyer <bouyer@antioche.eu.org>
To: gnats-bugs@gnats.netbsd.org
Cc: jdolecek@netbsd.org, gnats-admin@netbsd.org,
  Julian Coleman <jdc@coris.org.uk>
Subject: Re: bin/24940
Date: Sun, 28 Mar 2004 13:08:45 +0200

 On Sun, Mar 28, 2004 at 08:21:48AM -0000, jdolecek@netbsd.org wrote:
 > Synopsis: rcp doesn't like ipv6-only hosts
 > 
 > State-Changed-From-To: open->feedback
 > State-Changed-By: jdolecek
 > State-Changed-When: Sun Mar 28 08:18:54 UTC 2004
 > State-Changed-Why: 
 > rcp(1) compiled with rcp.c rev. 1.34 should work with IPv6.
 > Can you confirm it works? I don't have IPv6 connectivity, so I only
 > confirmed rcp(1) not returns 'No route to host' rather than
 > 'No address associated with hostname'.

 Hi, 
 It works with ipv6 now, but has a problem for dual-stack systems, where
 rshd is only listening on v4:
 rochebonne:~> rsh chassiron ls /tmp
 rcmd: rcmd: connect to address 2001:7a8:242c:0:a00:20ff:fe1c:276e
 Connection refused
 Trying 10.0.0.254...
 sa.out
 spam
 rochebonne:~> rcp chassiron:/tmp/spam /tmp
 rcp: rcmd: rcmd: connect to address 2001:7a8:242c:0:a00:20ff:fe1c:276e
 rochebonne:~> 
 and the file has not been copied.

 -- 
 Manuel Bouyer <bouyer@antioche.eu.org>
      NetBSD: 26 ans d'experience feront toujours la difference
 --
State-Changed-From-To: feedback->open 
State-Changed-By: fair 
State-Changed-When: Sun Jun 6 04:12:34 UTC 2004 
State-Changed-Why:  

Feedback provided, but there's still a problem to be resolved. 

Responsible-Changed-From-To: jdolecek->bin-bug-people
Responsible-Changed-By: jdolecek@netbsd.org
Responsible-Changed-When: Sat, 27 Nov 2004 22:12:43 +0000
Responsible-Changed-Why:
Too busy to complete the fix, someone else please step in.


From: Dave Tyson <Dave.Tyson@liverpool.ac.uk>
To: Manuel Bouyer <bouyer@antioche.eu.org>
Cc: gnats-bugs@NetBSD.org
Subject: Re: bin/24940: rcp doesn't like ipv6-only hosts
Date: Thu, 28 Sep 2006 16:24:31 +0100

 We have the same problems as you and it has bugged me sufficiently to 
 have a stab at fixing it.

 The following patch to /usr/src/lib/libc/net/rcmd.c will help in that rcp will
 now correctly obey the -4 and -6 options documented in the man page. This 
 means at least you can force a transfer with IPV4 if the IPV6 address is 
 unresponsive on a dual stack host. I think a fix to automatically make rcp 
 use IPV4 if the IPV6 connection fails is going to be very messy because of 
 the way a sub-process is spawned to do the copying. Arguably the fix should 
 be in rcmd.c as this is where the problem is solved for rsh, however, because 
 of the sub-process the only thing which knows if the connection has failed is 
 the rcp command itself. Changing this to check the available address families 
 and invoking the connection with IPV6 and falling back to IPV4 is an option, 
 but I view it as a kludge as the real problem is the sub-process. Other 
 *BSD's seem to have done away with this to avoid this issue. Maybe an import 
 of the OpenBSD/FreeBSD code is the most satisfactory solution. In the 
 meantime the fix below should apply cleanly to 3, 4 and current - If people 
 think its OK could it be pulled up into the 3 & 4 branches?

 --- rcmd.c.orig 2005-07-09 23:51:22.000000000 +0100
 +++ rcmd.c      2006-09-27 22:27:41.000000000 +0100
 @@ -78,7 +78,7 @@
  int    __ivaliduser_sa __P((FILE *, struct sockaddr *, socklen_t, const char 
 *,
             const char *));
  static int rshrcmd __P((char **, u_int32_t, const char *, const char *,
 -           const char *, int *, const char *));
 +           const char *, int *, const char *, const int));
  static int resrcmd __P((struct addrinfo *, char **, u_int32_t, const char *,
             const char *, const char *, int *));
  static int __icheckhost __P((struct sockaddr *, socklen_t, const char *));
 @@ -142,7 +142,7 @@
         sp = getservbyname("shell", "tcp");
         if (sp != NULL && sp->s_port == rport)
                 error = rshrcmd(ahost, (u_int32_t)rport,
 -                   locuser, remuser, cmd, fd2p, getenv("RCMD_CMD"));
 +                   locuser, remuser, cmd, fd2p, getenv("RCMD_CMD"), af);
         else
                 error = resrcmd(res, ahost, (u_int32_t)rport,
                     locuser, remuser, cmd, fd2p);
 @@ -379,12 +379,13 @@
   */
  /* ARGSUSED */
  static int
 -rshrcmd(ahost, rport, locuser, remuser, cmd, fd2p, rshcmd)
 +rshrcmd(ahost, rport, locuser, remuser, cmd, fd2p, rshcmd, af)
         char    **ahost;
         u_int32_t       rport;
         const   char *locuser, *remuser, *cmd;
         int     *fd2p;
         const   char *rshcmd;
 +       const   int af;
  {
         pid_t pid;
         int sp[2], ep[2];
 @@ -476,11 +477,18 @@
                         else
                                 rshcmd = pw->pw_shell;
                         p = strrchr(rshcmd, '/');
 -                       execlp(rshcmd, p ? p + 1 : rshcmd, "-c", cmd, NULL);
 +                       if (af == AF_UNSPEC)
 +                               execlp(rshcmd, p ? p + 1 : rshcmd, "-c", cmd, 
 NULL);
 +                       else
 +                               execlp(rshcmd, p ? p + 1 : rshcmd, af == 
 AF_INET ? "-4" : "-6", "-c",
 +                                       cmd, NULL);
                 } else {
                         p = strrchr(rshcmd, '/');
 -                       execlp(rshcmd, p ? p + 1 : rshcmd, *ahost, "-l",
 -                           remuser, cmd, NULL);
 +                       if (af == AF_UNSPEC)
 +                               execlp(rshcmd, p ? p + 1 : rshcmd, *ahost, 
 "-l", remuser, cmd, NULL);
 +                       else
 +                               execlp(rshcmd, p ? p + 1 : rshcmd, *ahost, af 
 == AF_INET ? "-4" : "-6",
 +                                       "-l", remuser, cmd, NULL);
                 }
                 warn("rshrcmd: exec %s", rshcmd);
                 _exit(1);


 -- 
 =====================================================================
 Computing Services Dept         Phone/Fax: 0151-794-3731/3759
 The University of Liverpool     Email: dtyson@liv.ac.uk
 Chadwick Tower, Peach Street    WWW:   http://www.liv.ac.uk/~dtyson
 Liverpool L69 7ZF               Open Source O/S: www.netbsd.org
 =====================================================================

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.