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

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