krb5 commit: KfW GUI -- show ticket flags
Benjamin Kaduk
kaduk at MIT.EDU
Mon Aug 27 11:52:12 EDT 2012
https://github.com/krb5/krb5/commit/ae2b7f989b34e14d03005fb5f45f3314ddab84b9
commit ae2b7f989b34e14d03005fb5f45f3314ddab84b9
Author: Kevin Wasserman <kevin.wasserman at painless-security.com>
Date: Wed Jun 27 19:05:22 2012 -0400
KfW GUI -- show ticket flags
Signed-off-by: Kevin Wasserman <kevin.wasserman at painless-security.com>
ticket: 7280 (new)
queue: kfw
target_version: 1.10.4
tags: pullup
src/windows/leash/LeashView.cpp | 47 ++++++++++++++++++++++++++++++++++++++-
1 files changed, 46 insertions(+), 1 deletions(-)
diff --git a/src/windows/leash/LeashView.cpp b/src/windows/leash/LeashView.cpp
index 11902dd..be4a8a5 100644
--- a/src/windows/leash/LeashView.cpp
+++ b/src/windows/leash/LeashView.cpp
@@ -151,6 +151,47 @@ ViewColumnInfo CLeashView::sm_viewColumns[] =
{"Flags", false, ID_SHOW_TICKET_FLAGS, 100}, // TICKET_FLAGS
};
+static struct TicketFlag {
+ unsigned long m_flag;
+ const LPTSTR m_description;
+} sm_TicketFlags[] =
+{
+ {TKT_FLG_FORWARDABLE, _T("Forwardable")},
+ {TKT_FLG_FORWARDED, _T("Forwarded")},
+ {TKT_FLG_PROXIABLE, _T("Proxiable")},
+ {TKT_FLG_PROXY, _T("Proxy")},
+ {TKT_FLG_RENEWABLE, _T("Renewable")},
+};
+
+static void krb5TicketFlagsToString(unsigned long flags, LPTSTR *outStr)
+{
+ const int numFlags = sizeof(sm_TicketFlags) / sizeof(sm_TicketFlags[0]);
+ int strSize = 1;
+ LPTSTR str;
+ // pass 1: compute size
+ for (int i = 0; i < numFlags; i++) {
+ if (flags & sm_TicketFlags[i].m_flag) {
+ if (strSize > 1)
+ strSize += 2;
+ strSize += strlen(sm_TicketFlags[i].m_description);
+ }
+ }
+ // allocate
+ str = (LPSTR)malloc(strSize);
+ if (str != NULL) {
+ *str = 0;
+ // pass 2: construct string
+ for (int i = 0; i < numFlags; i++) {
+ if (flags & sm_TicketFlags[i].m_flag) {
+ if (str[0])
+ _tcscat_s(str, strSize, _T(", "));
+ _tcscat_s(str, strSize, sm_TicketFlags[i].m_description);
+ }
+ }
+ }
+ *outStr = str;
+}
+
static HFONT CreateBoldFont(HFONT font)
{
@@ -1053,6 +1094,7 @@ void CLeashView::AddDisplayItem(CListCtrl &list,
{
TCHAR* localTimeStr=NULL;
TCHAR* durationStr=NULL;
+ TCHAR* flagsStr=NULL;
TCHAR tempStr[MAX_DURATION_STR+1];
time_t now = LeashTime();
@@ -1104,8 +1146,11 @@ void CLeashView::AddDisplayItem(CListCtrl &list,
list.SetItemText(iItem, iSubItem++, encTypes);
}
if (sm_viewColumns[TICKET_FLAGS].m_enabled) {
- list.SetItemText(iItem, iSubItem++, "ticket flags here");
+ krb5TicketFlagsToString(flags, &flagsStr);
+ list.SetItemText(iItem, iSubItem++, flagsStr);
}
+ if (flagsStr)
+ free(flagsStr);
if (localTimeStr)
free(localTimeStr);
if (durationStr)
More information about the cvs-krb5
mailing list