git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@864 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
1996-10-20 16:47:54 +00:00
parent 309846037c
commit dbdb412ba0
25 changed files with 595 additions and 479 deletions

View File

@@ -442,16 +442,16 @@ krb5_cc_read_cred (int fd,
int8_t dummy8;
int32_t dummy32;
return ret_principal (fd, &creds->client)
|| ret_principal (fd, &creds->server)
|| ret_keyblock (fd, &creds->session)
|| ret_times (fd, &creds->times)
|| ret_int8 (fd, &dummy8)
|| ret_int32 (fd, &dummy32)
|| ret_addrs (fd, &creds->addresses)
|| ret_authdata (fd, &creds->authdata)
|| ret_ticket (fd, &creds->ticket)
|| ret_ticket (fd, &creds->second_ticket);
return ret_principal (fd, &creds->client) ||
ret_principal (fd, &creds->server) ||
ret_keyblock (fd, &creds->session) ||
ret_times (fd, &creds->times) ||
ret_int8 (fd, &dummy8) ||
ret_int32 (fd, &dummy32) ||
ret_addrs (fd, &creds->addresses) ||
ret_authdata (fd, &creds->authdata) ||
ret_ticket (fd, &creds->ticket) ||
ret_ticket (fd, &creds->second_ticket);
}
krb5_error_code

View File

@@ -1,5 +1,11 @@
#include "krb5_locl.h"
/* XXX */
#ifdef sun
#define memmove(a,b,c) bcopy(b,a,c)
#endif
krb5_error_code
krb5_init_context(krb5_context *context)
{

View File

@@ -1,5 +1,10 @@
#include "krb5_locl.h"
/* XXX */
#ifdef sun
#define memmove(a,b,c) bcopy(b,a,c)
#endif
void
krb5_data_free(krb5_data *p)

View File

@@ -22,17 +22,17 @@
#endif
/* types */
typedef int32_t krb5_int32;
typedef int16_t krb5_int16;
typedef int8_t krb5_int8;
typedef int int32_t;
typedef short int16_t;
typedef char int8_t;
typedef unsigned int krb5_uint32;
typedef unsigned short krb5_uint16;
typedef unsigned char krb5_uint8;
typedef unsigned int u_int32_t;
typedef unsigned short u_int16_t;
typedef unsigned char u_int8_t;
typedef int krb5_boolean;
typedef krb5_int32 krb5_error_code;
typedef int32_t krb5_error_code;
@@ -196,7 +196,7 @@ typedef struct krb5_keytab{
typedef struct krb5_auth_context{
krb5_int32 flags;
int32_t flags;
krb5_cksumtype cksumtype;
krb5_address local_address;
@@ -205,8 +205,8 @@ typedef struct krb5_auth_context{
krb5_keyblock local_subkey;
krb5_keyblock remote_subkey;
krb5_int32 local_seqnumber;
krb5_int32 remote_seqnumber;
int32_t local_seqnumber;
int32_t remote_seqnumber;
krb5_authenticator authenticator;
@@ -217,7 +217,7 @@ typedef struct krb5_auth_context{
}krb5_auth_context;
typedef krb5_uint32 krb5_flags;
typedef u_int32_t krb5_flags;
#include <foo.h>

View File

@@ -2,12 +2,18 @@
RCSID("$Id$");
/* XXX */
#ifdef sun
#define memmove(a,b,c) bcopy(b,a,c)
#endif
/* Public principal handling functions */
void
krb5_free_principal(krb5_principal p)
{
krb5_principal_free(p);
krb5_principal_free(p);
}
krb5_error_code
@@ -16,117 +22,117 @@ krb5_parse_name(krb5_context context,
krb5_principal *principal)
{
krb5_data *comp;
int ncomp;
krb5_data realm;
krb5_data *comp;
int ncomp;
krb5_data realm;
char *p;
char *q;
char *s;
char *start;
char *p;
char *q;
char *s;
char *start;
int n;
char c;
int got_realm = 0;
int n;
char c;
int got_realm = 0;
/* count number of component */
ncomp = 1;
for(p = (char*)name; *p; p++){
if(*p=='\\'){
if(!p[1])
return KRB5_PARSE_MALFORMED;
p++;
} else if(*p == '/')
ncomp++;
}
comp = ALLOC(ncomp, krb5_data);
/* count number of component */
ncomp = 1;
for(p = (char*)name; *p; p++){
if(*p=='\\'){
if(!p[1])
return KRB5_PARSE_MALFORMED;
p++;
} else if(*p == '/')
ncomp++;
}
comp = ALLOC(ncomp, krb5_data);
n = 0;
start = q = p = s = strdup(name);
while(*p){
c = *p++;
if(c == '\\'){
c = *p++;
if(c == 'n')
c = '\n';
else if(c == 't')
c = '\t';
else if(c == 'b')
c = '\b';
else if(c == '0')
c = '\0';
}else if(c == '/' || c == '@'){
if(got_realm){
while(n>0)
free(comp[--n].data);
free(comp);
free(s);
return KRB5_PARSE_MALFORMED;
}else{
n = 0;
start = q = p = s = strdup(name);
while(*p){
c = *p++;
if(c == '\\'){
c = *p++;
if(c == 'n')
c = '\n';
else if(c == 't')
c = '\t';
else if(c == 'b')
c = '\b';
else if(c == '0')
c = '\0';
}else if(c == '/' || c == '@'){
if(got_realm){
while(n>0)
free(comp[--n].data);
free(comp);
free(s);
return KRB5_PARSE_MALFORMED;
}else{
comp[n].length = q - start;
comp[n].data = (krb5_pointer)malloc(comp[n].length);
memmove(comp[n].data, start, comp[n].length);
n++;
}
if(c == '@')
got_realm = 1;
start = q;
continue;
}
if(got_realm && (c == ':' || c == '/' || c == '\0')){
while(n>0)
free(comp[--n].data);
free(comp);
free(s);
return KRB5_PARSE_MALFORMED;
}
*q++ = c;
}
if(got_realm){
realm.length = q - start;
realm.data = (krb5_pointer)malloc(realm.length);
memmove(realm.data, start, realm.length);
}else{
comp[n].length = q - start;
comp[n].data = (krb5_pointer)malloc(comp[n].length);
memmove(comp[n].data, start, comp[n].length);
n++;
}
if(c == '@')
got_realm = 1;
start = q;
continue;
}
if(got_realm && (c == ':' || c == '/' || c == '\0')){
while(n>0)
free(comp[--n].data);
free(comp);
free(s);
return KRB5_PARSE_MALFORMED;
}
*q++ = c;
}
if(got_realm){
realm.length = q - start;
realm.data = (krb5_pointer)malloc(realm.length);
memmove(realm.data, start, realm.length);
}else{
comp[n].length = q - start;
comp[n].data = (krb5_pointer)malloc(comp[n].length);
memmove(comp[n].data, start, comp[n].length);
n++;
}
*principal = ALLOC(1, krb5_principal_data);
(*principal)->type = KRB5_NT_PRINCIPAL;
(*principal)->realm = realm;
(*principal)->comp = comp;
(*principal)->ncomp = n;
free(s);
return 0;
*principal = ALLOC(1, krb5_principal_data);
(*principal)->type = KRB5_NT_PRINCIPAL;
(*principal)->realm = realm;
(*principal)->comp = comp;
(*principal)->ncomp = n;
free(s);
return 0;
}
static void quote_string(char *s, int len, char **out)
{
char *q;
char *p = *out;
int c=0;
for(q = s; q < s + len; q++){
if(*q == '\n')
c = 'n';
else if(*q == '\t')
c = 't';
else if(*q == '\b')
c = 'b';
else if(*q == '\0')
c = '0';
else if(*q == '/')
c='/';
else if(*q == '@')
c = '@';
if(c){
*p++ = '\\';
*p++ = c;
c = 0;
}else
*p++ = *q;
}
*out = p;
char *q;
char *p = *out;
int c=0;
for(q = s; q < s + len; q++){
if(*q == '\n')
c = 'n';
else if(*q == '\t')
c = 't';
else if(*q == '\b')
c = 'b';
else if(*q == '\0')
c = '0';
else if(*q == '/')
c='/';
else if(*q == '@')
c = '@';
if(c){
*p++ = '\\';
*p++ = c;
c = 0;
}else
*p++ = *q;
}
*out = p;
}
@@ -135,25 +141,25 @@ krb5_unparse_name(krb5_context context,
krb5_principal principal,
char **name)
{
int size = 0;
char *p;
char *s;
int i;
for(i = 0; i < principal->ncomp; i++)
size += 2*principal->comp[i].length + 1;
size += 2*principal->realm.length + 1;
s = ALLOC(size, char);
p = s;
for(i = 0; i < principal->ncomp; i++){
if(i) *p++ = '/';
quote_string(principal->comp[i].data, principal->comp[i].length, &p);
}
*p++ = '@';
quote_string(principal->realm.data, principal->realm.length, &p);
*p = 0;
*name = strdup(s);
free(s);
return 0;
int size = 0;
char *p;
char *s;
int i;
for(i = 0; i < principal->ncomp; i++)
size += 2*principal->comp[i].length + 1;
size += 2*principal->realm.length + 1;
s = ALLOC(size, char);
p = s;
for(i = 0; i < principal->ncomp; i++){
if(i) *p++ = '/';
quote_string(principal->comp[i].data, principal->comp[i].length, &p);
}
*p++ = '@';
quote_string(principal->realm.data, principal->realm.length, &p);
*p = 0;
*name = strdup(s);
free(s);
return 0;
}
@@ -163,8 +169,8 @@ krb5_unparse_name_ext(krb5_context context,
char **name,
size_t *size)
{
fprintf(stderr, "krb5_unparse_name_ext: not implemented\n");
abort();
fprintf(stderr, "krb5_unparse_name_ext: not implemented\n");
abort();
}
@@ -172,7 +178,7 @@ krb5_data*
krb5_princ_realm(krb5_context context,
krb5_principal principal)
{
return &principal->realm;
return &principal->realm;
}
@@ -181,7 +187,7 @@ krb5_princ_set_realm(krb5_context context,
krb5_principal principal,
krb5_data *realm)
{
principal->realm = *realm;
principal->realm = *realm;
}
@@ -192,31 +198,31 @@ krb5_build_principal(krb5_context context,
const char *realm,
...)
{
krb5_error_code ret;
va_list ap;
va_start(ap, realm);
ret = krb5_build_principal_va(context, principal, rlen, realm, ap);
va_end(ap);
return ret;
krb5_error_code ret;
va_list ap;
va_start(ap, realm);
ret = krb5_build_principal_va(context, principal, rlen, realm, ap);
va_end(ap);
return ret;
}
krb5_error_code
krb5_principal_set_component(krb5_principal p, int n, void *data, size_t len)
{
krb5_data *tmp;
if(p->ncomp <= n){
int s = n + 10;
if(p->comp)
tmp = (krb5_data*)realloc(p->comp, s * sizeof(krb5_data));
else
tmp = ALLOC(s, krb5_data);
if(!tmp)
return ENOMEM;
p->comp = tmp;
p->ncomp = s;
}
krb5_data_copy(&p->comp[n], data, len);
return 0;
krb5_data *tmp;
if(p->ncomp <= n){
int s = n + 10;
if(p->comp)
tmp = (krb5_data*)realloc(p->comp, s * sizeof(krb5_data));
else
tmp = ALLOC(s, krb5_data);
if(!tmp)
return ENOMEM;
p->comp = tmp;
p->ncomp = s;
}
krb5_data_copy(&p->comp[n], data, len);
return 0;
}
@@ -227,30 +233,30 @@ krb5_build_principal_va(krb5_context context,
const char *realm,
va_list ap)
{
krb5_principal p;
int n;
char *s;
krb5_principal p;
int n;
char *s;
if(krb5_principal_alloc(&p))
return ENOMEM;
p->type = KRB5_NT_PRINCIPAL;
if(krb5_principal_alloc(&p))
return ENOMEM;
p->type = KRB5_NT_PRINCIPAL;
if(krb5_data_copy(&p->realm, (void*)realm, rlen)){
free(p);
return ENOMEM;
}
if(krb5_data_copy(&p->realm, (void*)realm, rlen)){
free(p);
return ENOMEM;
}
n = 0;
while(1){
s = va_arg(ap, char*);
if(s == NULL)
break;
krb5_principal_set_component(p, n, s, strlen(s));
n++;
}
p->ncomp = n;
*principal = p;
return 0;
n = 0;
while(1){
s = va_arg(ap, char*);
if(s == NULL)
break;
krb5_principal_set_component(p, n, s, strlen(s));
n++;
}
p->ncomp = n;
*principal = p;
return 0;
}
@@ -261,8 +267,8 @@ krb5_build_principal_ext(krb5_context context,
const char *realm,
...)
{
fprintf(stderr, "krb5_build_principal_ext: not implemented\n");
abort();
fprintf(stderr, "krb5_build_principal_ext: not implemented\n");
abort();
}
@@ -271,32 +277,32 @@ krb5_copy_principal(krb5_context context,
krb5_const_principal inprinc,
krb5_principal *outprinc)
{
krb5_principal p;
int i;
if(krb5_principal_alloc(&p))
return ENOMEM;
p->type = inprinc->type;
if(krb5_data_copy(&p->realm, inprinc->realm.data, inprinc->realm.length)){
krb5_free_principal(p);
return ENOMEM;
}
p->comp = ALLOC(inprinc->ncomp, krb5_data);
if(!p->comp){
krb5_free_principal(p);
return ENOMEM;
}
for(i=0; i<inprinc->ncomp; i++){
p->comp[i].length = 0;
if(krb5_data_copy(&p->comp[i], inprinc->comp[i].data,
inprinc->comp[i].length)){
krb5_free_principal(p);
return ENOMEM;
krb5_principal p;
int i;
if(krb5_principal_alloc(&p))
return ENOMEM;
p->type = inprinc->type;
if(krb5_data_copy(&p->realm, inprinc->realm.data, inprinc->realm.length)){
krb5_free_principal(p);
return ENOMEM;
}
p->ncomp = i+1;
}
*outprinc = p;
return 0;
p->comp = ALLOC(inprinc->ncomp, krb5_data);
if(!p->comp){
krb5_free_principal(p);
return ENOMEM;
}
for(i=0; i<inprinc->ncomp; i++){
p->comp[i].length = 0;
if(krb5_data_copy(&p->comp[i], inprinc->comp[i].data,
inprinc->comp[i].length)){
krb5_free_principal(p);
return ENOMEM;
}
p->ncomp = i+1;
}
*outprinc = p;
return 0;
}
@@ -305,19 +311,19 @@ krb5_principal_compare(krb5_context context,
krb5_const_principal princ1,
krb5_const_principal princ2)
{
int i;
if(!krb5_realm_compare(context, princ1, princ2))
return FALSE;
if(princ1->ncomp != princ2->ncomp)
return FALSE;
for(i=0; i<princ1->ncomp; i++){
if(princ1->comp[i].length != princ2->comp[i].length)
return FALSE;
if(memcmp(princ1->comp[i].data, princ2->comp[i].data,
princ1->comp[i].length))
return FALSE;
}
return TRUE;
int i;
if(!krb5_realm_compare(context, princ1, princ2))
return FALSE;
if(princ1->ncomp != princ2->ncomp)
return FALSE;
for(i=0; i<princ1->ncomp; i++){
if(princ1->comp[i].length != princ2->comp[i].length)
return FALSE;
if(memcmp(princ1->comp[i].data, princ2->comp[i].data,
princ1->comp[i].length))
return FALSE;
}
return TRUE;
}
@@ -326,11 +332,11 @@ krb5_realm_compare(krb5_context context,
krb5_const_principal princ1,
krb5_const_principal princ2)
{
if(princ1->realm.length != princ2->realm.length)
return FALSE;
if(memcmp(princ1->realm.data, princ2->realm.data, princ1->realm.length))
return FALSE;
return TRUE;
if(princ1->realm.length != princ2->realm.length)
return FALSE;
if(memcmp(princ1->realm.data, princ2->realm.data, princ1->realm.length))
return FALSE;
return TRUE;
}
@@ -341,10 +347,10 @@ krb5_425_conv_principal(krb5_context context,
const char *realm,
krb5_principal *princ)
{
if(!strcmp(name, "rcmd"))
name = "host";
return krb5_build_principal(context, princ,
strlen(realm), realm, name, instance, 0);
if(!strcmp(name, "rcmd"))
name = "host";
return krb5_build_principal(context, princ,
strlen(realm), realm, name, instance, 0);
}

View File

@@ -10,7 +10,7 @@ send_and_recv (int fd,
struct fd_set fdset;
struct timeval timeout;
int ret;
long nbytes;
int nbytes;
if (sendto (fd, send->data, send->length, 0,
(struct sockaddr *)addr, sizeof(*addr)) < 0)