From 83721dc828e9b018f532ddba3ef240c39b65741f Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Wed, 13 Nov 1996 03:35:50 +0000 Subject: [PATCH] * keytab.c (process_keytab): Retrieve *keytab_str using krb5_kt_default_name() to avoid global variable nastiness. * kadmin.c (kadmin_startup): Use krb5_kt_set_default_name to change the default keytab name rather than assigning to a library global variable. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9394 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kadmin/cli/ChangeLog | 9 +++++++++ src/kadmin/cli/kadmin.c | 21 ++++++++++++++++++--- src/kadmin/cli/keytab.c | 12 +++++++++--- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/src/kadmin/cli/ChangeLog b/src/kadmin/cli/ChangeLog index 33f8b5058..946ee6a49 100644 --- a/src/kadmin/cli/ChangeLog +++ b/src/kadmin/cli/ChangeLog @@ -1,3 +1,12 @@ +Tue Nov 12 22:05:26 1996 Tom Yu + + * keytab.c (process_keytab): Retrieve *keytab_str using + krb5_kt_default_name() to avoid global variable nastiness. + + * kadmin.c (kadmin_startup): Use krb5_kt_set_default_name to + change the default keytab name rather than assigning to a library + global variable. + Thu Nov 7 20:52:39 1996 Tom Yu * configure.in: Remove spurious WITH_CCOPTS and KRB_INCLUDE. diff --git a/src/kadmin/cli/kadmin.c b/src/kadmin/cli/kadmin.c index 67c7b4641..1881c872a 100644 --- a/src/kadmin/cli/kadmin.c +++ b/src/kadmin/cli/kadmin.c @@ -421,9 +421,24 @@ char *kadmin_startup(argc, argv) exit(1); } { -#define DEFAULT_KEYTAB "WRFILE:/etc/v5srvtab" - extern char *krb5_defkeyname; - krb5_defkeyname = DEFAULT_KEYTAB; + /* 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); } return query; diff --git a/src/kadmin/cli/keytab.c b/src/kadmin/cli/keytab.c index 338206356..5a47bf159 100644 --- a/src/kadmin/cli/keytab.c +++ b/src/kadmin/cli/keytab.c @@ -23,7 +23,6 @@ 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; @@ -45,8 +44,15 @@ int process_keytab(krb5_context context, char **keytab_str, int code; if (*keytab_str == NULL) { - if (! (*keytab_str = strdup(krb5_defkeyname))) { - com_err(whoami, ENOMEM, "while creating keytab name"); + 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); return 1; } code = krb5_kt_default(context, keytab); -- 2.26.2