From nobody Sun Feb 8 20:53:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 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=1614599428; cv=none; d=zohomail.com; s=zohoarc; b=iDNt6mdp1NYQDGuM+Zy8pFKuyf1vi99V/LBVFJfWXg/sAGp+F7ARg1cLstNlieXRLILfos+1k6WeB6mOZoQJEeMiN3Au9IC/QiEeHJ7D5gHz+beDyrOdClSA3RGBjys153WeM+SjvC4xnb049IsRWG40cdUBFZmxzTgM+kWUf8g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614599428; h=Content-Type:Content-Transfer-Encoding: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; bh=0BdeP9XXlDwnjEGT3FSI6Xs6Z8cFzgHR/Wr3HqCgcio=; b=LmTy8oxJHm5jTIEps1R+4cDc7gIs8XoRQCo06NVGl5GQsZaCWbzMJAa1xXn60I+MhpIyCgaKJjJNkNSAJqGlguw2I3mN6/R/PPbWgyObMNfe/laqOYwxop/OeRTmHOJTKO6K9H1Pue4jwYu3oImxoCyMotpp4UbNyj5aM+byoaQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1614599428952457.19884405246046; Mon, 1 Mar 2021 03:50:28 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-98-x4aYW9WoNNCowpJfakZr5g-1; Mon, 01 Mar 2021 06:50:23 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DDF4480197B; Mon, 1 Mar 2021 11:50:16 +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 B97D2608BA; Mon, 1 Mar 2021 11:50: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 84E3D57DFA; Mon, 1 Mar 2021 11:50:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 121Bo464026560 for ; Mon, 1 Mar 2021 06:50:04 -0500 Received: by smtp.corp.redhat.com (Postfix) id EE17160636; Mon, 1 Mar 2021 11:50:04 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.76]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7126650C0E for ; Mon, 1 Mar 2021 11:50:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614599425; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=0BdeP9XXlDwnjEGT3FSI6Xs6Z8cFzgHR/Wr3HqCgcio=; b=Wy3jp8f+bXNt/Wd7K8q9VktNx1wNGSE9166L4aK0aDojdgGmayYw98c9pzaqICyeN4CgXd NGS3wrBo/4J85UZrzLCIM9ELd25/UR8n3cA16fAjtAjX3FAs7QqlpH0ShWCeBj2I44W2rX vMYZc20ILx8lfGNju9xnh23muf9cSNM= X-MC-Unique: x4aYW9WoNNCowpJfakZr5g-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/4] qemu_shim: Always pre-create root dir Date: Mon, 1 Mar 2021 12:49:58 +0100 Message-Id: <20ad8828fb9e314a123d2632fc9060d1f52df9d9.1614599331.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This problem is reproducible only with secret driver. When starting a domain via virt-qemu-run and both secret and (nonexistent) root directory specified this is what happens: 1) virt-qemu-run opens "secret:///embed?root=3D$rootdir" connection, which results in the secret driver initialization (done in secretStateInitialize()). During this process, the driver creates it's own configDir (derived from $rootdir) including those parents which don't exists yet. This is all done with the mode S_IRWXU and thus results in the $rootdir being created with very restrictive mode (specifically, +x is missing for group and others). 2) now, virt-qemu-run-opens "qemu:///embed?root=3D$rootdir" and calls virDomainCreateXML(). This results in the master-key.aes being written somewhere under the $rootdir and telling qemu where to find it. But because the secret driver created $rootdir with too restrictive mode, qemu can't access the file (even though it knows the full path) and fails to start. It looks like the best solution is to pre-create the root directory before opening any connection (letting any driver initialize itself) and set its mode to something less restrictive. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1859873 Signed-off-by: Michal Privoznik --- src/qemu/qemu_shim.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_shim.c b/src/qemu/qemu_shim.c index 21a24abade..a08bdcac6a 100644 --- a/src/qemu/qemu_shim.c +++ b/src/qemu/qemu_shim.c @@ -213,11 +213,16 @@ int main(int argc, char **argv) } tmproot =3D true; =20 - if (chmod(root, 0755) < 0) { - g_printerr("%s: cannot chown temporary dir: %s\n", - argv[0], g_strerror(errno)); - goto cleanup; - } + } else if (g_mkdir_with_parents(root, 0755) < 0) { + g_printerr("%s: cannot create dir: %s\n", + argv[0], g_strerror(errno)); + goto cleanup; + } + + if (chmod(root, 0755) < 0) { + g_printerr("%s: cannot chmod temporary dir: %s\n", + argv[0], g_strerror(errno)); + goto cleanup; } =20 escaped =3D g_uri_escape_string(root, NULL, true); --=20 2.26.2