Make a KRB-ERROR message.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1849 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
31
lib/krb5/mk_error.c
Normal file
31
lib/krb5/mk_error.c
Normal file
@@ -0,0 +1,31 @@
|
||||
#include "krb5_locl.h"
|
||||
|
||||
RCSID("$Id$");
|
||||
|
||||
krb5_error_code
|
||||
krb5_mk_error(krb5_principal princ,
|
||||
krb5_error_code error_code,
|
||||
char *e_text,
|
||||
krb5_data *e_data,
|
||||
krb5_data *err)
|
||||
{
|
||||
KRB_ERROR msg;
|
||||
unsigned char buf[1024];
|
||||
|
||||
memset(&msg, 0, sizeof(msg));
|
||||
msg.pvno = 5;
|
||||
msg.msg_type = krb_error;
|
||||
msg.stime = time(0);
|
||||
msg.error_code = error_code;
|
||||
msg.realm = princ->realm.data;
|
||||
krb5_principal2principalname(&msg.sname, princ);
|
||||
if (e_text)
|
||||
msg.e_text = &e_text;
|
||||
if (e_data)
|
||||
msg.e_data = e_data;
|
||||
err->length = encode_KRB_ERROR(buf + sizeof(buf) - 1, sizeof(buf), &msg);
|
||||
err->data = malloc(err->length);
|
||||
memcpy(err->data, buf + sizeof(buf) - err->length, err->length);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user