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@
|
DEFS = @DEFS@
|
||||||
YACC = @YACC@
|
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 \
|
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 \
|
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
|
all: kinit klist
|
||||||
|
|
||||||
kinit: kinit.o libkrb5.a
|
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
|
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
|
tt: test.o libkrb5.a
|
||||||
$(CC) -o tt test.o libkrb5.a
|
$(CC) -o tt test.o libkrb5.a
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "der.h"
|
#include "der.h"
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "der.h"
|
#include "der.h"
|
||||||
|
@@ -19,6 +19,7 @@ init_generate (char *filename)
|
|||||||
fprintf (codefile,
|
fprintf (codefile,
|
||||||
"/* Generated from %s */\n"
|
"/* Generated from %s */\n"
|
||||||
"/* Do not edit */\n\n"
|
"/* Do not edit */\n\n"
|
||||||
|
"#include <stdio.h>\n"
|
||||||
"#include <stdlib.h>\n"
|
"#include <stdlib.h>\n"
|
||||||
"#include <time.h>\n"
|
"#include <time.h>\n"
|
||||||
"#include <der.h>\n"
|
"#include <der.h>\n"
|
||||||
@@ -222,7 +223,7 @@ encode_type (char *name, Type *t)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
for (m = t->members->prev; m && tag != m->val; m = m->prev) {
|
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);
|
sprintf (s, "%s(%s)->%s", m->optional ? "" : "&", name, m->gen_name);
|
||||||
if (m->optional)
|
if (m->optional)
|
||||||
@@ -424,7 +425,7 @@ decode_type (char *name, Type *t)
|
|||||||
"len = reallen;\n");
|
"len = reallen;\n");
|
||||||
|
|
||||||
for (m = t->members; m && tag != m->val; m = m->next) {
|
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);
|
sprintf (s, "%s(%s)->%s", m->optional ? "" : "&", name, m->gen_name);
|
||||||
fprintf (codefile, "{\n"
|
fprintf (codefile, "{\n"
|
||||||
|
11
asn1/lex.l
11
asn1/lex.l
@@ -10,10 +10,15 @@
|
|||||||
#include "symbol.h"
|
#include "symbol.h"
|
||||||
#include "parse.h"
|
#include "parse.h"
|
||||||
|
|
||||||
|
char *strdup(char *);
|
||||||
|
|
||||||
|
void error_message(char *, ...);
|
||||||
|
|
||||||
static unsigned lineno = 1;
|
static unsigned lineno = 1;
|
||||||
static char filename[256];
|
static char filename[256];
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
%%
|
%%
|
||||||
INTEGER { return INTEGER; }
|
INTEGER { return INTEGER; }
|
||||||
SEQUENCE { return SEQUENCE; }
|
SEQUENCE { return SEQUENCE; }
|
||||||
@@ -28,21 +33,23 @@ OPTIONAL { return OPTIONAL; }
|
|||||||
BEGIN { return TBEGIN; }
|
BEGIN { return TBEGIN; }
|
||||||
END { return END; }
|
END { return END; }
|
||||||
DEFINITIONS { return DEFINITIONS; }
|
DEFINITIONS { return DEFINITIONS; }
|
||||||
[][|{},()] { return *yytext; }
|
,|\{|\}|\(|\)|\[|\]|\| { return *yytext; }
|
||||||
::= { return EEQUAL; }
|
::= { return EEQUAL; }
|
||||||
--[^\n]*\n { ; }
|
--[^\n]*\n { ; }
|
||||||
-?[0-9]+ { yylval.constant = atoi(yytext); return CONSTANT; }
|
-?[0-9]+ { yylval.constant = atoi(yytext); return CONSTANT; }
|
||||||
[A-Za-z][-A-Za-z0-9_]* { yylval.name = strdup (yytext); return IDENTIFIER; }
|
[A-Za-z][-A-Za-z0-9_]* { yylval.name = strdup (yytext); return IDENTIFIER; }
|
||||||
[ \t] ;
|
[ \t] ;
|
||||||
\n { lineno++; }
|
\n { lineno++; }
|
||||||
. { fprintf(stderr, "Ignoring char(%c)\n", *yytext); }
|
. { error_message("Ignoring char(%c)\n", *yytext); }
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
#ifndef yywrap /* XXX */
|
||||||
int
|
int
|
||||||
yywrap ()
|
yywrap ()
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
error_message (char *format, ...)
|
error_message (char *format, ...)
|
||||||
|
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
static Type *new_type (Typetype t);
|
static Type *new_type (Typetype t);
|
||||||
void yyerror (char *);
|
void yyerror (char *);
|
||||||
|
|
||||||
|
char *strdup(char *);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%union {
|
%union {
|
||||||
@@ -167,6 +169,7 @@ new_type (Typetype tt)
|
|||||||
t->members = NULL;
|
t->members = NULL;
|
||||||
t->subtype = NULL;
|
t->subtype = NULL;
|
||||||
t->symbol = NULL;
|
t->symbol = NULL;
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
20
cache.c
20
cache.c
@@ -442,16 +442,16 @@ krb5_cc_read_cred (int fd,
|
|||||||
int8_t dummy8;
|
int8_t dummy8;
|
||||||
int32_t dummy32;
|
int32_t dummy32;
|
||||||
|
|
||||||
return ret_principal (fd, &creds->client)
|
return ret_principal (fd, &creds->client) ||
|
||||||
|| ret_principal (fd, &creds->server)
|
ret_principal (fd, &creds->server) ||
|
||||||
|| ret_keyblock (fd, &creds->session)
|
ret_keyblock (fd, &creds->session) ||
|
||||||
|| ret_times (fd, &creds->times)
|
ret_times (fd, &creds->times) ||
|
||||||
|| ret_int8 (fd, &dummy8)
|
ret_int8 (fd, &dummy8) ||
|
||||||
|| ret_int32 (fd, &dummy32)
|
ret_int32 (fd, &dummy32) ||
|
||||||
|| ret_addrs (fd, &creds->addresses)
|
ret_addrs (fd, &creds->addresses) ||
|
||||||
|| ret_authdata (fd, &creds->authdata)
|
ret_authdata (fd, &creds->authdata) ||
|
||||||
|| ret_ticket (fd, &creds->ticket)
|
ret_ticket (fd, &creds->ticket) ||
|
||||||
|| ret_ticket (fd, &creds->second_ticket);
|
ret_ticket (fd, &creds->second_ticket);
|
||||||
}
|
}
|
||||||
|
|
||||||
krb5_error_code
|
krb5_error_code
|
||||||
|
@@ -1,5 +1,11 @@
|
|||||||
#include "krb5_locl.h"
|
#include "krb5_locl.h"
|
||||||
|
|
||||||
|
/* XXX */
|
||||||
|
|
||||||
|
#ifdef sun
|
||||||
|
#define memmove(a,b,c) bcopy(b,a,c)
|
||||||
|
#endif
|
||||||
|
|
||||||
krb5_error_code
|
krb5_error_code
|
||||||
krb5_init_context(krb5_context *context)
|
krb5_init_context(krb5_context *context)
|
||||||
{
|
{
|
||||||
|
5
data.c
5
data.c
@@ -1,5 +1,10 @@
|
|||||||
#include "krb5_locl.h"
|
#include "krb5_locl.h"
|
||||||
|
|
||||||
|
/* XXX */
|
||||||
|
|
||||||
|
#ifdef sun
|
||||||
|
#define memmove(a,b,c) bcopy(b,a,c)
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
krb5_data_free(krb5_data *p)
|
krb5_data_free(krb5_data *p)
|
||||||
|
22
krb5.h
22
krb5.h
@@ -22,17 +22,17 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* types */
|
/* types */
|
||||||
typedef int32_t krb5_int32;
|
typedef int int32_t;
|
||||||
typedef int16_t krb5_int16;
|
typedef short int16_t;
|
||||||
typedef int8_t krb5_int8;
|
typedef char int8_t;
|
||||||
|
|
||||||
typedef unsigned int krb5_uint32;
|
typedef unsigned int u_int32_t;
|
||||||
typedef unsigned short krb5_uint16;
|
typedef unsigned short u_int16_t;
|
||||||
typedef unsigned char krb5_uint8;
|
typedef unsigned char u_int8_t;
|
||||||
|
|
||||||
typedef int krb5_boolean;
|
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{
|
typedef struct krb5_auth_context{
|
||||||
krb5_int32 flags;
|
int32_t flags;
|
||||||
krb5_cksumtype cksumtype;
|
krb5_cksumtype cksumtype;
|
||||||
|
|
||||||
krb5_address local_address;
|
krb5_address local_address;
|
||||||
@@ -205,8 +205,8 @@ typedef struct krb5_auth_context{
|
|||||||
krb5_keyblock local_subkey;
|
krb5_keyblock local_subkey;
|
||||||
krb5_keyblock remote_subkey;
|
krb5_keyblock remote_subkey;
|
||||||
|
|
||||||
krb5_int32 local_seqnumber;
|
int32_t local_seqnumber;
|
||||||
krb5_int32 remote_seqnumber;
|
int32_t remote_seqnumber;
|
||||||
|
|
||||||
krb5_authenticator authenticator;
|
krb5_authenticator authenticator;
|
||||||
|
|
||||||
@@ -217,7 +217,7 @@ typedef struct krb5_auth_context{
|
|||||||
}krb5_auth_context;
|
}krb5_auth_context;
|
||||||
|
|
||||||
|
|
||||||
typedef krb5_uint32 krb5_flags;
|
typedef u_int32_t krb5_flags;
|
||||||
|
|
||||||
#include <foo.h>
|
#include <foo.h>
|
||||||
|
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "der.h"
|
#include "der.h"
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "der.h"
|
#include "der.h"
|
||||||
|
@@ -19,6 +19,7 @@ init_generate (char *filename)
|
|||||||
fprintf (codefile,
|
fprintf (codefile,
|
||||||
"/* Generated from %s */\n"
|
"/* Generated from %s */\n"
|
||||||
"/* Do not edit */\n\n"
|
"/* Do not edit */\n\n"
|
||||||
|
"#include <stdio.h>\n"
|
||||||
"#include <stdlib.h>\n"
|
"#include <stdlib.h>\n"
|
||||||
"#include <time.h>\n"
|
"#include <time.h>\n"
|
||||||
"#include <der.h>\n"
|
"#include <der.h>\n"
|
||||||
@@ -222,7 +223,7 @@ encode_type (char *name, Type *t)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
for (m = t->members->prev; m && tag != m->val; m = m->prev) {
|
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);
|
sprintf (s, "%s(%s)->%s", m->optional ? "" : "&", name, m->gen_name);
|
||||||
if (m->optional)
|
if (m->optional)
|
||||||
@@ -424,7 +425,7 @@ decode_type (char *name, Type *t)
|
|||||||
"len = reallen;\n");
|
"len = reallen;\n");
|
||||||
|
|
||||||
for (m = t->members; m && tag != m->val; m = m->next) {
|
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);
|
sprintf (s, "%s(%s)->%s", m->optional ? "" : "&", name, m->gen_name);
|
||||||
fprintf (codefile, "{\n"
|
fprintf (codefile, "{\n"
|
||||||
|
@@ -10,10 +10,15 @@
|
|||||||
#include "symbol.h"
|
#include "symbol.h"
|
||||||
#include "parse.h"
|
#include "parse.h"
|
||||||
|
|
||||||
|
char *strdup(char *);
|
||||||
|
|
||||||
|
void error_message(char *, ...);
|
||||||
|
|
||||||
static unsigned lineno = 1;
|
static unsigned lineno = 1;
|
||||||
static char filename[256];
|
static char filename[256];
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
||||||
%%
|
%%
|
||||||
INTEGER { return INTEGER; }
|
INTEGER { return INTEGER; }
|
||||||
SEQUENCE { return SEQUENCE; }
|
SEQUENCE { return SEQUENCE; }
|
||||||
@@ -28,21 +33,23 @@ OPTIONAL { return OPTIONAL; }
|
|||||||
BEGIN { return TBEGIN; }
|
BEGIN { return TBEGIN; }
|
||||||
END { return END; }
|
END { return END; }
|
||||||
DEFINITIONS { return DEFINITIONS; }
|
DEFINITIONS { return DEFINITIONS; }
|
||||||
[][|{},()] { return *yytext; }
|
,|\{|\}|\(|\)|\[|\]|\| { return *yytext; }
|
||||||
::= { return EEQUAL; }
|
::= { return EEQUAL; }
|
||||||
--[^\n]*\n { ; }
|
--[^\n]*\n { ; }
|
||||||
-?[0-9]+ { yylval.constant = atoi(yytext); return CONSTANT; }
|
-?[0-9]+ { yylval.constant = atoi(yytext); return CONSTANT; }
|
||||||
[A-Za-z][-A-Za-z0-9_]* { yylval.name = strdup (yytext); return IDENTIFIER; }
|
[A-Za-z][-A-Za-z0-9_]* { yylval.name = strdup (yytext); return IDENTIFIER; }
|
||||||
[ \t] ;
|
[ \t] ;
|
||||||
\n { lineno++; }
|
\n { lineno++; }
|
||||||
. { fprintf(stderr, "Ignoring char(%c)\n", *yytext); }
|
. { error_message("Ignoring char(%c)\n", *yytext); }
|
||||||
%%
|
%%
|
||||||
|
|
||||||
|
#ifndef yywrap /* XXX */
|
||||||
int
|
int
|
||||||
yywrap ()
|
yywrap ()
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
error_message (char *format, ...)
|
error_message (char *format, ...)
|
||||||
|
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
static Type *new_type (Typetype t);
|
static Type *new_type (Typetype t);
|
||||||
void yyerror (char *);
|
void yyerror (char *);
|
||||||
|
|
||||||
|
char *strdup(char *);
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%union {
|
%union {
|
||||||
@@ -167,6 +169,7 @@ new_type (Typetype tt)
|
|||||||
t->members = NULL;
|
t->members = NULL;
|
||||||
t->subtype = NULL;
|
t->subtype = NULL;
|
||||||
t->symbol = NULL;
|
t->symbol = NULL;
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -442,16 +442,16 @@ krb5_cc_read_cred (int fd,
|
|||||||
int8_t dummy8;
|
int8_t dummy8;
|
||||||
int32_t dummy32;
|
int32_t dummy32;
|
||||||
|
|
||||||
return ret_principal (fd, &creds->client)
|
return ret_principal (fd, &creds->client) ||
|
||||||
|| ret_principal (fd, &creds->server)
|
ret_principal (fd, &creds->server) ||
|
||||||
|| ret_keyblock (fd, &creds->session)
|
ret_keyblock (fd, &creds->session) ||
|
||||||
|| ret_times (fd, &creds->times)
|
ret_times (fd, &creds->times) ||
|
||||||
|| ret_int8 (fd, &dummy8)
|
ret_int8 (fd, &dummy8) ||
|
||||||
|| ret_int32 (fd, &dummy32)
|
ret_int32 (fd, &dummy32) ||
|
||||||
|| ret_addrs (fd, &creds->addresses)
|
ret_addrs (fd, &creds->addresses) ||
|
||||||
|| ret_authdata (fd, &creds->authdata)
|
ret_authdata (fd, &creds->authdata) ||
|
||||||
|| ret_ticket (fd, &creds->ticket)
|
ret_ticket (fd, &creds->ticket) ||
|
||||||
|| ret_ticket (fd, &creds->second_ticket);
|
ret_ticket (fd, &creds->second_ticket);
|
||||||
}
|
}
|
||||||
|
|
||||||
krb5_error_code
|
krb5_error_code
|
||||||
|
@@ -1,5 +1,11 @@
|
|||||||
#include "krb5_locl.h"
|
#include "krb5_locl.h"
|
||||||
|
|
||||||
|
/* XXX */
|
||||||
|
|
||||||
|
#ifdef sun
|
||||||
|
#define memmove(a,b,c) bcopy(b,a,c)
|
||||||
|
#endif
|
||||||
|
|
||||||
krb5_error_code
|
krb5_error_code
|
||||||
krb5_init_context(krb5_context *context)
|
krb5_init_context(krb5_context *context)
|
||||||
{
|
{
|
||||||
|
@@ -1,5 +1,10 @@
|
|||||||
#include "krb5_locl.h"
|
#include "krb5_locl.h"
|
||||||
|
|
||||||
|
/* XXX */
|
||||||
|
|
||||||
|
#ifdef sun
|
||||||
|
#define memmove(a,b,c) bcopy(b,a,c)
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
krb5_data_free(krb5_data *p)
|
krb5_data_free(krb5_data *p)
|
||||||
|
@@ -22,17 +22,17 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* types */
|
/* types */
|
||||||
typedef int32_t krb5_int32;
|
typedef int int32_t;
|
||||||
typedef int16_t krb5_int16;
|
typedef short int16_t;
|
||||||
typedef int8_t krb5_int8;
|
typedef char int8_t;
|
||||||
|
|
||||||
typedef unsigned int krb5_uint32;
|
typedef unsigned int u_int32_t;
|
||||||
typedef unsigned short krb5_uint16;
|
typedef unsigned short u_int16_t;
|
||||||
typedef unsigned char krb5_uint8;
|
typedef unsigned char u_int8_t;
|
||||||
|
|
||||||
typedef int krb5_boolean;
|
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{
|
typedef struct krb5_auth_context{
|
||||||
krb5_int32 flags;
|
int32_t flags;
|
||||||
krb5_cksumtype cksumtype;
|
krb5_cksumtype cksumtype;
|
||||||
|
|
||||||
krb5_address local_address;
|
krb5_address local_address;
|
||||||
@@ -205,8 +205,8 @@ typedef struct krb5_auth_context{
|
|||||||
krb5_keyblock local_subkey;
|
krb5_keyblock local_subkey;
|
||||||
krb5_keyblock remote_subkey;
|
krb5_keyblock remote_subkey;
|
||||||
|
|
||||||
krb5_int32 local_seqnumber;
|
int32_t local_seqnumber;
|
||||||
krb5_int32 remote_seqnumber;
|
int32_t remote_seqnumber;
|
||||||
|
|
||||||
krb5_authenticator authenticator;
|
krb5_authenticator authenticator;
|
||||||
|
|
||||||
@@ -217,7 +217,7 @@ typedef struct krb5_auth_context{
|
|||||||
}krb5_auth_context;
|
}krb5_auth_context;
|
||||||
|
|
||||||
|
|
||||||
typedef krb5_uint32 krb5_flags;
|
typedef u_int32_t krb5_flags;
|
||||||
|
|
||||||
#include <foo.h>
|
#include <foo.h>
|
||||||
|
|
||||||
|
@@ -2,12 +2,18 @@
|
|||||||
|
|
||||||
RCSID("$Id$");
|
RCSID("$Id$");
|
||||||
|
|
||||||
|
/* XXX */
|
||||||
|
|
||||||
|
#ifdef sun
|
||||||
|
#define memmove(a,b,c) bcopy(b,a,c)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Public principal handling functions */
|
/* Public principal handling functions */
|
||||||
|
|
||||||
void
|
void
|
||||||
krb5_free_principal(krb5_principal p)
|
krb5_free_principal(krb5_principal p)
|
||||||
{
|
{
|
||||||
krb5_principal_free(p);
|
krb5_principal_free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
krb5_error_code
|
krb5_error_code
|
||||||
@@ -16,117 +22,117 @@ krb5_parse_name(krb5_context context,
|
|||||||
krb5_principal *principal)
|
krb5_principal *principal)
|
||||||
{
|
{
|
||||||
|
|
||||||
krb5_data *comp;
|
krb5_data *comp;
|
||||||
int ncomp;
|
int ncomp;
|
||||||
krb5_data realm;
|
krb5_data realm;
|
||||||
|
|
||||||
char *p;
|
char *p;
|
||||||
char *q;
|
char *q;
|
||||||
char *s;
|
char *s;
|
||||||
char *start;
|
char *start;
|
||||||
|
|
||||||
int n;
|
int n;
|
||||||
char c;
|
char c;
|
||||||
int got_realm = 0;
|
int got_realm = 0;
|
||||||
|
|
||||||
/* count number of component */
|
/* count number of component */
|
||||||
ncomp = 1;
|
ncomp = 1;
|
||||||
for(p = (char*)name; *p; p++){
|
for(p = (char*)name; *p; p++){
|
||||||
if(*p=='\\'){
|
if(*p=='\\'){
|
||||||
if(!p[1])
|
if(!p[1])
|
||||||
return KRB5_PARSE_MALFORMED;
|
return KRB5_PARSE_MALFORMED;
|
||||||
p++;
|
p++;
|
||||||
} else if(*p == '/')
|
} else if(*p == '/')
|
||||||
ncomp++;
|
ncomp++;
|
||||||
}
|
}
|
||||||
comp = ALLOC(ncomp, krb5_data);
|
comp = ALLOC(ncomp, krb5_data);
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
start = q = p = s = strdup(name);
|
start = q = p = s = strdup(name);
|
||||||
while(*p){
|
while(*p){
|
||||||
c = *p++;
|
c = *p++;
|
||||||
if(c == '\\'){
|
if(c == '\\'){
|
||||||
c = *p++;
|
c = *p++;
|
||||||
if(c == 'n')
|
if(c == 'n')
|
||||||
c = '\n';
|
c = '\n';
|
||||||
else if(c == 't')
|
else if(c == 't')
|
||||||
c = '\t';
|
c = '\t';
|
||||||
else if(c == 'b')
|
else if(c == 'b')
|
||||||
c = '\b';
|
c = '\b';
|
||||||
else if(c == '0')
|
else if(c == '0')
|
||||||
c = '\0';
|
c = '\0';
|
||||||
}else if(c == '/' || c == '@'){
|
}else if(c == '/' || c == '@'){
|
||||||
if(got_realm){
|
if(got_realm){
|
||||||
while(n>0)
|
while(n>0)
|
||||||
free(comp[--n].data);
|
free(comp[--n].data);
|
||||||
free(comp);
|
free(comp);
|
||||||
free(s);
|
free(s);
|
||||||
return KRB5_PARSE_MALFORMED;
|
return KRB5_PARSE_MALFORMED;
|
||||||
}else{
|
}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].length = q - start;
|
||||||
comp[n].data = (krb5_pointer)malloc(comp[n].length);
|
comp[n].data = (krb5_pointer)malloc(comp[n].length);
|
||||||
memmove(comp[n].data, start, comp[n].length);
|
memmove(comp[n].data, start, comp[n].length);
|
||||||
n++;
|
n++;
|
||||||
}
|
|
||||||
if(c == '@')
|
|
||||||
got_realm = 1;
|
|
||||||
start = q;
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
if(got_realm && (c == ':' || c == '/' || c == '\0')){
|
*principal = ALLOC(1, krb5_principal_data);
|
||||||
while(n>0)
|
(*principal)->type = KRB5_NT_PRINCIPAL;
|
||||||
free(comp[--n].data);
|
(*principal)->realm = realm;
|
||||||
free(comp);
|
(*principal)->comp = comp;
|
||||||
free(s);
|
(*principal)->ncomp = n;
|
||||||
return KRB5_PARSE_MALFORMED;
|
free(s);
|
||||||
}
|
return 0;
|
||||||
*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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void quote_string(char *s, int len, char **out)
|
static void quote_string(char *s, int len, char **out)
|
||||||
{
|
{
|
||||||
char *q;
|
char *q;
|
||||||
char *p = *out;
|
char *p = *out;
|
||||||
int c=0;
|
int c=0;
|
||||||
for(q = s; q < s + len; q++){
|
for(q = s; q < s + len; q++){
|
||||||
if(*q == '\n')
|
if(*q == '\n')
|
||||||
c = 'n';
|
c = 'n';
|
||||||
else if(*q == '\t')
|
else if(*q == '\t')
|
||||||
c = 't';
|
c = 't';
|
||||||
else if(*q == '\b')
|
else if(*q == '\b')
|
||||||
c = 'b';
|
c = 'b';
|
||||||
else if(*q == '\0')
|
else if(*q == '\0')
|
||||||
c = '0';
|
c = '0';
|
||||||
else if(*q == '/')
|
else if(*q == '/')
|
||||||
c='/';
|
c='/';
|
||||||
else if(*q == '@')
|
else if(*q == '@')
|
||||||
c = '@';
|
c = '@';
|
||||||
if(c){
|
if(c){
|
||||||
*p++ = '\\';
|
*p++ = '\\';
|
||||||
*p++ = c;
|
*p++ = c;
|
||||||
c = 0;
|
c = 0;
|
||||||
}else
|
}else
|
||||||
*p++ = *q;
|
*p++ = *q;
|
||||||
}
|
}
|
||||||
*out = p;
|
*out = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -135,25 +141,25 @@ krb5_unparse_name(krb5_context context,
|
|||||||
krb5_principal principal,
|
krb5_principal principal,
|
||||||
char **name)
|
char **name)
|
||||||
{
|
{
|
||||||
int size = 0;
|
int size = 0;
|
||||||
char *p;
|
char *p;
|
||||||
char *s;
|
char *s;
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < principal->ncomp; i++)
|
for(i = 0; i < principal->ncomp; i++)
|
||||||
size += 2*principal->comp[i].length + 1;
|
size += 2*principal->comp[i].length + 1;
|
||||||
size += 2*principal->realm.length + 1;
|
size += 2*principal->realm.length + 1;
|
||||||
s = ALLOC(size, char);
|
s = ALLOC(size, char);
|
||||||
p = s;
|
p = s;
|
||||||
for(i = 0; i < principal->ncomp; i++){
|
for(i = 0; i < principal->ncomp; i++){
|
||||||
if(i) *p++ = '/';
|
if(i) *p++ = '/';
|
||||||
quote_string(principal->comp[i].data, principal->comp[i].length, &p);
|
quote_string(principal->comp[i].data, principal->comp[i].length, &p);
|
||||||
}
|
}
|
||||||
*p++ = '@';
|
*p++ = '@';
|
||||||
quote_string(principal->realm.data, principal->realm.length, &p);
|
quote_string(principal->realm.data, principal->realm.length, &p);
|
||||||
*p = 0;
|
*p = 0;
|
||||||
*name = strdup(s);
|
*name = strdup(s);
|
||||||
free(s);
|
free(s);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -163,8 +169,8 @@ krb5_unparse_name_ext(krb5_context context,
|
|||||||
char **name,
|
char **name,
|
||||||
size_t *size)
|
size_t *size)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "krb5_unparse_name_ext: not implemented\n");
|
fprintf(stderr, "krb5_unparse_name_ext: not implemented\n");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -172,7 +178,7 @@ krb5_data*
|
|||||||
krb5_princ_realm(krb5_context context,
|
krb5_princ_realm(krb5_context context,
|
||||||
krb5_principal principal)
|
krb5_principal principal)
|
||||||
{
|
{
|
||||||
return &principal->realm;
|
return &principal->realm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -181,7 +187,7 @@ krb5_princ_set_realm(krb5_context context,
|
|||||||
krb5_principal principal,
|
krb5_principal principal,
|
||||||
krb5_data *realm)
|
krb5_data *realm)
|
||||||
{
|
{
|
||||||
principal->realm = *realm;
|
principal->realm = *realm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -192,31 +198,31 @@ krb5_build_principal(krb5_context context,
|
|||||||
const char *realm,
|
const char *realm,
|
||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
krb5_error_code ret;
|
krb5_error_code ret;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, realm);
|
va_start(ap, realm);
|
||||||
ret = krb5_build_principal_va(context, principal, rlen, realm, ap);
|
ret = krb5_build_principal_va(context, principal, rlen, realm, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
krb5_error_code
|
krb5_error_code
|
||||||
krb5_principal_set_component(krb5_principal p, int n, void *data, size_t len)
|
krb5_principal_set_component(krb5_principal p, int n, void *data, size_t len)
|
||||||
{
|
{
|
||||||
krb5_data *tmp;
|
krb5_data *tmp;
|
||||||
if(p->ncomp <= n){
|
if(p->ncomp <= n){
|
||||||
int s = n + 10;
|
int s = n + 10;
|
||||||
if(p->comp)
|
if(p->comp)
|
||||||
tmp = (krb5_data*)realloc(p->comp, s * sizeof(krb5_data));
|
tmp = (krb5_data*)realloc(p->comp, s * sizeof(krb5_data));
|
||||||
else
|
else
|
||||||
tmp = ALLOC(s, krb5_data);
|
tmp = ALLOC(s, krb5_data);
|
||||||
if(!tmp)
|
if(!tmp)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
p->comp = tmp;
|
p->comp = tmp;
|
||||||
p->ncomp = s;
|
p->ncomp = s;
|
||||||
}
|
}
|
||||||
krb5_data_copy(&p->comp[n], data, len);
|
krb5_data_copy(&p->comp[n], data, len);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -227,30 +233,30 @@ krb5_build_principal_va(krb5_context context,
|
|||||||
const char *realm,
|
const char *realm,
|
||||||
va_list ap)
|
va_list ap)
|
||||||
{
|
{
|
||||||
krb5_principal p;
|
krb5_principal p;
|
||||||
int n;
|
int n;
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
if(krb5_principal_alloc(&p))
|
if(krb5_principal_alloc(&p))
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
p->type = KRB5_NT_PRINCIPAL;
|
p->type = KRB5_NT_PRINCIPAL;
|
||||||
|
|
||||||
if(krb5_data_copy(&p->realm, (void*)realm, rlen)){
|
if(krb5_data_copy(&p->realm, (void*)realm, rlen)){
|
||||||
free(p);
|
free(p);
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
while(1){
|
while(1){
|
||||||
s = va_arg(ap, char*);
|
s = va_arg(ap, char*);
|
||||||
if(s == NULL)
|
if(s == NULL)
|
||||||
break;
|
break;
|
||||||
krb5_principal_set_component(p, n, s, strlen(s));
|
krb5_principal_set_component(p, n, s, strlen(s));
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
p->ncomp = n;
|
p->ncomp = n;
|
||||||
*principal = p;
|
*principal = p;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -261,8 +267,8 @@ krb5_build_principal_ext(krb5_context context,
|
|||||||
const char *realm,
|
const char *realm,
|
||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "krb5_build_principal_ext: not implemented\n");
|
fprintf(stderr, "krb5_build_principal_ext: not implemented\n");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -271,32 +277,32 @@ krb5_copy_principal(krb5_context context,
|
|||||||
krb5_const_principal inprinc,
|
krb5_const_principal inprinc,
|
||||||
krb5_principal *outprinc)
|
krb5_principal *outprinc)
|
||||||
{
|
{
|
||||||
krb5_principal p;
|
krb5_principal p;
|
||||||
int i;
|
int i;
|
||||||
if(krb5_principal_alloc(&p))
|
if(krb5_principal_alloc(&p))
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
p->type = inprinc->type;
|
p->type = inprinc->type;
|
||||||
if(krb5_data_copy(&p->realm, inprinc->realm.data, inprinc->realm.length)){
|
if(krb5_data_copy(&p->realm, inprinc->realm.data, inprinc->realm.length)){
|
||||||
krb5_free_principal(p);
|
krb5_free_principal(p);
|
||||||
return ENOMEM;
|
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;
|
|
||||||
}
|
}
|
||||||
p->ncomp = i+1;
|
p->comp = ALLOC(inprinc->ncomp, krb5_data);
|
||||||
}
|
if(!p->comp){
|
||||||
*outprinc = p;
|
krb5_free_principal(p);
|
||||||
return 0;
|
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 princ1,
|
||||||
krb5_const_principal princ2)
|
krb5_const_principal princ2)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
if(!krb5_realm_compare(context, princ1, princ2))
|
if(!krb5_realm_compare(context, princ1, princ2))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if(princ1->ncomp != princ2->ncomp)
|
if(princ1->ncomp != princ2->ncomp)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
for(i=0; i<princ1->ncomp; i++){
|
for(i=0; i<princ1->ncomp; i++){
|
||||||
if(princ1->comp[i].length != princ2->comp[i].length)
|
if(princ1->comp[i].length != princ2->comp[i].length)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if(memcmp(princ1->comp[i].data, princ2->comp[i].data,
|
if(memcmp(princ1->comp[i].data, princ2->comp[i].data,
|
||||||
princ1->comp[i].length))
|
princ1->comp[i].length))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -326,11 +332,11 @@ krb5_realm_compare(krb5_context context,
|
|||||||
krb5_const_principal princ1,
|
krb5_const_principal princ1,
|
||||||
krb5_const_principal princ2)
|
krb5_const_principal princ2)
|
||||||
{
|
{
|
||||||
if(princ1->realm.length != princ2->realm.length)
|
if(princ1->realm.length != princ2->realm.length)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if(memcmp(princ1->realm.data, princ2->realm.data, princ1->realm.length))
|
if(memcmp(princ1->realm.data, princ2->realm.data, princ1->realm.length))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -341,10 +347,10 @@ krb5_425_conv_principal(krb5_context context,
|
|||||||
const char *realm,
|
const char *realm,
|
||||||
krb5_principal *princ)
|
krb5_principal *princ)
|
||||||
{
|
{
|
||||||
if(!strcmp(name, "rcmd"))
|
if(!strcmp(name, "rcmd"))
|
||||||
name = "host";
|
name = "host";
|
||||||
return krb5_build_principal(context, princ,
|
return krb5_build_principal(context, princ,
|
||||||
strlen(realm), realm, name, instance, 0);
|
strlen(realm), realm, name, instance, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -10,7 +10,7 @@ send_and_recv (int fd,
|
|||||||
struct fd_set fdset;
|
struct fd_set fdset;
|
||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
int ret;
|
int ret;
|
||||||
long nbytes;
|
int nbytes;
|
||||||
|
|
||||||
if (sendto (fd, send->data, send->length, 0,
|
if (sendto (fd, send->data, send->length, 0,
|
||||||
(struct sockaddr *)addr, sizeof(*addr)) < 0)
|
(struct sockaddr *)addr, sizeof(*addr)) < 0)
|
||||||
|
430
principal.c
430
principal.c
@@ -2,12 +2,18 @@
|
|||||||
|
|
||||||
RCSID("$Id$");
|
RCSID("$Id$");
|
||||||
|
|
||||||
|
/* XXX */
|
||||||
|
|
||||||
|
#ifdef sun
|
||||||
|
#define memmove(a,b,c) bcopy(b,a,c)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Public principal handling functions */
|
/* Public principal handling functions */
|
||||||
|
|
||||||
void
|
void
|
||||||
krb5_free_principal(krb5_principal p)
|
krb5_free_principal(krb5_principal p)
|
||||||
{
|
{
|
||||||
krb5_principal_free(p);
|
krb5_principal_free(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
krb5_error_code
|
krb5_error_code
|
||||||
@@ -16,117 +22,117 @@ krb5_parse_name(krb5_context context,
|
|||||||
krb5_principal *principal)
|
krb5_principal *principal)
|
||||||
{
|
{
|
||||||
|
|
||||||
krb5_data *comp;
|
krb5_data *comp;
|
||||||
int ncomp;
|
int ncomp;
|
||||||
krb5_data realm;
|
krb5_data realm;
|
||||||
|
|
||||||
char *p;
|
char *p;
|
||||||
char *q;
|
char *q;
|
||||||
char *s;
|
char *s;
|
||||||
char *start;
|
char *start;
|
||||||
|
|
||||||
int n;
|
int n;
|
||||||
char c;
|
char c;
|
||||||
int got_realm = 0;
|
int got_realm = 0;
|
||||||
|
|
||||||
/* count number of component */
|
/* count number of component */
|
||||||
ncomp = 1;
|
ncomp = 1;
|
||||||
for(p = (char*)name; *p; p++){
|
for(p = (char*)name; *p; p++){
|
||||||
if(*p=='\\'){
|
if(*p=='\\'){
|
||||||
if(!p[1])
|
if(!p[1])
|
||||||
return KRB5_PARSE_MALFORMED;
|
return KRB5_PARSE_MALFORMED;
|
||||||
p++;
|
p++;
|
||||||
} else if(*p == '/')
|
} else if(*p == '/')
|
||||||
ncomp++;
|
ncomp++;
|
||||||
}
|
}
|
||||||
comp = ALLOC(ncomp, krb5_data);
|
comp = ALLOC(ncomp, krb5_data);
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
start = q = p = s = strdup(name);
|
start = q = p = s = strdup(name);
|
||||||
while(*p){
|
while(*p){
|
||||||
c = *p++;
|
c = *p++;
|
||||||
if(c == '\\'){
|
if(c == '\\'){
|
||||||
c = *p++;
|
c = *p++;
|
||||||
if(c == 'n')
|
if(c == 'n')
|
||||||
c = '\n';
|
c = '\n';
|
||||||
else if(c == 't')
|
else if(c == 't')
|
||||||
c = '\t';
|
c = '\t';
|
||||||
else if(c == 'b')
|
else if(c == 'b')
|
||||||
c = '\b';
|
c = '\b';
|
||||||
else if(c == '0')
|
else if(c == '0')
|
||||||
c = '\0';
|
c = '\0';
|
||||||
}else if(c == '/' || c == '@'){
|
}else if(c == '/' || c == '@'){
|
||||||
if(got_realm){
|
if(got_realm){
|
||||||
while(n>0)
|
while(n>0)
|
||||||
free(comp[--n].data);
|
free(comp[--n].data);
|
||||||
free(comp);
|
free(comp);
|
||||||
free(s);
|
free(s);
|
||||||
return KRB5_PARSE_MALFORMED;
|
return KRB5_PARSE_MALFORMED;
|
||||||
}else{
|
}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].length = q - start;
|
||||||
comp[n].data = (krb5_pointer)malloc(comp[n].length);
|
comp[n].data = (krb5_pointer)malloc(comp[n].length);
|
||||||
memmove(comp[n].data, start, comp[n].length);
|
memmove(comp[n].data, start, comp[n].length);
|
||||||
n++;
|
n++;
|
||||||
}
|
|
||||||
if(c == '@')
|
|
||||||
got_realm = 1;
|
|
||||||
start = q;
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
if(got_realm && (c == ':' || c == '/' || c == '\0')){
|
*principal = ALLOC(1, krb5_principal_data);
|
||||||
while(n>0)
|
(*principal)->type = KRB5_NT_PRINCIPAL;
|
||||||
free(comp[--n].data);
|
(*principal)->realm = realm;
|
||||||
free(comp);
|
(*principal)->comp = comp;
|
||||||
free(s);
|
(*principal)->ncomp = n;
|
||||||
return KRB5_PARSE_MALFORMED;
|
free(s);
|
||||||
}
|
return 0;
|
||||||
*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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void quote_string(char *s, int len, char **out)
|
static void quote_string(char *s, int len, char **out)
|
||||||
{
|
{
|
||||||
char *q;
|
char *q;
|
||||||
char *p = *out;
|
char *p = *out;
|
||||||
int c=0;
|
int c=0;
|
||||||
for(q = s; q < s + len; q++){
|
for(q = s; q < s + len; q++){
|
||||||
if(*q == '\n')
|
if(*q == '\n')
|
||||||
c = 'n';
|
c = 'n';
|
||||||
else if(*q == '\t')
|
else if(*q == '\t')
|
||||||
c = 't';
|
c = 't';
|
||||||
else if(*q == '\b')
|
else if(*q == '\b')
|
||||||
c = 'b';
|
c = 'b';
|
||||||
else if(*q == '\0')
|
else if(*q == '\0')
|
||||||
c = '0';
|
c = '0';
|
||||||
else if(*q == '/')
|
else if(*q == '/')
|
||||||
c='/';
|
c='/';
|
||||||
else if(*q == '@')
|
else if(*q == '@')
|
||||||
c = '@';
|
c = '@';
|
||||||
if(c){
|
if(c){
|
||||||
*p++ = '\\';
|
*p++ = '\\';
|
||||||
*p++ = c;
|
*p++ = c;
|
||||||
c = 0;
|
c = 0;
|
||||||
}else
|
}else
|
||||||
*p++ = *q;
|
*p++ = *q;
|
||||||
}
|
}
|
||||||
*out = p;
|
*out = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -135,25 +141,25 @@ krb5_unparse_name(krb5_context context,
|
|||||||
krb5_principal principal,
|
krb5_principal principal,
|
||||||
char **name)
|
char **name)
|
||||||
{
|
{
|
||||||
int size = 0;
|
int size = 0;
|
||||||
char *p;
|
char *p;
|
||||||
char *s;
|
char *s;
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i < principal->ncomp; i++)
|
for(i = 0; i < principal->ncomp; i++)
|
||||||
size += 2*principal->comp[i].length + 1;
|
size += 2*principal->comp[i].length + 1;
|
||||||
size += 2*principal->realm.length + 1;
|
size += 2*principal->realm.length + 1;
|
||||||
s = ALLOC(size, char);
|
s = ALLOC(size, char);
|
||||||
p = s;
|
p = s;
|
||||||
for(i = 0; i < principal->ncomp; i++){
|
for(i = 0; i < principal->ncomp; i++){
|
||||||
if(i) *p++ = '/';
|
if(i) *p++ = '/';
|
||||||
quote_string(principal->comp[i].data, principal->comp[i].length, &p);
|
quote_string(principal->comp[i].data, principal->comp[i].length, &p);
|
||||||
}
|
}
|
||||||
*p++ = '@';
|
*p++ = '@';
|
||||||
quote_string(principal->realm.data, principal->realm.length, &p);
|
quote_string(principal->realm.data, principal->realm.length, &p);
|
||||||
*p = 0;
|
*p = 0;
|
||||||
*name = strdup(s);
|
*name = strdup(s);
|
||||||
free(s);
|
free(s);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -163,8 +169,8 @@ krb5_unparse_name_ext(krb5_context context,
|
|||||||
char **name,
|
char **name,
|
||||||
size_t *size)
|
size_t *size)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "krb5_unparse_name_ext: not implemented\n");
|
fprintf(stderr, "krb5_unparse_name_ext: not implemented\n");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -172,7 +178,7 @@ krb5_data*
|
|||||||
krb5_princ_realm(krb5_context context,
|
krb5_princ_realm(krb5_context context,
|
||||||
krb5_principal principal)
|
krb5_principal principal)
|
||||||
{
|
{
|
||||||
return &principal->realm;
|
return &principal->realm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -181,7 +187,7 @@ krb5_princ_set_realm(krb5_context context,
|
|||||||
krb5_principal principal,
|
krb5_principal principal,
|
||||||
krb5_data *realm)
|
krb5_data *realm)
|
||||||
{
|
{
|
||||||
principal->realm = *realm;
|
principal->realm = *realm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -192,31 +198,31 @@ krb5_build_principal(krb5_context context,
|
|||||||
const char *realm,
|
const char *realm,
|
||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
krb5_error_code ret;
|
krb5_error_code ret;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, realm);
|
va_start(ap, realm);
|
||||||
ret = krb5_build_principal_va(context, principal, rlen, realm, ap);
|
ret = krb5_build_principal_va(context, principal, rlen, realm, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
krb5_error_code
|
krb5_error_code
|
||||||
krb5_principal_set_component(krb5_principal p, int n, void *data, size_t len)
|
krb5_principal_set_component(krb5_principal p, int n, void *data, size_t len)
|
||||||
{
|
{
|
||||||
krb5_data *tmp;
|
krb5_data *tmp;
|
||||||
if(p->ncomp <= n){
|
if(p->ncomp <= n){
|
||||||
int s = n + 10;
|
int s = n + 10;
|
||||||
if(p->comp)
|
if(p->comp)
|
||||||
tmp = (krb5_data*)realloc(p->comp, s * sizeof(krb5_data));
|
tmp = (krb5_data*)realloc(p->comp, s * sizeof(krb5_data));
|
||||||
else
|
else
|
||||||
tmp = ALLOC(s, krb5_data);
|
tmp = ALLOC(s, krb5_data);
|
||||||
if(!tmp)
|
if(!tmp)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
p->comp = tmp;
|
p->comp = tmp;
|
||||||
p->ncomp = s;
|
p->ncomp = s;
|
||||||
}
|
}
|
||||||
krb5_data_copy(&p->comp[n], data, len);
|
krb5_data_copy(&p->comp[n], data, len);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -227,30 +233,30 @@ krb5_build_principal_va(krb5_context context,
|
|||||||
const char *realm,
|
const char *realm,
|
||||||
va_list ap)
|
va_list ap)
|
||||||
{
|
{
|
||||||
krb5_principal p;
|
krb5_principal p;
|
||||||
int n;
|
int n;
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
if(krb5_principal_alloc(&p))
|
if(krb5_principal_alloc(&p))
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
p->type = KRB5_NT_PRINCIPAL;
|
p->type = KRB5_NT_PRINCIPAL;
|
||||||
|
|
||||||
if(krb5_data_copy(&p->realm, (void*)realm, rlen)){
|
if(krb5_data_copy(&p->realm, (void*)realm, rlen)){
|
||||||
free(p);
|
free(p);
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = 0;
|
n = 0;
|
||||||
while(1){
|
while(1){
|
||||||
s = va_arg(ap, char*);
|
s = va_arg(ap, char*);
|
||||||
if(s == NULL)
|
if(s == NULL)
|
||||||
break;
|
break;
|
||||||
krb5_principal_set_component(p, n, s, strlen(s));
|
krb5_principal_set_component(p, n, s, strlen(s));
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
p->ncomp = n;
|
p->ncomp = n;
|
||||||
*principal = p;
|
*principal = p;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -261,8 +267,8 @@ krb5_build_principal_ext(krb5_context context,
|
|||||||
const char *realm,
|
const char *realm,
|
||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "krb5_build_principal_ext: not implemented\n");
|
fprintf(stderr, "krb5_build_principal_ext: not implemented\n");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -271,32 +277,32 @@ krb5_copy_principal(krb5_context context,
|
|||||||
krb5_const_principal inprinc,
|
krb5_const_principal inprinc,
|
||||||
krb5_principal *outprinc)
|
krb5_principal *outprinc)
|
||||||
{
|
{
|
||||||
krb5_principal p;
|
krb5_principal p;
|
||||||
int i;
|
int i;
|
||||||
if(krb5_principal_alloc(&p))
|
if(krb5_principal_alloc(&p))
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
p->type = inprinc->type;
|
p->type = inprinc->type;
|
||||||
if(krb5_data_copy(&p->realm, inprinc->realm.data, inprinc->realm.length)){
|
if(krb5_data_copy(&p->realm, inprinc->realm.data, inprinc->realm.length)){
|
||||||
krb5_free_principal(p);
|
krb5_free_principal(p);
|
||||||
return ENOMEM;
|
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;
|
|
||||||
}
|
}
|
||||||
p->ncomp = i+1;
|
p->comp = ALLOC(inprinc->ncomp, krb5_data);
|
||||||
}
|
if(!p->comp){
|
||||||
*outprinc = p;
|
krb5_free_principal(p);
|
||||||
return 0;
|
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 princ1,
|
||||||
krb5_const_principal princ2)
|
krb5_const_principal princ2)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
if(!krb5_realm_compare(context, princ1, princ2))
|
if(!krb5_realm_compare(context, princ1, princ2))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if(princ1->ncomp != princ2->ncomp)
|
if(princ1->ncomp != princ2->ncomp)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
for(i=0; i<princ1->ncomp; i++){
|
for(i=0; i<princ1->ncomp; i++){
|
||||||
if(princ1->comp[i].length != princ2->comp[i].length)
|
if(princ1->comp[i].length != princ2->comp[i].length)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if(memcmp(princ1->comp[i].data, princ2->comp[i].data,
|
if(memcmp(princ1->comp[i].data, princ2->comp[i].data,
|
||||||
princ1->comp[i].length))
|
princ1->comp[i].length))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -326,11 +332,11 @@ krb5_realm_compare(krb5_context context,
|
|||||||
krb5_const_principal princ1,
|
krb5_const_principal princ1,
|
||||||
krb5_const_principal princ2)
|
krb5_const_principal princ2)
|
||||||
{
|
{
|
||||||
if(princ1->realm.length != princ2->realm.length)
|
if(princ1->realm.length != princ2->realm.length)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if(memcmp(princ1->realm.data, princ2->realm.data, princ1->realm.length))
|
if(memcmp(princ1->realm.data, princ2->realm.data, princ1->realm.length))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -341,10 +347,10 @@ krb5_425_conv_principal(krb5_context context,
|
|||||||
const char *realm,
|
const char *realm,
|
||||||
krb5_principal *princ)
|
krb5_principal *princ)
|
||||||
{
|
{
|
||||||
if(!strcmp(name, "rcmd"))
|
if(!strcmp(name, "rcmd"))
|
||||||
name = "host";
|
name = "host";
|
||||||
return krb5_build_principal(context, princ,
|
return krb5_build_principal(context, princ,
|
||||||
strlen(realm), realm, name, instance, 0);
|
strlen(realm), realm, name, instance, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -10,7 +10,7 @@ send_and_recv (int fd,
|
|||||||
struct fd_set fdset;
|
struct fd_set fdset;
|
||||||
struct timeval timeout;
|
struct timeval timeout;
|
||||||
int ret;
|
int ret;
|
||||||
long nbytes;
|
int nbytes;
|
||||||
|
|
||||||
if (sendto (fd, send->data, send->length, 0,
|
if (sendto (fd, send->data, send->length, 0,
|
||||||
(struct sockaddr *)addr, sizeof(*addr)) < 0)
|
(struct sockaddr *)addr, sizeof(*addr)) < 0)
|
||||||
|
@@ -1,5 +1,11 @@
|
|||||||
#include "krb5_locl.h"
|
#include "krb5_locl.h"
|
||||||
|
|
||||||
|
/* XXX */
|
||||||
|
|
||||||
|
#ifdef sun
|
||||||
|
#define memmove(a,b,c) bcopy(b,a,c)
|
||||||
|
#endif
|
||||||
|
|
||||||
static void reverse(unsigned char *p)
|
static void reverse(unsigned char *p)
|
||||||
{
|
{
|
||||||
unsigned char tmp[8];
|
unsigned char tmp[8];
|
||||||
|
Reference in New Issue
Block a user