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" is used, with the realm determined by domain-realm mapping.
30 command is the command to run as a NULL-terminated array of NUL-
31 terminated strings.
32
33 If no principal is specified and the default is used, the underlying
34 GSS-API library may canonicalize host via DNS before determining the
35 service principal, depending on your library configuration. Specifying
36 a principal disables this behavior.
37
38 The remctl protocol uses Kerberos via GSS-API for authentication. The
39 underlying GSS-API library will use the default ticket cache for
40 authentication, so to successfully use remctl(), the caller should
41 already have Kerberos tickets for an appropriate realm stored in its
42 default ticket cache. The environment variable KRB5CCNAME can be used
43 to control which ticket cache is used. If the client needs to control
44 which ticket cache is used without changing the environment, use the
45 full client API along with remctl_set_ccache(3).
46
47 remctl() returns a newly allocated remctl_result struct, which has the
48 following members:
49
50 struct remctl_result {
51 char *error; /* remctl error if non-NULL. */
52 char *stdout_buf; /* Standard output. */
53 size_t stdout_len; /* Length of standard output. */
54 char *stderr_buf; /* Standard error. */
55 size_t stderr_len; /* Length of standard error. */
56 int status; /* Exit status of remote command. */
57 };
58
59 If error is non-NULL, a protocol error occurred and the command was not
60 successfully completed. Otherwise, standard output from the command
61 will be stored in stdout_buf with the length in stdout_len, standard
62 error from the command will be stored in stderr_buf with the length in
63 stderr_len, and status will hold the exit status of the command.
64 Following the standard Unix convention, a 0 status should normally be
65 considered success and any non-zero status should normally be
66 considered failure, although a given command may have its own exit
67 status conventions.
68
69 remctl_result_free() frees the remctl_result struct when the calling
70 program is through with it.
71
72 If you want more control over the steps of the protocol, issue multiple
73 commands on the same connection, control the ticket cache or source IP,
74 set a timeout on replies, or send data as part of the command that
75 contains NULs, use the full API described in remctl_new(3),
76 remctl_open(3), remctl_commandv(3), and remctl_output(3).
77
79 remctl() returns NULL on failure to allocate a new remctl_result struct
80 or on failure to allocate space to store an error message. Otherwise,
81 it returns a newly allocated remctl_result struct with either an error
82 message in the error field or the results of the command filled out as
83 described above. If remctl() returns NULL, errno will be set to an
84 appropriate error code (generally ENOMEM).
85
87 This interface has been provided by the remctl client library since its
88 initial release in version 2.0.
89
90 The default port was changed to the IANA-registered port of 4373 in
91 version 2.11.
92
93 Support for IPv6 was added in version 2.4.
94
96 If the principal argument to remctl() is NULL, most GSS-API libraries
97 will canonicalize the host using DNS before deriving the principal name
98 from it. This means that when connecting to a remctl server via a
99 CNAME, remctl() will normally authenticate using a principal based on
100 the canonical name of the host instead of the specified host parameter.
101 This behavior may cause problems if two consecutive DNS lookups of host
102 may return two different results, such as with some DNS-based load-
103 balancing systems.
104
105 The canonicalization behavior is controlled by the GSS-API library;
106 with the MIT Kerberos GSS-API library, canonicalization can be disabled
107 by setting "rdns" to false in the [libdefaults] section of krb5.conf.
108 It can also be disabled by passing an explicit Kerberos principal name
109 via the principal argument, which will then be used without changes.
110 If canonicalization is desired, the caller may wish to canonicalize
111 host before calling remctl() to avoid problems with multiple DNS calls
112 returning different results.
113
114 The default behavior, when a port of 0 is given, of trying 4373 and
115 falling back to 4444 will be removed in a future version of this
116 library in favor of using the "remctl" service in /etc/services if set
117 and then falling back on only 4373. 4444 was the poorly-chosen
118 original remctl port and should be phased out.
119
121 The remctl port number, 4373, was derived by tracing the diagonals of a
122 QWERTY keyboard up from the letters "remc" to the number row.
123
125 Russ Allbery <eagle@eyrie.org>
126
128 Copyright 2007, 2008, 2009, 2014 The Board of Trustees of the Leland
129 Stanford Junior University
130
131 Copying and distribution of this file, with or without modification,
132 are permitted in any medium without royalty provided the copyright
133 notice and this notice are preserved. This file is offered as-is,
134 without any warranty.
135
137 remctl_new(3), remctl_open(3), remctl_command(3), remctl_commandv(3),
138 remctl_output(3), remctl_close(3)
139
140 The current version of the remctl library and complete details of the
141 remctl protocol are available from its web page at
142 <http://www.eyrie.org/~eagle/software/remctl/>.
143
144
145
1463.14 2018-04-01 REMCTL(3)