From: Chris Provenzano Date: Fri, 13 Jan 1995 21:21:42 +0000 (+0000) Subject: Removed all references to DECLARG and OLDDECLARG. X-Git-Tag: krb5-1.0-beta5~845 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5b169bc85d0ddcf7055e694d07cbb704021e6c3c;p=krb5.git Removed all references to DECLARG and OLDDECLARG. Added krb5_context to all krb5_routines. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@4810 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/ccache/ChangeLog b/src/lib/krb5/ccache/ChangeLog index 0de41cc14..07366413f 100644 --- a/src/lib/krb5/ccache/ChangeLog +++ b/src/lib/krb5/ccache/ChangeLog @@ -1,3 +1,7 @@ +Fri Jan 13 15:23:47 1995 Chris Provenzano (proven@mit.edu) + + * Added krb5_context to all krb5_routines + Thu Oct 13 17:23:08 1994 Theodore Y. Ts'o (tytso@maytag) * configure.in: Add ISODE_DEFS diff --git a/src/lib/krb5/ccache/ccbase.c b/src/lib/krb5/ccache/ccbase.c index dfcefbece..c9e295c84 100644 --- a/src/lib/krb5/ccache/ccbase.c +++ b/src/lib/krb5/ccache/ccbase.c @@ -42,10 +42,10 @@ static struct krb5_cc_typelist *cc_typehead = 0; */ krb5_error_code -krb5_cc_register(DECLARG(krb5_cc_ops *,ops), - DECLARG(krb5_boolean,override)) -OLDDECLARG(krb5_cc_ops *,ops) -OLDDECLARG(krb5_boolean,override) +krb5_cc_register(context, ops, override) + krb5_context context; + krb5_cc_ops *ops; + krb5_boolean override; { struct krb5_cc_typelist *t; for (t = cc_typehead;t && strcmp(t->ops->prefix,ops->prefix);t = t->next) @@ -75,9 +75,10 @@ OLDDECLARG(krb5_boolean,override) * particular cache type. */ -krb5_error_code krb5_cc_resolve (name, cache) - char *name; - krb5_ccache *cache; +krb5_error_code krb5_cc_resolve (context, name, cache) + krb5_context context; + char *name; + krb5_ccache *cache; { struct krb5_cc_typelist *tlist; char *pfx, *resid, *cp; @@ -86,7 +87,7 @@ krb5_error_code krb5_cc_resolve (name, cache) cp = strchr (name, ':'); if (!cp) { if (krb5_cc_dfl_ops) - return (*krb5_cc_dfl_ops->resolve)(cache, name); + return (*krb5_cc_dfl_ops->resolve)(context, cache, name); else return KRB5_CC_BADNAME; } @@ -106,12 +107,12 @@ krb5_error_code krb5_cc_resolve (name, cache) for (tlist = cc_typehead; tlist; tlist = tlist->next) { if (strcmp (tlist->ops->prefix, pfx) == 0) { free(pfx); - return (*tlist->ops->resolve)(cache, resid); + return (*tlist->ops->resolve)(context, cache, resid); } } if (krb5_cc_dfl_ops && !strcmp (pfx, krb5_cc_dfl_ops->prefix)) { free (pfx); - return (*krb5_cc_dfl_ops->resolve)(cache, resid); + return (*krb5_cc_dfl_ops->resolve)(context, cache, resid); } free(pfx); return KRB5_CC_UNKNOWN_TYPE; diff --git a/src/lib/krb5/ccache/ccdefault.c b/src/lib/krb5/ccache/ccdefault.c index e1f5f6540..3400fa2dc 100644 --- a/src/lib/krb5/ccache/ccdefault.c +++ b/src/lib/krb5/ccache/ccdefault.c @@ -27,8 +27,9 @@ #include -krb5_error_code krb5_cc_default(ccache) -krb5_ccache *ccache; +krb5_error_code krb5_cc_default(context, ccache) + krb5_context context; + krb5_ccache *ccache; { - return krb5_cc_resolve(krb5_cc_default_name(), ccache); + return krb5_cc_resolve(context, krb5_cc_default_name(context), ccache); } diff --git a/src/lib/krb5/ccache/file/ChangeLog b/src/lib/krb5/ccache/file/ChangeLog index 3234f48d4..e105df37d 100644 --- a/src/lib/krb5/ccache/file/ChangeLog +++ b/src/lib/krb5/ccache/file/ChangeLog @@ -1,3 +1,7 @@ +Fri Jan 13 15:23:47 1995 Chris Provenzano (proven@mit.edu) + + * Added krb5_context to all krb5_routines + Wed Dec 7 16:58:59 1994 * fcc_write.c (krb5_fcc_store_addrs): If a null addresses is diff --git a/src/lib/krb5/ccache/file/fcc-proto.h b/src/lib/krb5/ccache/file/fcc-proto.h index 56d4a1d3d..e7bee704e 100644 --- a/src/lib/krb5/ccache/file/fcc-proto.h +++ b/src/lib/krb5/ccache/file/fcc-proto.h @@ -29,85 +29,133 @@ #define KRB5_FCC_PROTO__ /* fcc_close.c */ -krb5_error_code krb5_fcc_close PROTOTYPE((krb5_ccache id )); +krb5_error_code krb5_fcc_close + PROTOTYPE((krb5_context, krb5_ccache id )); /* fcc_defnam.c */ -char *krb5_fcc_default_name PROTOTYPE((void )); +char *krb5_fcc_default_name + PROTOTYPE((krb5_context)); /* fcc_destry.c */ -krb5_error_code krb5_fcc_destroy PROTOTYPE((krb5_ccache id )); +krb5_error_code krb5_fcc_destroy + PROTOTYPE((krb5_context, krb5_ccache id )); /* fcc_eseq.c */ -krb5_error_code krb5_fcc_end_seq_get PROTOTYPE((krb5_ccache id , krb5_cc_cursor *cursor )); +krb5_error_code krb5_fcc_end_seq_get + PROTOTYPE((krb5_context, krb5_ccache id , krb5_cc_cursor *cursor )); /* fcc_gennew.c */ -krb5_error_code krb5_fcc_generate_new PROTOTYPE((krb5_ccache *id )); +krb5_error_code krb5_fcc_generate_new + PROTOTYPE((krb5_context, krb5_ccache *id )); /* fcc_getnam.c */ -char *krb5_fcc_get_name PROTOTYPE((krb5_ccache id )); +char *krb5_fcc_get_name + PROTOTYPE((krb5_context, krb5_ccache id )); /* fcc_gprin.c */ -krb5_error_code krb5_fcc_get_principal PROTOTYPE((krb5_ccache id , krb5_principal *princ )); +krb5_error_code krb5_fcc_get_principal + PROTOTYPE((krb5_context, krb5_ccache id , krb5_principal *princ )); /* fcc_init.c */ -krb5_error_code krb5_fcc_initialize PROTOTYPE((krb5_ccache id , krb5_principal princ )); +krb5_error_code krb5_fcc_initialize + PROTOTYPE((krb5_context, krb5_ccache id , krb5_principal princ )); /* fcc_nseq.c */ -krb5_error_code krb5_fcc_next_cred PROTOTYPE((krb5_ccache id , krb5_cc_cursor *cursor , krb5_creds *creds )); +krb5_error_code krb5_fcc_next_cred + PROTOTYPE((krb5_context, + krb5_ccache id , + krb5_cc_cursor *cursor , + krb5_creds *creds )); /* fcc_read.c */ -krb5_error_code krb5_fcc_read_principal PROTOTYPE((krb5_ccache id , krb5_principal *princ )); -krb5_error_code krb5_fcc_read_keyblock PROTOTYPE((krb5_ccache id , krb5_keyblock *keyblock )); -krb5_error_code krb5_fcc_read_data PROTOTYPE((krb5_ccache id , krb5_data *data )); -krb5_error_code krb5_fcc_read_int32 PROTOTYPE((krb5_ccache id , krb5_int32 *i )); -krb5_error_code krb5_fcc_read_ui_2 PROTOTYPE((krb5_ccache id , krb5_ui_2 *i )); -krb5_error_code krb5_fcc_read_octet PROTOTYPE((krb5_ccache id , krb5_octet *i )); -krb5_error_code krb5_fcc_read_times PROTOTYPE((krb5_ccache id , krb5_ticket_times *t )); -krb5_error_code krb5_fcc_read_addrs PROTOTYPE((krb5_ccache, krb5_address ***)); -krb5_error_code krb5_fcc_read_addr PROTOTYPE((krb5_ccache, krb5_address *)); -krb5_error_code krb5_fcc_read_authdata PROTOTYPE((krb5_ccache , krb5_authdata ***)); -krb5_error_code krb5_fcc_read_authdatum PROTOTYPE((krb5_ccache , krb5_authdata *)); +krb5_error_code krb5_fcc_read_principal + PROTOTYPE((krb5_context, krb5_ccache id , krb5_principal *princ )); +krb5_error_code krb5_fcc_read_keyblock + PROTOTYPE((krb5_context, krb5_ccache id , krb5_keyblock *keyblock )); +krb5_error_code krb5_fcc_read_data + PROTOTYPE((krb5_context, krb5_ccache id , krb5_data *data )); +krb5_error_code krb5_fcc_read_int32 + PROTOTYPE((krb5_context, krb5_ccache id , krb5_int32 *i )); +krb5_error_code krb5_fcc_read_ui_2 + PROTOTYPE((krb5_context, krb5_ccache id , krb5_ui_2 *i )); +krb5_error_code krb5_fcc_read_octet + PROTOTYPE((krb5_context, krb5_ccache id , krb5_octet *i )); +krb5_error_code krb5_fcc_read_times + PROTOTYPE((krb5_context, krb5_ccache id , krb5_ticket_times *t )); +krb5_error_code krb5_fcc_read_addrs + PROTOTYPE((krb5_context, krb5_ccache, krb5_address ***)); +krb5_error_code krb5_fcc_read_addr + PROTOTYPE((krb5_context, krb5_ccache, krb5_address *)); +krb5_error_code krb5_fcc_read_authdata + PROTOTYPE((krb5_context, krb5_ccache , krb5_authdata ***)); +krb5_error_code krb5_fcc_read_authdatum + PROTOTYPE((krb5_context, krb5_ccache , krb5_authdata *)); /* fcc_reslv.c */ -krb5_error_code krb5_fcc_resolve PROTOTYPE((krb5_ccache *id , char *residual )); +krb5_error_code krb5_fcc_resolve + PROTOTYPE((krb5_context, krb5_ccache *id , char *residual )); /* fcc_retrv.c */ -krb5_error_code krb5_fcc_retrieve PROTOTYPE((krb5_ccache id , krb5_flags whichfields , krb5_creds *mcreds , krb5_creds *creds )); +krb5_error_code krb5_fcc_retrieve + PROTOTYPE((krb5_context, + krb5_ccache id , + krb5_flags whichfields , + krb5_creds *mcreds , + krb5_creds *creds )); /* fcc_sseq.c */ -krb5_error_code krb5_fcc_start_seq_get PROTOTYPE((krb5_ccache id , krb5_cc_cursor *cursor )); +krb5_error_code krb5_fcc_start_seq_get + PROTOTYPE((krb5_context, krb5_ccache id , krb5_cc_cursor *cursor )); /* fcc_store.c */ -krb5_error_code krb5_fcc_store PROTOTYPE((krb5_ccache id , krb5_creds *creds )); +krb5_error_code krb5_fcc_store + PROTOTYPE((krb5_context, krb5_ccache id , krb5_creds *creds )); /* fcc_skip.c */ -krb5_error_code krb5_fcc_skip_principal PROTOTYPE((krb5_ccache id )); +krb5_error_code krb5_fcc_skip_principal + PROTOTYPE((krb5_context, krb5_ccache id )); /* fcc_sflags.c */ -krb5_error_code krb5_fcc_set_flags PROTOTYPE((krb5_ccache id , krb5_flags flags )); +krb5_error_code krb5_fcc_set_flags + PROTOTYPE((krb5_context, krb5_ccache id , krb5_flags flags )); /* fcc_ops.c */ extern krb5_cc_ops krb5_cc_file_ops; /* fcc_write.c */ -krb5_error_code krb5_fcc_write PROTOTYPE((krb5_ccache id , krb5_pointer buf , int len )); -krb5_error_code krb5_fcc_store_principal PROTOTYPE((krb5_ccache id , krb5_principal princ )); -krb5_error_code krb5_fcc_store_keyblock PROTOTYPE((krb5_ccache id , krb5_keyblock *keyblock )); -krb5_error_code krb5_fcc_store_data PROTOTYPE((krb5_ccache id , krb5_data *data )); -krb5_error_code krb5_fcc_store_int32 PROTOTYPE((krb5_ccache id , krb5_int32 i )); -krb5_error_code krb5_fcc_store_ui_2 PROTOTYPE((krb5_ccache id , krb5_int32 i )); -krb5_error_code krb5_fcc_store_octet PROTOTYPE((krb5_ccache id , krb5_int32 i )); -krb5_error_code krb5_fcc_store_times PROTOTYPE((krb5_ccache id , krb5_ticket_times *t )); -krb5_error_code krb5_fcc_store_addrs PROTOTYPE((krb5_ccache , krb5_address ** )); -krb5_error_code krb5_fcc_store_addr PROTOTYPE((krb5_ccache , krb5_address * )); -krb5_error_code krb5_fcc_store_authdata PROTOTYPE((krb5_ccache , krb5_authdata **)); -krb5_error_code krb5_fcc_store_authdatum PROTOTYPE((krb5_ccache , krb5_authdata *)); +krb5_error_code krb5_fcc_write + PROTOTYPE((krb5_context, krb5_ccache id , krb5_pointer buf , int len )); +krb5_error_code krb5_fcc_store_principal + PROTOTYPE((krb5_context, krb5_ccache id , krb5_principal princ )); +krb5_error_code krb5_fcc_store_keyblock + PROTOTYPE((krb5_context, krb5_ccache id , krb5_keyblock *keyblock )); +krb5_error_code krb5_fcc_store_data + PROTOTYPE((krb5_context, krb5_ccache id , krb5_data *data )); +krb5_error_code krb5_fcc_store_int32 + PROTOTYPE((krb5_context, krb5_ccache id , krb5_int32 i )); +krb5_error_code krb5_fcc_store_ui_2 + PROTOTYPE((krb5_context, krb5_ccache id , krb5_int32 i )); +krb5_error_code krb5_fcc_store_octet + PROTOTYPE((krb5_context, krb5_ccache id , krb5_int32 i )); +krb5_error_code krb5_fcc_store_times + PROTOTYPE((krb5_context, krb5_ccache id , krb5_ticket_times *t )); +krb5_error_code krb5_fcc_store_addrs + PROTOTYPE((krb5_context, krb5_ccache , krb5_address ** )); +krb5_error_code krb5_fcc_store_addr + PROTOTYPE((krb5_context, krb5_ccache , krb5_address * )); +krb5_error_code krb5_fcc_store_authdata + PROTOTYPE((krb5_context, krb5_ccache , krb5_authdata **)); +krb5_error_code krb5_fcc_store_authdatum + PROTOTYPE((krb5_context, krb5_ccache , krb5_authdata *)); /* fcc_errs.c */ -krb5_error_code krb5_fcc_interpret PROTOTYPE((int )); +krb5_error_code krb5_fcc_interpret + PROTOTYPE((krb5_context, int )); /* fcc_maybe.c */ -krb5_error_code krb5_fcc_close_file PROTOTYPE((krb5_ccache)); -krb5_error_code krb5_fcc_open_file PROTOTYPE((krb5_ccache, int)); +krb5_error_code krb5_fcc_close_file + PROTOTYPE((krb5_context, krb5_ccache)); +krb5_error_code krb5_fcc_open_file + PROTOTYPE((krb5_context, krb5_ccache, int)); #endif /* KRB5_FCC_PROTO__ */ diff --git a/src/lib/krb5/ccache/file/fcc.h b/src/lib/krb5/ccache/file/fcc.h index 18d560a32..bd7f0f90c 100644 --- a/src/lib/krb5/ccache/file/fcc.h +++ b/src/lib/krb5/ccache/file/fcc.h @@ -85,22 +85,22 @@ typedef struct _krb5_fcc_cursor { off_t pos; } krb5_fcc_cursor; -#define MAYBE_OPEN(ID, MODE) \ +#define MAYBE_OPEN(CONTEXT, ID, MODE) \ { \ if (OPENCLOSE (ID)) { \ - krb5_error_code maybe_open_ret = krb5_fcc_open_file (ID,MODE); \ + krb5_error_code maybe_open_ret = krb5_fcc_open_file (CONTEXT,ID,MODE); \ if (maybe_open_ret) return maybe_open_ret; } } -#define MAYBE_CLOSE(ID, RET) \ +#define MAYBE_CLOSE(CONTEXT, ID, RET) \ { \ if (OPENCLOSE (ID)) { \ - krb5_error_code maybe_close_ret = krb5_fcc_close_file (ID); \ + krb5_error_code maybe_close_ret = krb5_fcc_close_file (CONTEXT,ID); \ if (!(RET)) RET = maybe_close_ret; } } -#define MAYBE_CLOSE_IGNORE(ID) \ +#define MAYBE_CLOSE_IGNORE(CONTEXT, ID) \ { \ if (OPENCLOSE (ID)) { \ - (void) krb5_fcc_close_file (ID); } } + (void) krb5_fcc_close_file (CONTEXT,ID); } } /* DO NOT ADD ANYTHING AFTER THIS #endif */ #endif /* __KRB5_FILE_CCACHE__ */ diff --git a/src/lib/krb5/ccache/file/fcc_close.c b/src/lib/krb5/ccache/file/fcc_close.c index 30961d866..d59516e4d 100644 --- a/src/lib/krb5/ccache/file/fcc_close.c +++ b/src/lib/krb5/ccache/file/fcc_close.c @@ -37,13 +37,14 @@ * associated with the cache. */ krb5_error_code -krb5_fcc_close(id) +krb5_fcc_close(context, id) + krb5_context context; krb5_ccache id; { register int closeval = KRB5_OK; if (((krb5_fcc_data *) id->data)->fd >= 0) - krb5_fcc_close_file(id); + krb5_fcc_close_file(context, id); krb5_xfree(((krb5_fcc_data *) id->data)->filename); krb5_xfree(((krb5_fcc_data *) id->data)); diff --git a/src/lib/krb5/ccache/file/fcc_defnam.c b/src/lib/krb5/ccache/file/fcc_defnam.c index f8265d5ad..5926aca9f 100644 --- a/src/lib/krb5/ccache/file/fcc_defnam.c +++ b/src/lib/krb5/ccache/file/fcc_defnam.c @@ -49,7 +49,8 @@ static char krb5_default_name_string[KRB5_FCC_MAXLEN] = ""; */ char * -krb5_fcc_default_name () +krb5_fcc_default_name (context) + krb5_context context; { char *krb5ccache, *getenv(); int len; diff --git a/src/lib/krb5/ccache/file/fcc_destry.c b/src/lib/krb5/ccache/file/fcc_destry.c index 6a3298b41..9fb13f63e 100644 --- a/src/lib/krb5/ccache/file/fcc_destry.c +++ b/src/lib/krb5/ccache/file/fcc_destry.c @@ -35,7 +35,8 @@ * Errors: * system errors */ -krb5_error_code krb5_fcc_destroy(id) +krb5_error_code krb5_fcc_destroy(context, id) + krb5_context context; krb5_ccache id; { struct stat buf; @@ -46,7 +47,7 @@ krb5_error_code krb5_fcc_destroy(id) if (OPENCLOSE(id)) { ret = open(((krb5_fcc_data *) id->data)->filename, O_RDWR, 0); if (ret < 0) { - ret = krb5_fcc_interpret(errno); + ret = krb5_fcc_interpret(context, errno); goto cleanup; } ((krb5_fcc_data *) id->data)->fd = ret; @@ -56,7 +57,7 @@ krb5_error_code krb5_fcc_destroy(id) ret = unlink(((krb5_fcc_data *) id->data)->filename); if (ret < 0) { - ret = krb5_fcc_interpret(errno); + ret = krb5_fcc_interpret(context, errno); if (OPENCLOSE(id)) { (void) close(((krb5_fcc_data *)id->data)->fd); ((krb5_fcc_data *) id->data)->fd = -1; @@ -66,7 +67,7 @@ krb5_error_code krb5_fcc_destroy(id) ret = fstat(((krb5_fcc_data *) id->data)->fd, &buf); if (ret < 0) { - ret = krb5_fcc_interpret(errno); + ret = krb5_fcc_interpret(context, errno); if (OPENCLOSE(id)) { (void) close(((krb5_fcc_data *)id->data)->fd); ((krb5_fcc_data *) id->data)->fd = -1; @@ -80,7 +81,7 @@ krb5_error_code krb5_fcc_destroy(id) memset(zeros, 0, BUFSIZ); for (i=0; i < size / BUFSIZ; i++) if (write(((krb5_fcc_data *) id->data)->fd, zeros, BUFSIZ) < 0) { - ret = krb5_fcc_interpret(errno); + ret = krb5_fcc_interpret(context, errno); if (OPENCLOSE(id)) { (void) close(((krb5_fcc_data *)id->data)->fd); ((krb5_fcc_data *) id->data)->fd = -1; @@ -89,7 +90,7 @@ krb5_error_code krb5_fcc_destroy(id) } if (write(((krb5_fcc_data *) id->data)->fd, zeros, size % BUFSIZ) < 0) { - ret = krb5_fcc_interpret(errno); + ret = krb5_fcc_interpret(context, errno); if (OPENCLOSE(id)) { (void) close(((krb5_fcc_data *)id->data)->fd); ((krb5_fcc_data *) id->data)->fd = -1; @@ -101,7 +102,7 @@ krb5_error_code krb5_fcc_destroy(id) ((krb5_fcc_data *) id->data)->fd = -1; if (ret) - ret = krb5_fcc_interpret(errno); + ret = krb5_fcc_interpret(context, errno); cleanup: krb5_xfree(((krb5_fcc_data *) id->data)->filename); diff --git a/src/lib/krb5/ccache/file/fcc_errs.c b/src/lib/krb5/ccache/file/fcc_errs.c index 1dd96788d..8a4834ab1 100644 --- a/src/lib/krb5/ccache/file/fcc_errs.c +++ b/src/lib/krb5/ccache/file/fcc_errs.c @@ -29,7 +29,8 @@ #include "fcc.h" krb5_error_code -krb5_fcc_interpret(errnum) +krb5_fcc_interpret(context, errnum) + krb5_context context; int errnum; { register int retval; diff --git a/src/lib/krb5/ccache/file/fcc_eseq.c b/src/lib/krb5/ccache/file/fcc_eseq.c index d60a5b750..d2b5f1f8d 100644 --- a/src/lib/krb5/ccache/file/fcc_eseq.c +++ b/src/lib/krb5/ccache/file/fcc_eseq.c @@ -41,7 +41,8 @@ */ /* ARGSUSED */ krb5_error_code -krb5_fcc_end_seq_get(id, cursor) +krb5_fcc_end_seq_get(context, id, cursor) + krb5_context context; krb5_ccache id; krb5_cc_cursor *cursor; { @@ -50,7 +51,7 @@ krb5_fcc_end_seq_get(id, cursor) /* don't close; it may be left open by the caller, and if not, fcc_start_seq_get and/or fcc_next_cred will do the MAYBE_CLOSE. - MAYBE_CLOSE(id, kret); */ + MAYBE_CLOSE(context, id, kret); */ krb5_xfree((krb5_fcc_cursor *) *cursor); return kret; diff --git a/src/lib/krb5/ccache/file/fcc_gennew.c b/src/lib/krb5/ccache/file/fcc_gennew.c index 36d00aab7..9b843ee8a 100644 --- a/src/lib/krb5/ccache/file/fcc_gennew.c +++ b/src/lib/krb5/ccache/file/fcc_gennew.c @@ -52,7 +52,8 @@ extern krb5_cc_ops krb5_fcc_ops; * system errors (from open) */ krb5_error_code -krb5_fcc_generate_new (id) +krb5_fcc_generate_new (context, id) + krb5_context context; krb5_ccache *id; { krb5_ccache lid; @@ -100,7 +101,7 @@ krb5_fcc_generate_new (id) ret = open(((krb5_fcc_data *) lid->data)->filename, O_CREAT | O_EXCL | O_WRONLY, 0); if (ret == -1) { - retcode = krb5_fcc_interpret(errno); + retcode = krb5_fcc_interpret(context, errno); goto err_out; } else { krb5_int16 fcc_fvno = htons(KRB5_FCC_DEFAULT_FVNO); @@ -117,13 +118,13 @@ krb5_fcc_generate_new (id) errsave = errno; (void) close(ret); (void) unlink(((krb5_fcc_data *) lid->data)->filename); - retcode = (cnt == -1) ? krb5_fcc_interpret(errsave) : KRB5_CC_IO; + retcode = (cnt == -1) ? krb5_fcc_interpret(context, errsave) : KRB5_CC_IO; goto err_out; } if (close(ret) == -1) { errsave = errno; (void) unlink(((krb5_fcc_data *) lid->data)->filename); - retcode = krb5_fcc_interpret(errsave); + retcode = krb5_fcc_interpret(context, errsave); goto err_out; } diff --git a/src/lib/krb5/ccache/file/fcc_getnam.c b/src/lib/krb5/ccache/file/fcc_getnam.c index 76faf8825..f3357f101 100644 --- a/src/lib/krb5/ccache/file/fcc_getnam.c +++ b/src/lib/krb5/ccache/file/fcc_getnam.c @@ -36,7 +36,8 @@ * The name of the file cred cache id. */ char * -krb5_fcc_get_name (id) +krb5_fcc_get_name (context, id) + krb5_context context; krb5_ccache id; { return (char *) ((krb5_fcc_data *) id->data)->filename; diff --git a/src/lib/krb5/ccache/file/fcc_gprin.c b/src/lib/krb5/ccache/file/fcc_gprin.c index f239c6dbc..a97abd62e 100644 --- a/src/lib/krb5/ccache/file/fcc_gprin.c +++ b/src/lib/krb5/ccache/file/fcc_gprin.c @@ -41,19 +41,20 @@ * KRB5_CC_NOMEM */ krb5_error_code -krb5_fcc_get_principal(id, princ) +krb5_fcc_get_principal(context, id, princ) + krb5_context context; krb5_ccache id; krb5_principal *princ; { krb5_error_code kret = KRB5_OK; - MAYBE_OPEN(id, FCC_OPEN_RDONLY); + MAYBE_OPEN(context, id, FCC_OPEN_RDONLY); /* make sure we're beyond the vno */ lseek(((krb5_fcc_data *) id->data)->fd, sizeof(krb5_int16), SEEK_SET); - kret = krb5_fcc_read_principal(id, princ); + kret = krb5_fcc_read_principal(context, id, princ); - MAYBE_CLOSE(id, kret); + MAYBE_CLOSE(context, id, kret); return kret; } diff --git a/src/lib/krb5/ccache/file/fcc_init.c b/src/lib/krb5/ccache/file/fcc_init.c index 019640fa5..fffc09a88 100644 --- a/src/lib/krb5/ccache/file/fcc_init.c +++ b/src/lib/krb5/ccache/file/fcc_init.c @@ -41,13 +41,14 @@ * permission errors */ krb5_error_code -krb5_fcc_initialize(id, princ) +krb5_fcc_initialize(context, id, princ) + krb5_context context; krb5_ccache id; krb5_principal princ; { int ret = KRB5_OK; - MAYBE_OPEN(id, FCC_OPEN_AND_ERASE); + MAYBE_OPEN(context, id, FCC_OPEN_AND_ERASE); #ifdef NOFCHMOD ret = chmod(((krb5_fcc_data *) id->data)->filename, S_IREAD | S_IWRITE); @@ -55,13 +56,13 @@ krb5_fcc_initialize(id, princ) ret = fchmod(((krb5_fcc_data *) id->data)->fd, S_IREAD | S_IWRITE); #endif if (ret == -1) { - ret = krb5_fcc_interpret(errno); - MAYBE_CLOSE(id, ret); + ret = krb5_fcc_interpret(context, errno); + MAYBE_CLOSE(context, id, ret); return ret; } - krb5_fcc_store_principal(id, princ); + krb5_fcc_store_principal(context, id, princ); - MAYBE_CLOSE(id, ret); + MAYBE_CLOSE(context, id, ret); return ret; } diff --git a/src/lib/krb5/ccache/file/fcc_maybe.c b/src/lib/krb5/ccache/file/fcc_maybe.c index 5fcfc3aac..e72e812cc 100644 --- a/src/lib/krb5/ccache/file/fcc_maybe.c +++ b/src/lib/krb5/ccache/file/fcc_maybe.c @@ -118,7 +118,8 @@ int lockunlock; } krb5_error_code -krb5_fcc_close_file (id) +krb5_fcc_close_file (context, id) + krb5_context context; krb5_ccache id; { int ret; @@ -134,11 +135,12 @@ krb5_fcc_close_file (id) if (retval) return retval; else - return (ret == -1) ? krb5_fcc_interpret (errno) : 0; + return (ret == -1) ? krb5_fcc_interpret (context, errno) : 0; } krb5_error_code -krb5_fcc_open_file (id, mode) +krb5_fcc_open_file (context, id, mode) + krb5_context context; krb5_ccache id; int mode; { @@ -170,7 +172,7 @@ krb5_fcc_open_file (id, mode) fd = open (data->filename, open_flag, 0600); if (fd == -1) - return krb5_fcc_interpret (errno); + return krb5_fcc_interpret (context, errno); if (retval = fcc_lock_file(data, fd, LOCK_IT)) { (void) close(fd); @@ -188,7 +190,7 @@ krb5_fcc_open_file (id, mode) errsave = errno; (void) fcc_lock_file(data, fd, UNLOCK_IT); (void) close(fd); - return (cnt == -1) ? krb5_fcc_interpret(errsave) : KRB5_CC_IO; + return (cnt == -1) ? krb5_fcc_interpret(context, errsave) : KRB5_CC_IO; } } else { /* verify a valid version number is there */ diff --git a/src/lib/krb5/ccache/file/fcc_nseq.c b/src/lib/krb5/ccache/file/fcc_nseq.c index 08746a6b5..1a85acd0a 100644 --- a/src/lib/krb5/ccache/file/fcc_nseq.c +++ b/src/lib/krb5/ccache/file/fcc_nseq.c @@ -49,7 +49,8 @@ * system errors */ krb5_error_code -krb5_fcc_next_cred(id, cursor, creds) +krb5_fcc_next_cred(context, id, cursor, creds) + krb5_context context; krb5_ccache id; krb5_cc_cursor *cursor; krb5_creds *creds; @@ -63,47 +64,47 @@ krb5_fcc_next_cred(id, cursor, creds) memset((char *)creds, 0, sizeof(*creds)); - MAYBE_OPEN(id, FCC_OPEN_RDONLY); + MAYBE_OPEN(context, id, FCC_OPEN_RDONLY); fcursor = (krb5_fcc_cursor *) *cursor; ret = lseek(((krb5_fcc_data *) id->data)->fd, fcursor->pos, SEEK_SET); if (ret < 0) { - ret = krb5_fcc_interpret(errno); - MAYBE_CLOSE(id, ret); + ret = krb5_fcc_interpret(context, errno); + MAYBE_CLOSE(context, id, ret); return ret; } - kret = krb5_fcc_read_principal(id, &creds->client); + kret = krb5_fcc_read_principal(context, id, &creds->client); TCHECK(kret); - kret = krb5_fcc_read_principal(id, &creds->server); + kret = krb5_fcc_read_principal(context, id, &creds->server); TCHECK(kret); - kret = krb5_fcc_read_keyblock(id, &creds->keyblock); + kret = krb5_fcc_read_keyblock(context, id, &creds->keyblock); TCHECK(kret); - kret = krb5_fcc_read_times(id, &creds->times); + kret = krb5_fcc_read_times(context, id, &creds->times); TCHECK(kret); - kret = krb5_fcc_read_octet(id, &octet); + kret = krb5_fcc_read_octet(context, id, &octet); TCHECK(kret); creds->is_skey = octet; - kret = krb5_fcc_read_int32(id, &int32); + kret = krb5_fcc_read_int32(context, id, &int32); TCHECK(kret); creds->ticket_flags = int32; - kret = krb5_fcc_read_addrs(id, &creds->addresses); + kret = krb5_fcc_read_addrs(context, id, &creds->addresses); TCHECK(kret); - kret = krb5_fcc_read_authdata(id, &creds->authdata); + kret = krb5_fcc_read_authdata(context, id, &creds->authdata); TCHECK(kret); - kret = krb5_fcc_read_data(id, &creds->ticket); + kret = krb5_fcc_read_data(context, id, &creds->ticket); TCHECK(kret); - kret = krb5_fcc_read_data(id, &creds->second_ticket); + kret = krb5_fcc_read_data(context, id, &creds->second_ticket); TCHECK(kret); fcursor->pos = lseek(((krb5_fcc_data *) id->data)->fd, 0, SEEK_CUR); cursor = (krb5_cc_cursor *) fcursor; lose: - MAYBE_CLOSE(id, kret); /* won't overwrite kret + MAYBE_CLOSE(context, id, kret); /* won't overwrite kret if already set */ if (kret != KRB5_OK) - krb5_free_cred_contents(creds); + krb5_free_cred_contents(context, creds); return kret; } diff --git a/src/lib/krb5/ccache/file/fcc_read.c b/src/lib/krb5/ccache/file/fcc_read.c index 7a91d6a0f..801cb7501 100644 --- a/src/lib/krb5/ccache/file/fcc_read.c +++ b/src/lib/krb5/ccache/file/fcc_read.c @@ -41,7 +41,8 @@ * system errors (read) */ krb5_error_code -krb5_fcc_read(id, buf, len) +krb5_fcc_read(context, id, buf, len) + krb5_context context; krb5_ccache id; krb5_pointer buf; int len; @@ -50,7 +51,7 @@ krb5_fcc_read(id, buf, len) ret = read(((krb5_fcc_data *) id->data)->fd, (char *) buf, len); if (ret == -1) - return krb5_fcc_interpret(errno); + return krb5_fcc_interpret(context, errno); else if (ret != len) return KRB5_CC_END; else @@ -75,7 +76,8 @@ krb5_fcc_read(id, buf, len) */ krb5_error_code -krb5_fcc_read_principal(id, princ) +krb5_fcc_read_principal(context, id, princ) + krb5_context context; krb5_ccache id; krb5_principal *princ; { @@ -89,13 +91,13 @@ krb5_fcc_read_principal(id, princ) type = KRB5_NT_UNKNOWN; } else { /* Read principal type */ - kret = krb5_fcc_read_int32(id, &type); + kret = krb5_fcc_read_int32(context, id, &type); if (kret != KRB5_OK) return kret; } /* Read the number of components */ - kret = krb5_fcc_read_int32(id, &length); + kret = krb5_fcc_read_int32(context, id, &length); if (kret != KRB5_OK) return kret; @@ -121,13 +123,13 @@ krb5_fcc_read_principal(id, princ) tmpprinc->length = length; tmpprinc->type = type; - kret = krb5_fcc_read_data(id, krb5_princ_realm(tmpprinc)); + kret = krb5_fcc_read_data(context, id, krb5_princ_realm(context, tmpprinc)); i = 0; CHECK(kret); for (i=0; i < length; i++) { - kret = krb5_fcc_read_data(id, krb5_princ_component(tmpprinc, i)); + kret = krb5_fcc_read_data(context, id, krb5_princ_component(context, tmpprinc, i)); CHECK(kret); } *princ = tmpprinc; @@ -135,14 +137,15 @@ krb5_fcc_read_principal(id, princ) errout: while(--i >= 0) - free(krb5_princ_component(tmpprinc, i)->data); + free(krb5_princ_component(context, tmpprinc, i)->data); free((char *)tmpprinc->data); free((char *)tmpprinc); return kret; } krb5_error_code -krb5_fcc_read_addrs(id, addrs) +krb5_fcc_read_addrs(context, id, addrs) + krb5_context context; krb5_ccache id; krb5_address ***addrs; { @@ -153,7 +156,7 @@ krb5_fcc_read_addrs(id, addrs) *addrs = 0; /* Read the number of components */ - kret = krb5_fcc_read_int32(id, &length); + kret = krb5_fcc_read_int32(context, id, &length); CHECK(kret); /* Make *addrs able to hold length pointers to krb5_address structs @@ -166,22 +169,23 @@ krb5_fcc_read_addrs(id, addrs) for (i=0; i < length; i++) { (*addrs)[i] = (krb5_address *) malloc(sizeof(krb5_address)); if ((*addrs)[i] == NULL) { - krb5_free_addresses(*addrs); + krb5_free_addresses(context, *addrs); return KRB5_CC_NOMEM; } - kret = krb5_fcc_read_addr(id, (*addrs)[i]); + kret = krb5_fcc_read_addr(context, id, (*addrs)[i]); CHECK(kret); } return KRB5_OK; errout: if (*addrs) - krb5_free_addresses(*addrs); + krb5_free_addresses(context, *addrs); return kret; } krb5_error_code -krb5_fcc_read_keyblock(id, keyblock) +krb5_fcc_read_keyblock(context, id, keyblock) + krb5_context context; krb5_ccache id; krb5_keyblock *keyblock; { @@ -193,19 +197,19 @@ krb5_fcc_read_keyblock(id, keyblock) keyblock->magic = KV5M_KEYBLOCK; keyblock->contents = 0; - kret = krb5_fcc_read_ui_2(id, &ui2); + kret = krb5_fcc_read_ui_2(context, id, &ui2); keyblock->keytype = ui2; CHECK(kret); if ((data->version == KRB5_FCC_FVNO_1) || (data->version == KRB5_FCC_FVNO_2)) keyblock->etype = ETYPE_UNKNOWN; else { - kret = krb5_fcc_read_ui_2(id, &ui2); + kret = krb5_fcc_read_ui_2(context, id, &ui2); keyblock->etype = ui2; CHECK(kret); } - kret = krb5_fcc_read_int32(id, &int32); + kret = krb5_fcc_read_int32(context, id, &int32); CHECK(kret); keyblock->length = int32; if ( keyblock->length == 0 ) @@ -215,7 +219,7 @@ krb5_fcc_read_keyblock(id, keyblock) if (keyblock->contents == NULL) return KRB5_CC_NOMEM; - kret = krb5_fcc_read(id, keyblock->contents, keyblock->length); + kret = krb5_fcc_read(context, id, keyblock->contents, keyblock->length); if (kret) goto errout; @@ -227,7 +231,8 @@ krb5_fcc_read_keyblock(id, keyblock) } krb5_error_code -krb5_fcc_read_data(id, data) +krb5_fcc_read_data(context, id, data) + krb5_context context; krb5_ccache id; krb5_data *data; { @@ -236,7 +241,7 @@ krb5_fcc_read_data(id, data) data->magic = KV5M_DATA; data->data = 0; - kret = krb5_fcc_read_int32(id, &data->length); + kret = krb5_fcc_read_int32(context, id, &data->length); CHECK(kret); if (data->length == 0) { @@ -248,7 +253,7 @@ krb5_fcc_read_data(id, data) if (data->data == NULL) return KRB5_CC_NOMEM; - kret = krb5_fcc_read(id, data->data, data->length); + kret = krb5_fcc_read(context, id, data->data, data->length); CHECK(kret); data->data[data->length] = 0; /* Null terminate, just in case.... */ @@ -260,7 +265,8 @@ krb5_fcc_read_data(id, data) } krb5_error_code -krb5_fcc_read_addr(id, addr) +krb5_fcc_read_addr(context, id, addr) + krb5_context context; krb5_ccache id; krb5_address *addr; { @@ -271,11 +277,11 @@ krb5_fcc_read_addr(id, addr) addr->magic = KV5M_ADDRESS; addr->contents = 0; - kret = krb5_fcc_read_ui_2(id, &ui2); + kret = krb5_fcc_read_ui_2(context, id, &ui2); CHECK(kret); addr->addrtype = ui2; - kret = krb5_fcc_read_int32(id, &int32); + kret = krb5_fcc_read_int32(context, id, &int32); CHECK(kret); addr->length = int32; @@ -286,7 +292,7 @@ krb5_fcc_read_addr(id, addr) if (addr->contents == NULL) return KRB5_CC_NOMEM; - kret = krb5_fcc_read(id, addr->contents, addr->length); + kret = krb5_fcc_read(context, id, addr->contents, addr->length); CHECK(kret); return KRB5_OK; @@ -297,7 +303,8 @@ krb5_fcc_read_addr(id, addr) } krb5_error_code -krb5_fcc_read_int32(id, i) +krb5_fcc_read_int32(context, id, i) + krb5_context context; krb5_ccache id; krb5_int32 *i; { @@ -307,9 +314,9 @@ krb5_fcc_read_int32(id, i) if ((data->version == KRB5_FCC_FVNO_1) || (data->version == KRB5_FCC_FVNO_2)) - return krb5_fcc_read(id, (krb5_pointer) i, sizeof(krb5_int32)); + return krb5_fcc_read(context, id, (krb5_pointer) i, sizeof(krb5_int32)); else { - retval = krb5_fcc_read(id, buf, 4); + retval = krb5_fcc_read(context, id, buf, 4); if (retval) return retval; *i = (((((buf[0] << 8) + buf[1]) << 8 ) + buf[2]) << 8) + buf[3]; @@ -318,7 +325,8 @@ krb5_fcc_read_int32(id, i) } krb5_error_code -krb5_fcc_read_ui_2(id, i) +krb5_fcc_read_ui_2(context, id, i) + krb5_context context; krb5_ccache id; krb5_ui_2 *i; { @@ -328,9 +336,9 @@ krb5_fcc_read_ui_2(id, i) if ((data->version == KRB5_FCC_FVNO_1) || (data->version == KRB5_FCC_FVNO_2)) - return krb5_fcc_read(id, (krb5_pointer) i, sizeof(krb5_ui_2)); + return krb5_fcc_read(context, id, (krb5_pointer) i, sizeof(krb5_ui_2)); else { - retval = krb5_fcc_read(id, buf, 2); + retval = krb5_fcc_read(context, id, buf, 2); if (retval) return retval; *i = (buf[0] << 8) + buf[1]; @@ -339,16 +347,18 @@ krb5_fcc_read_ui_2(id, i) } krb5_error_code -krb5_fcc_read_octet(id, i) +krb5_fcc_read_octet(context, id, i) + krb5_context context; krb5_ccache id; krb5_octet *i; { - return krb5_fcc_read(id, (krb5_pointer) i, 1); + return krb5_fcc_read(context, id, (krb5_pointer) i, 1); } krb5_error_code -krb5_fcc_read_times(id, t) +krb5_fcc_read_times(context, id, t) + krb5_context context; krb5_ccache id; krb5_ticket_times *t; { @@ -358,21 +368,21 @@ krb5_fcc_read_times(id, t) if ((data->version == KRB5_FCC_FVNO_1) || (data->version == KRB5_FCC_FVNO_2)) - return krb5_fcc_read(id, (krb5_pointer) t, sizeof(krb5_ticket_times)); + return krb5_fcc_read(context, id, (krb5_pointer) t, sizeof(krb5_ticket_times)); else { - retval = krb5_fcc_read_int32(id, &i); + retval = krb5_fcc_read_int32(context, id, &i); CHECK(retval); t->authtime = i; - retval = krb5_fcc_read_int32(id, &i); + retval = krb5_fcc_read_int32(context, id, &i); CHECK(retval); t->starttime = i; - retval = krb5_fcc_read_int32(id, &i); + retval = krb5_fcc_read_int32(context, id, &i); CHECK(retval); t->endtime = i; - retval = krb5_fcc_read_int32(id, &i); + retval = krb5_fcc_read_int32(context, id, &i); CHECK(retval); t->renew_till = i; } @@ -382,7 +392,8 @@ errout: } krb5_error_code -krb5_fcc_read_authdata(id, a) +krb5_fcc_read_authdata(context, id, a) + krb5_context context; krb5_ccache id; krb5_authdata ***a; { @@ -393,7 +404,7 @@ krb5_fcc_read_authdata(id, a) *a = 0; /* Read the number of components */ - kret = krb5_fcc_read_int32(id, &length); + kret = krb5_fcc_read_int32(context, id, &length); CHECK(kret); if (length == 0) @@ -409,22 +420,23 @@ krb5_fcc_read_authdata(id, a) for (i=0; i < length; i++) { (*a)[i] = (krb5_authdata *) malloc(sizeof(krb5_authdata)); if ((*a)[i] == NULL) { - krb5_free_authdata(*a); + krb5_free_authdata(context, *a); return KRB5_CC_NOMEM; } - kret = krb5_fcc_read_authdatum(id, (*a)[i]); + kret = krb5_fcc_read_authdatum(context, id, (*a)[i]); CHECK(kret); } return KRB5_OK; errout: if (*a) - krb5_free_authdata(*a); + krb5_free_authdata(context, *a); return kret; } krb5_error_code -krb5_fcc_read_authdatum(id, a) +krb5_fcc_read_authdatum(context, id, a) + krb5_context context; krb5_ccache id; krb5_authdata *a; { @@ -435,9 +447,9 @@ krb5_fcc_read_authdatum(id, a) a->magic = KV5M_AUTHDATA; a->contents = NULL; - kret = krb5_fcc_read_ui_2(id, &a->ad_type); + kret = krb5_fcc_read_ui_2(context, id, &a->ad_type); CHECK(kret); - kret = krb5_fcc_read_int32(id, &int32); + kret = krb5_fcc_read_int32(context, id, &int32); CHECK(kret); a->length = int32; @@ -448,7 +460,7 @@ krb5_fcc_read_authdatum(id, a) if (a->contents == NULL) return KRB5_CC_NOMEM; - kret = krb5_fcc_read(id, a->contents, a->length); + kret = krb5_fcc_read(context, id, a->contents, a->length); CHECK(kret); return KRB5_OK; diff --git a/src/lib/krb5/ccache/file/fcc_reslv.c b/src/lib/krb5/ccache/file/fcc_reslv.c index 7c61ec52d..2944f43bb 100644 --- a/src/lib/krb5/ccache/file/fcc_reslv.c +++ b/src/lib/krb5/ccache/file/fcc_reslv.c @@ -50,7 +50,8 @@ extern krb5_cc_ops krb5_fcc_ops; * permission errors */ krb5_error_code -krb5_fcc_resolve (id, residual) +krb5_fcc_resolve (context, id, residual) + krb5_context context; krb5_ccache *id; char *residual; { diff --git a/src/lib/krb5/ccache/file/fcc_retrv.c b/src/lib/krb5/ccache/file/fcc_retrv.c index cf96ce058..b9d324224 100644 --- a/src/lib/krb5/ccache/file/fcc_retrv.c +++ b/src/lib/krb5/ccache/file/fcc_retrv.c @@ -33,11 +33,13 @@ static krb5_boolean times_match PROTOTYPE((const krb5_ticket_times *, const krb5_ticket_times *)); static krb5_boolean standard_fields_match - PROTOTYPE((const krb5_creds *, + PROTOTYPE((krb5_context, + const krb5_creds *, const krb5_creds *)); static krb5_boolean srvname_match - PROTOTYPE((const krb5_creds *, + PROTOTYPE((krb5_context, + const krb5_creds *, const krb5_creds *)); static krb5_boolean authdata_match @@ -83,7 +85,8 @@ register const krb5_data *data1, *data2; * KRB5_CC_NOMEM */ krb5_error_code -krb5_fcc_retrieve(id, whichfields, mcreds, creds) +krb5_fcc_retrieve(context, id, whichfields, mcreds, creds) + krb5_context context; krb5_ccache id; krb5_flags whichfields; krb5_creds *mcreds; @@ -96,14 +99,14 @@ krb5_fcc_retrieve(id, whichfields, mcreds, creds) krb5_error_code kret; krb5_creds fetchcreds; - kret = krb5_fcc_start_seq_get(id, &cursor); + kret = krb5_fcc_start_seq_get(context, id, &cursor); if (kret != KRB5_OK) return kret; - while ((kret = krb5_fcc_next_cred(id, &cursor, &fetchcreds)) == KRB5_OK) { + while ((kret = krb5_fcc_next_cred(context, id, &cursor, &fetchcreds)) == KRB5_OK) { if (((set(KRB5_TC_MATCH_SRV_NAMEONLY) && - srvname_match(mcreds, &fetchcreds)) || - standard_fields_match(mcreds, &fetchcreds)) + srvname_match(context, mcreds, &fetchcreds)) || + standard_fields_match(context, mcreds, &fetchcreds)) && (! set(KRB5_TC_MATCH_IS_SKEY) || mcreds->is_skey == fetchcreds.is_skey) @@ -127,17 +130,17 @@ krb5_fcc_retrieve(id, whichfields, mcreds, creds) data_match (&mcreds->second_ticket, &fetchcreds.second_ticket)) ) { - krb5_fcc_end_seq_get(id, &cursor); + krb5_fcc_end_seq_get(context, id, &cursor); *creds = fetchcreds; return KRB5_OK; } /* This one doesn't match */ - krb5_free_cred_contents(&fetchcreds); + krb5_free_cred_contents(context, &fetchcreds); } /* If we get here, a match wasn't found */ - krb5_fcc_end_seq_get(id, &cursor); + krb5_fcc_end_seq_get(context, id, &cursor); return KRB5_CC_NOTFOUND; } @@ -159,23 +162,25 @@ register const krb5_ticket_times *t2; } static krb5_boolean -standard_fields_match(mcreds, creds) +standard_fields_match(context, mcreds, creds) + krb5_context context; register const krb5_creds *mcreds, *creds; { - return (krb5_principal_compare(mcreds->client,creds->client) && - krb5_principal_compare(mcreds->server,creds->server)); + return (krb5_principal_compare(context, mcreds->client,creds->client) && + krb5_principal_compare(context, mcreds->server,creds->server)); } /* only match the server name portion, not the server realm portion */ static krb5_boolean -srvname_match(mcreds, creds) +srvname_match(context, mcreds, creds) + krb5_context context; register const krb5_creds *mcreds, *creds; { krb5_boolean retval; krb5_principal_data p1, p2; - retval = krb5_principal_compare(mcreds->client,creds->client); + retval = krb5_principal_compare(context, mcreds->client,creds->client); if (retval != TRUE) return retval; /* @@ -184,7 +189,7 @@ register const krb5_creds *mcreds, *creds; p1 = *mcreds->server; p2 = *creds->server; p1.realm = p2.realm; - return krb5_principal_compare(&p1, &p2); + return krb5_principal_compare(context, &p1, &p2); } static krb5_boolean diff --git a/src/lib/krb5/ccache/file/fcc_sflags.c b/src/lib/krb5/ccache/file/fcc_sflags.c index 1eb42afd4..ac4b5a96f 100644 --- a/src/lib/krb5/ccache/file/fcc_sflags.c +++ b/src/lib/krb5/ccache/file/fcc_sflags.c @@ -40,7 +40,8 @@ * Sets the operational flags of id to flags. */ krb5_error_code -krb5_fcc_set_flags(id, flags) +krb5_fcc_set_flags(context, id, flags) + krb5_context context; krb5_ccache id; krb5_flags flags; { @@ -48,12 +49,12 @@ krb5_fcc_set_flags(id, flags) if (flags & KRB5_TC_OPENCLOSE) { /* asking to turn on OPENCLOSE mode */ if (!OPENCLOSE(id)) { - (void) krb5_fcc_close_file (id); + (void) krb5_fcc_close_file (context, id); } } else { /* asking to turn off OPENCLOSE mode, meaning it must be left open. We open if it's not yet open */ - MAYBE_OPEN(id, FCC_OPEN_RDONLY); + MAYBE_OPEN(context, id, FCC_OPEN_RDONLY); } ((krb5_fcc_data *) id->data)->flags = flags; diff --git a/src/lib/krb5/ccache/file/fcc_skip.c b/src/lib/krb5/ccache/file/fcc_skip.c index 2cafdb0e2..15aa43bd2 100644 --- a/src/lib/krb5/ccache/file/fcc_skip.c +++ b/src/lib/krb5/ccache/file/fcc_skip.c @@ -29,17 +29,18 @@ #include "fcc.h" krb5_error_code -krb5_fcc_skip_principal(id) +krb5_fcc_skip_principal(context, id) + krb5_context context; krb5_ccache id; { krb5_error_code kret; krb5_principal princ; - kret = krb5_fcc_read_principal(id, &princ); + kret = krb5_fcc_read_principal(context, id, &princ); if (kret != KRB5_OK) return kret; - krb5_free_principal(princ); + krb5_free_principal(context, princ); return KRB5_OK; } diff --git a/src/lib/krb5/ccache/file/fcc_sseq.c b/src/lib/krb5/ccache/file/fcc_sseq.c index 1cdc0136f..622cd5701 100644 --- a/src/lib/krb5/ccache/file/fcc_sseq.c +++ b/src/lib/krb5/ccache/file/fcc_sseq.c @@ -41,7 +41,8 @@ * system errors */ krb5_error_code -krb5_fcc_start_seq_get(id, cursor) +krb5_fcc_start_seq_get(context, id, cursor) + krb5_context context; krb5_ccache id; krb5_cc_cursor *cursor; { @@ -52,7 +53,7 @@ krb5_fcc_start_seq_get(id, cursor) if (fcursor == NULL) return KRB5_CC_NOMEM; if (OPENCLOSE(id)) { - ret = krb5_fcc_open_file(id, FCC_OPEN_RDONLY); + ret = krb5_fcc_open_file(context, id, FCC_OPEN_RDONLY); if (ret) { krb5_xfree(fcursor); return ret; @@ -64,10 +65,10 @@ krb5_fcc_start_seq_get(id, cursor) /* Make sure we start reading right after the primary principal */ - krb5_fcc_skip_principal(id); + krb5_fcc_skip_principal(context, id); fcursor->pos = lseek(((krb5_fcc_data *) id->data)->fd, 0, SEEK_CUR); *cursor = (krb5_cc_cursor) fcursor; - MAYBE_CLOSE(id, ret); + MAYBE_CLOSE(context, id, ret); return ret; } diff --git a/src/lib/krb5/ccache/file/fcc_store.c b/src/lib/krb5/ccache/file/fcc_store.c index 9586f7483..352cae763 100644 --- a/src/lib/krb5/ccache/file/fcc_store.c +++ b/src/lib/krb5/ccache/file/fcc_store.c @@ -42,45 +42,46 @@ * storage failure errors */ krb5_error_code -krb5_fcc_store(id, creds) +krb5_fcc_store(context, id, creds) + krb5_context context; krb5_ccache id; krb5_creds *creds; { #define TCHECK(ret) if (ret != KRB5_OK) goto lose; krb5_error_code ret; - MAYBE_OPEN(id, FCC_OPEN_RDWR); + MAYBE_OPEN(context, id, FCC_OPEN_RDWR); /* Make sure we are writing to the end of the file */ ret = lseek(((krb5_fcc_data *) id->data)->fd, 0, SEEK_END); if (ret < 0) { - MAYBE_CLOSE_IGNORE(id); - return krb5_fcc_interpret(errno); + MAYBE_CLOSE_IGNORE(context, id); + return krb5_fcc_interpret(context, errno); } - ret = krb5_fcc_store_principal(id, creds->client); + ret = krb5_fcc_store_principal(context, id, creds->client); TCHECK(ret); - ret = krb5_fcc_store_principal(id, creds->server); + ret = krb5_fcc_store_principal(context, id, creds->server); TCHECK(ret); - ret = krb5_fcc_store_keyblock(id, &creds->keyblock); + ret = krb5_fcc_store_keyblock(context, id, &creds->keyblock); TCHECK(ret); - ret = krb5_fcc_store_times(id, &creds->times); + ret = krb5_fcc_store_times(context, id, &creds->times); TCHECK(ret); - ret = krb5_fcc_store_octet(id, creds->is_skey); + ret = krb5_fcc_store_octet(context, id, creds->is_skey); TCHECK(ret); - ret = krb5_fcc_store_int32(id, creds->ticket_flags); + ret = krb5_fcc_store_int32(context, id, creds->ticket_flags); TCHECK(ret); - ret = krb5_fcc_store_addrs(id, creds->addresses); + ret = krb5_fcc_store_addrs(context, id, creds->addresses); TCHECK(ret); - ret = krb5_fcc_store_authdata(id, creds->authdata); + ret = krb5_fcc_store_authdata(context, id, creds->authdata); TCHECK(ret); - ret = krb5_fcc_store_data(id, &creds->ticket); + ret = krb5_fcc_store_data(context, id, &creds->ticket); TCHECK(ret); - ret = krb5_fcc_store_data(id, &creds->second_ticket); + ret = krb5_fcc_store_data(context, id, &creds->second_ticket); TCHECK(ret); lose: - MAYBE_CLOSE(id, ret); + MAYBE_CLOSE(context, id, ret); return ret; #undef TCHECK } diff --git a/src/lib/krb5/ccache/file/fcc_test.c b/src/lib/krb5/ccache/file/fcc_test.c index 497e9c529..3e3b5c57c 100644 --- a/src/lib/krb5/ccache/file/fcc_test.c +++ b/src/lib/krb5/ccache/file/fcc_test.c @@ -111,27 +111,27 @@ void fcc_test() init_test_cred(); - kret = krb5_fcc_resolve(&id, "/tmp/tkt_test"); + kret = krb5_fcc_resolve(context, &id, "/tmp/tkt_test"); CHECK(kret, "resolve"); - kret = krb5_fcc_initialize(id, test_creds.client); + kret = krb5_fcc_initialize(context, id, test_creds.client); CHECK(kret, "initialize"); - kret = krb5_fcc_store(id, &test_creds); + kret = krb5_fcc_store(context, id, &test_creds); CHECK(kret, "store"); - kret = krb5_fcc_start_seq_get(id, &cursor); + kret = krb5_fcc_start_seq_get(context, id, &cursor); CHECK(kret, "start_seq_get"); kret = 0; while (kret != KRB5_CC_END) { printf("Calling next_cred\n"); - kret = krb5_fcc_next_cred(id, &cursor, &creds); + kret = krb5_fcc_next_cred(context, id, &cursor, &creds); CHECK(kret, "next_cred"); } - kret = krb5_fcc_end_seq_get(id, &cursor); + kret = krb5_fcc_end_seq_get(context, id, &cursor); CHECK(kret, "end_seq_get"); - kret = krb5_fcc_destroy(id); + kret = krb5_fcc_destroy(context, id); CHECK(kret, "destroy"); - kret = krb5_fcc_close(id); + kret = krb5_fcc_close(context, id); CHECK(kret, "close"); } diff --git a/src/lib/krb5/ccache/file/fcc_write.c b/src/lib/krb5/ccache/file/fcc_write.c index 2633bd509..f5c8f8c30 100644 --- a/src/lib/krb5/ccache/file/fcc_write.c +++ b/src/lib/krb5/ccache/file/fcc_write.c @@ -42,7 +42,8 @@ * system errors */ krb5_error_code -krb5_fcc_write(id, buf, len) +krb5_fcc_write(context, id, buf, len) + krb5_context context; krb5_ccache id; krb5_pointer buf; int len; @@ -51,7 +52,7 @@ krb5_fcc_write(id, buf, len) ret = write(((krb5_fcc_data *)id->data)->fd, (char *) buf, len); if (ret < 0) - return krb5_fcc_interpret(errno); + return krb5_fcc_interpret(context, errno); if (ret != len) return KRB5_CC_WRITE; return KRB5_OK; @@ -72,7 +73,8 @@ krb5_fcc_write(id, buf, len) */ krb5_error_code -krb5_fcc_store_principal(id, princ) +krb5_fcc_store_principal(context, id, princ) + krb5_context context; krb5_ccache id; krb5_principal princ; { @@ -80,8 +82,8 @@ krb5_fcc_store_principal(id, princ) krb5_error_code ret; krb5_int32 i, length, tmp, type; - type = krb5_princ_type(princ); - tmp = length = krb5_princ_size(princ); + type = krb5_princ_type(context, princ); + tmp = length = krb5_princ_size(context, princ); if (data->version == KRB5_FCC_FVNO_1) { /* @@ -91,18 +93,18 @@ krb5_fcc_store_principal(id, princ) */ tmp++; } else { - ret = krb5_fcc_store_int32(id, type); + ret = krb5_fcc_store_int32(context, id, type); CHECK(ret); } - ret = krb5_fcc_store_int32(id, tmp); + ret = krb5_fcc_store_int32(context, id, tmp); CHECK(ret); - ret = krb5_fcc_store_data(id, krb5_princ_realm(princ)); + ret = krb5_fcc_store_data(context, id, krb5_princ_realm(context, princ)); CHECK(ret); for (i=0; i < length; i++) { - ret = krb5_fcc_store_data(id, krb5_princ_component(princ, i)); + ret = krb5_fcc_store_data(context, id, krb5_princ_component(context, princ, i)); CHECK(ret); } @@ -110,7 +112,8 @@ krb5_fcc_store_principal(id, princ) } krb5_error_code -krb5_fcc_store_addrs(id, addrs) +krb5_fcc_store_addrs(context, id, addrs) + krb5_context context; krb5_ccache id; krb5_address ** addrs; { @@ -125,10 +128,10 @@ krb5_fcc_store_addrs(id, addrs) length += 1; } - ret = krb5_fcc_store_int32(id, length); + ret = krb5_fcc_store_int32(context, id, length); CHECK(ret); for (i=0; i < length; i++) { - ret = krb5_fcc_store_addr(id, addrs[i]); + ret = krb5_fcc_store_addr(context, id, addrs[i]); CHECK(ret); } @@ -136,54 +139,58 @@ krb5_fcc_store_addrs(id, addrs) } krb5_error_code -krb5_fcc_store_keyblock(id, keyblock) +krb5_fcc_store_keyblock(context, id, keyblock) + krb5_context context; krb5_ccache id; krb5_keyblock *keyblock; { krb5_fcc_data *data = (krb5_fcc_data *)id->data; krb5_error_code ret; - ret = krb5_fcc_store_ui_2(id, keyblock->keytype); + ret = krb5_fcc_store_ui_2(context, id, keyblock->keytype); CHECK(ret); if ((data->version != KRB5_FCC_FVNO_1) && (data->version != KRB5_FCC_FVNO_2)) { - ret = krb5_fcc_store_ui_2(id, keyblock->etype); + ret = krb5_fcc_store_ui_2(context, id, keyblock->etype); CHECK(ret); } - ret = krb5_fcc_store_int32(id, keyblock->length); + ret = krb5_fcc_store_int32(context, id, keyblock->length); CHECK(ret); - return krb5_fcc_write(id, (char *) keyblock->contents, keyblock->length); + return krb5_fcc_write(context, id, (char *) keyblock->contents, keyblock->length); } krb5_error_code -krb5_fcc_store_addr(id, addr) +krb5_fcc_store_addr(context, id, addr) + krb5_context context; krb5_ccache id; krb5_address *addr; { krb5_error_code ret; - ret = krb5_fcc_store_ui_2(id, addr->addrtype); + ret = krb5_fcc_store_ui_2(context, id, addr->addrtype); CHECK(ret); - ret = krb5_fcc_store_int32(id, addr->length); + ret = krb5_fcc_store_int32(context, id, addr->length); CHECK(ret); - return krb5_fcc_write(id, (char *) addr->contents, addr->length); + return krb5_fcc_write(context, id, (char *) addr->contents, addr->length); } krb5_error_code -krb5_fcc_store_data(id, data) +krb5_fcc_store_data(context, id, data) + krb5_context context; krb5_ccache id; krb5_data *data; { krb5_error_code ret; - ret = krb5_fcc_store_int32(id, data->length); + ret = krb5_fcc_store_int32(context, id, data->length); CHECK(ret); - return krb5_fcc_write(id, data->data, data->length); + return krb5_fcc_write(context, id, data->data, data->length); } krb5_error_code -krb5_fcc_store_int32(id, i) +krb5_fcc_store_int32(context, id, i) + krb5_context context; krb5_ccache id; krb5_int32 i; { @@ -192,7 +199,7 @@ krb5_fcc_store_int32(id, i) if ((data->version == KRB5_FCC_FVNO_1) || (data->version == KRB5_FCC_FVNO_2)) - return krb5_fcc_write(id, (char *) &i, sizeof(krb5_int32)); + return krb5_fcc_write(context, id, (char *) &i, sizeof(krb5_int32)); else { buf[3] = i & 0xFF; i >>= 8; @@ -202,12 +209,13 @@ krb5_fcc_store_int32(id, i) i >>= 8; buf[0] = i & 0xFF; - return krb5_fcc_write(id, buf, 4); + return krb5_fcc_write(context, id, buf, 4); } } krb5_error_code -krb5_fcc_store_ui_2(id, i) +krb5_fcc_store_ui_2(context, id, i) + krb5_context context; krb5_ccache id; krb5_int32 i; { @@ -218,29 +226,31 @@ krb5_fcc_store_ui_2(id, i) if ((data->version == KRB5_FCC_FVNO_1) || (data->version == KRB5_FCC_FVNO_2)) { ibuf = i; - return krb5_fcc_write(id, (char *) &ibuf, sizeof(krb5_ui_2)); + return krb5_fcc_write(context, id, (char *) &ibuf, sizeof(krb5_ui_2)); } else { buf[1] = i & 0xFF; i >>= 8; buf[0] = i & 0xFF; - return krb5_fcc_write(id, buf, 2); + return krb5_fcc_write(context, id, buf, 2); } } krb5_error_code -krb5_fcc_store_octet(id, i) +krb5_fcc_store_octet(context, id, i) + krb5_context context; krb5_ccache id; krb5_int32 i; { krb5_octet ibuf; ibuf = i; - return krb5_fcc_write(id, (char *) &ibuf, 1); + return krb5_fcc_write(context, id, (char *) &ibuf, 1); } krb5_error_code -krb5_fcc_store_times(id, t) +krb5_fcc_store_times(context, id, t) + krb5_context context; krb5_ccache id; krb5_ticket_times *t; { @@ -249,22 +259,23 @@ krb5_fcc_store_times(id, t) if ((data->version == KRB5_FCC_FVNO_1) || (data->version == KRB5_FCC_FVNO_2)) - return krb5_fcc_write(id, (char *) t, sizeof(krb5_ticket_times)); + return krb5_fcc_write(context, id, (char *) t, sizeof(krb5_ticket_times)); else { - retval = krb5_fcc_store_int32(id, t->authtime); + retval = krb5_fcc_store_int32(context, id, t->authtime); CHECK(retval); - retval = krb5_fcc_store_int32(id, t->starttime); + retval = krb5_fcc_store_int32(context, id, t->starttime); CHECK(retval); - retval = krb5_fcc_store_int32(id, t->endtime); + retval = krb5_fcc_store_int32(context, id, t->endtime); CHECK(retval); - retval = krb5_fcc_store_int32(id, t->renew_till); + retval = krb5_fcc_store_int32(context, id, t->renew_till); CHECK(retval); return 0; } } krb5_error_code -krb5_fcc_store_authdata(id, a) +krb5_fcc_store_authdata(context, id, a) + krb5_context context; krb5_ccache id; krb5_authdata **a; { @@ -277,24 +288,25 @@ krb5_fcc_store_authdata(id, a) length++; } - ret = krb5_fcc_store_int32(id, length); + ret = krb5_fcc_store_int32(context, id, length); CHECK(ret); for (i=0; iad_type); + ret = krb5_fcc_store_ui_2(context, id, a->ad_type); CHECK(ret); - ret = krb5_fcc_store_int32(id, a->length); + ret = krb5_fcc_store_int32(context, id, a->length); CHECK(ret); - return krb5_fcc_write(id, (krb5_pointer) a->contents, a->length); + return krb5_fcc_write(context, id, (krb5_pointer) a->contents, a->length); } diff --git a/src/lib/krb5/ccache/stdio/ChangeLog b/src/lib/krb5/ccache/stdio/ChangeLog index 13a9b22a4..98f59a2be 100644 --- a/src/lib/krb5/ccache/stdio/ChangeLog +++ b/src/lib/krb5/ccache/stdio/ChangeLog @@ -1,3 +1,7 @@ +Fri Jan 13 15:23:47 1995 Chris Provenzano (proven@mit.edu) + + * Added krb5_context to all krb5_routines + Tue Dec 13 15:42:50 1994 * scc_write.c (krb5_scc_store_addrs): If a null addresses is diff --git a/src/lib/krb5/ccache/stdio/scc-proto.h b/src/lib/krb5/ccache/stdio/scc-proto.h index 9cae84123..cf2e69fd2 100644 --- a/src/lib/krb5/ccache/stdio/scc-proto.h +++ b/src/lib/krb5/ccache/stdio/scc-proto.h @@ -29,85 +29,203 @@ #define KRB5_SCC_PROTO__ /* scc_close.c */ -krb5_error_code krb5_scc_close PROTOTYPE((krb5_ccache id )); +krb5_error_code krb5_scc_close + PROTOTYPE((krb5_context, + krb5_ccache id )); /* scc_defnam.c */ -char *krb5_scc_default_name PROTOTYPE((void )); +char *krb5_scc_default_name + PROTOTYPE((krb5_context)); /* scc_destry.c */ -krb5_error_code krb5_scc_destroy PROTOTYPE((krb5_ccache id )); +krb5_error_code krb5_scc_destroy + PROTOTYPE((krb5_context, + krb5_ccache id )); /* scc_eseq.c */ -krb5_error_code krb5_scc_end_seq_get PROTOTYPE((krb5_ccache id , krb5_cc_cursor *cursor )); +krb5_error_code krb5_scc_end_seq_get + PROTOTYPE((krb5_context, + krb5_ccache id , + krb5_cc_cursor *cursor )); /* scc_gennew.c */ -krb5_error_code krb5_scc_generate_new PROTOTYPE((krb5_ccache *id )); +krb5_error_code krb5_scc_generate_new + PROTOTYPE((krb5_context, + krb5_ccache *id )); /* scc_getnam.c */ -char *krb5_scc_get_name PROTOTYPE((krb5_ccache id )); +char *krb5_scc_get_name + PROTOTYPE((krb5_context, + krb5_ccache id )); /* scc_gprin.c */ -krb5_error_code krb5_scc_get_principal PROTOTYPE((krb5_ccache id , krb5_principal *princ )); +krb5_error_code krb5_scc_get_principal + PROTOTYPE((krb5_context, + krb5_ccache id , + krb5_principal *princ )); /* scc_init.c */ -krb5_error_code krb5_scc_initialize PROTOTYPE((krb5_ccache id , krb5_principal princ )); +krb5_error_code krb5_scc_initialize + PROTOTYPE((krb5_context, + krb5_ccache id , + krb5_principal princ )); /* scc_maybe.c */ -krb5_error_code krb5_scc_close_file PROTOTYPE((krb5_ccache)); -krb5_error_code krb5_scc_open_file PROTOTYPE((krb5_ccache,int)); +krb5_error_code krb5_scc_close_file + PROTOTYPE((krb5_context, + krb5_ccache)); +krb5_error_code krb5_scc_open_file + PROTOTYPE((krb5_context, + krb5_ccache, + int)); /* scc_nseq.c */ -krb5_error_code krb5_scc_next_cred PROTOTYPE((krb5_ccache id , krb5_cc_cursor *cursor , krb5_creds *creds )); +krb5_error_code krb5_scc_next_cred + PROTOTYPE((krb5_context, + krb5_ccache id , + krb5_cc_cursor *cursor , + krb5_creds *creds )); /* scc_read.c */ -krb5_error_code krb5_scc_read_principal PROTOTYPE((krb5_ccache id , krb5_principal *princ )); -krb5_error_code krb5_scc_read_keyblock PROTOTYPE((krb5_ccache id , krb5_keyblock *keyblock )); -krb5_error_code krb5_scc_read_data PROTOTYPE((krb5_ccache id , krb5_data *data )); -krb5_error_code krb5_scc_read_int32 PROTOTYPE((krb5_ccache id , krb5_int32 *i )); -krb5_error_code krb5_scc_read_ui_2 PROTOTYPE((krb5_ccache id , krb5_ui_2 *i )); -krb5_error_code krb5_scc_read_octet PROTOTYPE((krb5_ccache id , krb5_octet *i )); -krb5_error_code krb5_scc_read_times PROTOTYPE((krb5_ccache id , krb5_ticket_times *t )); -krb5_error_code krb5_scc_read_addrs PROTOTYPE((krb5_ccache, krb5_address ***)); -krb5_error_code krb5_scc_read_addr PROTOTYPE((krb5_ccache, krb5_address *)); -krb5_error_code krb5_scc_read_authdata PROTOTYPE((krb5_ccache, krb5_authdata***)); -krb5_error_code krb5_scc_read_authdatum PROTOTYPE((krb5_ccache, krb5_authdata*)); +krb5_error_code krb5_scc_read_principal + PROTOTYPE((krb5_context, + krb5_ccache id , + krb5_principal *princ )); +krb5_error_code krb5_scc_read_keyblock + PROTOTYPE((krb5_context, + krb5_ccache id , + krb5_keyblock *keyblock )); +krb5_error_code krb5_scc_read_data + PROTOTYPE((krb5_context, + krb5_ccache id , + krb5_data *data )); +krb5_error_code krb5_scc_read_int32 + PROTOTYPE((krb5_context, + krb5_ccache id , + krb5_int32 *i )); +krb5_error_code krb5_scc_read_ui_2 + PROTOTYPE((krb5_context, + krb5_ccache id , + krb5_ui_2 *i )); +krb5_error_code krb5_scc_read_octet + PROTOTYPE((krb5_context, + krb5_ccache id , + krb5_octet *i )); +krb5_error_code krb5_scc_read_times + PROTOTYPE((krb5_context, + krb5_ccache id , + krb5_ticket_times *t )); +krb5_error_code krb5_scc_read_addrs + PROTOTYPE((krb5_context, + krb5_ccache, + krb5_address ***)); +krb5_error_code krb5_scc_read_addr + PROTOTYPE((krb5_context, + krb5_ccache, + krb5_address *)); +krb5_error_code krb5_scc_read_authdata + PROTOTYPE((krb5_context, + krb5_ccache, + krb5_authdata***)); +krb5_error_code krb5_scc_read_authdatum + PROTOTYPE((krb5_context, + krb5_ccache, + krb5_authdata*)); /* scc_reslv.c */ -krb5_error_code krb5_scc_resolve PROTOTYPE((krb5_ccache *id , char *residual )); +krb5_error_code krb5_scc_resolve + PROTOTYPE((krb5_context, + krb5_ccache *id , + char *residual )); /* scc_retrv.c */ -krb5_error_code krb5_scc_retrieve PROTOTYPE((krb5_ccache id , krb5_flags whichfields , krb5_creds *mcreds , krb5_creds *creds )); +krb5_error_code krb5_scc_retrieve + PROTOTYPE((krb5_context, + krb5_ccache id , + krb5_flags whichfields , + krb5_creds *mcreds , + krb5_creds *creds )); /* scc_sseq.c */ -krb5_error_code krb5_scc_start_seq_get PROTOTYPE((krb5_ccache id , krb5_cc_cursor *cursor )); +krb5_error_code krb5_scc_start_seq_get + PROTOTYPE((krb5_context, + krb5_ccache id , + krb5_cc_cursor *cursor )); /* scc_store.c */ -krb5_error_code krb5_scc_store PROTOTYPE((krb5_ccache id , krb5_creds *creds )); +krb5_error_code krb5_scc_store + PROTOTYPE((krb5_context, + krb5_ccache id , + krb5_creds *creds )); /* scc_skip.c */ -krb5_error_code krb5_scc_skip_principal PROTOTYPE((krb5_ccache id )); +krb5_error_code krb5_scc_skip_principal + PROTOTYPE((krb5_context, + krb5_ccache id )); /* scc_sflags.c */ -krb5_error_code krb5_scc_set_flags PROTOTYPE((krb5_ccache id , krb5_flags flags )); +krb5_error_code krb5_scc_set_flags + PROTOTYPE((krb5_context, + krb5_ccache id , + krb5_flags flags )); /* scc_ops.c */ extern krb5_cc_ops krb5_scc_ops; /* scc_write.c */ -krb5_error_code krb5_scc_write PROTOTYPE((krb5_ccache id , krb5_pointer buf , int len )); -krb5_error_code krb5_scc_store_principal PROTOTYPE((krb5_ccache id , krb5_principal princ )); -krb5_error_code krb5_scc_store_keyblock PROTOTYPE((krb5_ccache id , krb5_keyblock *keyblock )); -krb5_error_code krb5_scc_store_data PROTOTYPE((krb5_ccache id , krb5_data *data )); -krb5_error_code krb5_scc_store_int32 PROTOTYPE((krb5_ccache id , krb5_int32 i )); -krb5_error_code krb5_scc_store_ui_2 PROTOTYPE((krb5_ccache id , krb5_int32 i )); -krb5_error_code krb5_scc_store_octet PROTOTYPE((krb5_ccache id , krb5_int32 i )); -krb5_error_code krb5_scc_store_times PROTOTYPE((krb5_ccache id , krb5_ticket_times *t )); -krb5_error_code krb5_scc_store_addrs PROTOTYPE((krb5_ccache , krb5_address ** )); -krb5_error_code krb5_scc_store_addr PROTOTYPE((krb5_ccache , krb5_address * )); -krb5_error_code krb5_scc_store_authdata PROTOTYPE((krb5_ccache, krb5_authdata **)); -krb5_error_code krb5_scc_store_authdatum PROTOTYPE((krb5_ccache, krb5_authdata *)); +krb5_error_code krb5_scc_write + PROTOTYPE((krb5_context, + krb5_ccache id , + krb5_pointer buf , + int len )); +krb5_error_code krb5_scc_store_principal + PROTOTYPE((krb5_context, + krb5_ccache id , + krb5_principal princ )); +krb5_error_code krb5_scc_store_keyblock + PROTOTYPE((krb5_context, + krb5_ccache id , + krb5_keyblock *keyblock )); +krb5_error_code krb5_scc_store_data + PROTOTYPE((krb5_context, + krb5_ccache id , + krb5_data *data )); +krb5_error_code krb5_scc_store_int32 + PROTOTYPE((krb5_context, + krb5_ccache id , + krb5_int32 i )); +krb5_error_code krb5_scc_store_ui_2 + PROTOTYPE((krb5_context, + krb5_ccache id , + krb5_int32 i )); +krb5_error_code krb5_scc_store_octet + PROTOTYPE((krb5_context, + krb5_ccache id , + krb5_int32 i )); +krb5_error_code krb5_scc_store_times + PROTOTYPE((krb5_context, + krb5_ccache id , + krb5_ticket_times *t )); +krb5_error_code krb5_scc_store_addrs + PROTOTYPE((krb5_context, + krb5_ccache , + krb5_address ** )); +krb5_error_code krb5_scc_store_addr + PROTOTYPE((krb5_context, + krb5_ccache , + krb5_address * )); +krb5_error_code krb5_scc_store_authdata + PROTOTYPE((krb5_context, + krb5_ccache, + krb5_authdata **)); +krb5_error_code krb5_scc_store_authdatum + PROTOTYPE((krb5_context, + krb5_ccache, + krb5_authdata *)); /* scc_errs.c */ -krb5_error_code krb5_scc_interpret PROTOTYPE((int )); +krb5_error_code krb5_scc_interpret + PROTOTYPE((krb5_context, + int )); #endif /* KRB5_SCC_PROTO__ */ diff --git a/src/lib/krb5/ccache/stdio/scc.h b/src/lib/krb5/ccache/stdio/scc.h index 203b316b5..0a7ae0159 100644 --- a/src/lib/krb5/ccache/stdio/scc.h +++ b/src/lib/krb5/ccache/stdio/scc.h @@ -79,16 +79,16 @@ typedef struct _krb5_scc_cursor { long pos; } krb5_scc_cursor; -#define MAYBE_OPEN(ID, MODE) \ +#define MAYBE_OPEN(context, ID, MODE) \ { \ if (OPENCLOSE (ID)) { \ - krb5_error_code maybe_open_ret = krb5_scc_open_file (ID,MODE); \ + krb5_error_code maybe_open_ret = krb5_scc_open_file (context, ID,MODE); \ if (maybe_open_ret) return maybe_open_ret; } } -#define MAYBE_CLOSE(ID, RET) \ +#define MAYBE_CLOSE(context, ID, RET) \ { \ if (OPENCLOSE (ID)) { \ - krb5_error_code maybe_close_ret = krb5_scc_close_file (ID); \ + krb5_error_code maybe_close_ret = krb5_scc_close_file (context, ID); \ if (!(RET)) RET = maybe_close_ret; } } /* DO NOT ADD ANYTHING AFTER THIS #endif */ diff --git a/src/lib/krb5/ccache/stdio/scc_close.c b/src/lib/krb5/ccache/stdio/scc_close.c index 760aed313..77f6d6b23 100644 --- a/src/lib/krb5/ccache/stdio/scc_close.c +++ b/src/lib/krb5/ccache/stdio/scc_close.c @@ -37,7 +37,8 @@ * associated with the cache. */ krb5_error_code -krb5_scc_close(id) +krb5_scc_close(context, id) + krb5_context context; krb5_ccache id; { register int closeval = KRB5_OK; @@ -47,7 +48,7 @@ krb5_scc_close(id) closeval = fclose (data->file); data->file = 0; if (closeval == -1) { - closeval = krb5_scc_interpret(errno); + closeval = krb5_scc_interpret(context, errno); } else closeval = KRB5_OK; diff --git a/src/lib/krb5/ccache/stdio/scc_defnam.c b/src/lib/krb5/ccache/stdio/scc_defnam.c index c62a59871..bf4d15da5 100644 --- a/src/lib/krb5/ccache/stdio/scc_defnam.c +++ b/src/lib/krb5/ccache/stdio/scc_defnam.c @@ -49,7 +49,8 @@ static char krb5_default_name_string[KRB5_SCC_MAXLEN] = ""; */ char * -krb5_scc_default_name () +krb5_scc_default_name (context) + krb5_context context; { char *krb5ccache, *getenv(); int len; diff --git a/src/lib/krb5/ccache/stdio/scc_destry.c b/src/lib/krb5/ccache/stdio/scc_destry.c index 88e261c74..7b1db878d 100644 --- a/src/lib/krb5/ccache/stdio/scc_destry.c +++ b/src/lib/krb5/ccache/stdio/scc_destry.c @@ -39,7 +39,8 @@ * Errors: * system errors */ -krb5_error_code krb5_scc_destroy(id) +krb5_error_code krb5_scc_destroy(context, id) + krb5_context context; krb5_ccache id; { #if 0 @@ -56,7 +57,7 @@ krb5_error_code krb5_scc_destroy(id) ret = remove (data->filename); if (ret < 0) { - ret = krb5_scc_interpret(errno); + ret = krb5_scc_interpret(context, errno); if (OPENCLOSE(id)) { (void) fclose(data->file); data->file = 0; @@ -72,7 +73,7 @@ krb5_error_code krb5_scc_destroy(id) */ ret = fstat(fileno(data->file), &buf); if (ret < 0) { - ret = krb5_scc_interpret(errno); + ret = krb5_scc_interpret(context, errno); if (OPENCLOSE(id)) { (void) fclose(data->file); data->file = 0; @@ -86,7 +87,7 @@ krb5_error_code krb5_scc_destroy(id) memset (zeros, 0, BUFSIZ); for (i=0; i < size / BUFSIZ; i++) if (fwrite(data->file, zeros, BUFSIZ) < 0) { - ret = krb5_scc_interpret(errno); + ret = krb5_scc_interpret(context, errno); if (OPENCLOSE(id)) { (void) fclose(data->file); data->file = 0; @@ -95,7 +96,7 @@ krb5_error_code krb5_scc_destroy(id) } if (fwrite(data->file, zeros, size % BUFSIZ) < 0) { - ret = krb5_scc_interpret(errno); + ret = krb5_scc_interpret(context, errno); if (OPENCLOSE(id)) { (void) fclose(data->file); data->file = 0; @@ -108,7 +109,7 @@ krb5_error_code krb5_scc_destroy(id) #endif if (ret) - ret = krb5_scc_interpret(errno); + ret = krb5_scc_interpret(context, errno); cleanup: krb5_xfree(data->filename); diff --git a/src/lib/krb5/ccache/stdio/scc_errs.c b/src/lib/krb5/ccache/stdio/scc_errs.c index ad3c6450e..77ad352af 100644 --- a/src/lib/krb5/ccache/stdio/scc_errs.c +++ b/src/lib/krb5/ccache/stdio/scc_errs.c @@ -29,7 +29,8 @@ #include "scc.h" krb5_error_code -krb5_scc_interpret(errnum) +krb5_scc_interpret(context, errnum) + krb5_context context; int errnum; { register int retval; diff --git a/src/lib/krb5/ccache/stdio/scc_eseq.c b/src/lib/krb5/ccache/stdio/scc_eseq.c index d49b7b821..f8cf9c0b6 100644 --- a/src/lib/krb5/ccache/stdio/scc_eseq.c +++ b/src/lib/krb5/ccache/stdio/scc_eseq.c @@ -41,12 +41,13 @@ */ /* ARGSUSED */ krb5_error_code -krb5_scc_end_seq_get(id, cursor) +krb5_scc_end_seq_get(context, id, cursor) + krb5_context context; krb5_ccache id; krb5_cc_cursor *cursor; { int ret = KRB5_OK; -/* MAYBE_CLOSE (id, ret);*/ +/* MAYBE_CLOSE (context, id, ret);*/ krb5_xfree((krb5_scc_cursor *) *cursor); diff --git a/src/lib/krb5/ccache/stdio/scc_gennew.c b/src/lib/krb5/ccache/stdio/scc_gennew.c index 7775a6fb2..8851ddba7 100644 --- a/src/lib/krb5/ccache/stdio/scc_gennew.c +++ b/src/lib/krb5/ccache/stdio/scc_gennew.c @@ -52,7 +52,8 @@ extern krb5_cc_ops krb5_scc_ops; * system errors (from open) */ krb5_error_code -krb5_scc_generate_new (id) +krb5_scc_generate_new (context, id) + krb5_context context; krb5_ccache *id; { krb5_ccache lid; @@ -99,19 +100,19 @@ krb5_scc_generate_new (id) f = fopen (((krb5_scc_data *) lid->data)->filename, "w+"); #endif if (!f) { - retcode = krb5_scc_interpret (errno); + retcode = krb5_scc_interpret (context, errno); goto err_out; } else { krb5_int16 scc_fvno = htons(KRB5_SCC_DEFAULT_FVNO); if (!fwrite((char *)&scc_fvno, sizeof(scc_fvno), 1, f)) { - retcode = krb5_scc_interpret(errno); + retcode = krb5_scc_interpret(context, errno); (void) fclose(f); (void) remove(((krb5_scc_data *) lid->data)->filename); goto err_out; } if (fclose(f) == EOF) { - retcode = krb5_scc_interpret(errno); + retcode = krb5_scc_interpret(context, errno); (void) remove(((krb5_scc_data *) lid->data)->filename); goto err_out; } diff --git a/src/lib/krb5/ccache/stdio/scc_getnam.c b/src/lib/krb5/ccache/stdio/scc_getnam.c index 61f55d1d7..0303c1009 100644 --- a/src/lib/krb5/ccache/stdio/scc_getnam.c +++ b/src/lib/krb5/ccache/stdio/scc_getnam.c @@ -36,7 +36,8 @@ * The name of the file cred cache id. */ char * -krb5_scc_get_name (id) +krb5_scc_get_name (context, id) + krb5_context context; krb5_ccache id; { return (char *) ((krb5_scc_data *) id->data)->filename; diff --git a/src/lib/krb5/ccache/stdio/scc_gprin.c b/src/lib/krb5/ccache/stdio/scc_gprin.c index 2054fed06..3f6c90d5e 100644 --- a/src/lib/krb5/ccache/stdio/scc_gprin.c +++ b/src/lib/krb5/ccache/stdio/scc_gprin.c @@ -41,18 +41,19 @@ * KRB5_CC_NOMEM */ krb5_error_code -krb5_scc_get_principal(id, princ) +krb5_scc_get_principal(context, id, princ) + krb5_context context; krb5_ccache id; krb5_principal *princ; { krb5_error_code kret; - MAYBE_OPEN (id, SCC_OPEN_RDONLY); + MAYBE_OPEN (context, id, SCC_OPEN_RDONLY); /* skip over vno at beginning of file */ fseek(((krb5_scc_data *) id->data)->file, sizeof(krb5_int16), 0); - kret = krb5_scc_read_principal(id, princ); + kret = krb5_scc_read_principal(context, id, princ); - MAYBE_CLOSE (id, kret); + MAYBE_CLOSE (context, id, kret); return kret; } diff --git a/src/lib/krb5/ccache/stdio/scc_init.c b/src/lib/krb5/ccache/stdio/scc_init.c index b3bde42df..ff765f9fa 100644 --- a/src/lib/krb5/ccache/stdio/scc_init.c +++ b/src/lib/krb5/ccache/stdio/scc_init.c @@ -41,20 +41,21 @@ * permission errors */ krb5_error_code -krb5_scc_initialize(id, princ) +krb5_scc_initialize(context, id, princ) + krb5_context context; krb5_ccache id; krb5_principal princ; { int ret; - ret = krb5_scc_open_file (id, SCC_OPEN_AND_ERASE); + ret = krb5_scc_open_file (context, id, SCC_OPEN_AND_ERASE); if (ret < 0) - return krb5_scc_interpret(errno); + return krb5_scc_interpret(context, errno); #if 0 ret = fchmod(((krb5_scc_data *) id->data)->fd, S_IREAD | S_IWRITE); if (ret == -1) { - ret = krb5_scc_interpret(errno); + ret = krb5_scc_interpret(context, errno); if (OPENCLOSE(id)) { close(((krb5_scc_data *)id->data)->fd); ((krb5_scc_data *) id->data)->fd = -1; @@ -62,9 +63,9 @@ krb5_scc_initialize(id, princ) return ret; } #endif - krb5_scc_store_principal(id, princ); + krb5_scc_store_principal(context, id, princ); - MAYBE_CLOSE (id, ret); + MAYBE_CLOSE (context, id, ret); return ret; } diff --git a/src/lib/krb5/ccache/stdio/scc_maybe.c b/src/lib/krb5/ccache/stdio/scc_maybe.c index 410dc6b6c..e337fe54a 100644 --- a/src/lib/krb5/ccache/stdio/scc_maybe.c +++ b/src/lib/krb5/ccache/stdio/scc_maybe.c @@ -40,7 +40,8 @@ int krb5_scc_default_format = KRB5_SCC_DEFAULT_FVNO; krb5_error_code -krb5_scc_close_file (id) +krb5_scc_close_file (context, id) + krb5_context context; krb5_ccache id; { krb5_scc_data *data; @@ -63,22 +64,23 @@ krb5_scc_close_file (id) memset (data->stdio_buffer, 0, sizeof (data->stdio_buffer)); if (ret == EOF) { int errsave = errno; - (void) krb5_unlock_file(data->file, data->filename); + (void) krb5_unlock_file(context, data->file, data->filename); (void) fclose (data->file); data->file = 0; - return krb5_scc_interpret (errsave); + return krb5_scc_interpret (context, errsave); } - retval = krb5_unlock_file(data->file, data->filename); + retval = krb5_unlock_file(context, data->file, data->filename); ret = fclose (data->file); data->file = 0; if (retval) return retval; else - return ret ? krb5_scc_interpret (errno) : 0; + return ret ? krb5_scc_interpret (context, errno) : 0; } krb5_error_code -krb5_scc_open_file (id, mode) +krb5_scc_open_file (context, id, mode) + krb5_context context; krb5_ccache id; int mode; { @@ -91,7 +93,7 @@ krb5_scc_open_file (id, mode) data = (krb5_scc_data *) id->data; if (data->file) { /* Don't know what state it's in; shut down and start anew. */ - (void) krb5_unlock_file(data->file, data->filename); + (void) krb5_unlock_file(context, data->file, data->filename); (void) fclose (data->file); data->file = 0; } @@ -125,7 +127,7 @@ krb5_scc_open_file (id, mode) f = fopen (data->filename, open_flag); if (!f) - return krb5_scc_interpret (errno); + return krb5_scc_interpret (context, errno); #ifdef HAS_SETVBUF setvbuf(f, data->stdio_buffer, _IOFBF, sizeof (data->stdio_buffer)); #else @@ -133,14 +135,14 @@ krb5_scc_open_file (id, mode) #endif switch (mode) { case SCC_OPEN_RDONLY: - if (retval = krb5_lock_file(f, data->filename, KRB5_LOCKMODE_SHARED)) { + if (retval = krb5_lock_file(context, f, data->filename, KRB5_LOCKMODE_SHARED)) { (void) fclose(f); return retval; } break; case SCC_OPEN_RDWR: case SCC_OPEN_AND_ERASE: - if (retval = krb5_lock_file(f, data->filename, + if (retval = krb5_lock_file(context, f, data->filename, KRB5_LOCKMODE_EXCLUSIVE)) { (void) fclose(f); return retval; @@ -155,21 +157,21 @@ krb5_scc_open_file (id, mode) data->version = krb5_scc_default_format; if (!fwrite((char *)&scc_fvno, sizeof(scc_fvno), 1, f)) { errsave = errno; - (void) krb5_unlock_file(f, data->filename); + (void) krb5_unlock_file(context, f, data->filename); (void) fclose(f); - return krb5_scc_interpret(errsave); + return krb5_scc_interpret(context, errsave); } } else { /* verify a valid version number is there */ if (!fread((char *)&scc_fvno, sizeof(scc_fvno), 1, f)) { - (void) krb5_unlock_file(f, data->filename); + (void) krb5_unlock_file(context, f, data->filename); (void) fclose(f); return KRB5_CCACHE_BADVNO; } if ((scc_fvno != htons(KRB5_SCC_FVNO_1)) && (scc_fvno != htons(KRB5_SCC_FVNO_2)) && (scc_fvno != htons(KRB5_SCC_FVNO_3))) { - (void) krb5_unlock_file(f, data->filename); + (void) krb5_unlock_file(context, f, data->filename); (void) fclose(f); return KRB5_CCACHE_BADVNO; } diff --git a/src/lib/krb5/ccache/stdio/scc_nseq.c b/src/lib/krb5/ccache/stdio/scc_nseq.c index 365f57330..49f9e255d 100644 --- a/src/lib/krb5/ccache/stdio/scc_nseq.c +++ b/src/lib/krb5/ccache/stdio/scc_nseq.c @@ -49,7 +49,8 @@ * system errors */ krb5_error_code -krb5_scc_next_cred(id, cursor, creds) +krb5_scc_next_cred(context, id, cursor, creds) + krb5_context context; krb5_ccache id; krb5_cc_cursor *cursor; krb5_creds *creds; @@ -71,37 +72,37 @@ krb5_scc_next_cred(id, cursor, creds) Z (addresses); #undef Z - MAYBE_OPEN (id, SCC_OPEN_RDONLY); + MAYBE_OPEN (context, id, SCC_OPEN_RDONLY); fcursor = (krb5_scc_cursor *) *cursor; ret = fseek(((krb5_scc_data *) id->data)->file, fcursor->pos, 0); if (ret < 0) { - ret = krb5_scc_interpret(errno); - MAYBE_CLOSE (id, ret); + ret = krb5_scc_interpret(context, errno); + MAYBE_CLOSE (context, id, ret); return ret; } - kret = krb5_scc_read_principal(id, &creds->client); + kret = krb5_scc_read_principal(context, id, &creds->client); TCHECK(kret); - kret = krb5_scc_read_principal(id, &creds->server); + kret = krb5_scc_read_principal(context, id, &creds->server); TCHECK(kret); - kret = krb5_scc_read_keyblock(id, &creds->keyblock); + kret = krb5_scc_read_keyblock(context, id, &creds->keyblock); TCHECK(kret); - kret = krb5_scc_read_times(id, &creds->times); + kret = krb5_scc_read_times(context, id, &creds->times); TCHECK(kret); - kret = krb5_scc_read_octet(id, &octet); + kret = krb5_scc_read_octet(context, id, &octet); TCHECK(kret); creds->is_skey = octet; - kret = krb5_scc_read_int32(id, &int32); + kret = krb5_scc_read_int32(context, id, &int32); TCHECK(kret); creds->ticket_flags = int32; - kret = krb5_scc_read_addrs(id, &creds->addresses); + kret = krb5_scc_read_addrs(context, id, &creds->addresses); TCHECK(kret); - kret = krb5_scc_read_authdata (id, &creds->authdata); + kret = krb5_scc_read_authdata (context, id, &creds->authdata); TCHECK (kret); - kret = krb5_scc_read_data(id, &creds->ticket); + kret = krb5_scc_read_data(context, id, &creds->ticket); TCHECK(kret); - kret = krb5_scc_read_data(id, &creds->second_ticket); + kret = krb5_scc_read_data(context, id, &creds->second_ticket); TCHECK(kret); fcursor->pos = ftell(((krb5_scc_data *) id->data)->file); @@ -109,8 +110,8 @@ krb5_scc_next_cred(id, cursor, creds) lose: if (kret != KRB5_OK) { - krb5_free_cred_contents(creds); + krb5_free_cred_contents(context, creds); } - MAYBE_CLOSE (id, kret); + MAYBE_CLOSE (context, id, kret); return kret; } diff --git a/src/lib/krb5/ccache/stdio/scc_read.c b/src/lib/krb5/ccache/stdio/scc_read.c index 1a7ee5a2d..29dbdb966 100644 --- a/src/lib/krb5/ccache/stdio/scc_read.c +++ b/src/lib/krb5/ccache/stdio/scc_read.c @@ -39,7 +39,8 @@ * system errors (read) */ krb5_error_code -krb5_scc_read(id, buf, len) +krb5_scc_read(context, id, buf, len) + krb5_context context; krb5_ccache id; krb5_pointer buf; int len; @@ -49,7 +50,7 @@ krb5_scc_read(id, buf, len) errno = 0; ret = fread((char *) buf, 1, len, ((krb5_scc_data *) id->data)->file); if ((ret == 0) && errno) - return krb5_scc_interpret(errno); + return krb5_scc_interpret(context, errno); else if (ret != len) return KRB5_CC_END; else @@ -74,7 +75,8 @@ krb5_scc_read(id, buf, len) */ krb5_error_code -krb5_scc_read_principal(id, princ) +krb5_scc_read_principal(context, id, princ) + krb5_context context; krb5_ccache id; krb5_principal *princ; { @@ -88,13 +90,13 @@ krb5_scc_read_principal(id, princ) type = KRB5_NT_UNKNOWN; } else { /* Read principal type */ - kret = krb5_scc_read_int32(id, &type); + kret = krb5_scc_read_int32(context, id, &type); if (kret != KRB5_OK) return kret; } /* Read the number of components */ - kret = krb5_scc_read_int32(id, &length); + kret = krb5_scc_read_int32(context, id, &length); if (kret != KRB5_OK) return kret; @@ -120,13 +122,13 @@ krb5_scc_read_principal(id, princ) tmpprinc->length = length; tmpprinc->type = type; - kret = krb5_scc_read_data(id, krb5_princ_realm(tmpprinc)); + kret = krb5_scc_read_data(context, id, krb5_princ_realm(context, tmpprinc)); i = 0; CHECK(kret); for (i=0; i < length; i++) { - kret = krb5_scc_read_data(id, krb5_princ_component(tmpprinc, i)); + kret = krb5_scc_read_data(context, id, krb5_princ_component(context, tmpprinc, i)); CHECK(kret); } *princ = tmpprinc; @@ -134,14 +136,15 @@ krb5_scc_read_principal(id, princ) errout: while(--i >= 0) - free(krb5_princ_component(tmpprinc, i)->data); + free(krb5_princ_component(context, tmpprinc, i)->data); free((char *)tmpprinc->data); free((char *)tmpprinc); return kret; } krb5_error_code -krb5_scc_read_addrs(id, addrs) +krb5_scc_read_addrs(context, id, addrs) + krb5_context context; krb5_ccache id; krb5_address ***addrs; { @@ -152,7 +155,7 @@ krb5_scc_read_addrs(id, addrs) *addrs = 0; /* Read the number of components */ - kret = krb5_scc_read_int32(id, &length); + kret = krb5_scc_read_int32(context, id, &length); CHECK(kret); /* Make *addrs able to hold length pointers to krb5_address structs @@ -165,22 +168,23 @@ krb5_scc_read_addrs(id, addrs) for (i=0; i < length; i++) { (*addrs)[i] = (krb5_address *) malloc(sizeof(krb5_address)); if ((*addrs)[i] == NULL) { - krb5_free_addresses(*addrs); + krb5_free_addresses(context, *addrs); return KRB5_CC_NOMEM; } - kret = krb5_scc_read_addr(id, (*addrs)[i]); + kret = krb5_scc_read_addr(context, id, (*addrs)[i]); CHECK(kret); } return KRB5_OK; errout: if (*addrs) - krb5_free_addresses(*addrs); + krb5_free_addresses(context, *addrs); return kret; } krb5_error_code -krb5_scc_read_keyblock(id, keyblock) +krb5_scc_read_keyblock(context, id, keyblock) + krb5_context context; krb5_ccache id; krb5_keyblock *keyblock; { @@ -192,19 +196,19 @@ krb5_scc_read_keyblock(id, keyblock) keyblock->magic = KV5M_KEYBLOCK; keyblock->contents = 0; - kret = krb5_scc_read_ui_2(id, &ui2); + kret = krb5_scc_read_ui_2(context, id, &ui2); keyblock->keytype = ui2; CHECK(kret); if ((data->version == KRB5_SCC_FVNO_1) || (data->version == KRB5_SCC_FVNO_2)) keyblock->etype = ETYPE_UNKNOWN; else { - kret = krb5_scc_read_ui_2(id, &ui2); + kret = krb5_scc_read_ui_2(context, id, &ui2); keyblock->etype = ui2; CHECK(kret); } - kret = krb5_scc_read_int32(id, &int32); + kret = krb5_scc_read_int32(context, id, &int32); CHECK(kret); keyblock->length = int32; if ( keyblock->length == 0 ) @@ -214,7 +218,7 @@ krb5_scc_read_keyblock(id, keyblock) if (keyblock->contents == NULL) return KRB5_CC_NOMEM; - kret = krb5_scc_read(id, keyblock->contents, keyblock->length); + kret = krb5_scc_read(context, id, keyblock->contents, keyblock->length); if (kret) goto errout; @@ -226,7 +230,8 @@ krb5_scc_read_keyblock(id, keyblock) } krb5_error_code -krb5_scc_read_data(id, data) +krb5_scc_read_data(context, id, data) + krb5_context context; krb5_ccache id; krb5_data *data; { @@ -235,7 +240,7 @@ krb5_scc_read_data(id, data) data->magic = KV5M_DATA; data->data = 0; - kret = krb5_scc_read_int32(id, &data->length); + kret = krb5_scc_read_int32(context, id, &data->length); CHECK(kret); if (data->length == 0) { @@ -247,7 +252,7 @@ krb5_scc_read_data(id, data) if (data->data == NULL) return KRB5_CC_NOMEM; - kret = krb5_scc_read(id, data->data, data->length); + kret = krb5_scc_read(context, id, data->data, data->length); CHECK(kret); data->data[data->length] = 0; /* Null terminate, just in case.... */ @@ -259,7 +264,8 @@ krb5_scc_read_data(id, data) } krb5_error_code -krb5_scc_read_addr(id, addr) +krb5_scc_read_addr(context, id, addr) + krb5_context context; krb5_ccache id; krb5_address *addr; { @@ -270,11 +276,11 @@ krb5_scc_read_addr(id, addr) addr->magic = KV5M_ADDRESS; addr->contents = 0; - kret = krb5_scc_read_ui_2(id, &ui2); + kret = krb5_scc_read_ui_2(context, id, &ui2); CHECK(kret); addr->addrtype = ui2; - kret = krb5_scc_read_int32(id, &int32); + kret = krb5_scc_read_int32(context, id, &int32); CHECK(kret); addr->length = int32; @@ -285,7 +291,7 @@ krb5_scc_read_addr(id, addr) if (addr->contents == NULL) return KRB5_CC_NOMEM; - kret = krb5_scc_read(id, addr->contents, addr->length); + kret = krb5_scc_read(context, id, addr->contents, addr->length); CHECK(kret); return KRB5_OK; @@ -296,7 +302,8 @@ krb5_scc_read_addr(id, addr) } krb5_error_code -krb5_scc_read_int32(id, i) +krb5_scc_read_int32(context, id, i) + krb5_context context; krb5_ccache id; krb5_int32 *i; { @@ -306,9 +313,9 @@ krb5_scc_read_int32(id, i) if ((data->version == KRB5_SCC_FVNO_1) || (data->version == KRB5_SCC_FVNO_2)) - return krb5_scc_read(id, (krb5_pointer) i, sizeof(krb5_int32)); + return krb5_scc_read(context, id, (krb5_pointer) i, sizeof(krb5_int32)); else { - retval = krb5_scc_read(id, buf, 4); + retval = krb5_scc_read(context, id, buf, 4); if (retval) return retval; *i = (((((buf[0] << 8) + buf[1]) << 8 ) + buf[2]) << 8) + buf[3]; @@ -317,7 +324,8 @@ krb5_scc_read_int32(id, i) } krb5_error_code -krb5_scc_read_ui_2(id, i) +krb5_scc_read_ui_2(context, id, i) + krb5_context context; krb5_ccache id; krb5_ui_2 *i; { @@ -327,9 +335,9 @@ krb5_scc_read_ui_2(id, i) if ((data->version == KRB5_SCC_FVNO_1) || (data->version == KRB5_SCC_FVNO_2)) - return krb5_scc_read(id, (krb5_pointer) i, sizeof(krb5_ui_2)); + return krb5_scc_read(context, id, (krb5_pointer) i, sizeof(krb5_ui_2)); else { - retval = krb5_scc_read(id, buf, 2); + retval = krb5_scc_read(context, id, buf, 2); if (retval) return retval; *i = (buf[0] << 8) + buf[1]; @@ -338,16 +346,18 @@ krb5_scc_read_ui_2(id, i) } krb5_error_code -krb5_scc_read_octet(id, i) +krb5_scc_read_octet(context, id, i) + krb5_context context; krb5_ccache id; krb5_octet *i; { - return krb5_scc_read(id, (krb5_pointer) i, 1); + return krb5_scc_read(context, id, (krb5_pointer) i, 1); } krb5_error_code -krb5_scc_read_times(id, t) +krb5_scc_read_times(context, id, t) + krb5_context context; krb5_ccache id; krb5_ticket_times *t; { @@ -357,21 +367,21 @@ krb5_scc_read_times(id, t) if ((data->version == KRB5_SCC_FVNO_1) || (data->version == KRB5_SCC_FVNO_2)) - return krb5_scc_read(id, (krb5_pointer) t, sizeof(krb5_ticket_times)); + return krb5_scc_read(context, id, (krb5_pointer) t, sizeof(krb5_ticket_times)); else { - retval = krb5_scc_read_int32(id, &i); + retval = krb5_scc_read_int32(context, id, &i); CHECK(retval); t->authtime = i; - retval = krb5_scc_read_int32(id, &i); + retval = krb5_scc_read_int32(context, id, &i); CHECK(retval); t->starttime = i; - retval = krb5_scc_read_int32(id, &i); + retval = krb5_scc_read_int32(context, id, &i); CHECK(retval); t->endtime = i; - retval = krb5_scc_read_int32(id, &i); + retval = krb5_scc_read_int32(context, id, &i); CHECK(retval); t->renew_till = i; } @@ -381,7 +391,8 @@ errout: } krb5_error_code -krb5_scc_read_authdata(id, a) +krb5_scc_read_authdata(context, id, a) + krb5_context context; krb5_ccache id; krb5_authdata ***a; { @@ -392,7 +403,7 @@ krb5_scc_read_authdata(id, a) *a = 0; /* Read the number of components */ - kret = krb5_scc_read_int32(id, &length); + kret = krb5_scc_read_int32(context, id, &length); CHECK(kret); if (length == 0) @@ -408,22 +419,23 @@ krb5_scc_read_authdata(id, a) for (i=0; i < length; i++) { (*a)[i] = (krb5_authdata *) malloc(sizeof(krb5_authdata)); if ((*a)[i] == NULL) { - krb5_free_authdata(*a); + krb5_free_authdata(context, *a); return KRB5_CC_NOMEM; } - kret = krb5_scc_read_authdatum(id, (*a)[i]); + kret = krb5_scc_read_authdatum(context, id, (*a)[i]); CHECK(kret); } return KRB5_OK; errout: if (*a) - krb5_free_authdata(*a); + krb5_free_authdata(context, *a); return kret; } krb5_error_code -krb5_scc_read_authdatum(id, a) +krb5_scc_read_authdatum(context, id, a) + krb5_context context; krb5_ccache id; krb5_authdata *a; { @@ -434,9 +446,9 @@ krb5_scc_read_authdatum(id, a) a->magic = KV5M_AUTHDATA; a->contents = NULL; - kret = krb5_scc_read_ui_2(id, &a->ad_type); + kret = krb5_scc_read_ui_2(context, id, &a->ad_type); CHECK(kret); - kret = krb5_scc_read_int32(id, &int32); + kret = krb5_scc_read_int32(context, id, &int32); CHECK(kret); a->length = int32; @@ -447,7 +459,7 @@ krb5_scc_read_authdatum(id, a) if (a->contents == NULL) return KRB5_CC_NOMEM; - kret = krb5_scc_read(id, a->contents, a->length); + kret = krb5_scc_read(context, id, a->contents, a->length); CHECK(kret); return KRB5_OK; diff --git a/src/lib/krb5/ccache/stdio/scc_reslv.c b/src/lib/krb5/ccache/stdio/scc_reslv.c index 40c3e81df..1add343e6 100644 --- a/src/lib/krb5/ccache/stdio/scc_reslv.c +++ b/src/lib/krb5/ccache/stdio/scc_reslv.c @@ -50,7 +50,8 @@ extern krb5_cc_ops krb5_scc_ops; * permission errors */ krb5_error_code -krb5_scc_resolve (id, residual) +krb5_scc_resolve (context, id, residual) + krb5_context context; krb5_ccache *id; char *residual; { diff --git a/src/lib/krb5/ccache/stdio/scc_retrv.c b/src/lib/krb5/ccache/stdio/scc_retrv.c index 865bdcbbb..5b20ad562 100644 --- a/src/lib/krb5/ccache/stdio/scc_retrv.c +++ b/src/lib/krb5/ccache/stdio/scc_retrv.c @@ -57,23 +57,25 @@ times_match_exact (t1, t2) } static krb5_boolean -standard_fields_match(mcreds, creds) +standard_fields_match(context, mcreds, creds) + krb5_context context; register const krb5_creds *mcreds, *creds; { - return (krb5_principal_compare(mcreds->client,creds->client) && - krb5_principal_compare(mcreds->server,creds->server)); + return (krb5_principal_compare(context, mcreds->client,creds->client) && + krb5_principal_compare(context, mcreds->server,creds->server)); } /* only match the server name portion, not the server realm portion */ static krb5_boolean -srvname_match(mcreds, creds) +srvname_match(context, mcreds, creds) + krb5_context context; register const krb5_creds *mcreds, *creds; { krb5_boolean retval; krb5_principal_data p1, p2; - retval = krb5_principal_compare(mcreds->client,creds->client); + retval = krb5_principal_compare(context, mcreds->client,creds->client); if (retval != TRUE) return retval; /* @@ -82,7 +84,7 @@ register const krb5_creds *mcreds, *creds; p1 = *mcreds->server; p2 = *creds->server; p1.realm = p2.realm; - return krb5_principal_compare(&p1, &p2); + return krb5_principal_compare(context, &p1, &p2); } @@ -153,7 +155,8 @@ register const krb5_data *data1, *data2; * KRB5_CC_NOMEM */ krb5_error_code -krb5_scc_retrieve(id, whichfields, mcreds, creds) +krb5_scc_retrieve(context, id, whichfields, mcreds, creds) + krb5_context context; krb5_ccache id; krb5_flags whichfields; krb5_creds *mcreds; @@ -166,11 +169,11 @@ krb5_scc_retrieve(id, whichfields, mcreds, creds) krb5_error_code kret; krb5_creds fetchcreds; - kret = krb5_scc_start_seq_get(id, &cursor); + kret = krb5_scc_start_seq_get(context, id, &cursor); if (kret != KRB5_OK) return kret; - while ((kret = krb5_scc_next_cred(id, &cursor, &fetchcreds)) == KRB5_OK) { + while ((kret = krb5_scc_next_cred(context, id, &cursor, &fetchcreds)) == KRB5_OK) { if (((set(KRB5_TC_MATCH_SRV_NAMEONLY) && srvname_match(mcreds, &fetchcreds)) || standard_fields_match(mcreds, &fetchcreds)) @@ -197,16 +200,16 @@ krb5_scc_retrieve(id, whichfields, mcreds, creds) data_match (&mcreds->second_ticket, &fetchcreds.second_ticket)) ) { - krb5_scc_end_seq_get(id, &cursor); + krb5_scc_end_seq_get(context, id, &cursor); *creds = fetchcreds; return KRB5_OK; } /* This one doesn't match */ - krb5_free_cred_contents(&fetchcreds); + krb5_free_cred_contents(context, &fetchcreds); } /* If we get here, a match wasn't found */ - krb5_scc_end_seq_get(id, &cursor); + krb5_scc_end_seq_get(context, id, &cursor); return KRB5_CC_NOTFOUND; } diff --git a/src/lib/krb5/ccache/stdio/scc_sflags.c b/src/lib/krb5/ccache/stdio/scc_sflags.c index f02589889..89ec826eb 100644 --- a/src/lib/krb5/ccache/stdio/scc_sflags.c +++ b/src/lib/krb5/ccache/stdio/scc_sflags.c @@ -40,7 +40,8 @@ * Sets the operational flags of id to flags. */ krb5_error_code -krb5_scc_set_flags(id, flags) +krb5_scc_set_flags(context, id, flags) + krb5_context context; krb5_ccache id; krb5_flags flags; { @@ -50,12 +51,12 @@ krb5_scc_set_flags(id, flags) if (flags & KRB5_TC_OPENCLOSE) { /* asking to turn on OPENCLOSE mode */ if (!OPENCLOSE(id)) - ret = krb5_scc_close_file (id); + ret = krb5_scc_close_file (context, id); } else { /* asking to turn off OPENCLOSE mode, meaning it must be left open. We open if it's not yet open */ if (OPENCLOSE(id)) { - ret = krb5_scc_open_file (id, SCC_OPEN_RDWR); + ret = krb5_scc_open_file (context, id, SCC_OPEN_RDWR); } } diff --git a/src/lib/krb5/ccache/stdio/scc_skip.c b/src/lib/krb5/ccache/stdio/scc_skip.c index 40ea25b12..01824026f 100644 --- a/src/lib/krb5/ccache/stdio/scc_skip.c +++ b/src/lib/krb5/ccache/stdio/scc_skip.c @@ -29,17 +29,18 @@ #include "scc.h" krb5_error_code -krb5_scc_skip_principal(id) +krb5_scc_skip_principal(context, id) + krb5_context context; krb5_ccache id; { krb5_error_code kret; krb5_principal princ; - kret = krb5_scc_read_principal(id, &princ); + kret = krb5_scc_read_principal(context, id, &princ); if (kret != KRB5_OK) return kret; - krb5_free_principal(princ); + krb5_free_principal(context, princ); return KRB5_OK; } diff --git a/src/lib/krb5/ccache/stdio/scc_sseq.c b/src/lib/krb5/ccache/stdio/scc_sseq.c index 2aec05b9f..f1971c5d2 100644 --- a/src/lib/krb5/ccache/stdio/scc_sseq.c +++ b/src/lib/krb5/ccache/stdio/scc_sseq.c @@ -42,7 +42,8 @@ * system errors */ krb5_error_code -krb5_scc_start_seq_get(id, cursor) +krb5_scc_start_seq_get(context, id, cursor) + krb5_context context; krb5_ccache id; krb5_cc_cursor *cursor; { @@ -54,14 +55,14 @@ krb5_scc_start_seq_get(id, cursor) return KRB5_CC_NOMEM; /* Make sure we start reading right after the primary principal */ - MAYBE_OPEN (id, SCC_OPEN_RDONLY); + MAYBE_OPEN (context, id, SCC_OPEN_RDONLY); /* skip over vno at beginning of file */ fseek(((krb5_scc_data *) id->data)->file, sizeof(krb5_int16), 0); - krb5_scc_skip_principal(id); + krb5_scc_skip_principal(context, id); fcursor->pos = ftell(((krb5_scc_data *) id->data)->file); *cursor = (krb5_cc_cursor) fcursor; - MAYBE_CLOSE (id, ret); + MAYBE_CLOSE (context, id, ret); return(ret); } diff --git a/src/lib/krb5/ccache/stdio/scc_store.c b/src/lib/krb5/ccache/stdio/scc_store.c index f8bd0907e..71b06210d 100644 --- a/src/lib/krb5/ccache/stdio/scc_store.c +++ b/src/lib/krb5/ccache/stdio/scc_store.c @@ -40,7 +40,8 @@ * storage failure errors */ krb5_error_code -krb5_scc_store(id, creds) +krb5_scc_store(context, id, creds) + krb5_context context; krb5_ccache id; krb5_creds *creds; { @@ -48,36 +49,36 @@ krb5_scc_store(id, creds) krb5_error_code ret; /* Make sure we are writing to the end of the file */ - MAYBE_OPEN (id, SCC_OPEN_RDWR); + MAYBE_OPEN (context, id, SCC_OPEN_RDWR); ret = fseek(((krb5_scc_data *) id->data)->file, 0, 2); if (ret < 0) - return krb5_scc_interpret(errno); + return krb5_scc_interpret(context, errno); - ret = krb5_scc_store_principal(id, creds->client); + ret = krb5_scc_store_principal(context, id, creds->client); TCHECK(ret); - ret = krb5_scc_store_principal(id, creds->server); + ret = krb5_scc_store_principal(context, id, creds->server); TCHECK(ret); - ret = krb5_scc_store_keyblock(id, &creds->keyblock); + ret = krb5_scc_store_keyblock(context, id, &creds->keyblock); TCHECK(ret); - ret = krb5_scc_store_times(id, &creds->times); + ret = krb5_scc_store_times(context, id, &creds->times); TCHECK(ret); - ret = krb5_scc_store_octet(id, creds->is_skey); + ret = krb5_scc_store_octet(context, id, creds->is_skey); TCHECK(ret); - ret = krb5_scc_store_int32(id, creds->ticket_flags); + ret = krb5_scc_store_int32(context, id, creds->ticket_flags); TCHECK(ret); - ret = krb5_scc_store_addrs(id, creds->addresses); + ret = krb5_scc_store_addrs(context, id, creds->addresses); TCHECK(ret); - ret = krb5_scc_store_authdata(id, creds->authdata); + ret = krb5_scc_store_authdata(context, id, creds->authdata); TCHECK(ret); - ret = krb5_scc_store_data(id, &creds->ticket); + ret = krb5_scc_store_data(context, id, &creds->ticket); TCHECK(ret); - ret = krb5_scc_store_data(id, &creds->second_ticket); + ret = krb5_scc_store_data(context, id, &creds->second_ticket); TCHECK(ret); lose: - MAYBE_CLOSE (id, ret); + MAYBE_CLOSE (context, id, ret); return ret; #undef TCHECK } diff --git a/src/lib/krb5/ccache/stdio/scc_test.c b/src/lib/krb5/ccache/stdio/scc_test.c index c76058ee5..d94829249 100644 --- a/src/lib/krb5/ccache/stdio/scc_test.c +++ b/src/lib/krb5/ccache/stdio/scc_test.c @@ -125,9 +125,9 @@ void scc_test() init_test_cred(); - kret = krb5_scc_resolve(&id, "/tmp/tkt_test"); + kret = krb5_scc_resolve(context, &id, "/tmp/tkt_test"); CHECK(kret, "resolve"); - kret = krb5_scc_initialize(id, test_creds.client); + kret = krb5_scc_initialize(context, id, test_creds.client); CHECK(kret, "initialize"); kret = krb5_scc_store(id, &test_creds); CHECK(kret, "store"); diff --git a/src/lib/krb5/ccache/stdio/scc_write.c b/src/lib/krb5/ccache/stdio/scc_write.c index db6015dd5..9226bb1f6 100644 --- a/src/lib/krb5/ccache/stdio/scc_write.c +++ b/src/lib/krb5/ccache/stdio/scc_write.c @@ -41,7 +41,8 @@ * system errors */ krb5_error_code -krb5_scc_write(id, buf, len) +krb5_scc_write(context, id, buf, len) + krb5_context context; krb5_ccache id; krb5_pointer buf; int len; @@ -51,7 +52,7 @@ krb5_scc_write(id, buf, len) errno = 0; ret = fwrite((char *) buf, 1, len, ((krb5_scc_data *)id->data)->file); if ((ret == 0) && errno) { - return krb5_scc_interpret (errno); + return krb5_scc_interpret (context, errno); } else if (ret != len) return KRB5_CC_END; return KRB5_OK; @@ -72,7 +73,8 @@ krb5_scc_write(id, buf, len) */ krb5_error_code -krb5_scc_store_principal(id, princ) +krb5_scc_store_principal(context, id, princ) + krb5_context context; krb5_ccache id; krb5_principal princ; { @@ -80,8 +82,8 @@ krb5_scc_store_principal(id, princ) krb5_error_code ret; krb5_int32 i, length, tmp, type; - type = krb5_princ_type(princ); - tmp = length = krb5_princ_size(princ); + type = krb5_princ_type(context, princ); + tmp = length = krb5_princ_size(context, princ); if (data->version == KRB5_SCC_FVNO_1) { /* @@ -91,18 +93,19 @@ krb5_scc_store_principal(id, princ) */ tmp++; } else { - ret = krb5_scc_store_int32(id, type); + ret = krb5_scc_store_int32(context, id, type); CHECK(ret); } - ret = krb5_scc_store_int32(id, tmp); + ret = krb5_scc_store_int32(context, id, tmp); CHECK(ret); - ret = krb5_scc_store_data(id, krb5_princ_realm(princ)); + ret = krb5_scc_store_data(context, id, krb5_princ_realm(context, princ)); CHECK(ret); for (i=0; i < length; i++) { - ret = krb5_scc_store_data(id, krb5_princ_component(princ, i)); + ret = krb5_scc_store_data(context, id, + krb5_princ_component(context, princ, i)); CHECK(ret); } @@ -110,7 +113,8 @@ krb5_scc_store_principal(id, princ) } krb5_error_code -krb5_scc_store_addrs(id, addrs) +krb5_scc_store_addrs(context, id, addrs) + krb5_context context; krb5_ccache id; krb5_address ** addrs; { @@ -125,10 +129,10 @@ krb5_scc_store_addrs(id, addrs) length += 1; } - ret = krb5_scc_store_int32(id, length); + ret = krb5_scc_store_int32(context, id, length); CHECK(ret); for (i=0; i < length; i++) { - ret = krb5_scc_store_addr(id, addrs[i]); + ret = krb5_scc_store_addr(context, id, addrs[i]); CHECK(ret); } @@ -136,54 +140,58 @@ krb5_scc_store_addrs(id, addrs) } krb5_error_code -krb5_scc_store_keyblock(id, keyblock) +krb5_scc_store_keyblock(context, id, keyblock) + krb5_context context; krb5_ccache id; krb5_keyblock *keyblock; { krb5_scc_data *data = (krb5_scc_data *)id->data; krb5_error_code ret; - ret = krb5_scc_store_ui_2(id, keyblock->keytype); + ret = krb5_scc_store_ui_2(context, id, keyblock->keytype); CHECK(ret); if ((data->version != KRB5_SCC_FVNO_1) && (data->version != KRB5_SCC_FVNO_2)) { - ret = krb5_scc_store_ui_2(id, keyblock->etype); + ret = krb5_scc_store_ui_2(context, id, keyblock->etype); CHECK(ret); } - ret = krb5_scc_store_int32(id, keyblock->length); + ret = krb5_scc_store_int32(context, id, keyblock->length); CHECK(ret); - return krb5_scc_write(id, (char *) keyblock->contents, keyblock->length); + return krb5_scc_write(context, id, (char *) keyblock->contents, keyblock->length); } krb5_error_code -krb5_scc_store_addr(id, addr) +krb5_scc_store_addr(context, id, addr) + krb5_context context; krb5_ccache id; krb5_address *addr; { krb5_error_code ret; - ret = krb5_scc_store_ui_2(id, addr->addrtype); + ret = krb5_scc_store_ui_2(context, id, addr->addrtype); CHECK(ret); - ret = krb5_scc_store_int32(id, addr->length); + ret = krb5_scc_store_int32(context, id, addr->length); CHECK(ret); - return krb5_scc_write(id, (char *) addr->contents, addr->length); + return krb5_scc_write(context, id, (char *) addr->contents, addr->length); } krb5_error_code -krb5_scc_store_data(id, data) +krb5_scc_store_data(context, id, data) + krb5_context context; krb5_ccache id; krb5_data *data; { krb5_error_code ret; - ret = krb5_scc_store_int32(id, data->length); + ret = krb5_scc_store_int32(context, id, data->length); CHECK(ret); - return krb5_scc_write(id, data->data, data->length); + return krb5_scc_write(context, id, data->data, data->length); } krb5_error_code -krb5_scc_store_int32(id, i) +krb5_scc_store_int32(context, id, i) + krb5_context context; krb5_ccache id; krb5_int32 i; { @@ -192,7 +200,7 @@ krb5_scc_store_int32(id, i) if ((data->version == KRB5_SCC_FVNO_1) || (data->version == KRB5_SCC_FVNO_2)) - return krb5_scc_write(id, (char *) &i, sizeof(krb5_int32)); + return krb5_scc_write(context, id, (char *) &i, sizeof(krb5_int32)); else { buf[3] = i & 0xFF; i >>= 8; @@ -202,12 +210,13 @@ krb5_scc_store_int32(id, i) i >>= 8; buf[0] = i & 0xFF; - return krb5_scc_write(id, buf, 4); + return krb5_scc_write(context, id, buf, 4); } } krb5_error_code -krb5_scc_store_ui_2(id, i) +krb5_scc_store_ui_2(context, id, i) + krb5_context context; krb5_ccache id; krb5_int32 i; { @@ -218,29 +227,31 @@ krb5_scc_store_ui_2(id, i) if ((data->version == KRB5_SCC_FVNO_1) || (data->version == KRB5_SCC_FVNO_2)) { ibuf = i; - return krb5_scc_write(id, (char *) &ibuf, sizeof(krb5_ui_2)); + return krb5_scc_write(context, id, (char *) &ibuf, sizeof(krb5_ui_2)); } else { buf[1] = i & 0xFF; i >>= 8; buf[0] = i & 0xFF; - return krb5_scc_write(id, buf, 2); + return krb5_scc_write(context, id, buf, 2); } } krb5_error_code -krb5_scc_store_octet(id, i) +krb5_scc_store_octet(context, id, i) + krb5_context context; krb5_ccache id; krb5_int32 i; { krb5_octet ibuf; ibuf = i; - return krb5_scc_write(id, (char *) &ibuf, 1); + return krb5_scc_write(context, id, (char *) &ibuf, 1); } krb5_error_code -krb5_scc_store_times(id, t) +krb5_scc_store_times(context, id, t) + krb5_context context; krb5_ccache id; krb5_ticket_times *t; { @@ -249,22 +260,23 @@ krb5_scc_store_times(id, t) if ((data->version == KRB5_SCC_FVNO_1) || (data->version == KRB5_SCC_FVNO_2)) - return krb5_scc_write(id, (char *) t, sizeof(krb5_ticket_times)); + return krb5_scc_write(context, id, (char *) t, sizeof(krb5_ticket_times)); else { - retval = krb5_scc_store_int32(id, t->authtime); + retval = krb5_scc_store_int32(context, id, t->authtime); CHECK(retval); - retval = krb5_scc_store_int32(id, t->starttime); + retval = krb5_scc_store_int32(context, id, t->starttime); CHECK(retval); - retval = krb5_scc_store_int32(id, t->endtime); + retval = krb5_scc_store_int32(context, id, t->endtime); CHECK(retval); - retval = krb5_scc_store_int32(id, t->renew_till); + retval = krb5_scc_store_int32(context, id, t->renew_till); CHECK(retval); return 0; } } krb5_error_code -krb5_scc_store_authdata(id, a) +krb5_scc_store_authdata(context, id, a) + krb5_context context; krb5_ccache id; krb5_authdata **a; { @@ -277,24 +289,25 @@ krb5_scc_store_authdata(id, a) length++; } - ret = krb5_scc_store_int32(id, length); + ret = krb5_scc_store_int32(context, id, length); CHECK(ret); for (i=0; iad_type); + ret = krb5_scc_store_ui_2(context, id, a->ad_type); CHECK(ret); - ret = krb5_scc_store_int32(id, a->length); + ret = krb5_scc_store_int32(context, id, a->length); CHECK(ret); - return krb5_scc_write(id, (krb5_pointer) a->contents, a->length); + return krb5_scc_write(context, id, (krb5_pointer) a->contents, a->length); } diff --git a/src/lib/krb5/error_tables/init_ets.c b/src/lib/krb5/error_tables/init_ets.c index 88d18dffb..78b9ef1e7 100644 --- a/src/lib/krb5/error_tables/init_ets.c +++ b/src/lib/krb5/error_tables/init_ets.c @@ -28,7 +28,7 @@ #include void -krb5_init_ets PROTOTYPE((void)) +krb5_init_ets PROTOTYPE((krb5_context context)) { static int initialized = 0; diff --git a/src/lib/krb5/free/ChangeLog b/src/lib/krb5/free/ChangeLog index 39542e101..1ae5063a7 100644 --- a/src/lib/krb5/free/ChangeLog +++ b/src/lib/krb5/free/ChangeLog @@ -1,3 +1,7 @@ +Fri Jan 13 15:23:47 1995 Chris Provenzano (proven@mit.edu) + + * Added krb5_context to all krb5_routines + Thu Oct 13 17:24:51 1994 Theodore Y. Ts'o (tytso@maytag) * configure.in: Add ISODE_DEFS diff --git a/src/lib/krb5/free/f_addr.c b/src/lib/krb5/free/f_addr.c index 95060d919..c141c74ce 100644 --- a/src/lib/krb5/free/f_addr.c +++ b/src/lib/krb5/free/f_addr.c @@ -29,8 +29,9 @@ #include void -krb5_free_address(val) -krb5_address *val; +krb5_free_address(context, val) + krb5_context context; + krb5_address *val; { if (val->contents) krb5_xfree(val->contents); diff --git a/src/lib/krb5/free/f_address.c b/src/lib/krb5/free/f_address.c index 238a37062..d4ead60aa 100644 --- a/src/lib/krb5/free/f_address.c +++ b/src/lib/krb5/free/f_address.c @@ -29,8 +29,9 @@ #include void -krb5_free_addresses(val) -krb5_address **val; +krb5_free_addresses(context, val) + krb5_context context; + krb5_address **val; { register krb5_address **temp; diff --git a/src/lib/krb5/free/f_ap_rep.c b/src/lib/krb5/free/f_ap_rep.c index 89b38e6be..1fa5d8745 100644 --- a/src/lib/krb5/free/f_ap_rep.c +++ b/src/lib/krb5/free/f_ap_rep.c @@ -29,8 +29,9 @@ #include void -krb5_free_ap_rep(val) -register krb5_ap_rep *val; +krb5_free_ap_rep(context, val) + krb5_context context; + register krb5_ap_rep *val; { if (val->enc_part.ciphertext.data) krb5_xfree(val->enc_part.ciphertext.data); diff --git a/src/lib/krb5/free/f_ap_req.c b/src/lib/krb5/free/f_ap_req.c index 1d71ba0cf..3632f6432 100644 --- a/src/lib/krb5/free/f_ap_req.c +++ b/src/lib/krb5/free/f_ap_req.c @@ -29,11 +29,12 @@ #include void -krb5_free_ap_req(val) -register krb5_ap_req *val; +krb5_free_ap_req(context, val) + krb5_context context; + register krb5_ap_req *val; { if (val->ticket) - krb5_free_ticket(val->ticket); + krb5_free_ticket(context, val->ticket); if (val->authenticator.ciphertext.data) krb5_xfree(val->authenticator.ciphertext.data); krb5_xfree(val); diff --git a/src/lib/krb5/free/f_arep_enc.c b/src/lib/krb5/free/f_arep_enc.c index af3e44480..16395944f 100644 --- a/src/lib/krb5/free/f_arep_enc.c +++ b/src/lib/krb5/free/f_arep_enc.c @@ -29,11 +29,12 @@ #include void -krb5_free_ap_rep_enc_part(val) -krb5_ap_rep_enc_part *val; +krb5_free_ap_rep_enc_part(context, val) + krb5_context context; + krb5_ap_rep_enc_part *val; { if (val->subkey) - krb5_free_keyblock(val->subkey); + krb5_free_keyblock(context, val->subkey); krb5_xfree(val); return; } diff --git a/src/lib/krb5/free/f_auth_cnt.c b/src/lib/krb5/free/f_auth_cnt.c index d4098f01a..3f4f03617 100644 --- a/src/lib/krb5/free/f_auth_cnt.c +++ b/src/lib/krb5/free/f_auth_cnt.c @@ -30,16 +30,17 @@ #include void -krb5_free_authenticator_contents(val) -krb5_authenticator *val; +krb5_free_authenticator_contents(context, val) + krb5_context context; + krb5_authenticator *val; { if (val->checksum) - krb5_free_checksum(val->checksum); + krb5_free_checksum(context, val->checksum); if (val->client) - krb5_free_principal(val->client); + krb5_free_principal(context, val->client); if (val->subkey) - krb5_free_keyblock(val->subkey); + krb5_free_keyblock(context, val->subkey); if (val->authorization_data) - krb5_free_authdata(val->authorization_data); + krb5_free_authdata(context, val->authorization_data); return; } diff --git a/src/lib/krb5/free/f_authdata.c b/src/lib/krb5/free/f_authdata.c index 497a33be5..cf22f6721 100644 --- a/src/lib/krb5/free/f_authdata.c +++ b/src/lib/krb5/free/f_authdata.c @@ -29,7 +29,8 @@ #include void -krb5_free_authdata(val) +krb5_free_authdata(context, val) + krb5_context context; krb5_authdata **val; { register krb5_authdata **temp; diff --git a/src/lib/krb5/free/f_authent.c b/src/lib/krb5/free/f_authent.c index e98faa48d..86a6036b2 100644 --- a/src/lib/krb5/free/f_authent.c +++ b/src/lib/krb5/free/f_authent.c @@ -30,17 +30,18 @@ #include void -krb5_free_authenticator(val) -krb5_authenticator *val; +krb5_free_authenticator(context, val) + krb5_context context; + krb5_authenticator *val; { if (val->checksum) - krb5_free_checksum(val->checksum); + krb5_free_checksum(context, val->checksum); if (val->client) - krb5_free_principal(val->client); + krb5_free_principal(context, val->client); if (val->subkey) - krb5_free_keyblock(val->subkey); + krb5_free_keyblock(context, val->subkey); if (val->authorization_data) - krb5_free_authdata(val->authorization_data); + krb5_free_authdata(context, val->authorization_data); krb5_xfree(val); return; } diff --git a/src/lib/krb5/free/f_cksum.c b/src/lib/krb5/free/f_cksum.c index 13272d6c7..40372fcd8 100644 --- a/src/lib/krb5/free/f_cksum.c +++ b/src/lib/krb5/free/f_cksum.c @@ -29,8 +29,9 @@ #include void -krb5_free_checksum(val) -register krb5_checksum *val; +krb5_free_checksum(context, val) + krb5_context context; + register krb5_checksum *val; { if (val->contents) krb5_xfree(val->contents); diff --git a/src/lib/krb5/free/f_cred.c b/src/lib/krb5/free/f_cred.c index 673af0616..2aaea23a6 100644 --- a/src/lib/krb5/free/f_cred.c +++ b/src/lib/krb5/free/f_cred.c @@ -29,11 +29,12 @@ #include void -krb5_free_cred(val) -register krb5_cred *val; +krb5_free_cred(context, val) + krb5_context context; + register krb5_cred *val; { if (val->tickets) - krb5_free_tickets(val->tickets); + krb5_free_tickets(context, val->tickets); if (val->enc_part.ciphertext.data) krb5_xfree(val->enc_part.ciphertext.data); krb5_xfree(val); diff --git a/src/lib/krb5/free/f_cred_cnt.c b/src/lib/krb5/free/f_cred_cnt.c index 56fb7bcdc..672614d70 100644 --- a/src/lib/krb5/free/f_cred_cnt.c +++ b/src/lib/krb5/free/f_cred_cnt.c @@ -34,13 +34,14 @@ */ void -krb5_free_cred_contents(val) -krb5_creds *val; +krb5_free_cred_contents(context, val) + krb5_context context; + krb5_creds *val; { if (val->client) - krb5_free_principal(val->client); + krb5_free_principal(context, val->client); if (val->server) - krb5_free_principal(val->server); + krb5_free_principal(context, val->server); if (val->keyblock.contents) { memset((char *)val->keyblock.contents, 0, val->keyblock.length); krb5_xfree(val->keyblock.contents); @@ -50,8 +51,8 @@ krb5_creds *val; if (val->second_ticket.data) krb5_xfree(val->second_ticket.data); if (val->addresses) - krb5_free_addresses(val->addresses); + krb5_free_addresses(context, val->addresses); if (val->authdata) - krb5_free_authdata(val->authdata); + krb5_free_authdata(context, val->authdata); return; } diff --git a/src/lib/krb5/free/f_cred_enc.c b/src/lib/krb5/free/f_cred_enc.c index b23271879..92aa108d3 100644 --- a/src/lib/krb5/free/f_cred_enc.c +++ b/src/lib/krb5/free/f_cred_enc.c @@ -29,26 +29,27 @@ #include void -krb5_free_cred_enc_part(val) -register krb5_cred_enc_part *val; +krb5_free_cred_enc_part(context, val) + krb5_context context; + register krb5_cred_enc_part *val; { register krb5_cred_info **temp; if (val->r_address) - krb5_free_address(val->r_address); + krb5_free_address(context, val->r_address); if (val->s_address) - krb5_free_address(val->s_address); + krb5_free_address(context, val->s_address); if (val->ticket_info) { for (temp = val->ticket_info; *temp; temp++) { if ((*temp)->session) - krb5_free_keyblock((*temp)->session); + krb5_free_keyblock(context, (*temp)->session); if ((*temp)->client) - krb5_free_principal((*temp)->client); + krb5_free_principal(context, (*temp)->client); if ((*temp)->server) - krb5_free_principal((*temp)->server); + krb5_free_principal(context, (*temp)->server); if ((*temp)->caddrs) - krb5_free_addresses((*temp)->caddrs); + krb5_free_addresses(context, (*temp)->caddrs); krb5_xfree((*temp)); } krb5_xfree(val->ticket_info); diff --git a/src/lib/krb5/free/f_creds.c b/src/lib/krb5/free/f_creds.c index 45f1c8ada..e80875a4c 100644 --- a/src/lib/krb5/free/f_creds.c +++ b/src/lib/krb5/free/f_creds.c @@ -29,10 +29,11 @@ #include void -krb5_free_creds(val) -krb5_creds *val; +krb5_free_creds(context, val) + krb5_context context; + krb5_creds *val; { - krb5_free_cred_contents(val); + krb5_free_cred_contents(context, val); krb5_xfree(val); return; } diff --git a/src/lib/krb5/free/f_enc_kdc.c b/src/lib/krb5/free/f_enc_kdc.c index d683ae292..e489bb103 100644 --- a/src/lib/krb5/free/f_enc_kdc.c +++ b/src/lib/krb5/free/f_enc_kdc.c @@ -29,17 +29,18 @@ #include void -krb5_free_enc_kdc_rep_part(val) -register krb5_enc_kdc_rep_part *val; +krb5_free_enc_kdc_rep_part(context, val) + krb5_context context; + register krb5_enc_kdc_rep_part *val; { if (val->session) - krb5_free_keyblock(val->session); + krb5_free_keyblock(context, val->session); if (val->last_req) - krb5_free_last_req(val->last_req); + krb5_free_last_req(context, val->last_req); if (val->server) - krb5_free_principal(val->server); + krb5_free_principal(context, val->server); if (val->caddrs) - krb5_free_addresses(val->caddrs); + krb5_free_addresses(context, val->caddrs); krb5_xfree(val); return; } diff --git a/src/lib/krb5/free/f_enc_tkt.c b/src/lib/krb5/free/f_enc_tkt.c index ece2693a9..d5dbad838 100644 --- a/src/lib/krb5/free/f_enc_tkt.c +++ b/src/lib/krb5/free/f_enc_tkt.c @@ -29,19 +29,20 @@ #include void -krb5_free_enc_tkt_part(val) -krb5_enc_tkt_part *val; +krb5_free_enc_tkt_part(context, val) + krb5_context context; + krb5_enc_tkt_part *val; { if (val->session) - krb5_free_keyblock(val->session); + krb5_free_keyblock(context, val->session); if (val->client) - krb5_free_principal(val->client); + krb5_free_principal(context, val->client); if (val->transited.tr_contents.data) krb5_xfree(val->transited.tr_contents.data); if (val->caddrs) - krb5_free_addresses(val->caddrs); + krb5_free_addresses(context, val->caddrs); if (val->authorization_data) - krb5_free_authdata(val->authorization_data); + krb5_free_authdata(context, val->authorization_data); krb5_xfree(val); return; } diff --git a/src/lib/krb5/free/f_error.c b/src/lib/krb5/free/f_error.c index 646b6b531..c51733b19 100644 --- a/src/lib/krb5/free/f_error.c +++ b/src/lib/krb5/free/f_error.c @@ -29,13 +29,14 @@ #include void -krb5_free_error(val) -register krb5_error *val; +krb5_free_error(context, val) + krb5_context context; + register krb5_error *val; { if (val->client) - krb5_free_principal(val->client); + krb5_free_principal(context, val->client); if (val->server) - krb5_free_principal(val->server); + krb5_free_principal(context, val->server); if (val->text.data) krb5_xfree(val->text.data); if (val->e_data.data) diff --git a/src/lib/krb5/free/f_kdc_rep.c b/src/lib/krb5/free/f_kdc_rep.c index 2091d9e5c..87e820984 100644 --- a/src/lib/krb5/free/f_kdc_rep.c +++ b/src/lib/krb5/free/f_kdc_rep.c @@ -29,19 +29,20 @@ #include void -krb5_free_kdc_rep(val) +krb5_free_kdc_rep(context, val) + krb5_context context; krb5_kdc_rep *val; { if (val->padata) - krb5_free_pa_data(val->padata); + krb5_free_pa_data(context, val->padata); if (val->client) - krb5_free_principal(val->client); + krb5_free_principal(context, val->client); if (val->ticket) - krb5_free_ticket(val->ticket); + krb5_free_ticket(context, val->ticket); if (val->enc_part.ciphertext.data) krb5_xfree(val->enc_part.ciphertext.data); if (val->enc_part2) - krb5_free_enc_kdc_rep_part(val->enc_part2); + krb5_free_enc_kdc_rep_part(context, val->enc_part2); krb5_xfree(val); return; } diff --git a/src/lib/krb5/free/f_kdc_req.c b/src/lib/krb5/free/f_kdc_req.c index 0e6416e91..0d9dfffae 100644 --- a/src/lib/krb5/free/f_kdc_req.c +++ b/src/lib/krb5/free/f_kdc_req.c @@ -29,25 +29,26 @@ #include void -krb5_free_kdc_req(val) -krb5_kdc_req *val; +krb5_free_kdc_req(context, val) + krb5_context context; + krb5_kdc_req *val; { if (val->padata) - krb5_free_pa_data(val->padata); + krb5_free_pa_data(context, val->padata); if (val->client) - krb5_free_principal(val->client); + krb5_free_principal(context, val->client); if (val->server) - krb5_free_principal(val->server); + krb5_free_principal(context, val->server); if (val->etype) krb5_xfree(val->etype); if (val->addresses) - krb5_free_addresses(val->addresses); + krb5_free_addresses(context, val->addresses); if (val->authorization_data.ciphertext.data) krb5_xfree(val->authorization_data.ciphertext.data); if (val->unenc_authdata) - krb5_free_authdata(val->unenc_authdata); + krb5_free_authdata(context, val->unenc_authdata); if (val->second_ticket) - krb5_free_tickets(val->second_ticket); + krb5_free_tickets(context, val->second_ticket); krb5_xfree(val); return; } diff --git a/src/lib/krb5/free/f_keyblock.c b/src/lib/krb5/free/f_keyblock.c index a360531e8..0117fbff5 100644 --- a/src/lib/krb5/free/f_keyblock.c +++ b/src/lib/krb5/free/f_keyblock.c @@ -29,8 +29,9 @@ #include void -krb5_free_keyblock(val) -register krb5_keyblock *val; +krb5_free_keyblock(context, val) + krb5_context context; + register krb5_keyblock *val; { if (val->contents) { memset((char *)val->contents, 0, val->length); diff --git a/src/lib/krb5/free/f_last_req.c b/src/lib/krb5/free/f_last_req.c index 62e34760d..d86c30fe3 100644 --- a/src/lib/krb5/free/f_last_req.c +++ b/src/lib/krb5/free/f_last_req.c @@ -29,8 +29,9 @@ #include void -krb5_free_last_req(val) -krb5_last_req_entry **val; +krb5_free_last_req(context, val) + krb5_context context; + krb5_last_req_entry **val; { register krb5_last_req_entry **temp; diff --git a/src/lib/krb5/free/f_padata.c b/src/lib/krb5/free/f_padata.c index 365d9eb1b..7aef9af36 100644 --- a/src/lib/krb5/free/f_padata.c +++ b/src/lib/krb5/free/f_padata.c @@ -29,8 +29,9 @@ #include void -krb5_free_pa_data(val) -krb5_pa_data **val; +krb5_free_pa_data(context, val) + krb5_context context; + krb5_pa_data **val; { register krb5_pa_data **temp; diff --git a/src/lib/krb5/free/f_princ.c b/src/lib/krb5/free/f_princ.c index b424cdd5d..60ad85a25 100644 --- a/src/lib/krb5/free/f_princ.c +++ b/src/lib/krb5/free/f_princ.c @@ -29,8 +29,9 @@ #include void -krb5_free_principal(val) -krb5_principal val; +krb5_free_principal(context, val) + krb5_context context; + krb5_principal val; { register int i; @@ -38,9 +39,9 @@ krb5_principal val; return; if (val->data) { - i = krb5_princ_size(val); + i = krb5_princ_size(context, val); while(--i >= 0) - free(krb5_princ_component(val, i)->data); + free(krb5_princ_component(context, val, i)->data); krb5_xfree(val->data); } if (val->realm.data) diff --git a/src/lib/krb5/free/f_priv.c b/src/lib/krb5/free/f_priv.c index 78f7e6935..61d684ec6 100644 --- a/src/lib/krb5/free/f_priv.c +++ b/src/lib/krb5/free/f_priv.c @@ -29,7 +29,8 @@ #include void -krb5_free_priv(val) +krb5_free_priv(context, val) + krb5_context context; register krb5_priv *val; { if (val->enc_part.ciphertext.data) diff --git a/src/lib/krb5/free/f_priv_enc.c b/src/lib/krb5/free/f_priv_enc.c index f2c1c3afa..46d31caef 100644 --- a/src/lib/krb5/free/f_priv_enc.c +++ b/src/lib/krb5/free/f_priv_enc.c @@ -29,15 +29,16 @@ #include void -krb5_free_priv_enc_part(val) -register krb5_priv_enc_part *val; +krb5_free_priv_enc_part(context, val) + krb5_context context; + register krb5_priv_enc_part *val; { if (val->user_data.data) krb5_xfree(val->user_data.data); if (val->r_address) - krb5_free_address(val->r_address); + krb5_free_address(context, val->r_address); if (val->s_address) - krb5_free_address(val->s_address); + krb5_free_address(context, val->s_address); krb5_xfree(val); return; } diff --git a/src/lib/krb5/free/f_pwd_data.c b/src/lib/krb5/free/f_pwd_data.c index 2e423d3d1..9d69fb4d3 100644 --- a/src/lib/krb5/free/f_pwd_data.c +++ b/src/lib/krb5/free/f_pwd_data.c @@ -29,11 +29,12 @@ #include void -krb5_free_pwd_data(val) +krb5_free_pwd_data(context, val) + krb5_context context; krb5_pwd_data *val; { if (val->element) - krb5_free_pwd_sequences(val->element); + krb5_free_pwd_sequences(context, val->element); krb5_xfree(val); return; } diff --git a/src/lib/krb5/free/f_pwd_seq.c b/src/lib/krb5/free/f_pwd_seq.c index 25cb915e8..fc0a1c553 100644 --- a/src/lib/krb5/free/f_pwd_seq.c +++ b/src/lib/krb5/free/f_pwd_seq.c @@ -29,8 +29,9 @@ #include void -krb5_free_pwd_sequences(val) -passwd_phrase_element **val; +krb5_free_pwd_sequences(context, val) + krb5_context context; + passwd_phrase_element **val; { if ((*val)->passwd) krb5_xfree((*val)->passwd); diff --git a/src/lib/krb5/free/f_safe.c b/src/lib/krb5/free/f_safe.c index 375a0b2dc..df37add0f 100644 --- a/src/lib/krb5/free/f_safe.c +++ b/src/lib/krb5/free/f_safe.c @@ -29,17 +29,18 @@ #include void -krb5_free_safe(val) -register krb5_safe *val; +krb5_free_safe(context, val) + krb5_context context; + register krb5_safe *val; { if (val->user_data.data) krb5_xfree(val->user_data.data); if (val->r_address) - krb5_free_address(val->r_address); + krb5_free_address(context, val->r_address); if (val->s_address) - krb5_free_address(val->s_address); + krb5_free_address(context, val->s_address); if (val->checksum) - krb5_free_checksum(val->checksum); + krb5_free_checksum(context, val->checksum); krb5_xfree(val); return; } diff --git a/src/lib/krb5/free/f_tgt_cred.c b/src/lib/krb5/free/f_tgt_cred.c index 832a68cb0..6210d296d 100644 --- a/src/lib/krb5/free/f_tgt_cred.c +++ b/src/lib/krb5/free/f_tgt_cred.c @@ -30,11 +30,12 @@ #include void -krb5_free_tgt_creds(tgts) -krb5_creds **tgts; +krb5_free_tgt_creds(context, tgts) + krb5_context context; + krb5_creds **tgts; { register krb5_creds **tgtpp; for (tgtpp = tgts; *tgtpp; tgtpp++) - krb5_free_creds(*tgtpp); + krb5_free_creds(context, *tgtpp); krb5_xfree(tgts); } diff --git a/src/lib/krb5/free/f_ticket.c b/src/lib/krb5/free/f_ticket.c index c6e30e5af..26e8ea0a4 100644 --- a/src/lib/krb5/free/f_ticket.c +++ b/src/lib/krb5/free/f_ticket.c @@ -29,15 +29,16 @@ #include void -krb5_free_ticket(val) -krb5_ticket *val; +krb5_free_ticket(context, val) + krb5_context context; + krb5_ticket *val; { if (val->server) - krb5_free_principal(val->server); + krb5_free_principal(context, val->server); if (val->enc_part.ciphertext.data) krb5_xfree(val->enc_part.ciphertext.data); if (val->enc_part2) - krb5_free_enc_tkt_part(val->enc_part2); + krb5_free_enc_tkt_part(context, val->enc_part2); krb5_xfree(val); return; } diff --git a/src/lib/krb5/free/f_tickets.c b/src/lib/krb5/free/f_tickets.c index 021fe0fa9..df609757c 100644 --- a/src/lib/krb5/free/f_tickets.c +++ b/src/lib/krb5/free/f_tickets.c @@ -29,13 +29,14 @@ #include void -krb5_free_tickets(val) -krb5_ticket **val; +krb5_free_tickets(context, val) + krb5_context context; + krb5_ticket **val; { register krb5_ticket **temp; for (temp = val; *temp; temp++) - krb5_free_ticket(*temp); + krb5_free_ticket(context, *temp); krb5_xfree(val); return; } diff --git a/src/lib/krb5/free/f_tkt_auth.c b/src/lib/krb5/free/f_tkt_auth.c index 85f6d8664..17b8e455f 100644 --- a/src/lib/krb5/free/f_tkt_auth.c +++ b/src/lib/krb5/free/f_tkt_auth.c @@ -29,13 +29,14 @@ #include void -krb5_free_tkt_authent(val) -krb5_tkt_authent *val; +krb5_free_tkt_authent(context, val) + krb5_context context; + krb5_tkt_authent *val; { if (val->ticket) - krb5_free_ticket(val->ticket); + krb5_free_ticket(context, val->ticket); if (val->authenticator) - krb5_free_authenticator(val->authenticator); + krb5_free_authenticator(context, val->authenticator); krb5_xfree(val); return; } diff --git a/src/lib/krb5/keytab/ChangeLog b/src/lib/krb5/keytab/ChangeLog index bde2e39e8..0cc1852f7 100644 --- a/src/lib/krb5/keytab/ChangeLog +++ b/src/lib/krb5/keytab/ChangeLog @@ -1,3 +1,7 @@ +Fri Jan 13 15:23:47 1995 Chris Provenzano (proven@mit.edu) + + * Added krb5_context to all krb5_routines + Fri Oct 14 23:09:02 1994 Theodore Y. Ts'o (tytso@dcl) * configure.in: Add ISODE_DEFS rule. diff --git a/src/lib/krb5/keytab/ktadd.c b/src/lib/krb5/keytab/ktadd.c index eb6935243..8e9b1853e 100644 --- a/src/lib/krb5/keytab/ktadd.c +++ b/src/lib/krb5/keytab/ktadd.c @@ -28,12 +28,13 @@ #include krb5_error_code -krb5_kt_add_entry (id, entry) -krb5_keytab id; -krb5_keytab_entry *entry; +krb5_kt_add_entry (context, id, entry) + krb5_context context; + krb5_keytab id; + krb5_keytab_entry *entry; { if (id->ops->add) - return (*id->ops->add)(id, entry); + return (*id->ops->add)(context, id, entry); else return KRB5_KT_NOWRITE; } diff --git a/src/lib/krb5/keytab/ktbase.c b/src/lib/krb5/keytab/ktbase.c index 189351c68..c359b0e26 100644 --- a/src/lib/krb5/keytab/ktbase.c +++ b/src/lib/krb5/keytab/ktbase.c @@ -42,8 +42,9 @@ static struct krb5_kt_typelist *kt_typehead = &krb5_kt_typelist_dfl; */ krb5_error_code -krb5_kt_register(ops) -krb5_kt_ops *ops; +krb5_kt_register(context, ops) + krb5_context context; + krb5_kt_ops *ops; { struct krb5_kt_typelist *t; for (t = kt_typehead;t && strcmp(t->ops->prefix,ops->prefix);t = t->next) @@ -69,7 +70,8 @@ krb5_kt_ops *ops; * particular keytab type. */ -krb5_error_code krb5_kt_resolve (name, ktid) +krb5_error_code krb5_kt_resolve (context, name, ktid) + krb5_context context; const char *name; krb5_keytab *ktid; { @@ -79,7 +81,7 @@ krb5_error_code krb5_kt_resolve (name, ktid) cp = strchr (name, ':'); if (!cp) { - return (*krb5_kt_dfl_ops.resolve)(name, ktid); + return (*krb5_kt_dfl_ops.resolve)(context, name, ktid); } pfxlen = cp - (char *)name; @@ -97,7 +99,7 @@ krb5_error_code krb5_kt_resolve (name, ktid) for (tlist = kt_typehead; tlist; tlist = tlist->next) { if (strcmp (tlist->ops->prefix, pfx) == 0) { free(pfx); - return (*tlist->ops->resolve)(resid, ktid); + return (*tlist->ops->resolve)(context, resid, ktid); } } free(pfx); diff --git a/src/lib/krb5/keytab/ktdefault.c b/src/lib/krb5/keytab/ktdefault.c index 071c2ab93..17bbf6d6b 100644 --- a/src/lib/krb5/keytab/ktdefault.c +++ b/src/lib/krb5/keytab/ktdefault.c @@ -28,15 +28,16 @@ #include #include -krb5_error_code krb5_kt_default(id) -krb5_keytab *id; +krb5_error_code krb5_kt_default(context, id) + krb5_context context; + krb5_keytab *id; { char defname[BUFSIZ]; krb5_error_code retval; - if (retval = krb5_kt_default_name(defname, sizeof(defname))) + if (retval = krb5_kt_default_name(context, defname, sizeof(defname))) return retval; - return krb5_kt_resolve(defname, id); + return krb5_kt_resolve(context, defname, id); } diff --git a/src/lib/krb5/keytab/ktfr_entry.c b/src/lib/krb5/keytab/ktfr_entry.c index 9204033a7..efe39329e 100644 --- a/src/lib/krb5/keytab/ktfr_entry.c +++ b/src/lib/krb5/keytab/ktfr_entry.c @@ -29,13 +29,14 @@ #include krb5_error_code -krb5_kt_free_entry (entry) -krb5_keytab_entry *entry; +krb5_kt_free_entry (context, entry) + krb5_context context; + krb5_keytab_entry *entry; { if (!entry) return 0; - krb5_free_principal(entry->principal); + krb5_free_principal(context, entry->principal); if (entry->key.contents) { memset((char *)entry->key.contents, 0, entry->key.length); krb5_xfree(entry->key.contents); diff --git a/src/lib/krb5/keytab/ktremove.c b/src/lib/krb5/keytab/ktremove.c index f068d4458..795ce742d 100644 --- a/src/lib/krb5/keytab/ktremove.c +++ b/src/lib/krb5/keytab/ktremove.c @@ -28,12 +28,13 @@ #include krb5_error_code -krb5_kt_remove_entry (id, entry) -krb5_keytab id; -krb5_keytab_entry *entry; +krb5_kt_remove_entry (context, id, entry) + krb5_context context; + krb5_keytab id; + krb5_keytab_entry *entry; { if (id->ops->remove) - return (*id->ops->remove)(id, entry); + return (*id->ops->remove)(context, id, entry); else return KRB5_KT_NOWRITE; } diff --git a/src/lib/krb5/keytab/read_servi.c b/src/lib/krb5/keytab/read_servi.c index 39eb42e53..ff4890b12 100644 --- a/src/lib/krb5/keytab/read_servi.c +++ b/src/lib/krb5/keytab/read_servi.c @@ -35,14 +35,12 @@ #define KSUCCESS 0 krb5_error_code -krb5_kt_read_service_key(DECLARG(krb5_pointer, keyprocarg), - DECLARG(krb5_principal, principal), - DECLARG(krb5_kvno, vno), - DECLARG(krb5_keyblock **, key)) -OLDDECLARG(krb5_pointer, keyprocarg) -OLDDECLARG(krb5_principal, principal) -OLDDECLARG(krb5_kvno, vno) -OLDDECLARG(krb5_keyblock **, key) +krb5_kt_read_service_key(context, keyprocarg, principal, vno, key) + krb5_context context; + krb5_pointer keyprocarg; + krb5_principal principal; + krb5_kvno vno; + krb5_keyblock ** key; /* effects: If keyprocarg is not NULL, it is taken to be the name of a keytab. Otherwise, the default @@ -64,7 +62,7 @@ OLDDECLARG(krb5_keyblock **, key) * Get the name of the file that we should use. */ if (!keyprocarg) { - if ((kerror = krb5_kt_default_name((char *)keytabname, + if ((kerror = krb5_kt_default_name(context, (char *)keytabname, sizeof(keytabname) - 1))!= KSUCCESS) return (kerror); } else { @@ -73,18 +71,18 @@ OLDDECLARG(krb5_keyblock **, key) sizeof(keytabname) - 1); } - if (kerror = krb5_kt_resolve((char *)keytabname, &id)) + if (kerror = krb5_kt_resolve(context, (char *)keytabname, &id)) return (kerror); - kerror = krb5_kt_get_entry(id, principal, vno, &entry); - krb5_kt_close(id); + kerror = krb5_kt_get_entry(context, id, principal, vno, &entry); + krb5_kt_close(context, id); if (kerror) return(kerror); - krb5_copy_keyblock(&entry.key, key); + krb5_copy_keyblock(context, &entry.key, key); - krb5_kt_free_entry(&entry); + krb5_kt_free_entry(context, &entry); return (KSUCCESS); } diff --git a/src/lib/krb5/krb/ChangeLog b/src/lib/krb5/krb/ChangeLog index bdeada425..ea7c50abe 100644 --- a/src/lib/krb5/krb/ChangeLog +++ b/src/lib/krb5/krb/ChangeLog @@ -1,3 +1,7 @@ +Fri Jan 13 15:23:47 1995 Chris Provenzano (proven@mit.edu) + + * Added krb5_context to all krb5_routines + Mon Dec 19 21:55:44 1994 Theodore Y. Ts'o (tytso@dcl) * init_ctx.c: New file. Initializes and frees the krb5_context diff --git a/src/lib/krb5/krb/addr_comp.c b/src/lib/krb5/krb/addr_comp.c index 84a9abb7c..211648f29 100644 --- a/src/lib/krb5/krb/addr_comp.c +++ b/src/lib/krb5/krb/addr_comp.c @@ -32,9 +32,10 @@ * If the two addresses are the same, return TRUE, else return FALSE */ krb5_boolean -krb5_address_compare(addr1, addr2) -const krb5_address *addr1; -const krb5_address *addr2; +krb5_address_compare(context, addr1, addr2) + krb5_context context; + const krb5_address *addr1; + const krb5_address *addr2; { if (addr1->addrtype != addr2->addrtype) return(FALSE); diff --git a/src/lib/krb5/krb/addr_order.c b/src/lib/krb5/krb/addr_order.c index 05059a5c6..6d9f34669 100644 --- a/src/lib/krb5/krb/addr_order.c +++ b/src/lib/krb5/krb/addr_order.c @@ -37,9 +37,10 @@ * < 0 if first is less than 2nd, > 0 if first is greater than 2nd. */ int -krb5_address_order(addr1, addr2) -register const krb5_address *addr1; -register const krb5_address *addr2; +krb5_address_order(context, addr1, addr2) + krb5_context context; + register const krb5_address *addr1; + register const krb5_address *addr2; { int dir; register int i; diff --git a/src/lib/krb5/krb/addr_srch.c b/src/lib/krb5/krb/addr_srch.c index a1e66c98b..cc9189f01 100644 --- a/src/lib/krb5/krb/addr_srch.c +++ b/src/lib/krb5/krb/addr_srch.c @@ -32,14 +32,15 @@ * if not listed, return FALSE */ krb5_boolean -krb5_address_search(addr, addrlist) -const krb5_address *addr; -krb5_address * const * addrlist; +krb5_address_search(context, addr, addrlist) + krb5_context context; + const krb5_address *addr; + krb5_address * const * addrlist; { if (!addrlist) return TRUE; for (; *addrlist; addrlist++) { - if (krb5_address_compare(addr, *addrlist)) + if (krb5_address_compare(context, addr, *addrlist)) return TRUE; } return FALSE; diff --git a/src/lib/krb5/krb/bld_pr_ext.c b/src/lib/krb5/krb/bld_pr_ext.c index 4efabfdc0..5d11e2b19 100644 --- a/src/lib/krb5/krb/bld_pr_ext.c +++ b/src/lib/krb5/krb/bld_pr_ext.c @@ -36,14 +36,14 @@ krb5_error_code #if __STDC__ || defined(STDARG_PROTOTYPES) -krb5_build_principal_ext(krb5_principal *princ, int rlen, - const char *realm, ...) +krb5_build_principal_ext(krb5_context context, krb5_principal * princ, int rlen, const char * realm, ...) #else -krb5_build_principal_ext(princ, rlen, realm, va_alist) -krb5_principal *princ; -int rlen; -const char *realm; -va_dcl +krb5_build_principal_ext(context, princ, rlen, realm, va_alist) + krb5_context context; + krb5_principal *princ; + int rlen; + const char *realm; + va_dcl #endif { va_list ap; @@ -84,8 +84,8 @@ va_dcl krb5_xfree(princ_ret); return ENOMEM; } - krb5_princ_set_realm_length(princ_ret, rlen); - krb5_princ_set_realm_data(princ_ret, tmpdata); + krb5_princ_set_realm_length(context, princ_ret, rlen); + krb5_princ_set_realm_data(context, princ_ret, tmpdata); memcpy(tmpdata, realm, rlen); tmpdata[rlen] = 0; @@ -107,7 +107,7 @@ va_dcl } va_end(ap); *princ = princ_ret; - krb5_princ_type(princ_ret) = KRB5_NT_UNKNOWN; + krb5_princ_type(context, princ_ret) = KRB5_NT_UNKNOWN; return 0; free_out: diff --git a/src/lib/krb5/krb/bld_princ.c b/src/lib/krb5/krb/bld_princ.c index 8a93fe66c..94dbb723d 100644 --- a/src/lib/krb5/krb/bld_princ.c +++ b/src/lib/krb5/krb/bld_princ.c @@ -37,11 +37,12 @@ #include krb5_error_code -krb5_build_principal_va(princ, rlen, realm, ap) -krb5_principal princ; -int rlen; -const char *realm; -va_list ap; +krb5_build_principal_va(context, princ, rlen, realm, ap) + krb5_context context; + krb5_principal princ; + int rlen; + const char *realm; + va_list ap; { register int i, count = 0; register char *next; @@ -55,13 +56,13 @@ va_list ap; data = (krb5_data *) malloc(sizeof(krb5_data) * count); if (data == 0) return ENOMEM; - krb5_princ_set_realm_length(princ, rlen); + krb5_princ_set_realm_length(context, princ, rlen); tmpdata = malloc(rlen); if (!tmpdata) { free (data); return ENOMEM; } - krb5_princ_set_realm_data(princ, tmpdata); + krb5_princ_set_realm_data(context, princ, tmpdata); memcpy(tmpdata, realm, rlen); /* process rest of components */ @@ -100,13 +101,15 @@ va_list ap; krb5_error_code #if __STDC__ || defined(STDARG_PROTOTYPES) -krb5_build_principal(krb5_principal *princ, int rlen, const char *realm, ...) +krb5_build_principal(krb5_context context, krb5_principal * princ, int rlen, + const char * realm, ...) #else -krb5_build_principal(princ, rlen, realm, va_alist) -krb5_principal *princ; -int rlen; -const char *realm; -va_dcl +krb5_build_principal(context, princ, rlen, realm, va_alist) + krb5_context context; + krb5_principal *princ; + int rlen; + const char *realm; + va_dcl #endif { va_list ap; @@ -121,7 +124,7 @@ va_dcl #else va_start(ap); #endif - retval = krb5_build_principal_va(pr_ret, rlen, realm, ap); + retval = krb5_build_principal_va(context, pr_ret, rlen, realm, ap); va_end(ap); if (retval == 0) *princ = pr_ret; diff --git a/src/lib/krb5/krb/chk_trans.c b/src/lib/krb5/krb/chk_trans.c index e4c06dd1d..9b2d5b9cd 100644 --- a/src/lib/krb5/krb/chk_trans.c +++ b/src/lib/krb5/krb/chk_trans.c @@ -25,7 +25,8 @@ #define MAX_REALM_LN 500 -krb5_error_code krb5_check_transited_list(trans, realm1, realm2) +krb5_error_code krb5_check_transited_list(context, trans, realm1, realm2) + krb5_context context; krb5_data *trans; krb5_data *realm1; krb5_data *realm2; @@ -42,7 +43,7 @@ krb5_data *realm2; trans_length = trans->data[trans->length-1] ? trans->length : trans->length - 1; - if (retval = krb5_walk_realm_tree(realm1, realm2, &tgs_list, + if (retval = krb5_walk_realm_tree(context, realm1, realm2, &tgs_list, KRB5_REALM_BRANCH_CHAR)) { return(retval); } @@ -64,8 +65,8 @@ krb5_data *realm2; if (*(nextp-1) == '.') strcat(next, prev); retval = KRB5KRB_AP_ERR_ILL_CR_TKT; for (j = 0; tgs_list[j]; j++) { - if (strlen(next) == krb5_princ_realm(tgs_list[j])->length && - !memcmp(next, krb5_princ_realm(tgs_list[j])->data, + if (strlen(next) == krb5_princ_realm(context, tgs_list[j])->length && + !memcmp(next, krb5_princ_realm(context, tgs_list[j])->data, strlen(next))) { retval = 0; break; @@ -87,6 +88,6 @@ krb5_data *realm2; } finish: - krb5_free_realm_tree(tgs_list); + krb5_free_realm_tree(context, tgs_list); return(retval); } diff --git a/src/lib/krb5/krb/compat_recv.c b/src/lib/krb5/krb/compat_recv.c index e809d31fd..264a35adc 100644 --- a/src/lib/krb5/krb/compat_recv.c +++ b/src/lib/krb5/krb/compat_recv.c @@ -58,7 +58,8 @@ static int krb_v4_recvauth(); #define KRB5_RECVAUTH_V5 5 krb5_error_code -krb5_compat_recvauth(/* IN */ +krb5_compat_recvauth(context, + /* IN */ fdp, appl_version, server, sender_addr, fetch_from, keyproc, keyprocarg, rc_type, flags, v4_options, v4_service, v4_instance, v4_faddr, v4_laddr, @@ -66,6 +67,7 @@ krb5_compat_recvauth(/* IN */ /* OUT */ auth_sys, seq_number, client, ticket, authent, v4_kdata, v4_schedule, v4_version) + krb5_context context; krb5_pointer fdp; char *appl_version; krb5_principal server; @@ -105,7 +107,7 @@ krb5_compat_recvauth(/* IN */ KTEXT v4_ticket; /* storage for client's ticket */ #endif - if ((retval = krb5_net_read(fd, vers.vers, 4)) != 4) + if ((retval = krb5_net_read(context, fd, vers.vers, 4)) != 4) return((retval < 0) ? errno : ECONNABORTED); #ifdef KRB5_KRB4_COMPAT @@ -114,7 +116,7 @@ krb5_compat_recvauth(/* IN */ * We must be talking to a V4 sendauth; read in the * rest of the version string and make sure. */ - if ((retval = krb5_net_read(fd, vers.vers, 4)) != 4) + if ((retval = krb5_net_read(context, fd, vers.vers, 4)) != 4) return((retval < 0) ? errno : ECONNABORTED); if (strncmp(vers.vers, KRB_V4_SENDAUTH_VERS+4, 4)) @@ -176,7 +178,7 @@ krb5_compat_recvauth(/* IN */ if (!buf) return ENOMEM; - length = krb5_net_read(fd, buf, len); + length = krb5_net_read(context, fd, buf, len); if (len != length) { krb5_xfree(buf); if (len < 0) @@ -193,7 +195,7 @@ krb5_compat_recvauth(/* IN */ *auth_sys = KRB5_RECVAUTH_V5; - retval = krb5_recvauth(fdp, appl_version, server, sender_addr, + retval = krb5_recvauth(context, fdp, appl_version, server, sender_addr, fetch_from, keyproc, keyprocarg, rc_type, flags | KRB5_RECVAUTH_SKIP_VERSION, diff --git a/src/lib/krb5/krb/conv_princ.c b/src/lib/krb5/krb/conv_princ.c index 31aa1fe7f..2ed3ccf03 100644 --- a/src/lib/krb5/krb/conv_princ.c +++ b/src/lib/krb5/krb/conv_princ.c @@ -99,21 +99,22 @@ static char *strnchr(s, c, n) /* XXX This calls for a new error code */ #define KRB5_INVALID_PRINCIPAL KRB5_LNAME_BADFORMAT -krb5_error_code krb5_524_conv_principal(princ, name, inst, realm) - const krb5_principal princ; - char *name; - char *inst; - char *realm; +krb5_error_code krb5_524_conv_principal(context, princ, name, inst, realm) + krb5_context context; + const krb5_principal princ; + char *name; + char *inst; + char *realm; { struct krb_convert *p; krb5_data *comp; char *c; *name = *inst = '\0'; - switch (krb5_princ_size(princ)) { + switch (krb5_princ_size(context, princ)) { case 2: /* Check if this principal is listed in the table */ - comp = krb5_princ_component(princ, 0); + comp = krb5_princ_component(context, princ, 0); p = sconv_list; while (p->v4_str) { if (strncmp(p->v5_str, comp->data, comp->length) == 0) { @@ -121,7 +122,7 @@ krb5_error_code krb5_524_conv_principal(princ, name, inst, realm) /* instance's domain name if requested */ strcpy(name, p->v4_str); if (p->flags & DO_REALM_CONVERSION) { - comp = krb5_princ_component(princ, 1); + comp = krb5_princ_component(context, princ, 1); c = strnchr(comp->data, '.', comp->length); if (!c || (c - comp->data) > INST_SZ - 1) return KRB5_INVALID_PRINCIPAL; @@ -135,7 +136,7 @@ krb5_error_code krb5_524_conv_principal(princ, name, inst, realm) /* If inst isn't set, the service isn't listed in the table, */ /* so just copy it. */ if (*inst == '\0') { - comp = krb5_princ_component(princ, 1); + comp = krb5_princ_component(context, princ, 1); if (comp->length >= INST_SZ - 1) return KRB5_INVALID_PRINCIPAL; strncpy(inst, comp->data, comp->length); @@ -145,7 +146,7 @@ krb5_error_code krb5_524_conv_principal(princ, name, inst, realm) case 1: /* name may have been set above; otherwise, just copy it */ if (*name == '\0') { - comp = krb5_princ_component(princ, 0); + comp = krb5_princ_component(context, princ, 0); if (comp->length >= ANAME_SZ) return KRB5_INVALID_PRINCIPAL; strncpy(name, comp->data, comp->length); @@ -156,7 +157,7 @@ krb5_error_code krb5_524_conv_principal(princ, name, inst, realm) return KRB5_INVALID_PRINCIPAL; } - comp = krb5_princ_realm(princ); + comp = krb5_princ_realm(context, princ); if (comp->length > REALM_SZ - 1) return KRB5_INVALID_PRINCIPAL; strncpy(realm, comp->data, comp->length); @@ -165,7 +166,8 @@ krb5_error_code krb5_524_conv_principal(princ, name, inst, realm) return 0; } -krb5_error_code krb5_425_conv_principal(name, instance, realm, princ) +krb5_error_code krb5_425_conv_principal(context, name, instance, realm, princ) + krb5_context context; const char *name; const char *instance; const char *realm; @@ -192,7 +194,7 @@ krb5_error_code krb5_425_conv_principal(name, instance, realm, princ) name = p->v5_str; if (p->flags & DO_REALM_CONVERSION) { strcpy(buf, instance); - retval = krb5_get_realm_domain(realm, &domain); + retval = krb5_get_realm_domain(context, realm, &domain); if (retval) return retval; if (domain) { @@ -207,6 +209,6 @@ krb5_error_code krb5_425_conv_principal(name, instance, realm, princ) } not_service: - return(krb5_build_principal(princ, strlen(realm), realm, name, + return(krb5_build_principal(context, princ, strlen(realm), realm, name, instance, 0)); } diff --git a/src/lib/krb5/krb/copy_addrs.c b/src/lib/krb5/krb/copy_addrs.c index c04e2dbd4..1bb0ba682 100644 --- a/src/lib/krb5/krb/copy_addrs.c +++ b/src/lib/krb5/krb/copy_addrs.c @@ -30,7 +30,8 @@ #include static krb5_error_code -krb5_copy_addr(inad, outad) +krb5_copy_addr(context, inad, outad) + krb5_context context; const krb5_address *inad; krb5_address **outad; { @@ -52,9 +53,10 @@ krb5_address **outad; * Copy an address array, with fresh allocation. */ krb5_error_code -krb5_copy_addresses(inaddr, outaddr) -krb5_address * const * inaddr; -krb5_address ***outaddr; +krb5_copy_addresses(context, inaddr, outaddr) + krb5_context context; + krb5_address * const * inaddr; + krb5_address ***outaddr; { krb5_error_code retval; krb5_address ** tempaddr; @@ -72,9 +74,9 @@ krb5_address ***outaddr; return ENOMEM; for (nelems = 0; inaddr[nelems]; nelems++) { - retval = krb5_copy_addr(inaddr[nelems], &tempaddr[nelems]); + retval = krb5_copy_addr(context, inaddr[nelems], &tempaddr[nelems]); if (retval) { - krb5_free_addresses(tempaddr); + krb5_free_addresses(context, tempaddr); return retval; } } @@ -89,9 +91,10 @@ krb5_address ***outaddr; * returns failure, but it will not change the contents of the list. */ krb5_error_code -krb5_append_addresses(inaddr, outaddr) -krb5_address * const * inaddr; -krb5_address ***outaddr; +krb5_append_addresses(context, inaddr, outaddr) + krb5_context context; + krb5_address * const * inaddr; + krb5_address ***outaddr; { krb5_error_code retval; krb5_address ** tempaddr; @@ -117,7 +120,7 @@ krb5_address ***outaddr; for (nelems = 0; inaddr[nelems]; nelems++) { - retval = krb5_copy_addr(inaddr[nelems], + retval = krb5_copy_addr(context, inaddr[nelems], &tempaddr[norigelems + nelems]); if (retval) goto cleanup; @@ -128,7 +131,7 @@ krb5_address ***outaddr; cleanup: while (--nelems >= 0) - krb5_free_address(tempaddr[norigelems + nelems]); + krb5_free_address(context, tempaddr[norigelems + nelems]); /* Try to allocate a smaller amount of memory for *outaddr. */ tempaddr = (krb5_address **) realloc((char *)tempaddr, diff --git a/src/lib/krb5/krb/copy_athctr.c b/src/lib/krb5/krb/copy_athctr.c index fe4575b80..82bb8d79f 100644 --- a/src/lib/krb5/krb/copy_athctr.c +++ b/src/lib/krb5/krb/copy_athctr.c @@ -30,7 +30,8 @@ #include krb5_error_code -krb5_copy_authenticator(authfrom, authto) +krb5_copy_authenticator(context, authfrom, authto) + krb5_context context; const krb5_authenticator *authfrom; krb5_authenticator **authto; { @@ -41,38 +42,38 @@ krb5_authenticator **authto; return ENOMEM; *tempto = *authfrom; - retval = krb5_copy_principal(authfrom->client, &tempto->client); + retval = krb5_copy_principal(context, authfrom->client, &tempto->client); if (retval) { krb5_xfree(tempto); return retval; } if (authfrom->checksum && - (retval = krb5_copy_checksum(authfrom->checksum, &tempto->checksum))) { - krb5_free_principal(tempto->client); + (retval = krb5_copy_checksum(context, authfrom->checksum, &tempto->checksum))) { + krb5_free_principal(context, tempto->client); krb5_xfree(tempto); return retval; } if (authfrom->subkey) { - retval = krb5_copy_keyblock(authfrom->subkey, &tempto->subkey); + retval = krb5_copy_keyblock(context, authfrom->subkey, &tempto->subkey); if (retval) { krb5_xfree(tempto->subkey); - krb5_free_checksum(tempto->checksum); - krb5_free_principal(tempto->client); + krb5_free_checksum(context, tempto->checksum); + krb5_free_principal(context, tempto->client); krb5_xfree(tempto); return retval; } } if (authfrom->authorization_data) { - retval = krb5_copy_authdata(authfrom->authorization_data, + retval = krb5_copy_authdata(context, authfrom->authorization_data, &tempto->authorization_data); if (retval) { krb5_xfree(tempto->subkey); - krb5_free_checksum(tempto->checksum); - krb5_free_principal(tempto->client); - krb5_free_authdata(tempto->authorization_data); + krb5_free_checksum(context, tempto->checksum); + krb5_free_principal(context, tempto->client); + krb5_free_authdata(context, tempto->authorization_data); krb5_xfree(tempto); return retval; } diff --git a/src/lib/krb5/krb/copy_auth.c b/src/lib/krb5/krb/copy_auth.c index 39a6c83cb..830af3a8a 100644 --- a/src/lib/krb5/krb/copy_auth.c +++ b/src/lib/krb5/krb/copy_auth.c @@ -30,7 +30,8 @@ #include static krb5_error_code -krb5_copy_authdatum(inad, outad) +krb5_copy_authdatum(context, inad, outad) + krb5_context context; const krb5_authdata *inad; krb5_authdata **outad; { @@ -52,7 +53,8 @@ krb5_authdata **outad; * Copy an authdata array, with fresh allocation. */ krb5_error_code -krb5_copy_authdata(inauthdat, outauthdat) +krb5_copy_authdata(context, inauthdat, outauthdat) + krb5_context context; krb5_authdata * const * inauthdat; krb5_authdata ***outauthdat; { @@ -73,10 +75,10 @@ krb5_authdata ***outauthdat; return ENOMEM; for (nelems = 0; inauthdat[nelems]; nelems++) { - retval = krb5_copy_authdatum(inauthdat[nelems], + retval = krb5_copy_authdatum(context, inauthdat[nelems], &tempauthdat[nelems]); if (retval) { - krb5_free_authdata(tempauthdat); + krb5_free_authdata(context, tempauthdat); return retval; } } diff --git a/src/lib/krb5/krb/copy_cksum.c b/src/lib/krb5/krb/copy_cksum.c index 5f92c0b7c..cf04f4840 100644 --- a/src/lib/krb5/krb/copy_cksum.c +++ b/src/lib/krb5/krb/copy_cksum.c @@ -30,9 +30,10 @@ #include krb5_error_code -krb5_copy_checksum(ckfrom, ckto) -const krb5_checksum *ckfrom; -krb5_checksum **ckto; +krb5_copy_checksum(context, ckfrom, ckto) + krb5_context context; + const krb5_checksum *ckfrom; + krb5_checksum **ckto; { krb5_checksum *tempto; diff --git a/src/lib/krb5/krb/copy_creds.c b/src/lib/krb5/krb/copy_creds.c index 0af3b263b..5c14be075 100644 --- a/src/lib/krb5/krb/copy_creds.c +++ b/src/lib/krb5/krb/copy_creds.c @@ -34,9 +34,10 @@ */ krb5_error_code -krb5_copy_creds(incred, outcred) -const krb5_creds *incred; -krb5_creds **outcred; +krb5_copy_creds(context, incred, outcred) + krb5_context context; + const krb5_creds *incred; + krb5_creds **outcred; { krb5_creds *tempcred; krb5_error_code retval; @@ -46,32 +47,32 @@ krb5_creds **outcred; return ENOMEM; *tempcred = *incred; /* copy everything quickly */ - retval = krb5_copy_principal(incred->client, &tempcred->client); + retval = krb5_copy_principal(context, incred->client, &tempcred->client); if (retval) goto cleanlast; - retval = krb5_copy_principal(incred->server, &tempcred->server); + retval = krb5_copy_principal(context, incred->server, &tempcred->server); if (retval) goto cleanclient; - retval = krb5_copy_keyblock_contents(&incred->keyblock, + retval = krb5_copy_keyblock_contents(context, &incred->keyblock, &tempcred->keyblock); if (retval) goto cleanserver; - retval = krb5_copy_addresses(incred->addresses, &tempcred->addresses); + retval = krb5_copy_addresses(context, incred->addresses, &tempcred->addresses); if (retval) goto cleanblock; - retval = krb5_copy_data(&incred->ticket, &scratch); + retval = krb5_copy_data(context, &incred->ticket, &scratch); if (retval) goto cleanaddrs; tempcred->ticket = *scratch; krb5_xfree(scratch); - retval = krb5_copy_data(&incred->second_ticket, &scratch); + retval = krb5_copy_data(context, &incred->second_ticket, &scratch); if (retval) goto cleanticket; tempcred->second_ticket = *scratch; krb5_xfree(scratch); - retval = krb5_copy_authdata(incred->authdata,&tempcred->authdata); + retval = krb5_copy_authdata(context, incred->authdata,&tempcred->authdata); if (retval) goto clearticket; @@ -83,13 +84,13 @@ krb5_creds **outcred; cleanticket: free(tempcred->ticket.data); cleanaddrs: - krb5_free_addresses(tempcred->addresses); + krb5_free_addresses(context, tempcred->addresses); cleanblock: krb5_xfree(tempcred->keyblock.contents); cleanserver: - krb5_free_principal(tempcred->server); + krb5_free_principal(context, tempcred->server); cleanclient: - krb5_free_principal(tempcred->client); + krb5_free_principal(context, tempcred->client); cleanlast: krb5_xfree(tempcred); return retval; diff --git a/src/lib/krb5/krb/copy_data.c b/src/lib/krb5/krb/copy_data.c index aa7389e6a..669ed3e8a 100644 --- a/src/lib/krb5/krb/copy_data.c +++ b/src/lib/krb5/krb/copy_data.c @@ -32,9 +32,10 @@ * Copy a data structure, with fresh allocation. */ krb5_error_code -krb5_copy_data(indata, outdata) -const krb5_data *indata; -krb5_data **outdata; +krb5_copy_data(context, indata, outdata) + krb5_context context; + const krb5_data *indata; + krb5_data **outdata; { krb5_data *tempdata; diff --git a/src/lib/krb5/krb/copy_key.c b/src/lib/krb5/krb/copy_key.c index 3f73a50bd..305d80d40 100644 --- a/src/lib/krb5/krb/copy_key.c +++ b/src/lib/krb5/krb/copy_key.c @@ -32,9 +32,10 @@ * Copy a keyblock, including alloc'ed storage. */ krb5_error_code -krb5_copy_keyblock(from, to) -const krb5_keyblock *from; -krb5_keyblock **to; +krb5_copy_keyblock(context, from, to) + krb5_context context; + const krb5_keyblock *from; + krb5_keyblock **to; { krb5_keyblock *new_key; diff --git a/src/lib/krb5/krb/copy_princ.c b/src/lib/krb5/krb/copy_princ.c index 61e178bed..4ccfa2568 100644 --- a/src/lib/krb5/krb/copy_princ.c +++ b/src/lib/krb5/krb/copy_princ.c @@ -33,9 +33,10 @@ * Copy a principal structure, with fresh allocation. */ krb5_error_code -krb5_copy_principal(inprinc, outprinc) -krb5_const_principal inprinc; -krb5_principal *outprinc; +krb5_copy_principal(context, inprinc, outprinc) + krb5_context context; + krb5_const_principal inprinc; + krb5_principal *outprinc; { register krb5_principal tempprinc; register int i, nelems; @@ -47,7 +48,7 @@ krb5_principal *outprinc; *tempprinc = *inprinc; /* Copy all of the non-allocated pieces */ - nelems = krb5_princ_size(inprinc); + nelems = krb5_princ_size(context, inprinc); tempprinc->data = malloc(nelems * sizeof(krb5_data)); if (tempprinc->data == 0) { @@ -56,24 +57,24 @@ krb5_principal *outprinc; } for (i = 0; i < nelems; i++) { - int len = krb5_princ_component(inprinc, i)->length; - krb5_princ_component(tempprinc, i)->length = len; - if ((krb5_princ_component(tempprinc, i)->data = malloc(len)) == 0) { + int len = krb5_princ_component(context, inprinc, i)->length; + krb5_princ_component(context, tempprinc, i)->length = len; + if ((krb5_princ_component(context, tempprinc, i)->data = malloc(len)) == 0) { while (--i >= 0) - free(krb5_princ_component(tempprinc, i)->data); + free(krb5_princ_component(context, tempprinc, i)->data); free (tempprinc->data); free (tempprinc); return ENOMEM; } - memcpy(krb5_princ_component(tempprinc, i)->data, - krb5_princ_component(inprinc, i)->data, len); + memcpy(krb5_princ_component(context, tempprinc, i)->data, + krb5_princ_component(context, inprinc, i)->data, len); } tempprinc->realm.data = malloc(tempprinc->realm.length = inprinc->realm.length); if (!tempprinc->realm.data) { for (i = 0; i < nelems; i++) - free(krb5_princ_component(tempprinc, i)->data); + free(krb5_princ_component(context, tempprinc, i)->data); free(tempprinc->data); free(tempprinc); return ENOMEM; diff --git a/src/lib/krb5/krb/copy_tick.c b/src/lib/krb5/krb/copy_tick.c index 00aea46df..c4d512b84 100644 --- a/src/lib/krb5/krb/copy_tick.c +++ b/src/lib/krb5/krb/copy_tick.c @@ -30,9 +30,10 @@ #include static krb5_error_code -krb5_copy_enc_tkt_part(partfrom, partto) -const krb5_enc_tkt_part *partfrom; -krb5_enc_tkt_part **partto; +krb5_copy_enc_tkt_part(context, partfrom, partto) + krb5_context context; + const krb5_enc_tkt_part *partfrom; + krb5_enc_tkt_part **partto; { krb5_error_code retval; krb5_enc_tkt_part *tempto; @@ -40,15 +41,15 @@ krb5_enc_tkt_part **partto; if (!(tempto = (krb5_enc_tkt_part *)malloc(sizeof(*tempto)))) return ENOMEM; *tempto = *partfrom; - retval = krb5_copy_keyblock(partfrom->session, + retval = krb5_copy_keyblock(context, partfrom->session, &tempto->session); if (retval) { krb5_xfree(tempto); return retval; } - retval = krb5_copy_principal(partfrom->client, &tempto->client); + retval = krb5_copy_principal(context, partfrom->client, &tempto->client); if (retval) { - krb5_free_keyblock(tempto->session); + krb5_free_keyblock(context, tempto->session); krb5_xfree(tempto); return retval; } @@ -59,8 +60,8 @@ krb5_enc_tkt_part **partto; tempto->transited.tr_contents.data = malloc(partfrom->transited.tr_contents.length); if (!tempto->transited.tr_contents.data) { - krb5_free_principal(tempto->client); - krb5_free_keyblock(tempto->session); + krb5_free_principal(context, tempto->client); + krb5_free_keyblock(context, tempto->session); krb5_xfree(tempto); return ENOMEM; } @@ -69,22 +70,22 @@ krb5_enc_tkt_part **partto; partfrom->transited.tr_contents.length); } - retval = krb5_copy_addresses(partfrom->caddrs, &tempto->caddrs); + retval = krb5_copy_addresses(context, partfrom->caddrs, &tempto->caddrs); if (retval) { krb5_xfree(tempto->transited.tr_contents.data); - krb5_free_principal(tempto->client); - krb5_free_keyblock(tempto->session); + krb5_free_principal(context, tempto->client); + krb5_free_keyblock(context, tempto->session); krb5_xfree(tempto); return retval; } if (partfrom->authorization_data) { - retval = krb5_copy_authdata(partfrom->authorization_data, + retval = krb5_copy_authdata(context, partfrom->authorization_data, &tempto->authorization_data); if (retval) { - krb5_free_addresses(tempto->caddrs); + krb5_free_addresses(context, tempto->caddrs); krb5_xfree(tempto->transited.tr_contents.data); - krb5_free_principal(tempto->client); - krb5_free_keyblock(tempto->session); + krb5_free_principal(context, tempto->client); + krb5_free_keyblock(context, tempto->session); krb5_xfree(tempto); return retval; } @@ -94,9 +95,10 @@ krb5_enc_tkt_part **partto; } krb5_error_code -krb5_copy_ticket(from, pto) -const krb5_ticket *from; -krb5_ticket **pto; +krb5_copy_ticket(context, from, pto) + krb5_context context; + const krb5_ticket *from; + krb5_ticket **pto; { krb5_error_code retval; krb5_ticket *tempto; @@ -105,23 +107,23 @@ krb5_ticket **pto; if (!(tempto = (krb5_ticket *)malloc(sizeof(*tempto)))) return ENOMEM; *tempto = *from; - retval = krb5_copy_principal(from->server, &tempto->server); + retval = krb5_copy_principal(context, from->server, &tempto->server); if (retval) { krb5_xfree(tempto); return retval; } - retval = krb5_copy_data(&from->enc_part.ciphertext, &scratch); + retval = krb5_copy_data(context, &from->enc_part.ciphertext, &scratch); if (retval) { - krb5_free_principal(tempto->server); + krb5_free_principal(context, tempto->server); krb5_xfree(tempto); return retval; } tempto->enc_part.ciphertext = *scratch; krb5_xfree(scratch); - retval = krb5_copy_enc_tkt_part(from->enc_part2, &tempto->enc_part2); + retval = krb5_copy_enc_tkt_part(context, from->enc_part2, &tempto->enc_part2); if (retval) { krb5_xfree(tempto->enc_part.ciphertext.data); - krb5_free_principal(tempto->server); + krb5_free_principal(context, tempto->server); krb5_xfree(tempto); return retval; } diff --git a/src/lib/krb5/krb/cp_key_cnt.c b/src/lib/krb5/krb/cp_key_cnt.c index 057857f7b..6b4db985d 100644 --- a/src/lib/krb5/krb/cp_key_cnt.c +++ b/src/lib/krb5/krb/cp_key_cnt.c @@ -32,9 +32,10 @@ * Copy a keyblock, including alloc'ed storage. */ krb5_error_code -krb5_copy_keyblock_contents(from, to) -const krb5_keyblock *from; -krb5_keyblock *to; +krb5_copy_keyblock_contents(context, from, to) + krb5_context context; + const krb5_keyblock *from; + krb5_keyblock *to; { *to = *from; to->contents = (krb5_octet *)malloc(to->length); diff --git a/src/lib/krb5/krb/decode_kdc.c b/src/lib/krb5/krb/decode_kdc.c index be54e6e19..dc24be99a 100644 --- a/src/lib/krb5/krb/decode_kdc.c +++ b/src/lib/krb5/krb/decode_kdc.c @@ -45,14 +45,12 @@ */ krb5_error_code -krb5_decode_kdc_rep(DECLARG(krb5_data *, enc_rep), - DECLARG(const krb5_keyblock *, key), - DECLARG(const krb5_enctype, etype), - DECLARG(krb5_kdc_rep **, dec_rep)) -OLDDECLARG(krb5_data *, enc_rep) -OLDDECLARG(const krb5_keyblock *, key) -OLDDECLARG(const krb5_enctype, etype) -OLDDECLARG(krb5_kdc_rep **, dec_rep) +krb5_decode_kdc_rep(context, enc_rep, key, etype, dec_rep) + krb5_context context; + krb5_data * enc_rep; + const krb5_keyblock * key; + const krb5_enctype etype; + krb5_kdc_rep ** dec_rep; { krb5_error_code retval; krb5_kdc_rep *local_dec_rep; @@ -68,12 +66,12 @@ OLDDECLARG(krb5_kdc_rep **, dec_rep) return retval; if (local_dec_rep->enc_part.etype != etype) { - krb5_free_kdc_rep(local_dec_rep); + krb5_free_kdc_rep(context, local_dec_rep); return KRB5_WRONG_ETYPE; } - retval = krb5_kdc_rep_decrypt_proc(key, 0, local_dec_rep); + retval = krb5_kdc_rep_decrypt_proc(context, key, 0, local_dec_rep); if (retval) { - krb5_free_kdc_rep(local_dec_rep); + krb5_free_kdc_rep(context, local_dec_rep); return(retval); } *dec_rep = local_dec_rep; diff --git a/src/lib/krb5/krb/decrypt_tk.c b/src/lib/krb5/krb/decrypt_tk.c index 41ddd301c..cd9332806 100644 --- a/src/lib/krb5/krb/decrypt_tk.c +++ b/src/lib/krb5/krb/decrypt_tk.c @@ -41,9 +41,10 @@ */ krb5_error_code -krb5_decrypt_tkt_part(srv_key, ticket) -const krb5_keyblock *srv_key; -register krb5_ticket *ticket; +krb5_decrypt_tkt_part(context, srv_key, ticket) + krb5_context context; + const krb5_keyblock *srv_key; + register krb5_ticket *ticket; { krb5_enc_tkt_part *dec_tkt_part; krb5_encrypt_block eblock; @@ -55,31 +56,31 @@ register krb5_ticket *ticket; /* put together an eblock for this encryption */ - krb5_use_cstype(&eblock, ticket->enc_part.etype); + krb5_use_cstype(context, &eblock, ticket->enc_part.etype); scratch.length = ticket->enc_part.ciphertext.length; if (!(scratch.data = malloc(ticket->enc_part.ciphertext.length))) return(ENOMEM); /* do any necessary key pre-processing */ - retval = krb5_process_key(&eblock, srv_key); + retval = krb5_process_key(context, &eblock, srv_key); if (retval) { free(scratch.data); return(retval); } /* call the encryption routine */ - retval = krb5_decrypt((krb5_pointer) ticket->enc_part.ciphertext.data, + retval = krb5_decrypt(context, (krb5_pointer) ticket->enc_part.ciphertext.data, (krb5_pointer) scratch.data, scratch.length, &eblock, 0); if (retval) { - (void) krb5_finish_key(&eblock); + (void) krb5_finish_key(context, &eblock); free(scratch.data); return retval; } #define clean_scratch() {memset(scratch.data, 0, scratch.length); \ free(scratch.data);} - retval = krb5_finish_key(&eblock); + retval = krb5_finish_key(context, &eblock); if (retval) { clean_scratch(); diff --git a/src/lib/krb5/krb/encode_kdc.c b/src/lib/krb5/krb/encode_kdc.c index 6b01b64d2..0918c2c7c 100644 --- a/src/lib/krb5/krb/encode_kdc.c +++ b/src/lib/krb5/krb/encode_kdc.c @@ -44,18 +44,14 @@ /* due to argument promotion rules, we need to use the DECLARG/OLDDECLARG stuff... */ krb5_error_code -krb5_encode_kdc_rep(DECLARG(const krb5_msgtype, type), - DECLARG(const krb5_enc_kdc_rep_part *, encpart), - DECLARG(krb5_encrypt_block *, eblock), - DECLARG(const krb5_keyblock *, client_key), - DECLARG(krb5_kdc_rep *, dec_rep), - DECLARG(krb5_data **, enc_rep)) -OLDDECLARG(const krb5_msgtype, type) -OLDDECLARG(const krb5_enc_kdc_rep_part *, encpart) -OLDDECLARG(krb5_encrypt_block *, eblock) -OLDDECLARG(const krb5_keyblock *, client_key) -OLDDECLARG(krb5_kdc_rep *, dec_rep) -OLDDECLARG(krb5_data **, enc_rep) +krb5_encode_kdc_rep(context, type, encpart, eblock, client_key, dec_rep, enc_rep) + krb5_context context; + const krb5_msgtype type; + const krb5_enc_kdc_rep_part * encpart; + krb5_encrypt_block * eblock; + const krb5_keyblock * client_key; + krb5_kdc_rep * dec_rep; + krb5_data ** enc_rep; { krb5_data *scratch; krb5_error_code retval; @@ -94,7 +90,7 @@ OLDDECLARG(krb5_data **, enc_rep) memset(&tmp_encpart, 0, sizeof(tmp_encpart)); #define cleanup_scratch() { (void) memset(scratch->data, 0, scratch->length); \ -krb5_free_data(scratch); } +krb5_free_data(context, scratch); } dec_rep->enc_part.ciphertext.length = krb5_encrypt_size(scratch->length, eblock->crypto_entry); @@ -120,26 +116,26 @@ free(dec_rep->enc_part.ciphertext.data); \ dec_rep->enc_part.ciphertext.length = 0; \ dec_rep->enc_part.ciphertext.data = 0;} - retval = krb5_process_key(eblock, client_key); + retval = krb5_process_key(context, eblock, client_key); if (retval) { goto clean_encpart; } -#define cleanup_prockey() {(void) krb5_finish_key(eblock);} +#define cleanup_prockey() {(void) krb5_finish_key(context, eblock);} - retval = krb5_encrypt((krb5_pointer) scratch->data, + retval = krb5_encrypt(context, (krb5_pointer) scratch->data, (krb5_pointer) dec_rep->enc_part.ciphertext.data, scratch->length, eblock, 0); if (retval) { goto clean_prockey; } - dec_rep->enc_part.etype = krb5_eblock_enctype(eblock); + dec_rep->enc_part.etype = krb5_eblock_enctype(context, eblock); /* do some cleanup */ cleanup_scratch(); - retval = krb5_finish_key(eblock); + retval = krb5_finish_key(context, eblock); if (retval) { cleanup_encpart(); return retval; diff --git a/src/lib/krb5/krb/encrypt_tk.c b/src/lib/krb5/krb/encrypt_tk.c index bb263da00..80095b4b4 100644 --- a/src/lib/krb5/krb/encrypt_tk.c +++ b/src/lib/krb5/krb/encrypt_tk.c @@ -44,10 +44,11 @@ */ krb5_error_code -krb5_encrypt_tkt_part(eblock, srv_key, dec_ticket) -krb5_encrypt_block *eblock; -const krb5_keyblock *srv_key; -register krb5_ticket *dec_ticket; +krb5_encrypt_tkt_part(context, eblock, srv_key, dec_ticket) + krb5_context context; + krb5_encrypt_block *eblock; + const krb5_keyblock *srv_key; + register krb5_ticket *dec_ticket; { krb5_data *scratch; krb5_error_code retval; @@ -59,7 +60,7 @@ register krb5_ticket *dec_ticket; } #define cleanup_scratch() { (void) memset(scratch->data, 0, scratch->length); \ -krb5_free_data(scratch); } +krb5_free_data(context, scratch); } dec_ticket->enc_part.ciphertext.length = krb5_encrypt_size(scratch->length, eblock->crypto_entry); @@ -86,25 +87,25 @@ dec_ticket->enc_part.ciphertext.length = 0; \ dec_ticket->enc_part.ciphertext.data = 0;} /* do any necessary key pre-processing */ - if (retval = krb5_process_key(eblock, srv_key)) { + if (retval = krb5_process_key(context, eblock, srv_key)) { goto clean_encpart; } -#define cleanup_prockey() {(void) krb5_finish_key(eblock);} +#define cleanup_prockey() {(void) krb5_finish_key(context, eblock);} /* call the encryption routine */ - if (retval = krb5_encrypt((krb5_pointer) scratch->data, + if (retval = krb5_encrypt(context, (krb5_pointer) scratch->data, (krb5_pointer) dec_ticket->enc_part.ciphertext.data, scratch->length, eblock, 0)) { goto clean_prockey; } - dec_ticket->enc_part.etype = krb5_eblock_enctype(eblock); + dec_ticket->enc_part.etype = krb5_eblock_enctype(context, eblock); /* ticket is now assembled-- do some cleanup */ cleanup_scratch(); - if (retval = krb5_finish_key(eblock)) { + if (retval = krb5_finish_key(context, eblock)) { cleanup_encpart(); return retval; } diff --git a/src/lib/krb5/krb/faddr_ordr.c b/src/lib/krb5/krb/faddr_ordr.c index 4e0487ce0..e6870d9bb 100644 --- a/src/lib/krb5/krb/faddr_ordr.c +++ b/src/lib/krb5/krb/faddr_ordr.c @@ -37,9 +37,10 @@ * < 0 if first is less than 2nd, > 0 if first is greater than 2nd. */ int -krb5_fulladdr_order(addr1, addr2) -register const krb5_fulladdr *addr1; -register const krb5_fulladdr *addr2; +krb5_fulladdr_order(context, addr1, addr2) + krb5_context context; + register const krb5_fulladdr *addr1; + register const krb5_fulladdr *addr2; { int dir; const int minlen = min(addr1->address->length, addr2->address->length); diff --git a/src/lib/krb5/krb/free_rtree.c b/src/lib/krb5/krb/free_rtree.c index 55888d865..fca10b034 100644 --- a/src/lib/krb5/krb/free_rtree.c +++ b/src/lib/krb5/krb/free_rtree.c @@ -29,12 +29,13 @@ #include void -krb5_free_realm_tree(realms) -krb5_principal *realms; +krb5_free_realm_tree(context, realms) + krb5_context context; + krb5_principal *realms; { register krb5_principal *nrealms = realms; while (*nrealms) { - krb5_free_principal(*nrealms); + krb5_free_principal(context, *nrealms); nrealms++; } krb5_xfree(realms); diff --git a/src/lib/krb5/krb/gc_2tgt.c b/src/lib/krb5/krb/gc_2tgt.c index 639c94277..5b2c0e304 100644 --- a/src/lib/krb5/krb/gc_2tgt.c +++ b/src/lib/krb5/krb/gc_2tgt.c @@ -32,20 +32,13 @@ #include "int-proto.h" krb5_error_code -#if defined(NARROW_PROTOTYPES) -krb5_get_cred_via_2tgt (krb5_creds * tgt, - const krb5_flags kdcoptions, - const krb5_enctype etype, - const krb5_cksumtype sumtype, - register krb5_creds *cred) -#else -krb5_get_cred_via_2tgt (tgt, kdcoptions, etype, sumtype, cred) -krb5_creds *tgt; -const krb5_flags kdcoptions; -const krb5_enctype etype; -const krb5_cksumtype sumtype; -register krb5_creds * cred; -#endif +krb5_get_cred_via_2tgt (context, tgt, kdcoptions, etype, sumtype, cred) + krb5_context context; + krb5_creds *tgt; + const krb5_flags kdcoptions; + const krb5_enctype etype; + const krb5_cksumtype sumtype; + register krb5_creds * cred; { krb5_error_code retval; #if 0 @@ -58,7 +51,7 @@ register krb5_creds * cred; /* tgt->client must be equal to cred->client */ /* tgt->server must be equal to krbtgt/realmof(cred->client) */ - if (!krb5_principal_compare(tgt->client, cred->client)) + if (!krb5_principal_compare(context, tgt->client, cred->client)) return KRB5_PRINC_NOMATCH; if (!tgt->ticket.length) @@ -68,21 +61,21 @@ register krb5_creds * cred; return(KRB5_NO_2ND_TKT); #if 0 /* What does this do? */ - if (retval = krb5_tgtname(krb5_princ_realm(cred->server), - krb5_princ_realm(cred->client), &tempprinc)) + if (retval = krb5_tgtname(context, krb5_princ_realm(cred->server), + krb5_princ_realm(context, cred->client), &tempprinc)) return(retval); - if (!krb5_principal_compare(tempprinc, tgt->server)) { - krb5_free_principal(tempprinc); + if (!krb5_principal_compare(context, tempprinc, tgt->server)) { + krb5_free_principal(context, tempprinc); return KRB5_PRINC_NOMATCH; } - krb5_free_principal(tempprinc); + krb5_free_principal(context, tempprinc); #endif if (!(kdcoptions & KDC_OPT_ENC_TKT_IN_SKEY)) return KRB5_INVALID_FLAGS; - if (retval = krb5_send_tgs(kdcoptions, &cred->times, etype, sumtype, + if (retval = krb5_send_tgs(context, kdcoptions, &cred->times, etype, sumtype, cred->server, tgt->addresses, cred->authdata, @@ -104,11 +97,11 @@ register krb5_creds * cred; } retval = err_reply->error + ERROR_TABLE_BASE_krb5; - krb5_free_error(err_reply); + krb5_free_error(context, err_reply); free(tgsrep.response.data); return retval; } - retval = krb5_decode_kdc_rep(&tgsrep.response, &tgt->keyblock, + retval = krb5_decode_kdc_rep(context, &tgsrep.response, &tgt->keyblock, etype, &dec_rep); free(tgsrep.response.data); if (retval) @@ -121,7 +114,7 @@ register krb5_creds * cred; /* now it's decrypted and ready for prime time */ - if (!krb5_principal_compare(dec_rep->client, tgt->client)) { + if (!krb5_principal_compare(context, dec_rep->client, tgt->client)) { retval = KRB5_KDCREP_MODIFIED; goto errout; } @@ -132,7 +125,7 @@ register krb5_creds * cred; } cred->keyblock.magic = KV5M_KEYBLOCK; cred->keyblock.etype = dec_rep->ticket->enc_part.etype; - if (retval = krb5_copy_keyblock_contents(dec_rep->enc_part2->session, + if (retval = krb5_copy_keyblock_contents(context, dec_rep->enc_part2->session, &cred->keyblock)) goto errout; @@ -141,19 +134,19 @@ register krb5_creds * cred; cred->ticket_flags = dec_rep->enc_part2->flags; cred->is_skey = TRUE; if (cred->addresses) - krb5_free_addresses(cred->addresses); + krb5_free_addresses(context, cred->addresses); if (dec_rep->enc_part2->caddrs) - retval = krb5_copy_addresses(dec_rep->enc_part2->caddrs, + retval = krb5_copy_addresses(context, dec_rep->enc_part2->caddrs, &cred->addresses); else /* no addresses in the list means we got what we had */ - retval = krb5_copy_addresses(tgt->addresses, &cred->addresses); + retval = krb5_copy_addresses(context, tgt->addresses, &cred->addresses); if (retval) goto errout; if (cred->server) - krb5_free_principal(cred->server); - if (retval = krb5_copy_principal(dec_rep->enc_part2->server, + krb5_free_principal(context, cred->server); + if (retval = krb5_copy_principal(context, dec_rep->enc_part2->server, &cred->server)) goto errout; @@ -171,17 +164,17 @@ errout: cred->keyblock.contents = 0; } if (cred->addresses) { - krb5_free_addresses(cred->addresses); + krb5_free_addresses(context, cred->addresses); cred->addresses = 0; } if (cred->server) { - krb5_free_principal(cred->server); + krb5_free_principal(context, cred->server); cred->server = 0; } } memset((char *)dec_rep->enc_part2->session->contents, 0, dec_rep->enc_part2->session->length); - krb5_free_kdc_rep(dec_rep); + krb5_free_kdc_rep(context, dec_rep); return retval; } diff --git a/src/lib/krb5/krb/gc_frm_kdc.c b/src/lib/krb5/krb/gc_frm_kdc.c index fcb04e5dc..e18fcfdc3 100644 --- a/src/lib/krb5/krb/gc_frm_kdc.c +++ b/src/lib/krb5/krb/gc_frm_kdc.c @@ -65,19 +65,11 @@ extern krb5_cksumtype krb5_kdc_req_sumtype; #define TGT_ETYPE \ krb5_keytype_array[tgt.keyblock.keytype]->system->proto_enctype; - -#ifdef __STDC__ -krb5_error_code krb5_get_cred_from_kdc( - krb5_ccache ccache, - krb5_creds *cred, - krb5_creds ***tgts -) -#else -krb5_error_code krb5_get_cred_from_kdc(ccache, cred, tgts) - krb5_ccache ccache; - krb5_creds *cred; - krb5_creds ***tgts; -#endif +krb5_error_code krb5_get_cred_from_kdc(context, ccache, cred, tgts) + krb5_context context; + krb5_ccache ccache; + krb5_creds *cred; + krb5_creds ***tgts; { krb5_creds **ret_tgts = NULL; int ntgts = 0; @@ -115,21 +107,21 @@ krb5_error_code krb5_get_cred_from_kdc(ccache, cred, tgts) * (the ticket may be issued by some other intermediate * realm's KDC; so we use KRB5_TC_MATCH_SRV_NAMEONLY) */ - if (retval = krb5_copy_principal(cred->client, &tgtq.client)) + if (retval = krb5_copy_principal(context, cred->client, &tgtq.client)) goto cleanup; /* get target tgt from cache */ - if (retval = krb5_tgtname(krb5_princ_realm(cred->server), - krb5_princ_realm(cred->client), + if (retval = krb5_tgtname(context, krb5_princ_realm(context, cred->server), + krb5_princ_realm(context, cred->client), &int_server)) { goto cleanup; } - if (retval = krb5_copy_principal(int_server, &tgtq.server)) { + if (retval = krb5_copy_principal(context, int_server, &tgtq.server)) { goto cleanup; } - if (retval = krb5_cc_retrieve_cred(ccache, + if (retval = krb5_cc_retrieve_cred(context, ccache, KRB5_TC_MATCH_SRV_NAMEONLY, &tgtq, &tgt)) { @@ -150,22 +142,23 @@ krb5_error_code krb5_get_cred_from_kdc(ccache, cred, tgts) * didn't find it in the cache so it is time to get a local * tgt and walk the realms tree. */ - krb5_free_principal(int_server); + krb5_free_principal(context, int_server); int_server = NULL; - if (retval = krb5_tgtname(krb5_princ_realm(cred->client), - krb5_princ_realm(cred->client), + if (retval = krb5_tgtname(context, + krb5_princ_realm(context, cred->client), + krb5_princ_realm(context, cred->client), &int_server)) { goto cleanup; } - krb5_free_cred_contents(&tgtq); + krb5_free_cred_contents(context, &tgtq); memset((char *)&tgtq, 0, sizeof(tgtq)); - if(retval = krb5_copy_principal(cred->client, &tgtq.client)) + if(retval = krb5_copy_principal(context, cred->client, &tgtq.client)) goto cleanup; - if(retval = krb5_copy_principal(int_server, &tgtq.server)) + if(retval = krb5_copy_principal(context, int_server, &tgtq.server)) goto cleanup; - if (retval = krb5_cc_retrieve_cred(ccache, + if (retval = krb5_cc_retrieve_cred(context, ccache, KRB5_TC_MATCH_SRV_NAMEONLY, &tgtq, &tgt)) { @@ -174,8 +167,9 @@ krb5_error_code krb5_get_cred_from_kdc(ccache, cred, tgts) /* get a list of realms to consult */ - if (retval = krb5_walk_realm_tree(krb5_princ_realm(cred->client), - krb5_princ_realm(cred->server), + if (retval = krb5_walk_realm_tree(context, + krb5_princ_realm(context, cred->client), + krb5_princ_realm(context, cred->server), &tgs_list, KRB5_REALM_BRANCH_CHAR)) { goto cleanup; @@ -211,23 +205,24 @@ krb5_error_code krb5_get_cred_from_kdc(ccache, cred, tgts) /* look in cache for a tgt for the destination */ - krb5_free_cred_contents(&tgtq); + krb5_free_cred_contents(context, &tgtq); memset(&tgtq, 0, sizeof(tgtq)); - if(retval = krb5_copy_principal(tgt.client, &tgtq.client)) + if(retval = krb5_copy_principal(context, tgt.client, &tgtq.client)) goto cleanup; - krb5_free_principal(int_server); + krb5_free_principal(context, int_server); int_server = NULL; - if (retval = krb5_tgtname(krb5_princ_realm(cred->server), - krb5_princ_realm(*top_server), + if (retval = krb5_tgtname(context, + krb5_princ_realm(context, cred->server), + krb5_princ_realm(context, *top_server), &int_server)) { goto cleanup; } - if(retval = krb5_copy_principal(int_server, &tgtq.server)) + if(retval = krb5_copy_principal(context, int_server, &tgtq.server)) goto cleanup; - if (retval = krb5_cc_retrieve_cred(ccache, + if (retval = krb5_cc_retrieve_cred(context, ccache, KRB5_TC_MATCH_SRV_NAMEONLY, &tgtq, &tgt)) { @@ -244,17 +239,17 @@ krb5_error_code krb5_get_cred_from_kdc(ccache, cred, tgts) goto cleanup; } - krb5_free_cred_contents(&tgtq); + krb5_free_cred_contents(context, &tgtq); memset(&tgtq, 0, sizeof(tgtq)); tgtq.times = tgt.times; - if (retval = krb5_copy_principal(tgt.client, &tgtq.client)) + if (retval = krb5_copy_principal(context, tgt.client, &tgtq.client)) goto cleanup; - if(retval = krb5_copy_principal(int_server, &tgtq.server)) + if(retval = krb5_copy_principal(context, int_server, &tgtq.server)) goto cleanup; tgtq.is_skey = FALSE; tgtq.ticket_flags = tgt.ticket_flags; etype = TGT_ETYPE; - if(retval = krb5_get_cred_via_tgt(&tgt, + if(retval = krb5_get_cred_via_tgt(context, &tgt, FLAGS2OPTS(tgtq.ticket_flags), etype, krb5_kdc_req_sumtype, @@ -270,23 +265,24 @@ krb5_error_code krb5_get_cred_from_kdc(ccache, cred, tgts) for (next_server = tgs_list + nservers - 1; next_server > top_server; next_server--) { - krb5_free_cred_contents(&tgtq); + krb5_free_cred_contents(context, &tgtq); memset(&tgtq, 0, sizeof(tgtq)); - if (retval = krb5_copy_principal(tgt.client, &tgtq.client)) + if (retval = krb5_copy_principal(context, tgt.client, &tgtq.client)) goto cleanup; - krb5_free_principal(int_server); + krb5_free_principal(context, int_server); int_server = NULL; - if (retval = krb5_tgtname(krb5_princ_realm(*next_server), - krb5_princ_realm(*top_server), + if (retval = krb5_tgtname(context, + krb5_princ_realm(context, *next_server), + krb5_princ_realm(context, *top_server), &int_server)) { goto cleanup; } - if(retval = krb5_copy_principal(int_server, &tgtq.server)) + if(retval = krb5_copy_principal(context, int_server, &tgtq.server)) goto cleanup; - if(retval = krb5_cc_retrieve_cred(ccache, + if(retval = krb5_cc_retrieve_cred(context, ccache, KRB5_TC_MATCH_SRV_NAMEONLY, &tgtq, &tgt)) { @@ -301,17 +297,17 @@ krb5_error_code krb5_get_cred_from_kdc(ccache, cred, tgts) goto cleanup; } - krb5_free_cred_contents(&tgtq); + krb5_free_cred_contents(context, &tgtq); memset(&tgtq, 0, sizeof(tgtq)); tgtq.times = tgt.times; - if (retval = krb5_copy_principal(tgt.client, &tgtq.client)) + if (retval = krb5_copy_principal(context, tgt.client, &tgtq.client)) goto cleanup; - if(retval = krb5_copy_principal(int_server, &tgtq.server)) + if(retval = krb5_copy_principal(context, int_server, &tgtq.server)) goto cleanup; tgtq.is_skey = FALSE; tgtq.ticket_flags = tgt.ticket_flags; etype = TGT_ETYPE; - if (retval = krb5_get_cred_via_tgt(&tgt, + if (retval = krb5_get_cred_via_tgt(context, &tgt, FLAGS2OPTS(tgtq.ticket_flags), etype, krb5_kdc_req_sumtype, @@ -320,7 +316,7 @@ krb5_error_code krb5_get_cred_from_kdc(ccache, cred, tgts) } /* save tgt in return array */ - if (retval = krb5_copy_creds(&tgtq, &ret_tgts[ntgts])) { + if (retval = krb5_copy_creds(context, &tgtq, &ret_tgts[ntgts])) { goto cleanup; } @@ -347,8 +343,8 @@ krb5_error_code krb5_get_cred_from_kdc(ccache, cred, tgts) */ for (next_server = top_server; *next_server; next_server++) { - krb5_data *realm_1 = krb5_princ_component(next_server[0], 1); - krb5_data *realm_2 = krb5_princ_component(tgtq.server, 1); + krb5_data *realm_1 = krb5_princ_component(context, next_server[0], 1); + krb5_data *realm_2 = krb5_princ_component(context, tgtq.server, 1); if (realm_1->length == realm_2->length && !memcmp(realm_1->data, realm_2->data, realm_1->length)) { break; @@ -360,7 +356,7 @@ krb5_error_code krb5_get_cred_from_kdc(ccache, cred, tgts) goto cleanup; } - if (retval = krb5_copy_creds(&tgtq, &ret_tgts[ntgts])) { + if (retval = krb5_copy_creds(context, &tgtq, &ret_tgts[ntgts])) { goto cleanup; } @@ -382,7 +378,7 @@ krb5_error_code krb5_get_cred_from_kdc(ccache, cred, tgts) etype = TGT_ETYPE; if (cred->second_ticket.length) { - retval = krb5_get_cred_via_2tgt(&tgt, + retval = krb5_get_cred_via_2tgt(context, &tgt, KDC_OPT_ENC_TKT_IN_SKEY | FLAGS2OPTS(tgt.ticket_flags), etype, @@ -390,7 +386,7 @@ krb5_error_code krb5_get_cred_from_kdc(ccache, cred, tgts) cred); } else { - retval = krb5_get_cred_via_tgt(&tgt, + retval = krb5_get_cred_via_tgt(context, &tgt, FLAGS2OPTS(tgt.ticket_flags), etype, krb5_kdc_req_sumtype, @@ -401,13 +397,13 @@ krb5_error_code krb5_get_cred_from_kdc(ccache, cred, tgts) cleanup: - if(tgs_list) krb5_free_realm_tree(tgs_list); - krb5_free_cred_contents(&tgtq); - if (int_server) krb5_free_principal(int_server); + if(tgs_list) krb5_free_realm_tree(context, tgs_list); + krb5_free_cred_contents(context, &tgtq); + if (int_server) krb5_free_principal(context, int_server); if (ntgts == 0) { *tgts = NULL; if (ret_tgts) free(ret_tgts); - krb5_free_cred_contents(&tgt); + krb5_free_cred_contents(context, &tgt); } return(retval); } diff --git a/src/lib/krb5/krb/gc_via_tgt.c b/src/lib/krb5/krb/gc_via_tgt.c index d2c565439..6aa3a11b8 100644 --- a/src/lib/krb5/krb/gc_via_tgt.c +++ b/src/lib/krb5/krb/gc_via_tgt.c @@ -34,16 +34,13 @@ #include "int-proto.h" krb5_error_code -krb5_get_cred_via_tgt (DECLARG(krb5_creds *, tgt), - DECLARG(const krb5_flags, kdcoptions), - DECLARG(const krb5_enctype, etype), - DECLARG(const krb5_cksumtype, sumtype), - DECLARG(krb5_creds *, cred)) -OLDDECLARG(krb5_creds *, tgt) -OLDDECLARG(const krb5_flags, kdcoptions) -OLDDECLARG(const krb5_enctype, etype) -OLDDECLARG(const krb5_cksumtype, sumtype) -OLDDECLARG(krb5_creds *, cred) +krb5_get_cred_via_tgt (context, tgt, kdcoptions, etype, sumtype, cred) + krb5_context context; + krb5_creds * tgt; + const krb5_flags kdcoptions; + const krb5_enctype etype; + const krb5_cksumtype sumtype; + krb5_creds * cred; { krb5_error_code retval; krb5_principal tempprinc; @@ -54,7 +51,7 @@ OLDDECLARG(krb5_creds *, cred) /* tgt->client must be equal to cred->client */ - if (!krb5_principal_compare(tgt->client, cred->client)) + if (!krb5_principal_compare(context, tgt->client, cred->client)) return KRB5_PRINC_NOMATCH; if (!tgt->ticket.length) @@ -64,17 +61,18 @@ OLDDECLARG(krb5_creds *, cred) /* tgt->server must be equal to */ /* krbtgt/realmof(cred->server)@realmof(tgt->server) */ - if(retval = krb5_tgtname(krb5_princ_realm(cred->server), - krb5_princ_realm(tgt->server), &tempprinc)) + if(retval = krb5_tgtname(context, + krb5_princ_realm(context, cred->server), + krb5_princ_realm(context, tgt->server), &tempprinc)) return(retval); - if (!krb5_principal_compare(tempprinc, tgt->server)) { - krb5_free_principal(tempprinc); + if (!krb5_principal_compare(context, tempprinc, tgt->server)) { + krb5_free_principal(context, tempprinc); return KRB5_PRINC_NOMATCH; } - krb5_free_principal(tempprinc); + krb5_free_principal(context, tempprinc); - if (retval = krb5_send_tgs(kdcoptions, &cred->times, etype, sumtype, + if (retval = krb5_send_tgs(context, kdcoptions, &cred->times, etype, sumtype, cred->server, tgt->addresses, cred->authdata, @@ -104,18 +102,18 @@ OLDDECLARG(krb5_creds *, cred) /* XXX need access to the actual assembled request... need a change to send_tgs */ if ((err_reply->ctime != request.ctime) || - !krb5_principal_compare(err_reply->server, request.server) || - !krb5_principal_compare(err_reply->client, request.client)) + !krb5_principal_compare(context, err_reply->server, request.server) || + !krb5_principal_compare(context, err_reply->client, request.client)) retval = KRB5_KDCREP_MODIFIED; else #endif retval = err_reply->error + ERROR_TABLE_BASE_krb5; - krb5_free_error(err_reply); + krb5_free_error(context, err_reply); cleanup(); return retval; } - retval = krb5_decode_kdc_rep(&tgsrep.response, + retval = krb5_decode_kdc_rep(context, &tgsrep.response, &tgt->keyblock, etype, /* enctype */ &dec_rep); @@ -126,7 +124,7 @@ OLDDECLARG(krb5_creds *, cred) #define cleanup() {\ memset((char *)dec_rep->enc_part2->session->contents, 0,\ dec_rep->enc_part2->session->length);\ - krb5_free_kdc_rep(dec_rep); } + krb5_free_kdc_rep(context, dec_rep); } if (dec_rep->msg_type != KRB5_TGS_REP) { retval = KRB5KRB_AP_ERR_MSG_TYPE; @@ -136,7 +134,7 @@ OLDDECLARG(krb5_creds *, cred) /* now it's decrypted and ready for prime time */ - if (!krb5_principal_compare(dec_rep->client, tgt->client)) { + if (!krb5_principal_compare(context, dec_rep->client, tgt->client)) { cleanup(); return KRB5_KDCREP_MODIFIED; } @@ -147,7 +145,7 @@ OLDDECLARG(krb5_creds *, cred) } cred->keyblock.magic = KV5M_KEYBLOCK; cred->keyblock.etype = dec_rep->ticket->enc_part.etype; - if (retval = krb5_copy_keyblock_contents(dec_rep->enc_part2->session, + if (retval = krb5_copy_keyblock_contents(context, dec_rep->enc_part2->session, &cred->keyblock)) { cleanup(); return retval; @@ -158,19 +156,19 @@ OLDDECLARG(krb5_creds *, cred) #undef cleanup #define cleanup() {\ memset((char *)cred->keyblock.contents, 0, cred->keyblock.length);\ - krb5_free_kdc_rep(dec_rep); } + krb5_free_kdc_rep(context, dec_rep); } cred->times = dec_rep->enc_part2->times; #if 0 /* XXX probably need access to the request */ /* check the contents for sanity: */ - if (!krb5_principal_compare(dec_rep->client, request.client) - || !krb5_principal_compare(dec_rep->enc_part2->server, request.server) - || !krb5_principal_compare(dec_rep->ticket->server, request.server) + if (!krb5_principal_compare(context, dec_rep->client, request.client) + || !krb5_principal_compare(context, dec_rep->enc_part2->server, request.server) + || !krb5_principal_compare(context, dec_rep->ticket->server, request.server) || (request.nonce != dec_rep->enc_part2->nonce) /* XXX check for extraneous flags */ - /* XXX || (!krb5_addresses_compare(addrs, dec_rep->enc_part2->caddrs)) */ + /* XXX || (!krb5_addresses_compare(context, addrs, dec_rep->enc_part2->caddrs)) */ || ((request.from != 0) && (request.from != dec_rep->enc_part2->times.starttime)) || ((request.till != 0) && @@ -199,17 +197,17 @@ OLDDECLARG(krb5_creds *, cred) cred->ticket_flags = dec_rep->enc_part2->flags; cred->is_skey = FALSE; if (cred->addresses) { - krb5_free_addresses(cred->addresses); + krb5_free_addresses(context, cred->addresses); } if (dec_rep->enc_part2->caddrs) { - if (retval = krb5_copy_addresses(dec_rep->enc_part2->caddrs, + if (retval = krb5_copy_addresses(context, dec_rep->enc_part2->caddrs, &cred->addresses)) { cleanup(); return retval; } } else { /* no addresses in the list means we got what we had */ - if (retval = krb5_copy_addresses(tgt->addresses, + if (retval = krb5_copy_addresses(context, tgt->addresses, &cred->addresses)) { cleanup(); return retval; @@ -219,8 +217,8 @@ OLDDECLARG(krb5_creds *, cred) * Free cred->server before overwriting it. */ if (cred->server) - krb5_free_principal(cred->server); - if (retval = krb5_copy_principal(dec_rep->enc_part2->server, + krb5_free_principal(context, cred->server); + if (retval = krb5_copy_principal(context, dec_rep->enc_part2->server, &cred->server)) { cleanup(); return retval; @@ -228,13 +226,13 @@ OLDDECLARG(krb5_creds *, cred) if (retval = encode_krb5_ticket(dec_rep->ticket, &scratch)) { cleanup(); - krb5_free_addresses(cred->addresses); + krb5_free_addresses(context, cred->addresses); return retval; } cred->ticket = *scratch; krb5_xfree(scratch); - krb5_free_kdc_rep(dec_rep); + krb5_free_kdc_rep(context, dec_rep); return retval; } diff --git a/src/lib/krb5/krb/gen_seqnum.c b/src/lib/krb5/krb/gen_seqnum.c index 96d8c3f88..f5ead423a 100644 --- a/src/lib/krb5/krb/gen_seqnum.c +++ b/src/lib/krb5/krb/gen_seqnum.c @@ -36,9 +36,10 @@ #endif krb5_error_code -krb5_generate_seq_number(key, seqno) -const krb5_keyblock *key; -krb5_int32 *seqno; +krb5_generate_seq_number(context, key, seqno) + krb5_context context; + const krb5_keyblock *key; + krb5_int32 *seqno; { krb5_pointer random_state; krb5_encrypt_block eblock; @@ -54,18 +55,18 @@ krb5_int32 *seqno; if (!valid_keytype(key->keytype)) return KRB5_PROG_KEYTYPE_NOSUPP; - krb5_use_keytype(&eblock, key->keytype); + krb5_use_keytype(context, &eblock, key->keytype); - if (retval = krb5_init_random_key(&eblock, key, &random_state)) + if (retval = krb5_init_random_key(context, &eblock, key, &random_state)) return(retval); - if (retval = krb5_random_key(&eblock, random_state, &subkey)) { - (void) krb5_finish_random_key(&eblock, &random_state); + if (retval = krb5_random_key(context, &eblock, random_state, &subkey)) { + (void) krb5_finish_random_key(context, &eblock, &random_state); return retval; } /* ignore the error if any, since we've already gotten the key out */ - if (retval = krb5_finish_random_key(&eblock, &random_state)) { - krb5_free_keyblock(subkey); + if (retval = krb5_finish_random_key(context, &eblock, &random_state)) { + krb5_free_keyblock(context, subkey); return retval; } @@ -80,19 +81,19 @@ krb5_int32 *seqno; retval = ENOMEM; goto cleanup; } - if (retval = krb5_process_key(&eblock, subkey)) { + if (retval = krb5_process_key(context, &eblock, subkey)) { goto cleanup; } - if (retval = krb5_us_timeofday(&timenow.seconds, + if (retval = krb5_us_timeofday(context, &timenow.seconds, &timenow.microseconds)) { goto cleanup; } memcpy((char *)intmp, (char *)&timenow, sizeof(timenow)); - retval = krb5_encrypt((krb5_pointer)intmp, (krb5_pointer)outtmp, + retval = krb5_encrypt(context, (krb5_pointer)intmp, (krb5_pointer)outtmp, sizeof(timenow), &eblock, 0); - (void) krb5_finish_key(&eblock); + (void) krb5_finish_key(context, &eblock); if (retval) goto cleanup; @@ -100,7 +101,7 @@ krb5_int32 *seqno; cleanup: if (subkey) - krb5_free_keyblock(subkey); + krb5_free_keyblock(context, subkey); if (intmp) krb5_xfree(intmp); if (outtmp) diff --git a/src/lib/krb5/krb/gen_subkey.c b/src/lib/krb5/krb/gen_subkey.c index e1178abca..68425b2c9 100644 --- a/src/lib/krb5/krb/gen_subkey.c +++ b/src/lib/krb5/krb/gen_subkey.c @@ -29,9 +29,10 @@ #include krb5_error_code -krb5_generate_subkey(key, subkey) -const krb5_keyblock *key; -krb5_keyblock **subkey; +krb5_generate_subkey(context, key, subkey) + krb5_context context; + const krb5_keyblock *key; + krb5_keyblock **subkey; { krb5_pointer random_state; krb5_encrypt_block eblock; @@ -40,23 +41,23 @@ krb5_keyblock **subkey; if (!valid_keytype(key->keytype)) return KRB5_PROG_KEYTYPE_NOSUPP; - krb5_use_keytype(&eblock, key->keytype); + krb5_use_keytype(context, &eblock, key->keytype); - if (retval = krb5_init_random_key(&eblock, key, &random_state)) + if (retval = krb5_init_random_key(context, &eblock, key, &random_state)) return(retval); *subkey = (krb5_keyblock *)malloc(sizeof(**subkey)); if (!*subkey) { - (void) krb5_finish_random_key(&eblock, &random_state); + (void) krb5_finish_random_key(context, &eblock, &random_state); return ENOMEM; } - if (retval = krb5_random_key(&eblock, random_state, subkey)) { - (void) krb5_finish_random_key(&eblock, &random_state); + if (retval = krb5_random_key(context, &eblock, random_state, subkey)) { + (void) krb5_finish_random_key(context, &eblock, &random_state); krb5_xfree(*subkey); return retval; } /* ignore the error if any, since we've already gotten the key out */ - (void) krb5_finish_random_key(&eblock, &random_state); + (void) krb5_finish_random_key(context, &eblock, &random_state); return 0; } diff --git a/src/lib/krb5/krb/get_creds.c b/src/lib/krb5/krb/get_creds.c index 0bcdbaeac..21f043e15 100644 --- a/src/lib/krb5/krb/get_creds.c +++ b/src/lib/krb5/krb/get_creds.c @@ -44,10 +44,11 @@ #include krb5_error_code -krb5_get_credentials(options, ccache, creds) -const krb5_flags options; -krb5_ccache ccache; -krb5_creds *creds; +krb5_get_credentials(context, options, ccache, creds) + krb5_context context; + const krb5_flags options; + krb5_ccache ccache; + krb5_creds *creds; { krb5_error_code retval, rv2; krb5_creds **tgts; @@ -77,27 +78,27 @@ krb5_creds *creds; return KRB5_NO_2ND_TKT; } - retval = krb5_cc_retrieve_cred(ccache, fields, &mcreds, &ncreds); + retval = krb5_cc_retrieve_cred(context, ccache, fields, &mcreds, &ncreds); if (retval == 0) { - krb5_free_cred_contents(creds); + krb5_free_cred_contents(context, creds); *creds = ncreds; } if (retval != KRB5_CC_NOTFOUND || options & KRB5_GC_CACHED) return retval; - retval = krb5_get_cred_from_kdc(ccache, creds, &tgts); + retval = krb5_get_cred_from_kdc(context, ccache, creds, &tgts); if (tgts) { register int i = 0; while (tgts[i]) { - if (rv2 = krb5_cc_store_cred(ccache, tgts[i])) { + if (rv2 = krb5_cc_store_cred(context, ccache, tgts[i])) { retval = rv2; break; } i++; } - krb5_free_tgt_creds(tgts); + krb5_free_tgt_creds(context, tgts); } if (!retval) - retval = krb5_cc_store_cred(ccache, creds); + retval = krb5_cc_store_cred(context, ccache, creds); return retval; } diff --git a/src/lib/krb5/krb/get_fcreds.c b/src/lib/krb5/krb/get_fcreds.c index b6cd2d820..a520e5aff 100644 --- a/src/lib/krb5/krb/get_fcreds.c +++ b/src/lib/krb5/krb/get_fcreds.c @@ -46,7 +46,8 @@ /* Get a TGT for use at the remote host */ krb5_error_code -krb5_get_for_creds(etype, sumtype, rhost, client, enc_key, forwardable, outbuf) +krb5_get_for_creds(context, etype, sumtype, rhost, client, enc_key, forwardable, outbuf) + krb5_context context; const krb5_enctype etype; const krb5_cksumtype sumtype; char *rhost; @@ -83,7 +84,7 @@ krb5_get_for_creds(etype, sumtype, rhost, client, enc_key, forwardable, outbuf) } strcpy(remote_host, hp->h_name); - if (retval = krb5_get_host_realm(remote_host, &hrealms)) + if (retval = krb5_get_host_realm(context, remote_host, &hrealms)) goto errout; if (!hrealms[0]) { retval = KRB5_ERR_HOST_REALM_UNKNOWN; @@ -118,10 +119,10 @@ krb5_get_for_creds(etype, sumtype, rhost, client, enc_key, forwardable, outbuf) } addrs[i] = 0; - if (retval = krb5_copy_principal(client, &creds.client)) + if (retval = krb5_copy_principal(context, client, &creds.client)) goto errout; - if (retval = krb5_build_principal_ext(&creds.server, + if (retval = krb5_build_principal_ext(context, &creds.server, strlen(hrealms[0]), hrealms[0], KRB5_TGS_NAME_SIZE, @@ -132,26 +133,26 @@ krb5_get_for_creds(etype, sumtype, rhost, client, enc_key, forwardable, outbuf) goto errout; creds.times.starttime = 0; - if (retval = krb5_timeofday(&now)) + if (retval = krb5_timeofday(context, &now)) goto errout; creds.times.endtime = now + KRB5_DEFAULT_LIFE; creds.times.renew_till = 0; - if (retval = krb5_cc_default(&cc)) + if (retval = krb5_cc_default(context, &cc)) goto errout; /* fetch tgt directly from cache */ - retval = krb5_cc_retrieve_cred (cc, + retval = krb5_cc_retrieve_cred (context, cc, KRB5_TC_MATCH_SRV_NAMEONLY, &creds, &tgt); - krb5_cc_close(cc); + krb5_cc_close(context, cc); if (retval) goto errout; /* tgt->client must be equal to creds.client */ - if (!krb5_principal_compare(tgt.client, creds.client)) { + if (!krb5_principal_compare(context, tgt.client, creds.client)) { retval = KRB5_PRINC_NOMATCH; goto errout; } @@ -166,7 +167,7 @@ krb5_get_for_creds(etype, sumtype, rhost, client, enc_key, forwardable, outbuf) if (!forwardable) /* Reset KDC_OPT_FORWARDABLE */ kdcoptions &= ~(KDC_OPT_FORWARDABLE); - if (retval = krb5_send_tgs(kdcoptions, &creds.times, etype, sumtype, + if (retval = krb5_send_tgs(context, kdcoptions, &creds.times, etype, sumtype, tgt.server, addrs, creds.authdata, @@ -190,11 +191,11 @@ krb5_get_for_creds(etype, sumtype, rhost, client, enc_key, forwardable, outbuf) retval = err_reply->error + ERROR_TABLE_BASE_krb5; - krb5_free_error(err_reply); + krb5_free_error(context, err_reply); goto errout; } - if (retval = krb5_decode_kdc_rep(&tgsrep.response, + if (retval = krb5_decode_kdc_rep(context, &tgsrep.response, &tgt.keyblock, etype, /* enctype */ &dec_rep)) @@ -207,12 +208,12 @@ krb5_get_for_creds(etype, sumtype, rhost, client, enc_key, forwardable, outbuf) /* now it's decrypted and ready for prime time */ - if (!krb5_principal_compare(dec_rep->client, tgt.client)) { + if (!krb5_principal_compare(context, dec_rep->client, tgt.client)) { retval = KRB5_KDCREP_MODIFIED; goto errout; } - retval = krb5_mk_cred(dec_rep, etype, enc_key, 0, 0, outbuf); + retval = krb5_mk_cred(context, dec_rep, etype, enc_key, 0, 0, outbuf); errout: if (remote_host) @@ -220,12 +221,12 @@ errout: if (hrealms) krb5_xfree(hrealms); if (addrs) - krb5_free_addresses(addrs); - krb5_free_cred_contents(&creds); + krb5_free_addresses(context, addrs); + krb5_free_cred_contents(context, &creds); if (tgsrep.response.data) free(tgsrep.response.data); if (dec_rep) - krb5_free_kdc_rep(dec_rep); + krb5_free_kdc_rep(context, dec_rep); return retval; } diff --git a/src/lib/krb5/krb/get_in_tkt.c b/src/lib/krb5/krb/get_in_tkt.c index 90e200c76..2cb128c8b 100644 --- a/src/lib/krb5/krb/get_in_tkt.c +++ b/src/lib/krb5/krb/get_in_tkt.c @@ -67,40 +67,34 @@ extern krb5_deltat krb5_clockskew; /* widen this prototype if need be */ #include -typedef krb5_error_code (*git_key_proc) PROTOTYPE((const krb5_keytype, +typedef krb5_error_code (*git_key_proc) PROTOTYPE((krb5_context, + const krb5_keytype, krb5_keyblock **, krb5_const_pointer, krb5_pa_data **)); #include -typedef krb5_error_code (*git_decrypt_proc) PROTOTYPE((const krb5_keyblock *, +typedef krb5_error_code (*git_decrypt_proc) PROTOTYPE((krb5_context, + const krb5_keyblock *, krb5_const_pointer, krb5_kdc_rep * )); krb5_error_code -krb5_get_in_tkt(DECLARG(const krb5_flags, options), - DECLARG(krb5_address * const *, addrs), - DECLARG(const krb5_preauthtype, pre_auth_type), - DECLARG(const krb5_enctype, etype), - DECLARG(const krb5_keytype, keytype), - DECLARG(git_key_proc, key_proc), - DECLARG(krb5_const_pointer, keyseed), - DECLARG(git_decrypt_proc, decrypt_proc), - DECLARG(krb5_const_pointer, decryptarg), - DECLARG(krb5_creds *, creds), - DECLARG(krb5_ccache, ccache), - DECLARG(krb5_kdc_rep **, ret_as_reply)) -OLDDECLARG(const krb5_flags, options) -OLDDECLARG(krb5_address * const *, addrs) -OLDDECLARG(const krb5_preauthtype, pre_auth_type) -OLDDECLARG(const krb5_enctype, etype) -OLDDECLARG(const krb5_keytype, keytype) -OLDDECLARG(git_key_proc, key_proc) -OLDDECLARG(krb5_const_pointer, keyseed) -OLDDECLARG(git_decrypt_proc, decrypt_proc) -OLDDECLARG(krb5_const_pointer, decryptarg) -OLDDECLARG(krb5_creds *, creds) -OLDDECLARG(krb5_ccache, ccache) -OLDDECLARG(krb5_kdc_rep **, ret_as_reply) +krb5_get_in_tkt(context, options, addrs, pre_auth_type, etype, keytype, + key_proc, keyseed, decrypt_proc, decryptarg, creds, + ccache, ret_as_reply) + krb5_context context; + const krb5_flags options; + krb5_address * const * addrs; + const krb5_preauthtype pre_auth_type; + const krb5_enctype etype; + const krb5_keytype keytype; + git_key_proc key_proc; + krb5_const_pointer keyseed; + git_decrypt_proc decrypt_proc; + krb5_const_pointer decryptarg; + krb5_creds * creds; + krb5_ccache ccache; + krb5_kdc_rep ** ret_as_reply; { krb5_kdc_req request; krb5_kdc_rep *as_reply = 0; @@ -113,7 +107,7 @@ OLDDECLARG(krb5_kdc_rep **, ret_as_reply) krb5_timestamp time_now; krb5_pa_data *padata; - if (! krb5_realm_compare(creds->client, creds->server)) + if (! krb5_realm_compare(context, creds->client, creds->server)) return KRB5_IN_TKT_REALM_MISMATCH; if (ret_as_reply) @@ -142,7 +136,7 @@ OLDDECLARG(krb5_kdc_rep **, ret_as_reply) * default. But if we're changing salts, because of a * realm renaming, or some such, this won't work. */ - retval = (*key_proc)(keytype, &decrypt_key, keyseed, 0); + retval = (*key_proc)(context, keytype, &decrypt_key, keyseed, 0); if (retval) return retval; request.padata = (krb5_pa_data **) malloc(sizeof(krb5_pa_data *) @@ -152,7 +146,7 @@ OLDDECLARG(krb5_kdc_rep **, ret_as_reply) goto cleanup; } - retval = krb5_obtain_padata(pre_auth_type, creds->client, + retval = krb5_obtain_padata(context, pre_auth_type, creds->client, request.addresses, decrypt_key, &padata); if (retval) @@ -168,7 +162,7 @@ OLDDECLARG(krb5_kdc_rep **, ret_as_reply) request.from = creds->times.starttime; request.till = creds->times.endtime; request.rtime = creds->times.renew_till; - if (retval = krb5_timeofday(&time_now)) + if (retval = krb5_timeofday(context, &time_now)) goto cleanup; /* XXX we know they are the same size... */ @@ -186,8 +180,9 @@ OLDDECLARG(krb5_kdc_rep **, ret_as_reply) if (retval = encode_krb5_as_req(&request, &packet)) goto cleanup; - retval = krb5_sendto_kdc(packet, krb5_princ_realm(creds->client), &reply); - krb5_free_data(packet); + retval = krb5_sendto_kdc(context, packet, + krb5_princ_realm(context, creds->client), &reply); + krb5_free_data(context, packet); if (retval) goto cleanup; @@ -201,15 +196,15 @@ OLDDECLARG(krb5_kdc_rep **, ret_as_reply) /* it was an error */ if ((err_reply->ctime != request.nonce) || - !krb5_principal_compare(err_reply->server, request.server) || - !krb5_principal_compare(err_reply->client, request.client)) + !krb5_principal_compare(context, err_reply->server, request.server) || + !krb5_principal_compare(context, err_reply->client, request.client)) retval = KRB5_KDCREP_MODIFIED; else retval = err_reply->error + ERROR_TABLE_BASE_krb5; /* XXX somehow make error msg text available to application? */ - krb5_free_error(err_reply); + krb5_free_error(context, err_reply); goto cleanup; } @@ -230,27 +225,27 @@ OLDDECLARG(krb5_kdc_rep **, ret_as_reply) /* Generate the key, if we haven't done so already. */ if (!decrypt_key) { - if (retval = (*key_proc)(keytype, &decrypt_key, keyseed, + if (retval = (*key_proc)(context, keytype, &decrypt_key, keyseed, as_reply->padata)) goto cleanup; } - if (retval = (*decrypt_proc)(decrypt_key, decryptarg, as_reply)) + if (retval = (*decrypt_proc)(context, decrypt_key, decryptarg, as_reply)) goto cleanup; - krb5_free_keyblock(decrypt_key); + krb5_free_keyblock(context, decrypt_key); decrypt_key = 0; /* check the contents for sanity: */ if (!as_reply->enc_part2->times.starttime) as_reply->enc_part2->times.starttime = as_reply->enc_part2->times.authtime; - if (!krb5_principal_compare(as_reply->client, request.client) - || !krb5_principal_compare(as_reply->enc_part2->server, request.server) - || !krb5_principal_compare(as_reply->ticket->server, request.server) + if (!krb5_principal_compare(context, as_reply->client, request.client) + || !krb5_principal_compare(context, as_reply->enc_part2->server, request.server) + || !krb5_principal_compare(context, as_reply->ticket->server, request.server) || (request.nonce != as_reply->enc_part2->nonce) /* XXX check for extraneous flags */ - /* XXX || (!krb5_addresses_compare(addrs, as_reply->enc_part2->caddrs)) */ + /* XXX || (!krb5_addresses_compare(context, addrs, as_reply->enc_part2->caddrs)) */ || ((request.from != 0) && (request.from != as_reply->enc_part2->times.starttime)) || ((request.till != 0) && @@ -276,7 +271,8 @@ OLDDECLARG(krb5_kdc_rep **, ret_as_reply) /* XXX issue warning if as_reply->enc_part2->key_exp is nearby */ /* fill in the credentials */ - if (retval = krb5_copy_keyblock_contents(as_reply->enc_part2->session, + if (retval = krb5_copy_keyblock_contents(context, + as_reply->enc_part2->session, &creds->keyblock)) goto cleanup; creds->keyblock.etype = as_reply->ticket->enc_part.etype; @@ -285,7 +281,7 @@ OLDDECLARG(krb5_kdc_rep **, ret_as_reply) creds->is_skey = FALSE; /* this is an AS_REQ, so cannot be encrypted in skey */ creds->ticket_flags = as_reply->enc_part2->flags; - if (retval = krb5_copy_addresses(as_reply->enc_part2->caddrs, + if (retval = krb5_copy_addresses(context, as_reply->enc_part2->caddrs, &creds->addresses)) goto cred_cleanup; @@ -299,7 +295,7 @@ OLDDECLARG(krb5_kdc_rep **, ret_as_reply) krb5_xfree(packet); /* store it in the ccache! */ - if (retval = krb5_cc_store_cred(ccache, creds)) + if (retval = krb5_cc_store_cred(context, ccache, creds)) goto cred_cleanup; if (ret_as_reply) { @@ -311,15 +307,15 @@ OLDDECLARG(krb5_kdc_rep **, ret_as_reply) cleanup: if (as_reply) - krb5_free_kdc_rep(as_reply); + krb5_free_kdc_rep(context, as_reply); if (reply.data) free(reply.data); if (decrypt_key) - krb5_free_keyblock(decrypt_key); + krb5_free_keyblock(context, decrypt_key); if (request.padata) free(request.padata); if (!addrs) - krb5_free_addresses(request.addresses); + krb5_free_addresses(context, request.addresses); return retval; /* @@ -338,7 +334,7 @@ cred_cleanup: creds->ticket.data = 0; } if (creds->addresses) { - krb5_free_addresses(creds->addresses); + krb5_free_addresses(context, creds->addresses); creds->addresses = 0; } goto cleanup; diff --git a/src/lib/krb5/krb/in_tkt_pwd.c b/src/lib/krb5/krb/in_tkt_pwd.c index 6d636d5c6..2258f89ce 100644 --- a/src/lib/krb5/krb/in_tkt_pwd.c +++ b/src/lib/krb5/krb/in_tkt_pwd.c @@ -42,14 +42,12 @@ extern char *krb5_default_pwd_prompt1; #include static krb5_error_code -pwd_keyproc(DECLARG(const krb5_keytype, type), - DECLARG(krb5_keyblock **, key), - DECLARG(krb5_const_pointer, keyseed), - DECLARG(krb5_pa_data **,padata)) -OLDDECLARG(const krb5_keytype, type) -OLDDECLARG(krb5_keyblock **, key) -OLDDECLARG(krb5_const_pointer, keyseed) -OLDDECLARG(krb5_pa_data **,padata) +pwd_keyproc(context, type, key, keyseed, padata) + krb5_context context; + const krb5_keytype type; + krb5_keyblock ** key; + krb5_const_pointer keyseed; + krb5_pa_data ** padata; #include { krb5_data salt; @@ -64,7 +62,7 @@ OLDDECLARG(krb5_pa_data **,padata) if (!valid_keytype(type)) return KRB5_PROG_KEYTYPE_NOSUPP; - krb5_use_keytype(&eblock, type); + krb5_use_keytype(context, &eblock, type); if (padata) { krb5_pa_data **ptr; @@ -84,13 +82,13 @@ OLDDECLARG(krb5_pa_data **,padata) arg = (const struct pwd_keyproc_arg *)keyseed; if (!use_salt) { /* need to use flattened principal */ - if (retval = krb5_principal2salt(arg->who, &salt)) + if (retval = krb5_principal2salt(context, arg->who, &salt)) return(retval); f_salt = 1; } if (!arg->password.length) { - if (retval = krb5_read_password(krb5_default_pwd_prompt1, + if (retval = krb5_read_password(context, krb5_default_pwd_prompt1, 0, pwdbuf, &pwsize)) { if (f_salt) krb5_xfree(salt.data); @@ -106,7 +104,7 @@ OLDDECLARG(krb5_pa_data **,padata) if (f_salt) krb5_xfree(salt.data); return ENOMEM; } - retval = krb5_string_to_key(&eblock, type, *key, &arg->password, &salt); + retval = krb5_string_to_key(context, &eblock, type, *key, &arg->password, &salt); if (retval) { krb5_xfree(*key); if (f_salt) krb5_xfree(salt.data); @@ -137,24 +135,18 @@ OLDDECLARG(krb5_pa_data **,padata) returns system errors, encryption errors */ krb5_error_code -krb5_get_in_tkt_with_password(DECLARG(const krb5_flags, options), - DECLARG(krb5_address * const *, addrs), - DECLARG(const krb5_preauthtype, pre_auth_type), - DECLARG(const krb5_enctype, etype), - DECLARG(const krb5_keytype, keytype), - DECLARG(const char *, password), - DECLARG(krb5_ccache, ccache), - DECLARG(krb5_creds *, creds), - DECLARG(krb5_kdc_rep **, ret_as_reply)) -OLDDECLARG(const krb5_flags, options) -OLDDECLARG(krb5_address * const *, addrs) -OLDDECLARG(const krb5_preauthtype, pre_auth_type) -OLDDECLARG(const krb5_enctype, etype) -OLDDECLARG(const krb5_keytype, keytype) -OLDDECLARG(const char *, password) -OLDDECLARG(krb5_ccache, ccache) -OLDDECLARG(krb5_creds *, creds) -OLDDECLARG(krb5_kdc_rep **, ret_as_reply) +krb5_get_in_tkt_with_password(context, options, addrs, pre_auth_type, etype, + keytype, password, ccache, creds, ret_as_reply) + krb5_context context; + const krb5_flags options; + krb5_address * const * addrs; + const krb5_preauthtype pre_auth_type; + const krb5_enctype etype; + const krb5_keytype keytype; + const char * password; + krb5_ccache ccache; + krb5_creds * creds; + krb5_kdc_rep ** ret_as_reply; { krb5_error_code retval; struct pwd_keyproc_arg keyseed; @@ -167,7 +159,7 @@ OLDDECLARG(krb5_kdc_rep **, ret_as_reply) keyseed.password.length = 0; keyseed.who = creds->client; - retval = krb5_get_in_tkt(options, addrs, pre_auth_type, etype, + retval = krb5_get_in_tkt(context, options, addrs, pre_auth_type, etype, keytype, pwd_keyproc, (krb5_pointer) &keyseed, krb5_kdc_rep_decrypt_proc, 0, creds, ccache, ret_as_reply); diff --git a/src/lib/krb5/krb/in_tkt_sky.c b/src/lib/krb5/krb/in_tkt_sky.c index daae3774e..26b194723 100644 --- a/src/lib/krb5/krb/in_tkt_sky.c +++ b/src/lib/krb5/krb/in_tkt_sky.c @@ -42,14 +42,12 @@ struct skey_keyproc_arg { */ #include static krb5_error_code -skey_keyproc(DECLARG(const krb5_keytype, type), - DECLARG(krb5_keyblock **, key), - DECLARG(krb5_const_pointer, keyseed), - DECLARG(krb5_pa_data **, padata)) -OLDDECLARG(const krb5_keytype, type) -OLDDECLARG(krb5_keyblock **, key) -OLDDECLARG(krb5_const_pointer, keyseed) -OLDDECLARG(krb5_pa_data **,padata) +skey_keyproc(context, type, key, keyseed, padata) + krb5_context context; + const krb5_keytype type; + krb5_keyblock ** key; + krb5_const_pointer keyseed; + krb5_pa_data ** padata; #include { krb5_keyblock *realkey; @@ -66,26 +64,26 @@ OLDDECLARG(krb5_pa_data **,padata) if (arg->client) { /* do keytab stuff */ /* else we need to fetch from system key place */ - if (retval = krb5_kt_default(&kt_id)) + if (retval = krb5_kt_default(context, &kt_id)) return retval; - if (retval = krb5_kt_get_entry(kt_id, arg->client, + if (retval = krb5_kt_get_entry(context, kt_id, arg->client, 0, /* don't have vno available */ &kt_ent)) return retval; } -#define cleanup() {if (arg->client) (void) krb5_kt_free_entry(&kt_ent);} +#define cleanup() {if (arg->client) (void) krb5_kt_free_entry(context, &kt_ent);} if (arg->key) - retval = krb5_copy_keyblock(arg->key, &realkey); + retval = krb5_copy_keyblock(context, arg->key, &realkey); else - retval = krb5_copy_keyblock(&kt_ent.key, &realkey); + retval = krb5_copy_keyblock(context, &kt_ent.key, &realkey); if (retval) { cleanup(); return retval; } if (realkey->keytype != type) { - krb5_free_keyblock(realkey); + krb5_free_keyblock(context, realkey); cleanup(); return KRB5_PROG_ETYPE_NOSUPP; } @@ -118,22 +116,17 @@ OLDDECLARG(krb5_pa_data **,padata) */ krb5_error_code -krb5_get_in_tkt_with_skey(DECLARG(const krb5_flags, options), - DECLARG(krb5_address * const *, addrs), - DECLARG(const krb5_preauthtype, pre_auth_type), - DECLARG(const krb5_enctype, etype), - DECLARG(const krb5_keyblock *,key), - DECLARG(krb5_ccache, ccache), - DECLARG(krb5_creds *,creds), - DECLARG(krb5_kdc_rep **, ret_as_reply)) -OLDDECLARG(const krb5_flags, options) -OLDDECLARG(krb5_address * const *, addrs) -OLDDECLARG(const krb5_preauthtype, pre_auth_type) -OLDDECLARG(const krb5_enctype, etype) -OLDDECLARG(const krb5_keyblock *,key) -OLDDECLARG(krb5_ccache, ccache) -OLDDECLARG(krb5_creds *, creds) -OLDDECLARG(krb5_kdc_rep **, ret_as_reply) +krb5_get_in_tkt_with_skey(context, options, addrs, pre_auth_type, etype, + key, ccache, creds, ret_as_reply) + krb5_context context; + const krb5_flags options; + krb5_address * const * addrs; + const krb5_preauthtype pre_auth_type; + const krb5_enctype etype; + const krb5_keyblock * key; + krb5_ccache ccache; + krb5_creds * creds; + krb5_kdc_rep ** ret_as_reply; { struct skey_keyproc_arg arg; @@ -151,8 +144,8 @@ OLDDECLARG(krb5_kdc_rep **, ret_as_reply) keytype = krb5_csarray[etype]->system->proto_keytype; } - return (krb5_get_in_tkt(options, addrs, pre_auth_type, etype, keytype, - skey_keyproc, (krb5_pointer) &arg, + return (krb5_get_in_tkt(context, options, addrs, pre_auth_type, etype, + keytype, skey_keyproc, (krb5_pointer) &arg, krb5_kdc_rep_decrypt_proc, 0, creds, ccache, ret_as_reply)); } diff --git a/src/lib/krb5/krb/int-proto.h b/src/lib/krb5/krb/int-proto.h index d05fc239c..9a264a3df 100644 --- a/src/lib/krb5/krb/int-proto.h +++ b/src/lib/krb5/krb/int-proto.h @@ -31,11 +31,13 @@ #include krb5_error_code krb5_tgtname - PROTOTYPE((const krb5_data *, + PROTOTYPE((krb5_context context, + const krb5_data *, const krb5_data *, krb5_principal *)); krb5_error_code krb5_get_cred_via_tgt - PROTOTYPE((krb5_creds *, + PROTOTYPE((krb5_context context, + krb5_creds *, const krb5_flags, const krb5_enctype, const krb5_cksumtype, diff --git a/src/lib/krb5/krb/kdc_rep_dc.c b/src/lib/krb5/krb/kdc_rep_dc.c index ed2209249..569e08821 100644 --- a/src/lib/krb5/krb/kdc_rep_dc.c +++ b/src/lib/krb5/krb/kdc_rep_dc.c @@ -37,12 +37,11 @@ /*ARGSUSED*/ krb5_error_code -krb5_kdc_rep_decrypt_proc(DECLARG(const krb5_keyblock *, key), - DECLARG(krb5_const_pointer, decryptarg), - DECLARG(krb5_kdc_rep *, dec_rep)) -OLDDECLARG(const krb5_keyblock *, key) -OLDDECLARG(krb5_const_pointer, decryptarg) -OLDDECLARG(krb5_kdc_rep *, dec_rep) +krb5_kdc_rep_decrypt_proc(context, key, decryptarg, dec_rep) + krb5_context context; + const krb5_keyblock * key; + krb5_const_pointer decryptarg; + krb5_kdc_rep * dec_rep; { krb5_error_code retval; krb5_encrypt_block eblock; @@ -61,25 +60,25 @@ OLDDECLARG(krb5_kdc_rep *, dec_rep) /* put together an eblock for this encryption */ - krb5_use_cstype(&eblock, dec_rep->enc_part.etype); + krb5_use_cstype(context, &eblock, dec_rep->enc_part.etype); /* do any necessary key pre-processing */ - if (retval = krb5_process_key(&eblock, key)) { + if (retval = krb5_process_key(context, &eblock, key)) { free(scratch.data); return(retval); } /* call the decryption routine */ - if (retval = krb5_decrypt((krb5_pointer) dec_rep->enc_part.ciphertext.data, + if (retval = krb5_decrypt(context, (krb5_pointer) dec_rep->enc_part.ciphertext.data, (krb5_pointer) scratch.data, scratch.length, &eblock, 0)) { - (void) krb5_finish_key(&eblock); + (void) krb5_finish_key(context, &eblock); free(scratch.data); return retval; } #define clean_scratch() {memset(scratch.data, 0, scratch.length); \ free(scratch.data);} - if (retval = krb5_finish_key(&eblock)) { + if (retval = krb5_finish_key(context, &eblock)) { clean_scratch(); return retval; } diff --git a/src/lib/krb5/krb/mk_cred.c b/src/lib/krb5/krb/mk_cred.c index d50cd8c59..3e08defff 100644 --- a/src/lib/krb5/krb/mk_cred.c +++ b/src/lib/krb5/krb/mk_cred.c @@ -35,13 +35,14 @@ /* Create asn.1 encoded KRB-CRED message from the kdc reply. */ krb5_error_code -krb5_mk_cred(dec_rep, etype, key, sender_addr, recv_addr, outbuf) -krb5_kdc_rep *dec_rep; -krb5_enctype etype; -krb5_keyblock *key; -krb5_address *sender_addr; -krb5_address *recv_addr; -krb5_data *outbuf; +krb5_mk_cred(context, dec_rep, etype, key, sender_addr, recv_addr, outbuf) + krb5_context context; + krb5_kdc_rep *dec_rep; + krb5_enctype etype; + krb5_keyblock *key; + krb5_address *sender_addr; + krb5_address *recv_addr; + krb5_data *outbuf; { krb5_error_code retval; krb5_encrypt_block eblock; @@ -64,19 +65,19 @@ krb5_data *outbuf; cred_enc_part.ticket_info = (krb5_cred_info **) calloc(2, sizeof(*cred_enc_part.ticket_info)); if (!cred_enc_part.ticket_info) { - krb5_free_tickets(ret_cred.tickets); + krb5_free_tickets(context, ret_cred.tickets); return ENOMEM; } cred_enc_part.ticket_info[0] = (krb5_cred_info *) malloc(sizeof(*cred_enc_part.ticket_info[0])); if (!cred_enc_part.ticket_info[0]) { - krb5_free_tickets(ret_cred.tickets); - krb5_free_cred_enc_part(cred_enc_part); + krb5_free_tickets(context, ret_cred.tickets); + krb5_free_cred_enc_part(context, cred_enc_part); return ENOMEM; } cred_enc_part.nonce = 0; - if (retval = krb5_us_timeofday(&cred_enc_part.timestamp, + if (retval = krb5_us_timeofday(context, &cred_enc_part.timestamp, &cred_enc_part.usec)) return retval; @@ -97,11 +98,11 @@ krb5_data *outbuf; if (retval = encode_krb5_enc_cred_part(&cred_enc_part, &scratch)) return retval; -#define cleanup_scratch() { (void) memset(scratch->data, 0, scratch->length); krb5_free_data(scratch); } +#define cleanup_scratch() { (void) memset(scratch->data, 0, scratch->length); krb5_free_data(context, scratch); } /* put together an eblock for this encryption */ - krb5_use_cstype(&eblock, etype); + krb5_use_cstype(context, &eblock, etype); ret_cred.enc_part.ciphertext.length = krb5_encrypt_size(scratch->length, eblock.crypto_entry); /* add padding area, and zero it */ @@ -127,14 +128,14 @@ krb5_data *outbuf; ret_cred.enc_part.ciphertext.data = 0;} /* do any necessary key pre-processing */ - if (retval = krb5_process_key(&eblock, key)) { + if (retval = krb5_process_key(context, &eblock, key)) { goto clean_encpart; } -#define cleanup_prockey() {(void) krb5_finish_key(&eblock);} +#define cleanup_prockey() {(void) krb5_finish_key(context, &eblock);} /* call the encryption routine */ - if (retval = krb5_encrypt((krb5_pointer) scratch->data, + if (retval = krb5_encrypt(context, (krb5_pointer) scratch->data, (krb5_pointer) ret_cred.enc_part.ciphertext.data, scratch->length, &eblock, @@ -145,7 +146,7 @@ krb5_data *outbuf; /* private message is now assembled-- do some cleanup */ cleanup_scratch(); - if (retval = krb5_finish_key(&eblock)) { + if (retval = krb5_finish_key(context, &eblock)) { cleanup_encpart(); return retval; } diff --git a/src/lib/krb5/krb/mk_error.c b/src/lib/krb5/krb/mk_error.c index 0c27d511e..5a92a16ec 100644 --- a/src/lib/krb5/krb/mk_error.c +++ b/src/lib/krb5/krb/mk_error.c @@ -39,9 +39,10 @@ returns system errors */ krb5_error_code -krb5_mk_error(dec_err, enc_err) -const krb5_error *dec_err; -krb5_data *enc_err; +krb5_mk_error(context, dec_err, enc_err) + krb5_context context; + const krb5_error *dec_err; + krb5_data *enc_err; { krb5_error_code retval; krb5_data *new_enc_err; diff --git a/src/lib/krb5/krb/mk_priv.c b/src/lib/krb5/krb/mk_priv.c index 7b81eb493..df762b27a 100644 --- a/src/lib/krb5/krb/mk_priv.c +++ b/src/lib/krb5/krb/mk_priv.c @@ -48,26 +48,19 @@ returns system errors */ krb5_error_code -krb5_mk_priv(DECLARG(const krb5_data *, userdata), - DECLARG(const krb5_enctype, etype), - DECLARG(const krb5_keyblock *, key), - DECLARG(const krb5_address *, sender_addr), - DECLARG(const krb5_address *, recv_addr), - DECLARG(krb5_int32, seq_number), - DECLARG(krb5_int32, priv_flags), - DECLARG(krb5_rcache, rcache), - DECLARG(krb5_pointer, i_vector), - DECLARG(krb5_data *, outbuf)) -OLDDECLARG(const krb5_data *, userdata) -OLDDECLARG(const krb5_enctype, etype) -OLDDECLARG(const krb5_keyblock *, key) -OLDDECLARG(const krb5_address *, sender_addr) -OLDDECLARG(const krb5_address *, recv_addr) -OLDDECLARG(krb5_int32, seq_number) -OLDDECLARG(krb5_int32, priv_flags) -OLDDECLARG(krb5_rcache, rcache) -OLDDECLARG(krb5_pointer, i_vector) -OLDDECLARG(krb5_data *, outbuf) +krb5_mk_priv(context, userdata, etype, key, sender_addr, recv_addr, + seq_number, priv_flags, rcache, i_vector, outbuf) + krb5_context context; + const krb5_data * userdata; + const krb5_enctype etype; + const krb5_keyblock * key; + const krb5_address * sender_addr; + const krb5_address * recv_addr; + krb5_int32 seq_number; + krb5_int32 priv_flags; + krb5_rcache rcache; + krb5_pointer i_vector; + krb5_data * outbuf; { krb5_error_code retval; krb5_encrypt_block eblock; @@ -91,7 +84,7 @@ OLDDECLARG(krb5_data *, outbuf) if (!rcache) /* gotta provide an rcache in this case... */ return KRB5_RC_REQUIRED; - if (retval = krb5_us_timeofday(&privmsg_enc_part.timestamp, + if (retval = krb5_us_timeofday(context, &privmsg_enc_part.timestamp, &privmsg_enc_part.usec)) return retval; } else @@ -106,11 +99,11 @@ OLDDECLARG(krb5_data *, outbuf) if (retval = encode_krb5_enc_priv_part(&privmsg_enc_part, &scratch)) return retval; -#define cleanup_scratch() { (void) memset(scratch->data, 0, scratch->length); krb5_free_data(scratch); } +#define cleanup_scratch() { (void) memset(scratch->data, 0, scratch->length); krb5_free_data(context, scratch); } /* put together an eblock for this encryption */ - krb5_use_cstype(&eblock, etype); + krb5_use_cstype(context, &eblock, etype); privmsg.enc_part.ciphertext.length = krb5_encrypt_size(scratch->length, eblock.crypto_entry); /* add padding area, and zero it */ @@ -136,14 +129,14 @@ OLDDECLARG(krb5_data *, outbuf) privmsg.enc_part.ciphertext.data = 0;} /* do any necessary key pre-processing */ - if (retval = krb5_process_key(&eblock, key)) { + if (retval = krb5_process_key(context, &eblock, key)) { goto clean_encpart; } -#define cleanup_prockey() {(void) krb5_finish_key(&eblock);} +#define cleanup_prockey() {(void) krb5_finish_key(context, &eblock);} /* call the encryption routine */ - if (retval = krb5_encrypt((krb5_pointer) scratch->data, + if (retval = krb5_encrypt(context, (krb5_pointer) scratch->data, (krb5_pointer) privmsg.enc_part.ciphertext.data, scratch->length, &eblock, i_vector)) { @@ -162,7 +155,7 @@ OLDDECLARG(krb5_data *, outbuf) /* private message is now assembled-- do some cleanup */ cleanup_scratch(); - if (retval = krb5_finish_key(&eblock)) { + if (retval = krb5_finish_key(context, &eblock)) { cleanup_encpart(); return retval; } @@ -176,7 +169,7 @@ OLDDECLARG(krb5_data *, outbuf) if (!(priv_flags & KRB5_PRIV_NOTIME)) { krb5_donot_replay replay; - if (retval = krb5_gen_replay_name(sender_addr, "_priv", + if (retval = krb5_gen_replay_name(context, sender_addr, "_priv", &replay.client)) { cleanup_scratch(); return retval; @@ -185,7 +178,7 @@ OLDDECLARG(krb5_data *, outbuf) replay.server = ""; /* XXX */ replay.cusec = privmsg_enc_part.usec; replay.ctime = privmsg_enc_part.timestamp; - if (retval = krb5_rc_store(rcache, &replay)) { + if (retval = krb5_rc_store(context, rcache, &replay)) { /* should we really error out here? XXX */ cleanup_scratch(); krb5_xfree(replay.client); diff --git a/src/lib/krb5/krb/mk_rep.c b/src/lib/krb5/krb/mk_rep.c index a07b86494..504d9ca49 100644 --- a/src/lib/krb5/krb/mk_rep.c +++ b/src/lib/krb5/krb/mk_rep.c @@ -46,10 +46,11 @@ */ krb5_error_code -krb5_mk_rep(repl, kblock, outbuf) -const krb5_ap_rep_enc_part *repl; -const krb5_keyblock *kblock; -krb5_data *outbuf; +krb5_mk_rep(context, repl, kblock, outbuf) + krb5_context context; + const krb5_ap_rep_enc_part *repl; + const krb5_keyblock *kblock; + krb5_data *outbuf; { krb5_error_code retval; krb5_data *scratch; @@ -72,11 +73,11 @@ krb5_data *outbuf; return retval; #define cleanup_scratch() { (void) memset(scratch->data, 0, scratch->length); \ -krb5_free_data(scratch); } +krb5_free_data(context, scratch); } /* put together an eblock for this encryption */ - krb5_use_cstype(&eblock, etype); + krb5_use_cstype(context, &eblock, etype); reply.enc_part.etype = etype; reply.enc_part.kvno = 0; /* XXX user set? */ @@ -104,14 +105,14 @@ free(reply.enc_part.ciphertext.data); \ reply.enc_part.ciphertext.length = 0; reply.enc_part.ciphertext.data = 0;} /* do any necessary key pre-processing */ - if (retval = krb5_process_key(&eblock, kblock)) { + if (retval = krb5_process_key(context, &eblock, kblock)) { goto clean_encpart; } -#define cleanup_prockey() {(void) krb5_finish_key(&eblock);} +#define cleanup_prockey() {(void) krb5_finish_key(context, &eblock);} /* call the encryption routine */ - if (retval = krb5_encrypt((krb5_pointer) scratch->data, + if (retval = krb5_encrypt(context, (krb5_pointer) scratch->data, (krb5_pointer) reply.enc_part.ciphertext.data, scratch->length, &eblock, 0)) { goto clean_prockey; @@ -120,7 +121,7 @@ reply.enc_part.ciphertext.length = 0; reply.enc_part.ciphertext.data = 0;} /* encrypted part now assembled-- do some cleanup */ cleanup_scratch(); - if (retval = krb5_finish_key(&eblock)) { + if (retval = krb5_finish_key(context, &eblock)) { cleanup_encpart(); return retval; } diff --git a/src/lib/krb5/krb/mk_req.c b/src/lib/krb5/krb/mk_req.c index 84a623342..c99aa463b 100644 --- a/src/lib/krb5/krb/mk_req.c +++ b/src/lib/krb5/krb/mk_req.c @@ -51,12 +51,13 @@ extern krb5_flags krb5_kdc_default_options; krb5_error_code -krb5_mk_req(server, ap_req_options, checksum, ccache, outbuf) -krb5_const_principal server; -const krb5_flags ap_req_options; -const krb5_checksum *checksum; -krb5_ccache ccache; -krb5_data *outbuf; +krb5_mk_req(context, server, ap_req_options, checksum, ccache, outbuf) + krb5_context context; + krb5_const_principal server; + const krb5_flags ap_req_options; + const krb5_checksum *checksum; + krb5_ccache ccache; + krb5_data *outbuf; { krb5_error_code retval; krb5_creds creds; @@ -64,9 +65,9 @@ krb5_data *outbuf; /* obtain ticket & session key */ memset((char *)&creds, 0, sizeof(creds)); - if (retval = krb5_copy_principal(server, &creds.server)) + if (retval = krb5_copy_principal(context, server, &creds.server)) goto errout; - if (retval = krb5_cc_get_principal(ccache, &creds.client)) + if (retval = krb5_cc_get_principal(context, ccache, &creds.client)) goto errout; /* creds.times.endtime = 0; -- memset 0 takes care of this zero means "as long as possible" */ @@ -74,12 +75,12 @@ krb5_data *outbuf; zero means no session keytype preference */ - if (retval = krb5_get_credentials(krb5_kdc_default_options, + if (retval = krb5_get_credentials(context, krb5_kdc_default_options, ccache, &creds)) goto errout; - retval = krb5_mk_req_extended(ap_req_options, + retval = krb5_mk_req_extended(context, ap_req_options, checksum, krb5_kdc_default_options, 0, /* no sequence number */ @@ -90,6 +91,6 @@ krb5_data *outbuf; outbuf); errout: - krb5_free_cred_contents(&creds); + krb5_free_cred_contents(context, &creds); return retval; } diff --git a/src/lib/krb5/krb/mk_req_ext.c b/src/lib/krb5/krb/mk_req_ext.c index d5639741f..585ebde20 100644 --- a/src/lib/krb5/krb/mk_req_ext.c +++ b/src/lib/krb5/krb/mk_req_ext.c @@ -67,22 +67,24 @@ */ static krb5_error_code -krb5_generate_authenticator PROTOTYPE(( krb5_authenticator *, krb5_principal, +krb5_generate_authenticator PROTOTYPE((krb5_context, + krb5_authenticator *, krb5_principal, const krb5_checksum *, krb5_keyblock *, krb5_int32, krb5_authdata ** )); krb5_error_code -krb5_mk_req_extended(ap_req_options, checksum, kdc_options, +krb5_mk_req_extended(context, ap_req_options, checksum, kdc_options, sequence, newkey, ccache, creds, authentp, outbuf) -const krb5_flags ap_req_options; -const krb5_checksum *checksum; -const krb5_flags kdc_options; -krb5_int32 sequence; -krb5_keyblock **newkey; -krb5_ccache ccache; -krb5_creds *creds; -krb5_authenticator *authentp; -krb5_data *outbuf; + krb5_context context; + const krb5_flags ap_req_options; + const krb5_checksum *checksum; + const krb5_flags kdc_options; + krb5_int32 sequence; + krb5_keyblock **newkey; + krb5_ccache ccache; + krb5_creds *creds; + krb5_authenticator *authentp; + krb5_data *outbuf; { krb5_error_code retval; krb5_ap_req request; @@ -105,7 +107,7 @@ krb5_data *outbuf; if (!creds->ticket.length) { /* go get creds */ - if (retval = krb5_get_credentials(kdc_options, + if (retval = krb5_get_credentials(context, kdc_options, ccache, creds)) return(retval); @@ -125,11 +127,11 @@ krb5_data *outbuf; request.ap_options = ap_req_options; if (newkey) { - if (retval = krb5_generate_subkey(&creds->keyblock, newkey)) + if (retval = krb5_generate_subkey(context, &creds->keyblock, newkey)) goto cleanup; } - if (retval = krb5_generate_authenticator(&authent, creds->client, checksum, + if (retval = krb5_generate_authenticator(context, &authent, creds->client, checksum, newkey ? *newkey : 0, sequence, creds->authdata)) goto cleanup; @@ -148,11 +150,11 @@ krb5_data *outbuf; if (authentp) *authentp = authent; else - krb5_free_authenticator_contents(&authent); + krb5_free_authenticator_contents(context, &authent); /* put together an eblock for this encryption */ - krb5_use_cstype(&eblock, etype); + krb5_use_cstype(context, &eblock, etype); request.authenticator.etype = etype; request.authenticator.kvno = 0; request.authenticator.ciphertext.length = @@ -173,18 +175,18 @@ krb5_data *outbuf; } /* do any necessary key pre-processing */ - if (retval = krb5_process_key(&eblock, &creds->keyblock)) + if (retval = krb5_process_key(context, &eblock, &creds->keyblock)) goto cleanup; cleanup_key++; /* call the encryption routine */ - if (retval = krb5_encrypt((krb5_pointer) scratch->data, + if (retval = krb5_encrypt(context, (krb5_pointer) scratch->data, (krb5_pointer) request.authenticator.ciphertext.data, scratch->length, &eblock, 0)) goto cleanup; - if (retval = krb5_finish_key(&eblock)) + if (retval = krb5_finish_key(context, &eblock)) goto cleanup; cleanup_key = 0; @@ -197,40 +199,41 @@ krb5_data *outbuf; cleanup: if (request.ticket) - krb5_free_ticket(request.ticket); + krb5_free_ticket(context, request.ticket); if (request.authenticator.ciphertext.data) { (void) memset(request.authenticator.ciphertext.data, 0, request.authenticator.ciphertext.length); free(request.authenticator.ciphertext.data); } if (newkey && *newkey) - krb5_free_keyblock(*newkey); + krb5_free_keyblock(context, *newkey); if (scratch) { memset(scratch->data, 0, scratch->length); krb5_xfree(scratch->data); krb5_xfree(scratch); } if (cleanup_key) - krb5_finish_key(&eblock); + krb5_finish_key(context, &eblock); return retval; } static krb5_error_code -krb5_generate_authenticator(authent, client, cksum, key, seq_number, authorization) -krb5_authenticator *authent; -krb5_principal client; -const krb5_checksum *cksum; -krb5_keyblock *key; -krb5_int32 seq_number; -krb5_authdata **authorization; +krb5_generate_authenticator(context, authent, client, cksum, key, seq_number, authorization) + krb5_context context; + krb5_authenticator *authent; + krb5_principal client; + const krb5_checksum *cksum; + krb5_keyblock *key; + krb5_int32 seq_number; + krb5_authdata **authorization; { krb5_error_code retval; authent->client = client; authent->checksum = (krb5_checksum *)cksum; if (key) { - retval = krb5_copy_keyblock(key, &authent->subkey); + retval = krb5_copy_keyblock(context, key, &authent->subkey); if (retval) return retval; } else @@ -239,5 +242,5 @@ krb5_authdata **authorization; authent->seq_number = seq_number; authent->authorization_data = authorization; - return(krb5_us_timeofday(&authent->ctime, &authent->cusec)); + return(krb5_us_timeofday(context, &authent->ctime, &authent->cusec)); } diff --git a/src/lib/krb5/krb/mk_safe.c b/src/lib/krb5/krb/mk_safe.c index f692d4332..e50d92477 100644 --- a/src/lib/krb5/krb/mk_safe.c +++ b/src/lib/krb5/krb/mk_safe.c @@ -46,24 +46,18 @@ returns system errors */ krb5_error_code -krb5_mk_safe(DECLARG(const krb5_data *, userdata), - DECLARG(const krb5_cksumtype, sumtype), - DECLARG(const krb5_keyblock *, key), - DECLARG(const krb5_address *, sender_addr), - DECLARG(const krb5_address *, recv_addr), - DECLARG(krb5_int32, seq_number), - DECLARG(krb5_int32, safe_flags), - DECLARG(krb5_rcache, rcache), - DECLARG(krb5_data *, outbuf)) -OLDDECLARG(const krb5_data *, userdata) -OLDDECLARG(const krb5_cksumtype, sumtype) -OLDDECLARG(const krb5_keyblock *, key) -OLDDECLARG(const krb5_address *, sender_addr) -OLDDECLARG(const krb5_address *, recv_addr) -OLDDECLARG(krb5_int32, seq_number) -OLDDECLARG(krb5_int32, safe_flags) -OLDDECLARG(krb5_rcache, rcache) -OLDDECLARG(krb5_data *, outbuf) +krb5_mk_safe(context, userdata, sumtype, key, sender_addr, recv_addr, + seq_number, safe_flags, rcache, outbuf) + krb5_context context; + const krb5_data * userdata; + const krb5_cksumtype sumtype; + const krb5_keyblock * key; + const krb5_address * sender_addr; + const krb5_address * recv_addr; + krb5_int32 seq_number; + krb5_int32 safe_flags; + krb5_rcache rcache; + krb5_data * outbuf; { krb5_error_code retval; krb5_safe safemsg; @@ -87,7 +81,7 @@ OLDDECLARG(krb5_data *, outbuf) if (!rcache) /* gotta provide an rcache in this case... */ return KRB5_RC_REQUIRED; - if (retval = krb5_us_timeofday(&safemsg.timestamp, &safemsg.usec)) + if (retval = krb5_us_timeofday(context, &safemsg.timestamp, &safemsg.usec)) return retval; } else safemsg.timestamp = 0, safemsg.usec = 0; @@ -112,14 +106,14 @@ OLDDECLARG(krb5_data *, outbuf) #define clean_scratch() {(void) memset((char *)scratch->data, 0,\ scratch->length); \ - krb5_free_data(scratch);} + krb5_free_data(context, scratch);} if (!(safe_checksum.contents = - (krb5_octet *) malloc(krb5_checksum_size(sumtype)))) { + (krb5_octet *) malloc(krb5_checksum_size(context, sumtype)))) { clean_scratch(); return ENOMEM; } - if (retval = krb5_calculate_checksum(sumtype, scratch->data, + if (retval = krb5_calculate_checksum(context, sumtype, scratch->data, scratch->length, (krb5_pointer) key->contents, key->length, &safe_checksum)) { @@ -137,7 +131,7 @@ OLDDECLARG(krb5_data *, outbuf) if (!(safe_flags & KRB5_SAFE_NOTIME)) { krb5_donot_replay replay; - if (retval = krb5_gen_replay_name(sender_addr, "_safe", + if (retval = krb5_gen_replay_name(context, sender_addr, "_safe", &replay.client)) { clean_scratch(); return retval; @@ -146,7 +140,7 @@ OLDDECLARG(krb5_data *, outbuf) replay.server = ""; /* XXX */ replay.cusec = safemsg.usec; replay.ctime = safemsg.timestamp; - if (retval = krb5_rc_store(rcache, &replay)) { + if (retval = krb5_rc_store(context, rcache, &replay)) { /* should we really error out here? XXX */ clean_scratch(); krb5_xfree(replay.client); diff --git a/src/lib/krb5/krb/parse.c b/src/lib/krb5/krb/parse.c index 3e5edfd6f..fe051ae68 100644 --- a/src/lib/krb5/krb/parse.c +++ b/src/lib/krb5/krb/parse.c @@ -65,7 +65,8 @@ * that arbitrarily large multi-component names are a Good Thing..... */ krb5_error_code -krb5_parse_name(name, nprincipal) +krb5_parse_name(context, name, nprincipal) + krb5_context context; const char *name; krb5_principal *nprincipal; { @@ -149,7 +150,7 @@ krb5_parse_name(name, nprincipal) */ if (!parsed_realm) { if (!default_realm) { - retval = krb5_get_default_realm(&default_realm); + retval = krb5_get_default_realm(context, &default_realm); if (retval) { krb5_xfree(principal->data); krb5_xfree((char *)principal); @@ -157,7 +158,7 @@ krb5_parse_name(name, nprincipal) } default_realm_size = strlen(default_realm); } - krb5_princ_realm(principal)->length = default_realm_size; + krb5_princ_realm(context, principal)->length = default_realm_size; realmsize = default_realm_size; } /* @@ -174,20 +175,20 @@ krb5_parse_name(name, nprincipal) cp++; size++; } else if (c == COMPONENT_SEP) { - krb5_princ_component(principal, i)->length = size; + krb5_princ_component(context, principal, i)->length = size; size = 0; i++; } else if (c == REALM_SEP) { - krb5_princ_component(principal, i)->length = size; + krb5_princ_component(context, principal, i)->length = size; size = 0; parsed_realm = cp+1; } else size++; } if (parsed_realm) - krb5_princ_realm(principal)->length = size; + krb5_princ_realm(context, principal)->length = size; else - krb5_princ_component(principal, i)->length = size; + krb5_princ_component(context, principal, i)->length = size; if (i + 1 != components) { fprintf(stderr, "Programming error in krb5_parse_name!"); @@ -200,8 +201,8 @@ krb5_parse_name(name, nprincipal) * principal structure */ for (i=0; i < components; i++) - krb5_princ_component(principal, i)->length = fcompsize[i]; - krb5_princ_realm(principal)->length = realmsize; + krb5_princ_component(context, principal, i)->length = fcompsize[i]; + krb5_princ_realm(context, principal)->length = realmsize; } /* * Now, we need to allocate the space for the strings themselves..... @@ -212,19 +213,19 @@ krb5_parse_name(name, nprincipal) krb5_xfree(principal); return ENOMEM; } - krb5_princ_set_realm_data(principal, tmpdata); + krb5_princ_set_realm_data(context, principal, tmpdata); for (i=0; i < components; i++) { char *tmpdata = - malloc(krb5_princ_component(principal, i)->length + 1); + malloc(krb5_princ_component(context, principal, i)->length + 1); if (!tmpdata) { for (i--; i >= 0; i--) - krb5_xfree(krb5_princ_component(principal, i)->data); - krb5_xfree(krb5_princ_realm(principal)->data); + krb5_xfree(krb5_princ_component(context, principal, i)->data); + krb5_xfree(krb5_princ_realm(context, principal)->data); krb5_xfree(principal->data); krb5_xfree(principal); return(ENOMEM); } - krb5_princ_component(principal, i)->data = tmpdata; + krb5_princ_component(context, principal, i)->data = tmpdata; } /* @@ -232,7 +233,7 @@ krb5_parse_name(name, nprincipal) * time filling in the krb5_principal structure which we just * allocated. */ - q = krb5_princ_component(principal, 0)->data; + q = krb5_princ_component(context, principal, 0)->data; for (i=0,cp = name; c = *cp; cp++) { if (c == QUOTECHAR) { cp++; @@ -256,20 +257,20 @@ krb5_parse_name(name, nprincipal) i++; *q++ = '\0'; if (c == COMPONENT_SEP) - q = krb5_princ_component(principal, i)->data; + q = krb5_princ_component(context, principal, i)->data; else - q = krb5_princ_realm(principal)->data; + q = krb5_princ_realm(context, principal)->data; } else *q++ = c; } *q++ = '\0'; if (!parsed_realm) - strcpy(krb5_princ_realm(principal)->data, default_realm); + strcpy(krb5_princ_realm(context, principal)->data, default_realm); /* * Alright, we're done. Now stuff a pointer to this monstrosity * into the return variable, and let's get out of here. */ - krb5_princ_type(principal) = KRB5_NT_PRINCIPAL; + krb5_princ_type(context, principal) = KRB5_NT_PRINCIPAL; *nprincipal = principal; return(0); } diff --git a/src/lib/krb5/krb/pr_to_salt.c b/src/lib/krb5/krb/pr_to_salt.c index a486cc911..f920621f0 100644 --- a/src/lib/krb5/krb/pr_to_salt.c +++ b/src/lib/krb5/krb/pr_to_salt.c @@ -33,10 +33,11 @@ * Convert a krb5_principal into the default salt for that principal. */ krb5_error_code -krb5_principal2salt_internal(pr, ret, use_realm) -register krb5_const_principal pr; -krb5_data *ret; -int use_realm; +krb5_principal2salt_internal(context, pr, ret, use_realm) + krb5_context context; + register krb5_const_principal pr; + krb5_data *ret; + int use_realm; { int size = 0, offset = 0; int nelem; @@ -48,43 +49,45 @@ int use_realm; return 0; } - nelem = krb5_princ_size(pr); + nelem = krb5_princ_size(context, pr); if (use_realm) - size += krb5_princ_realm(pr)->length; + size += krb5_princ_realm(context, pr)->length; for (i = 0; i < nelem; i++) - size += krb5_princ_component(pr, i)->length; + size += krb5_princ_component(context, pr, i)->length; ret->length = size; if (!(ret->data = malloc (size))) return ENOMEM; if (use_realm) { - offset = krb5_princ_realm(pr)->length; - memcpy(ret->data, krb5_princ_realm(pr)->data, offset); + offset = krb5_princ_realm(context, pr)->length; + memcpy(ret->data, krb5_princ_realm(context, pr)->data, offset); } for (i = 0; i < nelem; i++) { - memcpy(&ret->data[offset], krb5_princ_component(pr, i)->data, - krb5_princ_component(pr, i)->length); - offset += krb5_princ_component(pr, i)->length; + memcpy(&ret->data[offset], krb5_princ_component(context, pr, i)->data, + krb5_princ_component(context, pr, i)->length); + offset += krb5_princ_component(context, pr, i)->length; } return 0; } krb5_error_code -krb5_principal2salt(pr, ret) -register krb5_const_principal pr; -krb5_data *ret; +krb5_principal2salt(context, pr, ret) + krb5_context context; + register krb5_const_principal pr; + krb5_data *ret; { - return krb5_principal2salt_internal(pr, ret, 1); + return krb5_principal2salt_internal(context, pr, ret, 1); } krb5_error_code -krb5_principal2salt_norealm(pr, ret) -register krb5_const_principal pr; -krb5_data *ret; +krb5_principal2salt_norealm(context, pr, ret) + krb5_context context; + register krb5_const_principal pr; + krb5_data *ret; { - return krb5_principal2salt_internal(pr, ret, 0); + return krb5_principal2salt_internal(context, pr, ret, 0); } diff --git a/src/lib/krb5/krb/preauth.c b/src/lib/krb5/krb/preauth.c index 05badcae3..e03d24ced 100644 --- a/src/lib/krb5/krb/preauth.c +++ b/src/lib/krb5/krb/preauth.c @@ -77,7 +77,8 @@ static krb5_error_code find_preauthenticator * Note: This is a first crack at what any preauthentication will need... */ krb5_error_code -krb5_obtain_padata(type, client, src_addr, encrypt_key, ret_data) +krb5_obtain_padata(context, type, client, src_addr, encrypt_key, ret_data) + krb5_context context; int type; /*IN: Preauth type */ krb5_principal client; /*IN: requestor */ krb5_address **src_addr; /*IN: array of ptrs to addresses */ @@ -110,7 +111,7 @@ krb5_obtain_padata(type, client, src_addr, encrypt_key, ret_data) if (retval) goto error_out; - retval = (*p_system->obtain)( client, src_addr, data ); + retval = (*p_system->obtain)(context, client, src_addr, data ); if (retval) goto error_out; @@ -121,10 +122,10 @@ krb5_obtain_padata(type, client, src_addr, encrypt_key, ret_data) retval = KRB5_PREAUTH_NO_KEY; goto error_out; } - krb5_use_keytype(&eblock, encrypt_key->keytype); + krb5_use_keytype(context, &eblock, encrypt_key->keytype); /* do any necessay key pre-processing */ - retval = krb5_process_key(&eblock, encrypt_key); + retval = krb5_process_key(context, &eblock, encrypt_key); if (retval) goto error_out; @@ -137,7 +138,7 @@ krb5_obtain_padata(type, client, src_addr, encrypt_key, ret_data) eblock.crypto_entry) + 4; if(!(scratch.data = malloc(scratch.length))){ - (void) krb5_finish_key(&eblock); + (void) krb5_finish_key(context, &eblock); retval = ENOMEM; goto error_out; } @@ -148,14 +149,14 @@ krb5_obtain_padata(type, client, src_addr, encrypt_key, ret_data) scratch.data[3] = data->length; /* Encrypt preauth data in encryption key */ - if (retval = krb5_encrypt((krb5_pointer) data->contents, + if (retval = krb5_encrypt(context, (krb5_pointer) data->contents, (char *) scratch.data + 4, data->length, &eblock, 0)) { - (void) krb5_finish_key(&eblock); + (void) krb5_finish_key(context, &eblock); free(scratch.data); goto error_out; } - (void) krb5_finish_key(&eblock); + (void) krb5_finish_key(context, &eblock); free(data->contents); data->length = scratch.length; @@ -182,7 +183,8 @@ error_out: */ krb5_error_code -krb5_verify_padata(data,client,src_addr, decrypt_key, req_id, flags) +krb5_verify_padata(context, data,client,src_addr, decrypt_key, req_id, flags) + krb5_context context; krb5_pa_data *data; /*IN: padata */ krb5_principal client; /*IN: requestor */ krb5_address **src_addr; /*IN: array of ptrs to addresses */ @@ -212,7 +214,7 @@ krb5_verify_padata(data,client,src_addr, decrypt_key, req_id, flags) if (!decrypt_key) return(EINVAL); - krb5_use_keytype(&eblock, decrypt_key->keytype); + krb5_use_keytype(context, &eblock, decrypt_key->keytype); scratch.length = data->length; if (!(scratch.data = (char *)malloc(scratch.length))) { @@ -220,18 +222,18 @@ krb5_verify_padata(data,client,src_addr, decrypt_key, req_id, flags) } /* do any necessay key pre-processing */ - retval = krb5_process_key(&eblock,decrypt_key); + retval = krb5_process_key(context, &eblock,decrypt_key); if (retval) { free(scratch.data); return(retval); } /* Decrypt data */ - retval = krb5_decrypt((char *) data->contents + 4, + retval = krb5_decrypt(context, (char *) data->contents + 4, (krb5_pointer) scratch.data, scratch.length - 4, &eblock, 0); if (retval) { - (void) krb5_finish_key(&eblock); + (void) krb5_finish_key(context, &eblock); free(scratch.data); return(retval); } @@ -246,7 +248,7 @@ krb5_verify_padata(data,client,src_addr, decrypt_key, req_id, flags) scratch.length = data->length; } - retval = (*p_system->verify)(client, src_addr, &scratch); + retval = (*p_system->verify)(context, client, src_addr, &scratch); if (free_scratch) free(scratch.data); if (retval) @@ -260,10 +262,10 @@ krb5_verify_padata(data,client,src_addr, decrypt_key, req_id, flags) replay detection. */ /* MUST malloc cksum.contents */ cksum.contents = (krb5_octet *)calloc(1, - krb5_checksum_size(CKSUMTYPE_CRC32)); + krb5_checksum_size(context, CKSUMTYPE_CRC32)); if (!cksum.contents) return(1); - if (krb5_calculate_checksum(CKSUMTYPE_CRC32, + if (krb5_calculate_checksum(context, CKSUMTYPE_CRC32, data->contents, data->length, 0, /* seed is ignored */ @@ -306,7 +308,8 @@ find_preauthenticator(type, preauth) int seeded = 0 ; /* Used by srand below */ krb5_error_code -get_unixtime_padata(client, src_addr, pa_data) +get_unixtime_padata(context, client, src_addr, pa_data) + krb5_context context; krb5_principal client; krb5_address **src_addr; krb5_pa_data *pa_data; @@ -321,7 +324,7 @@ get_unixtime_padata(client, src_addr, pa_data) if (!tmp) return(ENOMEM); - retval = krb5_timeofday(&kdc_time); + retval = krb5_timeofday(context, &kdc_time); if (retval) return retval; if ( !seeded) { @@ -342,7 +345,8 @@ get_unixtime_padata(client, src_addr, pa_data) } krb5_error_code -verify_unixtime_padata(client, src_addr, data) +verify_unixtime_padata(context, client, src_addr, data) + krb5_context context; krb5_principal client; krb5_address **src_addr; krb5_data *data; @@ -361,7 +365,7 @@ verify_unixtime_padata(client, src_addr, data) patime += (int) tmp[11] << 8; patime += tmp[12]; - retval = krb5_timeofday(¤ttime); + retval = krb5_timeofday(context, ¤ttime); if (retval) return retval; @@ -390,18 +394,18 @@ verify_securid_padata(client, src_addr, data) memset((char *)&sd,0, sizeof (sd)); memset((char *) username, 0, sizeof(username)); - memcpy((char *) username, krb5_princ_component(client,0)->data, - krb5_princ_component(client,0)->length); + memcpy((char *) username, krb5_princ_component(context, client,0)->data, + krb5_princ_component(context, client,0)->length); /* If Instance then Append */ - if (krb5_princ_size(client) > 1 ) { - if (strncmp(krb5_princ_realm(client)->data, - krb5_princ_component(client,1)->data, - krb5_princ_component(client,1)->length) || - krb5_princ_realm(client)->length != - krb5_princ_component(client,1)->length) { + if (krb5_princ_size(context, client) > 1 ) { + if (strncmp(krb5_princ_realm(context, client)->data, + krb5_princ_component(context, client,1)->data, + krb5_princ_component(context, client,1)->length) || + krb5_princ_realm(context, client)->length != + krb5_princ_component(context, client,1)->length) { strncat(username,"/",1); - strncat(username,krb5_princ_component(client,1)->data, - krb5_princ_component(client,1)->length); + strncat(username,krb5_princ_component(context, client,1)->data, + krb5_princ_component(context, client,1)->length); } } if (retval = sd_check(data->data,username,&sd) != ACM_OK) { @@ -414,7 +418,7 @@ verify_securid_padata(client, src_addr, data) } else { char *username = 0; - krb5_unparse_name(client,&username); + krb5_unparse_name(context, client,&username); syslog(LOG_INFO, "%s Provided Securid but this KDC does not support Securid", username); @@ -424,13 +428,14 @@ verify_securid_padata(client, src_addr, data) } #else krb5_error_code -verify_securid_padata(client, src_addr, data) +verify_securid_padata(context, client, src_addr, data) + krb5_context context; krb5_principal client; krb5_address **src_addr; krb5_data *data; { char *username = 0; - krb5_unparse_name(client,&username); + krb5_unparse_name(context, client,&username); syslog(LOG_INFO, "%s Provided Securid but this KDC does not support Securid", username); @@ -447,7 +452,8 @@ static char *krb5_SecureId_prompt = "\nEnter Your SecurId Access Code Prepended static char *krb5_SecureId_prompt = "\nEnter Your SecurId Access Code Prepended with Your PIN\n (or a \'#\'if Your PIN is entered on the card keypad): "; krb5_error_code -get_securid_padata(client,src_addr,pa_data) +get_securid_padata(context, client,src_addr,pa_data) + krb5_context context; krb5_principal client; krb5_address **src_addr; krb5_pa_data *pa_data; @@ -458,7 +464,7 @@ get_securid_padata(client,src_addr,pa_data) int retval = 0; tempsize = sizeof(temp) - 1; - if (krb5_read_password(krb5_SecureId_prompt, 0, temp, &tempsize)) + if (krb5_read_password(context, krb5_SecureId_prompt, 0, temp, &tempsize)) return(KRB5_PARSE_ILLCHAR); temp[tempsize] = '\0'; diff --git a/src/lib/krb5/krb/princ_comp.c b/src/lib/krb5/krb/princ_comp.c index f1eedad14..7697707f3 100644 --- a/src/lib/krb5/krb/princ_comp.c +++ b/src/lib/krb5/krb/princ_comp.c @@ -30,35 +30,39 @@ #include krb5_boolean -krb5_realm_compare(princ1, princ2) -krb5_const_principal princ1; -krb5_const_principal princ2; +krb5_realm_compare(context, princ1, princ2) + krb5_context context; + krb5_const_principal princ1; + krb5_const_principal princ2; { - if (krb5_princ_realm(princ1)->length != krb5_princ_realm(princ2)->length || - memcmp (krb5_princ_realm(princ1)->data, krb5_princ_realm(princ2)->data, - krb5_princ_realm(princ2)->length)) + if (krb5_princ_realm(context, princ1)->length != + krb5_princ_realm(context, princ2)->length || + memcmp (krb5_princ_realm(context, princ1)->data, + krb5_princ_realm(context, princ2)->data, + krb5_princ_realm(context, princ2)->length)) return FALSE; return TRUE; } krb5_boolean -krb5_principal_compare(princ1, princ2) -krb5_const_principal princ1; -krb5_const_principal princ2; +krb5_principal_compare(context, princ1, princ2) + krb5_context context; + krb5_const_principal princ1; + krb5_const_principal princ2; { register int i, nelem; - nelem = krb5_princ_size(princ1); - if (nelem != krb5_princ_size(princ2)) + nelem = krb5_princ_size(context, princ1); + if (nelem != krb5_princ_size(context, princ2)) return FALSE; - if (! krb5_realm_compare(princ1, princ2)) + if (! krb5_realm_compare(context, princ1, princ2)) return FALSE; for (i = 0; i < nelem; i++) { - register const krb5_data *p1 = krb5_princ_component(princ1, i); - register const krb5_data *p2 = krb5_princ_component(princ2, i); + register const krb5_data *p1 = krb5_princ_component(context, princ1, i); + register const krb5_data *p2 = krb5_princ_component(context, princ2, i); if (p1->length != p2->length || memcmp(p1->data, p2->data, p1->length)) return FALSE; diff --git a/src/lib/krb5/krb/rd_cred.c b/src/lib/krb5/krb/rd_cred.c index 3c8dc6afd..dd7b3a629 100644 --- a/src/lib/krb5/krb/rd_cred.c +++ b/src/lib/krb5/krb/rd_cred.c @@ -37,12 +37,13 @@ extern krb5_deltat krb5_clockskew; /* Decode the KRB-CRED message, and return creds */ krb5_error_code -krb5_rd_cred(inbuf, key, creds, sender_addr, recv_addr) -const krb5_data *inbuf; -const krb5_keyblock *key; -krb5_creds *creds; /* Filled in */ -const krb5_address *sender_addr; /* optional */ -const krb5_address *recv_addr; /* optional */ +krb5_rd_cred(context, inbuf, key, creds, sender_addr, recv_addr) + krb5_context context; + const krb5_data *inbuf; + const krb5_keyblock *key; + krb5_creds *creds; /* Filled in */ + const krb5_address *sender_addr; /* optional */ + const krb5_address *recv_addr; /* optional */ { krb5_error_code retval; krb5_encrypt_block eblock; @@ -90,7 +91,7 @@ const krb5_address *recv_addr; /* optional */ /* put together an eblock for this decryption */ - krb5_use_cstype(&eblock, credmsg->enc_part.etype); + krb5_use_cstype(context, &eblock, credmsg->enc_part.etype); scratch->length = credmsg->enc_part.ciphertext.length; if (!(scratch->data = malloc(scratch->length))) { @@ -99,16 +100,16 @@ const krb5_address *recv_addr; /* optional */ } /* do any necessary key pre-processing */ - if (retval = krb5_process_key(&eblock, key)) { + if (retval = krb5_process_key(context, &eblock, key)) { cleanup_credmsg(); cleanup_scratch(); return retval; } -#define cleanup_prockey() {(void) krb5_finish_key(&eblock);} +#define cleanup_prockey() {(void) krb5_finish_key(context, &eblock);} /* call the decryption routine */ - if (retval = krb5_decrypt((krb5_pointer) credmsg->enc_part.ciphertext.data, + if (retval = krb5_decrypt(context, (krb5_pointer) credmsg->enc_part.ciphertext.data, (krb5_pointer) scratch->data, scratch->length, &eblock, 0)) { @@ -122,7 +123,7 @@ const krb5_address *recv_addr; /* optional */ cleanup_credmsg(); - if (retval = krb5_finish_key(&eblock)) { + if (retval = krb5_finish_key(context, &eblock)) { cleanup_scratch(); return retval; } @@ -136,7 +137,7 @@ const krb5_address *recv_addr; /* optional */ #define cleanup_mesg() {(void)krb5_xfree(credmsg_enc_part);} - if (retval = krb5_timeofday(¤ttime)) { + if (retval = krb5_timeofday(context, ¤ttime)) { cleanup_mesg(); return retval; } @@ -146,13 +147,13 @@ const krb5_address *recv_addr; /* optional */ } if (sender_addr && credmsg_enc_part->s_address && - !krb5_address_compare(sender_addr, + !krb5_address_compare(context, sender_addr, credmsg_enc_part->s_address)) { cleanup_mesg(); return KRB5KRB_AP_ERR_BADADDR; } if (recv_addr && credmsg_enc_part->r_address && - !krb5_address_compare(recv_addr, + !krb5_address_compare(context, recv_addr, credmsg_enc_part->r_address)) { cleanup_mesg(); return KRB5KRB_AP_ERR_BADADDR; @@ -165,27 +166,27 @@ const krb5_address *recv_addr; /* optional */ cleanup_mesg(); return retval; } - if (!krb5_address_search(credmsg_enc_part->r_address, + if (!krb5_address_search(context, credmsg_enc_part->r_address, our_addrs)) { - krb5_free_addresses(our_addrs); + krb5_free_addresses(context, our_addrs); cleanup_mesg(); return KRB5KRB_AP_ERR_BADADDR; } - krb5_free_addresses(our_addrs); + krb5_free_addresses(context, our_addrs); } - if (retval = krb5_copy_principal(credmsg_enc_part->ticket_info[0]->client, + if (retval = krb5_copy_principal(context, credmsg_enc_part->ticket_info[0]->client, &creds->client)) { return(retval); } - if (retval = krb5_copy_principal(credmsg_enc_part->ticket_info[0]->server, + if (retval = krb5_copy_principal(context, credmsg_enc_part->ticket_info[0]->server, &creds->server)) { return(retval); } if (retval = - krb5_copy_keyblock_contents(credmsg_enc_part->ticket_info[0]->session, + krb5_copy_keyblock_contents(context, credmsg_enc_part->ticket_info[0]->session, &creds->keyblock)) { return(retval); } @@ -200,7 +201,7 @@ const krb5_address *recv_addr; /* optional */ creds->is_skey = FALSE; creds->ticket_flags = credmsg_enc_part->ticket_info[0]->flags; - if (retval = krb5_copy_addresses(credmsg_enc_part->ticket_info[0]->caddrs, + if (retval = krb5_copy_addresses(context, credmsg_enc_part->ticket_info[0]->caddrs, &creds->addresses)) { clean(); return(retval); diff --git a/src/lib/krb5/krb/rd_error.c b/src/lib/krb5/krb/rd_error.c index 70c31a275..c30310d94 100644 --- a/src/lib/krb5/krb/rd_error.c +++ b/src/lib/krb5/krb/rd_error.c @@ -42,9 +42,10 @@ */ krb5_error_code -krb5_rd_error( enc_errbuf, dec_error) -const krb5_data *enc_errbuf; -krb5_error **dec_error; +krb5_rd_error(context, enc_errbuf, dec_error) + krb5_context context; + const krb5_data *enc_errbuf; + krb5_error **dec_error; { if (!krb5_is_krb_error(enc_errbuf)) return KRB5KRB_AP_ERR_MSG_TYPE; diff --git a/src/lib/krb5/krb/rd_priv.c b/src/lib/krb5/krb/rd_priv.c index 78da0553f..08cda457e 100644 --- a/src/lib/krb5/krb/rd_priv.c +++ b/src/lib/krb5/krb/rd_priv.c @@ -56,24 +56,18 @@ Returns system errors, integrity errors. */ krb5_error_code -krb5_rd_priv(DECLARG(const krb5_data *, inbuf), - DECLARG(const krb5_keyblock *, key), - DECLARG(const krb5_address *, sender_addr), - DECLARG(const krb5_address *, recv_addr), - DECLARG(krb5_int32, seq_number), - DECLARG(krb5_int32, priv_flags), - DECLARG(krb5_pointer, i_vector), - DECLARG(krb5_rcache, rcache), - DECLARG(krb5_data *, outbuf)) -OLDDECLARG(const krb5_data *, inbuf) -OLDDECLARG(const krb5_keyblock *, key) -OLDDECLARG(const krb5_address *, sender_addr) -OLDDECLARG(const krb5_address *, recv_addr) -OLDDECLARG(krb5_int32, seq_number) -OLDDECLARG(krb5_int32, priv_flags) -OLDDECLARG(krb5_pointer, i_vector) -OLDDECLARG(krb5_rcache, rcache) -OLDDECLARG(krb5_data *, outbuf) +krb5_rd_priv(context, inbuf, key, sender_addr, recv_addr, seq_number, + priv_flags, i_vector, rcache, outbuf) + krb5_context context; + const krb5_data * inbuf; + const krb5_keyblock * key; + const krb5_address * sender_addr; + const krb5_address * recv_addr; + krb5_int32 seq_number; + krb5_int32 priv_flags; + krb5_pointer i_vector; + krb5_rcache rcache; + krb5_data * outbuf; { krb5_error_code retval; krb5_encrypt_block eblock; @@ -97,7 +91,7 @@ OLDDECLARG(krb5_data *, outbuf) /* put together an eblock for this decryption */ - krb5_use_cstype(&eblock, privmsg->enc_part.etype); + krb5_use_cstype(context, &eblock, privmsg->enc_part.etype); scratch.length = privmsg->enc_part.ciphertext.length; if (!(scratch.data = malloc(scratch.length))) { @@ -108,16 +102,16 @@ OLDDECLARG(krb5_data *, outbuf) #define cleanup_scratch() {(void)memset(scratch.data, 0, scratch.length); (void)krb5_xfree(scratch.data);} /* do any necessary key pre-processing */ - if (retval = krb5_process_key(&eblock, key)) { + if (retval = krb5_process_key(context, &eblock, key)) { cleanup_privmsg(); cleanup_scratch(); return retval; } -#define cleanup_prockey() {(void) krb5_finish_key(&eblock);} +#define cleanup_prockey() {(void) krb5_finish_key(context, &eblock);} /* call the decryption routine */ - if (retval = krb5_decrypt((krb5_pointer) privmsg->enc_part.ciphertext.data, + if (retval = krb5_decrypt(context, (krb5_pointer) privmsg->enc_part.ciphertext.data, (krb5_pointer) scratch.data, scratch.length, &eblock, i_vector)) { @@ -141,7 +135,7 @@ OLDDECLARG(krb5_data *, outbuf) cleanup_privmsg(); - if (retval = krb5_finish_key(&eblock)) { + if (retval = krb5_finish_key(context, &eblock)) { cleanup_scratch(); return retval; } @@ -159,7 +153,7 @@ OLDDECLARG(krb5_data *, outbuf) if (!(priv_flags & KRB5_PRIV_NOTIME)) { krb5_donot_replay replay; - if (retval = krb5_timeofday(¤ttime)) { + if (retval = krb5_timeofday(context, ¤ttime)) { cleanup_data(); cleanup_mesg(); return retval; @@ -175,7 +169,7 @@ OLDDECLARG(krb5_data *, outbuf) cleanup_mesg(); return KRB5_RC_REQUIRED; } - if (retval = krb5_gen_replay_name(sender_addr, "_priv", + if (retval = krb5_gen_replay_name(context, sender_addr, "_priv", &replay.client)) { cleanup_data(); cleanup_mesg(); @@ -184,7 +178,7 @@ OLDDECLARG(krb5_data *, outbuf) replay.server = ""; /* XXX */ replay.cusec = privmsg_enc_part->usec; replay.ctime = privmsg_enc_part->timestamp; - if (retval = krb5_rc_store(rcache, &replay)) { + if (retval = krb5_rc_store(context, rcache, &replay)) { krb5_xfree(replay.client); cleanup_data(); cleanup_mesg(); @@ -200,7 +194,7 @@ OLDDECLARG(krb5_data *, outbuf) return KRB5KRB_AP_ERR_BADORDER; } - if (!krb5_address_compare(sender_addr, privmsg_enc_part->s_address)) { + if (!krb5_address_compare(context, sender_addr, privmsg_enc_part->s_address)) { cleanup_data(); cleanup_mesg(); return KRB5KRB_AP_ERR_BADADDR; @@ -208,7 +202,7 @@ OLDDECLARG(krb5_data *, outbuf) if (privmsg_enc_part->r_address) { if (recv_addr) { - if (!krb5_address_compare(recv_addr, + if (!krb5_address_compare(context, recv_addr, privmsg_enc_part->r_address)) { cleanup_data(); cleanup_mesg(); @@ -222,13 +216,13 @@ OLDDECLARG(krb5_data *, outbuf) cleanup_mesg(); return retval; } - if (!krb5_address_search(privmsg_enc_part->r_address, our_addrs)) { - krb5_free_addresses(our_addrs); + if (!krb5_address_search(context, privmsg_enc_part->r_address, our_addrs)) { + krb5_free_addresses(context, our_addrs); cleanup_data(); cleanup_mesg(); return KRB5KRB_AP_ERR_BADADDR; } - krb5_free_addresses(our_addrs); + krb5_free_addresses(context, our_addrs); } } diff --git a/src/lib/krb5/krb/rd_rep.c b/src/lib/krb5/krb/rd_rep.c index bbd848090..13a49c740 100644 --- a/src/lib/krb5/krb/rd_rep.c +++ b/src/lib/krb5/krb/rd_rep.c @@ -42,10 +42,11 @@ */ krb5_error_code -krb5_rd_rep(inbuf, kblock, repl) -const krb5_data *inbuf; -const krb5_keyblock *kblock; -krb5_ap_rep_enc_part **repl; +krb5_rd_rep(context, inbuf, kblock, repl) + krb5_context context; + const krb5_data *inbuf; + const krb5_keyblock *kblock; + krb5_ap_rep_enc_part **repl; { krb5_error_code retval; krb5_ap_rep *reply; @@ -66,37 +67,37 @@ krb5_ap_rep_enc_part **repl; /* put together an eblock for this encryption */ if (!valid_etype(reply->enc_part.etype)) { - krb5_free_ap_rep(reply); + krb5_free_ap_rep(context, reply); return KRB5_PROG_ETYPE_NOSUPP; } - krb5_use_cstype(&eblock, reply->enc_part.etype); + krb5_use_cstype(context, &eblock, reply->enc_part.etype); scratch.length = reply->enc_part.ciphertext.length; if (!(scratch.data = malloc(scratch.length))) { - krb5_free_ap_rep(reply); + krb5_free_ap_rep(context, reply); return(ENOMEM); } /* do any necessary key pre-processing */ - if (retval = krb5_process_key(&eblock, kblock)) { + if (retval = krb5_process_key(context, &eblock, kblock)) { errout: free(scratch.data); - krb5_free_ap_rep(reply); + krb5_free_ap_rep(context, reply); return(retval); } /* call the encryption routine */ - if (retval = krb5_decrypt((krb5_pointer) reply->enc_part.ciphertext.data, + if (retval = krb5_decrypt(context, (krb5_pointer) reply->enc_part.ciphertext.data, (krb5_pointer) scratch.data, scratch.length, &eblock, 0)) { - (void) krb5_finish_key(&eblock); + (void) krb5_finish_key(context, &eblock); goto errout; } #define clean_scratch() {memset(scratch.data, 0, scratch.length); \ free(scratch.data);} /* finished with the top-level encoding of the ap_rep */ - krb5_free_ap_rep(reply); - if (retval = krb5_finish_key(&eblock)) { + krb5_free_ap_rep(context, reply); + if (retval = krb5_finish_key(context, &eblock)) { clean_scratch(); return retval; diff --git a/src/lib/krb5/krb/rd_req.c b/src/lib/krb5/krb/rd_req.c index 97fd82bcb..5ec3758cf 100644 --- a/src/lib/krb5/krb/rd_req.c +++ b/src/lib/krb5/krb/rd_req.c @@ -64,16 +64,17 @@ typedef krb5_error_code (*rdreq_key_proc) PROTOTYPE((krb5_pointer, #include krb5_error_code -krb5_rd_req(inbuf, server, sender_addr, fetchfrom, keyproc, keyprocarg, - rcache, authdat) -const krb5_data *inbuf; -krb5_const_principal server; -const krb5_address *sender_addr; -const char * fetchfrom; -rdreq_key_proc keyproc; -krb5_pointer keyprocarg; -krb5_rcache rcache; -krb5_tkt_authent **authdat; +krb5_rd_req(context, inbuf, server, sender_addr, fetchfrom, keyproc, + keyprocarg, rcache, authdat) + krb5_context context; + const krb5_data *inbuf; + krb5_const_principal server; + const krb5_address *sender_addr; + const char * fetchfrom; + krb5_rdreq_key_proc keyproc; + krb5_pointer keyprocarg; + krb5_rcache rcache; + krb5_tkt_authent **authdat; { krb5_error_code retval; krb5_ap_req *request; @@ -94,9 +95,10 @@ krb5_tkt_authent **authdat; } - retval = krb5_rd_req_decoded(request, server, sender_addr, fetchfrom, - keyproc, keyprocarg, rcache, authdat); - krb5_free_ap_req(request); + retval = krb5_rd_req_decoded(context, request, server, sender_addr, + fetchfrom, keyproc, keyprocarg, rcache, + authdat); + krb5_free_ap_req(context, request); return retval; } diff --git a/src/lib/krb5/krb/rd_req_dec.c b/src/lib/krb5/krb/rd_req_dec.c index fc3a0f801..463970763 100644 --- a/src/lib/krb5/krb/rd_req_dec.c +++ b/src/lib/krb5/krb/rd_req_dec.c @@ -66,9 +66,10 @@ #include static krb5_error_code decrypt_authenticator - PROTOTYPE((const krb5_ap_req *, krb5_authenticator **)); + PROTOTYPE((krb5_context, const krb5_ap_req *, krb5_authenticator **)); typedef krb5_error_code (*rdreq_key_proc) - PROTOTYPE((krb5_pointer, krb5_principal, krb5_kvno, krb5_keyblock **)); + PROTOTYPE((krb5_context, krb5_pointer, krb5_principal, + krb5_kvno, krb5_keyblock **)); /* and back to normal... */ #include @@ -77,23 +78,24 @@ extern krb5_deltat krb5_clockskew; #define in_clock_skew(date) (abs((date)-currenttime) < krb5_clockskew) krb5_error_code -krb5_rd_req_decoded(req, server, sender_addr, fetchfrom, keyproc, keyprocarg, - rcache, authdat) -const krb5_ap_req *req; -krb5_const_principal server; -const krb5_address *sender_addr; -const char * fetchfrom; -rdreq_key_proc keyproc; -krb5_pointer keyprocarg; -krb5_rcache rcache; -krb5_tkt_authent **authdat; +krb5_rd_req_decoded(context, req, server, sender_addr, fetchfrom, keyproc, + keyprocarg, rcache, authdat) + krb5_context context; + const krb5_ap_req *req; + krb5_const_principal server; + const krb5_address *sender_addr; + const char * fetchfrom; + rdreq_key_proc keyproc; + krb5_pointer keyprocarg; + krb5_rcache rcache; + krb5_tkt_authent **authdat; { krb5_error_code retval = 0; krb5_keyblock *tkt_key = NULL; krb5_timestamp currenttime, starttime; krb5_tkt_authent *tktauthent = NULL; - if (server && !krb5_principal_compare(server, req->ticket->server)) + if (server && !krb5_principal_compare(context, server, req->ticket->server)) return KRB5KRB_AP_WRONG_PRINC; /* if (req->ap_options & AP_OPTS_USE_SESSION_KEY) @@ -101,7 +103,7 @@ krb5_tkt_authent **authdat; /* fetch a server key */ if (keyproc) { - retval = (*keyproc)(keyprocarg, req->ticket->server, + retval = (*keyproc)(context, keyprocarg, req->ticket->server, req->ticket->enc_part.kvno, &tkt_key); } else { krb5_keytab keytabid; @@ -109,18 +111,18 @@ krb5_tkt_authent **authdat; if (fetchfrom) { /* use the named keytab */ - retval = krb5_kt_resolve(fetchfrom, &keytabid); + retval = krb5_kt_resolve(context, fetchfrom, &keytabid); } else { /* use default keytab */ - retval = krb5_kt_default(&keytabid); + retval = krb5_kt_default(context, &keytabid); } if (!retval) { - retval = krb5_kt_get_entry(keytabid, req->ticket->server, + retval = krb5_kt_get_entry(context, keytabid, req->ticket->server, req->ticket->enc_part.kvno, &ktentry); - (void) krb5_kt_close(keytabid); + (void) krb5_kt_close(context, keytabid); if (!retval) { - retval = krb5_copy_keyblock(&ktentry.key, &tkt_key); - (void) krb5_kt_free_entry(&ktentry); + retval = krb5_copy_keyblock(context, &ktentry.key, &tkt_key); + (void) krb5_kt_free_entry(context, &ktentry); } } } @@ -128,8 +130,8 @@ krb5_tkt_authent **authdat; return retval; /* some error in getting the key */ /* decrypt the ticket */ - if (retval = krb5_decrypt_tkt_part(tkt_key, req->ticket)) { - krb5_free_keyblock(tkt_key); + if (retval = krb5_decrypt_tkt_part(context, tkt_key, req->ticket)) { + krb5_free_keyblock(context, tkt_key); return(retval); } @@ -145,21 +147,22 @@ krb5_tkt_authent **authdat; memset((char *)tktauthent, 0, sizeof(*tktauthent)); - if (retval = decrypt_authenticator(req, &tktauthent->authenticator)) + if (retval = decrypt_authenticator(context, req, &tktauthent->authenticator)) goto cleanup; *authdat = NULL; /* Set authdat to tktauthent when we finish */ - if (!krb5_principal_compare(tktauthent->authenticator->client, + if (!krb5_principal_compare(context, tktauthent->authenticator->client, req->ticket->enc_part2->client)) { retval = KRB5KRB_AP_ERR_BADMATCH; goto cleanup; } - if (sender_addr && !krb5_address_search(sender_addr, req->ticket->enc_part2->caddrs)) { + if (sender_addr && !krb5_address_search(context, sender_addr, req->ticket->enc_part2->caddrs)) { retval = KRB5KRB_AP_ERR_BADADDR; goto cleanup; } - if (retval = krb5_timeofday(¤ttime)) + + if (retval = krb5_timeofday(context, ¤ttime)) goto cleanup; if (!in_clock_skew(tktauthent->authenticator->ctime)) { retval = KRB5KRB_AP_ERR_SKEW; @@ -186,13 +189,13 @@ krb5_tkt_authent **authdat; /* No cross-realm tickets */ { char *lrealm; - krb5_data *realm = krb5_princ_realm(req->ticket->enc_part2->client); + krb5_data *realm = krb5_princ_realm(context, req->ticket->enc_part2->client); krb5_transited *trans = &(req->ticket->enc_part2->transited); /* If the transited list is empty, then we have at most one hop */ /* So we also have to check that the client's realm is the local one */ - krb5_get_default_realm(&lrealm); + krb5_get_default_realm(context, &lrealm); if ((trans->tr_contents.data && trans->tr_contents.data[0]) || strlen(lrealm) != realm->length || memcmp(lrealm, realm->data, strlen(lrealm))) { @@ -207,7 +210,7 @@ krb5_tkt_authent **authdat; { int i; krb5_data lrealm; - krb5_data *realm = krb5_princ_realm(req->ticket->enc_part2->client); + krb5_data *realm = krb5_princ_realm(context, req->ticket->enc_part2->client); krb5_transited *trans = &(req->ticket->enc_part2->transited); /* If the transited list is not empty, then check that all realms */ @@ -215,9 +218,9 @@ krb5_tkt_authent **authdat; /* and the local realm. */ if (trans->tr_contents.data && trans->tr_contents.data[0]) { - krb5_get_default_realm(&(lrealm.data)); + krb5_get_default_realm(context, &(lrealm.data)); lrealm.length = strlen(lrealm.data); - retval = krb5_check_transited_list(&(trans->tr_contents), realm, + retval = krb5_check_transited_list(context, &(trans->tr_contents), realm, &lrealm); free(lrealm.data); } @@ -233,12 +236,12 @@ krb5_tkt_authent **authdat; krb5_donot_replay rep; tktauthent->ticket = req->ticket; /* Temporary; allocated below */ - retval = krb5_auth_to_rep(tktauthent, &rep); + retval = krb5_auth_to_rep(context, tktauthent, &rep); tktauthent->ticket = 0; /* Don't allow cleanup to free original ticket. */ if (retval) goto cleanup; - retval = krb5_rc_store(rcache, &rep); + retval = krb5_rc_store(context, rcache, &rep); krb5_xfree(rep.server); krb5_xfree(rep.client); if (retval) @@ -263,12 +266,12 @@ krb5_tkt_authent **authdat; retval = KRB5KRB_AP_ERR_TKT_INVALID; goto cleanup; } - retval = krb5_copy_ticket(req->ticket, &tktauthent->ticket); + retval = krb5_copy_ticket(context, req->ticket, &tktauthent->ticket); cleanup: if (tktauthent) { if (retval) { - krb5_free_tkt_authent(tktauthent); + krb5_free_tkt_authent(context, tktauthent); } else { tktauthent->ap_options = req->ap_options; *authdat = tktauthent; @@ -277,18 +280,19 @@ cleanup: if (retval && req->ticket->enc_part2) { /* only free if we're erroring out...otherwise some applications will need the output. */ - krb5_free_enc_tkt_part(req->ticket->enc_part2); + krb5_free_enc_tkt_part(context, req->ticket->enc_part2); req->ticket->enc_part2 = NULL; } if (tkt_key) - krb5_free_keyblock(tkt_key); + krb5_free_keyblock(context, tkt_key); return retval; } static krb5_error_code -decrypt_authenticator(request, authpp) -const krb5_ap_req *request; -krb5_authenticator **authpp; +decrypt_authenticator(context, request, authpp) + krb5_context context; + const krb5_ap_req *request; + krb5_authenticator **authpp; { krb5_authenticator *local_auth; krb5_error_code retval; @@ -306,29 +310,29 @@ krb5_authenticator **authpp; if (!valid_etype(request->authenticator.etype)) return KRB5_PROG_ETYPE_NOSUPP; - krb5_use_cstype(&eblock, request->authenticator.etype); + krb5_use_cstype(context, &eblock, request->authenticator.etype); scratch.length = request->authenticator.ciphertext.length; if (!(scratch.data = malloc(scratch.length))) return(ENOMEM); /* do any necessary key pre-processing */ - if (retval = krb5_process_key(&eblock, sesskey)) { + if (retval = krb5_process_key(context, &eblock, sesskey)) { free(scratch.data); return(retval); } /* call the encryption routine */ - if (retval = krb5_decrypt((krb5_pointer) request->authenticator.ciphertext.data, + if (retval = krb5_decrypt(context, (krb5_pointer) request->authenticator.ciphertext.data, (krb5_pointer) scratch.data, scratch.length, &eblock, 0)) { - (void) krb5_finish_key(&eblock); + (void) krb5_finish_key(context, &eblock); free(scratch.data); return retval; } #define clean_scratch() {memset(scratch.data, 0, scratch.length); \ free(scratch.data);} - if (retval = krb5_finish_key(&eblock)) { + if (retval = krb5_finish_key(context, &eblock)) { clean_scratch(); return retval; diff --git a/src/lib/krb5/krb/rd_req_sim.c b/src/lib/krb5/krb/rd_req_sim.c index e0c110247..24a2515c7 100644 --- a/src/lib/krb5/krb/rd_req_sim.c +++ b/src/lib/krb5/krb/rd_req_sim.c @@ -49,27 +49,29 @@ */ krb5_error_code -krb5_rd_req_simple(inbuf, server, sender_addr, authdat) -const krb5_data *inbuf; -krb5_const_principal server; -const krb5_address *sender_addr; -krb5_tkt_authent **authdat; +krb5_rd_req_simple(context, inbuf, server, sender_addr, authdat) + krb5_context context; + const krb5_data *inbuf; + krb5_const_principal server; + const krb5_address *sender_addr; + krb5_tkt_authent **authdat; { krb5_error_code retval; krb5_rcache rcache = 0; if (server) { - retval = krb5_get_server_rcache(krb5_princ_component(server, 0), + retval = krb5_get_server_rcache(context, + krb5_princ_component(context, server, 0), &rcache); if (retval) goto cleanup; } - retval = krb5_rd_req(inbuf, server, sender_addr, 0, 0, 0, + retval = krb5_rd_req(context, inbuf, server, sender_addr, 0, 0, 0, rcache, authdat); cleanup: if (rcache) - krb5_rc_close(rcache); + krb5_rc_close(context, rcache); return retval; } diff --git a/src/lib/krb5/krb/rd_safe.c b/src/lib/krb5/krb/rd_safe.c index 33d557227..1844a6735 100644 --- a/src/lib/krb5/krb/rd_safe.c +++ b/src/lib/krb5/krb/rd_safe.c @@ -47,16 +47,17 @@ extern krb5_deltat krb5_clockskew; returns system errors, integrity errors */ krb5_error_code -krb5_rd_safe(inbuf, key, sender_addr, recv_addr, seq_number, safe_flags, - rcache, outbuf) -const krb5_data *inbuf; -const krb5_keyblock *key; -const krb5_address *sender_addr; -const krb5_address *recv_addr; -krb5_int32 seq_number; -krb5_int32 safe_flags; -krb5_rcache rcache; -krb5_data *outbuf; +krb5_rd_safe(context, inbuf, key, sender_addr, recv_addr, seq_number, + safe_flags, rcache, outbuf) + krb5_context context; + const krb5_data *inbuf; + const krb5_keyblock *key; + const krb5_address *sender_addr; + const krb5_address *recv_addr; + krb5_int32 seq_number; + krb5_int32 safe_flags; + krb5_rcache rcache; + krb5_data *outbuf; { krb5_error_code retval; krb5_safe *message; @@ -71,7 +72,7 @@ krb5_data *outbuf; if (retval = decode_krb5_safe(inbuf, &message)) return retval; -#define cleanup() krb5_free_safe(message) +#define cleanup() krb5_free_safe(context, message) if (!valid_cksumtype(message->checksum->checksum_type)) { cleanup(); @@ -86,7 +87,7 @@ krb5_data *outbuf; if (!(safe_flags & KRB5_SAFE_NOTIME)) { krb5_donot_replay replay; - if (retval = krb5_timeofday(¤ttime)) { + if (retval = krb5_timeofday(context, ¤ttime)) { cleanup(); return retval; } @@ -100,7 +101,7 @@ krb5_data *outbuf; cleanup(); return KRB5_RC_REQUIRED; } - if (retval = krb5_gen_replay_name(sender_addr, "_safe", + if (retval = krb5_gen_replay_name(context, sender_addr, "_safe", &replay.client)) { cleanup(); return retval; @@ -108,7 +109,7 @@ krb5_data *outbuf; replay.server = ""; /* XXX */ replay.cusec = message->usec; replay.ctime = message->timestamp; - if (retval = krb5_rc_store(rcache, &replay)) { + if (retval = krb5_rc_store(context, rcache, &replay)) { krb5_xfree(replay.client); cleanup(); return retval; @@ -122,30 +123,30 @@ krb5_data *outbuf; return KRB5KRB_AP_ERR_BADORDER; } - if (!krb5_address_compare(sender_addr, message->s_address)) { + if (!krb5_address_compare(context, sender_addr, message->s_address)) { cleanup(); return KRB5KRB_AP_ERR_BADADDR; } if (message->r_address) { if (recv_addr) { - if (!krb5_address_compare(recv_addr, message->r_address)) { + if (!krb5_address_compare(context, recv_addr, message->r_address)) { cleanup(); return KRB5KRB_AP_ERR_BADADDR; } } else { krb5_address **our_addrs; - if (retval = krb5_os_localaddr(&our_addrs)) { + if (retval = krb5_os_localaddr( &our_addrs)) { cleanup(); return retval; } - if (!krb5_address_search(message->r_address, our_addrs)) { - krb5_free_addresses(our_addrs); + if (!krb5_address_search(context, message->r_address, our_addrs)) { + krb5_free_addresses(context, our_addrs); cleanup(); return KRB5KRB_AP_ERR_BADADDR; } - krb5_free_addresses(our_addrs); + krb5_free_addresses(context, our_addrs); } } @@ -169,20 +170,20 @@ krb5_data *outbuf; message->checksum = his_cksum; if (!(our_cksum.contents = (krb5_octet *) - malloc(krb5_checksum_size(his_cksum->checksum_type)))) { + malloc(krb5_checksum_size(context, his_cksum->checksum_type)))) { cleanup(); return ENOMEM; } #undef cleanup -#define cleanup() {krb5_free_safe(message); krb5_xfree(our_cksum.contents);} +#define cleanup() {krb5_free_safe(context, message); krb5_xfree(our_cksum.contents);} - retval = krb5_calculate_checksum(his_cksum->checksum_type, + retval = krb5_calculate_checksum(context, his_cksum->checksum_type, scratch->data, scratch->length, (krb5_pointer) key->contents, key->length, &our_cksum); (void) memset((char *)scratch->data, 0, scratch->length); - krb5_free_data(scratch); + krb5_free_data(context, scratch); if (retval) { cleanup(); @@ -200,10 +201,10 @@ krb5_data *outbuf; krb5_xfree(our_cksum.contents); if (message->s_address) - krb5_free_address(message->s_address); + krb5_free_address(context, message->s_address); if (message->r_address) - krb5_free_address(message->r_address); - krb5_free_checksum(his_cksum); + krb5_free_address(context, message->r_address); + krb5_free_checksum(context, his_cksum); krb5_xfree(message); return 0; diff --git a/src/lib/krb5/krb/recvauth.c b/src/lib/krb5/krb/recvauth.c index d8fb01eac..3f682d36c 100644 --- a/src/lib/krb5/krb/recvauth.c +++ b/src/lib/krb5/krb/recvauth.c @@ -43,11 +43,13 @@ extern krb5_flags krb5_kdc_default_options; static char *sendauth_version = "KRB5_SENDAUTH_V1.0"; krb5_error_code -krb5_recvauth(/* IN */ +krb5_recvauth(context, + /* IN */ fd, appl_version, server, sender_addr, fetch_from, keyproc, keyprocarg, rc_type, flags, /* OUT */ seq_number, client, ticket, authent) + krb5_context context; krb5_pointer fd; char *appl_version; krb5_principal server; @@ -85,7 +87,7 @@ krb5_recvauth(/* IN */ /* * First read the sendauth version string and check it. */ - if (retval = krb5_read_message(fd, &inbuf)) + if (retval = krb5_read_message(context, fd, &inbuf)) return(retval); if (strcmp(inbuf.data, sendauth_version)) { krb5_xfree(inbuf.data); @@ -99,7 +101,7 @@ krb5_recvauth(/* IN */ /* * Do the same thing for the application version string. */ - if (retval = krb5_read_message(fd, &inbuf)) + if (retval = krb5_read_message(context, fd, &inbuf)) return(retval); if (strcmp(inbuf.data, appl_version)) { krb5_xfree(inbuf.data); @@ -138,7 +140,7 @@ krb5_recvauth(/* IN */ * Now we actually write the response. If the response is non-zero, * exit with a return value of problem */ - if ((krb5_net_write(*((int *) fd), (char *)&response, 1)) < 0) { + if ((krb5_net_write(context, *((int *) fd), (char *)&response, 1)) < 0) { return(problem); /* We'll return the top-level problem */ } if (problem) @@ -150,11 +152,11 @@ krb5_recvauth(/* IN */ if (!(rcache = (krb5_rcache) malloc(sizeof(*rcache)))) problem = ENOMEM; if (!problem) - problem = krb5_rc_resolve_type(&rcache, + problem = krb5_rc_resolve_type(context, &rcache, rc_type ? rc_type : "dfl"); cachename = NULL; if (server) { - server_name = krb5_princ_component(server, 0); + server_name = krb5_princ_component(context, server, 0); } else { null_server.data = "default"; null_server.length = 7; @@ -167,17 +169,17 @@ krb5_recvauth(/* IN */ strcpy(cachename, rc_base ? rc_base : "rc_"); strncat(cachename, server_name->data, server_name->length); cachename[server_name->length+strlen(rc_base)] = '\0'; - problem = krb5_rc_resolve(rcache, cachename); + problem = krb5_rc_resolve(context, rcache, cachename); } if (!problem) { - if (krb5_rc_recover(rcache)) + if (krb5_rc_recover(context, rcache)) /* * If the rc_recover didn't work, then try * initializing the replay cache. */ - problem = krb5_rc_initialize(rcache, krb5_clockskew); + problem = krb5_rc_initialize(context, rcache, krb5_clockskew); if (problem) { - krb5_rc_close(rcache); + krb5_rc_close(context, rcache); rcache = NULL; } } @@ -185,8 +187,8 @@ krb5_recvauth(/* IN */ /* * Now, let's read the AP_REQ message and decode it */ - if (retval = krb5_read_message(fd, &inbuf)) { - (void) krb5_rc_close(rcache); + if (retval = krb5_read_message(context, fd, &inbuf)) { + (void) krb5_rc_close(context, rcache); if (cachename) free(cachename); return(retval); @@ -194,11 +196,11 @@ krb5_recvauth(/* IN */ authdat = 0; /* so we can tell if we need to free it later... */ if (!problem) - problem = krb5_rd_req(&inbuf, server, sender_addr, fetch_from, + problem = krb5_rd_req(context, &inbuf, server, sender_addr, fetch_from, keyproc, keyprocarg, rcache, &authdat); krb5_xfree(inbuf.data); if (rcache) - retval = krb5_rc_close(rcache); + retval = krb5_rc_close(context, rcache); if (!problem && retval) problem = retval; if (cachename) @@ -214,7 +216,7 @@ krb5_recvauth(/* IN */ const char *message; memset((char *)&error, 0, sizeof(error)); - krb5_us_timeofday(&error.stime, &error.susec); + krb5_us_timeofday(context, &error.stime, &error.susec); error.server = server; error.error = problem - ERROR_TABLE_BASE_krb5; if (error.error > 127) @@ -224,7 +226,7 @@ krb5_recvauth(/* IN */ if (!(error.text.data = malloc(error.text.length))) return(ENOMEM); strcpy(error.text.data, message); - if (retval = krb5_mk_error(&error, &outbuf)) { + if (retval = krb5_mk_error(context, &error, &outbuf)) { free(error.text.data); return(retval); } @@ -233,18 +235,18 @@ krb5_recvauth(/* IN */ outbuf.length = 0; outbuf.data = 0; } - if (retval = krb5_write_message(fd, &outbuf)) { + if (retval = krb5_write_message(context, fd, &outbuf)) { if (outbuf.data) krb5_xfree(outbuf.data); if (!problem) - krb5_free_tkt_authent(authdat); + krb5_free_tkt_authent(context, authdat); return(retval); } if (problem) { /* * We sent back an error, we need to return */ - if (authdat) krb5_free_tkt_authent(authdat); + if (authdat) krb5_free_tkt_authent(context, authdat); return(problem); } /* @@ -259,9 +261,9 @@ krb5_recvauth(/* IN */ * Generate a random sequence number */ if (seq_number && - (retval = krb5_generate_seq_number(authdat->ticket->enc_part2->session, - seq_number))) { - krb5_free_tkt_authent(authdat); + (retval = krb5_generate_seq_number(context, + authdat->ticket->enc_part2->session, seq_number))) { + krb5_free_tkt_authent(context, authdat); return(retval); } @@ -273,15 +275,15 @@ krb5_recvauth(/* IN */ else repl.seq_number = 0; - if (retval = krb5_mk_rep(&repl, + if (retval = krb5_mk_rep(context, &repl, authdat->ticket->enc_part2->session, &outbuf)) { - krb5_free_tkt_authent(authdat); + krb5_free_tkt_authent(context, authdat); return(retval); } - if (retval = krb5_write_message(fd, &outbuf)) { + if (retval = krb5_write_message(context, fd, &outbuf)) { krb5_xfree(outbuf.data); - krb5_free_tkt_authent(authdat); + krb5_free_tkt_authent(context, authdat); return(retval); } krb5_xfree(outbuf.data); @@ -293,9 +295,9 @@ krb5_recvauth(/* IN */ */ if (client) if (retval = - krb5_copy_principal(authdat->ticket->enc_part2->client, + krb5_copy_principal(context, authdat->ticket->enc_part2->client, client)) { - krb5_free_tkt_authent(authdat); + krb5_free_tkt_authent(context, authdat); return(retval); } /* @@ -311,11 +313,11 @@ krb5_recvauth(/* IN */ if (ticket) *ticket = authdat->ticket; else - krb5_free_ticket(authdat->ticket); + krb5_free_ticket(context, authdat->ticket); if (authent) *authent = authdat->authenticator; else - krb5_free_authenticator(authdat->authenticator); + krb5_free_authenticator(context, authdat->authenticator); krb5_xfree(authdat); return 0; } diff --git a/src/lib/krb5/krb/send_tgs.c b/src/lib/krb5/krb/send_tgs.c index f2abf2093..bc15f6659 100644 --- a/src/lib/krb5/krb/send_tgs.c +++ b/src/lib/krb5/krb/send_tgs.c @@ -49,28 +49,20 @@ returns system errors */ krb5_error_code -krb5_send_tgs(DECLARG(const krb5_flags, kdcoptions), - DECLARG(const krb5_ticket_times *,timestruct), - DECLARG(const krb5_enctype, etype), - DECLARG(const krb5_cksumtype, sumtype), - DECLARG(krb5_const_principal, sname), - DECLARG(krb5_address * const *, addrs), - DECLARG(krb5_authdata * const *,authorization_data), - DECLARG(krb5_pa_data * const *, padata), - DECLARG(const krb5_data *,second_ticket), - DECLARG(krb5_creds *,usecred), - DECLARG(krb5_response *,rep)) -OLDDECLARG(const krb5_flags, kdcoptions) -OLDDECLARG(const krb5_ticket_times *,timestruct) -OLDDECLARG(const krb5_enctype, etype) -OLDDECLARG(const krb5_cksumtype, sumtype) -OLDDECLARG(krb5_const_principal, sname) -OLDDECLARG(krb5_address * const *, addrs) -OLDDECLARG(krb5_authdata * const *,authorization_data) -OLDDECLARG(krb5_pa_data * const *, padata) -OLDDECLARG(const krb5_data *,second_ticket) -OLDDECLARG(krb5_creds *,usecred) -OLDDECLARG(krb5_response *,rep) +krb5_send_tgs(context, kdcoptions, timestruct, etype, sumtype, sname, addrs, + authorization_data, padata, second_ticket, usecred, rep) + krb5_context context; + const krb5_flags kdcoptions; + const krb5_ticket_times * timestruct; + const krb5_enctype etype; + const krb5_cksumtype sumtype; + krb5_const_principal sname; + krb5_address * const * addrs; + krb5_authdata * const * authorization_data; + krb5_pa_data * const * padata; + const krb5_data * second_ticket; + krb5_creds * usecred; + krb5_response * rep; { krb5_error_code retval; krb5_kdc_req tgsreq; @@ -94,7 +86,7 @@ OLDDECLARG(krb5_response *,rep) tgsreq.from = timestruct->starttime; tgsreq.till = timestruct->endtime; tgsreq.rtime = timestruct->renew_till; - if (retval = krb5_timeofday(&time_now)) + if (retval = krb5_timeofday(context, &time_now)) return(retval); /* XXX we know they are the same size... */ tgsreq.nonce = (krb5_int32) time_now; @@ -112,13 +104,12 @@ OLDDECLARG(krb5_response *,rep) if (retval = encode_krb5_authdata(authorization_data, &scratch)) return(retval); - krb5_use_cstype(&eblock, etype); + krb5_use_cstype(context, &eblock, etype); tgsreq.authorization_data.etype = etype; tgsreq.authorization_data.kvno = 0; /* ticket session key has */ /* no version */ tgsreq.authorization_data.ciphertext.length = - krb5_encrypt_size(scratch->length, - eblock.crypto_entry); + krb5_encrypt_size(scratch->length, eblock.crypto_entry); /* add padding area, and zero it */ if (!(scratch->data = realloc(scratch->data, tgsreq.authorization_data.ciphertext.length))) { @@ -130,24 +121,24 @@ OLDDECLARG(krb5_response *,rep) tgsreq.authorization_data.ciphertext.length - scratch->length); if (!(tgsreq.authorization_data.ciphertext.data = malloc(tgsreq.authorization_data.ciphertext.length))) { - krb5_free_data(scratch); + krb5_free_data(context, scratch); return ENOMEM; } - if (retval = krb5_process_key(&eblock, &usecred->keyblock)) { - krb5_free_data(scratch); + if (retval = krb5_process_key(context, &eblock, &usecred->keyblock)) { + krb5_free_data(context, scratch); return retval; } /* call the encryption routine */ - if (retval = krb5_encrypt((krb5_pointer) scratch->data, + if (retval = krb5_encrypt(context, (krb5_pointer) scratch->data, (krb5_pointer) tgsreq.authorization_data.ciphertext.data, scratch->length, &eblock, 0)) { - (void) krb5_finish_key(&eblock); + (void) krb5_finish_key(context, &eblock); krb5_xfree(tgsreq.authorization_data.ciphertext.data); - krb5_free_data(scratch); + krb5_free_data(context, scratch); return retval; } - krb5_free_data(scratch); - if (retval = krb5_finish_key(&eblock)) { + krb5_free_data(context, scratch); + if (retval = krb5_finish_key(context, &eblock)) { krb5_xfree(tgsreq.authorization_data.ciphertext.data); return retval; } @@ -176,44 +167,45 @@ OLDDECLARG(krb5_response *,rep) retval = encode_krb5_kdc_req_body(&tgsreq, &scratch); if (retval) { if (sec_ticket) - krb5_free_ticket(sec_ticket); + krb5_free_ticket(context, sec_ticket); cleanup_authdata(); return(retval); } if (!(ap_checksum.contents = (krb5_octet *) - malloc(krb5_checksum_size(sumtype)))) { + malloc(krb5_checksum_size(context, sumtype)))) { if (sec_ticket) - krb5_free_ticket(sec_ticket); - krb5_free_data(scratch); + krb5_free_ticket(context, sec_ticket); + krb5_free_data(context, scratch); cleanup_authdata(); return ENOMEM; } - if (retval = krb5_calculate_checksum(sumtype, + if (retval = krb5_calculate_checksum(context, sumtype, scratch->data, scratch->length, (krb5_pointer) usecred->keyblock.contents, usecred->keyblock.length, &ap_checksum)) { if (sec_ticket) - krb5_free_ticket(sec_ticket); + krb5_free_ticket(context, sec_ticket); krb5_xfree(ap_checksum.contents); - krb5_free_data(scratch); + krb5_free_data(context, scratch); cleanup_authdata(); return retval; } /* done with body */ - krb5_free_data(scratch); + krb5_free_data(context, scratch); #define cleanup() {krb5_xfree(ap_checksum.contents);\ - if (sec_ticket) krb5_free_ticket(sec_ticket);} + if (sec_ticket) krb5_free_ticket(context, sec_ticket);} /* attach ap_req to the tgsreq */ /* * Get an ap_req. */ - if (retval = krb5_mk_req_extended (0L /* no ap options */, + if (retval = krb5_mk_req_extended (context, + 0L /* no ap options */, &ap_checksum, 0L, /* don't need kdc_options for this */ 0, /* no initial sequence */ @@ -269,7 +261,7 @@ OLDDECLARG(krb5_response *,rep) return(retval); } if (sec_ticket) - krb5_free_ticket(sec_ticket); + krb5_free_ticket(context, sec_ticket); cleanup_authdata(); krb5_xfree(combined_padata); krb5_xfree(ap_req_padata.contents); @@ -278,9 +270,10 @@ OLDDECLARG(krb5_response *,rep) #define cleanup() {krb5_xfree(ap_checksum.contents);} /* now send request & get response from KDC */ - retval = krb5_sendto_kdc(scratch, krb5_princ_realm(sname), + retval = krb5_sendto_kdc(context, scratch, + krb5_princ_realm(context, sname), &rep->response); - krb5_free_data(scratch); + krb5_free_data(context, scratch); cleanup(); if (retval) { return retval; diff --git a/src/lib/krb5/krb/sendauth.c b/src/lib/krb5/krb/sendauth.c index 244563e4c..ec320698e 100644 --- a/src/lib/krb5/krb/sendauth.c +++ b/src/lib/krb5/krb/sendauth.c @@ -45,7 +45,8 @@ extern krb5_flags krb5_kdc_default_options; static char *sendauth_version = "KRB5_SENDAUTH_V1.0"; krb5_error_code -krb5_sendauth(/* IN */ +krb5_sendauth(context, + /* IN */ fd, appl_version, client, server, ap_req_options, checksump, /* IN/OUT */ @@ -53,6 +54,7 @@ krb5_sendauth(/* IN */ /* OUT */ sequence, newkey, error, rep_result) + krb5_context context; krb5_pointer fd; char *appl_version; krb5_principal client; @@ -83,17 +85,17 @@ krb5_sendauth(/* IN */ */ outbuf.length = strlen(sendauth_version) + 1; outbuf.data = sendauth_version; - if (retval = krb5_write_message(fd, &outbuf)) + if (retval = krb5_write_message(context, fd, &outbuf)) return(retval); outbuf.length = strlen(appl_version) + 1; outbuf.data = appl_version; - if (retval = krb5_write_message(fd, &outbuf)) + if (retval = krb5_write_message(context, fd, &outbuf)) return(retval); /* * Now, read back a byte: 0 means no error, 1 means bad sendauth * version, 2 means bad application version */ - if ((len = krb5_net_read(*((int *) fd), (char *)&result, 1)) != 1) + if ((len = krb5_net_read(context, *((int *) fd), (char *)&result, 1)) != 1) return((len < 0) ? errno : ECONNABORTED); if (result == 1) return(KRB5_SENDAUTH_BADAUTHVERS); @@ -119,19 +121,19 @@ krb5_sendauth(/* IN */ if (!credsp || !credsp->ticket.length) { if (ccache) use_ccache = ccache; - else if (retval = krb5_cc_default(&use_ccache)) + else if (retval = krb5_cc_default(context, &use_ccache)) goto error_return; } if (!credsp) { - if (retval = krb5_copy_principal(server, &creds.server)) + if (retval = krb5_copy_principal(context, server, &creds.server)) goto error_return; if (client) - retval = krb5_copy_principal(client, &creds.client); + retval = krb5_copy_principal(context, client, &creds.client); else - retval = krb5_cc_get_principal(use_ccache, + retval = krb5_cc_get_principal(context, use_ccache, &creds.client); if (retval) { - krb5_free_principal(creds.server); + krb5_free_principal(context, creds.server); goto error_return; } /* creds.times.endtime = 0; -- memset 0 takes care of this @@ -142,7 +144,7 @@ krb5_sendauth(/* IN */ credsp = &creds; } if (!credsp->ticket.length) { - if (retval = krb5_get_credentials(kdc_options, + if (retval = krb5_get_credentials(context, kdc_options, use_ccache, credsp)) goto error_return; @@ -152,13 +154,13 @@ krb5_sendauth(/* IN */ * Generate a random sequence number */ if (sequence && - (retval = krb5_generate_seq_number(&credsp->keyblock, sequence))) + (retval = krb5_generate_seq_number(context, &credsp->keyblock, sequence))) goto error_return; /* * OK, get the authentication header! */ - if (retval = krb5_mk_req_extended(ap_req_options, checksump, + if (retval = krb5_mk_req_extended(context, ap_req_options, checksump, kdc_options, sequence ? *sequence : 0, newkey, use_ccache, credsp, &authent, @@ -169,7 +171,7 @@ krb5_sendauth(/* IN */ * First write the length of the AP_REQ message, then write * the message itself. */ - retval = krb5_write_message(fd, &outbuf); + retval = krb5_write_message(context, fd, &outbuf); free(outbuf.data); if (retval) goto error_return; @@ -180,12 +182,12 @@ krb5_sendauth(/* IN */ * authentication was rejected, and we need to return the * error structure. */ - if (retval = krb5_read_message(fd, &inbuf)) + if (retval = krb5_read_message(context, fd, &inbuf)) goto error_return; if (inbuf.length) { if (error) { - if (retval = krb5_rd_error(&inbuf, error)) { + if (retval = krb5_rd_error(context, &inbuf, error)) { krb5_xfree(inbuf.data); goto error_return; } @@ -202,17 +204,17 @@ krb5_sendauth(/* IN */ if ((ap_req_options & AP_OPTS_MUTUAL_REQUIRED)) { krb5_ap_rep_enc_part *repl = 0; - if (retval = krb5_read_message(fd, &inbuf)) + if (retval = krb5_read_message(context, fd, &inbuf)) goto error_return; - retval = krb5_rd_rep(&inbuf, &credsp->keyblock, &repl); + retval = krb5_rd_rep(context, &inbuf, &credsp->keyblock, &repl); krb5_xfree(inbuf.data); if (retval || ((repl->ctime != authent.ctime) || (repl->cusec != authent.cusec))) retval = KRB5_SENDAUTH_MUTUAL_FAILED; if (retval) { if (repl) - krb5_free_ap_rep_enc_part(repl); + krb5_free_ap_rep_enc_part(context, repl); goto error_return; } /* @@ -222,14 +224,14 @@ krb5_sendauth(/* IN */ if (rep_result) *rep_result = repl; else - krb5_free_ap_rep_enc_part(repl); + krb5_free_ap_rep_enc_part(context, repl); } retval = 0; /* Normal return */ error_return: if (!ccache && use_ccache) - krb5_cc_close(use_ccache); - krb5_free_cred_contents(&creds); - krb5_free_authenticator_contents(&authent); + krb5_cc_close(context, use_ccache); + krb5_free_cred_contents(context, &creds); + krb5_free_authenticator_contents(context, &authent); return(retval); } diff --git a/src/lib/krb5/krb/srv_rcache.c b/src/lib/krb5/krb/srv_rcache.c index cc397c464..63f547865 100644 --- a/src/lib/krb5/krb/srv_rcache.c +++ b/src/lib/krb5/krb/srv_rcache.c @@ -31,9 +31,10 @@ #include krb5_error_code -krb5_get_server_rcache(piece, rcptr) -const krb5_data *piece; -krb5_rcache *rcptr; +krb5_get_server_rcache(context, piece, rcptr) + krb5_context context; + const krb5_data *piece; + krb5_rcache *rcptr; { krb5_rcache rcache = 0; char *cachename = 0; @@ -46,7 +47,7 @@ krb5_rcache *rcptr; if (!rcache) return ENOMEM; - retval = krb5_rc_resolve_type(&rcache, "dfl"); + retval = krb5_rc_resolve_type(context, &rcache, "dfl"); if (retval) goto cleanup; len = piece->length + 3 + 1; @@ -81,16 +82,16 @@ krb5_rcache *rcptr; } cachename[p++] = '\0'; - if (retval = krb5_rc_resolve(rcache, cachename)) + if (retval = krb5_rc_resolve(context, rcache, cachename)) goto cleanup; /* * First try to recover the replay cache; if that doesn't work, * initialize it. */ - if (krb5_rc_recover(rcache)) { - if (retval = krb5_rc_initialize(rcache, krb5_clockskew)) { - krb5_rc_close(rcache); + if (krb5_rc_recover(context, rcache)) { + if (retval = krb5_rc_initialize(context, rcache, krb5_clockskew)) { + krb5_rc_close(context, rcache); rcache = 0; goto cleanup; } diff --git a/src/lib/krb5/krb/t_walk_rtree.c b/src/lib/krb5/krb/t_walk_rtree.c index b033b36cb..e1ced303c 100644 --- a/src/lib/krb5/krb/t_walk_rtree.c +++ b/src/lib/krb5/krb/t_walk_rtree.c @@ -17,7 +17,7 @@ main(argc, argv) char *name; krb5_error_code retval; - krb5_init_ets(); + krb5_init_ets(context); if (argc < 3 && argc > 4) { fprintf(stderr, @@ -34,7 +34,7 @@ main(argc, argv) if (argc == 4) realm_branch_char = argv[3][0]; - retval = krb5_walk_realm_tree(&client, &server, &tree, + retval = krb5_walk_realm_tree(context, &client, &server, &tree, realm_branch_char); if (retval) { com_err("krb5_walk_realm_tree", retval, ""); @@ -42,7 +42,7 @@ main(argc, argv) } for (p = tree; *p; p++) { - retval = krb5_unparse_name(*p, &name); + retval = krb5_unparse_name(context, *p, &name); if (retval) { com_err("krb5_unprase_name", retval, ""); exit(2); @@ -51,7 +51,7 @@ main(argc, argv) free(name); } - krb5_free_realm_tree(tree); + krb5_free_realm_tree(context, tree); exit(0); } diff --git a/src/lib/krb5/krb/tgtname.c b/src/lib/krb5/krb/tgtname.c index b0a2b56d1..7b342a1b8 100644 --- a/src/lib/krb5/krb/tgtname.c +++ b/src/lib/krb5/krb/tgtname.c @@ -31,11 +31,12 @@ /* This is an internal-only function, used by krb5_get_cred_from_kdc() */ krb5_error_code -krb5_tgtname(server, client, tgtprinc) -const krb5_data *server, *client; -krb5_principal *tgtprinc; +krb5_tgtname(context, server, client, tgtprinc) + krb5_context context; + const krb5_data *server, *client; + krb5_principal *tgtprinc; { - return krb5_build_principal_ext(tgtprinc, client->length, client->data, + return krb5_build_principal_ext(context, tgtprinc, client->length, client->data, KRB5_TGS_NAME_SIZE, KRB5_TGS_NAME, server->length, server->data, 0); diff --git a/src/lib/krb5/krb/unparse.c b/src/lib/krb5/krb/unparse.c index 39380ef20..7c29f84ba 100644 --- a/src/lib/krb5/krb/unparse.c +++ b/src/lib/krb5/krb/unparse.c @@ -56,18 +56,19 @@ #define COMPONENT_SEP '/' krb5_error_code -krb5_unparse_name_ext(principal, name, size) -krb5_const_principal principal; -register char **name; -int *size; +krb5_unparse_name_ext(context, principal, name, size) + krb5_context context; + krb5_const_principal principal; + register char **name; + int *size; { register char *cp, *q; register int i,j; int length, nelem; register int totalsize = 0; - cp = krb5_princ_realm(principal)->data; - length = krb5_princ_realm(principal)->length; + cp = krb5_princ_realm(context, principal)->data; + length = krb5_princ_realm(context, principal)->length; totalsize += length; for (j = 0; j < length; j++,cp++) if (*cp == REALM_SEP || *cp == COMPONENT_SEP || @@ -76,10 +77,10 @@ int *size; totalsize++; totalsize++; /* This is for the separator */ - nelem = krb5_princ_size(principal); + nelem = krb5_princ_size(context, principal); for (i = 0; i < nelem; i++) { - cp = krb5_princ_component(principal, i)->data; - length = krb5_princ_component(principal, i)->length; + cp = krb5_princ_component(context, principal, i)->data; + length = krb5_princ_component(context, principal, i)->length; totalsize += length; for (j=0; j < length; j++,cp++) if (*cp == REALM_SEP || *cp == COMPONENT_SEP || @@ -113,8 +114,8 @@ int *size; q = *name; for (i = 0; i < nelem; i++) { - cp = krb5_princ_component(principal, i)->data; - length = krb5_princ_component(principal, i)->length; + cp = krb5_princ_component(context, principal, i)->data; + length = krb5_princ_component(context, principal, i)->length; for (j=0; j < length; j++,cp++) { switch (*cp) { case COMPONENT_SEP: @@ -149,8 +150,8 @@ int *size; q--; /* Back up last component separator */ *q++ = REALM_SEP; - cp = krb5_princ_realm(principal)->data; - length = krb5_princ_realm(principal)->length; + cp = krb5_princ_realm(context, principal)->data; + length = krb5_princ_realm(context, principal)->length; for (j=0; j < length; j++,cp++) { switch (*cp) { case COMPONENT_SEP: @@ -174,12 +175,13 @@ int *size; } krb5_error_code -krb5_unparse_name(principal, name) -krb5_const_principal principal; -register char **name; +krb5_unparse_name(context, principal, name) + krb5_context context; + krb5_const_principal principal; + register char **name; { *name = NULL; - return(krb5_unparse_name_ext(principal, name, NULL)); + return(krb5_unparse_name_ext(context, principal, name, NULL)); } diff --git a/src/lib/krb5/krb/walk_rtree.c b/src/lib/krb5/krb/walk_rtree.c index 0890f94d8..c3170d200 100644 --- a/src/lib/krb5/krb/walk_rtree.c +++ b/src/lib/krb5/krb/walk_rtree.c @@ -37,15 +37,10 @@ #endif krb5_error_code -#ifdef NARROW_PROTOTYPES -krb5_walk_realm_tree(const krb5_data *client, const krb5_data *server, - krb5_principal **tree, char realm_branch_char) -#else -krb5_walk_realm_tree(client, server, tree, realm_branch_char) -const krb5_data *client, *server; -krb5_principal **tree; -char realm_branch_char; -#endif +krb5_walk_realm_tree(context, client, server, tree, realm_branch_char) + krb5_context context; + const krb5_data *client, *server; + krb5_principal **tree; { krb5_error_code retval; krb5_principal *rettree; @@ -135,7 +130,7 @@ char realm_branch_char; return ENOMEM; } i = 1; - if (retval = krb5_tgtname(client, + if (retval = krb5_tgtname(context, client, client, &rettree[0])) { krb5_xfree(rettree); return retval; @@ -152,9 +147,9 @@ char realm_branch_char; tmpsrealm.data = ccp; tmpsrealm.length = client->length - (ccp - client->data); - if (retval = krb5_tgtname(&tmpsrealm, &tmpcrealm, &rettree[i])) { + if (retval = krb5_tgtname(context, &tmpsrealm, &tmpcrealm, &rettree[i])) { while (i) { - krb5_free_principal(rettree[i-1]); + krb5_free_principal(context, rettree[i-1]); i--; } krb5_xfree(rettree); @@ -170,9 +165,9 @@ char realm_branch_char; tmpsrealm.data = com_sdot + 1; tmpsrealm.length = server->length - (com_sdot + 1 - server->data); - if (retval = krb5_tgtname(&tmpsrealm, &tmpcrealm, &rettree[i])) { + if (retval = krb5_tgtname(context, &tmpsrealm, &tmpcrealm, &rettree[i])) { while (i) { - krb5_free_principal(rettree[i-1]); + krb5_free_principal(context, rettree[i-1]); i--; } krb5_xfree(rettree); @@ -194,9 +189,9 @@ char realm_branch_char; tmpsrealm.data = scp + 1; tmpsrealm.length = server->length - (scp + 1 - server->data); - if (retval = krb5_tgtname(&tmpsrealm, &tmpcrealm, &rettree[i])) { + if (retval = krb5_tgtname(context, &tmpsrealm, &tmpcrealm, &rettree[i])) { while (i) { - krb5_free_principal(rettree[i-1]); + krb5_free_principal(context, rettree[i-1]); i--; } krb5_xfree(rettree); @@ -213,10 +208,10 @@ char realm_branch_char; tmpcrealm.data = prevscp; tmpcrealm.length = server->length - (prevscp - server->data); - if (retval = krb5_tgtname(server, &tmpcrealm, + if (retval = krb5_tgtname(context, server, &tmpcrealm, &rettree[i])) { while (i) { - krb5_free_principal(rettree[i-1]); + krb5_free_principal(context, rettree[i-1]); i--; } krb5_xfree(rettree);