Add gssapi_krb5_clear_status, gssapi_krb5_set_status for handling error
messages. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@16157 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -112,27 +112,49 @@ supplementary_error(OM_uint32 v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gssapi_krb5_set_error_string (void)
|
gssapi_krb5_clear_status (void)
|
||||||
{
|
{
|
||||||
struct gssapi_thr_context *ctx = gssapi_get_thread_context(1);
|
struct gssapi_thr_context *ctx = gssapi_get_thread_context(1);
|
||||||
char *e;
|
|
||||||
|
|
||||||
if (ctx == NULL)
|
if (ctx == NULL)
|
||||||
return;
|
return;
|
||||||
HEIMDAL_MUTEX_lock(&ctx->mutex);
|
HEIMDAL_MUTEX_lock(&ctx->mutex);
|
||||||
if (ctx->error_string)
|
if (ctx->error_string)
|
||||||
free(ctx->error_string);
|
free(ctx->error_string);
|
||||||
e = krb5_get_error_string(gssapi_krb5_context);
|
|
||||||
if (e == NULL)
|
|
||||||
ctx->error_string = NULL;
|
ctx->error_string = NULL;
|
||||||
else {
|
|
||||||
/* ignore failures, will use status code instead */
|
|
||||||
ctx->error_string = strdup(e);
|
|
||||||
krb5_free_error_string(gssapi_krb5_context, e);
|
|
||||||
}
|
|
||||||
HEIMDAL_MUTEX_unlock(&ctx->mutex);
|
HEIMDAL_MUTEX_unlock(&ctx->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gssapi_krb5_set_status (const char *fmt, ...)
|
||||||
|
{
|
||||||
|
struct gssapi_thr_context *ctx = gssapi_get_thread_context(1);
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
if (ctx == NULL)
|
||||||
|
return;
|
||||||
|
HEIMDAL_MUTEX_lock(&ctx->mutex);
|
||||||
|
va_start(args, fmt);
|
||||||
|
if (ctx->error_string)
|
||||||
|
free(ctx->error_string);
|
||||||
|
/* ignore failures, will use status code instead */
|
||||||
|
vasprintf(&ctx->error_string, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
HEIMDAL_MUTEX_unlock(&ctx->mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gssapi_krb5_set_error_string (void)
|
||||||
|
{
|
||||||
|
char *e;
|
||||||
|
|
||||||
|
e = krb5_get_error_string(gssapi_krb5_context);
|
||||||
|
if (e) {
|
||||||
|
gssapi_krb5_set_status("%s", e);
|
||||||
|
krb5_free_error_string(gssapi_krb5_context, e);
|
||||||
|
} else
|
||||||
|
gssapi_krb5_clear_status();
|
||||||
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
gssapi_krb5_get_error_string (void)
|
gssapi_krb5_get_error_string (void)
|
||||||
{
|
{
|
||||||
|
@@ -112,27 +112,49 @@ supplementary_error(OM_uint32 v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gssapi_krb5_set_error_string (void)
|
gssapi_krb5_clear_status (void)
|
||||||
{
|
{
|
||||||
struct gssapi_thr_context *ctx = gssapi_get_thread_context(1);
|
struct gssapi_thr_context *ctx = gssapi_get_thread_context(1);
|
||||||
char *e;
|
|
||||||
|
|
||||||
if (ctx == NULL)
|
if (ctx == NULL)
|
||||||
return;
|
return;
|
||||||
HEIMDAL_MUTEX_lock(&ctx->mutex);
|
HEIMDAL_MUTEX_lock(&ctx->mutex);
|
||||||
if (ctx->error_string)
|
if (ctx->error_string)
|
||||||
free(ctx->error_string);
|
free(ctx->error_string);
|
||||||
e = krb5_get_error_string(gssapi_krb5_context);
|
|
||||||
if (e == NULL)
|
|
||||||
ctx->error_string = NULL;
|
ctx->error_string = NULL;
|
||||||
else {
|
|
||||||
/* ignore failures, will use status code instead */
|
|
||||||
ctx->error_string = strdup(e);
|
|
||||||
krb5_free_error_string(gssapi_krb5_context, e);
|
|
||||||
}
|
|
||||||
HEIMDAL_MUTEX_unlock(&ctx->mutex);
|
HEIMDAL_MUTEX_unlock(&ctx->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gssapi_krb5_set_status (const char *fmt, ...)
|
||||||
|
{
|
||||||
|
struct gssapi_thr_context *ctx = gssapi_get_thread_context(1);
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
if (ctx == NULL)
|
||||||
|
return;
|
||||||
|
HEIMDAL_MUTEX_lock(&ctx->mutex);
|
||||||
|
va_start(args, fmt);
|
||||||
|
if (ctx->error_string)
|
||||||
|
free(ctx->error_string);
|
||||||
|
/* ignore failures, will use status code instead */
|
||||||
|
vasprintf(&ctx->error_string, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
HEIMDAL_MUTEX_unlock(&ctx->mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gssapi_krb5_set_error_string (void)
|
||||||
|
{
|
||||||
|
char *e;
|
||||||
|
|
||||||
|
e = krb5_get_error_string(gssapi_krb5_context);
|
||||||
|
if (e) {
|
||||||
|
gssapi_krb5_set_status("%s", e);
|
||||||
|
krb5_free_error_string(gssapi_krb5_context, e);
|
||||||
|
} else
|
||||||
|
gssapi_krb5_clear_status();
|
||||||
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
gssapi_krb5_get_error_string (void)
|
gssapi_krb5_get_error_string (void)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user