]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
userdb: Use json_dispatch_user_group_name() to parse GetMembership fields
authorSamuel Cabrero <scabrero@suse.de>
Fri, 10 Feb 2023 13:04:27 +0000 (14:04 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Fri, 10 Feb 2023 15:09:45 +0000 (15:09 +0000)
It allows to relax the checks and allow characters like '\', used by
windows to split the domain name and user name.

For reference, discussion in the systemd-devel mailing list:
https://lists.freedesktop.org/archives/systemd-devel/2023-February/048804.html

Signed-off-by: Samuel Cabrero <scabrero@suse.de>
src/shared/userdb.c

index aa55cc00ae453092db307d294554243b29382ab0..a77eff4407a49c7c12d316328d6d4749788619f3 100644 (file)
@@ -294,8 +294,8 @@ static int userdb_on_query_reply(
                 } membership_data = {};
 
                 static const JsonDispatch dispatch_table[] = {
-                        { "userName",  JSON_VARIANT_STRING, json_dispatch_const_string, offsetof(struct membership_data, user_name),  JSON_SAFE },
-                        { "groupName", JSON_VARIANT_STRING, json_dispatch_const_string, offsetof(struct membership_data, group_name), JSON_SAFE },
+                        { "userName",  JSON_VARIANT_STRING, json_dispatch_user_group_name, offsetof(struct membership_data, user_name),  JSON_RELAX },
+                        { "groupName", JSON_VARIANT_STRING, json_dispatch_user_group_name, offsetof(struct membership_data, group_name), JSON_RELAX },
                         {}
                 };