xref: /freebsd/lib/libc/net/rcmdsh.3 (revision 8aac90f18aef7c9eea906c3ff9a001ca7b94f375)
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.Dd September 1, 1996
31.Dt RCMDSH 3
32.Os
33.Sh NAME
34.Nm rcmdsh
35.Nd return a stream to a remote command without superuser
36.Sh SYNOPSIS
37.In unistd.h
38.Ft int
39.Fo rcmdsh
40.Fa "char **ahost"
41.Fa "int inport"
42.Fa "const char *locuser"
43.Fa "const char *remuser"
44.Fa "const char *cmd"
45.Fa "const char *rshprog"
46.Fc
47.Sh DESCRIPTION
48The
49.Fn rcmdsh
50function
51is used by normal users to execute a command on
52a remote machine using an authentication scheme based
53on reserved port numbers using
54.Xr rshd 8
55or the value of
56.Fa rshprog
57(if
58.No non- Ns Dv NULL ) .
59.Pp
60The
61.Fn rcmdsh
62function
63looks up the host
64.Fa *ahost
65using
66.Xr gethostbyname 3 ,
67returning \-1 if the host does not exist.
68Otherwise
69.Fa *ahost
70is set to the standard name of the host
71and a connection is established to a server
72residing at the well-known Internet port
73.Dq Li shell/tcp
74(or whatever port is used by
75.Fa rshprog ) .
76The
77.Fa inport
78argument
79is ignored; it is only included to provide an interface similar to
80.Xr rcmd 3 .
81.Pp
82If the connection succeeds,
83a socket in the
84.Ux
85domain of type
86.Dv SOCK_STREAM
87is returned to the caller, and given to the remote
88command as
89.Dv stdin , stdout ,
90and
91.Dv stderr .
92.Sh RETURN VALUES
93The
94.Fn rcmdsh
95function
96returns a valid socket descriptor on success.
97Otherwise, \-1 is returned
98and a diagnostic message is printed on the standard error.
99.Sh SEE ALSO
100.Xr rsh 1 ,
101.Xr socketpair 2 ,
102.Xr rcmd 3 ,
103.Xr rshd 8
104.Sh HISTORY
105The
106.Fn rcmdsh
107function first appeared in
108.Ox 2.0 ,
109and made its way into
110.Fx 4.6 .
111.Sh BUGS
112If
113.Xr rsh 1
114encounters an error, a file descriptor is still returned instead of \-1.
115