From adf7019f301aca9b138b2bf31f62a33d47113710 Mon Sep 17 00:00:00 2001 From: Barry Jaspan Date: Fri, 18 Oct 1996 17:24:33 +0000 Subject: [PATCH] * tcl_kadm5.c (unparse_principal_ent): don't unparse allocated fields that were not requested in mask to get_principal git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@9198 dc483132-0cff-0310-8789-dd5450dbe970 --- src/kadmin/testing/util/ChangeLog | 5 +++ src/kadmin/testing/util/tcl_kadm5.c | 54 +++++++++++++++++------------ 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/src/kadmin/testing/util/ChangeLog b/src/kadmin/testing/util/ChangeLog index d77ad746e..84a5977b4 100644 --- a/src/kadmin/testing/util/ChangeLog +++ b/src/kadmin/testing/util/ChangeLog @@ -1,3 +1,8 @@ +Fri Oct 18 13:23:46 1996 Barry Jaspan + + * tcl_kadm5.c (unparse_principal_ent): don't unparse allocated + fields that were not requested in mask to get_principal + Mon Oct 14 07:01:34 1996 Ezra Peisach * Makefile.in: Only attempt to build programs if Tcl present. diff --git a/src/kadmin/testing/util/tcl_kadm5.c b/src/kadmin/testing/util/tcl_kadm5.c index b102cdfc2..515056a3c 100644 --- a/src/kadmin/testing/util/tcl_kadm5.c +++ b/src/kadmin/testing/util/tcl_kadm5.c @@ -631,7 +631,8 @@ static int parse_policy_mask(Tcl_Interp *interp, char *str, krb5_int32 *flags) } -static Tcl_DString *unparse_principal_ent(kadm5_principal_ent_t princ) +static Tcl_DString *unparse_principal_ent(kadm5_principal_ent_t princ, + krb5_int32 mask) { Tcl_DString *str, *tmp_dstring; char *tmp; @@ -649,14 +650,17 @@ static Tcl_DString *unparse_principal_ent(kadm5_principal_ent_t princ) /* code for krb5_parse_name that the pointer passed into */ /* it should be initialized to 0 if I want it do be */ /* allocated automatically. */ - if (krb5_ret = krb5_unparse_name(context, princ->principal, &tmp)) { - /* XXX Do we want to return an error? Not sure. */ - Tcl_DStringAppendElement(str, "[unparseable principal]"); - } - else { - Tcl_DStringAppendElement(str, tmp); - free(tmp); - } + if (mask & KADM5_PRINCIPAL) { + if ( krb5_ret = krb5_unparse_name(context, princ->principal, &tmp)) { + /* XXX Do we want to return an error? Not sure. */ + Tcl_DStringAppendElement(str, "[unparseable principal]"); + } + else { + Tcl_DStringAppendElement(str, tmp); + free(tmp); + } + } else + Tcl_DStringAppendElement(str, "null"); sprintf(buf, "%d", princ->princ_expire_time); Tcl_DStringAppendElement(str, buf); @@ -671,22 +675,28 @@ static Tcl_DString *unparse_principal_ent(kadm5_principal_ent_t princ) Tcl_DStringAppendElement(str, buf); tmp = 0; - if (krb5_ret = krb5_unparse_name(context, princ->mod_name, &tmp)) { - /* XXX */ - Tcl_DStringAppendElement(str, "[unparseable principal]"); - } - else { - Tcl_DStringAppendElement(str, tmp); - free(tmp); - } + if (mask & KADM5_MOD_NAME) { + if (krb5_ret = krb5_unparse_name(context, princ->mod_name, &tmp)) { + /* XXX */ + Tcl_DStringAppendElement(str, "[unparseable principal]"); + } + else { + Tcl_DStringAppendElement(str, tmp); + free(tmp); + } + } else + Tcl_DStringAppendElement(str, "null"); sprintf(buf, "%d", princ->mod_date); Tcl_DStringAppendElement(str, buf); - tmp_dstring = unparse_krb5_flags(princ->attributes); - Tcl_DStringAppendElement(str, tmp_dstring->string); - Tcl_DStringFree(tmp_dstring); - free(tmp_dstring); + if (mask & KADM5_ATTRIBUTES) { + tmp_dstring = unparse_krb5_flags(princ->attributes); + Tcl_DStringAppendElement(str, tmp_dstring->string); + Tcl_DStringFree(tmp_dstring); + free(tmp_dstring); + } else + Tcl_DStringAppendElement(str, "null"); sprintf(buf, "%d", princ->kvno); Tcl_DStringAppendElement(str, buf); @@ -1887,7 +1897,7 @@ int tcl_kadm5_get_principal(ClientData clientData, Tcl_Interp *interp, if (ret == KADM5_OK) { if (ent_var) { - ent_dstring = unparse_principal_ent(&ent); + ent_dstring = unparse_principal_ent(&ent, mask); if (! Tcl_SetVar(interp, ent_var, ent_dstring->string, TCL_LEAVE_ERR_MSG)) { Tcl_AppendElement(interp, -- 2.26.2