Ugh
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@864 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
48
Makefile
Normal file
48
Makefile
Normal file
@@ -0,0 +1,48 @@
|
||||
# Generated automatically from Makefile.in by configure.
|
||||
CC = cc -std1
|
||||
CFLAGS = -g
|
||||
|
||||
|
||||
#YACC=bison -y
|
||||
YACC = yacc
|
||||
|
||||
SOURCES = cache.c principal.c principal_p.c data.c context.c misc.c \
|
||||
krbhst.c get_port.c send_to_kdc.c der.c e.c d.c str2key.c \
|
||||
get_in_tkt.c get_in_tkt_pw.c der_put.c constants.c get_addrs.c \
|
||||
k5_der.c
|
||||
|
||||
OBJECTS = $(SOURCES:%.c=%.o) config_file.o
|
||||
|
||||
all: kinit klist
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -c $(CFLAGS) -I. -I/usr/athena/include $< -o $@
|
||||
|
||||
kinit: kinit.o libkrb5.a
|
||||
$(CC) -o kinit kinit.o libkrb5.a -L/usr/athena/lib -ldes
|
||||
|
||||
klist: klist.o libkrb5.a
|
||||
$(CC) -o klist klist.o libkrb5.a -L/usr/athena/lib -ldes
|
||||
|
||||
tt: test.o libkrb5.a
|
||||
$(CC) -o tt test.o libkrb5.a
|
||||
|
||||
test.o: krb5.h
|
||||
|
||||
libkrb5.a: $(OBJECTS)
|
||||
ar cr libkrb5.a $(OBJECTS)
|
||||
ranlib libkrb5.a
|
||||
|
||||
config_file.o: config_file.c
|
||||
|
||||
config_file.c: config_file.y
|
||||
$(YACC) -p __k5cf_ $<
|
||||
mv -f y.tab.c config_file.c
|
||||
|
||||
clean:
|
||||
rm -f *.o *~ libkrb5.a tt core \#* config_file.c
|
||||
|
||||
|
||||
|
||||
$(OBJECTS): krb5_locl.h krb5.h
|
||||
|
@@ -9,7 +9,9 @@ CC = @CC@
|
||||
DEFS = @DEFS@
|
||||
YACC = @YACC@
|
||||
|
||||
CFLAGS = -g -I$(srcdir) -Iasn1 -I.
|
||||
CFLAGS = -g -I$(srcdir) -Iasn1 -I. -I/usr/athena/include
|
||||
|
||||
LIBS = -L/usr/athena/lib -ldes
|
||||
|
||||
SOURCES = cache.c principal.c principal_p.c data.c context.c misc.c \
|
||||
krbhst.c get_port.c send_to_kdc.c str2key.c \
|
||||
@@ -21,10 +23,10 @@ OBJECTS = $(SOURCES:%.c=%.o) config_file.o
|
||||
all: kinit klist
|
||||
|
||||
kinit: kinit.o libkrb5.a
|
||||
$(CC) -o kinit kinit.o libkrb5.a -Lasn1 -lasn1 -L/usr/local/lib -ldes
|
||||
$(CC) -o kinit kinit.o libkrb5.a -Lasn1 -lasn1 $(LIBS)
|
||||
|
||||
klist: klist.o libkrb5.a
|
||||
$(CC) -o klist klist.o libkrb5.a -L/usr/local/lib -ldes
|
||||
$(CC) -o klist klist.o libkrb5.a $(LIBS)
|
||||
|
||||
tt: test.o libkrb5.a
|
||||
$(CC) -o tt test.o libkrb5.a
|
||||
|
@@ -3,6 +3,7 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include "der.h"
|
||||
|
@@ -3,6 +3,7 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include "der.h"
|
||||
|
@@ -19,6 +19,7 @@ init_generate (char *filename)
|
||||
fprintf (codefile,
|
||||
"/* Generated from %s */\n"
|
||||
"/* Do not edit */\n\n"
|
||||
"#include <stdio.h>\n"
|
||||
"#include <stdlib.h>\n"
|
||||
"#include <time.h>\n"
|
||||
"#include <der.h>\n"
|
||||
@@ -222,7 +223,7 @@ encode_type (char *name, Type *t)
|
||||
break;
|
||||
|
||||
for (m = t->members->prev; m && tag != m->val; m = m->prev) {
|
||||
char *s = malloc(1 + strlen(name) + 1 + strlen(m->gen_name) + 3);
|
||||
char *s = malloc(2 + strlen(name) + 1 + strlen(m->gen_name) + 3);
|
||||
|
||||
sprintf (s, "%s(%s)->%s", m->optional ? "" : "&", name, m->gen_name);
|
||||
if (m->optional)
|
||||
@@ -424,7 +425,7 @@ decode_type (char *name, Type *t)
|
||||
"len = reallen;\n");
|
||||
|
||||
for (m = t->members; m && tag != m->val; m = m->next) {
|
||||
char *s = malloc(1 + strlen(name) + 1 + strlen(m->gen_name) + 3);
|
||||
char *s = malloc(2 + strlen(name) + 1 + strlen(m->gen_name) + 3);
|
||||
|
||||
sprintf (s, "%s(%s)->%s", m->optional ? "" : "&", name, m->gen_name);
|
||||
fprintf (codefile, "{\n"
|
||||
|
11
asn1/lex.l
11
asn1/lex.l
@@ -10,10 +10,15 @@
|
||||
#include "symbol.h"
|
||||
#include "parse.h"
|
||||
|
||||
char *strdup(char *);
|
||||
|
||||
void error_message(char *, ...);
|
||||
|
||||
static unsigned lineno = 1;
|
||||
static char filename[256];
|
||||
%}
|
||||
|
||||
|
||||
%%
|
||||
INTEGER { return INTEGER; }
|
||||
SEQUENCE { return SEQUENCE; }
|
||||
@@ -28,21 +33,23 @@ OPTIONAL { return OPTIONAL; }
|
||||
BEGIN { return TBEGIN; }
|
||||
END { return END; }
|
||||
DEFINITIONS { return DEFINITIONS; }
|
||||
[][|{},()] { return *yytext; }
|
||||
,|\{|\}|\(|\)|\[|\]|\| { return *yytext; }
|
||||
::= { return EEQUAL; }
|
||||
--[^\n]*\n { ; }
|
||||
-?[0-9]+ { yylval.constant = atoi(yytext); return CONSTANT; }
|
||||
[A-Za-z][-A-Za-z0-9_]* { yylval.name = strdup (yytext); return IDENTIFIER; }
|
||||
[ \t] ;
|
||||
\n { lineno++; }
|
||||
. { fprintf(stderr, "Ignoring char(%c)\n", *yytext); }
|
||||
. { error_message("Ignoring char(%c)\n", *yytext); }
|
||||
%%
|
||||
|
||||
#ifndef yywrap /* XXX */
|
||||
int
|
||||
yywrap ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
error_message (char *format, ...)
|
||||
|
@@ -12,6 +12,8 @@
|
||||
|
||||
static Type *new_type (Typetype t);
|
||||
void yyerror (char *);
|
||||
|
||||
char *strdup(char *);
|
||||
%}
|
||||
|
||||
%union {
|
||||
@@ -167,6 +169,7 @@ new_type (Typetype tt)
|
||||
t->members = NULL;
|
||||
t->subtype = NULL;
|
||||
t->symbol = NULL;
|
||||
return t;
|
||||
}
|
||||
|
||||
static void
|
||||
|
20
cache.c
20
cache.c
@@ -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
|
||||
|
@@ -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)
|
||||
{
|
||||
|
5
data.c
5
data.c
@@ -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)
|
||||
|
22
krb5.h
22
krb5.h
@@ -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>
|
||||
|
||||
|
@@ -3,6 +3,7 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include "der.h"
|
||||
|
@@ -3,6 +3,7 @@
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include "der.h"
|
||||
|
@@ -19,6 +19,7 @@ init_generate (char *filename)
|
||||
fprintf (codefile,
|
||||
"/* Generated from %s */\n"
|
||||
"/* Do not edit */\n\n"
|
||||
"#include <stdio.h>\n"
|
||||
"#include <stdlib.h>\n"
|
||||
"#include <time.h>\n"
|
||||
"#include <der.h>\n"
|
||||
@@ -222,7 +223,7 @@ encode_type (char *name, Type *t)
|
||||
break;
|
||||
|
||||
for (m = t->members->prev; m && tag != m->val; m = m->prev) {
|
||||
char *s = malloc(1 + strlen(name) + 1 + strlen(m->gen_name) + 3);
|
||||
char *s = malloc(2 + strlen(name) + 1 + strlen(m->gen_name) + 3);
|
||||
|
||||
sprintf (s, "%s(%s)->%s", m->optional ? "" : "&", name, m->gen_name);
|
||||
if (m->optional)
|
||||
@@ -424,7 +425,7 @@ decode_type (char *name, Type *t)
|
||||
"len = reallen;\n");
|
||||
|
||||
for (m = t->members; m && tag != m->val; m = m->next) {
|
||||
char *s = malloc(1 + strlen(name) + 1 + strlen(m->gen_name) + 3);
|
||||
char *s = malloc(2 + strlen(name) + 1 + strlen(m->gen_name) + 3);
|
||||
|
||||
sprintf (s, "%s(%s)->%s", m->optional ? "" : "&", name, m->gen_name);
|
||||
fprintf (codefile, "{\n"
|
||||
|
@@ -10,10 +10,15 @@
|
||||
#include "symbol.h"
|
||||
#include "parse.h"
|
||||
|
||||
char *strdup(char *);
|
||||
|
||||
void error_message(char *, ...);
|
||||
|
||||
static unsigned lineno = 1;
|
||||
static char filename[256];
|
||||
%}
|
||||
|
||||
|
||||
%%
|
||||
INTEGER { return INTEGER; }
|
||||
SEQUENCE { return SEQUENCE; }
|
||||
@@ -28,21 +33,23 @@ OPTIONAL { return OPTIONAL; }
|
||||
BEGIN { return TBEGIN; }
|
||||
END { return END; }
|
||||
DEFINITIONS { return DEFINITIONS; }
|
||||
[][|{},()] { return *yytext; }
|
||||
,|\{|\}|\(|\)|\[|\]|\| { return *yytext; }
|
||||
::= { return EEQUAL; }
|
||||
--[^\n]*\n { ; }
|
||||
-?[0-9]+ { yylval.constant = atoi(yytext); return CONSTANT; }
|
||||
[A-Za-z][-A-Za-z0-9_]* { yylval.name = strdup (yytext); return IDENTIFIER; }
|
||||
[ \t] ;
|
||||
\n { lineno++; }
|
||||
. { fprintf(stderr, "Ignoring char(%c)\n", *yytext); }
|
||||
. { error_message("Ignoring char(%c)\n", *yytext); }
|
||||
%%
|
||||
|
||||
#ifndef yywrap /* XXX */
|
||||
int
|
||||
yywrap ()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
error_message (char *format, ...)
|
||||
|
@@ -12,6 +12,8 @@
|
||||
|
||||
static Type *new_type (Typetype t);
|
||||
void yyerror (char *);
|
||||
|
||||
char *strdup(char *);
|
||||
%}
|
||||
|
||||
%union {
|
||||
@@ -167,6 +169,7 @@ new_type (Typetype tt)
|
||||
t->members = NULL;
|
||||
t->subtype = NULL;
|
||||
t->symbol = NULL;
|
||||
return t;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -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
|
||||
|
@@ -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)
|
||||
{
|
||||
|
@@ -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)
|
||||
|
@@ -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>
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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)
|
||||
|
430
principal.c
430
principal.c
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -1,5 +1,11 @@
|
||||
#include "krb5_locl.h"
|
||||
|
||||
/* XXX */
|
||||
|
||||
#ifdef sun
|
||||
#define memmove(a,b,c) bcopy(b,a,c)
|
||||
#endif
|
||||
|
||||
static void reverse(unsigned char *p)
|
||||
{
|
||||
unsigned char tmp[8];
|
||||
|
Reference in New Issue
Block a user