Improve error messages by logging the full path of the module we tried

to load rather than just the module name.


git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@525 185d5e19-27fe-0310-9dcf-9bff6b9f3609
This commit is contained in:
Dag-Erling Smørgrav 2012-01-11 00:45:09 +00:00
parent c3d9f63b55
commit cf0963e668
1 changed files with 8 additions and 5 deletions

View File

@ -99,7 +99,7 @@ try_dlopen(const char *modfn)
return (dlh); return (dlh);
} }
#endif #endif
/* /*
* OpenPAM internal * OpenPAM internal
* *
@ -131,9 +131,6 @@ openpam_dynamic(const char *path)
*strrchr(vpath, '.') = '\0'; *strrchr(vpath, '.') = '\0';
dlh = try_dlopen(vpath); dlh = try_dlopen(vpath);
} }
serrno = errno;
FREE(vpath);
errno = serrno;
if (dlh == NULL) if (dlh == NULL)
goto err; goto err;
if ((module = calloc(1, sizeof *module)) == NULL) if ((module = calloc(1, sizeof *module)) == NULL)
@ -164,14 +161,20 @@ openpam_dynamic(const char *path)
#endif #endif
} }
} }
FREE(vpath);
return (module); return (module);
buf_err: buf_err:
serrno = errno;
if (dlh != NULL) if (dlh != NULL)
dlclose(dlh); dlclose(dlh);
FREE(module); FREE(module);
errno = serrno;
err: err:
serrno = errno;
if (errno != 0) if (errno != 0)
openpam_log(PAM_LOG_ERROR, "%s: %m", path); openpam_log(PAM_LOG_ERROR, "%s: %m", vpath);
FREE(vpath);
errno = serrno;
return (NULL); return (NULL);
} }