summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/krb5/krb/plugin.c32
-rw-r--r--src/util/profile/prof_init.c27
2 files changed, 21 insertions, 38 deletions
diff --git a/src/lib/krb5/krb/plugin.c b/src/lib/krb5/krb/plugin.c
index 6f164e0a68..de81f9df9a 100644
--- a/src/lib/krb5/krb/plugin.c
+++ b/src/lib/krb5/krb/plugin.c
@@ -132,35 +132,6 @@ parse_modstr(krb5_context context, const char *modstr,
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(krb5_context context, const char *modpath,
- char **full_modpath_out)
-{
- char *path;
-
- *full_modpath_out = NULL;
-
- /* XXX Unix-specific path handling for now. */
- if (*modpath == '/') {
- /* We already have an absolute path. */
- path = strdup(modpath);
- if (path == NULL)
- return ENOMEM;
- } else {
- /* Append the relative path to the system plugins directory. */
- if (asprintf(&path, "%s/%s", context->plugin_base_dir, modpath) < 0)
- return ENOMEM;
- }
-
- *full_modpath_out = path;
- return 0;
-}
-
/* Return true if value is found in list. */
static krb5_boolean
find_in_list(char **list, const char *value)
@@ -250,7 +221,8 @@ register_dyn_mapping(krb5_context context, struct plugin_interface *interface,
ret = parse_modstr(context, modstr, &modname, &modpath);
if (ret != 0)
goto cleanup;
- ret = expand_relative_modpath(context, modpath, &fullpath);
+ /* Treat non-absolute modpaths as relative to the plugin base directory. */
+ ret = k5_path_join(context->plugin_base_dir, modpath, &fullpath);
if (ret != 0)
goto cleanup;
if (!module_enabled(modname, enable, disable))
diff --git a/src/util/profile/prof_init.c b/src/util/profile/prof_init.c
index bbb7f88fd3..7dc5b470d6 100644
--- a/src/util/profile/prof_init.c
+++ b/src/util/profile/prof_init.c
@@ -66,27 +66,38 @@ init_module(struct profile_vtable *vtable, void *cbdata,
static errcode_t
parse_modspec(const char *modspec, char **ret_path, char **ret_residual)
{
- const char *p, *prefix;
- char *path, *residual;
+ const char *p;
+ char *path, *fullpath, *residual;
+ errcode_t ret;
*ret_path = *ret_residual = NULL;
- p = strchr(modspec, ':');
+ /* Find the separator, skipping a Windows drive letter if present. */
+ p = (*modspec != '\0' && modspec[1] == ':') ? modspec + 2 : modspec;
+ p = strchr(p, ':');
if (p == NULL)
return PROF_MODULE_SYNTAX;
- /* XXX Unix path handling for now. */
- prefix = (*modspec == '/') ? "" : LIBDIR "/";
- if (asprintf(&path, "%s%.*s", prefix, (int)(p - modspec), modspec) < 0)
+ /* Copy the path. */
+ path = malloc(p - modspec + 1);
+ if (path == NULL)
return ENOMEM;
+ memcpy(path, modspec, p - modspec);
+ path[p - modspec] = '\0';
+
+ /* Compose the path with LIBDIR if it's not absolute. */
+ ret = k5_path_join(LIBDIR, path, &fullpath);
+ free(path);
+ if (ret)
+ return ret;
residual = strdup(p + 1);
if (residual == NULL) {
- free(path);
+ free(fullpath);
return ENOMEM;
}
- *ret_path = path;
+ *ret_path = fullpath;
*ret_residual = residual;
return 0;
}