1.\" $OpenBSD: rcmdsh.3,v 1.6 1999/07/05 04:41:00 aaron Exp $ 2.\" 3.\" Copyright (c) 1983, 1991, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. Neither the name of the University nor the names of its contributors 15.\" may be used to endorse or promote products derived from this software 16.\" without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.\" $FreeBSD: src/lib/libc/net/rcmdsh.3,v 1.7 2007/01/09 00:28:02 imp Exp $ 31.\" $DragonFly: src/lib/libc/net/rcmdsh.3,v 1.4 2007/08/18 20:48:47 swildner Exp $ 32.\" 33.Dd September 1, 1996 34.Dt RCMDSH 3 35.Os 36.Sh NAME 37.Nm rcmdsh 38.Nd return a stream to a remote command without superuser 39.Sh LIBRARY 40.Lb libc 41.Sh SYNOPSIS 42.In unistd.h 43.Ft int 44.Fo rcmdsh 45.Fa "char **ahost" 46.Fa "int inport" 47.Fa "const char *locuser" 48.Fa "const char *remuser" 49.Fa "const char *cmd" 50.Fa "const char *rshprog" 51.Fc 52.Sh DESCRIPTION 53The 54.Fn rcmdsh 55function 56is used by normal users to execute a command on 57a remote machine using an authentication scheme based 58on reserved port numbers using 59.Xr rshd 8 60or the value of 61.Fa rshprog 62(if 63.No non- Ns Dv NULL ) . 64.Pp 65The 66.Fn rcmdsh 67function 68looks up the host 69.Fa *ahost 70using 71.Xr gethostbyname 3 , 72returning \-1 if the host does not exist. 73Otherwise 74.Fa *ahost 75is set to the standard name of the host 76and a connection is established to a server 77residing at the well-known Internet port 78.Dq Li shell/tcp 79(or whatever port is used by 80.Fa rshprog ) . 81The 82.Fa inport 83argument 84is ignored; it is only included to provide an interface similar to 85.Xr rcmd 3 . 86.Pp 87If the connection succeeds, 88a socket in the 89.Ux 90domain of type 91.Dv SOCK_STREAM 92is returned to the caller, and given to the remote 93command as 94.Dv stdin , stdout , 95and 96.Dv stderr . 97.Sh RETURN VALUES 98The 99.Fn rcmdsh 100function 101returns a valid socket descriptor on success. 102Otherwise, \-1 is returned 103and a diagnostic message is printed on the standard error. 104.Sh SEE ALSO 105.Xr rsh 1 , 106.Xr socketpair 2 , 107.Xr rcmd 3 , 108.Xr rshd 8 109.Sh HISTORY 110The 111.Fn rcmdsh 112function first appeared in 113.Ox 2.0 , 114and made its way into 115.Fx 4.6 . 116.Sh BUGS 117If 118.Xr rsh 1 119encounters an error, a file descriptor is still returned instead of \-1. 120