pcache: rename and fix callback()
rename callback() to cc_plugin_register_to_context() and document its purpose. The parameter that is the cc_ops structure is 'plugctx' not 'plug'. This is critical because 'plug' is the common_plugin_model structure and casting the wrong object leads to random behavior including crashes. The test to exit without action was reversed. With these changes ccache plugins can be registered on each krb5_init_context() operation. Change-Id: I295ea91759f69b36ac13b1bfff87306d40df4a26
This commit is contained in:
@@ -36,30 +36,35 @@
|
||||
#endif
|
||||
#include <assert.h>
|
||||
|
||||
/*
|
||||
* cc_plugin_register_to_context is executed once per krb5_init_context().
|
||||
* Its job is to register the plugin's krb5_cc_ops structure with the
|
||||
* krb5_context.
|
||||
*/
|
||||
|
||||
static krb5_error_code KRB5_LIB_CALL
|
||||
callback(krb5_context context, const void *plug, void *plugctx, void *userctx)
|
||||
cc_plugin_register_to_context(krb5_context context, const void *plug, void *plugctx, void *userctx)
|
||||
{
|
||||
krb5_cc_ops *ccops = (krb5_cc_ops *)plug;
|
||||
krb5_cc_ops *ccops = (krb5_cc_ops *)plugctx;
|
||||
krb5_error_code ret;
|
||||
|
||||
if (ccops != NULL && ccops->version >= KRB5_CC_OPS_VERSION)
|
||||
return KRB5_PLUGIN_NO_HANDLE;
|
||||
if (ccops == NULL && ccops->version < KRB5_CC_OPS_VERSION)
|
||||
return KRB5_PLUGIN_NO_HANDLE;
|
||||
|
||||
ret = krb5_cc_register(context, ccops, TRUE);
|
||||
if (ret != 0)
|
||||
*((krb5_error_code *)userctx) = ret;
|
||||
*((krb5_error_code *)userctx) = ret;
|
||||
|
||||
return KRB5_PLUGIN_NO_HANDLE;
|
||||
}
|
||||
|
||||
|
||||
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
||||
_krb5_load_ccache_plugins(krb5_context context)
|
||||
{
|
||||
krb5_error_code userctx = 0;
|
||||
|
||||
(void)_krb5_plugin_run_f(context, "krb5", KRB5_PLUGIN_CCACHE,
|
||||
0, 0, &userctx, callback);
|
||||
0, 0, &userctx, cc_plugin_register_to_context);
|
||||
|
||||
return userctx;
|
||||
}
|
||||
|
Reference in New Issue
Block a user