varlink: also honour new env var $SYSTEMD_VARLINK_LISTEN in varlink_server_listen_auto()
varlink_server_listen_auto() is supposed to be the one-stop solution for turning simple command line tools into IPC services. They aren't easy to test/debug however, since you have to invoke them through a service manager. Let's make this easier: if the SYSTEMD_VARLINK_LISTEN env var is set, let's listen on the socket specified therein. This makes things easier to gdb: just run the service from the cmdline.
This commit is contained in:
@@ -3477,6 +3477,14 @@ int varlink_server_listen_auto(VarlinkServer *s) {
|
||||
n++;
|
||||
}
|
||||
|
||||
/* For debug purposes 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 (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
@@ -3922,6 +3930,10 @@ 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 */
|
||||
if (e)
|
||||
return true;
|
||||
|
||||
r = sd_listen_fds_with_names(/* unset_environment= */ false, &names);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
Reference in New Issue
Block a user