krb5 commit: Get rid of krb5_{get,free}_krbhst

Greg Hudson ghudson at MIT.EDU
Fri Mar 22 16:01:08 EDT 2013


https://github.com/krb5/krb5/commit/81fde7e475b02986c1aff88766cc48882004d5dc
commit 81fde7e475b02986c1aff88766cc48882004d5dc
Author: Greg Hudson <ghudson at mit.edu>
Date:   Fri Mar 22 16:00:48 2013 -0400

    Get rid of krb5_{get,free}_krbhst
    
    These functions were always internal.  They haven't been used since
    v5passwdd was eliminated in krb5 1.4.

 src/include/k5-int.h             |    2 -
 src/lib/krb5/libkrb5.exports     |    2 -
 src/lib/krb5/os/Makefile.in      |    7 --
 src/lib/krb5/os/free_krbhs.c     |   41 -------------
 src/lib/krb5/os/get_krbhst.c     |  121 --------------------------------------
 src/lib/krb5/os/hst_realm.c      |   10 +++-
 src/lib/krb5/os/ref_std_conf.out |    2 -
 src/lib/krb5/os/t_std_conf.c     |   36 +-----------
 8 files changed, 9 insertions(+), 212 deletions(-)

diff --git a/src/include/k5-int.h b/src/include/k5-int.h
index cb8350f..ed9f255 100644
--- a/src/include/k5-int.h
+++ b/src/include/k5-int.h
@@ -570,8 +570,6 @@ krb5_error_code krb5_unlock_file(krb5_context, int);
 krb5_error_code krb5_sendto_kdc(krb5_context, const krb5_data *,
                                 const krb5_data *, krb5_data *, int *, int);
 
-krb5_error_code krb5_get_krbhst(krb5_context, const krb5_data *, char *** );
-krb5_error_code krb5_free_krbhst(krb5_context, char * const * );
 krb5_error_code krb5_create_secure_file(krb5_context, const char * pathname);
 krb5_error_code krb5_sync_disk_file(krb5_context, FILE *fp);
 
diff --git a/src/lib/krb5/libkrb5.exports b/src/lib/krb5/libkrb5.exports
index 1656cfc..de41959 100644
--- a/src/lib/krb5/libkrb5.exports
+++ b/src/lib/krb5/libkrb5.exports
@@ -304,7 +304,6 @@ krb5_free_kdc_req
 krb5_free_keyblock
 krb5_free_keyblock_contents
 krb5_free_keytab_entry_contents
-krb5_free_krbhst
 krb5_free_last_req
 krb5_free_octet_data
 krb5_free_pa_data
@@ -376,7 +375,6 @@ krb5_get_init_creds_opt_set_responder
 krb5_get_init_creds_opt_set_salt
 krb5_get_init_creds_opt_set_tkt_life
 krb5_get_init_creds_password
-krb5_get_krbhst
 krb5_get_notification_message
 krb5_get_permitted_enctypes
 krb5_get_profile
diff --git a/src/lib/krb5/os/Makefile.in b/src/lib/krb5/os/Makefile.in
index d95ece0..f013899 100644
--- a/src/lib/krb5/os/Makefile.in
+++ b/src/lib/krb5/os/Makefile.in
@@ -22,9 +22,7 @@ STLIBOBJS= \
 	dnsglue.o	\
 	dnssrv.o	\
 	expand_path.o	\
-	free_krbhs.o	\
 	full_ipadr.o	\
-	get_krbhst.o	\
 	gen_port.o	\
 	genaddrs.o	\
 	gen_rname.o	\
@@ -69,9 +67,7 @@ OBJS= \
 	$(OUTPRE)dnsglue.$(OBJEXT)	\
 	$(OUTPRE)dnssrv.$(OBJEXT)	\
 	$(OUTPRE)expand_path.$(OBJEXT)	\
-	$(OUTPRE)free_krbhs.$(OBJEXT)	\
 	$(OUTPRE)full_ipadr.$(OBJEXT)	\
-	$(OUTPRE)get_krbhst.$(OBJEXT)	\
 	$(OUTPRE)gen_port.$(OBJEXT)	\
 	$(OUTPRE)genaddrs.$(OBJEXT)	\
 	$(OUTPRE)gen_rname.$(OBJEXT)	\
@@ -116,9 +112,7 @@ SRCS= \
 	$(srcdir)/dnsglue.c	\
 	$(srcdir)/dnssrv.c	\
 	$(srcdir)/expand_path.c	\
-	$(srcdir)/free_krbhs.c	\
 	$(srcdir)/full_ipadr.c	\
-	$(srcdir)/get_krbhst.c	\
 	$(srcdir)/gen_port.c	\
 	$(srcdir)/genaddrs.c	\
 	$(srcdir)/gen_rname.c	\
@@ -205,7 +199,6 @@ check-unix:: check-unix-stdconf check-unix-locate check-unix-trace \
 check-unix-stdconf:: t_std_conf
 	KRB5_CONFIG=$(srcdir)/td_krb5.conf ; export KRB5_CONFIG ;\
 	$(KRB5_RUN_ENV) $(VALGRIND) ./t_std_conf  -d -s NEW.DEFAULT.REALM -d \
-		-k IGGY.ORG -k DEFAULT_REALM.TST \
 		-D DEFAULT_REALM.TST -r bad.idea -r itar.bad.idea \
 		-r really.BAD.IDEA. -r clipper.bad.idea -r KeYEsCrOW.BaD.IDea \
 		-r pgp.good.idea -r no_domain > test.out
diff --git a/src/lib/krb5/os/free_krbhs.c b/src/lib/krb5/os/free_krbhs.c
deleted file mode 100644
index 58a6c43..0000000
--- a/src/lib/krb5/os/free_krbhs.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/* lib/krb5/os/free_krbhs.c */
-/*
- * Copyright 1990,1991 by the Massachusetts Institute of Technology.
- * All Rights Reserved.
- *
- * Export of this software from the United States of America may
- *   require a specific license from the United States Government.
- *   It is the responsibility of any person or organization contemplating
- *   export to obtain such a license before exporting.
- *
- * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
- * distribute this software and its documentation for any purpose and
- * without fee is hereby granted, provided that the above copyright
- * notice appear in all copies and that both that copyright notice and
- * this permission notice appear in supporting documentation, and that
- * the name of M.I.T. not be used in advertising or publicity pertaining
- * to distribution of the software without specific, written prior
- * permission.  Furthermore if you modify this software you must label
- * your software as modified software and not distribute it in such a
- * fashion that it might be confused with the original M.I.T. software.
- * M.I.T. makes no representations about the suitability of
- * this software for any purpose.  It is provided "as is" without express
- * or implied warranty.
- */
-
-#include "k5-int.h"
-
-/* Free the storage taken by a host list returned by krb5_get_krbhst. */
-krb5_error_code
-krb5_free_krbhst(krb5_context context, char *const *hostlist)
-{
-    register char * const *cp;
-
-    if (hostlist == NULL)
-        return 0;
-    for (cp = hostlist; *cp; cp++)
-        free(*cp);
-    free((char *)hostlist);
-    return 0;
-}
diff --git a/src/lib/krb5/os/get_krbhst.c b/src/lib/krb5/os/get_krbhst.c
deleted file mode 100644
index d607366..0000000
--- a/src/lib/krb5/os/get_krbhst.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
-/* lib/krb5/os/get_krbhst.c */
-/*
- * Copyright 1990,1991 by the Massachusetts Institute of Technology.
- * All Rights Reserved.
- *
- * Export of this software from the United States of America may
- *   require a specific license from the United States Government.
- *   It is the responsibility of any person or organization contemplating
- *   export to obtain such a license before exporting.
- *
- * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
- * distribute this software and its documentation for any purpose and
- * without fee is hereby granted, provided that the above copyright
- * notice appear in all copies and that both that copyright notice and
- * this permission notice appear in supporting documentation, and that
- * the name of M.I.T. not be used in advertising or publicity pertaining
- * to distribution of the software without specific, written prior
- * permission.  Furthermore if you modify this software you must label
- * your software as modified software and not distribute it in such a
- * fashion that it might be confused with the original M.I.T. software.
- * M.I.T. makes no representations about the suitability of
- * this software for any purpose.  It is provided "as is" without express
- * or implied warranty.
- */
-
-#include "k5-int.h"
-#include <stdio.h>
-#include <ctype.h>
-
-/*
-  Figures out the Kerberos server names for the given realm, filling in a
-  pointer to an argv[] style list of names, terminated with a null pointer.
-
-  If the realm is unknown, the filled-in pointer is set to NULL.
-
-  The pointer array and strings pointed to are all in allocated storage,
-  and should be freed by the caller when finished.
-
-  returns system errors
-*/
-
-/*
- * Implementation:  the server names for given realms are stored in a
- * configuration file,
- * named by krb5_config_file;  the first token (on the first line) in
- * this file is taken as the default local realm name.
- *
- * Each succeeding line has a realm name as the first token, and a server name
- * as a second token.  Additional tokens may be present on the line, but
- * are ignored by this function.
- *
- * All lines which begin with the desired realm name will have the
- * hostname added to the list returned.
- */
-
-krb5_error_code
-krb5_get_krbhst(krb5_context context, const krb5_data *realm, char ***hostlist)
-{
-    char        **values, **cpp, *cp;
-    const char  *realm_kdc_names[4];
-    krb5_error_code     retval;
-    int i, count;
-    char **rethosts;
-
-    rethosts = 0;
-
-    realm_kdc_names[0] = KRB5_CONF_REALMS;
-    realm_kdc_names[1] = realm->data;
-    realm_kdc_names[2] = KRB5_CONF_KDC;
-    realm_kdc_names[3] = 0;
-
-    if (context->profile == 0)
-        return KRB5_CONFIG_CANTOPEN;
-
-    retval = profile_get_values(context->profile, realm_kdc_names, &values);
-    if (retval == PROF_NO_SECTION)
-        return KRB5_REALM_UNKNOWN;
-    if (retval == PROF_NO_RELATION)
-        return KRB5_CONFIG_BADFORMAT;
-    if (retval)
-        return retval;
-
-    /*
-     * Do cleanup over the list.  We allow for some extra field to be
-     * added to the kdc line later (maybe the port number)
-     */
-    for (cpp = values; *cpp; cpp++) {
-        cp = strchr(*cpp, ' ');
-        if (cp)
-            *cp = 0;
-        cp = strchr(*cpp, '\t');
-        if (cp)
-            *cp = 0;
-        cp = strchr(*cpp, ':');
-        if (cp)
-            *cp = 0;
-    }
-    count = cpp - values;
-    rethosts = malloc(sizeof(char *) * (count + 1));
-    if (!rethosts) {
-        retval = ENOMEM;
-        goto cleanup;
-    }
-    for (i = 0; i < count; i++) {
-        rethosts[i] = k5memdup0(values[i], strlen(values[i]), &retval);
-        if (rethosts[i] == NULL)
-            goto cleanup;
-    }
-    rethosts[count] = 0;
-cleanup:
-    if (retval && rethosts) {
-        for (cpp = rethosts; *cpp; cpp++)
-            free(*cpp);
-        free(rethosts);
-        rethosts = 0;
-    }
-    profile_free_list(values);
-    *hostlist = rethosts;
-    return retval;
-}
diff --git a/src/lib/krb5/os/hst_realm.c b/src/lib/krb5/os/hst_realm.c
index 7bfce5e..599823e 100644
--- a/src/lib/krb5/os/hst_realm.c
+++ b/src/lib/krb5/os/hst_realm.c
@@ -489,6 +489,12 @@ cleanup:
 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);
+    char *const *cp;
+
+    if (realmlist == NULL)
+        return 0;
+    for (cp = realmlist; *cp; cp++)
+        free(*cp);
+    free((char *)realmlist);
+    return 0;
 }
diff --git a/src/lib/krb5/os/ref_std_conf.out b/src/lib/krb5/os/ref_std_conf.out
index 9634946..1e8f5fb 100644
--- a/src/lib/krb5/os/ref_std_conf.out
+++ b/src/lib/krb5/os/ref_std_conf.out
@@ -1,8 +1,6 @@
 krb5_get_default_realm() returned 'DEFAULT.REALM.TST'
 krb5_set_default_realm(NEW.DEFAULT.REALM)
 krb5_get_default_realm() returned 'NEW.DEFAULT.REALM'
-krb_get_krbhst(IGGY.ORG) returned: 'KERBEROS.IGGY.ORG' 'KERBEROS-B.IGGY.ORG'
-krb_get_krbhst(DEFAULT_REALM.TST) returned: 'FIRST.KDC.HOST' 'SECOND.KDC.HOST'
 krb5_get_realm_domain(DEFAULT_REALM.TST) returned 'MIT.EDU'
 krb_get_host_realm(bad.idea) returned: 'US.GOV'
 krb_get_host_realm(itar.bad.idea) returned: 'NSA.GOV'
diff --git a/src/lib/krb5/os/t_std_conf.c b/src/lib/krb5/os/t_std_conf.c
index 74987b1..e2ff572 100644
--- a/src/lib/krb5/os/t_std_conf.c
+++ b/src/lib/krb5/os/t_std_conf.c
@@ -72,37 +72,6 @@ test_set_default_ccname(krb5_context ctx, char *ccname)
 }
 
 static void
-test_get_krbhst(krb5_context ctx, char *realm)
-{
-    char **hostlist, **cpp;
-    krb5_data rlm;
-    krb5_error_code retval;
-
-    rlm.data = realm;
-    rlm.length = strlen(realm);
-    retval = krb5_get_krbhst(ctx, &rlm, &hostlist);
-    if (retval) {
-        com_err("krb5_get_krbhst", retval, 0);
-        return;
-    }
-    printf("krb_get_krbhst(%s) returned:", realm);
-    if (hostlist == 0) {
-        printf(" (null)\n");
-        return;
-    }
-    if (hostlist[0] == 0) {
-        printf(" (none)\n");
-        krb5_free_krbhst(ctx, hostlist);
-        return;
-    }
-    for (cpp = hostlist; *cpp; cpp++) {
-        printf(" '%s'", *cpp);
-    }
-    krb5_free_krbhst(ctx, hostlist);
-    printf("\n");
-}
-
-static void
 test_locate_kdc(krb5_context ctx, char *realm)
 {
     struct serverlist servers;
@@ -221,7 +190,7 @@ main(int argc, char **argv)
         exit(1);
     }
 
-    while ((c = getopt(argc, argv, "cdk:r:C:D:l:s:")) != -1) {
+    while ((c = getopt(argc, argv, "cdr:C:D:l:s:")) != -1) {
         switch (c) {
         case 'c':           /* Get default ccname */
             test_get_default_ccname(ctx);
@@ -229,9 +198,6 @@ main(int argc, char **argv)
         case 'd': /* Get default realm */
             test_get_default_realm(ctx);
             break;
-        case 'k': /* Get list of KDC's */
-            test_get_krbhst(ctx, optarg);
-            break;
         case 'l':
             test_locate_kdc(ctx, optarg);
             break;


More information about the cvs-krb5 mailing list