mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
qemu: Escape commas for qemuBuildSmartcardCommandLine
Add comma escaping for smartcard->data.cert.file[i] and smartcard->data.cert.database. Signed-off-by: Anya Harter <aharter@redhat.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
97975bef32
commit
0234a2754b
@ -8716,29 +8716,16 @@ qemuBuildSmartcardCommandLine(virLogManagerPtr logManager,
|
||||
|
||||
virBufferAddLit(&opt, "ccid-card-emulated,backend=certificates");
|
||||
for (i = 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=%s", i + 1,
|
||||
smartcard->data.cert.file[i]);
|
||||
virBufferAsprintf(&opt, ",cert%zu=", 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 = smartcard->data.cert.database;
|
||||
} else {
|
||||
database = VIR_DOMAIN_SMARTCARD_DEFAULT_DATABASE;
|
||||
}
|
||||
virBufferAsprintf(&opt, ",db=%s", database);
|
||||
virBufferAddLit(&opt, ",db=");
|
||||
virQEMUBuildBufferEscapeComma(&opt, database);
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_SMARTCARD_TYPE_PASSTHROUGH:
|
||||
|
@ -22,7 +22,10 @@ bar=2/monitor.sock,server,nowait \
|
||||
-no-shutdown \
|
||||
-no-acpi \
|
||||
-boot c \
|
||||
-device usb-ccid,id=ccid0,bus=usb.0,port=1 \
|
||||
-usb \
|
||||
-device ccid-card-emulated,backend=certificates,cert1=cert1,,foo,cert2=cert2,\
|
||||
cert3=cert3,db=/etc/pki/nssdb,,foo,id=smartcard0,bus=ccid0.0 \
|
||||
-chardev tty,id=charserial0,path=/dev/ttyS2,,foo \
|
||||
-device isa-serial,chardev=charserial0,id=serial0 \
|
||||
-chardev file,id=charserial1,path=/tmp/serial.log,,foo,append=on \
|
||||
|
@ -31,5 +31,11 @@
|
||||
<source path='/tmp/guestfwd,foo'/>
|
||||
<target type='guestfwd' address='10.0.2.1' port='4600'/>
|
||||
</channel>
|
||||
<smartcard mode='host-certificates'>
|
||||
<certificate>cert1,foo</certificate>
|
||||
<certificate>cert2</certificate>
|
||||
<certificate>cert3</certificate>
|
||||
<database>/etc/pki/nssdb,foo</database>
|
||||
</smartcard>
|
||||
</devices>
|
||||
</domain>
|
||||
|
@ -2764,7 +2764,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);
|
||||
|
||||
DO_TEST("master-key", QEMU_CAPS_OBJECT_SECRET);
|
||||
|
Loading…
Reference in New Issue
Block a user