openpam_dynamic(): If the pathname provided is not an absolute pathname,

prepend PAM_SOPREFIX to the name before dlopen()'ing it.  On NetBSD, define
PAM_SOPREFIX as "/usr/lib/security/".
This commit is contained in:
thorpej 2005-01-03 17:21:48 +00:00
parent d3f6e9192f
commit a6336417c1
2 changed files with 14 additions and 2 deletions

View File

@ -303,7 +303,8 @@ DATA_SET(_openpam_static_modules, _pam_module)
#endif
#if defined(__NetBSD__)
# define PAM_SOEXT ".so"
# define PAM_SOEXT ".so"
# define PAM_SOPREFIX "/usr/lib/security/"
# if !defined(__GNUC__) || defined(NO_STATIC_MODULES)
# undef OPENPAM_STATIC_MODULE /* disable static module macros */
# undef OPENPAM_STATIC_MODULES /* disable static module support in libpam */
@ -323,6 +324,10 @@ __link_set_add_data(_openpam_static_modules, _pam_module)
# endif
#endif
#if !defined(PAM_SOPREFIX)
#define PAM_SOPREFIX ""
#endif
#if !defined(OPENPAM_STATIC_MODULE)
#define PAM_EXTERN /* nothing */
#define PAM_MODULE_ENTRY(name) /*LINTED empty decl*/

View File

@ -58,6 +58,7 @@ openpam_dynamic(const char *path)
{
pam_module_t *module;
char *vpath;
const char *prefix;
void *dlh;
int i;
@ -65,8 +66,14 @@ openpam_dynamic(const char *path)
if ((module = calloc((size_t)1, sizeof *module)) == NULL)
goto buf_err;
/* Prepend the standard prefix if not an absolute pathname. */
if (path[0] != '/')
prefix = PAM_SOPREFIX;
else
prefix = "";
/* try versioned module first, then unversioned module */
if (asprintf(&vpath, "%s.%d", path, LIB_MAJ) < 0)
if (asprintf(&vpath, "%s%s.%d", prefix, path, LIB_MAJ) < 0)
goto buf_err;
if ((dlh = dlopen(vpath, RTLD_NOW)) == NULL) {
openpam_log(PAM_LOG_DEBUG, "%s: %s", vpath, dlerror());