| 1 |
<?xml version='1.0'?> |
| 2 |
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
| 3 |
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> |
| 4 |
<!-- SPDX-License-Identifier: LGPL-2.1-or-later --> |
| 5 |
|
| 6 |
<refentry id="varlinkctl" |
| 7 |
xmlns:xi="http://www.w3.org/2001/XInclude"> |
| 8 |
|
| 9 |
<refentryinfo> |
| 10 |
<title>varlinkctl</title> |
| 11 |
<productname>systemd</productname> |
| 12 |
</refentryinfo> |
| 13 |
|
| 14 |
<refmeta> |
| 15 |
<refentrytitle>varlinkctl</refentrytitle> |
| 16 |
<manvolnum>1</manvolnum> |
| 17 |
</refmeta> |
| 18 |
|
| 19 |
<refnamediv> |
| 20 |
<refname>varlinkctl</refname> |
| 21 |
<refpurpose>Introspect with and invoke Varlink services</refpurpose> |
| 22 |
</refnamediv> |
| 23 |
|
| 24 |
<refsynopsisdiv> |
| 25 |
<cmdsynopsis> |
| 26 |
<command>varlinkctl</command> |
| 27 |
<arg choice="opt" rep="repeat">OPTIONS</arg> |
| 28 |
<arg choice="plain">info</arg> |
| 29 |
<arg choice="plain"><replaceable>ADDRESS</replaceable></arg> |
| 30 |
</cmdsynopsis> |
| 31 |
|
| 32 |
<cmdsynopsis> |
| 33 |
<command>varlinkctl</command> |
| 34 |
<arg choice="opt" rep="repeat">OPTIONS</arg> |
| 35 |
<arg choice="plain">list-interfaces</arg> |
| 36 |
<arg choice="plain"><replaceable>ADDRESS</replaceable></arg> |
| 37 |
</cmdsynopsis> |
| 38 |
|
| 39 |
<cmdsynopsis> |
| 40 |
<command>varlinkctl</command> |
| 41 |
<arg choice="opt" rep="repeat">OPTIONS</arg> |
| 42 |
<arg choice="plain">list-methods</arg> |
| 43 |
<arg choice="plain"><replaceable>ADDRESS</replaceable></arg> |
| 44 |
<arg choice="opt" rep="repeat"><replaceable>INTERFACE</replaceable></arg> |
| 45 |
</cmdsynopsis> |
| 46 |
|
| 47 |
<cmdsynopsis> |
| 48 |
<command>varlinkctl</command> |
| 49 |
<arg choice="opt" rep="repeat">OPTIONS</arg> |
| 50 |
<arg choice="plain">introspect</arg> |
| 51 |
<arg choice="plain"><replaceable>ADDRESS</replaceable></arg> |
| 52 |
<arg choice="opt" rep="repeat"><replaceable>INTERFACE</replaceable></arg> |
| 53 |
</cmdsynopsis> |
| 54 |
|
| 55 |
<cmdsynopsis> |
| 56 |
<command>varlinkctl</command> |
| 57 |
<arg choice="opt" rep="repeat">OPTIONS</arg> |
| 58 |
<arg choice="plain">call</arg> |
| 59 |
<arg choice="plain"><replaceable>ADDRESS</replaceable></arg> |
| 60 |
<arg choice="plain"><replaceable>METHOD</replaceable></arg> |
| 61 |
<arg choice="opt"><replaceable>ARGUMENTS</replaceable></arg> |
| 62 |
</cmdsynopsis> |
| 63 |
|
| 64 |
<cmdsynopsis> |
| 65 |
<command>varlinkctl</command> |
| 66 |
<arg choice="opt" rep="repeat">OPTIONS</arg> |
| 67 |
<arg choice="plain">--exec</arg> |
| 68 |
<arg choice="plain">call</arg> |
| 69 |
<arg choice="plain"><replaceable>ADDRESS</replaceable></arg> |
| 70 |
<arg choice="plain"><replaceable>METHOD</replaceable></arg> |
| 71 |
<arg choice="plain"><replaceable>ARGUMENTS</replaceable></arg> |
| 72 |
<arg choice="plain">--</arg> |
| 73 |
<arg choice="plain"><replaceable>CMDLINE</replaceable></arg> |
| 74 |
</cmdsynopsis> |
| 75 |
|
| 76 |
<cmdsynopsis> |
| 77 |
<command>varlinkctl</command> |
| 78 |
<arg choice="opt" rep="repeat">OPTIONS</arg> |
| 79 |
<arg choice="plain">serve</arg> |
| 80 |
<arg choice="plain"><replaceable>METHOD</replaceable></arg> |
| 81 |
<arg choice="req" rep="repeat"><replaceable>CMDLINE</replaceable></arg> |
| 82 |
</cmdsynopsis> |
| 83 |
|
| 84 |
<cmdsynopsis> |
| 85 |
<command>varlinkctl</command> |
| 86 |
<arg choice="opt" rep="repeat">OPTIONS</arg> |
| 87 |
<arg choice="plain">validate-idl</arg> |
| 88 |
<arg choice="opt"><replaceable>FILE</replaceable></arg> |
| 89 |
</cmdsynopsis> |
| 90 |
</refsynopsisdiv> |
| 91 |
|
| 92 |
<refsect1> |
| 93 |
<title>Description</title> |
| 94 |
|
| 95 |
<para><command>varlinkctl</command> may be used to introspect and invoke <ulink |
| 96 |
url="https://varlink.org/">Varlink</ulink> services.</para> |
| 97 |
|
| 98 |
<para>Services are referenced by one of the following:</para> |
| 99 |
|
| 100 |
<itemizedlist> |
| 101 |
<listitem><para>A Varlink service reference starting with the <literal>unix:</literal> string, followed |
| 102 |
by an absolute <constant>AF_UNIX</constant> socket path, or by <literal>@</literal> and an arbitrary |
| 103 |
string (the latter for referencing sockets in the abstract namespace). In this case, a stream socket |
| 104 |
connection is made to the specified socket.</para></listitem> |
| 105 |
|
| 106 |
<listitem><para>A Varlink service reference starting with the <literal>exec:</literal> string, followed |
| 107 |
by an absolute path of a binary to execute. In this case, the specified process is forked off locally, |
| 108 |
with a connected stream socket passed in.</para></listitem> |
| 109 |
|
| 110 |
<listitem><para>A Varlink service reference starting with the <literal>ssh-unix:</literal> string, followed |
| 111 |
by an SSH host specification, followed by <literal>:</literal>, followed by an absolute |
| 112 |
<constant>AF_UNIX</constant> socket path. (This requires OpenSSH 9.4 or newer on the server side, |
| 113 |
and abstract namespace sockets are not supported.)</para></listitem> |
| 114 |
|
| 115 |
<listitem><para>A Varlink service reference starting with the <literal>ssh-exec:</literal> string, |
| 116 |
followed by an SSH host specification, followed by <literal>:</literal>, followed by a command line. In |
| 117 |
this case, the command is invoked and the Varlink protocol is spoken on the standard input and output of |
| 118 |
the invoked command.</para></listitem> |
| 119 |
</itemizedlist> |
| 120 |
|
| 121 |
<para>For convenience, these two simpler (redundant) service address syntaxes are also supported:</para> |
| 122 |
|
| 123 |
<itemizedlist> |
| 124 |
<listitem><para>A file system path to an <constant>AF_UNIX</constant> socket, either absolute |
| 125 |
(i.e. begins with <literal>/</literal>) or relative (in which case it must begin with |
| 126 |
<literal>./</literal>).</para></listitem> |
| 127 |
|
| 128 |
<listitem><para>A file system path to an executable, either absolute or relative (as above, must begin |
| 129 |
with <literal>/</literal> or <literal>./</literal>, respectively).</para></listitem> |
| 130 |
</itemizedlist> |
| 131 |
</refsect1> |
| 132 |
|
| 133 |
<refsect1> |
| 134 |
<title>Commands</title> |
| 135 |
|
| 136 |
<para>The following commands are understood:</para> |
| 137 |
|
| 138 |
<variablelist> |
| 139 |
<varlistentry> |
| 140 |
<term><command>info</command> <replaceable>ADDRESS</replaceable></term> |
| 141 |
|
| 142 |
<listitem><para>Shows brief information about the specified service, including vendor name and list of |
| 143 |
implemented interfaces. Expects a service address in one of the formats described above.</para> |
| 144 |
|
| 145 |
<xi:include href="version-info.xml" xpointer="v255"/></listitem> |
| 146 |
</varlistentry> |
| 147 |
|
| 148 |
<varlistentry> |
| 149 |
<term><command>list-interfaces</command> <replaceable>ADDRESS</replaceable></term> |
| 150 |
|
| 151 |
<listitem><para>Shows a list of interfaces implemented by the specified service. Expects a service |
| 152 |
address in one of the formats described above.</para> |
| 153 |
|
| 154 |
<xi:include href="version-info.xml" xpointer="v255"/></listitem> |
| 155 |
</varlistentry> |
| 156 |
|
| 157 |
<varlistentry> |
| 158 |
<term><command>list-methods</command> <replaceable>ADDRESS</replaceable> [<replaceable>INTERFACE…</replaceable>]</term> |
| 159 |
|
| 160 |
<listitem><para>Shows a list of methods implemented by the specified service. Expects a service address |
| 161 |
in one of the formats described above as well as one or more interface names. If no interface name is |
| 162 |
specified, lists all methods of all interfaces implemented by the service, otherwise just the methods |
| 163 |
in the specified interfaces.</para> |
| 164 |
|
| 165 |
<xi:include href="version-info.xml" xpointer="v257"/></listitem> |
| 166 |
</varlistentry> |
| 167 |
|
| 168 |
<varlistentry> |
| 169 |
<term><command>introspect</command> <replaceable>ADDRESS</replaceable> [<replaceable>INTERFACE…</replaceable>]</term> |
| 170 |
|
| 171 |
<listitem><para>Shows the interface definitions of the specified interfaces provided by the specified |
| 172 |
service. Expects a service address in one of the formats described above and optionally one or more |
| 173 |
Varlink interface names. If no interface names are specified, shows all provided interfaces by the |
| 174 |
service.</para> |
| 175 |
|
| 176 |
<xi:include href="version-info.xml" xpointer="v255"/></listitem> |
| 177 |
</varlistentry> |
| 178 |
|
| 179 |
<varlistentry> |
| 180 |
<term><command>call</command> <replaceable>ADDRESS</replaceable> <replaceable>METHOD</replaceable> [<replaceable>ARGUMENTS</replaceable>]</term> |
| 181 |
|
| 182 |
<listitem><para>Calls the specified method of the specified service. Expects a service address in the |
| 183 |
format described above, a fully qualified Varlink method name, and a JSON arguments object. If the |
| 184 |
arguments object is not specified, it is read from STDIN instead. To pass an empty list of |
| 185 |
parameters, specify the empty object <literal>{}</literal>.</para> |
| 186 |
|
| 187 |
<para>The reply parameters are written as JSON objects to STDOUT.</para> |
| 188 |
|
| 189 |
<xi:include href="version-info.xml" xpointer="v255"/></listitem> |
| 190 |
</varlistentry> |
| 191 |
|
| 192 |
<varlistentry> |
| 193 |
<term><command>serve</command> <replaceable>METHOD</replaceable> <replaceable>CMDLINE…</replaceable></term> |
| 194 |
|
| 195 |
<listitem><para>Run a Varlink server that accepts protocol upgrade requests for the specified method |
| 196 |
and connects the upgraded connection to the standard input and output of the specified command. This |
| 197 |
can act as a server-side counterpart to <command>call</command> <option>--upgrade</option>.</para> |
| 198 |
|
| 199 |
<para>The listening socket must be passed via socket activation (i.e. the |
| 200 |
<varname>$LISTEN_FDS</varname> protocol), making this command suitable for use in socket-activated |
| 201 |
service units. When a client calls the specified method with the upgrade flag, the server sends a |
| 202 |
reply confirming the upgrade, then forks and executes the given command line with the upgraded |
| 203 |
connection on its standard input and output.</para> |
| 204 |
|
| 205 |
<para>This effectively turns any command that speaks a protocol over standard input/output into a |
| 206 |
Varlink service, discoverable via the service registry and authenticated via socket credentials. |
| 207 |
Because each connection is handled by a forked child process, the service unit can apply systemd's |
| 208 |
sandboxing options (such as <varname>ProtectSystem=</varname>, etc.) and does not operate in the |
| 209 |
caller's environment.</para> |
| 210 |
|
| 211 |
<xi:include href="version-info.xml" xpointer="v261"/></listitem> |
| 212 |
</varlistentry> |
| 213 |
|
| 214 |
<varlistentry> |
| 215 |
<term><command>list-registry</command></term> |
| 216 |
|
| 217 |
<listitem><para>Shows a list of Varlink services currently registered in the service registry, plus |
| 218 |
their entrypoint sockets. (Currently, this simply enumerates the sockets and symlinked sockets in |
| 219 |
<filename>/run/varlink/registry/</filename>, see below.)</para> |
| 220 |
|
| 221 |
<xi:include href="version-info.xml" xpointer="v260"/></listitem> |
| 222 |
</varlistentry> |
| 223 |
|
| 224 |
<varlistentry> |
| 225 |
<term><command>validate-idl</command> [<replaceable>FILE</replaceable>]</term> |
| 226 |
|
| 227 |
<listitem><para>Reads a Varlink interface definition file, parses and validates it, then outputs it |
| 228 |
with syntax highlighting. This checks for syntax and internal consistency of the interface. Expects a |
| 229 |
file name to read the interface definition from. If omitted, reads the interface definition from |
| 230 |
STDIN.</para> |
| 231 |
|
| 232 |
<xi:include href="version-info.xml" xpointer="v255"/></listitem> |
| 233 |
</varlistentry> |
| 234 |
|
| 235 |
<varlistentry> |
| 236 |
<term><command>help</command></term> |
| 237 |
|
| 238 |
<listitem><para>Shows command syntax help.</para> |
| 239 |
|
| 240 |
<xi:include href="version-info.xml" xpointer="v255"/></listitem> |
| 241 |
</varlistentry> |
| 242 |
</variablelist> |
| 243 |
</refsect1> |
| 244 |
|
| 245 |
<refsect1> |
| 246 |
<title>Options</title> |
| 247 |
|
| 248 |
<para>The following options are understood:</para> |
| 249 |
|
| 250 |
<variablelist> |
| 251 |
<varlistentry> |
| 252 |
<term><option>--more</option></term> |
| 253 |
|
| 254 |
<listitem><para>When used with <command>call</command>: expect multiple method replies. If this flag |
| 255 |
is set, the method call is sent with the <constant>more</constant> flag set, which tells the service |
| 256 |
to generate multiple replies, if needed. The command remains running until the service sends a reply |
| 257 |
message that indicates it is the last in the series (or if the configured timeout is reached, see |
| 258 |
below). This flag should be set only for method calls that support this mechanism.</para> |
| 259 |
|
| 260 |
<para>If this mode is enabled, output is automatically switched to JSON-SEQ mode, so that individual |
| 261 |
reply objects can be easily discerned.</para> |
| 262 |
|
| 263 |
<para>This switch has no effect on the method call timeout applied by default. Regardless of |
| 264 |
whether <option>--more</option> is specified or not, the default timeout will be 45s. Use |
| 265 |
<option>--timeout=</option> (see below) to change or disable the timeout. When invoking a method |
| 266 |
call that continuously returns updates, it is typically desirable to disable the timeout with |
| 267 |
<option>--timeout=infinity</option>. On the other hand, when invoking a <option>--more</option> |
| 268 |
method call for the purpose of enumerating objects (which likely will complete quickly), it is |
| 269 |
typically beneficial to leave the timeout logic enabled, for robustness reasons.</para> |
| 270 |
|
| 271 |
<xi:include href="version-info.xml" xpointer="v255"/></listitem> |
| 272 |
</varlistentry> |
| 273 |
|
| 274 |
<varlistentry> |
| 275 |
<term><option>-E</option></term> |
| 276 |
|
| 277 |
<listitem><para>A shortcut for <option>--more --timeout=infinity</option>. This switch is |
| 278 |
useful for method calls that implement subscription to a continuous stream of updates.</para> |
| 279 |
|
| 280 |
<xi:include href="version-info.xml" xpointer="v257"/></listitem> |
| 281 |
</varlistentry> |
| 282 |
|
| 283 |
<varlistentry> |
| 284 |
<term><option>--collect</option></term> |
| 285 |
|
| 286 |
<listitem><para>This is similar to <option>--more</option>, but collects all responses in a JSON |
| 287 |
array, and prints it, rather than in JSON-SEQ mode.</para> |
| 288 |
|
| 289 |
<xi:include href="version-info.xml" xpointer="v256"/></listitem> |
| 290 |
</varlistentry> |
| 291 |
|
| 292 |
<varlistentry> |
| 293 |
<term><option>--oneway</option></term> |
| 294 |
|
| 295 |
<listitem><para>When used with <command>call</command>: do not expect a method reply. If this flag |
| 296 |
is set, the method call is sent with the <constant>oneway</constant> flag set (the command exits |
| 297 |
immediately after), which tells the service not to generate a reply.</para> |
| 298 |
|
| 299 |
<xi:include href="version-info.xml" xpointer="v255"/></listitem> |
| 300 |
</varlistentry> |
| 301 |
|
| 302 |
<varlistentry> |
| 303 |
<term><option>--upgrade</option></term> |
| 304 |
|
| 305 |
<listitem><para>When used with <command>call</command>: request a protocol upgrade. The method call |
| 306 |
is sent with the <constant>upgrade</constant> flag set. The service is expected to send a single |
| 307 |
reply confirming the upgrade. After the reply, the Varlink protocol is no longer in effect on |
| 308 |
the connection.</para> |
| 309 |
|
| 310 |
<para>If <option>--exec</option> is not specified, <command>varlinkctl</command> acts as a |
| 311 |
bidirectional proxy: data read from standard input is forwarded to the upgraded connection, and data |
| 312 |
received from the connection is written to standard output.</para> |
| 313 |
|
| 314 |
<para>If <option>--exec</option> is specified, the upgraded connection socket is placed on both |
| 315 |
standard input and standard output of the invoked process. This is similar to the regular |
| 316 |
<option>--exec</option> behavior (without <option>--upgrade</option>), which places the method call |
| 317 |
reply on standard input. The invoked process can thus simply read from and write to |
| 318 |
stdin/stdout to communicate over the upgraded protocol.</para> |
| 319 |
|
| 320 |
<para>This option may not be combined with <option>--more</option>, <option>--oneway</option>, |
| 321 |
<option>--collect</option>, <option>--graceful=</option>, or <option>--push-fd=</option>.</para> |
| 322 |
|
| 323 |
<xi:include href="version-info.xml" xpointer="v261"/></listitem> |
| 324 |
</varlistentry> |
| 325 |
|
| 326 |
<varlistentry> |
| 327 |
<term><option>--json=<replaceable>MODE</replaceable></option></term> |
| 328 |
|
| 329 |
<listitem> |
| 330 |
<para>Selects the JSON output formatting, either <literal>pretty</literal> for nicely indented, |
| 331 |
colorized output, or <literal>short</literal> for terse output with minimal whitespace and no |
| 332 |
newlines. Defaults to <literal>short</literal>.</para> |
| 333 |
|
| 334 |
<xi:include href="version-info.xml" xpointer="v255"/> |
| 335 |
</listitem> |
| 336 |
</varlistentry> |
| 337 |
|
| 338 |
<varlistentry> |
| 339 |
<term><option>-j</option></term> |
| 340 |
|
| 341 |
<listitem> |
| 342 |
<para>Equivalent to <option>--json=pretty</option> when invoked interactively from a terminal. Otherwise, |
| 343 |
it is equivalent to <option>--json=short</option>, in particular when the output is piped to some other |
| 344 |
program.</para> |
| 345 |
|
| 346 |
<xi:include href="version-info.xml" xpointer="v255"/> |
| 347 |
</listitem> |
| 348 |
</varlistentry> |
| 349 |
|
| 350 |
<varlistentry> |
| 351 |
<term><option>--quiet</option></term> |
| 352 |
<term><option>-q</option></term> |
| 353 |
|
| 354 |
<listitem> |
| 355 |
<para>Suppress output of method call replies.</para> |
| 356 |
|
| 357 |
<xi:include href="version-info.xml" xpointer="v257"/> |
| 358 |
</listitem> |
| 359 |
</varlistentry> |
| 360 |
|
| 361 |
<varlistentry> |
| 362 |
<term><option>--graceful=</option></term> |
| 363 |
|
| 364 |
<listitem> |
| 365 |
<para>Takes a qualified Varlink error name, i.e. an interface name, suffixed by an error name, |
| 366 |
separated by a dot, e.g. <literal>org.varlink.service.InvalidParameter</literal>. Ensures that, if |
| 367 |
a method call fails with the specified error, this will be treated as success, i.e. will cause the |
| 368 |
<command>varlinkctl</command> invocation to exit with a zero exit status. This option may be used more |
| 369 |
than once in order to treat multiple different errors as successes.</para> |
| 370 |
|
| 371 |
<xi:include href="version-info.xml" xpointer="v257"/> |
| 372 |
</listitem> |
| 373 |
</varlistentry> |
| 374 |
|
| 375 |
<varlistentry> |
| 376 |
<term><option>--timeout=</option></term> |
| 377 |
|
| 378 |
<listitem> |
| 379 |
<para>Expects a timeout in seconds as parameter. By default, a timeout of 45s is enforced. To turn |
| 380 |
off the timeout, specify <literal>infinity</literal> or an empty string.</para> |
| 381 |
|
| 382 |
<xi:include href="version-info.xml" xpointer="v257"/> |
| 383 |
</listitem> |
| 384 |
</varlistentry> |
| 385 |
|
| 386 |
<varlistentry> |
| 387 |
<term><option>--exec</option></term> |
| 388 |
|
| 389 |
<listitem> |
| 390 |
<para>Once the method call issued via <command>call</command> completed successfully, chainload the |
| 391 |
specified command line, with the method call output parameters serialized to JSON passed into |
| 392 |
standard input (and standard output and standard error inherited from the invoking |
| 393 |
process). Moreover any file descriptors passed back on the underlying communication socket are |
| 394 |
passed to the invoked process via the usual <varname>$LISTEN_FDS</varname> protocol. This |
| 395 |
functionality may be used to consume replies that come with associated file descriptors in a |
| 396 |
reasonable way.</para> |
| 397 |
|
| 398 |
<para>Now that if <option>--exec</option> is specified the the third parameter to |
| 399 |
<command>call</command> is not optional (i.e. the method call parameters).</para> |
| 400 |
|
| 401 |
<xi:include href="version-info.xml" xpointer="v258"/> |
| 402 |
</listitem> |
| 403 |
</varlistentry> |
| 404 |
|
| 405 |
<varlistentry> |
| 406 |
<term><option>--push-fd=</option></term> |
| 407 |
|
| 408 |
<listitem> |
| 409 |
<para>Takes a numeric file descriptor number as parameter. May be used to pass a file |
| 410 |
descriptor along with the method call, if the underlying transport supports this. May be used |
| 411 |
multiple times to pass multiple file descriptors, retaining the order in which they are |
| 412 |
specified. The specified file descriptors must be passed to the <command>varlinkctl</command> |
| 413 |
invocation. Optionally, in place of a numeric file descriptor number an absolute or relative file |
| 414 |
system path (the latter must be prefixed with <literal>./</literal>) may be specified, which is |
| 415 |
opened in read-only mode.</para> |
| 416 |
|
| 417 |
<xi:include href="version-info.xml" xpointer="v258"/> |
| 418 |
</listitem> |
| 419 |
</varlistentry> |
| 420 |
|
| 421 |
<varlistentry> |
| 422 |
<term><option>--system</option></term> |
| 423 |
<term><option>--user</option></term> |
| 424 |
|
| 425 |
<listitem> |
| 426 |
<para>Determines whether to query to the per-system or per-user registry when using the |
| 427 |
<command>list-registry</command> command. By default, the per-system registry is queried.</para> |
| 428 |
</listitem> |
| 429 |
|
| 430 |
<xi:include href="version-info.xml" xpointer="v260"/> |
| 431 |
</varlistentry> |
| 432 |
|
| 433 |
<xi:include href="standard-options.xml" xpointer="no-ask-password" /> |
| 434 |
<xi:include href="standard-options.xml" xpointer="no-pager" /> |
| 435 |
<xi:include href="standard-options.xml" xpointer="help" /> |
| 436 |
<xi:include href="standard-options.xml" xpointer="version" /> |
| 437 |
</variablelist> |
| 438 |
</refsect1> |
| 439 |
|
| 440 |
<refsect1> |
| 441 |
<title>Files & Directories</title> |
| 442 |
|
| 443 |
<variablelist> |
| 444 |
<varlistentry> |
| 445 |
<term><filename>/run/varlink/registry/</filename></term> |
| 446 |
|
| 447 |
<listitem> |
| 448 |
<para>Directory containing <constant>AF_UNIX</constant> entrypoint socket inodes (or symlinks to |
| 449 |
them) of well-known, public Varlink interfaces on the local system. They are named after the |
| 450 |
Varlink interface they implement.</para> |
| 451 |
|
| 452 |
<para>Use <command>varlinkctl list-registry</command> to show the contents of this |
| 453 |
directory.</para> |
| 454 |
|
| 455 |
<para>(Inodes that neither qualify as socket inodes nor as symlinks to them shall be ignored. A |
| 456 |
future extension might introduce regular files and directories to enhance the registry |
| 457 |
functionality.)</para> |
| 458 |
|
| 459 |
<xi:include href="version-info.xml" xpointer="v260"/> |
| 460 |
</listitem> |
| 461 |
</varlistentry> |
| 462 |
</variablelist> |
| 463 |
</refsect1> |
| 464 |
|
| 465 |
<refsect1> |
| 466 |
<title>Examples</title> |
| 467 |
|
| 468 |
<example> |
| 469 |
<title>Investigating a Service</title> |
| 470 |
|
| 471 |
<para>The following three commands inspect the <literal>io.systemd.Resolve</literal> service |
| 472 |
implemented by |
| 473 |
<citerefentry><refentrytitle>systemd-resolved.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>, |
| 474 |
listing general service information and implemented interfaces, and then displaying the interface |
| 475 |
definition of its primary interface:</para> |
| 476 |
|
| 477 |
<programlisting>$ varlinkctl info /run/systemd/resolve/io.systemd.Resolve |
| 478 |
Vendor: The systemd Project |
| 479 |
Product: systemd (systemd-resolved) |
| 480 |
Version: 254 (254-1522-g4790521^) |
| 481 |
URL: https://systemd.io/ |
| 482 |
Interfaces: io.systemd |
| 483 |
io.systemd.Resolve |
| 484 |
org.varlink.service |
| 485 |
$ varlinkctl list-interfaces /run/systemd/resolve/io.systemd.Resolve |
| 486 |
io.systemd |
| 487 |
io.systemd.Resolve |
| 488 |
org.varlink.service |
| 489 |
$ varlinkctl introspect /run/systemd/resolve/io.systemd.Resolve io.systemd.Resolve |
| 490 |
interface io.systemd.Resolve |
| 491 |
type ResolvedAddress( |
| 492 |
ifindex: ?int, |
| 493 |
…</programlisting> |
| 494 |
|
| 495 |
<para>(Interface definition has been truncated in the example above, in the interest of brevity.)</para> |
| 496 |
</example> |
| 497 |
|
| 498 |
<example> |
| 499 |
<title>Invoking a Method</title> |
| 500 |
|
| 501 |
<para>The following command resolves a hostname via |
| 502 |
<citerefentry><refentrytitle>systemd-resolved.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>'s |
| 503 |
<function>ResolveHostname</function> method call.</para> |
| 504 |
|
| 505 |
<programlisting>$ varlinkctl call /run/systemd/resolve/io.systemd.Resolve io.systemd.Resolve.ResolveHostname '{"name":"systemd.io","family":2}' -j |
| 506 |
{ |
| 507 |
"addresses" : [ |
| 508 |
{ |
| 509 |
"ifindex" : 2, |
| 510 |
"family" : 2, |
| 511 |
"address" : [ |
| 512 |
185, |
| 513 |
199, |
| 514 |
111, |
| 515 |
153 |
| 516 |
] |
| 517 |
} |
| 518 |
], |
| 519 |
"name" : "systemd.io", |
| 520 |
"flags" : 1048577 |
| 521 |
}</programlisting> |
| 522 |
</example> |
| 523 |
|
| 524 |
<example> |
| 525 |
<title>Investigating a Service Executable</title> |
| 526 |
|
| 527 |
<para>The following command inspects the <filename>/usr/lib/systemd/systemd-pcrextend</filename> |
| 528 |
executable and the IPC APIs it provides. It then invokes a method on it:</para> |
| 529 |
|
| 530 |
<programlisting># varlinkctl info /usr/lib/systemd/systemd-pcrextend |
| 531 |
Vendor: The systemd Project |
| 532 |
Product: systemd (systemd-pcrextend) |
| 533 |
Version: 254 (254-1536-g97734fb) |
| 534 |
URL: https://systemd.io/ |
| 535 |
Interfaces: io.systemd |
| 536 |
io.systemd.PCRExtend |
| 537 |
org.varlink.service |
| 538 |
# varlinkctl introspect /usr/lib/systemd/systemd-pcrextend io.systemd.PCRExtend |
| 539 |
interface io.systemd.PCRExtend |
| 540 |
|
| 541 |
method Extend( |
| 542 |
pcr: int, |
| 543 |
text: ?string, |
| 544 |
data: ?string |
| 545 |
) -> () |
| 546 |
# varlinkctl call /usr/lib/systemd/systemd-pcrextend io.systemd.PCRExtend.Extend '{"pcr":15,"text":"foobar"}' |
| 547 |
{}</programlisting> |
| 548 |
</example> |
| 549 |
|
| 550 |
<example> |
| 551 |
<title>Invoking a method remotely via SSH</title> |
| 552 |
|
| 553 |
<para>The following command acquires a report about the identity of a remote host |
| 554 |
<literal>somehost</literal> from |
| 555 |
<citerefentry><refentrytitle>systemd-hostnamed.service</refentrytitle><manvolnum>8</manvolnum></citerefentry> |
| 556 |
by connecting via SSH to the <constant>AF_UNIX</constant> socket the service listens on:</para> |
| 557 |
|
| 558 |
<programlisting># varlinkctl call ssh-unix:somehost:/run/systemd/io.systemd.Hostname io.systemd.Hostname.Describe '{}'</programlisting> |
| 559 |
|
| 560 |
<para>To invoke a Varlink service binary directly on the remote host, rather than talking to a service |
| 561 |
via <constant>AF_UNIX</constant> can be done like this:</para> |
| 562 |
|
| 563 |
<programlisting># varlinkctl call ssh-exec:somehost:systemd-creds org.varlink.service.GetInfo '{}'</programlisting> |
| 564 |
</example> |
| 565 |
|
| 566 |
<example> |
| 567 |
<title>Serving a Sandboxed Decompressor via Protocol Upgrade</title> |
| 568 |
|
| 569 |
<para>The following socket and service units expose <command>xz</command> decompression as a Varlink |
| 570 |
service. Clients connect and send compressed data over the upgraded connection, receiving decompressed |
| 571 |
output in return.</para> |
| 572 |
|
| 573 |
<programlisting># /etc/systemd/system/varlink-decompress-xz.socket |
| 574 |
[Socket] |
| 575 |
ListenStream=/run/varlink/registry/com.example.Decompress.XZ |
| 576 |
|
| 577 |
[Install] |
| 578 |
WantedBy=sockets.target |
| 579 |
|
| 580 |
# /etc/systemd/system/varlink-decompress-xz.service |
| 581 |
[Service] |
| 582 |
ExecStart=varlinkctl serve com.example.Decompress.XZ xz -d |
| 583 |
DynamicUser=yes |
| 584 |
PrivateNetwork=yes |
| 585 |
ProtectSystem=strict |
| 586 |
ProtectHome=yes |
| 587 |
NoNewPrivileges=yes |
| 588 |
SystemCallFilter=~@privileged @resources |
| 589 |
MemoryMax=256M</programlisting> |
| 590 |
|
| 591 |
<para>A client can then decompress data through this service:</para> |
| 592 |
|
| 593 |
<programlisting>$ echo "hello" | xz | varlinkctl call --upgrade \ |
| 594 |
unix:/run/varlink/registry/com.example.Decompress.XZ \ |
| 595 |
com.example.Decompress.XZ '{}' |
| 596 |
hello</programlisting> |
| 597 |
|
| 598 |
<para>For quick testing without unit files, <command>systemd-socket-activate</command> can be used |
| 599 |
to provide the listening socket:</para> |
| 600 |
|
| 601 |
<programlisting>$ systemd-socket-activate -l /tmp/decompress.sock -- varlinkctl serve com.example.Decompress.XZ xz -d & |
| 602 |
$ echo "hello" | xz | varlinkctl call --upgrade unix:/tmp/decompress.sock com.example.Decompress.XZ '{}' |
| 603 |
hello</programlisting> |
| 604 |
</example> |
| 605 |
|
| 606 |
</refsect1> |
| 607 |
|
| 608 |
<refsect1> |
| 609 |
<title>See Also</title> |
| 610 |
|
| 611 |
<para><simplelist type="inline"> |
| 612 |
<member><citerefentry><refentrytitle>busctl</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 613 |
<member><ulink url="https://varlink.org/">Varlink</ulink></member> |
| 614 |
</simplelist></para> |
| 615 |
</refsect1> |
| 616 |
</refentry> |