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