vmspawn-varlink: treat empty event subscription filter as catch-all
A client supplying "filter": [] previously matched no events at all, because filter is checked with strv_contains() — an unintuitive corner case. Treat an empty filter strv identically to a NULL filter (deliver all events) by freeing the empty strv before it lands in the subscription map. Brings the API closer to least-surprise. Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
This commit is contained in:
@@ -159,6 +159,10 @@ static int vl_method_subscribe_events(sd_varlink *link, sd_json_variant *paramet
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
/* Treat [] identically to null: deliver all events. */
|
||||
if (strv_isempty(filter))
|
||||
filter = strv_free(filter);
|
||||
|
||||
sd_varlink_ref(link);
|
||||
|
||||
r = hashmap_ensure_put(&ctx->subscribed, &varlink_subscriber_hash_ops, link, filter);
|
||||
|
||||
Reference in New Issue
Block a user