]> git.ipfire.org Git - thirdparty/systemd.git/commit
varlink,json: introduce new varlink_dispatch() helper
authorLennart Poettering <lennart@poettering.net>
Wed, 1 Nov 2023 17:36:12 +0000 (18:36 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 2 Nov 2023 01:19:21 +0000 (01:19 +0000)
commitf1b622a00ce614654fcdff309a2394cfae3b3a88
tree0c54e3da87805ec8c33da5276c3cb22e20652b5e
parentd0404391e5f87a892c2eaed3a89028281af34f6b
varlink,json: introduce new varlink_dispatch() helper

varlink_dispatch() is a simple wrapper around json_dispatch() that
returns clean, standards-compliant InvalidParameter error back to
clients, if the specified JSON cannot be parsed properly.

For this json_dispatch() is extended to return the offending field's
name. Because it already has quite a few parameters, I then renamed
json_dispatch() to json_dispatch_full() and made json_dispatch() a
wrapper around it that passes the new argument as NULL. While doing so I
figured we should also get rid of the bad= argument in the short
wrapper, since it's only used in the OCI code.

To simplify the OCI code this adds a second wrapper oci_dispatch()
around json_dispatch_full(), that fills in bad= the way we want.

Net result: instead of one json_dispatch() call there are now:

1. json_dispatch_full() for the fully feature mother of all dispathers.
2. json_dispatch() for the simpler version that you want to use most of
   the time.
3. varlink_dispatch() that generates nice Varlink errors
4. oci_dispatch() that does the OCI specific error handling

And that's all there is.
24 files changed:
src/core/core-varlink.c
src/fuzz/fuzz-bootspec.c
src/hibernate-resume/hibernate-resume-config.c
src/home/homed-varlink.c
src/machine/machined-varlink.c
src/nspawn/nspawn-oci.c
src/nss-resolve/nss-resolve.c
src/oom/oomd-manager.c
src/pcrextend/pcrextend.c
src/resolve/resolvectl.c
src/resolve/resolved-dns-rr.c
src/resolve/resolved-varlink.c
src/shared/group-record.c
src/shared/json.c
src/shared/json.h
src/shared/user-record.c
src/shared/userdb.c
src/shared/varlink-io.systemd.service.c
src/shared/varlink.c
src/shared/varlink.h
src/sysext/sysext.c
src/test/test-varlink.c
src/userdb/userwork.c
src/varlinkctl/varlinkctl.c