krb5: reintroduce deprecated krb5_addlog_func()

krb5_addlog_func() is used by Samba to obtain Kerberos log messages
and place them into the Samba logs.

Providing a hook down to the heim_addlog_func() is less disruptive
than needing to call multiple different APIs as Samba compiles
both with an included copy of Heimdal and against a system
Heimdal (when not an AD DC).

This API was deprecated and stubbed out in March 2020 by ea90ca8 and was
previously stable until 0c86917 (which looks like it should have been part of
e44c680).

Despite the need for the extra argument, which we add a test for, Samba would
prefer to keep the krb5_addlog_func() facility, so this adds it back.

Signed-off-by: Andrew Bartlett abartlet@samba.org
This commit is contained in:
Luke Howard
2021-08-09 23:27:22 +10:00
parent d5b6869dc7
commit c953bc5e79

View File

@@ -45,17 +45,60 @@ krb5_initlog(krb5_context context,
return heim_initlog(context->hcontext, program, fac);
}
struct krb5_addlog_func_wrapper {
krb5_context context;
krb5_log_log_func_t log_func;
krb5_log_close_func_t close_func;
void *data;
};
static void HEIM_CALLCONV
krb5_addlog_func_wrapper_log(heim_context hcontext,
const char *prefix,
const char *msg,
void *data)
{
struct krb5_addlog_func_wrapper *w = data;
w->log_func(w->context,
prefix,
msg,
w->data);
}
static void HEIM_CALLCONV
krb5_addlog_func_wrapper_close(void *data)
{
struct krb5_addlog_func_wrapper *w = data;
w->close_func(w->data);
free(w);
}
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_addlog_func(krb5_context context,
krb5_log_facility *fac,
int min,
int max,
krb5_log_log_func_t log_func,
krb5_log_close_func_t close_func,
void *data)
KRB5_DEPRECATED_FUNCTION("Use X instead")
krb5_log_facility *fac,
int min,
int max,
krb5_log_log_func_t log_func,
krb5_log_close_func_t close_func,
void *data)
{
return ENOTSUP;
struct krb5_addlog_func_wrapper *w = NULL;
w = calloc(1, sizeof(*w));
if (w == NULL)
return krb5_enomem(context);
w->context = context;
w->log_func = log_func;
w->close_func = close_func;
w->data = data;
return heim_addlog_func(context->hcontext, fac, min, max,
krb5_addlog_func_wrapper_log,
krb5_addlog_func_wrapper_close,
w);
}
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL