tree-wide: use JSON_ALLOW_EXTENSIONS when disptching at various places

If we want to allow method replies to be extended without this breaking
compat, then we should set this flag. Do so at various method call
replies hence.

Also do it when parsing user/group records, which are expressly
documented to be extensible, as well as the hibernate JSON record.
This commit is contained in:
Lennart Poettering 2024-01-05 12:39:28 +01:00
parent a617fd9047
commit f0e4244b2f
6 changed files with 8 additions and 8 deletions

View file

@ -192,7 +192,7 @@ static int get_efi_hibernate_location(EFIHibernateLocation **ret) {
if (!e)
return log_oom();
r = json_dispatch(v, dispatch_table, JSON_LOG, e);
r = json_dispatch(v, dispatch_table, JSON_LOG|JSON_ALLOW_EXTENSIONS, e);
if (r < 0)
return r;

View file

@ -113,7 +113,7 @@ static int check_netns_match(void) {
{},
};
r = json_dispatch(reply, dispatch_table, JSON_LOG, &id);
r = json_dispatch(reply, dispatch_table, JSON_LOG|JSON_ALLOW_EXTENSIONS, &id);
if (r < 0)
return r;

View file

@ -20,7 +20,7 @@
#include "strv.h"
#include "varlink.h"
static JsonDispatchFlags json_dispatch_flags = 0;
static JsonDispatchFlags json_dispatch_flags = JSON_ALLOW_EXTENSIONS;
static void setup_logging(void) {
log_parse_environment_variables();

View file

@ -230,7 +230,7 @@ int group_record_load(
if (r < 0)
return r;
r = json_dispatch(h->json, group_dispatch_table, json_flags, h);
r = json_dispatch(h->json, group_dispatch_table, json_flags | JSON_ALLOW_EXTENSIONS, h);
if (r < 0)
return r;

View file

@ -1625,7 +1625,7 @@ int user_record_load(UserRecord *h, JsonVariant *v, UserRecordLoadFlags load_fla
if (r < 0)
return r;
r = json_dispatch(h->json, user_dispatch_table, json_flags, h);
r = json_dispatch(h->json, user_dispatch_table, json_flags | JSON_ALLOW_EXTENSIONS, h);
if (r < 0)
return r;

View file

@ -199,7 +199,7 @@ static int userdb_on_query_reply(
assert_se(!iterator->found_user);
r = json_dispatch(parameters, dispatch_table, 0, &user_data);
r = json_dispatch(parameters, dispatch_table, JSON_ALLOW_EXTENSIONS, &user_data);
if (r < 0)
goto finish;
@ -256,7 +256,7 @@ static int userdb_on_query_reply(
assert_se(!iterator->found_group);
r = json_dispatch(parameters, dispatch_table, 0, &group_data);
r = json_dispatch(parameters, dispatch_table, JSON_ALLOW_EXTENSIONS, &group_data);
if (r < 0)
goto finish;
@ -309,7 +309,7 @@ static int userdb_on_query_reply(
assert(!iterator->found_user_name);
assert(!iterator->found_group_name);
r = json_dispatch(parameters, dispatch_table, 0, &membership_data);
r = json_dispatch(parameters, dispatch_table, JSON_ALLOW_EXTENSIONS, &membership_data);
if (r < 0)
goto finish;