Blame SOURCES/0006-vddk-If-relative-libdir-parameter-is-passed-make-it-.patch

fe7475
From 7aa9fbe2dc6ef46b4701f13584c88d657255bdbf Mon Sep 17 00:00:00 2001
fe7475
From: "Richard W.M. Jones" <rjones@redhat.com>
fe7475
Date: Wed, 25 Jul 2018 09:28:32 +0100
fe7475
Subject: [PATCH] vddk: If relative libdir parameter is passed, make it
fe7475
 absolute.
fe7475
fe7475
(cherry picked from commit 8838497c44d51f2c3ea12adad89fd836116af201)
fe7475
---
fe7475
 plugins/vddk/nbdkit-vddk-plugin.pod |  3 +--
fe7475
 plugins/vddk/vddk.c                 | 14 ++++++++++----
fe7475
 2 files changed, 11 insertions(+), 6 deletions(-)
fe7475
fe7475
diff --git a/plugins/vddk/nbdkit-vddk-plugin.pod b/plugins/vddk/nbdkit-vddk-plugin.pod
fe7475
index ba7806d..57a039f 100644
fe7475
--- a/plugins/vddk/nbdkit-vddk-plugin.pod
fe7475
+++ b/plugins/vddk/nbdkit-vddk-plugin.pod
fe7475
@@ -87,8 +87,7 @@ L</NOTES> below).
fe7475
 
fe7475
 =item B<libdir=PATHNAME>
fe7475
 
fe7475
-Optional.  This sets the path of the VMware VDDK distribution.  It
fe7475
-must be an absolute path.
fe7475
+Optional.  This sets the path of the VMware VDDK distribution.
fe7475
 
fe7475
 VDDK uses this to load its own plugins, if this path is unspecified or
fe7475
 wrong then VDDK will work with reduced functionality.
fe7475
diff --git a/plugins/vddk/vddk.c b/plugins/vddk/vddk.c
fe7475
index 67aaa61..a8216fc 100644
fe7475
--- a/plugins/vddk/vddk.c
fe7475
+++ b/plugins/vddk/vddk.c
fe7475
@@ -72,7 +72,7 @@ static int init_called = 0;                /* was InitEx called */
fe7475
 static char *config = NULL;                /* config */
fe7475
 static const char *cookie = NULL;          /* cookie */
fe7475
 static const char *filename = NULL;        /* file */
fe7475
-static const char *libdir = VDDK_LIBDIR;   /* libdir */
fe7475
+static char *libdir = NULL;                /* libdir */
fe7475
 static int nfc_host_port = 0;              /* nfchostport */
fe7475
 static char *password = NULL;              /* password */
fe7475
 static int port = 0;                       /* port */
fe7475
@@ -180,6 +180,7 @@ vddk_unload (void)
fe7475
   if (dl)
fe7475
     dlclose (dl);
fe7475
   free (config);
fe7475
+  free (libdir);
fe7475
   free (password);
fe7475
 }
fe7475
 
fe7475
@@ -205,7 +206,11 @@ vddk_config (const char *key, const char *value)
fe7475
     filename = value;
fe7475
   }
fe7475
   else if (strcmp (key, "libdir") == 0) {
fe7475
-    libdir = value;
fe7475
+    /* See FILENAMES AND PATHS in nbdkit-plugin(3). */
fe7475
+    free (libdir);
fe7475
+    libdir = nbdkit_realpath (value);
fe7475
+    if (!libdir)
fe7475
+      return -1;
fe7475
   }
fe7475
   else if (strcmp (key, "nfchostport") == 0) {
fe7475
     if (sscanf (value, "%d", &nfc_host_port) != 1) {
fe7475
@@ -296,12 +301,13 @@ vddk_config_complete (void)
fe7475
   /* Initialize VDDK library. */
fe7475
   DEBUG_CALL ("VixDiskLib_InitEx",
fe7475
               "%d, %d, &debug_fn, &error_fn, &error_fn, %s, %s",
fe7475
-              VDDK_MAJOR, VDDK_MINOR, libdir, config ? : "NULL");
fe7475
+              VDDK_MAJOR, VDDK_MINOR,
fe7475
+              libdir ? : VDDK_LIBDIR, config ? : "NULL");
fe7475
   err = VixDiskLib_InitEx (VDDK_MAJOR, VDDK_MINOR,
fe7475
                            &debug_function, /* log function */
fe7475
                            &error_function, /* warn function */
fe7475
                            &error_function, /* panic function */
fe7475
-                           libdir, config);
fe7475
+                           libdir ? : VDDK_LIBDIR, config);
fe7475
   if (err != VIX_OK) {
fe7475
     VDDK_ERROR (err, "VixDiskLib_InitEx");
fe7475
     exit (EXIT_FAILURE);
fe7475
-- 
fe7475
1.8.3.1
fe7475