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

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