diff options
author | Greg Hudson <ghudson@mit.edu> | 2011-08-07 01:17:16 +0000 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2011-08-07 01:17:16 +0000 |
commit | d394a0acf45448d46c3fad4cc84fdd0ad728ffb7 (patch) | |
tree | cbc21a6f8f7e5542f224f638ce1a5bf59a84e6ea /src/util/profile | |
parent | 62a276e55287a06d66373f02202ab39c7ba74c00 (diff) | |
download | krb5-d394a0acf45448d46c3fad4cc84fdd0ad728ffb7.tar.gz krb5-d394a0acf45448d46c3fad4cc84fdd0ad728ffb7.tar.xz krb5-d394a0acf45448d46c3fad4cc84fdd0ad728ffb7.zip |
Use portable path functions when loading plugins
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@25075 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/util/profile')
-rw-r--r-- | src/util/profile/prof_init.c | 27 |
1 files changed, 19 insertions, 8 deletions
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; } |