[libvirt] [PATCH 0/2] fix VNC and Spice unix socket escaping

Pavel Hrdina (2): qemu: skip only ',' for VNC and Spice unix socket Revert "util: virqemu: introduce virQEMUBuildBufferEscape" src/libvirt_private.syms | 1 - src/qemu/qemu_command.c | 4 ++-- src/util/virqemu.c | 17 ----------------- src/util/virqemu.h | 1 - tests/qemuxml2argvdata/qemuxml2argv-name-escape.args | 4 ++-- 5 files changed, 4 insertions(+), 23 deletions(-) -- 2.13.0

Commit 824272cb28d attempted to fix escaping of characters in unix socket path but it was wrong. We need to escape only ',', there is no escape character for '='. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_command.c | 4 ++-- tests/qemuxml2argvdata/qemuxml2argv-name-escape.args | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 0f87809177..df85798ac3 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7927,7 +7927,7 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg, switch (glisten->type) { case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_SOCKET: virBufferAddLit(&opt, "unix:"); - virQEMUBuildBufferEscape(&opt, glisten->socket); + virQEMUBuildBufferEscapeComma(&opt, glisten->socket); break; case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS: @@ -8060,7 +8060,7 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, } virBufferAddLit(&opt, "unix,addr="); - virQEMUBuildBufferEscape(&opt, glisten->socket); + virQEMUBuildBufferEscapeComma(&opt, glisten->socket); virBufferAddLit(&opt, ","); hasInsecure = true; break; diff --git a/tests/qemuxml2argvdata/qemuxml2argv-name-escape.args b/tests/qemuxml2argvdata/qemuxml2argv-name-escape.args index ea13654bf1..d94ab76312 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-name-escape.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-name-escape.args @@ -20,7 +20,7 @@ bar=2/monitor.sock,server,nowait \ -no-acpi \ -boot c \ -usb \ --vnc 'unix:/tmp/lib/domain--1-foo\=1,,bar\=2/vnc.sock' \ --spice 'unix,addr=/tmp/lib/domain--1-foo\=1,,bar\=2/spice.sock' \ +-vnc unix:/tmp/lib/domain--1-foo=1,,bar=2/vnc.sock \ +-spice unix,addr=/tmp/lib/domain--1-foo=1,,bar=2/spice.sock \ -vga cirrus \ -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 -- 2.13.0

On 06/12/2017 05:51 AM, Pavel Hrdina wrote:
Commit 824272cb28d attempted to fix escaping of characters in unix socket path but it was wrong. We need to escape only ',', there is no escape character for '='.
You could have mentioned the bz again like the original commit did...
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_command.c | 4 ++-- tests/qemuxml2argvdata/qemuxml2argv-name-escape.args | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
Reviewed-by: John Ferlan <jferlan@redhat.com> John

This reverts commit 22b02f44920388534d3da65cc6f0a70714dcf075. --- src/libvirt_private.syms | 1 - src/util/virqemu.c | 17 ----------------- src/util/virqemu.h | 1 - 3 files changed, 19 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b6c828fc22..044510f091 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2422,7 +2422,6 @@ virProcessWait; # util/virqemu.h -virQEMUBuildBufferEscape; virQEMUBuildBufferEscapeComma; virQEMUBuildCommandLineJSON; virQEMUBuildCommandLineJSONArrayBitmap; diff --git a/src/util/virqemu.c b/src/util/virqemu.c index f10b356781..2e9e65f9ef 100644 --- a/src/util/virqemu.c +++ b/src/util/virqemu.c @@ -300,23 +300,6 @@ virQEMUBuildBufferEscapeComma(virBufferPtr buf, const char *str) /** - * virQEMUBuildBufferEscape: - * @buf: buffer to append the escaped string - * @str: the string to escape - * - * Some characters passed as values on the QEMU command line must be escaped. - * - * - ',' must by escaped by ',' - * - '=' must by escaped by '\' - */ -void -virQEMUBuildBufferEscape(virBufferPtr buf, const char *str) -{ - virBufferEscapeN(buf, "%s", str, ',', ",", '\\', "=", NULL); -} - - -/** * virQEMUBuildLuksOpts: * @buf: buffer to build the string into * @enc: pointer to encryption info diff --git a/src/util/virqemu.h b/src/util/virqemu.h index 10aeb67f4e..539d62ab14 100644 --- a/src/util/virqemu.h +++ b/src/util/virqemu.h @@ -50,7 +50,6 @@ char *virQEMUBuildObjectCommandlineFromJSON(const char *type, char *virQEMUBuildDriveCommandlineFromJSON(virJSONValuePtr src); void virQEMUBuildBufferEscapeComma(virBufferPtr buf, const char *str); -void virQEMUBuildBufferEscape(virBufferPtr buf, const char *str); void virQEMUBuildLuksOpts(virBufferPtr buf, virStorageEncryptionInfoDefPtr enc, const char *alias) -- 2.13.0

On 06/12/2017 05:51 AM, Pavel Hrdina wrote:
This reverts commit 22b02f44920388534d3da65cc6f0a70714dcf075. --- src/libvirt_private.syms | 1 - src/util/virqemu.c | 17 ----------------- src/util/virqemu.h | 1 - 3 files changed, 19 deletions(-)
me wonders if anyone will ever find/use virBufferEscapeN from 726403461b Reviewed-by: John Ferlan <jferlan@redhat.com> John

On Mon, 2017-06-12 at 11:51 +0200, Pavel Hrdina wrote:
Pavel Hrdina (2): qemu: skip only ',' for VNC and Spice unix socket Revert "util: virqemu: introduce virQEMUBuildBufferEscape"
src/libvirt_private.syms | 1 - src/qemu/qemu_command.c | 4 ++-- src/util/virqemu.c | 17 ----------------- src/util/virqemu.h | 1 - tests/qemuxml2argvdata/qemuxml2argv-name-escape.args | 4 ++-- 5 files changed, 4 insertions(+), 23 deletions(-)
Reviewed-by: Andrea Bolognani <abologna@redhat.com> -- Andrea Bolognani / Red Hat / Virtualization
participants (3)
-
Andrea Bolognani
-
John Ferlan
-
Pavel Hrdina