10 static HEIMDAL_MUTEX lsacc_mutex
= HEIMDAL_MUTEX_INITIALIZER
;
11 const krb5_cc_ops
* lsacc_ops
= NULL
;
13 static void *lsacc_handle
;
16 _krb5_mslsa_register_cc_ops(krb5_context context
, krb5_boolean override
)
18 const char *lib
= NULL
;
20 HEIMDAL_MUTEX_lock(&lsacc_mutex
);
22 HEIMDAL_MUTEX_unlock(&lsacc_mutex
);
24 krb5_clear_error_message(context
);
25 krb5_cc_register(context
, lsacc_ops
, override
);
31 lib
= krb5_config_get_string(context
, NULL
,
32 "libdefaults", "mslsa_library",
35 lib
= "%{LIBDIR}/mslsa_cc.dll";
40 if (_krb5_expand_path_tokens(context
, lib
, &explib
) == 0) {
41 lsacc_handle
= dlopen(explib
, RTLD_LAZY
|RTLD_LOCAL
);
46 if (lsacc_handle
== NULL
) {
47 HEIMDAL_MUTEX_unlock(&lsacc_mutex
);
49 krb5_set_error_message(context
, KRB5_CC_NOSUPP
,
50 N_("Failed to load MSLSA cache module %s", "file"),
52 return KRB5_CC_NOSUPP
;
56 krb5_error_code ret
= 0;
57 krb5_error_code (KRB5_CALLCONV
*lsacc_get_ops
)(const krb5_cc_ops
** ops
);
59 lsacc_get_ops
= (krb5_error_code (KRB5_CALLCONV
*)(const krb5_cc_ops
**))
60 dlsym(lsacc_handle
, "lsacc_get_ops");
63 ret
= (*lsacc_get_ops
)(&lsacc_ops
);
66 HEIMDAL_MUTEX_unlock(&lsacc_mutex
);
70 krb5_set_error_message(context
, KRB5_CC_NOSUPP
,
71 N_("LSA cache initialization failed (%d)",
73 dlclose(lsacc_handle
);
74 return KRB5_CC_NOSUPP
;
77 if (lsacc_get_ops
== NULL
) {
79 krb5_set_error_message(context
, KRB5_CC_NOSUPP
,
80 N_("Failed to find lsacc_get_ops"
81 "in %s: %s", "file, error"), lib
, dlerror());
82 dlclose(lsacc_handle
);
83 return KRB5_CC_NOSUPP
;
87 assert(lsacc_ops
!= NULL
);
90 return krb5_cc_register(context
, lsacc_ops
, override
);