Richard W.M. Jones
2018-Jun-14 10:25 UTC
[Libguestfs] lib: Convert all drive socket parameters to an absolute path
One interesting omission is that we don't allow sockets in the abstract namespace. The API won't let you pass these sockets because they contain a '\0' character in the middle of the string. Therefore this patch doesn't need to deal with those. However we should in future allow that, probably using the '@' character to stand in for the NUL byte, as is used in a few other places (eg. this is used by the ‘netstat’ program). Rich.
Richard W.M. Jones
2018-Jun-14 10:25 UTC
[Libguestfs] [PATCH] lib: Convert all drive socket parameters to an absolute path (RHBZ#1588451).
--- lib/drives.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/drives.c b/lib/drives.c index 82ef30093..7697f369a 100644 --- a/lib/drives.c +++ b/lib/drives.c @@ -28,6 +28,7 @@ #include <stdbool.h> #include <string.h> #include <unistd.h> +#include <limits.h> #include <netdb.h> #include <arpa/inet.h> #include <assert.h> @@ -645,7 +646,18 @@ parse_one_server (guestfs_h *g, const char *server, struct drive_server *ret) return -1; } ret->transport = drive_transport_unix; - ret->u.socket = safe_strdup (g, server+5); + + /* libvirt requires sockets to be specified as an absolute path + * (see RHBZ#1588451), and it's probably a good idea anyway to + * check the socket exists and convert it to an absolute path. + */ + ret->u.socket = realpath (server+5, NULL); + if (ret->u.socket == NULL) { + perrorf (g, _("realpath: could not convert ‘%s’ to an absolute path"), + server+5); + return -1; + } + ret->port = 0; return 0; } -- 2.16.2
Possibly Parallel Threads
- [PATCH v3] lib: libvirt: Convert all drive socket parameters to an absolute path (RHBZ#1588451).
- [PATCH v2] lib: Convert all drive socket parameters to an absolute path (RHBZ#1588451).
- [PATCH 0/2] Don't use snapshot=on
- [PATCH v2 0/2] lib: qemu: Memoize qemu feature detection.
- [PATCH v3] lib: libvirt: Convert all drive socket parameters to an absolute path (RHBZ#1588451).