From: John Kohl Date: Tue, 12 Mar 1991 16:48:58 +0000 (+0000) Subject: pepsy changes X-Git-Tag: krb5-1.0-alpha4~91 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d52d527df4698638d0e6b4e1228de3e40b9ccb3b;p=krb5.git pepsy changes git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1881 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/config/Project.tmpl b/src/config/Project.tmpl index ab3ffc1b8..dd5a03b7c 100644 --- a/src/config/Project.tmpl +++ b/src/config/Project.tmpl @@ -30,17 +30,12 @@ #ifndef ComErrLib #define ComErrLib -lcom_err #endif -#ifndef PosyFlags -#define PosyFlags -f -h2 -a -s +#ifndef PepsyFlags +#define PepsyFlags -f -h0 -a -s +/* -h2 breaks pepsy, ARRGH! */ #endif -#ifndef PepyFlags -#define PepyFlags -a PY_advise -P -s -r -#endif -#ifndef PepyCmd -#define PepyCmd pepy -#endif -#ifndef PosyCmd -#define PosyCmd posy +#ifndef PepsyCmd +#define PepsyCmd pepsy #endif #ifndef ArAddCmd #define ArAddCmd ar cruv @@ -59,12 +54,14 @@ #define DesDefines YouMustFigureOutYourDesDefines #endif -#ifndef PepyPosyRules -#define PepyPosyRules() @@\ +#ifndef PepsyTarget +#define PepsyTarget(basename) @@\ .SUFFIXES: .py @@\ -.py.c: @@\ - $(PEPY) $(PYFLAGS) $< -#endif /* PepyPosyRules */ +basename/**/_tables.c: basename-asn.py @@\ + @echo '***Ignore the warning message "Warning: Can'\''t find UNIV.ph failed"' @@\ + $(PEPSY) $(PSYFLAGS) basename-asn.py @@\ +basename-types.h: basename/**/_tables.c +#endif /* PepsyTarget */ #ifndef ErrorTableObjectRule @@ -255,10 +252,8 @@ P_PROTOS=-UUseNarrowPrototypes TOP_INCLUDES = -I$(TOP)/include $(STDC_TOP_INCLUDES) CONFIGSRC = $(TOP)/config ISODE = IsodeDir - POFLAGS = PosyFlags - PYFLAGS = PepyFlags - PEPY = PepyCmd - POSY = PosyCmd + PSYFLAGS = PepsyFlags + PEPSY = PepsyCmd TOUCH = TouchCmd IMAKE = ImakeCmd DEPEND = DependCmd diff --git a/src/config/site.def b/src/config/site.def index 3a276c1ac..14de28837 100644 --- a/src/config/site.def +++ b/src/config/site.def @@ -78,15 +78,12 @@ library. This might want to be -lisode if you have it installed. IsodeDir is put into the 'make' variable ISODE. */ -#define IsodeLib -L/mit/isode/isode-6.0/@sys/lib -lisode -#define IsodeDir /mit/isode/isode-6.0 +#define IsodeLib -L/mit/isode/isode-6.8/@sys/lib -lisode +#define IsodeDir /mit/isode/isode-6.8 -/* Re-define PepyCmd and PosyCmd if pepy & posy aren't in your search - path. */ - -#define PepyCmd $(ISODE)/@sys/bin/pepy -#define PosyCmd $(ISODE)/@sys/bin/posy +/* Re-define PepsyCmd if pepsy isn't in your search path. */ +#define PepsyCmd $(ISODE)/@sys/bin/pepsy #define UseImakeInstalled /* -- turn on if you have imake installed */ #define UseMakedependInstalled /* -- turn on if you have makedepend installed */ diff --git a/src/lib/krb5/asn.1/KRB5-asn.py b/src/lib/krb5/asn.1/KRB5-asn.py index c7d603fe7..1a7e625a4 100644 --- a/src/lib/krb5/asn.1/KRB5-asn.py +++ b/src/lib/krb5/asn.1/KRB5-asn.py @@ -13,6 +13,11 @@ KRB5 DEFINITIONS ::= BEGIN +-- needed to do the Right Thing with pepsy; this isn't a valid ASN.1 +-- token, however. + +SECTIONS encode decode none + -- the order of stuff in this file matches the order in the draft RFC Realm ::= GeneralString diff --git a/src/lib/krb5/asn.1/klsrq2lsrq.c b/src/lib/krb5/asn.1/klsrq2lsrq.c index 6b0af5c5d..11b540050 100644 --- a/src/lib/krb5/asn.1/klsrq2lsrq.c +++ b/src/lib/krb5/asn.1/klsrq2lsrq.c @@ -32,6 +32,10 @@ krb5_last_req2KRB5_LastReq(val, error) register krb5_last_req_entry * const *val; register int *error; { +#if 0 + /* this code is for -h2 style ISODE structures. However, pepsy + generates horribly broken when given -h2. */ + register struct type_KRB5_LastReq *retval; register krb5_last_req_entry * const *temp; register int i; @@ -65,4 +69,42 @@ register int *error; } } return(retval); +#endif + register struct type_KRB5_LastReq *retval = 0, *rv1 = 0, *rv2; + register krb5_last_req_entry * const *temp; + register int i; + + /* count elements */ + for (i = 0, temp = val; *temp; temp++,i++, rv1 = rv2) { + + rv2 = (struct type_KRB5_LastReq *) xmalloc(sizeof(*rv2)); + if (!rv2) { + if (retval) + free_KRB5_LastReq(retval); + *error = ENOMEM; + return(0); + } + if (rv1) + rv1->next = rv2; + xbzero((char *)rv2, sizeof (*rv2)); + if (!retval) + retval = rv2; + + rv2->element_KRB5_4 = (struct element_KRB5_5 *) + xmalloc(sizeof(*(retval->element_KRB5_4))); + if (!rv2->element_KRB5_4) { + errout: + *error = ENOMEM; + if (retval) + free_KRB5_LastReq(retval); + return(0); + } + rv2->element_KRB5_4->lr__type = val[i]->lr_type; + rv2->element_KRB5_4->lr__value = unix2gentime(val[i]->value, + error); + if (!retval->element_KRB5_4->lr__value) { + goto errout; + } + } + return(retval); } diff --git a/src/lib/krb5/asn.1/kprin2prin.c b/src/lib/krb5/asn.1/kprin2prin.c index 58044f76a..d0a6239ff 100644 --- a/src/lib/krb5/asn.1/kprin2prin.c +++ b/src/lib/krb5/asn.1/kprin2prin.c @@ -32,6 +32,10 @@ krb5_principal2KRB5_PrincipalName(val, error) krb5_const_principal val; register int *error; { +#if 0 + /* this code is for -h2 style ISODE structures. However, pepsy + generates horribly broken when given -h2. */ + register int i; register struct type_KRB5_PrincipalName *retval; @@ -58,4 +62,34 @@ register int *error; } } return(retval); + +#endif + register struct type_KRB5_PrincipalName *retval = 0, *rv1 = 0, *rv2; + register int i; + + /* still skipping realm */ + for (i = 1; val[i]; i++, rv1 = rv2) { + rv2 = (struct type_KRB5_PrincipalName *) xmalloc(sizeof(*rv2)); + if (!rv2) { + if (retval) + free_KRB5_PrincipalName(retval); + *error = ENOMEM; + return(0); + } + if (rv1) + rv1->next = rv2; + xbzero((char *)rv2, sizeof (*rv2)); + if (!retval) + retval = rv2; + + rv2->GeneralString = krb5_data2qbuf(val[i]); + if (!rv2->GeneralString) { + /* clean up */ + if (retval) + free_KRB5_PrincipalName(retval); + *error = ENOMEM; + return(0); + } + } + return(retval); } diff --git a/src/lib/krb5/asn.1/ktgrq2tgrq.c b/src/lib/krb5/asn.1/ktgrq2tgrq.c index b4e56ea24..06967656c 100644 --- a/src/lib/krb5/asn.1/ktgrq2tgrq.c +++ b/src/lib/krb5/asn.1/ktgrq2tgrq.c @@ -81,21 +81,38 @@ register int *error; } } retval->nonce = val->nonce; +#if 0 + /* XXX !@#*)@# busted ASN.1 compiler, -h2 doesn't generate compilable + code */ retval->etype = (struct element_KRB5_8 *)malloc(sizeof(*retval->etype)+ max(0,val->netypes-1)*sizeof(integer)); - if (!retval->etype) + if (!retval->etype) { + *error = ENOMEM; goto errout; - -#if 0 + } for (i = 0; i < val->netypes; i++) { retval->etype->element_KRB5_9[i] = val->etype[i]; } retval->etype->nelem = val->netypes; -#else - /* XXX !@#*)@# busted ASN.1 compiler */ - retval->etype->element_KRB5_9 = val->etype[0]; - retval->etype->nelem = 1; #endif + { + register struct element_KRB5_8 *rv1 = 0, *rv2; + register int i; + + for (i = 0; i < val->netypes; i++, rv1 = rv2) { + rv2 = (struct element_KRB5_8 *) xmalloc(sizeof(*rv2)); + if (!rv2) { + *error = ENOMEM; + goto errout; + } + if (rv1) + rv1->next = rv2; + xbzero((char *)rv2, sizeof (*rv2)); + if (!retval->etype) + retval->etype = rv2; + rv2->element_KRB5_9 = val->etype[i]; + } + } if (val->addresses) { retval->addresses = @@ -112,6 +129,9 @@ register int *error; goto errout; } if (val->second_ticket) { +#if 0 + /* code for -h2 structures, which generate bogus code from pepsy */ + struct element_KRB5_10 *adtk; krb5_ticket * const *temp; register int i; @@ -140,7 +160,43 @@ register int *error; } } retval->additional__tickets = adtk; +#endif + register struct element_KRB5_10 *adtk = 0, *rv1 = 0, *rv2; + krb5_ticket * const *temp; + register int i; + + /* count elements */ + for (i = 0, temp = val->second_ticket; *temp; temp++,i++, rv1 = rv2) { + + rv2 = (struct element_KRB5_10 *)xmalloc(sizeof(*rv2)); + if (!rv2) { + *error = ENOMEM; + goto errout; + } + xbzero(adtk, sizeof(*adtk)); + if (rv1) + rv1->next = rv2; + xbzero((char *)rv2, sizeof (*rv2)); + if (!adtk) + adtk = rv2; + + rv2->Ticket = krb5_ticket2KRB5_Ticket(val->second_ticket[i], + error); + if (!rv2->Ticket) { + for (rv1 = adtk; rv1; rv1 = rv2) { + if (rv1->Ticket) + free_KRB5_Ticket(rv1->Ticket); + rv2 = rv1->next; + xfree(rv1); + } + goto errout; + } + } + retval->additional__tickets = adtk; } else { +#if 0 + /* this was once necessary to get around faulty optional processing */ + struct element_KRB5_10 *adtk; adtk = (struct element_KRB5_10 *)xmalloc(sizeof(*adtk)); if (!adtk) { @@ -150,6 +206,8 @@ register int *error; xbzero(adtk, sizeof(*adtk)); adtk->nelem = 0; retval->additional__tickets = adtk; +#endif + retval->additional__tickets = 0; } return retval; diff --git a/src/lib/krb5/asn.1/lsrq2klsrq.c b/src/lib/krb5/asn.1/lsrq2klsrq.c index db0f9ad52..6f41f6a06 100644 --- a/src/lib/krb5/asn.1/lsrq2klsrq.c +++ b/src/lib/krb5/asn.1/lsrq2klsrq.c @@ -32,6 +32,10 @@ KRB5_LastReq2krb5_last_req(val, error) const struct type_KRB5_LastReq *val; register int *error; { +#if 0 + /* this code is for -h2 style ISODE structures. However, pepsy + generates horribly broken when given -h2. */ + register krb5_last_req_entry **retval; register int i; @@ -60,4 +64,36 @@ register int *error; } retval[i] = 0; return(retval); +#endif + register krb5_last_req_entry **retval; + register int i; + register struct type_KRB5_LastReq *rv; + + for (i = 0, rv = val; rv; i++, rv = rv->next) + ; + + /* plus one for null terminator */ + retval = (krb5_last_req_entry **) xcalloc(i + 1, sizeof(*retval)); + if (!retval) { + *error = ENOMEM; + return(0); + } + for (i = 0, rv = val; rv; rv = rv->next, i++) { + retval[i] = (krb5_last_req_entry *) xmalloc(sizeof(*retval[i])); + if (!retval[i]) { + krb5_free_last_req(retval); + *error = ENOMEM; + return(0); + } + retval[i]->value = gentime2unix(rv->element_KRB5_4->lr__value, + error); + if (*error) { + /* value is zero if error, so it won't get freed... */ + krb5_free_last_req(retval); + return(0); + } + retval[i]->lr_type = rv->element_KRB5_4->lr__type; + } + retval[i] = 0; + return(retval); } diff --git a/src/lib/krb5/asn.1/prin2kprin.c b/src/lib/krb5/asn.1/prin2kprin.c index f07966dfd..37299783e 100644 --- a/src/lib/krb5/asn.1/prin2kprin.c +++ b/src/lib/krb5/asn.1/prin2kprin.c @@ -33,6 +33,10 @@ const struct type_KRB5_PrincipalName *val; const struct type_KRB5_Realm *realm; register int *error; { +#if 0 + /* this code is for -h2 style ISODE structures. However, pepsy + generates horribly broken when given -h2. */ + register krb5_principal retval; register int i; @@ -58,4 +62,35 @@ register int *error; } retval[i+1] = 0; return(retval); +#endif + + register krb5_principal retval; + register int i; + register struct type_KRB5_PrincipalName *rv; + + for (i = 1, rv = val; rv->next; i++, rv = rv->next) + ; + + /* plus one for the realm, plus one for null term */ + retval = (krb5_principal) xcalloc(i + 2, sizeof(krb5_data *)); + + if (!retval) { + *error = ENOMEM; + return(0); + } + + retval[0] = qbuf2krb5_data(realm, error); + if (!retval[0]) { + xfree(retval); + return(0); + } + for (i = 1, rv = val; rv; rv = rv->next, i++) { + retval[i] = qbuf2krb5_data(rv->GeneralString, error); + if (!retval[i]) { + krb5_free_principal(retval); + return(0); + } + } + retval[i] = 0; + return(retval); } diff --git a/src/lib/krb5/asn.1/tgrq2ktgrq.c b/src/lib/krb5/asn.1/tgrq2ktgrq.c index 53a47c499..dee030fd5 100644 --- a/src/lib/krb5/asn.1/tgrq2ktgrq.c +++ b/src/lib/krb5/asn.1/tgrq2ktgrq.c @@ -80,20 +80,34 @@ register int *error; } retval->nonce = val->nonce; +#if 0 retval->etype = (krb5_enctype *) xmalloc(sizeof(*(retval->etype))*min(1,val->etype->nelem)); - if (!retval->etype) + if (!retval->etype) { + *error = ENOMEM; goto errout; -#if 0 + } + /* XXX @#$#@ broken ASN.1 compiler, -h2 generates unusable code, + but the structures would be handle like so: */ for (i = 0; i < val->etype->nelem; i++) { retval->etype[i] = val->etype->element_KRB5_9[i]; } - val->netypes = val->etype->nelem; -#else - /* XXX @#$#@ broken ASN.1 compiler */ - retval->etype[0] = val->etype->element_KRB5_9; - retval->netypes = 1; + retval->netypes = val->etype->nelem; #endif - + { + register int i; + register struct element_KRB5_8 *rv; + for (i = 0, rv = val->etype; rv; i++, rv = rv->next) + ; + retval->netypes = i; + retval->etype = (krb5_enctype *) xcalloc(i+1,sizeof(*retval->etype)); + if (!retval->etype) { + *error = ENOMEM; + goto errout; + } + for (i = 0, rv = val->etype; rv; rv = rv->next, i++) + retval->etype[i] = rv->element_KRB5_9; + } + if (val->addresses) { retval->addresses = KRB5_HostAddresses2krb5_address(val->addresses, error); @@ -111,6 +125,9 @@ register int *error; goto errout; } if (val->additional__tickets) { +#if 0 + /* code for -h2 style, which pepsy can't do right */ + register krb5_ticket **aticks; register struct element_KRB5_10 *tptr; register int i; @@ -119,6 +136,10 @@ register int *error; /* plus one for null terminator */ aticks = (krb5_ticket **) xcalloc(tptr->nelem + 1, sizeof(*aticks)); + if (!aticks) { + *error = ENOMEM; + goto errout; + } for (i = 0; (i < tptr->nelem) && tptr->Ticket[i]; i++) { aticks[i] = KRB5_Ticket2krb5_ticket(tptr->Ticket[i], error); if (!aticks[i]) { @@ -126,6 +147,35 @@ register int *error; krb5_free_ticket(aticks[i]); i--; } + xfree(aticks); + goto errout; + } + } + retval->second_ticket = aticks; +#endif + register krb5_ticket **aticks; + register struct element_KRB5_10 *tptr, *rv; + register int i; + + tptr = val->additional__tickets; + for (i = 0, rv = tptr; rv; i++, rv = rv->next) + ; + + /* plus one for null terminator */ + aticks = (krb5_ticket **) xcalloc(i + 1, sizeof(*aticks)); + if (!aticks) { + *error = ENOMEM; + goto errout; + } + + for (i = 0, rv = tptr; rv; rv = rv->next, i++) { + aticks[i] = KRB5_Ticket2krb5_ticket(rv->Ticket, error); + if (!aticks[i]) { + while (i >= 0) { + krb5_free_ticket(aticks[i]); + i--; + } + xfree(aticks); goto errout; } }