]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: fix type confusion around parsing JSON booleans
authorLennart Poettering <lennart@poettering.net>
Thu, 2 May 2024 13:25:34 +0000 (15:25 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 2 May 2024 17:31:08 +0000 (19:31 +0200)
Sometimes we store them in a tristate, sometimes in C stdbool booleans.
Sometimes we fucked up picking the right parsing function however. Fix
that.

src/nspawn/nspawn-oci.c
src/shared/user-record.c
src/sysext/sysext.c

index 5edc35665b8e8a7a86001bca02e6a67acfb12d3f..293a8d4023e6dcad2b912c55a46b3a380dc6e22f 100644 (file)
@@ -417,7 +417,7 @@ static int oci_process(const char *name, JsonVariant *v, JsonDispatchFlags flags
                 { "rlimits",         JSON_VARIANT_ARRAY,   oci_rlimits,           0,                                     0               },
                 { "apparmorProfile", JSON_VARIANT_STRING,  oci_unsupported,       0,                                     JSON_PERMISSIVE },
                 { "capabilities",    JSON_VARIANT_OBJECT,  oci_capabilities,      0,                                     0               },
-                { "noNewPrivileges", JSON_VARIANT_BOOLEAN, json_dispatch_boolean, offsetof(Settings, no_new_privileges), 0               },
+                { "noNewPrivileges", JSON_VARIANT_BOOLEAN, json_dispatch_tristate,offsetof(Settings, no_new_privileges), 0               },
                 { "oomScoreAdj",     JSON_VARIANT_INTEGER, oci_oom_score_adj,     0,                                     0               },
                 { "selinuxLabel",    JSON_VARIANT_STRING,  oci_unsupported,       0,                                     JSON_PERMISSIVE },
                 { "user",            JSON_VARIANT_OBJECT,  oci_user,              0,                                     0               },
@@ -433,7 +433,7 @@ static int oci_root(const char *name, JsonVariant *v, JsonDispatchFlags flags, v
 
         static const JsonDispatch table[] = {
                 { "path",     JSON_VARIANT_STRING,  json_dispatch_string,  offsetof(Settings, root)      },
-                { "readonly", JSON_VARIANT_BOOLEAN, json_dispatch_boolean, offsetof(Settings, read_only) },
+                { "readonly", JSON_VARIANT_BOOLEAN, json_dispatch_tristate,offsetof(Settings, read_only) },
                 {}
         };
 
index fe102b004a1cf2fb297b3d7377bd3564a90bf76e..ec084de4e0a62a20a32f42a2ff0b041d0649b07c 100644 (file)
@@ -1401,7 +1401,7 @@ static int dispatch_status(const char *name, JsonVariant *variant, JsonDispatchF
                 { "lastBadAuthenticationUSec",  _JSON_VARIANT_TYPE_INVALID, json_dispatch_uint64,           offsetof(UserRecord, last_bad_authentication_usec),  0         },
                 { "rateLimitBeginUSec",         _JSON_VARIANT_TYPE_INVALID, json_dispatch_uint64,           offsetof(UserRecord, ratelimit_begin_usec),          0         },
                 { "rateLimitCount",             _JSON_VARIANT_TYPE_INVALID, json_dispatch_uint64,           offsetof(UserRecord, ratelimit_count),               0         },
-                { "removable",                  JSON_VARIANT_BOOLEAN,       json_dispatch_boolean,          offsetof(UserRecord, removable),                     0         },
+                { "removable",                  JSON_VARIANT_BOOLEAN,       json_dispatch_tristate,         offsetof(UserRecord, removable),                     0         },
                 { "accessMode",                 JSON_VARIANT_UNSIGNED,      json_dispatch_access_mode,      offsetof(UserRecord, access_mode),                   0         },
                 { "fileSystemType",             JSON_VARIANT_STRING,        json_dispatch_string,           offsetof(UserRecord, file_system_type),              JSON_SAFE },
                 { "fallbackShell",              JSON_VARIANT_STRING,        json_dispatch_filename_or_path, offsetof(UserRecord, fallback_shell),                0         },
index 9248e67127f30940e2f273624c808caf4bd09b19..c55c24fdf333e9ec0535e71c9a835a598bf32e55 100644 (file)
@@ -1922,9 +1922,9 @@ static int parse_merge_parameters(Varlink *link, JsonVariant *parameters, Method
 
         static const JsonDispatch dispatch_table[] = {
                 { "class",    JSON_VARIANT_STRING,  json_dispatch_const_string, offsetof(MethodMergeParameters, class),     0 },
-                { "force",    JSON_VARIANT_BOOLEAN, json_dispatch_boolean,      offsetof(MethodMergeParameters, force),     0 },
-                { "noReload", JSON_VARIANT_BOOLEAN, json_dispatch_boolean,      offsetof(MethodMergeParameters, no_reload), 0 },
-                { "noexec",   JSON_VARIANT_BOOLEAN, json_dispatch_boolean,      offsetof(MethodMergeParameters, noexec),    0 },
+                { "force",    JSON_VARIANT_BOOLEAN, json_dispatch_tristate,     offsetof(MethodMergeParameters, force),     0 },
+                { "noReload", JSON_VARIANT_BOOLEAN, json_dispatch_tristate,     offsetof(MethodMergeParameters, no_reload), 0 },
+                { "noexec",   JSON_VARIANT_BOOLEAN, json_dispatch_tristate,     offsetof(MethodMergeParameters, noexec),    0 },
                 {}
         };