From 72e1cf8784fbcb1bffa28b08f663ea9469634590 Mon Sep 17 00:00:00 2001 From: Kevin Coffman Date: Fri, 30 Mar 2007 18:32:10 -0400 Subject: [PATCH] Hide differences between MIT and Heimdal in macros Clean up a lot of #ifdef'd code using macros, masking the differences between MIT and Heimdal implementations. The currently unused macros will be used in later patches. Signed-off-by: Kevin Coffman Signed-off-by: Neil Brown --- utils/gssd/krb5_util.c | 30 +++++------------------------- utils/gssd/krb5_util.h | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/utils/gssd/krb5_util.c b/utils/gssd/krb5_util.c index a0ee110..7ef690b 100644 --- a/utils/gssd/krb5_util.c +++ b/utils/gssd/krb5_util.c @@ -364,11 +364,7 @@ gssd_get_single_krb5_cred(krb5_context context, "principal '%s' from keytab '%s'\n", error_message(code), pname ? pname : "", kt_name); -#ifdef HAVE_KRB5 - if (pname) krb5_free_unparsed_name(context, pname); -#else - if (pname) free(pname); -#endif + if (pname) k5_free_unparsed_name(context, pname); goto out; } @@ -497,11 +493,7 @@ gssd_process_krb5_keytab(krb5_context context, krb5_keytab kt, char *kt_name) if (ple == NULL) { printerr(0, "ERROR: could not allocate storage " "for principal list entry\n"); -#ifdef HAVE_KRB5 - krb5_free_unparsed_name(context, pname); -#else - free(pname); -#endif + k5_free_unparsed_name(context, pname); krb5_kt_free_entry(context, &kte); retval = ENOMEM; goto out; @@ -521,11 +513,7 @@ gssd_process_krb5_keytab(krb5_context context, krb5_keytab kt, char *kt_name) printerr(0, "ERROR: %s while copying realm to " "principal list entry\n", "not enough memory"); -#ifdef HAVE_KRB5 - krb5_free_unparsed_name(context, pname); -#else - free(pname); -#endif + k5_free_unparsed_name(context, pname); krb5_kt_free_entry(context, &kte); retval = ENOMEM; goto out; @@ -535,11 +523,7 @@ gssd_process_krb5_keytab(krb5_context context, krb5_keytab kt, char *kt_name) printerr(0, "ERROR: %s while copying principal " "to principal list entry\n", error_message(code)); -#ifdef HAVE_KRB5 - krb5_free_unparsed_name(context, pname); -#else - free(pname); -#endif + k5_free_unparsed_name(context, pname); krb5_kt_free_entry(context, &kte); retval = code; goto out; @@ -555,11 +539,7 @@ gssd_process_krb5_keytab(krb5_context context, krb5_keytab kt, char *kt_name) printerr(2, "We will NOT use this entry (%s)\n", pname); } -#ifdef HAVE_KRB5 - krb5_free_unparsed_name(context, pname); -#else - free(pname); -#endif + k5_free_unparsed_name(context, pname); krb5_kt_free_entry(context, &kte); } diff --git a/utils/gssd/krb5_util.h b/utils/gssd/krb5_util.h index da04530..36dfcc8 100644 --- a/utils/gssd/krb5_util.h +++ b/utils/gssd/krb5_util.h @@ -27,4 +27,19 @@ void gssd_destroy_krb5_machine_creds(void); int limit_krb5_enctypes(struct rpc_gss_sec *sec, uid_t uid); #endif +/* + * Hide away some of the MIT vs. Heimdal differences + * here with macros... + */ + +#ifdef HAVE_KRB5 +#define k5_free_unparsed_name(ctx, name) krb5_free_unparsed_name((ctx), (name)) +#define k5_free_default_realm(ctx, realm) krb5_free_default_realm((ctx), (realm)) +#define k5_free_kt_entry(ctx, kte) krb5_free_keytab_entry_contents((ctx),(kte)) +#else /* Heimdal */ +#define k5_free_unparsed_name(ctx, name) free(name) +#define k5_free_default_realm(ctx, realm) free(realm) +#define k5_free_kt_entry(ctx, kte) krb5_kt_free_entry((ctx),(kte)) +#endif + #endif /* KRB5_UTIL_H */ -- 2.39.5