vhost-user-test: fix predictable filename on tmpfs

vhost-user-test uses getpid to create a unique filename. This name is
predictable, and a security problem.  Instead, use a tmp directory
created by mkdtemp, which is a suggested best practice.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
Michael S. Tsirkin 2015-10-01 15:50:52 +03:00
parent 1b7e1e3b46
commit 6fdac09370

View File

@ -330,7 +330,7 @@ int main(int argc, char **argv)
root = tmpfs; root = tmpfs;
} }
socket_path = g_strdup_printf("/tmp/vhost-%d.sock", getpid()); socket_path = g_strdup_printf("%s/vhost.sock", tmpfs);
/* create char dev and add read handlers */ /* create char dev and add read handlers */
qemu_add_opts(&qemu_chardev_opts); qemu_add_opts(&qemu_chardev_opts);