#include <netdb.h>
[[deprecated]]
int rexec(char **restrict ahost, int inport,
const char *restrict user, const char *restrict passwd,
const char *restrict cmd, int *restrict fd2p);
[[deprecated]]
int rexec_af(char **restrict ahost, int inport,
const char *restrict user, const char *restrict passwd,
const char *restrict cmd, int *restrict fd2p,
sa_family_t af);
rexec(), rexec_af():
glibc 2.19 以降:
_DEFAULT_SOURCE
glibc 2.19 以前:
_BSD_SOURCE
The rexec() function looks up the host *ahost using gethostbyname(3), returning -1 if the host does not exist. Otherwise, *ahost is set to the standard name of the host. If a username and password are both specified, then these are used to authenticate to the foreign host; otherwise, the environment and then the .netrc file in user's home directory are searched for appropriate information. If all this fails, the user is prompted for the information.
ポート inport には、接続に使用する DARPA Internet の well-known ポートを指定する。 getservbyname("exec", "tcp") を呼び出すと構造体へのポインターが返され (getservent(3) 参照)、この構造体には必要なポートが入っている。 接続に使用されるプロトコルについての詳細は rexecd(8) に書かれている (訳注: 現在のところ存在しない)。
接続に成功すると、インターネットドメインの SOCK_STREAM 型のソケットが返され、そのソケットはリモートコマンドの 標準入力および標準出力となる。 fd2p が 0 以外の場合、制御プロセスへの補助チャンネルがセットアップされ、 補助チャンネルのファイルディスクリプターが *fd2p に書かれる。 制御プロセスはコマンドからの診断メッセージ出力 (ファイルディスクリプター 2) をこのチャンネルで返す。また、このチャンネル経由で UNIX のシグナル番号を示すバイトを受信する。受信したシグナルは コマンドが属すプロセスグループに転送される。 診断情報にはリモートの認証失敗は含まれない。なぜなら、認証の確認が行われた 後で補助チャンネルの接続はセットアップされるからである。 fd2p が 0 の場合、標準エラー (リモートコマンドのファイルディスクリプター 2) は 標準出力と同様に扱われ、リモートプロセスに任意のシグナルを送るための 手段は提供されない。但し、リモートプロセスに対してトリガーをかけるために、 帯域外データ (out-of-band data) を使うことはできる。
| Interface | Attribute | Value |
| rexec(), rexec_af() | Thread safety | MT-Unsafe |
The underlying service is considered a big security hole, and therefore, not enabled on many sites; see rexecd(8) for explanations.