From nobody Mon Feb 9 21:37:07 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1562569759; cv=none; d=zoho.com; s=zohoarc; b=ocyZwmYPlnLITyu1wzE7wNZjCjxlm1cMPX9kBAcdadG+6IsR5qXe5hBPs2GeXNyhUWRnnI2VU6QB2O+RN6cYkpDAF6O/ngvgLi/R+x+o9OKEdmdACtlyo+A9ixAMDMleOEiGL5DAjG/OK3kCQ1S9or0PWshcE7P1zGP2BdEsbLA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562569759; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=KDgrbS3A60xz3DreGets4ub9mvFLEPHIcn1okU31j8A=; b=IZhfOBBAi6Bo8Zl/VN8semhDK19Zyg1Bcu5x/vBxNeby8+z6Tj+UKONFq+TTCnHpGkZoAbYmHKxMQo9kT1Yu+uPpH762c21Ywe2DtK6aMI7M/F+/oHnltUhnUGUdLdFddTFy+gLx4ZHLrw9Zs13bauoGwplVES6qk2Wnt4lvAxk= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 156256975915820.026088119864767; Mon, 8 Jul 2019 00:09:19 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 212F310F6F; Mon, 8 Jul 2019 07:09:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ED98D5DA34; Mon, 8 Jul 2019 07:09:16 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id ABCA9C59A; Mon, 8 Jul 2019 07:09:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6878Oup006601 for ; Mon, 8 Jul 2019 03:08:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4E08739C5; Mon, 8 Jul 2019 07:08:24 +0000 (UTC) Received: from localhost (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC2422FC41; Mon, 8 Jul 2019 07:08:18 +0000 (UTC) From: marcandre.lureau@redhat.com To: libvir-list@redhat.com Date: Mon, 8 Jul 2019 11:07:26 +0400 Message-Id: <20190708070747.1962-3-marcandre.lureau@redhat.com> In-Reply-To: <20190708070747.1962-1-marcandre.lureau@redhat.com> References: <20190708070747.1962-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [libvirt] [PATCH 02/23] dbus: correctly build reply message X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 08 Jul 2019 07:09:17 +0000 (UTC) From: Marc-Andr=C3=A9 Lureau dbus_message_new() does not construct correct replies by itself, it is recommended to use dbus_message_new_method_return() instead. Signed-off-by: Marc-Andr=C3=A9 Lureau --- src/util/virdbus.c | 18 ++++++++++++------ src/util/virdbus.h | 6 ++++-- tests/virfirewalltest.c | 9 ++++++--- tests/virpolkittest.c | 3 ++- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/util/virdbus.c b/src/util/virdbus.c index b0ac8d7055..64513eef14 100644 --- a/src/util/virdbus.c +++ b/src/util/virdbus.c @@ -1456,6 +1456,7 @@ int virDBusCreateMethod(DBusMessage **call, =20 /** * virDBusCreateReplyV: + * @msg: the message to reply to * @reply: pointer to be filled with a method reply message * @types: type signature for following method arguments * @args: method arguments @@ -1468,13 +1469,14 @@ int virDBusCreateMethod(DBusMessage **call, * as variadic args. See virDBusCreateMethodV for a * description of this parameter. */ -int virDBusCreateReplyV(DBusMessage **reply, +int virDBusCreateReplyV(DBusMessage *msg, + DBusMessage **reply, const char *types, va_list args) { int ret =3D -1; =20 - if (!(*reply =3D dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN))) { + if (!(*reply =3D dbus_message_new_method_return(msg))) { virReportOOMError(); goto cleanup; } @@ -1493,6 +1495,7 @@ int virDBusCreateReplyV(DBusMessage **reply, =20 /** * virDBusCreateReply: + * @msg: the message to reply to * @reply: pointer to be filled with a method reply message * @types: type signature for following method arguments * @...: method arguments @@ -1500,14 +1503,15 @@ int virDBusCreateReplyV(DBusMessage **reply, * See virDBusCreateReplyV for a description of the * behaviour of this method. */ -int virDBusCreateReply(DBusMessage **reply, +int virDBusCreateReply(DBusMessage *msg, + DBusMessage **reply, const char *types, ...) { va_list args; int ret; =20 va_start(args, types); - ret =3D virDBusCreateReplyV(reply, types, args); + ret =3D virDBusCreateReplyV(msg, reply, types, args); va_end(args); =20 return ret; @@ -1811,7 +1815,8 @@ int virDBusCreateMethodV(DBusMessage **call ATTRIBUTE= _UNUSED, return -1; } =20 -int virDBusCreateReplyV(DBusMessage **reply ATTRIBUTE_UNUSED, +int virDBusCreateReplyV(DBusMessage *msg ATTRIBUTE_UNUSED, + DBusMessage **reply ATTRIBUTE_UNUSED, const char *types ATTRIBUTE_UNUSED, va_list args ATTRIBUTE_UNUSED) { @@ -1820,7 +1825,8 @@ int virDBusCreateReplyV(DBusMessage **reply ATTRIBUTE= _UNUSED, return -1; } =20 -int virDBusCreateReply(DBusMessage **reply ATTRIBUTE_UNUSED, +int virDBusCreateReply(DBusMessage *msg ATTRIBUTE_UNUSED, + DBusMessage **reply ATTRIBUTE_UNUSED, const char *types ATTRIBUTE_UNUSED, ...) { virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/util/virdbus.h b/src/util/virdbus.h index 083c074d59..0303e91045 100644 --- a/src/util/virdbus.h +++ b/src/util/virdbus.h @@ -52,9 +52,11 @@ int virDBusCreateMethodV(DBusMessage **call, const char *member, const char *types, va_list args); -int virDBusCreateReply(DBusMessage **reply, +int virDBusCreateReply(DBusMessage *msg, + DBusMessage **reply, const char *types, ...); -int virDBusCreateReplyV(DBusMessage **reply, +int virDBusCreateReplyV(DBusMessage *msg, + DBusMessage **reply, const char *types, va_list args); =20 diff --git a/tests/virfirewalltest.c b/tests/virfirewalltest.c index 7c586877d3..d2c85a27cc 100644 --- a/tests/virfirewalltest.c +++ b/tests/virfirewalltest.c @@ -150,7 +150,8 @@ VIR_MOCK_WRAP_RET_ARGS(dbus_connection_send_with_reply_= and_block, if (nargs =3D=3D 1 && STREQ(type, "ipv4") && STREQ(args[0], "-L")) { - if (virDBusCreateReply(&reply, + if (virDBusCreateReply(message, + &reply, "s", TEST_FILTER_TABLE_LIST) < 0) goto error; } else if (nargs =3D=3D 3 && @@ -158,11 +159,13 @@ VIR_MOCK_WRAP_RET_ARGS(dbus_connection_send_with_repl= y_and_block, STREQ(args[0], "-t") && STREQ(args[1], "nat") && STREQ(args[2], "-L")) { - if (virDBusCreateReply(&reply, + if (virDBusCreateReply(message, + &reply, "s", TEST_NAT_TABLE_LIST) < 0) goto error; } else { - if (virDBusCreateReply(&reply, + if (virDBusCreateReply(message, + &reply, "s", "success") < 0) goto error; } diff --git a/tests/virpolkittest.c b/tests/virpolkittest.c index 94a6daae0c..598eca8803 100644 --- a/tests/virpolkittest.c +++ b/tests/virpolkittest.c @@ -123,7 +123,8 @@ VIR_MOCK_WRAP_RET_ARGS(dbus_connection_send_with_reply_= and_block, VIR_FREE(cancellationId); virStringListFreeCount(details, detailslen); =20 - if (virDBusCreateReply(&reply, + if (virDBusCreateReply(message, + &reply, "(bba&{ss})", is_authorized, is_challenge, --=20 2.22.0.214.g8dca754b1e -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list