1REMCTL(3) remctl Library Reference REMCTL(3)
2
3
4
6 remctl, remctl_result_free - Simple remctl call to a remote server
7
9 #include <remctl.h>
10
11 struct remctl_result *
12 remctl(const char *host, unsigned short port,
13 const char *principal, const char **command);
14
15 void remctl_result_free(struct remctl_result *result);
16
18 remctl() provides a simplified client API for the remctl protocol.
19 Given the host, port, service principal for authentication, and command
20 to run, it opens a connection to the remote system, sends the command
21 via the remctl protocol, reads the results, closes the connection, and
22 returns the result as a remctl_result struct.
23
24 host is a hostname or IP address and must be non-NULL. port is the
25 port to connect to; if 0, the library first attempts to connect to the
26 registered port of 4373 and then tries the legacy port of 4444 if that
27 fails. Future versions of the library will drop this fallback to 4444.
28 principal is the service principal to use for authentication; if NULL,
29 "host/host" in the default local realm is used. command is the command
30 to run as a NULL-terminated array of nul-terminated strings.
31
32 The remctl protocol uses Kerberos v5 via GSS-API for authentication.
33 The underlying GSS-API library will use the default ticket cache for
34 authentication, so to successfully use remctl(), the caller should
35 already have Kerberos tickets for an appropriate realm stored in its
36 default ticket cache. The environment variable KRB5CCNAME can be used
37 to control which ticket cache is used.
38
39 remctl() returns a newly allocated remctl_result struct, which has the
40 following members:
41
42 struct remctl_result {
43 char *error; /* remctl error if non-NULL. */
44 char *stdout_buf; /* Standard output. */
45 size_t stdout_len; /* Length of standard output. */
46 char *stderr_buf; /* Standard error. */
47 size_t stderr_len; /* Length of standard error. */
48 int status; /* Exit status of remote command. */
49 };
50
51 If error is non-NULL, a protocol error occurred and the command was not
52 successfully completed. Otherwise, standard output from the command
53 will be stored in stdout_buf with the length in stdout_len, standard
54 error from the command will be stored in stderr_buf with the length in
55 stderr_len, and status will hold the exit status of the command. Fol‐
56 lowing the standard Unix convention, a 0 status should normally be con‐
57 sidered success and any non-zero status should normally be considered
58 failure, although a given command may have its own exit status conven‐
59 tions.
60
61 remctl_result_free() frees the remctl_result struct when the calling
62 program is through with it.
63
64 If you want more control over the steps of the protocol, if you want to
65 issue multiple commands on the same connection, or if you need to send
66 data as part of the command that contains nuls, use the full API
67 described in remctl_new(3), remctl_open(3), remctl_commandv(3), and
68 remctl_output(3).
69
71 remctl() returns NULL on failure to allocate a new remctl_result struct
72 or on failure to allocate space to store an error message. Otherwise,
73 it returns a newly allocated remctl_result struct with either an error
74 message in the error field or the results of the command filled out as
75 described above. If remctl() returns NULL, errno will be set to an
76 appropriate error code (generally ENOMEM).
77
79 The default behavior, when a port of 0 is given, of trying 4373 and
80 falling back to 4444 will be removed in a future version of this
81 library in favor of using the "remctl" service in /etc/services if set
82 and then falling back on only 4373. 4444 was the poorly-chosen origi‐
83 nal remctl port and should be phased out.
84
86 The remctl port number, 4373, was derived by tracing the diagonals of a
87 QWERTY keyboard up from the letters "remc" to the number row.
88
90 remctl_new(3), remctl_open(3), remctl_command(3), remctl_commandv(3),
91 remctl_output(3), remctl_close(3)
92
93 The current version of the remctl library and complete details of the
94 remctl protocol are available from its web page at
95 <http://www.eyrie.org/~eagle/software/remctl/>.
96
98 Russ Allbery <rra@stanford.edu>
99
100
101
1022.11 2007-09-01 REMCTL(3)