krb5 commit: Add support for "{ptype}" trace format specifier

Tom Yu tlyu at MIT.EDU
Wed May 23 15:57:54 EDT 2012


https://github.com/krb5/krb5/commit/27417b7d27bd61acf567da2ddccc591b7f499e47
commit 27417b7d27bd61acf567da2ddccc591b7f499e47
Author: W. Trevor King <wking at tremily.us>
Date:   Thu May 17 21:10:20 2012 -0400

    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

 src/include/k5-trace.h  |    1 +
 src/lib/krb5/os/trace.c |   24 ++++++++++++++++++++++++
 2 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/src/include/k5-trace.h b/src/include/k5-trace.h
index ee826ec..c889c50 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 bc52f2b..f3e1d89 100644
--- a/src/lib/krb5/os/trace.c
+++ b/src/lib/krb5/os/trace.c
@@ -64,6 +64,27 @@ hash_bytes(krb5_context context, const void *ptr, size_t len)
 }
 
 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)
 {
     struct k5buf buf;
@@ -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)


More information about the cvs-krb5 mailing list