From 1384e5b47387b60e51995a59bc160fca51e312e8 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Thu, 5 Feb 2004 08:04:45 +0000 Subject: [PATCH] Add support for specifying the credential cache to be used as well as fix a few minor user interface bugs ticket: new target_version: 1.3.2 tags: pullup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16021 dc483132-0cff-0310-8789-dd5450dbe970 --- src/windows/gss/ChangeLog | 14 ++++- src/windows/gss/Makefile.in | 9 ++- src/windows/gss/gss-client.c | 28 +++++---- src/windows/gss/gss.c | 106 ++++++++++++++++++++++++++++++++--- src/windows/gss/gss.h | 2 +- src/windows/gss/gss.rc | 33 ++++++----- src/windows/gss/resource.h | 5 +- 7 files changed, 160 insertions(+), 37 deletions(-) diff --git a/src/windows/gss/ChangeLog b/src/windows/gss/ChangeLog index e989480f2..2b66b030a 100644 --- a/src/windows/gss/ChangeLog +++ b/src/windows/gss/ChangeLog @@ -1,3 +1,15 @@ +2004-02-04 Jeffrey Altman + + * resource.h: add new component id values for ccache + + * Makefile.in: add conditional linkage to krbcc32.lib (if KRB5_KFW_BUILD) + + * gss.rc: add new component for ccache selection + + * gss.h, gss.c, gss-client.c: add support for ccache selection and + if built with USE_LEASH add support for dynamic querying of the + available ccache list + 2004-01-30 Jeffrey Altman * resource.h: new file containing new ui component id values @@ -7,7 +19,7 @@ * gss.h, gss-misc.c, gss-client.c: Updates to support new UI and corrections to add compatibility with the Unix gss-server - * Makefile: add linkage to comctl32.lib + * Makefile.in: add linkage to comctl32.lib 2002-06-13 Ken Raeburn diff --git a/src/windows/gss/Makefile.in b/src/windows/gss/Makefile.in index c88452667..1c4baa1af 100644 --- a/src/windows/gss/Makefile.in +++ b/src/windows/gss/Makefile.in @@ -8,7 +8,12 @@ XOBJS = $(RESFILE) ##### Options # Set NODEBUG if building release instead of debug BUILDTOP=..\.. -LOCALINCLUDES= /I$(BUILDTOP)\include /I$(BUILDTOP)\include\krb5 + +!if defined(KRB5_KFW_COMPILE) +KFWINC= /I$(BUILDTOP)\..\..\krbcc\include +KFWLIB= krbcc32.lib +!endif +LOCALINCLUDES= /I$(BUILDTOP)\include /I$(BUILDTOP)\include\krb5 $(KFWINC) ##### RC Compiler RFLAGS = $(LOCALINCLUDES) @@ -17,7 +22,7 @@ RCFLAGS = $(RFLAGS) -D_WIN32 -DGSS_APP ##### Linker LINK = link LIBS = $(GLIB) $(CLIB) $(WLIB) -SYSLIBS = kernel32.lib ws2_32.lib user32.lib gdi32.lib comdlg32.lib comctl32.lib +SYSLIBS = kernel32.lib ws2_32.lib user32.lib gdi32.lib comdlg32.lib comctl32.lib $(KFWLIB) LFLAGS = /nologo $(LOPTS) all:: Makefile $(OUTPRE)gss.exe diff --git a/src/windows/gss/gss-client.c b/src/windows/gss/gss-client.c index 848f226cd..e014c35d8 100644 --- a/src/windows/gss/gss-client.c +++ b/src/windows/gss/gss-client.c @@ -27,6 +27,7 @@ #include #include +#include #include "gss.h" #include "gss-misc.h" @@ -546,27 +547,34 @@ static void parse_oid(char *mechanism, gss_OID *oid) int gss (char *server_host, char *service_name, char *mechanism, char *msg, int port, int verbose, int delegate, int v1_format, int auth_flag, int wrap_flag, - int encrypt_flag, int mic_flag, int ccount, int mcount) + int encrypt_flag, int mic_flag, int ccount, int mcount, char *ccache) { int use_file = 0; OM_uint32 deleg_flag = (delegate ? GSS_C_DELEG_FLAG : 0), min_stat; gss_OID oid = GSS_C_NULL_OID; + OM_uint32 minor_status; int i; int rc = 0; - if (ccount <= 0) ccount = 1; - if (mcount <= 0) mcount = 1; + if (ccount <= 0) ccount = 1; + if (mcount <= 0) mcount = 1; - if (mechanism && mechanism[0]) - parse_oid(mechanism, &oid); + if (mechanism && mechanism[0]) + parse_oid(mechanism, &oid); - for (i = 0; i < ccount; i++) { - if (call_server(server_host, port, oid, service_name, + /* By using this function the independence between the application and + * the underlying authentication system is broken + */ + if ( ccache && ccache[0] ) + gss_krb5_ccache_name(&minor_status, ccache, NULL); + + for (i = 0; i < ccount; i++) { + if (call_server(server_host, port, oid, service_name, deleg_flag, auth_flag, wrap_flag, encrypt_flag, mic_flag, v1_format, msg, use_file, mcount) < 0) - rc = -1; - break; - } + rc = -1; + break; + } if (oid != GSS_C_NULL_OID) (void) gss_release_oid(&min_stat, &oid); diff --git a/src/windows/gss/gss.c b/src/windows/gss/gss.c index 4254211a6..6d9ac469b 100644 --- a/src/windows/gss/gss.c +++ b/src/windows/gss/gss.c @@ -11,6 +11,10 @@ #include #include #include "gss.h" +#include +#ifdef USE_LEASH +#include +#endif #include "resource.h" @@ -38,6 +42,7 @@ #define INI_LAST_NOWRAP "No Wrap" #define INI_LAST_NOCRYPT "No Encrypt" #define INI_LAST_NOMIC "No Mic" +#define INI_LAST_CCACHE "CCache" #define MAX_SAVED 9 char hosts[MAX_SAVED][256]; @@ -48,6 +53,7 @@ char szHost[256]; // GSSAPI Host to connect to char szService[256]; // Service to do char szMessage[256]; // Message to send char szMech[256]; // OID to use +char szCCache[256]; // CCache to use int port = 0; // Which port to use int delegate = 0; // Delegate? int verbose = 1; // Verbose? @@ -118,7 +124,8 @@ do_gssapi_test (void) { hcursor = SetCursor(LoadCursor(NULL, IDC_WAIT)); n = gss (szHost, szService, szMech, szMessage[0] ? szMessage : "Test Gssapi Message", port, - verbose, delegate, gssv1, !noauth, !nowrap, !nocrypt, !nomic, ccount, mcount); + verbose, delegate, gssv1, !noauth, !nowrap, !nocrypt, !nomic, ccount, mcount, + szCCache); SetCursor(hcursor); if (n) @@ -146,7 +153,7 @@ OpenGssapiDlg( HDC hDC; // For getting graphic info DWORD Ext; // Size of dialog int xExt, yExt; // Size broken apart - char buff[32]; + char buff[64]; switch (message) { case WM_INITDIALOG: @@ -171,6 +178,49 @@ OpenGssapiDlg( SendMessage(hDlg, WM_SETFOCUS, 0, 0); return (TRUE); + case WM_HSCROLL: + switch (LOWORD(wParam)) { + case TB_THUMBTRACK: + case TB_THUMBPOSITION: + { + long pos = HIWORD(wParam); // the position of the slider + int ctrlID = GetDlgCtrlID((HWND)lParam); + + if (ctrlID == GSS_CALL_COUNT) { + sprintf(buff,"Call Count: %d",pos); + SetWindowText(GetDlgItem(hDialog, IDC_STATIC_CCOUNT),buff); + } + if (ctrlID == GSS_MESSAGE_COUNT) { + sprintf(buff,"Message Count: %d",pos); + SetWindowText(GetDlgItem(hDialog, IDC_STATIC_MSG_COUNT),buff); + } + } + break; + case TB_BOTTOM: + case TB_TOP: + case TB_ENDTRACK: + case TB_LINEDOWN: + case TB_LINEUP: + case TB_PAGEDOWN: + case TB_PAGEUP: + default: + { + int ctrlID = GetDlgCtrlID((HWND)lParam); + long pos = SendMessage(GetDlgItem(hDialog,ctrlID), TBM_GETPOS, 0, 0); // the position of the slider + + if (ctrlID == GSS_CALL_COUNT) { + sprintf(buff,"Call Count: %d",pos); + SetWindowText(GetDlgItem(hDialog, IDC_STATIC_CCOUNT),buff); + } + if (ctrlID == GSS_MESSAGE_COUNT) { + sprintf(buff,"Message Count: %d",pos); + SetWindowText(GetDlgItem(hDialog, IDC_STATIC_MSG_COUNT),buff); + } + } + } + break; + + case WM_COMMAND: switch (wParam) { case GSS_CANCEL: // Only way out of the dialog @@ -196,6 +246,7 @@ OpenGssapiDlg( } GetDlgItemText(hDlg, GSS_MECHANISM, szMech, 256); + GetDlgItemText(hDlg, GSS_CCACHE_NAME, szCCache, 256); GetDlgItemText(hDlg, GSS_MESSAGE, szMessage, 256); GetDlgItemText(hDlg, GSS_PORT, buff, 32); if (!*buff) { @@ -224,7 +275,7 @@ OpenGssapiDlg( update_saved (); // Add it to the host list fill_combo (hDlg); // Update the combo box - SetDlgItemText(hDlg, GSS_OUTPUT, "", 0); + SetDlgItemText(hDlg, GSS_OUTPUT, ""); do_gssapi_test (); // Test GSSAPI //EndDialog(hDlg, TRUE); @@ -342,6 +393,7 @@ read_saved (void) { GetPrivateProfileString(INI_LAST, INI_LAST_SVC, "", szService, 256, GSSAPI_INI); GetPrivateProfileString(INI_LAST, INI_LAST_MSG, "", szMessage, 256, GSSAPI_INI); GetPrivateProfileString(INI_LAST, INI_LAST_MECH, "", szMech, 256, GSSAPI_INI); + GetPrivateProfileString(INI_LAST, INI_LAST_CCACHE, "", szCCache, 256, GSSAPI_INI); GetPrivateProfileString(INI_LAST, INI_LAST_DELEGATE, "", buff, 32, GSSAPI_INI); if ( buff[0] ) delegate = atoi(buff); @@ -412,6 +464,7 @@ write_saved () { WritePrivateProfileString(INI_LAST, INI_LAST_PORT, buff, GSSAPI_INI); WritePrivateProfileString(INI_LAST, INI_LAST_SVC, szService, GSSAPI_INI); WritePrivateProfileString(INI_LAST, INI_LAST_MECH, szMech, GSSAPI_INI); + WritePrivateProfileString(INI_LAST, INI_LAST_CCACHE, szCCache, GSSAPI_INI); WritePrivateProfileString(INI_LAST, INI_LAST_MSG, szMessage, GSSAPI_INI); wsprintf(buff, "%d", delegate); WritePrivateProfileString(INI_LAST, INI_LAST_DELEGATE, buff, GSSAPI_INI); @@ -492,7 +545,12 @@ update_saved (void) { static void fill_combo (HWND hDlg) { int i; // Index - char buff[32]; + char buff[256]; +#ifdef USE_LEASH + krb5_error_code retval; + apiCB * cc_ctx = 0; + struct _infoNC ** pNCi = 0; +#endif SendDlgItemMessage(hDlg, GSS_HOST_NAME, CB_RESETCONTENT, 0, 0); SetDlgItemText(hDlg, GSS_HOST_NAME, szHost); @@ -521,6 +579,37 @@ fill_combo (HWND hDlg) { SendDlgItemMessage(hDlg, GSS_MECHANISM, CB_ADDSTRING, 0, (LPARAM) ((LPSTR) mechs[i])); } + SendDlgItemMessage(hDlg, GSS_CCACHE_NAME, CB_RESETCONTENT, 0, 0); + SetDlgItemText(hDlg, GSS_CCACHE_NAME, szCCache); + SendDlgItemMessage(hDlg, GSS_CCACHE_NAME, CB_SETEDITSEL, 0, 0); + +#ifdef USE_LEASH + retval = cc_initialize(&cc_ctx, CC_API_VER_2, NULL, NULL); + if (retval) + goto skip_ccache; + + retval = cc_get_NC_info(cc_ctx, &pNCi); + if (retval) + goto clean_ccache; + + for ( i=0; pNCi[i]; i++ ) { + if (pNCi[i]->vers == CC_CRED_V5) { + sprintf(buff,"API:%s",pNCi[i]->name); + SendDlgItemMessage(hDlg, GSS_CCACHE_NAME, CB_ADDSTRING, 0, (LPARAM) ((LPSTR) buff)); + } + } + + clean_ccache: + if (pNCi) + cc_free_NC_info(cc_ctx, &pNCi); + if (cc_ctx) + cc_shutdown(&cc_ctx); + skip_ccache: +#endif /* USE_LEASH */ + if ( szCCache[0] ) + SendDlgItemMessage(hDlg, GSS_CCACHE_NAME, CB_ADDSTRING, 0, (LPARAM) ((LPSTR) szCCache)); + SendDlgItemMessage(hDlg, GSS_CCACHE_NAME, CB_ADDSTRING, 0, (LPARAM) ((LPSTR) "MSLSA:")); + SendDlgItemMessage(hDlg, GSS_MESSAGE, CB_RESETCONTENT, 0, 0); SetDlgItemText(hDlg, GSS_MESSAGE, szMessage); SendDlgItemMessage(hDlg, GSS_MESSAGE, CB_SETEDITSEL, 0, 0); @@ -553,14 +642,17 @@ fill_combo (HWND hDlg) { EnableWindow(GetDlgItem(hDlg, GSS_NO_MIC), TRUE); } - SendDlgItemMessage(hDlg, GSS_CALL_COUNT, TBM_SETRANGEMIN, (WPARAM) FALSE, (LPARAM) 0); + SendDlgItemMessage(hDlg, GSS_CALL_COUNT, TBM_SETRANGEMIN, (WPARAM) FALSE, (LPARAM) 1); SendDlgItemMessage(hDlg, GSS_CALL_COUNT, TBM_SETRANGEMAX, (WPARAM) FALSE, (LPARAM) 20); SendDlgItemMessage(hDlg, GSS_CALL_COUNT, TBM_SETPOS, (WPARAM) FALSE, (LPARAM) ccount); + sprintf(buff,"Call Count: %d",ccount); + SetWindowText(GetDlgItem(hDialog, IDC_STATIC_CCOUNT),buff); - SendDlgItemMessage(hDlg, GSS_MESSAGE_COUNT, TBM_SETRANGEMIN, (WPARAM) FALSE, (LPARAM) 0); + SendDlgItemMessage(hDlg, GSS_MESSAGE_COUNT, TBM_SETRANGEMIN, (WPARAM) FALSE, (LPARAM) 1); SendDlgItemMessage(hDlg, GSS_MESSAGE_COUNT, TBM_SETRANGEMAX, (WPARAM) FALSE, (LPARAM) 20); SendDlgItemMessage(hDlg, GSS_MESSAGE_COUNT, TBM_SETPOS, (WPARAM) FALSE, (LPARAM) mcount); - + sprintf(buff,"Message Count: %d",mcount); + SetWindowText(GetDlgItem(hDialog, IDC_STATIC_MSG_COUNT),buff); } int diff --git a/src/windows/gss/gss.h b/src/windows/gss/gss.h index 8dcf4fcd0..8eec4a73c 100644 --- a/src/windows/gss/gss.h +++ b/src/windows/gss/gss.h @@ -27,7 +27,7 @@ void my_perror (char *msg); int gss (char *server_host, char *service_name, char *mechanism, char *msg, int port, int verbose, int delegate, int v1_format, int auth_flag, int wrap_flag, - int encrypt_flag, int mic_flag, int ccount, int mcount); + int encrypt_flag, int mic_flag, int ccount, int mcount, char * ccache); int call_server(char *host, u_short port, gss_OID oid, char *service_name, OM_uint32 deleg_flag, int auth_flag, int wrap_flag, int encrypt_flag, int mic_flag, int v1_format, diff --git a/src/windows/gss/gss.rc b/src/windows/gss/gss.rc index bc4a622df..e3c1e9056 100644 --- a/src/windows/gss/gss.rc +++ b/src/windows/gss/gss.rc @@ -1,8 +1,6 @@ -//Microsoft Developer Studio generated resource script. +// Microsoft Visual C++ generated resource script. // -#include "resource.h" - #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // @@ -11,6 +9,7 @@ #define APSTUDIO_HIDDEN_SYMBOLS #include "windows.h" #undef APSTUDIO_HIDDEN_SYMBOLS +#include "resource.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS @@ -31,34 +30,38 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. -GSS ICON DISCARDABLE "gss.ico" +GSS ICON "gss.ico" ///////////////////////////////////////////////////////////////////////////// // // Dialog // -GSSAPIDLG DIALOG DISCARDABLE 63, 65, 330, 311 -STYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_CAPTION | WS_SYSMENU +GSSAPIDLG DIALOGEX 63, 65, 330, 311 +STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_CAPTION | + WS_SYSMENU CAPTION "Test GSSAPI Connection" -FONT 8, "MS Sans Serif" +FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN - RTEXT "Hostname:",IDC_STATIC_PORT,5,12,60,10,NOT WS_GROUP - COMBOBOX GSS_HOST_NAME,70,9,246,60,CBS_DROPDOWN | CBS_AUTOHSCROLL | + RTEXT "Hostname:",IDC_STATIC_HOST,5,12,60,10,NOT WS_GROUP + COMBOBOX GSS_HOST_NAME,70,9,245,60,CBS_DROPDOWN | CBS_AUTOHSCROLL | WS_VSCROLL | WS_GROUP | WS_TABSTOP DEFPUSHBUTTON "Test",GSS_OK,80,290,51,14,WS_GROUP PUSHBUTTON "Exit",GSS_CANCEL,185,290,51,14 RTEXT "Port:",IDC_STATIC_PORT,16,27,50,8 EDITTEXT GSS_PORT,70,25,40,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER - COMBOBOX GSS_SERVICE_NAME,69,41,246,30,CBS_DROPDOWN | CBS_SORT | + COMBOBOX GSS_SERVICE_NAME,70,41,245,60,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP RTEXT "GSS Service Name:",IDC_STATIC_SERVICE,1,44,64,8 - COMBOBOX GSS_MECHANISM,70,110,245,30,CBS_DROPDOWN | + COMBOBOX GSS_CCACHE_NAME,70,69,245,60,CBS_DROPDOWN | CBS_SORT | + WS_VSCROLL | WS_TABSTOP + RTEXT "CCache Name:",IDC_STATIC_CCACHE,16,71,49,8 + COMBOBOX GSS_MECHANISM,70,110,245,60,CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP RTEXT "Mechanism (OID):",IDC_STATIC_MECH,0,115,65,8 RTEXT "Test Message:",IDC_STATIC_MSG,0,55,65,8 - COMBOBOX GSS_MESSAGE,70,55,245,30,CBS_DROPDOWN | CBS_AUTOHSCROLL | + COMBOBOX GSS_MESSAGE,70,55,245,60,CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP LTEXT "The following items are optional and should only be altered by those who understand their implications.", IDC_STATIC_OPTIONS,10,85,305,20 @@ -95,12 +98,12 @@ END // TEXTINCLUDE // -1 TEXTINCLUDE DISCARDABLE +1 TEXTINCLUDE BEGIN "resrc1.h\0" END -2 TEXTINCLUDE DISCARDABLE +2 TEXTINCLUDE BEGIN "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" "#include ""windows.h""\r\n" @@ -109,7 +112,7 @@ BEGIN "\0" END -3 TEXTINCLUDE DISCARDABLE +3 TEXTINCLUDE BEGIN "\r\n" "\0" diff --git a/src/windows/gss/resource.h b/src/windows/gss/resource.h index 39abfe636..5de4525fc 100644 --- a/src/windows/gss/resource.h +++ b/src/windows/gss/resource.h @@ -28,6 +28,9 @@ #define GSS_OK 1024 #define GSS_CANCEL 1025 #define IDC_STATIC_PORT 1026 +#define IDC_STATIC_HOST 1027 +#define GSS_CCACHE_NAME 1028 +#define IDC_STATIC_CCACHE 1029 #define IDD_GSSAPIDLG 101 @@ -38,7 +41,7 @@ #define _APS_NO_MFC 1 #define _APS_NEXT_RESOURCE_VALUE 102 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1027 +#define _APS_NEXT_CONTROL_VALUE 1030 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif -- 2.26.2