Skip to content

Commit

Permalink
tree-wide: use JSON_ALLOW_EXTENSIONS when disptching at various places
Browse files Browse the repository at this point in the history
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.

(cherry picked from commit f0e4244)
  • Loading branch information
poettering authored and keszybz committed Jun 29, 2024
1 parent 35bfbbf commit efeb731
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/hibernate-resume/hibernate-resume-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,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;

Expand Down
2 changes: 1 addition & 1 deletion src/nss-resolve/nss-resolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/shared/group-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/shared/user-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions src/shared/userdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit efeb731

Please sign in to comment.