Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/openpam/dist/lib - dlopen(3) errors should be p...
details: https://anonhg.NetBSD.org/src/rev/eda748e906d9
branches: trunk
changeset: 784695:eda748e906d9
user: christos <christos%NetBSD.org@localhost>
date: Tue Feb 05 23:47:42 2013 +0000
description:
- dlopen(3) errors should be printed with dlerror(3) so we get the reason the
module link failed, instead of printing "Undefined error 0".
- don't print free'd variable on error, restructure so that we free at the
end and print the consistent name of the path dlopened.
diffstat:
external/bsd/openpam/dist/lib/openpam_dynamic.c | 49 +++++++++++++++---------
1 files changed, 30 insertions(+), 19 deletions(-)
diffs (100 lines):
diff -r fdf019f0ae99 -r eda748e906d9 external/bsd/openpam/dist/lib/openpam_dynamic.c
--- a/external/bsd/openpam/dist/lib/openpam_dynamic.c Tue Feb 05 23:42:21 2013 +0000
+++ b/external/bsd/openpam/dist/lib/openpam_dynamic.c Tue Feb 05 23:47:42 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: openpam_dynamic.c,v 1.4 2012/08/15 06:16:41 christos Exp $ */
+/* $NetBSD: openpam_dynamic.c,v 1.5 2013/02/05 23:47:42 christos Exp $ */
/*-
* Copyright (c) 2002-2003 Networks Associates Technology, Inc.
@@ -63,12 +63,14 @@
*/
static void *
-try_dlopen(const char *modfn)
+try_dlopen(const char *modfn, int *error)
{
-
- if (openpam_check_path_owner_perms(modfn) != 0)
- return (NULL);
- return (dlopen(modfn, RTLD_NOW));
+ if (openpam_check_path_owner_perms(modfn) != 0) {
+ *error = errno;
+ return NULL;
+ }
+ *error = 0;
+ return dlopen(modfn, RTLD_NOW);
}
/*
@@ -82,12 +84,13 @@
{
const pam_module_t *dlmodule;
pam_module_t *module;
- const char *prefix, *epath = path;
+ const char *prefix;
char *vpath;
void *dlh;
int i, serrno;
dlh = NULL;
+ module = NULL;
/* Prepend the standard prefix if not an absolute pathname. */
if (path[0] != '/')
@@ -98,16 +101,18 @@
/* try versioned module first, then unversioned module */
if (asprintf(&vpath, "%s/%s.%d", prefix, path, LIB_MAJ) < 0)
goto err;
- epath = vpath;
- if ((dlh = try_dlopen(vpath)) == NULL && errno == ENOENT) {
+ if ((dlh = try_dlopen(vpath, &serrno)) == NULL && errno == ENOENT) {
*strrchr(vpath, '.') = '\0';
- dlh = try_dlopen(vpath);
+ dlh = try_dlopen(vpath, &serrno);
}
- serrno = errno;
- FREE(vpath);
- errno = serrno;
- if (dlh == NULL)
- goto err;
+ if (dlh == NULL) {
+ if (serrno == 0)
+ goto dl_err;
+ else {
+ errno = serrno;
+ goto err;
+ }
+ }
if ((module = calloc((size_t)1, sizeof *module)) == NULL)
goto buf_err;
if ((module->path = strdup(path)) == NULL)
@@ -119,9 +124,10 @@
(pam_func_t)dlsym(dlh, pam_sm_func_name[i]);
if (module->func[i] == NULL)
openpam_log(PAM_LOG_DEBUG, "%s: %s(): %s",
- path, pam_sm_func_name[i], dlerror());
+ vpath, pam_sm_func_name[i], dlerror());
}
- return (module);
+ free(vpath);
+ return module;
buf_err:
serrno = errno;
if (dlh != NULL)
@@ -130,8 +136,13 @@
errno = serrno;
err:
openpam_log(errno == ENOENT ? PAM_LOG_DEBUG : PAM_LOG_ERROR, "%s: %s",
- epath, strerror(errno));
- return (NULL);
+ vpath, strerror(errno));
+ free(vpath);
+ return NULL;
+dl_err:
+ openpam_log(PAM_LOG_ERROR, "%s: %s", vpath, dlerror());
+ free(vpath);
+ return NULL;
}
/*
Home |
Main Index |
Thread Index |
Old Index