From 81daff23ac65fdc3ce54f88151b934ce8e063fb3 Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Wed, 13 Nov 1996 21:05:00 +0000 Subject: [PATCH] revert kt_default_name changes; see ChangeLogs for details git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9407 dc483132-0cff-0310-8789-dd5450dbe970 --- src/include/ChangeLog | 4 ++ src/include/k5-int.h | 1 - src/include/krb5.hin | 3 -- src/kadmin/cli/ChangeLog | 10 +++++ src/kadmin/cli/kadmin.c | 23 +++------- src/kadmin/cli/keytab.c | 14 +++--- src/kadmin/server/ChangeLog | 7 +++ src/kadmin/server/ovsec_kadmd.c | 24 +++++----- src/lib/krb5/krb/ChangeLog | 4 ++ src/lib/krb5/krb/init_ctx.c | 3 -- src/lib/krb5/os/ChangeLog | 3 ++ src/lib/krb5/os/ktdefname.c | 79 +++++++++++++-------------------- src/lib/krb5/os/osconfig.c | 2 + 13 files changed, 80 insertions(+), 97 deletions(-) diff --git a/src/include/ChangeLog b/src/include/ChangeLog index b3eebeb0f..3a2976d58 100644 --- a/src/include/ChangeLog +++ b/src/include/ChangeLog @@ -1,3 +1,7 @@ +Wed Nov 13 14:28:08 1996 Tom Yu + + * k5-int.h, krb5.hin: Revert kt_default_name changes. + Tue Nov 12 22:04:41 1996 Tom Yu * krb5.hin: Add definition for krb5_kt_set_default_name(). diff --git a/src/include/k5-int.h b/src/include/k5-int.h index 977b34e9d..f6f30ef5c 100644 --- a/src/include/k5-int.h +++ b/src/include/k5-int.h @@ -926,7 +926,6 @@ struct _krb5_context { krb5_boolean profile_secure; int fcc_default_format; int scc_default_format; - char FAR *kt_default_name; }; #define KRB5_LIBOPT_SYNC_KDCTIME 0x0001 diff --git a/src/include/krb5.hin b/src/include/krb5.hin index 9b4703e29..8696e94d8 100644 --- a/src/include/krb5.hin +++ b/src/include/krb5.hin @@ -1551,9 +1551,6 @@ krb5_error_code krb5_kt_default_name KRB5_PROTOTYPE((krb5_context, char *, int )); -krb5_error_code krb5_kt_set_default_name - KRB5_PROTOTYPE((krb5_context, - char *)); krb5_error_code krb5_kt_default KRB5_PROTOTYPE((krb5_context, krb5_keytab * )); diff --git a/src/kadmin/cli/ChangeLog b/src/kadmin/cli/ChangeLog index 946ee6a49..bd2e1592d 100644 --- a/src/kadmin/cli/ChangeLog +++ b/src/kadmin/cli/ChangeLog @@ -1,3 +1,13 @@ +Wed Nov 13 14:29:02 1996 Tom Yu + + * keytab.c (process_keytab): Note that krb5_defkeyname is an + internal interface. + + * kadmin.c (kadmin_startup): Note that krb5_defkeyname is an + internal interface. + + * kadmin.c, keytab.c: Revert kt_default_name changes. + Tue Nov 12 22:05:26 1996 Tom Yu * keytab.c (process_keytab): Retrieve *keytab_str using diff --git a/src/kadmin/cli/kadmin.c b/src/kadmin/cli/kadmin.c index 1881c872a..d8011f86e 100644 --- a/src/kadmin/cli/kadmin.c +++ b/src/kadmin/cli/kadmin.c @@ -421,24 +421,11 @@ char *kadmin_startup(argc, argv) exit(1); } { - /* hack up the default keytab name to begin with "WRFILE:" */ - char *cp, ktdef[BUFSIZ]; - if ((retval = krb5_kt_default_name(context, ktdef, BUFSIZ))) { - com_err(whoami, retval, "while looking up default keytab name"); - exit(1); - } - if ((cp = malloc(strlen(ktdef) + 1 + 2)) == NULL) { - com_err(whoami, ENOMEM, "while editting default keytab name"); - exit(1); - } - strcpy(cp, "WR"); - strcat(cp, ktdef); - if ((retval = krb5_kt_set_default_name(context, cp))) { - com_err(whoami, retval, - "while changing default keytab name"); - exit(1); - } - free(cp); +#define DEFAULT_KEYTAB "WRFILE:/etc/v5srvtab" + /* XXX krb5_defkeyname is an internal library global and + should go away */ + extern char *krb5_defkeyname; + krb5_defkeyname = DEFAULT_KEYTAB; } return query; diff --git a/src/kadmin/cli/keytab.c b/src/kadmin/cli/keytab.c index 5a47bf159..df4f6ce25 100644 --- a/src/kadmin/cli/keytab.c +++ b/src/kadmin/cli/keytab.c @@ -23,6 +23,7 @@ static int remove_principal(char *keytab_str, krb5_keytab keytab, char *princ_str, char *kvno_str); static char *etype_string(krb5_enctype enctype); +extern char *krb5_defkeyname; extern char *whoami; extern krb5_context context; extern void *handle; @@ -44,15 +45,10 @@ int process_keytab(krb5_context context, char **keytab_str, int code; if (*keytab_str == NULL) { - char *keytab_str = malloc(BUFSIZ); - - if (keytab_str == NULL) { - com_err(whoami, ENOMEM, "while creating default keytab name"); - return 1; - } - if ((code = krb5_kt_default_name(context, keytab_str, BUFSIZ))) { - com_err(whoami, code, "while copying default keytab name"); - free(*keytab_str); + /* XXX krb5_defkeyname is an internal library global and + should go away */ + if (! (*keytab_str = strdup(krb5_defkeyname))) { + com_err(whoami, ENOMEM, "while creating keytab name"); return 1; } code = krb5_kt_default(context, keytab); diff --git a/src/kadmin/server/ChangeLog b/src/kadmin/server/ChangeLog index 308b2f2df..6092176df 100644 --- a/src/kadmin/server/ChangeLog +++ b/src/kadmin/server/ChangeLog @@ -1,3 +1,10 @@ +Wed Nov 13 14:29:34 1996 Tom Yu + + * ovsec_kadmd.c (main): Note that krb5_defkeyname is an internal + interface. + + * ovsec_kadmd.c (main): Revert kt_default_name changes. + Tue Nov 12 22:07:05 1996 Tom Yu * ovsec_kadmd.c (main): Use krb5_kt_set_default_name() rather than diff --git a/src/kadmin/server/ovsec_kadmd.c b/src/kadmin/server/ovsec_kadmd.c index 67aa77525..21514aca1 100644 --- a/src/kadmin/server/ovsec_kadmd.c +++ b/src/kadmin/server/ovsec_kadmd.c @@ -58,6 +58,13 @@ void *global_server_handle; #define OVSEC_KADM_ADMIN_SERVICE "ovsec_adm/admin" #define OVSEC_KADM_CHANGEPW_SERVICE "ovsec_adm/changepw" +/* + * This enables us to set the keytab that gss_acquire_cred uses, but + * it also restricts us to linking against the Kv5 GSS-API library. + * Since this is *k*admind, that shouldn't be a problem. + */ +extern char *krb5_defkeyname; + char *build_princ_name(char *name, char *realm); void log_badauth(OM_uint32 major, OM_uint32 minor, struct sockaddr_in *addr, char *data); @@ -309,20 +316,9 @@ int main(int argc, char *argv[]) exit(1); } - /* - * This enables us to set the keytab that gss_acquire_cred uses, but - * it also restricts us to linking against the Kv5 GSS-API library. - * Since this is *k*admind, that shouldn't be a problem. - */ - if ((ret = krb5_kt_set_default_name(context, params.admin_keytab))) { - krb5_klog_syslog(LOG_ERR, "Cannot change default keytab name: %s", - error_message(ret)); - fprintf(stderr, "%s: Cannot change default keytab name.\n", - whoami); - kadm5_destroy(global_server_handle); - krb5_klog_close(); - exit(1); - } + /* XXX krb5_defkeyname is an internal library global and should + go away */ + krb5_defkeyname = params.admin_keytab; /* * Try to acquire creds for the old OV services as well as the diff --git a/src/lib/krb5/krb/ChangeLog b/src/lib/krb5/krb/ChangeLog index a45b8a985..c702d0aa9 100644 --- a/src/lib/krb5/krb/ChangeLog +++ b/src/lib/krb5/krb/ChangeLog @@ -1,3 +1,7 @@ +Wed Nov 13 14:30:47 1996 Tom Yu + + * init_ctx.c: Revert previous kt_default_name changes. + Tue Nov 12 22:07:33 1996 Tom Yu * init_ctx.c (krb5_init_context): Oops. Initialize kt_default_name diff --git a/src/lib/krb5/krb/init_ctx.c b/src/lib/krb5/krb/init_ctx.c index d84d59d07..19aaf6642 100644 --- a/src/lib/krb5/krb/init_ctx.c +++ b/src/lib/krb5/krb/init_ctx.c @@ -68,7 +68,6 @@ krb5_init_context(context) goto cleanup; ctx->default_realm = 0; - ctx->kt_default_name = 0; profile_get_integer(ctx->profile, "libdefaults", "clockskew", 0, 5 * 60, &tmp); ctx->clockskew = tmp; @@ -155,8 +154,6 @@ krb5_free_context(ctx) if (ctx->ser_ctx_count && ctx->ser_ctx) free(ctx->ser_ctx); - if (ctx->kt_default_name) - free(ctx->kt_default_name); ctx->magic = 0; free(ctx); } diff --git a/src/lib/krb5/os/ChangeLog b/src/lib/krb5/os/ChangeLog index 124935ea1..85a320de3 100644 --- a/src/lib/krb5/os/ChangeLog +++ b/src/lib/krb5/os/ChangeLog @@ -1,5 +1,8 @@ Wed Nov 13 02:53:31 1996 Tom Yu + * ktdefname.c, osconfig.c: Revert previous kt_default_name + changes. + * ktdefname.c (krb5_kt_default_name): Fix a few memory-leak type problems in previous changes. diff --git a/src/lib/krb5/os/ktdefname.c b/src/lib/krb5/os/ktdefname.c index ef5391ab4..29eb54fe2 100644 --- a/src/lib/krb5/os/ktdefname.c +++ b/src/lib/krb5/os/ktdefname.c @@ -28,6 +28,8 @@ #include "k5-int.h" +extern char *krb5_defkeyname; + krb5_error_code krb5_kt_default_name(context, name, namesize) krb5_context context; @@ -38,58 +40,37 @@ krb5_kt_default_name(context, name, namesize) krb5_error_code code; char *retval; - if (context->kt_default_name == NULL) { - if ((context->profile_secure == FALSE) && - (cp = getenv("KRB5_KTNAME"))) { - if ((context->kt_default_name = malloc(strlen(cp) + 1)) == NULL) - return ENOMEM; - strcpy(context->kt_default_name, cp); - } else if (((code = profile_get_string(context->profile, - "libdefaults", - "default_keytab_name", NULL, - NULL, &cp)) == 0) && cp){ - context->kt_default_name = cp; - } else { + if ((context->profile_secure == FALSE) && + (cp = getenv("KRB5_KTNAME"))) { + strncpy(name, cp, namesize); + if (strlen(cp) >= (size_t) namesize) + return KRB5_CONFIG_NOTENUFSPACE; + } else if (((code = profile_get_string(context->profile, + "libdefaults", + "default_keytab_name", NULL, + NULL, &retval)) == 0) && + retval) { + strncpy(name, retval, namesize); + if ((size_t) namesize < strlen(retval)) + return KRB5_CONFIG_NOTENUFSPACE; + } else { #if defined (_MSDOS) || defined(_WIN32) - { - char defname[160]; - int len; - - len= GetWindowsDirectory( defname, sizeof(defname)-2 ); - defname[len]= '\0'; - if ((cp = malloc(strlen(DEFAULT_KEYTAB_NAME) + 1 + len)) - == NULL) - return ENOMEM; - sprintf(cp, DEFAULT_KEYTAB_NAME, defname); - context->kt_default_name = cp; - } + { + char defname[160]; + int len; + + len= GetWindowsDirectory( defname, sizeof(defname)-2 ); + defname[len]= '\0'; + if ( (len + strlen(krb5_defkeyname) + 1) > namesize ) + return KRB5_CONFIG_NOTENUFSPACE; + sprintf(name, krb5_defkeyname, defname); + } #else - if ((cp = malloc(strlen(DEFAULT_KEYTAB_NAME) + 1)) == NULL) - return ENOMEM; - strcpy(cp, DEFAULT_KEYTAB_NAME); - context->kt_default_name = cp; + strncpy(name, krb5_defkeyname, namesize); + if ((size_t) namesize < strlen(krb5_defkeyname)) + return KRB5_CONFIG_NOTENUFSPACE; #endif - } } - strncpy(name, context->kt_default_name, namesize); - if ((size_t) namesize < strlen(context->kt_default_name)) - return KRB5_CONFIG_NOTENUFSPACE; return 0; } - -krb5_error_code -krb5_kt_set_default_name(context, name) - krb5_context context; - char *name; -{ - char *cp; - if ((cp = malloc(strlen(name) + 1)) == NULL) - return ENOMEM; - else { - strcpy(cp, name); - if (context->kt_default_name) - free(context->kt_default_name); - context->kt_default_name = cp; - return 0; - } -} + diff --git a/src/lib/krb5/os/osconfig.c b/src/lib/krb5/os/osconfig.c index 568ed0280..8403aa38b 100644 --- a/src/lib/krb5/os/osconfig.c +++ b/src/lib/krb5/os/osconfig.c @@ -26,6 +26,8 @@ #include "k5-int.h" +char *krb5_defkeyname = DEFAULT_KEYTAB_NAME; + int krb5_max_dgram_size = MAX_DGRAM_SIZE; int krb5_max_skdc_timeout = MAX_SKDC_TIMEOUT; int krb5_skdc_timeout_shift = SKDC_TIMEOUT_SHIFT; -- 2.26.2