svn rev #23576: trunk/src/lib/krb5/ krb/ os/
tsitkova@MIT.EDU
tsitkova at MIT.EDU
Mon Jan 4 01:22:41 EST 2010
http://src.mit.edu/fisheye/changelog/krb5/?cs=23576
Commit By: tsitkova
Log Message:
For the better code modularity keep some "free" routines closer to the resource allocators. Also, reindent cleanup in the touched files.
Changed Files:
U trunk/src/lib/krb5/krb/Makefile.in
U trunk/src/lib/krb5/krb/etype_list.c
D trunk/src/lib/krb5/krb/free_rtree.c
U trunk/src/lib/krb5/krb/walk_rtree.c
U trunk/src/lib/krb5/os/Makefile.in
D trunk/src/lib/krb5/os/free_hstrl.c
U trunk/src/lib/krb5/os/hst_realm.c
Modified: trunk/src/lib/krb5/krb/Makefile.in
===================================================================
--- trunk/src/lib/krb5/krb/Makefile.in 2010-01-03 23:41:49 UTC (rev 23575)
+++ trunk/src/lib/krb5/krb/Makefile.in 2010-01-04 06:22:41 UTC (rev 23576)
@@ -42,7 +42,6 @@
encrypt_tk.o \
etype_list.o \
fast.o \
- free_rtree.o \
fwd_tgt.o \
gc_frm_kdc.o \
gc_via_tkt.o \
@@ -137,7 +136,6 @@
$(OUTPRE)encrypt_tk.$(OBJEXT) \
$(OUTPRE)etype_list.$(OBJEXT) \
$(OUTPRE)fast.$(OBJEXT) \
- $(OUTPRE)free_rtree.$(OBJEXT) \
$(OUTPRE)fwd_tgt.$(OBJEXT) \
$(OUTPRE)gc_frm_kdc.$(OBJEXT) \
$(OUTPRE)gc_via_tkt.$(OBJEXT) \
@@ -233,7 +231,6 @@
$(srcdir)/encrypt_tk.c \
$(srcdir)/etype_list.c \
$(srcdir)/fast.c \
- $(srcdir)/free_rtree.c \
$(srcdir)/fwd_tgt.c \
$(srcdir)/gc_frm_kdc.c \
$(srcdir)/gc_via_tkt.c \
@@ -323,7 +320,7 @@
COMERRLIB=$(TOPLIBD)/libcom_err.a
T_WALK_RTREE_OBJS= t_walk_rtree.o walk_rtree.o tgtname.o unparse.o \
- free_rtree.o bld_pr_ext.o copy_data.o
+ bld_pr_ext.o copy_data.o
T_KERB_OBJS= t_kerb.o conv_princ.o unparse.o set_realm.o str_conv.o
Modified: trunk/src/lib/krb5/krb/etype_list.c
===================================================================
--- trunk/src/lib/krb5/krb/etype_list.c 2010-01-03 23:41:49 UTC (rev 23575)
+++ trunk/src/lib/krb5/krb/etype_list.c 2010-01-04 06:22:41 UTC (rev 23576)
@@ -56,4 +56,3 @@
*new_list = list;
return 0;
}
-
Modified: trunk/src/lib/krb5/krb/walk_rtree.c
===================================================================
--- trunk/src/lib/krb5/krb/walk_rtree.c 2010-01-03 23:41:49 UTC (rev 23575)
+++ trunk/src/lib/krb5/krb/walk_rtree.c 2010-01-04 06:22:41 UTC (rev 23576)
@@ -25,6 +25,7 @@
* or implied warranty.
*
* krb5_walk_realm_tree()
+ * krb5_free_realm_tree()
*
* internal function, used by krb5_get_cred_from_kdc()
*/
@@ -44,51 +45,45 @@
};
static krb5_error_code
-rtree_capath_tree(
- krb5_context context,
- const krb5_data *client,
- const krb5_data *server,
- char **vals,
- krb5_principal **tree);
+rtree_capath_tree(krb5_context context,
+ const krb5_data *client,
+ const krb5_data *server,
+ char **vals,
+ krb5_principal **tree);
static krb5_error_code
-rtree_capath_vals(
- krb5_context context,
- const krb5_data *client,
- const krb5_data *server,
- char ***vals);
+rtree_capath_vals(krb5_context context,
+ const krb5_data *client,
+ const krb5_data *server,
+ char ***vals);
static krb5_error_code
-rtree_hier_tree(
- krb5_context context,
- const krb5_data *client,
- const krb5_data *server,
- krb5_principal **rettree,
- int sep);
+rtree_hier_tree(krb5_context context,
+ const krb5_data *client,
+ const krb5_data *server,
+ krb5_principal **rettree,
+ int sep);
static krb5_error_code
-rtree_hier_realms(
- krb5_context context,
- const krb5_data *client,
- const krb5_data *server,
- krb5_data **realms,
- size_t *nrealms,
- int sep);
+rtree_hier_realms(krb5_context context,
+ const krb5_data *client,
+ const krb5_data *server,
+ krb5_data **realms,
+ size_t *nrealms,
+ int sep);
static void
-free_realmlist(
- krb5_context context,
- krb5_data *realms,
- size_t nrealms);
+free_realmlist(krb5_context context,
+ krb5_data *realms,
+ size_t nrealms);
static krb5_error_code
-rtree_hier_tweens(
- krb5_context context,
- struct hstate *realm,
- krb5_data **tweens,
- size_t *ntweens,
- int dotail,
- int sep);
+rtree_hier_tweens(krb5_context context,
+ struct hstate *realm,
+ krb5_data **tweens,
+ size_t *ntweens,
+ int dotail,
+ int sep);
static void
adjtail(struct hstate *c, struct hstate *s, int sep);
@@ -97,12 +92,11 @@
comtail(struct hstate *c, struct hstate *s, int sep);
krb5_error_code
-krb5_walk_realm_tree(
- krb5_context context,
- const krb5_data *client,
- const krb5_data *server,
- krb5_principal **tree,
- int realm_sep)
+krb5_walk_realm_tree( krb5_context context,
+ const krb5_data *client,
+ const krb5_data *server,
+ krb5_principal **tree,
+ int realm_sep)
{
krb5_error_code retval = 0;
char **capvals;
@@ -188,12 +182,11 @@
* walk_rtree_capath_vals().
*/
static krb5_error_code
-rtree_capath_tree(
- krb5_context context,
- const krb5_data *client,
- const krb5_data *server,
- char **vals,
- krb5_principal **rettree)
+rtree_capath_tree(krb5_context context,
+ const krb5_data *client,
+ const krb5_data *server,
+ char **vals,
+ krb5_principal **rettree)
{
krb5_error_code retval = 0;
unsigned int nvals, nlinks, nprincs, i;
@@ -253,11 +246,10 @@
* by not finding anything.
*/
static krb5_error_code
-rtree_capath_vals(
- krb5_context context,
- const krb5_data *client,
- const krb5_data *server,
- char ***vals)
+rtree_capath_vals(krb5_context context,
+ const krb5_data *client,
+ const krb5_data *server,
+ char ***vals)
{
krb5_error_code retval = 0;
/* null-terminated realm names */
@@ -306,12 +298,11 @@
* Build tree by hierarchical traversal.
*/
static krb5_error_code
-rtree_hier_tree(
- krb5_context context,
- const krb5_data *client,
- const krb5_data *server,
- krb5_principal **rettree,
- int sep)
+rtree_hier_tree(krb5_context context,
+ const krb5_data *client,
+ const krb5_data *server,
+ krb5_principal **rettree,
+ int sep)
{
krb5_error_code retval;
krb5_data *realms;
@@ -356,13 +347,12 @@
* Construct list of realms between client and server.
*/
static krb5_error_code
-rtree_hier_realms(
- krb5_context context,
- const krb5_data *client,
- const krb5_data *server,
- krb5_data **realms,
- size_t *nrealms,
- int sep)
+rtree_hier_realms(krb5_context context,
+ const krb5_data *client,
+ const krb5_data *server,
+ krb5_data **realms,
+ size_t *nrealms,
+ int sep)
{
krb5_error_code retval;
struct hstate c, s;
@@ -418,10 +408,9 @@
}
static void
-free_realmlist(
- krb5_context context,
- krb5_data *realms,
- size_t nrealms)
+free_realmlist(krb5_context context,
+ krb5_data *realms,
+ size_t nrealms)
{
size_t i;
@@ -439,13 +428,12 @@
* make copies as needed and not call krb5_free_data_contents, etc.
*/
static krb5_error_code
-rtree_hier_tweens(
- krb5_context context,
- struct hstate *realm,
- krb5_data **tweens,
- size_t *ntweens,
- int dotail,
- int sep)
+rtree_hier_tweens(krb5_context context,
+ struct hstate *realm,
+ krb5_data **tweens,
+ size_t *ntweens,
+ int dotail,
+ int sep)
{
char *p, *r, *rtail, *lp;
size_t rlen, n;
@@ -579,3 +567,16 @@
c->dot = cdot;
s->dot = sdot;
}
+
+void
+krb5_free_realm_tree(krb5_context context, krb5_principal *realms)
+{
+ register krb5_principal *nrealms = realms;
+ if (realms == NULL)
+ return;
+ while (*nrealms) {
+ krb5_free_principal(context, *nrealms);
+ nrealms++;
+ }
+ free(realms);
+}
Modified: trunk/src/lib/krb5/os/Makefile.in
===================================================================
--- trunk/src/lib/krb5/os/Makefile.in 2010-01-03 23:41:49 UTC (rev 23575)
+++ trunk/src/lib/krb5/os/Makefile.in 2010-01-04 06:22:41 UTC (rev 23576)
@@ -21,7 +21,6 @@
dnsglue.o \
dnssrv.o \
free_krbhs.o \
- free_hstrl.o \
full_ipadr.o \
get_krbhst.o \
gen_port.o \
@@ -65,7 +64,6 @@
$(OUTPRE)dnsglue.$(OBJEXT) \
$(OUTPRE)dnssrv.$(OBJEXT) \
$(OUTPRE)free_krbhs.$(OBJEXT) \
- $(OUTPRE)free_hstrl.$(OBJEXT) \
$(OUTPRE)full_ipadr.$(OBJEXT) \
$(OUTPRE)get_krbhst.$(OBJEXT) \
$(OUTPRE)gen_port.$(OBJEXT) \
@@ -109,7 +107,6 @@
$(srcdir)/dnsglue.c \
$(srcdir)/dnssrv.c \
$(srcdir)/free_krbhs.c \
- $(srcdir)/free_hstrl.c \
$(srcdir)/full_ipadr.c \
$(srcdir)/get_krbhst.c \
$(srcdir)/gen_port.c \
Modified: trunk/src/lib/krb5/os/hst_realm.c
===================================================================
--- trunk/src/lib/krb5/os/hst_realm.c 2010-01-03 23:41:49 UTC (rev 23575)
+++ trunk/src/lib/krb5/os/hst_realm.c 2010-01-04 06:22:41 UTC (rev 23576)
@@ -2,7 +2,7 @@
/*
* lib/krb5/os/hst_realm.c
*
- * Copyright 1990,1991,2002,2008 by the Massachusetts Institute of Technology.
+ * Copyright 1990,1991,2002,2008,2009 by the Massachusetts Institute of Technology.
* All Rights Reserved.
*
* Export of this software from the United States of America may
@@ -26,6 +26,9 @@
*
*
* krb5_get_host_realm()
+ * krb5_get_fallback_host_realm()
+ * krb5int_clean_hostname()
+ * krb5_free_host_realm()
*/
@@ -94,7 +97,7 @@
krb5_error_code krb5int_translate_gai_error (int);
static krb5_error_code
-krb5int_get_fq_hostname (char *buf, size_t bufsize, const char *name)
+get_fq_hostname(char *buf, size_t bufsize, const char *name)
{
struct addrinfo *ai, hints;
int err;
@@ -116,13 +119,13 @@
Always return a null-terminated string.
Might return an error if gethostname fails. */
krb5_error_code
-krb5int_get_fq_local_hostname (char *buf, size_t bufsiz)
+krb5int_get_fq_local_hostname(char *buf, size_t bufsiz)
{
buf[0] = 0;
if (gethostname (buf, bufsiz) == -1)
return SOCKET_ERRNO;
buf[bufsiz - 1] = 0;
- return krb5int_get_fq_hostname (buf, bufsiz, buf);
+ return get_fq_hostname (buf, bufsiz, buf);
}
krb5_error_code KRB5_CALLCONV
@@ -266,7 +269,8 @@
*/
krb5_error_code KRB5_CALLCONV
-krb5_get_fallback_host_realm(krb5_context context, krb5_data *hdata, char ***realmsp)
+krb5_get_fallback_host_realm(krb5_context context,
+ krb5_data *hdata, char ***realmsp)
{
char **retrealms;
char *realm, *cp;
@@ -368,7 +372,8 @@
* to do basic sanity checks on supplied hostname.
*/
krb5_error_code KRB5_CALLCONV
-krb5int_clean_hostname(krb5_context context, const char *host, char *local_host, size_t lhsize)
+krb5int_clean_hostname(krb5_context context,
+ const char *host, char *local_host, size_t lhsize)
{
char *cp;
krb5_error_code retval;
@@ -492,3 +497,14 @@
free(fqdn);
return retval;
}
+
+/*
+ * Frees the storage taken by a realm list returned by krb5_get_host_realm.
+ */
+
+krb5_error_code KRB5_CALLCONV
+krb5_free_host_realm(krb5_context context, char *const *realmlist)
+{
+ /* same format, so why duplicate code? */
+ return krb5_free_krbhst(context, realmlist);
+}
More information about the cvs-krb5
mailing list