From nobody Mon Feb 9 16:45:14 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599190929; cv=none; d=zohomail.com; s=zohoarc; b=m7EdYZBqFLstPI3cezVSQWNQ5MegBcv4Ih0RCnGtgjPY/Hswue+kf76PHZeE1Vin7ftB2T6h82r789qoJxWXPBUy1mt7VnydV94QnuV6zryVp0lPeooOY1xadbmywkUXzhGBh+ZCCLr9JKaPvXsESZrPOUecxfc8+nOAyHx9rAA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599190929; 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=z2OP2WbAg1y9nYkKKuxr0LoCA5geWGNCWabxBKVY588=; b=gK+y9BIEW5R6YNK2Vi14rdYO0wGGh9jRyWWhxhlWmNUXvAGTBSZMrH7tC96e2VcJX0yjdkZsfZY4RLUflfHgT6QfuYyDUH9XjDFOdz+mWQGGlbtennT2dx/bzHkKNW+ztYwClCFfYhr7fkgAiiOud7pSQfLR5O9HUqwkJA9KpFE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1599190929837526.1800527996245; Thu, 3 Sep 2020 20:42:09 -0700 (PDT) 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-518-yvsVlXDoPh2DtW_k7ZrHVg-1; Thu, 03 Sep 2020 23:41:59 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 500A62FD05; Fri, 4 Sep 2020 03:41:52 +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 2D0335D9DC; Fri, 4 Sep 2020 03:41:52 +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 EBD74181A272; Fri, 4 Sep 2020 03:41:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0843fBbX030652 for ; Thu, 3 Sep 2020 23:41:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2456110379C; Fri, 4 Sep 2020 03:41:10 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 172691037B7 for ; Fri, 4 Sep 2020 03:41:07 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ABE2E800969 for ; Fri, 4 Sep 2020 03:41:07 +0000 (UTC) Received: from mail-m24147.qiye.163.com (mail-m24147.qiye.163.com [220.194.24.147]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-405-HzKyQSA6M92U--msd2zQDA-1; Thu, 03 Sep 2020 23:41:03 -0400 Received: from localhost.localdomain (unknown [58.56.27.130]) by smtp4 (Coremail) with SMTP id JedpCgAHcNgStlFfYHYgCg--.1426S27; Fri, 04 Sep 2020 11:35:55 +0800 (CST) X-MC-Unique: yvsVlXDoPh2DtW_k7ZrHVg-1 X-MC-Unique: HzKyQSA6M92U--msd2zQDA-1 From: Shi Lei To: libvir-list@redhat.com Subject: [RFCv2 25/46] conf: Replace virDomainGraphicsAuthDefParseXML(hardcoded) with namesake(generated) Date: Fri, 4 Sep 2020 11:35:17 +0800 Message-Id: <20200904033538.418579-26-shi_lei@massclouds.com> In-Reply-To: <20200904033538.418579-1-shi_lei@massclouds.com> References: <20200904033538.418579-1-shi_lei@massclouds.com> MIME-Version: 1.0 X-CM-TRANSID: JedpCgAHcNgStlFfYHYgCg--.1426S27 X-Coremail-Antispam: 1Uf129KBjvJXoWxWr48tw4fZrW3ZF17tFy7Jrb_yoWrtr17pa 13Zrs3ArWFqr43W3yv93Wq9wsF9F1kJr47Awn3uw4DAFyUGw4vyr1rJr1q934UKr95ZrW3 AFWSqa1YqF4vy37anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0piAnY3UUUUU= X-Originating-IP: [58.56.27.130] X-CM-SenderInfo: pvklsz1hl6ztxvvfz0xxgvhudrp/1tbiTxuVT1f4qM1mUgAAsw X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false; X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 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.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.003 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Shi Lei --- src/conf/domain_conf.c | 92 +++++------------------------------------- src/conf/domain_conf.h | 13 +++--- 2 files changed, 18 insertions(+), 87 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 544b984..1fd2a06 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -1788,17 +1788,6 @@ bool virDomainObjTaint(virDomainObjPtr obj, } =20 =20 -static void -virDomainGraphicsAuthDefClear(virDomainGraphicsAuthDefPtr def) -{ - if (!def) - return; - - VIR_FREE(def->passwd); - - /* Don't free def */ -} - static void virDomainGraphicsListenDefClear(virDomainGraphicsListenDefPtr def) { @@ -14129,75 +14118,6 @@ virDomainTimerDefParseXML(xmlNodePtr node, } =20 =20 -static int -virDomainGraphicsAuthDefParseXML(xmlNodePtr node, - virDomainGraphicsAuthDefPtr def, - int type) -{ - g_autofree char *validTo =3D NULL; - g_autofree char *connected =3D virXMLPropString(node, "connected"); - - def->passwd =3D virXMLPropString(node, "passwd"); - - if (!def->passwd) - return 0; - - validTo =3D virXMLPropString(node, "passwdValidTo"); - if (validTo) { - g_autoptr(GDateTime) then =3D NULL; - g_autoptr(GTimeZone) tz =3D g_time_zone_new_utc(); - char *tmp; - int year, mon, mday, hour, min, sec; - - /* Expect: YYYY-MM-DDTHH:MM:SS (%d-%d-%dT%d:%d:%d) eg 2010-11-28T= 14:29:01 */ - if (/* year */ - virStrToLong_i(validTo, &tmp, 10, &year) < 0 || *tmp !=3D '-' = || - /* month */ - virStrToLong_i(tmp+1, &tmp, 10, &mon) < 0 || *tmp !=3D '-' || - /* day */ - virStrToLong_i(tmp+1, &tmp, 10, &mday) < 0 || *tmp !=3D 'T' || - /* hour */ - virStrToLong_i(tmp+1, &tmp, 10, &hour) < 0 || *tmp !=3D ':' || - /* minute */ - virStrToLong_i(tmp+1, &tmp, 10, &min) < 0 || *tmp !=3D ':' || - /* second */ - virStrToLong_i(tmp+1, &tmp, 10, &sec) < 0 || *tmp !=3D '\0') { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot parse password validity time '%s', ex= pect YYYY-MM-DDTHH:MM:SS"), - validTo); - VIR_FREE(def->passwd); - return -1; - } - - then =3D g_date_time_new(tz, year, mon, mday, hour, min, sec); - def->validTo =3D (time_t)g_date_time_to_unix(then); - def->expires =3D true; - } - - if (connected) { - int action =3D virDomainGraphicsAuthConnectedTypeFromString(connec= ted); - if (action <=3D 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown connected value %s"), - connected); - return -1; - } - - /* VNC supports connected=3D'keep' only */ - if (type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_VNC && - action !=3D VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_KEEP) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("VNC supports connected=3D'keep' only")); - return -1; - } - - def->connected =3D action; - } - - return 0; -} - - /** * virDomainGraphicsListenDefParseXML: * @def: listen def pointer to be filled @@ -14506,9 +14426,17 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsD= efPtr def, def->data.vnc.keymap =3D virXMLPropString(node, "keymap"); =20 if (virDomainGraphicsAuthDefParseXML(node, &def->data.vnc.auth, - def->type) < 0) + NULL, def, NULL) < 0) return -1; =20 + /* VNC supports connected=3D'keep' only */ + if (def->data.vnc.auth.connected && + def->data.vnc.auth.connected !=3D VIR_DOMAIN_GRAPHICS_AUTH_CONNECT= ED_KEEP) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("VNC supports connected=3D'keep' only")); + return -1; + } + return 0; } =20 @@ -14644,7 +14572,7 @@ virDomainGraphicsDefParseXMLSpice(virDomainGraphics= DefPtr def, def->data.spice.keymap =3D virXMLPropString(node, "keymap"); =20 if (virDomainGraphicsAuthDefParseXML(node, &def->data.spice.auth, - def->type) < 0) + NULL, def, NULL) < 0) return -1; =20 cur =3D node->children; diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e64a284..616cbf4 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1573,11 +1573,14 @@ typedef enum { VIR_DOMAIN_GRAPHICS_AUTH_CONNECTED_LAST } virDomainGraphicsAuthConnectedType; =20 -struct _virDomainGraphicsAuthDef { - char *passwd; - bool expires; /* Whether there is an expiry time set */ - time_t validTo; /* seconds since epoch */ - int connected; /* action if connected */ +struct _virDomainGraphicsAuthDef { /* genparse */ + char *passwd; /* xmlattr */ + /* Whether there is an expiry time set */ + bool expires; + /* seconds since epoch */ + time_t validTo; /* xmlattr:passwdValidTo, specified:ex= pires */ + /* action if connected */ + virDomainGraphicsAuthConnectedType connected; /* xmlattr */ }; =20 typedef enum { --=20 2.25.1