Debian Codegraph @

upstream/fedora-44/man1/varlinkctl.1

raw
1 '\" t
2 .TH "VARLINKCTL" "1" "" "systemd 259.5" "varlinkctl"
3 .\" -----------------------------------------------------------------
4 .\" * Define some portability stuff
5 .\" -----------------------------------------------------------------
6 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 .\" http://bugs.debian.org/507673
8 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
9 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 .ie \n(.g .ds Aq \(aq
11 .el .ds Aq '
12 .\" -----------------------------------------------------------------
13 .\" * set default formatting
14 .\" -----------------------------------------------------------------
15 .\" disable hyphenation
16 .nh
17 .\" disable justification (adjust text to left margin only)
18 .ad l
19 .\" -----------------------------------------------------------------
20 .\" * MAIN CONTENT STARTS HERE *
21 .\" -----------------------------------------------------------------
22 .SH "NAME"
23 varlinkctl \- Introspect with and invoke Varlink services
24 .SH "SYNOPSIS"
25 .HP \w'\fBvarlinkctl\fR\ 'u
26 \fBvarlinkctl\fR [OPTIONS...] info \fIADDRESS\fR
27 .HP \w'\fBvarlinkctl\fR\ 'u
28 \fBvarlinkctl\fR [OPTIONS...] list\-interfaces \fIADDRESS\fR
29 .HP \w'\fBvarlinkctl\fR\ 'u
30 \fBvarlinkctl\fR [OPTIONS...] list\-methods \fIADDRESS\fR [\fIINTERFACE\fR...]
31 .HP \w'\fBvarlinkctl\fR\ 'u
32 \fBvarlinkctl\fR [OPTIONS...] introspect \fIADDRESS\fR [\fIINTERFACE\fR...]
33 .HP \w'\fBvarlinkctl\fR\ 'u
34 \fBvarlinkctl\fR [OPTIONS...] call \fIADDRESS\fR \fIMETHOD\fR [\fIARGUMENTS\fR]
35 .HP \w'\fBvarlinkctl\fR\ 'u
36 \fBvarlinkctl\fR [OPTIONS...] \-\-exec\ call call \fIADDRESS\fR \fIMETHOD\fR \fIARGUMENTS\fR \-\- \fICMDLINE\fR
37 .HP \w'\fBvarlinkctl\fR\ 'u
38 \fBvarlinkctl\fR [OPTIONS...] validate\-idl [\fIFILE\fR]
39 .SH "DESCRIPTION"
40 .PP
41 \fBvarlinkctl\fR
42 may be used to introspect and invoke
43 \m[blue]\fBVarlink\fR\m[]\&\s-2\u[1]\d\s+2
44 services\&.
45 .PP
46 Services are referenced by one of the following:
47 .sp
48 .RS 4
49 .ie n \{\
50 \h'-04'\(bu\h'+03'\c
51 .\}
52 .el \{\
53 .sp -1
54 .IP \(bu 2.3
55 .\}
56 A Varlink service reference starting with the
57 "unix:"
58 string, followed by an absolute
59 \fBAF_UNIX\fR
60 socket path, or by
61 "@"
62 and an arbitrary string (the latter for referencing sockets in the abstract namespace)\&. In this case, a stream socket connection is made to the specified socket\&.
63 .RE
64 .sp
65 .RS 4
66 .ie n \{\
67 \h'-04'\(bu\h'+03'\c
68 .\}
69 .el \{\
70 .sp -1
71 .IP \(bu 2.3
72 .\}
73 A Varlink service reference starting with the
74 "exec:"
75 string, followed by an absolute path of a binary to execute\&. In this case, the specified process is forked off locally, with a connected stream socket passed in\&.
76 .RE
77 .sp
78 .RS 4
79 .ie n \{\
80 \h'-04'\(bu\h'+03'\c
81 .\}
82 .el \{\
83 .sp -1
84 .IP \(bu 2.3
85 .\}
86 A Varlink service reference starting with the
87 "ssh\-unix:"
88 string, followed by an SSH host specification, followed by
89 ":", followed by an absolute
90 \fBAF_UNIX\fR
91 socket path\&. (This requires OpenSSH 9\&.4 or newer on the server side, and abstract namespace sockets are not supported\&.)
92 .RE
93 .sp
94 .RS 4
95 .ie n \{\
96 \h'-04'\(bu\h'+03'\c
97 .\}
98 .el \{\
99 .sp -1
100 .IP \(bu 2.3
101 .\}
102 A Varlink service reference starting with the
103 "ssh\-exec:"
104 string, followed by an SSH host specification, followed by
105 ":", followed by a command line\&. In this case, the command is invoked and the Varlink protocol is spoken on the standard input and output of the invoked command\&.
106 .RE
107 .PP
108 For convenience, these two simpler (redundant) service address syntaxes are also supported:
109 .sp
110 .RS 4
111 .ie n \{\
112 \h'-04'\(bu\h'+03'\c
113 .\}
114 .el \{\
115 .sp -1
116 .IP \(bu 2.3
117 .\}
118 A file system path to an
119 \fBAF_UNIX\fR
120 socket, either absolute (i\&.e\&. begins with
121 "/") or relative (in which case it must begin with
122 "\&./")\&.
123 .RE
124 .sp
125 .RS 4
126 .ie n \{\
127 \h'-04'\(bu\h'+03'\c
128 .\}
129 .el \{\
130 .sp -1
131 .IP \(bu 2.3
132 .\}
133 A file system path to an executable, either absolute or relative (as above, must begin with
134 "/"
135 or
136 "\&./", respectively)\&.
137 .RE
138 .SH "COMMANDS"
139 .PP
140 The following commands are understood:
141 .PP
142 \fBinfo\fR \fIADDRESS\fR
143 .RS 4
144 Shows brief information about the specified service, including vendor name and list of implemented interfaces\&. Expects a service address in one of the formats described above\&.
145 .sp
146 Added in version 255\&.
147 .RE
148 .PP
149 \fBlist\-interfaces\fR \fIADDRESS\fR
150 .RS 4
151 Shows a list of interfaces implemented by the specified service\&. Expects a service address in one of the formats described above\&.
152 .sp
153 Added in version 255\&.
154 .RE
155 .PP
156 \fBlist\-methods\fR \fIADDRESS\fR [\fIINTERFACE\&...\fR]
157 .RS 4
158 Shows a list of methods implemented by the specified service\&. Expects a service address in one of the formats described above as well as one or more interface names\&. If no interface name is specified, lists all methods of all interfaces implemented by the service, otherwise just the methods in the specified interfaces\&.
159 .sp
160 Added in version 257\&.
161 .RE
162 .PP
163 \fBintrospect\fR \fIADDRESS\fR [\fIINTERFACE\&...\fR]
164 .RS 4
165 Shows the interface definitions of the specified interfaces provided by the specified service\&. Expects a service address in one of the formats described above and optionally one or more Varlink interface names\&. If no interface names are specified, shows all provided interfaces by the service\&.
166 .sp
167 Added in version 255\&.
168 .RE
169 .PP
170 \fBcall\fR \fIADDRESS\fR \fIMETHOD\fR [\fIARGUMENTS\fR]
171 .RS 4
172 Calls the specified method of the specified service\&. Expects a service address in the format described above, a fully qualified Varlink method name, and a JSON arguments object\&. If the arguments object is not specified, it is read from STDIN instead\&. To pass an empty list of parameters, specify the empty object
173 "{}"\&.
174 .sp
175 The reply parameters are written as JSON objects to STDOUT\&.
176 .sp
177 Added in version 255\&.
178 .RE
179 .PP
180 \fBvalidate\-idl\fR [\fIFILE\fR]
181 .RS 4
182 Reads a Varlink interface definition file, parses and validates it, then outputs it with syntax highlighting\&. This checks for syntax and internal consistency of the interface\&. Expects a file name to read the interface definition from\&. If omitted, reads the interface definition from STDIN\&.
183 .sp
184 Added in version 255\&.
185 .RE
186 .PP
187 \fBhelp\fR
188 .RS 4
189 Shows command syntax help\&.
190 .sp
191 Added in version 255\&.
192 .RE
193 .SH "OPTIONS"
194 .PP
195 The following options are understood:
196 .PP
197 \fB\-\-more\fR
198 .RS 4
199 When used with
200 \fBcall\fR: expect multiple method replies\&. If this flag is set, the method call is sent with the
201 \fBmore\fR
202 flag set, which tells the service to generate multiple replies, if needed\&. The command remains running until the service sends a reply message that indicates it is the last in the series (or if the configured timeout is reached, see below)\&. This flag should be set only for method calls that support this mechanism\&.
203 .sp
204 If this mode is enabled, output is automatically switched to JSON\-SEQ mode, so that individual reply objects can be easily discerned\&.
205 .sp
206 This switch has no effect on the method call timeout applied by default\&. Regardless of whether
207 \fB\-\-more\fR
208 is specified or not, the default timeout will be 45s\&. Use
209 \fB\-\-timeout=\fR
210 (see below) to change or disable the timeout\&. When invoking a method call that continuously returns updates, it is typically desirable to disable the timeout with
211 \fB\-\-timeout=infinity\fR\&. On the other hand, when invoking a
212 \fB\-\-more\fR
213 method call for the purpose of enumerating objects (which likely will complete quickly), it is typically beneficial to leave the timeout logic enabled, for robustness reasons\&.
214 .sp
215 Added in version 255\&.
216 .RE
217 .PP
218 \fB\-E\fR
219 .RS 4
220 A shortcut for
221 \fB\-\-more \-\-timeout=infinity\fR\&. This switch is useful for method calls that implement subscription to a continuous stream of updates\&.
222 .sp
223 Added in version 257\&.
224 .RE
225 .PP
226 \fB\-\-collect\fR
227 .RS 4
228 This is similar to
229 \fB\-\-more\fR, but collects all responses in a JSON array, and prints it, rather than in JSON\-SEQ mode\&.
230 .sp
231 Added in version 256\&.
232 .RE
233 .PP
234 \fB\-\-oneway\fR
235 .RS 4
236 When used with
237 \fBcall\fR: do not expect a method reply\&. If this flag is set, the method call is sent with the
238 \fBoneway\fR
239 flag set (the command exits immediately after), which tells the service not to generate a reply\&.
240 .sp
241 Added in version 255\&.
242 .RE
243 .PP
244 \fB\-\-json=\fR\fB\fIMODE\fR\fR
245 .RS 4
246 Selects the JSON output formatting, either
247 "pretty"
248 for nicely indented, colorized output, or
249 "short"
250 for terse output with minimal whitespace and no newlines\&. Defaults to
251 "short"\&.
252 .sp
253 Added in version 255\&.
254 .RE
255 .PP
256 \fB\-j\fR
257 .RS 4
258 Equivalent to
259 \fB\-\-json=pretty\fR
260 when invoked interactively from a terminal\&. Otherwise, it is equivalent to
261 \fB\-\-json=short\fR, in particular when the output is piped to some other program\&.
262 .sp
263 Added in version 255\&.
264 .RE
265 .PP
266 \fB\-\-quiet\fR, \fB\-q\fR
267 .RS 4
268 Suppress output of method call replies\&.
269 .sp
270 Added in version 257\&.
271 .RE
272 .PP
273 \fB\-\-graceful=\fR
274 .RS 4
275 Takes a qualified Varlink error name, i\&.e\&. an interface name, suffixed by an error name, separated by a dot, e\&.g\&.
276 "org\&.varlink\&.service\&.InvalidParameter"\&. Ensures that, if a method call fails with the specified error, this will be treated as success, i\&.e\&. will cause the
277 \fBvarlinkctl\fR
278 invocation to exit with a zero exit status\&. This option may be used more than once in order to treat multiple different errors as successes\&.
279 .sp
280 Added in version 257\&.
281 .RE
282 .PP
283 \fB\-\-timeout=\fR
284 .RS 4
285 Expects a timeout in seconds as parameter\&. By default, a timeout of 45s is enforced\&. To turn off the timeout, specify
286 "infinity"
287 or an empty string\&.
288 .sp
289 Added in version 257\&.
290 .RE
291 .PP
292 \fB\-\-exec\fR
293 .RS 4
294 Once the method call issued via
295 \fBcall\fR
296 completed successfully, chainload the specified command line, with the method call output parameters serialized to JSON passed into standard input (and standard output and standard error inherited from the invoking process)\&. Moreover any file descriptors passed back on the underlying communication socket are passed to the invoked process via the usual
297 \fI$LISTEN_FDS\fR
298 protocol\&. This functionality may be used to consume replies that come with associated file descriptors in a reasonable way\&.
299 .sp
300 Now that if
301 \fB\-\-exec\fR
302 is specified the the third parameter to
303 \fBcall\fR
304 is not optional (i\&.e\&. the method call parameters)\&.
305 .sp
306 Added in version 258\&.
307 .RE
308 .PP
309 \fB\-\-push\-fd=\fR
310 .RS 4
311 Takes a numeric file descriptor number as parameter\&. May be used to pass a file descriptor along with the method call, if the underlying transport supports this\&. May be used multiple times to pass multiple file descriptors, retaining the order in which they are specified\&. The specified file descriptors must be passed to the
312 \fBvarlinkctl\fR
313 invocation\&. Optionally, in place of a numeric file descriptor number an absolute or relative file system path (the latter must be prefixed with
314 "\&./") may be specified, which is opened in read\-only mode\&.
315 .sp
316 Added in version 258\&.
317 .RE
318 .PP
319 \fB\-\-no\-pager\fR
320 .RS 4
321 Do not pipe output into a pager\&.
322 .RE
323 .PP
324 \fB\-h\fR, \fB\-\-help\fR
325 .RS 4
326 Print a short help text and exit\&.
327 .RE
328 .PP
329 \fB\-\-version\fR
330 .RS 4
331 Print a short version string and exit\&.
332 .RE
333 .SH "EXAMPLES"
334 .PP
335 \fBExample\ \&1.\ \&Investigating a Service\fR
336 .PP
337 The following three commands inspect the
338 "io\&.systemd\&.Resolve"
339 service implemented by
340 \fBsystemd-resolved.service\fR(8), listing general service information and implemented interfaces, and then displaying the interface definition of its primary interface:
341 .sp
342 .if n \{\
343 .RS 4
344 .\}
345 .nf
346 $ varlinkctl info /run/systemd/resolve/io\&.systemd\&.Resolve
347 Vendor: The systemd Project
348 Product: systemd (systemd\-resolved)
349 Version: 254 (254\-1522\-g4790521^)
350 URL: https://systemd\&.io/
351 Interfaces: io\&.systemd
352 io\&.systemd\&.Resolve
353 org\&.varlink\&.service
354 $ varlinkctl list\-interfaces /run/systemd/resolve/io\&.systemd\&.Resolve
355 io\&.systemd
356 io\&.systemd\&.Resolve
357 org\&.varlink\&.service
358 $ varlinkctl introspect /run/systemd/resolve/io\&.systemd\&.Resolve io\&.systemd\&.Resolve
359 interface io\&.systemd\&.Resolve
360 type ResolvedAddress(
361 ifindex: ?int,
362 \&...
363 .fi
364 .if n \{\
365 .RE
366 .\}
367 .PP
368 (Interface definition has been truncated in the example above, in the interest of brevity\&.)
369 .PP
370 \fBExample\ \&2.\ \&Invoking a Method\fR
371 .PP
372 The following command resolves a hostname via
373 \fBsystemd-resolved.service\fR(8)\*(Aqs
374 \fBResolveHostname\fR
375 method call\&.
376 .sp
377 .if n \{\
378 .RS 4
379 .\}
380 .nf
381 $ varlinkctl call /run/systemd/resolve/io\&.systemd\&.Resolve io\&.systemd\&.Resolve\&.ResolveHostname \*(Aq{"name":"systemd\&.io","family":2}\*(Aq \-j
382 {
383 "addresses" : [
384 {
385 "ifindex" : 2,
386 "family" : 2,
387 "address" : [
388 185,
389 199,
390 111,
391 153
392 ]
393 }
394 ],
395 "name" : "systemd\&.io",
396 "flags" : 1048577
397 }
398 .fi
399 .if n \{\
400 .RE
401 .\}
402 .PP
403 \fBExample\ \&3.\ \&Investigating a Service Executable\fR
404 .PP
405 The following command inspects the
406 /usr/lib/systemd/systemd\-pcrextend
407 executable and the IPC APIs it provides\&. It then invokes a method on it:
408 .sp
409 .if n \{\
410 .RS 4
411 .\}
412 .nf
413 # varlinkctl info /usr/lib/systemd/systemd\-pcrextend
414 Vendor: The systemd Project
415 Product: systemd (systemd\-pcrextend)
416 Version: 254 (254\-1536\-g97734fb)
417 URL: https://systemd\&.io/
418 Interfaces: io\&.systemd
419 io\&.systemd\&.PCRExtend
420 org\&.varlink\&.service
421 # varlinkctl introspect /usr/lib/systemd/systemd\-pcrextend io\&.systemd\&.PCRExtend
422 interface io\&.systemd\&.PCRExtend
423
424 method Extend(
425 pcr: int,
426 text: ?string,
427 data: ?string
428 ) \-> ()
429 # varlinkctl call /usr/lib/systemd/systemd\-pcrextend io\&.systemd\&.PCRExtend\&.Extend \*(Aq{"pcr":15,"text":"foobar"}\*(Aq
430 {}
431 .fi
432 .if n \{\
433 .RE
434 .\}
435 .PP
436 \fBExample\ \&4.\ \&Invoking a method remotely via SSH\fR
437 .PP
438 The following command acquires a report about the identity of a remote host
439 "somehost"
440 from
441 \fBsystemd-hostnamed.service\fR(8)
442 by connecting via SSH to the
443 \fBAF_UNIX\fR
444 socket the service listens on:
445 .sp
446 .if n \{\
447 .RS 4
448 .\}
449 .nf
450 # varlinkctl call ssh\-unix:somehost:/run/systemd/io\&.systemd\&.Hostname io\&.systemd\&.Hostname\&.Describe \*(Aq{}\*(Aq
451 .fi
452 .if n \{\
453 .RE
454 .\}
455 .PP
456 To invoke a Varlink service binary directly on the remote host, rather than talking to a service via
457 \fBAF_UNIX\fR
458 can be done like this:
459 .sp
460 .if n \{\
461 .RS 4
462 .\}
463 .nf
464 # varlinkctl call ssh\-exec:somehost:systemd\-creds org\&.varlink\&.service\&.GetInfo \*(Aq{}\*(Aq
465 .fi
466 .if n \{\
467 .RE
468 .\}
469 .SH "SEE ALSO"
470 .PP
471 \fBbusctl\fR(1), \m[blue]\fBVarlink\fR\m[]\&\s-2\u[1]\d\s+2
472 .SH "NOTES"
473 .IP " 1." 4
474 Varlink
475 .RS 4
476 \%https://varlink.org/
477 .RE