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