.\" $NetBSD: rcmd.3,v 1.9 1996/05/28 02:07:39 mrg Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" %%%LICENSE_START(BSD_4_CLAUSE_UCB) .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" %%%LICENSE_END .\" .\" @(#)rcmd.3 8.1 (Berkeley) 6/4/93 .\" .\" Contributed as Linux man page by David A. Holland, 970908 .\" I have not checked whether the Linux situation is exactly the same. .\" .\" 2007-12-08, mtk, Converted from mdoc to man macros .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1999 NAKANO Takeo all rights reserved. .\" Translated Mon Mar 1 1999 by NAKANO Takeo .\" Updated 2012-04-30, Akihiro MOTOKI .\" Updated 2012-05-05, Akihiro MOTOKI .\" .TH RCMD 3 2020\-12\-21 Linux "Linux Programmer's Manual" .SH 名前 rcmd, rresvport, iruserok, ruserok, rcmd_af, rresvport_af, iruserok_af, ruserok_af \- リモートコマンドにストリームを返す関数群 .SH 書式 .nf \fB#include \ \ \fP/* Or on some systems */ .PP \fBint rcmd(char **\fP\fIahost\fP\fB, unsigned short \fP\fIinport\fP\fB, const char *\fP\fIlocuser\fP\fB,\fP \fB const char *\fP\fIremuser\fP\fB, const char *\fP\fIcmd\fP\fB, int *\fP\fIfd2p\fP\fB);\fP .PP \fBint rresvport(int *\fP\fIport\fP\fB);\fP .PP \fBint iruserok(uint32_t \fP\fIraddr\fP\fB, int \fP\fIsuperuser\fP\fB,\fP \fB const char *\fP\fIruser\fP\fB, const char *\fP\fIluser\fP\fB);\fP .PP \fBint ruserok(const char *\fP\fIrhost\fP\fB, int \fP\fIsuperuser\fP\fB,\fP \fB const char *\fP\fIruser\fP\fB, const char *\fP\fIluser\fP\fB);\fP .PP \fBint rcmd_af(char **\fP\fIahost\fP\fB, unsigned short \fP\fIinport\fP\fB, const char *\fP\fIlocuser\fP\fB,\fP \fB const char *\fP\fIremuser\fP\fB, const char *\fP\fIcmd\fP\fB, int *\fP\fIfd2p\fP\fB,\fP \fB sa_family_t \fP\fIaf\fP\fB);\fP .PP \fBint rresvport_af(int *\fP\fIport\fP\fB, sa_family_t \fP\fIaf\fP\fB);\fP .PP \fBint iruserok_af(const void *\fP\fIraddr\fP\fB, int \fP\fIsuperuser\fP\fB,\fP \fB const char *\fP\fIruser\fP\fB, const char *\fP\fIluser\fP\fB, sa_family_t \fP\fIaf\fP\fB);\fP .PP \fBint ruserok_af(const char *\fP\fIrhost\fP\fB, int \fP\fIsuperuser\fP\fB,\fP \fB const char *\fP\fIruser\fP\fB, const char *\fP\fIluser\fP\fB, sa_family_t \fP\fIaf\fP\fB);\fP .fi .PP .RS -4 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .RE .PP \fBrcmd\fP(), \fBrcmd_af\fP(), \fBrresvport\fP(), \fBrresvport_af\fP(), \fBiruserok\fP(), \fBiruserok_af\fP(), \fBruserok\fP(), \fBruserok_af\fP(): Since glibc 2.19: _DEFAULT_SOURCE Glibc 2.19 and earlier: _BSD_SOURCE .SH 説明 \fBrcmd\fP() 関数は、スーパーユーザーがリモートマシンでコマンドを実行するために 用いられる。このとき特権ポート番号をもとにした認証スキームが 用いられる。 \fBrresvport\fP() 関数は、特権ポート空間のアドレスを持つソケットのファイルディスクリプターを返す。 \fBiruserok\fP() 関数と \fBruserok\fP() 関数は、 \fBrcmd\fP() でサービス要求を行ったクライアントの認証を行うために サーバーが用いる関数である。 以上の 4 つの関数は、 \fBrshd\fP(8) サーバーによって (他の関数とともに) 利用される。 .SS rcmd() \fBrcmd\fP() 関数は \fBgethostbyname\fP(3) を用いて \fI*ahost\fP の参照を行う。ホストが存在しない場合は \-1 を返す。 見つかった場合は \fI*ahost\fP にホストの標準名 (standard name) をセットして、 予約されているインターネットポート \fIinport\fP 経由でサーバーへの接続を確立する。 .PP 接続に成功したら、インターネットドメインに存在するタイプ \fBSOCK_STREAM\fP のソケットが呼び出しもとに返される。 このソケットの相手側はリモートコマンドの \fIstdin\fP および \fIstdout\fP に接続される。 \fIfd2p\fP がゼロでない場合は、制御プロセスへの接続がもう一つ用意され、 そのファイルディスクリプターが \fI*fd2p\fP にセットされる。 制御プロセスはリモートコマンドからの標準エラー出力 (unit 2) を このチャンネルに返す。 また制御プロセスはこの接続から受け取ったバイトデータを UNIX シグナルの番号として扱い、リモートコマンドのプロセス グループへとシグナルを送る。 \fIfd2p\fP がゼロの場合は、 \fIstderr\fP (リモートコマンドの unit 2) は \fIstdout\fP と一緒にまとめられる。またこの場合はリモートプロセスへ 任意のシグナルを送ることはできなくなる。 ただし帯域外 (out\-of\-band) データを用いれば、 リモートプロセスの注意を引くことはできるかもしれない。 .PP プロトコルの詳細は \fBrshd\fP(8) に記述されている。 .SS rresvport() .\" The \fBrresvport\fP() function is used to obtain a socket with a privileged port bound to it. This socket is suitable for use by \fBrcmd\fP() and several other functions. Privileged ports are those in the range 0 to 1023. Only a privileged process (on Linux: a process that has the \fBCAP_NET_BIND_SERVICE\fP capability in the user namespace governing its network namespace). is allowed to bind to a privileged port. In the glibc implementation, this function restricts its search to the ports from 512 to 1023. The \fIport\fP argument is value\-result: the value it supplies to the call is used as the starting point for a circular search of the port range; on (successful) return, it contains the port number that was bound to. .SS "iruserok() と ruserok()" \fBiruserok\fP() と \fBruserok\fP() 関数は、まず以下の引数を取る: リモートホスト (\fBiruserok\fP() は IP アドレスで、 \fBruserok\fP() はホスト名で指定)、 2 つのユーザー名、ローカルユーザーの名前が スーパーユーザーのものであるかどうかを示すフラグ、である。 もしユーザーが\fBスーパーユーザーではない\fP場合は、これらの関数は \fI/etc/hosts.equiv\fP ファイルをチェックする。ファイルが見つからなかったり、 内容のチェックに失敗した場合には、 ローカルユーザーのホームディレクトリにある \fI.rhosts\fP ファイルをチェックして、サービス要求が許可されているかどうか調べる。 .PP If this file does not exist, is not a regular file, is owned by anyone other than the user or the superuser, is writable by anyone other than the owner, or is hardlinked anywhere, the check automatically fails. Zero is returned if the machine name is listed in the \fIhosts.equiv\fP file, or the host and remote username are found in the \fI.rhosts\fP file; otherwise \fBiruserok\fP() and \fBruserok\fP() return \-1. If the local domain (as obtained from \fBgethostname\fP(2)) is the same as the remote domain, only the machine name need be specified. .PP リモートホストの IP アドレスがわかっている場合は、 \fBruserok\fP() よりも \fBiruserok\fP()\fBを用いる方が良いだろう。\fP \fBruserok\fP() はリモートホストの所属するドメインの DNS サーバーが信頼できなくても 使用できるからである。 .SS "*_af() 版" 上記で述べた関数は全て IPv4 (\fBAF_INET\fP) ソケットで動作する。 "_af" 版では追加の引数があり、この引数でソケットアドレス ファミリーを指定できる。これらの関数では、 \fIaf\fP 引数には \fBAF_INET\fP か \fBAF_INET6\fP が指定できる。 \fBrcmd_af\fP() では追加で \fBAF_UNSPEC\fP も指定できる。 .SH 返り値 \fBrcmd\fP() 関数は成功すると有効なソケットディスクリプターを返す。 失敗すると \-1 を返し、標準エラー出力に診断メッセージを 表示する。 .PP \fBrresvport\fP() 関数は、成功するとバインドされた有効なソケットディスクリプターを返す。 失敗すると \-1 を返し、グローバル変数 \fIerrno\fP をエラーの原因に対応する値にセットする。 エラーコード \fBEAGAIN\fP は、この関数においては「すべてのネットワークポートが使用中」 という意味を表す。 .PP \fBruserok\fP() と \fBiruserok\fP() の返り値については、上述の説明を参照。 .SH バージョン 関数 \fBiruserok_af\fP(), \fBrcmd_af\fP(), \fBrresvport_af\fP(), \fBruserok_af\fP() は glibc バージョン 2.2 以降で提供されている。 .SH 属性 この節で使用されている用語の説明は \fBattributes\fP(7) を参照のこと。 .TS allbox; lbw27 lb lb l l l. Interface Attribute Value T{ \fBrcmd\fP(), \fBrcmd_af\fP() T} Thread safety MT\-Unsafe T{ \fBrresvport\fP(), \fBrresvport_af\fP() T} Thread safety MT\-Safe T{ \fBiruserok\fP(), \fBruserok\fP(), .br \fBiruserok_af\fP(), \fBruserok_af\fP() T} Thread safety MT\-Safe locale .TE .sp 1 .SH 準拠 POSIX.1 にはない。 BSD 系、Solaris や他の多くのシステムに存在する。 これらの関数は 4.2BSD で登場した。 "_af" が付くバージョンはより最近に 追加されたもので、あまり多くのシステムには存在しない。 .SH バグ .\" Bug filed 25 Nov 2007: .\" http://sources.redhat.com/bugzilla/show_bug.cgi?id=5399 \fBiruserok\fP() と \fBiruserok_af\fP() は glibc バージョン 2.12 以降のヘッダー でのみ宣言されている。 .SH 関連項目 \fBrlogin\fP(1), \fBrsh\fP(1), \fBrexec\fP(3), \fBrexecd\fP(8), \fBrlogind\fP(8), \fBrshd\fP(8) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。