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