From: W. Trevor King Date: Fri, 18 May 2012 01:10:20 +0000 (-0400) Subject: Add support for "{ptype}" trace format specifier X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=27417b7d27bd61acf567da2ddccc591b7f499e47;p=krb5.git Add support for "{ptype}" trace format specifier Add the "{ptype}" trace format specifier, for principal name types. Also document the new option in the "k5-trace.h" comments. ticket: 7151 --- diff --git a/src/include/k5-trace.h b/src/include/k5-trace.h index ee826ecc0..c889c50ea 100644 --- a/src/include/k5-trace.h +++ b/src/include/k5-trace.h @@ -69,6 +69,7 @@ * {key} krb5_key, display enctype and hash of key * {cksum} const krb5_checksum *, display cksumtype and hex checksum * {princ} krb5_principal, unparse and display + * {ptype} krb5_int32, krb5_principal type, display name * {patypes} krb5_pa_data **, display list of padata type numbers * {etype} krb5_enctype, display shortest name of enctype * {etypes} krb5_enctype *, display list of enctypes diff --git a/src/lib/krb5/os/trace.c b/src/lib/krb5/os/trace.c index bc52f2b21..f3e1d8954 100644 --- a/src/lib/krb5/os/trace.c +++ b/src/lib/krb5/os/trace.c @@ -63,6 +63,27 @@ hash_bytes(krb5_context context, const void *ptr, size_t len) return s; } +static char * +principal_type_string(krb5_int32 type) +{ + switch (type) { + case KRB5_NT_UNKNOWN: return "unknown"; + case KRB5_NT_PRINCIPAL: return "principal"; + case KRB5_NT_SRV_INST: return "service instance"; + case KRB5_NT_SRV_HST: return "service with host as instance"; + case KRB5_NT_SRV_XHST: return "service with host as components"; + case KRB5_NT_UID: return "unique ID"; + case KRB5_NT_X500_PRINCIPAL: return "X.509"; + case KRB5_NT_SMTP_NAME: return "SMTP email"; + case KRB5_NT_ENTERPRISE_PRINCIPAL: return "Windows 2000 UPN"; + case KRB5_NT_WELLKNOWN: return "well-known"; + case KRB5_NT_MS_PRINCIPAL: return "Windows 2000 UPN and SID"; + case KRB5_NT_MS_PRINCIPAL_AND_ID: return "NT 4 style name"; + case KRB5_NT_ENT_PRINCIPAL_AND_ID: return "NT 4 style name and SID"; + default: return "?"; + } +} + static char * trace_format(krb5_context context, const char *fmt, va_list ap) { @@ -207,6 +228,9 @@ trace_format(krb5_context context, const char *fmt, va_list ap) krb5int_buf_add(&buf, str); krb5_free_unparsed_name(context, str); } + } else if (strcmp(tmpbuf, "ptype") == 0) { + p = principal_type_string(va_arg(ap, krb5_int32)); + krb5int_buf_add(&buf, p); } else if (strcmp(tmpbuf, "patypes") == 0) { padata = va_arg(ap, krb5_pa_data **); if (padata == NULL || *padata == NULL)