1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-27 01:55:22 +03:00

varlink: if $SYSTEMD_VARLINK_LISTEN is set to "-", listen on stdio

This commit is contained in:
Lennart Poettering 2024-04-25 10:57:56 +02:00
parent 4120151f7b
commit ab89c6d162
2 changed files with 10 additions and 4 deletions

View File

@ -686,7 +686,8 @@ Tools using the Varlink protocol (such as `varlinkctl`) or sd-bus (such as
* `$SYSTEMD_VARLINK_LISTEN` interpreted by some tools that provide a Varlink
service. Takes a file system path: if specified the tool will listen on an
`AF_UNIX` stream socket on the specified path in addition to whatever else it
would listen on.
would listen on. If set to "-" the tool will turn stdin/stdout into a Varlink
connection.
`systemd-mountfsd`:

View File

@ -3803,12 +3803,17 @@ int varlink_server_listen_auto(VarlinkServer *s) {
n++;
}
/* For debug purposes let's listen on an explicitly specified address */
/* Let's listen on an explicitly specified address */
const char *e = secure_getenv("SYSTEMD_VARLINK_LISTEN");
if (e) {
r = varlink_server_listen_address(s, e, FLAGS_SET(s->flags, VARLINK_SERVER_ROOT_ONLY) ? 0600 : 0666);
if (streq(e, "-"))
r = varlink_server_add_connection_stdio(s, /* ret= */ NULL);
else
r = varlink_server_listen_address(s, e, FLAGS_SET(s->flags, VARLINK_SERVER_ROOT_ONLY) ? 0600 : 0666);
if (r < 0)
return r;
n++;
}
return n;
@ -4258,7 +4263,7 @@ int varlink_invocation(VarlinkInvocationFlags flags) {
/* Returns true if this is a "pure" varlink server invocation, i.e. with one fd passed. */
const char *e = secure_getenv("SYSTEMD_VARLINK_LISTEN"); /* Permit a manual override for testing purposes */
const char *e = secure_getenv("SYSTEMD_VARLINK_LISTEN"); /* Permit an explicit override */
if (e)
return true;