xref: /freebsd/lib/libc/net/rcmdsh.3 (revision d45672120f0aeab46254d514727c0cec784a1826)
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
43d4567212SWarner Losh.Fd #include <unistd.h>
44d4567212SWarner Losh.Ft int
45d4567212SWarner Losh.Fn rcmdsh "char **ahost" "int inport" "const char *locuser" "const char *remuser" "const char *cmd" "char *rshprog"
46d4567212SWarner Losh.Sh DESCRIPTION
47d4567212SWarner LoshThe
48d4567212SWarner Losh.Fn rcmdsh
49d4567212SWarner Loshfunction
50d4567212SWarner Loshis used by normal users to execute a command on
51d4567212SWarner Losha remote machine using an authentication scheme based
52d4567212SWarner Loshon reserved port numbers using
53d4567212SWarner Losh.Xr rshd 8
54d4567212SWarner Loshor the value of
55d4567212SWarner Losh.Fa rshprog
56d4567212SWarner Losh(if non-null).
57d4567212SWarner Losh.Pp
58d4567212SWarner LoshThe
59d4567212SWarner Losh.Fn rcmdsh
60d4567212SWarner Loshfunction
61d4567212SWarner Loshlooks up the host
62d4567212SWarner Losh.Fa *ahost
63d4567212SWarner Loshusing
64d4567212SWarner Losh.Xr gethostbyname 3 ,
65d4567212SWarner Loshreturning \-1 if the host does not exist.
66d4567212SWarner LoshOtherwise
67d4567212SWarner Losh.Fa *ahost
68d4567212SWarner Loshis set to the standard name of the host
69d4567212SWarner Loshand a connection is established to a server
70d4567212SWarner Loshresiding at the well-known Internet port
71d4567212SWarner Losh.Li shell/tcp
72d4567212SWarner Losh(or whatever port is used by
73d4567212SWarner Losh.Fa rshprog
74d4567212SWarner Losh).  The parameter
75d4567212SWarner Losh.Fa inport
76d4567212SWarner Loshis ignored; it is only included to provide an interface similar to
77d4567212SWarner Losh.Xr rcmd 3 .
78d4567212SWarner Losh.Pp
79d4567212SWarner LoshIf the connection succeeds,
80d4567212SWarner Losha socket in the
81d4567212SWarner Losh.Tn UNIX
82d4567212SWarner Loshdomain of type
83d4567212SWarner Losh.Dv SOCK_STREAM
84d4567212SWarner Loshis returned to the caller, and given to the remote
85d4567212SWarner Loshcommand as stdin and stdout, and stderr.
86d4567212SWarner Losh.Sh DIAGNOSTICS
87d4567212SWarner LoshThe
88d4567212SWarner Losh.Fn rcmdsh
89d4567212SWarner Loshfunction
90d4567212SWarner Loshreturns a valid socket descriptor on success.
91d4567212SWarner LoshIt returns \-1 on error and prints a diagnostic message on the standard error.
92d4567212SWarner Losh.Sh SEE ALSO
93d4567212SWarner Losh.Xr rsh 1 ,
94d4567212SWarner Losh.Xr socketpair 2 ,
95d4567212SWarner Losh.Xr rcmd 3 ,
96d4567212SWarner Losh.Xr rshd 8
97d4567212SWarner Losh.Sh BUGS
98d4567212SWarner LoshIf
99d4567212SWarner Losh.Xr rsh 1
100d4567212SWarner Loshgets an error a file descriptor is still returned instead of \-1.
101d4567212SWarner Losh.Sh HISTORY
102d4567212SWarner LoshThe
103d4567212SWarner Losh.Fn rcmdsh
104d4567212SWarner Loshfunction first appeared in
105d4567212SWarner Losh.Ox 2.0 .
106