xref: /freebsd/lib/libc/net/rcmdsh.3 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
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.
14*fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors
15d4567212SWarner Losh.\"    may be used to endorse or promote products derived from this software
16d4567212SWarner Losh.\"    without specific prior written permission.
17d4567212SWarner Losh.\"
18d4567212SWarner Losh.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19d4567212SWarner Losh.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20d4567212SWarner Losh.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21d4567212SWarner Losh.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22d4567212SWarner Losh.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23d4567212SWarner Losh.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24d4567212SWarner Losh.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25d4567212SWarner Losh.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26d4567212SWarner Losh.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27d4567212SWarner Losh.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28d4567212SWarner Losh.\" SUCH DAMAGE.
29d4567212SWarner Losh.\"
30d4567212SWarner Losh.Dd September 1, 1996
31d4567212SWarner Losh.Dt RCMDSH 3
32d4567212SWarner Losh.Os
33d4567212SWarner Losh.Sh NAME
34d4567212SWarner Losh.Nm rcmdsh
35d4567212SWarner Losh.Nd return a stream to a remote command without superuser
36d4567212SWarner Losh.Sh SYNOPSIS
37e117e7a5SRuslan Ermilov.In unistd.h
38d4567212SWarner Losh.Ft int
39e117e7a5SRuslan Ermilov.Fo rcmdsh
40e117e7a5SRuslan Ermilov.Fa "char **ahost"
41e117e7a5SRuslan Ermilov.Fa "int inport"
42e117e7a5SRuslan Ermilov.Fa "const char *locuser"
43e117e7a5SRuslan Ermilov.Fa "const char *remuser"
44e117e7a5SRuslan Ermilov.Fa "const char *cmd"
45e117e7a5SRuslan Ermilov.Fa "const char *rshprog"
46e117e7a5SRuslan Ermilov.Fc
47d4567212SWarner Losh.Sh DESCRIPTION
48d4567212SWarner LoshThe
49d4567212SWarner Losh.Fn rcmdsh
50d4567212SWarner Loshfunction
51d4567212SWarner Loshis used by normal users to execute a command on
52d4567212SWarner Losha remote machine using an authentication scheme based
53d4567212SWarner Loshon reserved port numbers using
54d4567212SWarner Losh.Xr rshd 8
55d4567212SWarner Loshor the value of
56d4567212SWarner Losh.Fa rshprog
57e117e7a5SRuslan Ermilov(if
58e117e7a5SRuslan Ermilov.No non- Ns Dv NULL ) .
59d4567212SWarner Losh.Pp
60d4567212SWarner LoshThe
61d4567212SWarner Losh.Fn rcmdsh
62d4567212SWarner Loshfunction
63d4567212SWarner Loshlooks up the host
64d4567212SWarner Losh.Fa *ahost
65d4567212SWarner Loshusing
66d4567212SWarner Losh.Xr gethostbyname 3 ,
67d4567212SWarner Loshreturning \-1 if the host does not exist.
68d4567212SWarner LoshOtherwise
69d4567212SWarner Losh.Fa *ahost
70d4567212SWarner Loshis set to the standard name of the host
71d4567212SWarner Loshand a connection is established to a server
72d4567212SWarner Loshresiding at the well-known Internet port
73e117e7a5SRuslan Ermilov.Dq Li shell/tcp
74d4567212SWarner Losh(or whatever port is used by
75e117e7a5SRuslan Ermilov.Fa rshprog ) .
762efeeba5SRuslan ErmilovThe
77d4567212SWarner Losh.Fa inport
782efeeba5SRuslan Ermilovargument
79d4567212SWarner Loshis ignored; it is only included to provide an interface similar to
80d4567212SWarner Losh.Xr rcmd 3 .
81d4567212SWarner Losh.Pp
82d4567212SWarner LoshIf the connection succeeds,
83d4567212SWarner Losha socket in the
84e117e7a5SRuslan Ermilov.Ux
85d4567212SWarner Loshdomain of type
86d4567212SWarner Losh.Dv SOCK_STREAM
87d4567212SWarner Loshis returned to the caller, and given to the remote
88ae828962SRuslan Ermilovcommand as
89ae828962SRuslan Ermilov.Dv stdin , stdout ,
90ae828962SRuslan Ermilovand
91ae828962SRuslan Ermilov.Dv stderr .
92e117e7a5SRuslan Ermilov.Sh RETURN VALUES
93d4567212SWarner LoshThe
94d4567212SWarner Losh.Fn rcmdsh
95d4567212SWarner Loshfunction
96d4567212SWarner Loshreturns a valid socket descriptor on success.
97e117e7a5SRuslan ErmilovOtherwise, \-1 is returned
98e117e7a5SRuslan Ermilovand a diagnostic message is printed on the standard error.
99d4567212SWarner Losh.Sh SEE ALSO
100d4567212SWarner Losh.Xr rsh 1 ,
101d4567212SWarner Losh.Xr socketpair 2 ,
102d4567212SWarner Losh.Xr rcmd 3 ,
103d4567212SWarner Losh.Xr rshd 8
104d4567212SWarner Losh.Sh HISTORY
105d4567212SWarner LoshThe
106d4567212SWarner Losh.Fn rcmdsh
107d4567212SWarner Loshfunction first appeared in
108e117e7a5SRuslan Ermilov.Ox 2.0 ,
109e117e7a5SRuslan Ermilovand made its way into
11068f8e47aSSheldon Hearn.Fx 4.6 .
11124a0682cSRuslan Ermilov.Sh BUGS
11224a0682cSRuslan ErmilovIf
11324a0682cSRuslan Ermilov.Xr rsh 1
11424a0682cSRuslan Ermilovencounters an error, a file descriptor is still returned instead of \-1.
115