From nobody Thu Jul 3 19:29:47 2025 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1529344682160760.9618005682339; Mon, 18 Jun 2018 10:58:02 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AE6C3308625E; Mon, 18 Jun 2018 17:58:00 +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 6C8895C1B2; Mon, 18 Jun 2018 17:58:00 +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 12F3B3FCC1; Mon, 18 Jun 2018 17:58:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5IHvdNi027844 for ; Mon, 18 Jun 2018 13:57:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3280E111AF16; Mon, 18 Jun 2018 17:57:39 +0000 (UTC) Received: from dhcp-17-130.bos.redhat.com (dhcp-17-130.bos.redhat.com [10.18.17.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 16393111CA1D; Mon, 18 Jun 2018 17:57:39 +0000 (UTC) From: Anya Harter To: libvir-list@redhat.com Date: Mon, 18 Jun 2018 13:57:25 -0400 Message-Id: <37ed7844dedd9483eb213ec805f2aa976513885a.1529344085.git.aharter@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Anya Harter Subject: [libvirt] [PATCH 3/4] qemu: Escape commas for qemuBuildSmartcardCommandLine 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: , MIME-Version: 1.0 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 18 Jun 2018 17:58:01 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add comma escaping for smartcard->data.cert.file[i] and smartcard->data.cert.database. Signed-off-by: Anya Harter Reviewed-by: John Ferlan --- src/qemu/qemu_command.c | 21 ++++----------------- tests/qemuxml2argvdata/name-escape.args | 3 +++ tests/qemuxml2argvdata/name-escape.xml | 6 ++++++ tests/qemuxml2argvtest.c | 3 ++- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 40e8f8fccf..a9a5e200e9 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -8716,29 +8716,16 @@ qemuBuildSmartcardCommandLine(virLogManagerPtr logM= anager, =20 virBufferAddLit(&opt, "ccid-card-emulated,backend=3Dcertificates"); for (i =3D 0; i < VIR_DOMAIN_SMARTCARD_NUM_CERTIFICATES; i++) { - if (strchr(smartcard->data.cert.file[i], ',')) { - virBufferFreeAndReset(&opt); - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("invalid certificate name: %s"), - smartcard->data.cert.file[i]); - return -1; - } - virBufferAsprintf(&opt, ",cert%zu=3D%s", i + 1, - smartcard->data.cert.file[i]); + virBufferAsprintf(&opt, ",cert%zu=3D", i + 1); + virQEMUBuildBufferEscapeComma(&opt, smartcard->data.cert.file[= i]); } if (smartcard->data.cert.database) { - if (strchr(smartcard->data.cert.database, ',')) { - virBufferFreeAndReset(&opt); - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("invalid database name: %s"), - smartcard->data.cert.database); - return -1; - } database =3D smartcard->data.cert.database; } else { database =3D VIR_DOMAIN_SMARTCARD_DEFAULT_DATABASE; } - virBufferAsprintf(&opt, ",db=3D%s", database); + virBufferAddLit(&opt, ",db=3D"); + virQEMUBuildBufferEscapeComma(&opt, database); break; =20 case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH: diff --git a/tests/qemuxml2argvdata/name-escape.args b/tests/qemuxml2argvda= ta/name-escape.args index 35a13b2533..d3b908a7e6 100644 --- a/tests/qemuxml2argvdata/name-escape.args +++ b/tests/qemuxml2argvdata/name-escape.args @@ -22,7 +22,10 @@ bar=3D2/monitor.sock,server,nowait \ -no-shutdown \ -no-acpi \ -boot c \ +-device usb-ccid,id=3Dccid0,bus=3Dusb.0,port=3D1 \ -usb \ +-device ccid-card-emulated,backend=3Dcertificates,cert1=3Dcert1,,foo,cert2= =3Dcert2,\ +cert3=3Dcert3,db=3D/etc/pki/nssdb,,foo,id=3Dsmartcard0,bus=3Dccid0.0 \ -chardev tty,id=3Dcharserial0,path=3D/dev/ttyS2,,foo \ -device isa-serial,chardev=3Dcharserial0,id=3Dserial0 \ -chardev file,id=3Dcharserial1,path=3D/tmp/serial.log,,foo,append=3Don \ diff --git a/tests/qemuxml2argvdata/name-escape.xml b/tests/qemuxml2argvdat= a/name-escape.xml index 79c1b34458..9ca7be5968 100644 --- a/tests/qemuxml2argvdata/name-escape.xml +++ b/tests/qemuxml2argvdata/name-escape.xml @@ -31,5 +31,11 @@ + + cert1,foo + cert2 + cert3 + /etc/pki/nssdb,foo + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 3e02fa576c..7468537c68 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2762,7 +2762,8 @@ mymain(void) QEMU_CAPS_SPICE, QEMU_CAPS_SPICE_UNIX, QEMU_CAPS_DEVICE_ISA_SERIAL, - QEMU_CAPS_CHARDEV_FILE_APPEND); + QEMU_CAPS_CHARDEV_FILE_APPEND, + QEMU_CAPS_CCID_EMULATED); DO_TEST("debug-threads", QEMU_CAPS_NAME_DEBUG_THREADS); =20 DO_TEST("master-key", QEMU_CAPS_OBJECT_SECRET); --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list