Skip to content

Commit

Permalink
Fix PKCS11 module path search
Browse files Browse the repository at this point in the history
Commit c5c1183 switched the loading
of the PKCS#11 module from dlopen() to krb5int_open_plugin().  Because
krb5int_open_plugin() includes a stat() test, this change has the
unintended consequence of requiring the module name to be an absolute
or relative path to the library, not a filename within the dynamic
linker search path.

Within krb5int_open_plugin(), only stat() the filename on the
platforms which will use the file type.

[ghudson@mit.edu: adjusted conditionals to call stat() on Windows;
rewrote commit message]

ticket: 9067 (new)
tags: pullup
target_version: 1.20-next
  • Loading branch information
Sashan authored and greghudson committed Jun 29, 2022
1 parent 0b5e963 commit e134d9a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/util/support/plugins.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,10 @@ long KRB5_CALLCONV
krb5int_open_plugin (const char *filepath, struct plugin_file_handle **h, struct errinfo *ep)
{
long err = 0;
struct stat statbuf;
struct plugin_file_handle *htmp = NULL;
int got_plugin = 0;
#if defined(USE_CFBUNDLE) || defined(_WIN32)
struct stat statbuf;

if (!err) {
if (stat (filepath, &statbuf) < 0) {
Expand All @@ -201,18 +202,20 @@ krb5int_open_plugin (const char *filepath, struct plugin_file_handle **h, struct
filepath, strerror(err));
}
}
#endif

if (!err) {
htmp = calloc (1, sizeof (*htmp)); /* calloc initializes ptrs to NULL */
if (htmp == NULL) { err = ENOMEM; }
}

#if USE_DLOPEN
if (!err && ((statbuf.st_mode & S_IFMT) == S_IFREG
if (!err
#if USE_CFBUNDLE
|| (statbuf.st_mode & S_IFMT) == S_IFDIR
&& ((statbuf.st_mode & S_IFMT) == S_IFREG
|| (statbuf.st_mode & S_IFMT) == S_IFDIR)
#endif /* USE_CFBUNDLE */
)) {
) {
void *handle = NULL;

#if USE_CFBUNDLE
Expand Down

0 comments on commit e134d9a

Please sign in to comment.