xref: /freebsd/lib/libc/net/rcmdsh.3 (revision 41466b50c1d5bfd1cf6adaae547a579a75d7c04e)
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. All advertising materials mentioning features or use of this software
15.\"    must display the following acknowledgement:
16.\"	This product includes software developed by the University of
17.\"	California, Berkeley and its contributors.
18.\" 4. Neither the name of the University nor the names of its contributors
19.\"    may be used to endorse or promote products derived from this software
20.\"    without specific prior written permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32.\" SUCH DAMAGE.
33.\"
34.\" $FreeBSD$
35.\"
36.Dd September 1, 1996
37.Dt RCMDSH 3
38.Os
39.Sh NAME
40.Nm rcmdsh
41.Nd return a stream to a remote command without superuser
42.Sh SYNOPSIS
43.Fd #include <unistd.h>
44.Ft int
45.Fn rcmdsh "char **ahost" "int inport" "const char *locuser" "const char *remuser" "const char *cmd" "char *rshprog"
46.Sh DESCRIPTION
47The
48.Fn rcmdsh
49function
50is used by normal users to execute a command on
51a remote machine using an authentication scheme based
52on reserved port numbers using
53.Xr rshd 8
54or the value of
55.Fa rshprog
56(if non-null).
57.Pp
58The
59.Fn rcmdsh
60function
61looks up the host
62.Fa *ahost
63using
64.Xr gethostbyname 3 ,
65returning \-1 if the host does not exist.
66Otherwise
67.Fa *ahost
68is set to the standard name of the host
69and a connection is established to a server
70residing at the well-known Internet port
71.Li shell/tcp
72(or whatever port is used by
73.Fa rshprog
74).  The parameter
75.Fa inport
76is ignored; it is only included to provide an interface similar to
77.Xr rcmd 3 .
78.Pp
79If the connection succeeds,
80a socket in the
81.Tn UNIX
82domain of type
83.Dv SOCK_STREAM
84is returned to the caller, and given to the remote
85command as stdin and stdout, and stderr.
86.Sh DIAGNOSTICS
87The
88.Fn rcmdsh
89function
90returns a valid socket descriptor on success.
91It returns \-1 on error and prints a diagnostic message on the standard error.
92.Sh SEE ALSO
93.Xr rsh 1 ,
94.Xr socketpair 2 ,
95.Xr rcmd 3 ,
96.Xr rshd 8
97.Sh BUGS
98If
99.Xr rsh 1
100gets an error a file descriptor is still returned instead of \-1.
101.Sh HISTORY
102The
103.Fn rcmdsh
104function first appeared in
105.Ox 2.0 .
106