rcmdsh(3)

rcmdsh3

Return a stream to a remote command without superuser

Usage

#include <unistd.h>

int

rcmdsh(char **ahost, int inport, const char *locuser, const char *remuser, const char *cmd, const char *rshprog);

Overview

The rcmdsh() function is used by normal users to execute a command on a remote machine using an authentication scheme based on reserved port numbers using rshd(8) or the value of rshprog (if non-NULL).

The rcmdsh() 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 and a connection is established to a server residing at the well-known Internet port “shell/tcp” (or whatever port is used by rshprog). The inport argument is ignored; it is only included to provide an interface similar to rcmd(3).

If the connection succeeds, a socket in the UNIX domain of type SOCK_STREAM is returned to the caller, and given to the remote command as stdin, stdout, and stderr.

Return values

The rcmdsh() function returns a valid socket descriptor on success. Otherwise, -1 is returned and a diagnostic message is printed on the standard error.

Releases

63 releases since FreeBSD 4.6-RELEASE; the text changed 36 times.

  1. 4.6–4.6.2
  2. 4.7–4.11
  3. 5.0
  4. 5.1–5.5
  5. 6.0–6.3
  6. 6.4
  7. 7.0
  8. 7.1
  9. 7.2
  10. 7.3
  11. 7.4
  12. 8.0
  13. 8.1
  14. 8.2
  15. 8.3
  16. 8.4
  17. 9.0
  18. 9.1
  19. 9.2
  20. 9.3
  21. 10.0
  22. 10.1
  23. 10.2
  24. 10.3
  25. 10.4
  26. 11.0
  27. 11.1
  28. 11.2
  29. 11.3
  30. 11.4
  31. 12.0
  32. 12.1
  33. 12.2
  34. 12.3
  35. 12.4
  36. 13.0–13.2
  37. 13.3–16.0

History

The rcmdsh() function first appeared in OpenBSD 2.0, and made its way into FreeBSD 4.6.

Bugs

If rsh(1) encounters an error, a file descriptor is still returned instead of -1.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.