svn rev #24277: trunk/src/lib/krb5/krb/

ghudson@MIT.EDU ghudson at MIT.EDU
Mon Aug 30 12:20:34 EDT 2010


http://src.mit.edu/fisheye/changelog/krb5/?cs=24277
Commit By: ghudson
Log Message:
ticket: 6763

Make relative plugin module paths be interpreted as relative to
LIBDIR/krb5/plugins.



Changed Files:
U   trunk/src/lib/krb5/krb/plugin.c
Modified: trunk/src/lib/krb5/krb/plugin.c
===================================================================
--- trunk/src/lib/krb5/krb/plugin.c	2010-08-29 22:53:39 UTC (rev 24276)
+++ trunk/src/lib/krb5/krb/plugin.c	2010-08-30 16:20:34 UTC (rev 24277)
@@ -132,6 +132,34 @@
     return 0;
 }
 
+/*
+ * Convert a possibly relative pathname for a shared object to an absolute
+ * path.  Non-absolute pathnames will be treated as relative to the system
+ * plugins directory.
+ */
+static krb5_error_code
+expand_relative_modpath(const char *modpath, char **full_modpath_out)
+{
+    char *fullpath;
+
+    *full_modpath_out = NULL;
+
+    /* XXX Unix-specific path handling for now. */
+    if (*modpath == '/') {
+        /* We already have an absolute path. */
+        fullpath = strdup(modpath);
+        if (fullpath == NULL)
+            return ENOMEM;
+    } else {
+        /* Append the relative path to the system plugins directory. */
+        if (asprintf(&fullpath, "%s/%s", LIBDIR "/krb5/plugins", modpath) < 0)
+            return ENOMEM;
+    }
+
+    *full_modpath_out = fullpath;
+    return 0;
+}
+
 /* Return true if value is found in list. */
 static krb5_boolean
 find_in_list(char **list, const char *value)
@@ -176,7 +204,8 @@
                     char **disable)
 {
     krb5_error_code ret;
-    char *modname = NULL, *modpath = NULL, *symname = NULL;
+    char *modname = NULL, *modpath = NULL, *full_modpath = NULL;
+    char *symname = NULL;
     struct plugin_file_handle *handle = NULL;
     void (*initvt_fn)();
 
@@ -184,6 +213,9 @@
     ret = parse_modstr(context, modstr, &modname, &modpath);
     if (ret != 0)
         goto cleanup;
+    ret = expand_relative_modpath(modpath, &full_modpath);
+    if (ret != 0)
+        goto cleanup;
     if (!module_enabled(modname, enable, disable))
         goto cleanup;
 
@@ -195,7 +227,7 @@
     }
 
     /* Open the plugin and resolve the initvt symbol. */
-    ret = krb5int_open_plugin(modpath, &handle, &context->err);
+    ret = krb5int_open_plugin(full_modpath, &handle, &context->err);
     if (ret != 0)
         goto cleanup;
     ret = krb5int_get_plugin_func(handle, symname, &initvt_fn, &context->err);
@@ -212,6 +244,7 @@
 cleanup:
     free(modname);
     free(modpath);
+    free(full_modpath);
     free(symname);
     if (handle != NULL)
         krb5int_close_plugin(handle);




More information about the cvs-krb5 mailing list