From 67fc215badd8535cee970d83424b03baed1c57f9 Mon Sep 17 00:00:00 2001 From: halex <> Date: Mon, 23 Mar 2015 22:29:32 +0000 Subject: Make rcmdsh(3) not fail if it is passed a non resolvable hostname. Instead, silently ignore the fact and instead let the underlying ssh (or $RSH) command handle it. ok millert@ --- src/lib/libc/net/rcmd.3 | 13 ++++++------- src/lib/libc/net/rcmdsh.3 | 12 ++++++------ src/lib/libc/net/rcmdsh.c | 11 ++++------- 3 files changed, 16 insertions(+), 20 deletions(-) (limited to 'src/lib') diff --git a/src/lib/libc/net/rcmd.3 b/src/lib/libc/net/rcmd.3 index b77e417b87..5fe1ee58eb 100644 --- a/src/lib/libc/net/rcmd.3 +++ b/src/lib/libc/net/rcmd.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: rcmd.3,v 1.31 2014/04/19 18:11:19 tedu Exp $ +.\" $OpenBSD: rcmd.3,v 1.32 2015/03/23 22:29:32 halex Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd $Mdocdate: April 19 2014 $ +.Dd $Mdocdate: March 23 2015 $ .Dt RCMD 3 .Os .Sh NAME @@ -105,12 +105,11 @@ The function looks up the host .Fa *ahost using -.Xr gethostbyname 3 , -returning \-1 if the host does not exist. -Otherwise +.Xr gethostbyname 3 +and, if the host exists, .Fa *ahost -is set to the standard name of the host -and a connection is established to a server +is set to the standard name of the host. +A connection is then established to a server residing at the well-known Internet port .Fa inport . If the user is not the superuser, the only valid port is diff --git a/src/lib/libc/net/rcmdsh.3 b/src/lib/libc/net/rcmdsh.3 index 702fb1d163..daf23bc3c0 100644 --- a/src/lib/libc/net/rcmdsh.3 +++ b/src/lib/libc/net/rcmdsh.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: rcmdsh.3,v 1.16 2014/04/19 18:11:19 tedu Exp $ +.\" $OpenBSD: rcmdsh.3,v 1.17 2015/03/23 22:29:32 halex Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd $Mdocdate: April 19 2014 $ +.Dd $Mdocdate: March 23 2015 $ .Dt RCMDSH 3 .Os .Sh NAME @@ -55,11 +55,11 @@ The function looks up the host .Fa *ahost using -.Xr gethostbyname 3 , -returning \-1 if the host does not exist. -Otherwise +.Xr gethostbyname 3 +and, if the host exists, .Fa *ahost -is set to the standard name of the host and a connection is established to +is set to the standard name of the host. +A connection is then established to a server residing at the well-known Internet port .Li shell/tcp (or whatever port is used by diff --git a/src/lib/libc/net/rcmdsh.c b/src/lib/libc/net/rcmdsh.c index 7404a6d597..ab86475c84 100644 --- a/src/lib/libc/net/rcmdsh.c +++ b/src/lib/libc/net/rcmdsh.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcmdsh.c,v 1.13 2014/04/24 18:56:24 jmc Exp $ */ +/* $OpenBSD: rcmdsh.c,v 1.14 2015/03/23 22:29:32 halex Exp $ */ /* * Copyright (c) 2001, MagniComp @@ -74,12 +74,9 @@ rcmdsh(char **ahost, int rport, const char *locuser, const char *remuser, /* Validate remote hostname. */ if (strcmp(*ahost, "localhost") != 0) { - if (((hp = gethostbyname2(*ahost, AF_INET)) == NULL) && - ((hp = gethostbyname2(*ahost, AF_INET6)) == NULL)) { - herror(*ahost); - return(-1); - } - *ahost = hp->h_name; + if ((hp = gethostbyname2(*ahost, AF_INET)) || + (hp = gethostbyname2(*ahost, AF_INET6))) + *ahost = hp->h_name; } /* Get a socketpair we'll use for stdin and stdout. */ -- cgit v1.2.3-55-g6feb