From nobody Fri Dec 19 04:23:34 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1613760384; cv=none; d=zohomail.com; s=zohoarc; b=e/O0/L4AwYiNkjI/eyHYpZE9UI1T+ZIxumPeNhd4j2I3N8OoWq01FaryAU0mBxb4OLbjTXv71zGhwWJUjUPXHKQuIRDllp/hbC/b/Pd913RNu0CyvOLAQv6Jpnu/1fq2bWFRw6nYfoB7v7jP7jaZ/KRCN1o3q9Wdy370lZFDzQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613760384; 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; bh=BtXOAq6it1BcF5yzBIOic/BpRKe8WNEUHKw406Fxt4M=; b=HBnKmhSELfKWksdZjFmVzY1Kp/+KBI8HY//QTwty36iKZJPp8JeV7ZWMIvykpcnWKI+QsnpUCskznEXdKF4WBcjo7066y2IiM1z8xBcLIqv/lyLb8DesyDahmgIFjI3AEJA0ujCtpPmY4L5m0XpUkfKfS17+Dja9KRcZJV/xndk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 161376038436718.941318502562922; Fri, 19 Feb 2021 10:46:24 -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-277-zLlat72RNqe4Q2fjJfoTxQ-1; Fri, 19 Feb 2021 13:46:20 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 11841C293; Fri, 19 Feb 2021 18:46:14 +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 6A0D660C05; Fri, 19 Feb 2021 18:46:13 +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 D569B18095CB; Fri, 19 Feb 2021 18:46:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 11JIk8ge029380 for ; Fri, 19 Feb 2021 13:46:08 -0500 Received: by smtp.corp.redhat.com (Postfix) id BB09E1970A; Fri, 19 Feb 2021 18:46:08 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-112-33.ams2.redhat.com [10.36.112.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id B087019D9B; Fri, 19 Feb 2021 18:46:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613760383; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=BtXOAq6it1BcF5yzBIOic/BpRKe8WNEUHKw406Fxt4M=; b=S/lK7Hu3UEb+JEZbRiLkUAxafvIIxhzzsSRrLXIyYjnrgf0fjLRwUR3pFdlpZ3ME8pyz3/ GyS0Tjry4I19SbF0AIjcE8rxgVIPUKc32x8b6kgROAk6Lm5IjXA8TQutpUV8mM52/uLrp9 vwF2ndZZmBeWdDOzqEYLY+cOu96pF80= X-MC-Unique: zLlat72RNqe4Q2fjJfoTxQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH 1/4] ui: introduce "password-secret" option for VNC servers Date: Fri, 19 Feb 2021 18:45:53 +0000 Message-Id: <20210219184556.154972-2-berrange@redhat.com> In-Reply-To: <20210219184556.154972-1-berrange@redhat.com> References: <20210219184556.154972-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com, Gerd Hoffmann , "Dr. David Alan Gilbert" 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.12 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Currently when using VNC the "password" flag turns on password based authentication. The actual password has to be provided separately via the monitor. This introduces a "password-secret" option which lets the password be provided up front. $QEMU --object secret,id=3Dvncsec0,file=3Dpasswd.txt \ --vnc localhost:0,password-secret=3Dvncsec0 Signed-off-by: Daniel P. Berrang=C3=A9 --- qemu-options.hx | 5 +++++ ui/vnc.c | 23 ++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/qemu-options.hx b/qemu-options.hx index 6c34c7050f..893d0f500b 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -2164,6 +2164,11 @@ SRST time to allow password to expire immediately or never expire. =20 + ``password-secret=3D`` + Require that password based authentication is used for client + connections, using the password provided by the ``secret`` + object identified by ``secret-id``. + ``tls-creds=3DID`` Provides the ID of a set of TLS credentials to use to secure the VNC server. They will apply to both the normal VNC server socket diff --git a/ui/vnc.c b/ui/vnc.c index 16bb3be770..77e07ac351 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -48,6 +48,7 @@ #include "crypto/tlscredsanon.h" #include "crypto/tlscredsx509.h" #include "crypto/random.h" +#include "crypto/secret_common.h" #include "qom/object_interfaces.h" #include "qemu/cutils.h" #include "qemu/help_option.h" @@ -3469,6 +3470,9 @@ static QemuOptsList qemu_vnc_opts =3D { },{ .name =3D "password", .type =3D QEMU_OPT_BOOL, + },{ + .name =3D "password-secret", + .type =3D QEMU_OPT_STRING, },{ .name =3D "reverse", .type =3D QEMU_OPT_BOOL, @@ -3941,6 +3945,7 @@ void vnc_display_open(const char *id, Error **errp) int lock_key_sync =3D 1; int key_delay_ms; const char *audiodev; + const char *passwordSecret; =20 if (!vd) { error_setg(errp, "VNC display not active"); @@ -3958,7 +3963,23 @@ void vnc_display_open(const char *id, Error **errp) goto fail; } =20 - password =3D qemu_opt_get_bool(opts, "password", false); + + passwordSecret =3D qemu_opt_get(opts, "password-secret"); + if (passwordSecret) { + if (qemu_opt_get(opts, "password")) { + error_setg(errp, + "'password' flag is redundant with 'password-secret= '"); + goto fail; + } + vd->password =3D qcrypto_secret_lookup_as_utf8(passwordSecret, + errp); + if (!vd->password) { + goto fail; + } + password =3D true; + } else { + password =3D qemu_opt_get_bool(opts, "password", false); + } if (password) { if (fips_get_state()) { error_setg(errp, --=20 2.29.2