json: add json_dispatch_const_user_group_name()
authorLennart Poettering <lennart@poettering.net>
Mon, 30 Sep 2024 15:33:05 +0000 (17:33 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 1 Oct 2024 06:32:00 +0000 (08:32 +0200)
commit0376ef36a1ff3768ad0c833f215064e34b40b86c
treec99151a967ceb44d92e989ca55314d0bc44db30f
parent468c6265a27d6fc1f02377feb1eacd1af8d74a21
json: add json_dispatch_const_user_group_name()

This is the same as json_dispatch_user_group_name() but fills in the
string as "const char*" to the JSON field. Or in other words, it's what
sd_json_dispatch_const_string() is to sd_json_dispatch_string().

Note this drops the SD_JSON_STRICT flags from various dispatch tables
for these fields, and replaces this by SD_JSON_RELAX, i.e. the opposite
behaviour. As #34558 correctly suggests we should validate user names
in lookup functions using the lax rules, rather than the strict ones,
since clients not knowing the rules might ask us for arbitrary
resolution.

(SD_JSON_RELAX internally translates to valid_user_group_name() with the
VALID_USER_RELAX flag).

See: #34558
src/core/core-varlink.c
src/home/homed-varlink.c
src/libsystemd/sd-json/json-util.c
src/libsystemd/sd-json/json-util.h
src/machine/machined-varlink.c
src/nsresourced/nsresourcework.c
src/userdb/userwork.c