]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
varlink: in varlink_observe() correctly collect error parameters
authorLennart Poettering <lennart@poettering.net>
Wed, 17 Jan 2024 09:56:25 +0000 (10:56 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 17 Jan 2024 15:14:10 +0000 (16:14 +0100)
In varlink errors can have parameters (and they regularly do, for
example the io.systemd.System error we generate carries the errno in its
parameter), hence it's essential that varlink_oberserve collects that
properly and returns it too.

src/shared/varlink.c

index f9c7f2e659daa5dbdd984d58fe0f51b91be7dd9e..ce9cf736468099de9f55f5cac14d6b391c9abf96 100644 (file)
@@ -2285,6 +2285,10 @@ static int collect_callback(
         /* If we hit an error, we will drop all collected replies and just return the error_id and flags in varlink_collect() */
         if (error_id) {
                 context->error_id = error_id;
+
+                json_variant_unref(context->parameters);
+                context->parameters = json_variant_ref(parameters);
+
                 return 0;
         }
 
@@ -2337,6 +2341,8 @@ int varlink_collect(
 
                 /* If we get an error from any of the replies, return immediately with just the error_id and flags*/
                 if (context.error_id) {
+                        if (ret_parameters)
+                                *ret_parameters = TAKE_PTR(context.parameters);
                         if (ret_error_id)
                                 *ret_error_id = TAKE_PTR(context.error_id);
                         if (ret_flags)