From 6c54cd4356478f300fb057a3e43b60b4884387fe Mon Sep 17 00:00:00 2001 From: Chris Provenzano Date: Fri, 13 Jan 1995 21:30:09 +0000 Subject: [PATCH] Removed all references to DECLARG and OLDDECLARG. Added krb5_context to all krb5_routines. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@4812 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/rcache/ChangeLog | 4 + src/lib/krb5/rcache/rc_base.c | 53 ++++++------ src/lib/krb5/rcache/rc_conv.c | 13 +-- src/lib/krb5/rcache/rc_dfl.c | 153 +++++++++++++++++++--------------- src/lib/krb5/rcache/rc_dfl.h | 40 +++++++-- src/lib/krb5/rcache/rc_io.c | 72 +++++++++------- src/lib/krb5/rcache/rc_io.h | 43 ++++++++-- 7 files changed, 228 insertions(+), 150 deletions(-) diff --git a/src/lib/krb5/rcache/ChangeLog b/src/lib/krb5/rcache/ChangeLog index 2bfee3f04..6fd18161c 100644 --- a/src/lib/krb5/rcache/ChangeLog +++ b/src/lib/krb5/rcache/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 Dec 22 15:44:50 1994 Theodore Y. Ts'o (tytso@dcl) * configure.in: Add test for uid_t. diff --git a/src/lib/krb5/rcache/rc_base.c b/src/lib/krb5/rcache/rc_base.c index 2324b3565..e0ff8d0c4 100644 --- a/src/lib/krb5/rcache/rc_base.c +++ b/src/lib/krb5/rcache/rc_base.c @@ -30,8 +30,9 @@ static struct krb5_rc_typelist *typehead = &krb5_rc_typelist_dfl; semaphore ex_typelist = 1; #endif -krb5_error_code krb5_rc_register_type(ops) -krb5_rc_ops *ops; +krb5_error_code krb5_rc_register_type(context, ops) + krb5_context context; + krb5_rc_ops *ops; { struct krb5_rc_typelist *t; #ifdef SEMAPHORE @@ -58,9 +59,10 @@ krb5_rc_ops *ops; return 0; } -krb5_error_code krb5_rc_resolve_type(id, type) -krb5_rcache *id; -char *type; +krb5_error_code krb5_rc_resolve_type(context, id, type) + krb5_context context; + krb5_rcache *id; + char *type; { struct krb5_rc_typelist *t; #ifdef SEMAPHORE @@ -78,17 +80,15 @@ char *type; return 0; } -char *krb5_rc_get_type(id) -krb5_rcache id; +char *krb5_rc_get_type(context, id) + krb5_context context; + krb5_rcache id; { return id->ops->type; } -#ifdef __STDC__ -char *krb5_rc_default_type(void) -#else -char *krb5_rc_default_type() -#endif +char *krb5_rc_default_type(context) + krb5_context context; { char *s; if (s = getenv("KRB5RCACHETYPE")) @@ -97,11 +97,8 @@ char *krb5_rc_default_type() return "dfl"; } -#ifdef __STDC__ -char *krb5_rc_default_name(void) -#else -char *krb5_rc_default_name() -#endif +char *krb5_rc_default_name(context) + krb5_context context; { char *s; if (s = getenv("KRB5RCACHENAME")) @@ -111,27 +108,31 @@ char *krb5_rc_default_name() } krb5_error_code -krb5_rc_default(id) -krb5_rcache *id; +krb5_rc_default(context, id) + krb5_context context; + krb5_rcache *id; { krb5_error_code retval; if (!(*id = (krb5_rcache )malloc(sizeof(**id)))) return KRB5_RC_MALLOC; - if (retval = krb5_rc_resolve_type(id, krb5_rc_default_type())) { + if (retval = krb5_rc_resolve_type(context, id, + krb5_rc_default_type(context))) { FREE(*id); return retval; } - if (retval = krb5_rc_resolve(*id, krb5_rc_default_name())) + if (retval = krb5_rc_resolve(context, *id, + krb5_rc_default_name(context))) FREE(*id); return retval; } -krb5_error_code krb5_rc_resolve_full(id, string_name) -krb5_rcache *id; -char *string_name; +krb5_error_code krb5_rc_resolve_full(context, id, string_name) + krb5_context context; + krb5_rcache *id; + char *string_name; { char *type; char *residual; @@ -150,13 +151,13 @@ char *string_name; return KRB5_RC_MALLOC; } - if (retval = krb5_rc_resolve_type(id,type)) { + if (retval = krb5_rc_resolve_type(context, id,type)) { FREE(type); FREE(*id); return retval; } FREE(type); - if (retval = krb5_rc_resolve(*id,residual + 1)) + if (retval = krb5_rc_resolve(context, *id,residual + 1)) FREE(*id); return retval; } diff --git a/src/lib/krb5/rcache/rc_conv.c b/src/lib/krb5/rcache/rc_conv.c index 74e070b0a..92cf77f8d 100644 --- a/src/lib/krb5/rcache/rc_conv.c +++ b/src/lib/krb5/rcache/rc_conv.c @@ -17,21 +17,22 @@ /* Local stuff: - krb5_auth_to_replay(krb5_tkt_authent *auth,krb5_donot_replay *rep) + krb5_auth_to_replay(context, krb5_tkt_authent *auth,krb5_donot_replay *rep) given auth, take important information and make rep; return -1 if failed */ krb5_error_code -krb5_auth_to_rep(auth, rep) -krb5_tkt_authent *auth; -krb5_donot_replay *rep; +krb5_auth_to_rep(context, auth, rep) + krb5_context context; + krb5_tkt_authent *auth; + krb5_donot_replay *rep; { krb5_error_code retval; rep->cusec = auth->authenticator->cusec; rep->ctime = auth->authenticator->ctime; - if (retval = krb5_unparse_name(auth->ticket->server,&rep->server)) + if (retval = krb5_unparse_name(context, auth->ticket->server,&rep->server)) return retval; /* shouldn't happen */ - if (retval = krb5_unparse_name(auth->authenticator->client,&rep->client)) { + if (retval = krb5_unparse_name(context, auth->authenticator->client,&rep->client)) { FREE(rep->server); return retval; /* shouldn't happen. */ } diff --git a/src/lib/krb5/rcache/rc_dfl.c b/src/lib/krb5/rcache/rc_dfl.c index 51c6a80e8..d1fae953b 100644 --- a/src/lib/krb5/rcache/rc_dfl.c +++ b/src/lib/krb5/rcache/rc_dfl.c @@ -29,7 +29,7 @@ HASHSIZE size of hash table (constant), can be preset static int cmp(krb5_donot_replay *old,krb5_donot_replay *new,krb5_deltat t) compare old and new; return CMP_REPLAY or CMP_HOHUM -static int alive(krb5_donot_replay *new,krb5_deltat t) +static int alive (krb5_context, krb5_donot_replay *new,krb5_deltat t) see if new is still alive; return CMP_EXPIRED or CMP_HOHUM CMP_MALLOC, CMP_EXPIRED, CMP_REPLAY, CMP_HOHUM return codes from cmp(), alive(), and store() @@ -37,7 +37,7 @@ struct dfl_data data stored in this cache type, namely "dfl" struct authlist multilinked list of reps -static int store(krb5_rcache id,krb5_donot_replay *rep) +static int store(context, krb5_rcache id,krb5_donot_replay *rep) store rep in cache id; return CMP_REPLAY if replay, else CMP_MALLOC/CMP_HOHUM */ @@ -84,13 +84,14 @@ krb5_deltat t; return CMP_HOHUM; } -static int alive(new, t) -krb5_donot_replay *new; -krb5_deltat t; +static int alive(context, new, t) + krb5_context context; + krb5_donot_replay *new; + krb5_deltat t; { krb5_int32 time; - if (krb5_timeofday(&time)) + if (krb5_timeofday(context, &time)) return CMP_HOHUM; /* who cares? */ if (new->ctime + t < time) /* I hope we don't have to worry about overflow */ return CMP_EXPIRED; @@ -123,9 +124,10 @@ struct authlist /* of course, list is backwards from file */ /* hash could be forwards since we have to search on match, but naaaah */ -static int store(id, rep) -krb5_rcache id; -krb5_donot_replay *rep; +static int store(context, id, rep) + krb5_context context; + krb5_rcache id; + krb5_donot_replay *rep; { struct dfl_data *t = (struct dfl_data *)id->data; int rephash; @@ -137,7 +139,7 @@ krb5_donot_replay *rep; switch(cmp(&ta->rep,rep,t->lifespan)) { case CMP_REPLAY: return CMP_REPLAY; - case CMP_HOHUM: if (alive(&ta->rep,t->lifespan) == CMP_EXPIRED) + case CMP_HOHUM: if (alive(context, &ta->rep,t->lifespan) == CMP_EXPIRED) t->nummisses++; else t->numhits++; @@ -163,21 +165,24 @@ krb5_donot_replay *rep; return CMP_HOHUM; } -char *krb5_rc_dfl_get_name(id) -krb5_rcache id; +char *krb5_rc_dfl_get_name(context, id) + krb5_context context; + krb5_rcache id; { return ((struct dfl_data *) (id->data))->name; } -krb5_error_code krb5_rc_dfl_get_span(id, lifespan) -krb5_rcache id; -krb5_deltat *lifespan; +krb5_error_code krb5_rc_dfl_get_span(context, id, lifespan) + krb5_context context; + krb5_rcache id; + krb5_deltat *lifespan; { *lifespan = ((struct dfl_data *) (id->data))->lifespan; return 0; } -krb5_error_code krb5_rc_dfl_init(id, lifespan) +krb5_error_code krb5_rc_dfl_init(context, id, lifespan) + krb5_context context; krb5_rcache id; krb5_deltat lifespan; { @@ -186,17 +191,18 @@ krb5_deltat lifespan; t->lifespan = lifespan; #ifndef NOIOSTUFF - if (retval = krb5_rc_io_creat(&t->d,&t->name)) + if (retval = krb5_rc_io_creat(context, &t->d,&t->name)) return retval; - if (krb5_rc_io_write(&t->d,(krb5_pointer) &t->lifespan,sizeof(t->lifespan)) - || krb5_rc_io_sync(&t->d)) + if (krb5_rc_io_write(context, &t->d,(krb5_pointer) &t->lifespan,sizeof(t->lifespan)) + || krb5_rc_io_sync(context, &t->d)) return KRB5_RC_IO; #endif return 0; } -krb5_error_code krb5_rc_dfl_close_no_free(id) -krb5_rcache id; +krb5_error_code krb5_rc_dfl_close_no_free(context, id) + krb5_context context; + krb5_rcache id; { struct dfl_data *t = (struct dfl_data *)id->data; struct authlist *q; @@ -213,33 +219,36 @@ krb5_rcache id; } #ifndef NOIOSTUFF if (t->d.fd >= 0) - (void) krb5_rc_io_close(&t->d); + (void) krb5_rc_io_close(context, &t->d); #endif FREE(t); return 0; } -krb5_error_code krb5_rc_dfl_close(id) -krb5_rcache id; +krb5_error_code krb5_rc_dfl_close(context, id) + krb5_context context; + krb5_rcache id; { - krb5_rc_dfl_close_no_free(id); + krb5_rc_dfl_close_no_free(context, id); free(id); return 0; } -krb5_error_code krb5_rc_dfl_destroy(id) +krb5_error_code krb5_rc_dfl_destroy(context, id) + krb5_context context; krb5_rcache id; { #ifndef NOIOSTUFF - if (krb5_rc_io_destroy(&((struct dfl_data *) (id->data))->d)) + if (krb5_rc_io_destroy(context, &((struct dfl_data *) (id->data))->d)) return KRB5_RC_IO; #endif - return krb5_rc_dfl_close(id); + return krb5_rc_dfl_close(context, id); } -krb5_error_code krb5_rc_dfl_resolve(id, name) -krb5_rcache id; -char *name; +krb5_error_code krb5_rc_dfl_resolve(context, id, name) + krb5_context context; + krb5_rcache id; + char *name; { struct dfl_data *t = 0; krb5_error_code retval; @@ -283,7 +292,8 @@ cleanup: return retval; } -void krb5_rc_free_entry (rep) +void krb5_rc_free_entry (context, rep) + krb5_context context; krb5_donot_replay **rep; { krb5_donot_replay *rp = *rep; @@ -302,7 +312,8 @@ void krb5_rc_free_entry (rep) } } -krb5_error_code krb5_rc_io_fetch(t, rep, maxlen) +krb5_error_code krb5_rc_io_fetch(context, t, rep, maxlen) + krb5_context context; struct dfl_data *t; krb5_donot_replay *rep; int maxlen; @@ -312,7 +323,7 @@ krb5_error_code krb5_rc_io_fetch(t, rep, maxlen) rep->client = rep->server = 0; - retval = krb5_rc_io_read (&t->d, (krb5_pointer) &len, sizeof(len)); + retval = krb5_rc_io_read (context, &t->d, (krb5_pointer) &len, sizeof(len)); if (retval) return retval; @@ -323,11 +334,11 @@ krb5_error_code krb5_rc_io_fetch(t, rep, maxlen) if (!rep->client) return KRB5_RC_MALLOC; - retval = krb5_rc_io_read (&t->d, (krb5_pointer) rep->client, len); + retval = krb5_rc_io_read (context, &t->d, (krb5_pointer) rep->client, len); if (retval) goto errout; - retval = krb5_rc_io_read (&t->d, (krb5_pointer) &len, sizeof(len)); + retval = krb5_rc_io_read (context, &t->d, (krb5_pointer) &len, sizeof(len)); if (retval) goto errout; @@ -342,15 +353,15 @@ krb5_error_code krb5_rc_io_fetch(t, rep, maxlen) goto errout; } - retval = krb5_rc_io_read (&t->d, (krb5_pointer) rep->server, len); + retval = krb5_rc_io_read (context, &t->d, (krb5_pointer) rep->server, len); if (retval) goto errout; - retval = krb5_rc_io_read (&t->d, (krb5_pointer) &rep->cusec, sizeof(rep->cusec)); + retval = krb5_rc_io_read (context, &t->d, (krb5_pointer) &rep->cusec, sizeof(rep->cusec)); if (retval) goto errout; - retval = krb5_rc_io_read (&t->d, (krb5_pointer) &rep->ctime, sizeof(rep->ctime)); + retval = krb5_rc_io_read (context, &t->d, (krb5_pointer) &rep->ctime, sizeof(rep->ctime)); if (retval) goto errout; @@ -366,7 +377,8 @@ errout: -krb5_error_code krb5_rc_dfl_recover(id) +krb5_error_code krb5_rc_dfl_recover(context, id) + krb5_context context; krb5_rcache id; { #ifdef NOIOSTUFF @@ -378,13 +390,13 @@ krb5_rcache id; krb5_error_code retval; int max_size; - if (retval = krb5_rc_io_open(&t->d,t->name)) + if (retval = krb5_rc_io_open(context, &t->d,t->name)) return retval; - max_size = krb5_rc_io_size(&t->d); + max_size = krb5_rc_io_size(context, &t->d); rep = NULL; - if (krb5_rc_io_read(&t->d,(krb5_pointer) &t->lifespan,sizeof(t->lifespan))) { + if (krb5_rc_io_read(context, &t->d,(krb5_pointer) &t->lifespan,sizeof(t->lifespan))) { retval = KRB5_RC_IO; goto io_fail; } @@ -392,7 +404,7 @@ krb5_rcache id; /* now read in each auth_replay and insert into table */ for (;;) { rep = NULL; - if (krb5_rc_io_mark(&t->d)) { + if (krb5_rc_io_mark(context, &t->d)) { retval = KRB5_RC_IO; goto io_fail; } @@ -404,7 +416,7 @@ krb5_rcache id; rep->client = NULL; rep->server = NULL; - retval = krb5_rc_io_fetch (t, rep, max_size); + retval = krb5_rc_io_fetch (context, t, rep, max_size); if (retval == KRB5_RC_IO_EOF) break; @@ -412,12 +424,12 @@ krb5_rcache id; goto io_fail; - if (alive(rep,t->lifespan) == CMP_EXPIRED) { - krb5_rc_free_entry(&rep); + if (alive(context, rep,t->lifespan) == CMP_EXPIRED) { + krb5_rc_free_entry(context, &rep); continue; } - if (store(id,rep) == CMP_MALLOC) {/* can't be a replay */ + if (store(context, id,rep) == CMP_MALLOC) {/* can't be a replay */ retval = KRB5_RC_MALLOC; goto io_fail; } /* @@ -430,21 +442,22 @@ krb5_rcache id; rep = NULL; } retval = 0; - krb5_rc_io_unmark(&t->d); + krb5_rc_io_unmark(context, &t->d); /* * An automatic expunge here could remove the need for * mark/unmark but that would be inefficient. */ io_fail: - krb5_rc_free_entry(&rep); + krb5_rc_free_entry(context, &rep); if (retval) - krb5_rc_io_close(&t->d); + krb5_rc_io_close(context, &t->d); return retval; #endif } -krb5_error_code krb5_rc_io_store (t, rep) +krb5_error_code krb5_rc_io_store (context, t, rep) + krb5_context context; struct dfl_data *t; krb5_donot_replay *rep; { @@ -467,19 +480,20 @@ krb5_error_code krb5_rc_io_store (t, rep) memcpy(ptr, &rep->cusec, sizeof(rep->cusec)); ptr += sizeof(rep->cusec); memcpy(ptr, &rep->ctime, sizeof(rep->ctime)); ptr += sizeof(rep->ctime); - ret = krb5_rc_io_write(&t->d, buf, len); + ret = krb5_rc_io_write(context, &t->d, buf, len); free(buf); return ret; } -krb5_error_code krb5_rc_dfl_store(id, rep) +krb5_error_code krb5_rc_dfl_store(context, id, rep) + krb5_context context; krb5_rcache id; krb5_donot_replay *rep; { unsigned long ret; struct dfl_data *t = (struct dfl_data *)id->data; - switch(store(id,rep)) { + switch(store(context, id,rep)) { case CMP_MALLOC: return KRB5_RC_MALLOC; case CMP_REPLAY: @@ -488,26 +502,27 @@ krb5_donot_replay *rep; default: /* wtf? */ ; } #ifndef NOIOSTUFF - ret = krb5_rc_io_store (t, rep); + ret = krb5_rc_io_store (context, t, rep); if (ret) return ret; #endif /* Shall we automatically expunge? */ if (t->nummisses > t->numhits + EXCESSREPS) { - return krb5_rc_dfl_expunge(id); + return krb5_rc_dfl_expunge(context, id); } #ifndef NOIOSTUFF else { - if (krb5_rc_io_sync(&t->d)) + if (krb5_rc_io_sync(context, &t->d)) return KRB5_RC_IO; } #endif return 0; } -krb5_error_code krb5_rc_dfl_expunge(id) +krb5_error_code krb5_rc_dfl_expunge(context, id) + krb5_context context; krb5_rcache id; { struct dfl_data *t = (struct dfl_data *)id->data; @@ -520,7 +535,7 @@ krb5_rcache id; for (q = &t->a;*q;q = qt) { qt = &(*q)->na; - if (alive(&(*q)->rep,t->lifespan) == CMP_EXPIRED) { + if (alive(context, &(*q)->rep,t->lifespan) == CMP_EXPIRED) { FREE((*q)->rep.client); FREE((*q)->rep.server); FREE(*q); @@ -545,34 +560,34 @@ krb5_rcache id; name = t->name; t->name = 0; /* Clear name so it isn't freed */ - (void) krb5_rc_dfl_close_no_free(id); - retval = krb5_rc_dfl_resolve(id, name); + (void) krb5_rc_dfl_close_no_free(context, id); + retval = krb5_rc_dfl_resolve(context, id, name); free(name); if (retval) return retval; - retval = krb5_rc_dfl_recover(id); + retval = krb5_rc_dfl_recover(context, id); if (retval) return retval; t = (struct dfl_data *)id->data; /* point to recovered cache */ tmp = (krb5_rcache) malloc(sizeof(*tmp)); if (!tmp) return ENOMEM; - retval = krb5_rc_resolve_type(&tmp, "dfl"); + retval = krb5_rc_resolve_type(context, &tmp, "dfl"); if (retval) return retval; - retval = krb5_rc_resolve(tmp, 0); + retval = krb5_rc_resolve(context, tmp, 0); if (retval) return retval; - retval = krb5_rc_initialize(tmp, lifespan); + retval = krb5_rc_initialize(context, tmp, lifespan); if (retval) return retval; for (q = t->a;q;q = q->na) { - if (krb5_rc_io_store ((struct dfl_data *)tmp->data, &q->rep)) + if (krb5_rc_io_store (context, (struct dfl_data *)tmp->data, &q->rep)) return KRB5_RC_IO; } - if (krb5_rc_io_sync(&t->d)) + if (krb5_rc_io_sync(context, &t->d)) return KRB5_RC_IO; - if (krb5_rc_io_move(&t->d, &((struct dfl_data *)tmp->data)->d)) + if (krb5_rc_io_move(context, &t->d, &((struct dfl_data *)tmp->data)->d)) return KRB5_RC_IO; #endif return 0; diff --git a/src/lib/krb5/rcache/rc_dfl.h b/src/lib/krb5/rcache/rc_dfl.h index 4e22b6269..76e0e58cd 100644 --- a/src/lib/krb5/rcache/rc_dfl.h +++ b/src/lib/krb5/rcache/rc_dfl.h @@ -15,14 +15,36 @@ extern krb5_rc_ops krb5_rc_dfl_ops; /* initialized to the following */ -krb5_error_code krb5_rc_dfl_init PROTOTYPE((krb5_rcache,krb5_deltat)); -krb5_error_code krb5_rc_dfl_recover PROTOTYPE((krb5_rcache)); -krb5_error_code krb5_rc_dfl_destroy PROTOTYPE((krb5_rcache)); -krb5_error_code krb5_rc_dfl_close PROTOTYPE((krb5_rcache)); -krb5_error_code krb5_rc_dfl_store PROTOTYPE((krb5_rcache,krb5_donot_replay *)); -krb5_error_code krb5_rc_dfl_expunge PROTOTYPE((krb5_rcache)); -krb5_error_code krb5_rc_dfl_get_span PROTOTYPE((krb5_rcache,krb5_deltat *)); -char *krb5_rc_dfl_get_name PROTOTYPE((krb5_rcache)); -krb5_error_code krb5_rc_dfl_resolve PROTOTYPE((krb5_rcache,char *)); +krb5_error_code krb5_rc_dfl_init + PROTOTYPE((krb5_context, + krb5_rcache, + krb5_deltat)); +krb5_error_code krb5_rc_dfl_recover + PROTOTYPE((krb5_context, + krb5_rcache)); +krb5_error_code krb5_rc_dfl_destroy + PROTOTYPE((krb5_context, + krb5_rcache)); +krb5_error_code krb5_rc_dfl_close + PROTOTYPE((krb5_context, + krb5_rcache)); +krb5_error_code krb5_rc_dfl_store + PROTOTYPE((krb5_context, + krb5_rcache, + krb5_donot_replay *)); +krb5_error_code krb5_rc_dfl_expunge + PROTOTYPE((krb5_context, + krb5_rcache)); +krb5_error_code krb5_rc_dfl_get_span + PROTOTYPE((krb5_context, + krb5_rcache, + krb5_deltat *)); +char *krb5_rc_dfl_get_name + PROTOTYPE((krb5_context, + krb5_rcache)); +krb5_error_code krb5_rc_dfl_resolve + PROTOTYPE((krb5_context, + krb5_rcache, + char *)); #endif diff --git a/src/lib/krb5/rcache/rc_io.c b/src/lib/krb5/rcache/rc_io.c index 5659b85f3..efe2f66b0 100644 --- a/src/lib/krb5/rcache/rc_io.c +++ b/src/lib/krb5/rcache/rc_io.c @@ -57,9 +57,10 @@ static void getdir() } } -krb5_error_code krb5_rc_io_creat (d, fn) -krb5_rc_iostuff *d; -char **fn; +krb5_error_code krb5_rc_io_creat (context, d, fn) + krb5_context context; + krb5_rc_iostuff *d; + char **fn; { char *c; krb5_int16 rc_vno = htons(KRB5_RC_VNO); @@ -127,8 +128,8 @@ char **fn; retval = KRB5_RC_IO_UNKNOWN; goto fail; } } - if ((retval = krb5_rc_io_write(d, (krb5_pointer)&rc_vno, sizeof(rc_vno))) || - (retval = krb5_rc_io_sync(d))) + if ((retval = krb5_rc_io_write(context, d, (krb5_pointer)&rc_vno, sizeof(rc_vno))) || + (retval = krb5_rc_io_sync(context, d))) { fail: (void) unlink(d->fn); @@ -140,9 +141,10 @@ char **fn; return 0; } -krb5_error_code krb5_rc_io_open (d, fn) -krb5_rc_iostuff *d; -char *fn; +krb5_error_code krb5_rc_io_open (context, d, fn) + krb5_context context; + krb5_rc_iostuff *d; + char *fn; { krb5_int16 rc_vno; krb5_error_code retval; @@ -192,7 +194,7 @@ char *fn; goto fail; } } - if (retval = krb5_rc_io_read(d, (krb5_pointer) &rc_vno, sizeof(rc_vno))) + if (retval = krb5_rc_io_read(context, d, (krb5_pointer) &rc_vno, sizeof(rc_vno))) goto unlk; @@ -210,22 +212,24 @@ char *fn; return 0; } -krb5_error_code krb5_rc_io_move (new, old) -krb5_rc_iostuff *new; -krb5_rc_iostuff *old; +krb5_error_code krb5_rc_io_move (context, new, old) + krb5_context context; + krb5_rc_iostuff *new; + krb5_rc_iostuff *old; { if (rename(old->fn,new->fn) == -1) /* MUST be atomic! */ return KRB5_RC_IO_UNKNOWN; - (void) krb5_rc_io_close(new); + (void) krb5_rc_io_close(context, new); new->fn = old->fn; new->fd = old->fd; return 0; } -krb5_error_code krb5_rc_io_write (d, buf, num) -krb5_rc_iostuff *d; -krb5_pointer buf; -int num; +krb5_error_code krb5_rc_io_write (context, d, buf, num) + krb5_context context; + krb5_rc_iostuff *d; + krb5_pointer buf; + int num; { if (write(d->fd,(char *) buf,num) == -1) switch(errno) @@ -242,7 +246,8 @@ int num; return 0; } -krb5_error_code krb5_rc_io_sync (d) +krb5_error_code krb5_rc_io_sync (context, d) + krb5_context context; krb5_rc_iostuff *d; { if (fsync(d->fd) == -1) { @@ -256,10 +261,11 @@ krb5_error_code krb5_rc_io_sync (d) return 0; } -krb5_error_code krb5_rc_io_read (d, buf, num) -krb5_rc_iostuff *d; -krb5_pointer buf; -int num; +krb5_error_code krb5_rc_io_read (context, d, buf, num) + krb5_context context; + krb5_rc_iostuff *d; + krb5_pointer buf; + int num; { int count; if ((count = read(d->fd,(char *) buf,num)) == -1) @@ -274,8 +280,9 @@ int num; return 0; } -krb5_error_code krb5_rc_io_close (d) -krb5_rc_iostuff *d; +krb5_error_code krb5_rc_io_close (context, d) + krb5_context context; + krb5_rc_iostuff *d; { FREE(d->fn); d->fn = NULL; @@ -284,8 +291,9 @@ krb5_rc_iostuff *d; return 0; } -krb5_error_code krb5_rc_io_destroy (d) -krb5_rc_iostuff *d; +krb5_error_code krb5_rc_io_destroy (context, d) + krb5_context context; + krb5_rc_iostuff *d; { if (unlink(d->fn) == -1) switch(errno) @@ -300,21 +308,23 @@ krb5_rc_iostuff *d; return 0; } -krb5_error_code krb5_rc_io_mark (d) -krb5_rc_iostuff *d; +krb5_error_code krb5_rc_io_mark (context, d) + krb5_context context; + krb5_rc_iostuff *d; { d->mark = lseek(d->fd,0,SEEK_CUR); /* can't fail */ return 0; } -krb5_error_code krb5_rc_io_unmark (d) -krb5_rc_iostuff *d; +krb5_error_code krb5_rc_io_unmark (context, d) + krb5_context context; + krb5_rc_iostuff *d; { (void) lseek(d->fd,d->mark,SEEK_SET); /* if it fails, tough luck */ return 0; } -int krb5_rc_io_size (d) +int krb5_rc_io_size (context, d) krb5_rc_iostuff *d; { struct stat statb; diff --git a/src/lib/krb5/rcache/rc_io.h b/src/lib/krb5/rcache/rc_io.h index b0d2b1adb..249aa674d 100644 --- a/src/lib/krb5/rcache/rc_io.h +++ b/src/lib/krb5/rcache/rc_io.h @@ -24,14 +24,39 @@ krb5_rc_iostuff; /* first argument is always iostuff for result file */ -krb5_error_code krb5_rc_io_creat PROTOTYPE((krb5_rc_iostuff *,char **)); -krb5_error_code krb5_rc_io_open PROTOTYPE((krb5_rc_iostuff *,char *)); -krb5_error_code krb5_rc_io_move PROTOTYPE((krb5_rc_iostuff *,krb5_rc_iostuff *)); -krb5_error_code krb5_rc_io_write PROTOTYPE((krb5_rc_iostuff *,krb5_pointer,int)); -krb5_error_code krb5_rc_io_read PROTOTYPE((krb5_rc_iostuff *,krb5_pointer,int)); -krb5_error_code krb5_rc_io_close PROTOTYPE((krb5_rc_iostuff *)); -krb5_error_code krb5_rc_io_destroy PROTOTYPE((krb5_rc_iostuff *)); -krb5_error_code krb5_rc_io_mark PROTOTYPE((krb5_rc_iostuff *)); -krb5_error_code krb5_rc_io_unmark PROTOTYPE((krb5_rc_iostuff *)); +krb5_error_code krb5_rc_io_creat + PROTOTYPE((krb5_context, + krb5_rc_iostuff *, + char **)); +krb5_error_code krb5_rc_io_open + PROTOTYPE((krb5_context, + krb5_rc_iostuff *, + char *)); +krb5_error_code krb5_rc_io_move + PROTOTYPE((krb5_context, + krb5_rc_iostuff *, + krb5_rc_iostuff *)); +krb5_error_code krb5_rc_io_write + PROTOTYPE((krb5_context, + krb5_rc_iostuff *, + krb5_pointer, + int)); +krb5_error_code krb5_rc_io_read + PROTOTYPE((krb5_context, + krb5_rc_iostuff *, + krb5_pointer, + int)); +krb5_error_code krb5_rc_io_close + PROTOTYPE((krb5_context, + krb5_rc_iostuff *)); +krb5_error_code krb5_rc_io_destroy + PROTOTYPE((krb5_context, + krb5_rc_iostuff *)); +krb5_error_code krb5_rc_io_mark + PROTOTYPE((krb5_context, + krb5_rc_iostuff *)); +krb5_error_code krb5_rc_io_unmark + PROTOTYPE((krb5_context, + krb5_rc_iostuff *)); #endif -- 2.26.2