From nobody Sun Feb 8 05:27:09 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; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1569247479; cv=none; d=zoho.com; s=zohoarc; b=ZrS+Gpv5RCFLY7ZfzL8hQ6k9WZup+XG/WNi/MvU7zCqFkbFLEf10LPSJLqn1oozy2Yey1oBkHMNjl/vQdrIJIw1MtlxX/KTlv/w0sjrUyajx8cyrzb9dYZXLL6kj69m+eJvHmn2Ov8SpCRx2FiGbc1huDrzQqbUMSL/vk9E+ifI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1569247479; 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=7eOBbc7cfepry5t5RMRuOTF7ofxlo2Y/RW+CE0y6lTA=; b=SsS+fqO4IIxAqZiLto922O1Y+AFWS9ukSSaqzv/mNq+/rf4KiuOC6NuzZCH7/SxUYN3AfNvPZZmFiorfHoEIABeaJ/a4Y6MgpwaH9/w9W8FW1xG/z6cUTdX2BbzGnWoDizbpxGmKywIl75d4JSX9Shwf6LBxG2QhXARvfLb9/aI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail 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 156924747994426.208607677785835; Mon, 23 Sep 2019 07:04:39 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8638E309BF09; Mon, 23 Sep 2019 14:04:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6140C1001B33; Mon, 23 Sep 2019 14:04:37 +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 2780C180B761; Mon, 23 Sep 2019 14:04:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8NE4Dlk006994 for ; Mon, 23 Sep 2019 10:04:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 23BFE5DC1B; Mon, 23 Sep 2019 14:04:13 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1C0BE5D9D5; Mon, 23 Sep 2019 14:04:13 +0000 (UTC) Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1572DC058CA4; Mon, 23 Sep 2019 14:04:12 +0000 (UTC) Received: by mail-qk1-f179.google.com with SMTP id h126so15472666qke.10; Mon, 23 Sep 2019 07:04:12 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c6:df05:2a1f:6ce3:83c3:51c0]) by smtp.gmail.com with ESMTPSA id o124sm5298435qke.66.2019.09.23.07.04.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2019 07:04:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1podIevalJ2Nak8MrrauaCfYMh4sJetVaAjzcP7z01M=; b=QVSune7v2XcqzuM4XX2Q7quujoRQKYeX+uqEo8Rvafxv1QBTgn0SFnLD20HCz7dvie 6LfxjRlJMZ3gQuM0wtbBHqmltxoTwDcEE64c3EFKxGe7kARcHxCUQHQZsuzbmuix3wr+ dj2naUL79sPNK+z3gU717EepFsniE8CjZShsPtgaVINWK9X32OyYnb4i4V03QxbyoKBC 62OeZHQ1sD/YJcCBeI5uB0k14/u7VdZbfGPaNInZ4b8Bn4aMAn+mV4B6/Co3PMB6WXek QwnGkmdBCujYWrJLyR/aSrOtnaODxCx5p7q5uwP9cq3QB1FDUH4NjN5MG/3iJVnVS8gY xWOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1podIevalJ2Nak8MrrauaCfYMh4sJetVaAjzcP7z01M=; b=ZwAawhNpi3L3YyYZLWqmIfkfbFE/4dqBEzh1z+KL8hlQoDsnUViGTJh1Kmo+kebYmB vCeTURTxTBwb+5zXB4nQ1oQpeXgjN5DJbFL4R520q8IvNUDFcB+yUA66sdHigwl3nkOp N+fjWuykbTva1b+RnwvzSAB/LQ6uW3legCaznes6WDokC5SKEOgFS3lBXGBSQEBfprf2 yY4UbcGK5zqQqLHesBUY/hiCmb8Y7MH6olg3ub2XytVhLdKKtopqkyI7P+c+dZmb1Q/J 21BdzHSM1NcIgF1cuWu6FE2wM/lQPEDc2HBQ622iqdcsyUhRStvl+51Y9w9MfL28ouVS 6mEA== X-Gm-Message-State: APjAAAXGqNHVs4TIJ7g3MXOgq14QOX+dSnF1RtTNgCwVzpSgA6CfpoF5 uCJAymxUgL3DrFGKwNzte4ToWWi+ X-Google-Smtp-Source: APXvYqxAvZPy32XTYPNYE8yNjDiQoQ86gr6pDcsi8ctM9Rb0WnmyHnKq/y/peHXIxxoMDIKGx166Og== X-Received: by 2002:a37:660c:: with SMTP id a12mr17364514qkc.70.1569247451097; Mon, 23 Sep 2019 07:04:11 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Mon, 23 Sep 2019 11:03:41 -0300 Message-Id: <20190923140343.1950-9-danielhb413@gmail.com> In-Reply-To: <20190923140343.1950-1-danielhb413@gmail.com> References: <20190923140343.1950-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 23 Sep 2019 14:04:12 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 23 Sep 2019 14:04:12 +0000 (UTC) for IP:'209.85.222.179' DOMAIN:'mail-qk1-f179.google.com' HELO:'mail-qk1-f179.google.com' FROM:'danielhb413@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.15 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS) 209.85.222.179 mail-qk1-f179.google.com 209.85.222.179 mail-qk1-f179.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza Subject: [libvirt] [PATCH 08/10] qemu_driver.c: use virConnectValidateURIPath() 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-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 23 Sep 2019 14:04:38 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The existing QEMU URI path validation considers that a privileged user can use a "/session" URI as well. Let's update virConnectValidateURIPath() to consider this usage, allowing us to use the function inside qemu_driver.c. Although the existing callers of virConnectValidateURIPath() didn't consider that a privileged user could connect with "/session", it is sensible to consider that this should be the case. thus no serious harm is done. Suggested-by: Cole Robinson Signed-off-by: Daniel Henrique Barboza --- src/driver.c | 3 ++- src/qemu/qemu_driver.c | 20 ++++---------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/driver.c b/src/driver.c index e627b0c1d7..f9c41383dc 100644 --- a/src/driver.c +++ b/src/driver.c @@ -276,7 +276,8 @@ virConnectValidateURIPath(const char *uriPath, bool privileged) { if (privileged) { - if (STRNEQ(uriPath, "/system")) { + if (STRNEQ(uriPath, "/system") && + STRNEQ(uriPath, "/session")) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected %s URI path '%s', try %s:///syste= m"), entityName, uriPath, entityName); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0753904472..05025e7251 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1295,22 +1295,10 @@ static virDrvOpenStatus qemuConnectOpen(virConnectP= tr conn, return VIR_DRV_OPEN_ERROR; } =20 - if (virQEMUDriverIsPrivileged(qemu_driver)) { - if (STRNEQ(conn->uri->path, "/system") && - STRNEQ(conn->uri->path, "/session")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected QEMU URI path '%s', try qemu:///s= ystem"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } - } else { - if (STRNEQ(conn->uri->path, "/session")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected QEMU URI path '%s', try qemu:///s= ession"), - conn->uri->path); - return VIR_DRV_OPEN_ERROR; - } - } + if (!virConnectValidateURIPath(conn->uri->path, + "QEMU", + virQEMUDriverIsPrivileged(qemu_driver))) + return VIR_DRV_OPEN_ERROR; =20 if (virConnectOpenEnsureACL(conn) < 0) return VIR_DRV_OPEN_ERROR; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list