From e59a4c20c5d0b6f1320095f04d14878c2e40d2a5 Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Tue, 28 Nov 2006 23:02:22 +0000 Subject: [PATCH] pull up r18863 from trunk r18863@cathode-dark-space: jaltman | 2006-11-22 13:11:16 -0500 ticket: new subject: KFW 3.1 commits for Final Release tags: pullup KfW 3.1 final (NetIDMgr 1.1.8.0) nidmgr32.dll (1.1.8.0) - When detecting IP address changes, wait for things to settle down before setting of the IP address change notification. krb5cred.dll (1.1.8.0) - Fixed the Kerberos 5 configuration dialog which didn't handle setting the default realm properly. Setting the default realm now sets the correct string in krb5.ini. - Changing the default realm now marks the relevant configuration node as dirty, and enabled the 'Apply' button. - Changing the 'renewable', 'forwardable' and 'addressless' checkboxes in the identity configuration panels now mark the relevant configuration nodes as dirty, and enables the 'Apply' button. - The location of the Kerberos 5 configuration file is now read-only in the Kerberos 5 configuration dialog. - Set the maximum number of characters for the edit controls in the configuration dialog. krb4cred.dll (1.1.8.0) - The location of the Kerberos 4 configuration files are now read-only in the Kerberos 4 configuration dialog. - Handles setting the ticket string. - Changing the ticket string now marks the relevant configuration node as dirty, and enables the 'Apply' button. - Fixed the plug-in initialization code to perform the initial ticket listing at the end of the initializaton process. ticket: 4861 version_fixed: 1.4.5 git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-4@18867 dc483132-0cff-0310-8789-dd5450dbe970 --- src/windows/identity/config/Makefile.w2k | 2 +- src/windows/identity/config/Makefile.w32 | 2 +- .../identity/plugins/krb4/krb4configdlg.c | 141 +++++++++++++++++- src/windows/identity/plugins/krb4/krb4funcs.c | 24 +++ src/windows/identity/plugins/krb4/krb4funcs.h | 3 + .../identity/plugins/krb4/krb4plugin.c | 9 +- .../identity/plugins/krb4/krbconfig.csv | 1 + .../plugins/krb4/lang/en_us/langres.rc | 37 ++--- .../identity/plugins/krb5/krb5configdlg.c | 141 ++++++++++++++++-- .../identity/plugins/krb5/krb5configid.c | 3 +- src/windows/identity/plugins/krb5/krb5funcs.c | 27 +++- .../plugins/krb5/lang/en_us/langres.rc | 20 +-- src/windows/identity/plugins/krb5/langres.h | 1 + src/windows/identity/ui/addrchange.c | 4 +- 14 files changed, 353 insertions(+), 62 deletions(-) diff --git a/src/windows/identity/config/Makefile.w2k b/src/windows/identity/config/Makefile.w2k index c3c7f030f..b9902bd90 100644 --- a/src/windows/identity/config/Makefile.w2k +++ b/src/windows/identity/config/Makefile.w2k @@ -47,7 +47,7 @@ KHIMAIRA_WIN32_CONFIG=1 # Version info NETIDMGR_VERSION_MAJOR=1 NETIDMGR_VERSION_MINOR=1 -NETIDMGR_VERSION_PATCH=6 +NETIDMGR_VERSION_PATCH=8 NETIDMGR_VERSION_AUX=0 NETIDMGR_RELEASEDESC= diff --git a/src/windows/identity/config/Makefile.w32 b/src/windows/identity/config/Makefile.w32 index e5bb18f9a..c66042689 100644 --- a/src/windows/identity/config/Makefile.w32 +++ b/src/windows/identity/config/Makefile.w32 @@ -47,7 +47,7 @@ KHIMAIRA_WIN32_CONFIG=1 # Version info NETIDMGR_VERSION_MAJOR=1 NETIDMGR_VERSION_MINOR=1 -NETIDMGR_VERSION_PATCH=6 +NETIDMGR_VERSION_PATCH=8 NETIDMGR_VERSION_AUX=0 NETIDMGR_RELEASEDESC= diff --git a/src/windows/identity/plugins/krb4/krb4configdlg.c b/src/windows/identity/plugins/krb4/krb4configdlg.c index 6c2b02d43..94f111cee 100644 --- a/src/windows/identity/plugins/krb4/krb4configdlg.c +++ b/src/windows/identity/plugins/krb4/krb4configdlg.c @@ -307,6 +307,12 @@ krb4_id_config_proc(HWND hwnd, return FALSE; } +typedef struct tag_k4_config_dlg_data { + khui_config_node node; + char krb_path[MAX_PATH]; + char krbrealm_path[MAX_PATH]; + char tkt_string[MAX_PATH]; +} k4_config_dlg_data; INT_PTR CALLBACK krb4_confg_proc(HWND hwnd, @@ -314,6 +320,9 @@ krb4_confg_proc(HWND hwnd, WPARAM wParam, LPARAM lParam) { + static BOOL in_init = FALSE; + k4_config_dlg_data * d; + switch(uMsg) { case WM_INITDIALOG: { @@ -323,8 +332,21 @@ krb4_confg_proc(HWND hwnd, CHAR ticketName[MAX_PATH]; char * pticketName; unsigned int krb_path_sz = sizeof(krb_path); - unsigned int krbrealm_path_sz = sizeof(krbrealm_path); - + unsigned int krbrealm_path_sz = sizeof(krbrealm_path); + khm_size cbsize; + + d = PMALLOC(sizeof(*d)); + ZeroMemory(d, sizeof(*d)); + +#pragma warning(push) +#pragma warning(disable: 4244) + SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d); +#pragma warning(pop) + + d->node = (khui_config_node) lParam; + + in_init = TRUE; + // Set KRB.CON memset(krb_path, '\0', sizeof(krb_path)); if (!pkrb_get_krbconf2(krb_path, &krb_path_sz)) { @@ -332,6 +354,7 @@ krb4_confg_proc(HWND hwnd, } else { // normal find AnsiStrToUnicode(wbuf, sizeof(wbuf), krb_path); SetDlgItemText(hwnd, IDC_CFG_CFGPATH, wbuf); + StringCbCopyA(d->krb_path, sizeof(d->krb_path), krb_path); } // Set KRBREALM.CON @@ -341,26 +364,128 @@ krb4_confg_proc(HWND hwnd, } else { AnsiStrToUnicode(wbuf, sizeof(wbuf), krbrealm_path); SetDlgItemText(hwnd, IDC_CFG_RLMPATH, wbuf); + StringCbCopyA(d->krbrealm_path, sizeof(d->krbrealm_path), + krbrealm_path); } - // Set TICKET.KRB file Editbox - *ticketName = 0; - pkrb_set_tkt_string(0); + cbsize = sizeof(wbuf); + if (KHM_SUCCEEDED(khc_read_string(csp_params, L"TktString", + wbuf, &cbsize)) && + wbuf[0] != L'\0') { + + UnicodeStrToAnsi(ticketName, sizeof(ticketName), wbuf); + + } else { + + // Set TICKET.KRB file Editbox + *ticketName = 0; + pkrb_set_tkt_string(0); - pticketName = ptkt_string(); - if (pticketName) - StringCbCopyA(ticketName, sizeof(ticketName), pticketName); + pticketName = ptkt_string(); + if (pticketName) + StringCbCopyA(ticketName, sizeof(ticketName), pticketName); + + } if (!*ticketName) { // error } else { AnsiStrToUnicode(wbuf, sizeof(wbuf), ticketName); SetDlgItemText(hwnd, IDC_CFG_CACHE, wbuf); + StringCbCopyA(d->tkt_string, sizeof(d->tkt_string), + ticketName); } + + in_init = FALSE; + + } + break; + + case WM_COMMAND: + if (MAKEWPARAM(IDC_CFG_CACHE, EN_CHANGE)) { + char tkt_string[MAX_PATH]; + wchar_t wtkt_string[MAX_PATH]; + + if (in_init) { + return TRUE; + } + + d = (k4_config_dlg_data *) (LONG_PTR) + GetWindowLongPtr(hwnd, DWLP_USER); + + if (d == NULL) + return TRUE; + + tkt_string[0] = 0; + wtkt_string[0] = 0; + + GetDlgItemText(hwnd, IDC_CFG_CACHE, + wtkt_string, ARRAYLENGTH(wtkt_string)); + UnicodeStrToAnsi(tkt_string, sizeof(tkt_string), + wtkt_string); + + if (_stricmp(tkt_string, d->tkt_string)) { + khui_cfg_set_flags(d->node, + KHUI_CNFLAG_MODIFIED, + KHUI_CNFLAG_MODIFIED); + } else { + khui_cfg_set_flags(d->node, + 0, + KHUI_CNFLAG_MODIFIED); + } + + return TRUE; + } + break; + + case KHUI_WM_CFG_NOTIFY: + if (HIWORD(wParam) == WMCFG_APPLY) { + wchar_t wtkt_string[MAX_PATH]; + char tkt_string[MAX_PATH]; + int t; + + d = (k4_config_dlg_data *) (LONG_PTR) + GetWindowLongPtr(hwnd, DWLP_USER); + + if (d == NULL) + return TRUE; + + t = GetDlgItemText(hwnd, IDC_CFG_CACHE, + wtkt_string, ARRAYLENGTH(wtkt_string)); + if (t == 0) + return TRUE; + + UnicodeStrToAnsi(tkt_string, sizeof(tkt_string), wtkt_string); + + if (_stricmp(tkt_string, d->tkt_string)) { + + pkrb_set_tkt_string(tkt_string); + + khc_write_string(csp_params, L"TktString", wtkt_string); + + khui_cfg_set_flags(d->node, + KHUI_CNFLAG_APPLIED, + KHUI_CNFLAG_APPLIED | + KHUI_CNFLAG_MODIFIED); + khm_krb4_list_tickets(); + } else { + khui_cfg_set_flags(d->node, + 0, + KHUI_CNFLAG_MODIFIED); + } + + return TRUE; } break; case WM_DESTROY: + d = (k4_config_dlg_data *) (LONG_PTR) + GetWindowLongPtr(hwnd, DWLP_USER); + + if (d) { + PFREE(d); + } + break; } return FALSE; diff --git a/src/windows/identity/plugins/krb4/krb4funcs.c b/src/windows/identity/plugins/krb4/krb4funcs.c index 728d2db4a..306437a00 100644 --- a/src/windows/identity/plugins/krb4/krb4funcs.c +++ b/src/windows/identity/plugins/krb4/krb4funcs.c @@ -553,6 +553,28 @@ make_postfix(const char * base, return ret; } +void +khm_krb4_set_def_tkt_string(void) { + wchar_t wtkt_string[MAX_PATH]; + char tkt_string[MAX_PATH]; + khm_size cb; + + cb = sizeof(wtkt_string); + + if (KHM_FAILED(khc_read_string(csp_params, L"TktString", + wtkt_string, &cb)) || + wtkt_string[0] == L'\0') { + + pkrb_set_tkt_string(0); + + } else { + + UnicodeStrToAnsi(tkt_string, sizeof(tkt_string), + wtkt_string); + pkrb_set_tkt_string(tkt_string); + } +} + static long @@ -839,6 +861,8 @@ khm_krb4_kinit(char * aname, goto cleanup; } + khm_krb4_set_def_tkt_string(); + err_context = L"fetching ticket"; rc4 = (*pkrb_get_pw_in_tkt)(aname, inst, realm, "krbtgt", realm, lifetime, password); diff --git a/src/windows/identity/plugins/krb4/krb4funcs.h b/src/windows/identity/plugins/krb4/krb4funcs.h index 8abb7ac33..742d13626 100644 --- a/src/windows/identity/plugins/krb4/krb4funcs.h +++ b/src/windows/identity/plugins/krb4/krb4funcs.h @@ -112,6 +112,9 @@ config_boolean_to_int( const char *s ); +void +khm_krb4_set_def_tkt_string(void); + wchar_t * khm_krb5_get_default_realm(void); wchar_t * khm_krb5_get_realm_list(void); diff --git a/src/windows/identity/plugins/krb4/krb4plugin.c b/src/windows/identity/plugins/krb4/krb4plugin.c index c47f5c828..b4edd4192 100644 --- a/src/windows/identity/plugins/krb4/krb4plugin.c +++ b/src/windows/identity/plugins/krb4/krb4plugin.c @@ -162,9 +162,6 @@ krb4_msg_system(khm_int32 msg_type, khm_int32 msg_subtype, khui_cfg_release(idents); - krb4_initialized = TRUE; - - khm_krb4_list_tickets(); } /* Lookup common data types */ @@ -203,6 +200,12 @@ krb4_msg_system(khm_int32 msg_type, khm_int32 msg_subtype, &attr_id_krb5_flags))) { rv = KHM_ERROR_UNKNOWN; } + + krb4_initialized = TRUE; + + khm_krb4_set_def_tkt_string(); + + khm_krb4_list_tickets(); #endif } break; diff --git a/src/windows/identity/plugins/krb4/krbconfig.csv b/src/windows/identity/plugins/krb4/krbconfig.csv index d77abbffa..3d95b40b3 100644 --- a/src/windows/identity/plugins/krb4/krbconfig.csv +++ b/src/windows/identity/plugins/krb4/krbconfig.csv @@ -12,5 +12,6 @@ Krb4Cred,KC_SPACE,0,"Kerberos IV Credentials Provider" DefaultLifetime,KC_INT32,36000,Default ticket lifetime MaxLifetime,KC_INT32,86400,Maximum lifetime MinLifetime,KC_INT32,60,Minimum lifetime + TktString,KC_STRING,,Ticket string. Use default if NULL Parameters,KC_ENDSPACE,0, Krb4Cred,KC_ENDSPACE,0, diff --git a/src/windows/identity/plugins/krb4/lang/en_us/langres.rc b/src/windows/identity/plugins/krb4/lang/en_us/langres.rc index d9114e5b6..cd46a8d9f 100644 --- a/src/windows/identity/plugins/krb4/lang/en_us/langres.rc +++ b/src/windows/identity/plugins/krb4/lang/en_us/langres.rc @@ -57,18 +57,12 @@ STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_SYSMENU EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - CONTROL "Kerberos 4 Ticket Options",IDC_STATIC,"Static", - SS_LEFTNOWORDWRAP | SS_SUNKEN | WS_GROUP,7,7,286,11 - CONTROL "Obtain Kerberos 4 tickets",IDC_NCK4_OBTAIN,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,26,97,10 - GROUPBOX "Obtain Kerberos 4 tickets using",IDC_STATIC,7,43,286,72, - WS_GROUP - CONTROL "Automatically determine method",IDC_NCK4_AUTO,"Button", - BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,23,58,119,10 - CONTROL "Kerberos 5 to 4 translation",IDC_NCK4_K524,"Button", - BS_AUTORADIOBUTTON,23,76,101,10 - CONTROL "Password",IDC_NCK4_PWD,"Button",BS_AUTORADIOBUTTON,23, - 94,47,10 + CONTROL "Kerberos 4 Ticket Options",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | SS_SUNKEN | WS_GROUP,7,7,286,11 + CONTROL "Obtain Kerberos 4 tickets",IDC_NCK4_OBTAIN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,26,97,10 + GROUPBOX "Obtain Kerberos 4 tickets using",IDC_STATIC,7,43,286,72,WS_GROUP + CONTROL "Automatically determine method",IDC_NCK4_AUTO,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,23,58,119,10 + CONTROL "Kerberos 5 to 4 translation",IDC_NCK4_K524,"Button",BS_AUTORADIOBUTTON,23,76,101,10 + CONTROL "Password",IDC_NCK4_PWD,"Button",BS_AUTORADIOBUTTON,23,94,47,10 END IDD_CFG_KRB4 DIALOGEX 0, 0, 255, 182 @@ -79,11 +73,11 @@ BEGIN LTEXT "Ticket cache location",IDC_CFG_LBL_CACHE,7,10,67,8 EDITTEXT IDC_CFG_CACHE,83,7,165,14,ES_AUTOHSCROLL LTEXT "Config file path",IDC_CFG_LBL_CFGFILE,7,30,50,8 - EDITTEXT IDC_CFG_CFGPATH,83,27,113,14,ES_AUTOHSCROLL - PUSHBUTTON "Browse...",IDC_CFG_CFGBROW,200,27,48,14 + EDITTEXT IDC_CFG_CFGPATH,83,27,165,14,ES_AUTOHSCROLL | ES_READONLY + PUSHBUTTON "Browse...",IDC_CFG_CFGBROW,200,95,48,14,NOT WS_VISIBLE LTEXT "Realm file path",IDC_CFG_LBL_RLMPATH,7,50,48,8 - EDITTEXT IDC_CFG_RLMPATH,83,47,113,14,ES_AUTOHSCROLL - PUSHBUTTON "Browse...",IDC_CFG_RLMBROW,200,47,48,14 + EDITTEXT IDC_CFG_RLMPATH,83,47,165,14,ES_AUTOHSCROLL | ES_READONLY + PUSHBUTTON "Browse...",IDC_CFG_RLMBROW,200,127,48,14,NOT WS_VISIBLE END IDD_CFG_IDS_KRB4 DIALOGEX 0, 0, 235, 151 @@ -91,10 +85,8 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - CONTROL "Obtain Kerberos 4 tickets",IDC_CFG_GETTIX,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,7,7,221,17 - LTEXT "Note that, if enabled, Kerberos 4 tickets will be acquired during initial credential acquisition and during credential renewals.\n\nHowever, currently Kerberos 4 tickets can only be obtained for the default identity.", - IDC_STATIC,7,91,221,53,SS_SUNKEN + CONTROL "Obtain Kerberos 4 tickets",IDC_CFG_GETTIX,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,7,221,17 + LTEXT "Note that, if enabled, Kerberos 4 tickets will be acquired during initial credential acquisition and during credential renewals.\n\nHowever, currently Kerberos 4 tickets can only be obtained for the default identity.",IDC_STATIC,7,91,221,53,SS_SUNKEN END IDD_CFG_ID_KRB4 DIALOGEX 0, 0, 235, 151 @@ -102,9 +94,8 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - CONTROL "Obtain Kerberos 4 tickets for this identity", - IDC_CFG_GETTIX,"Button",BS_AUTOCHECKBOX | WS_DISABLED | - WS_TABSTOP,7,7,147,10 + CONTROL "Obtain Kerberos 4 tickets for this identity",IDC_CFG_GETTIX, + "Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,7,7,147,10 END diff --git a/src/windows/identity/plugins/krb5/krb5configdlg.c b/src/windows/identity/plugins/krb5/krb5configdlg.c index 8caafe904..9c8af5dc4 100644 --- a/src/windows/identity/plugins/krb5/krb5configdlg.c +++ b/src/windows/identity/plugins/krb5/krb5configdlg.c @@ -77,6 +77,11 @@ typedef struct tag_k5_config_data { khm_boolean create_config_file; /* create config_file if missing? */ khm_boolean inc_realms; /* include full realm list in new credentials dialog? */ + wchar_t loaded_config_file[MAX_PATH]; /* path to the + configuration file + that has been + loaded into the + realm editor. */ /* [libdefaults] */ khm_boolean dns_lookup_kdc; @@ -548,15 +553,6 @@ k5_write_config_data(k5_config_data * d) { if (!k5_is_profile_loaded()) return; - if (d->flags & K5_CDFLAG_MOD_DEF_REALM) { - if (SUCCEEDED(StringCbLength(d->def_realm, - sizeof(d->def_realm), &s)) && - s > 0) { - khm_krb5_set_default_realm(d->def_realm); - } - d->flags &= ~K5_CDFLAG_MOD_DEF_REALM; - } - /* write the MSLSA import setting */ if (d->flags & K5_CDFLAG_MOD_LSA_IMPORT) { khc_write_int32(csp_params, L"MsLsaImport", d->lsa_import); @@ -569,7 +565,8 @@ k5_write_config_data(k5_config_data * d) { } if (!(d->flags & - (K5_CDFLAG_MOD_CONF_FILE | + (K5_CDFLAG_MOD_DEF_REALM | + K5_CDFLAG_MOD_CONF_FILE | K5_CDFLAG_MOD_DNS_FALLBACK | K5_CDFLAG_MOD_DNS_LOOKUP_RLM | K5_CDFLAG_MOD_DNS_LOOKUP_KDC | @@ -615,6 +612,27 @@ k5_write_config_data(k5_config_data * d) { const char * sec_libdefaults[] = { "libdefaults", NULL, NULL }; khm_size r; + if (d->flags & K5_CDFLAG_MOD_DEF_REALM) { + if (SUCCEEDED(StringCbLength(d->def_realm, + sizeof(d->def_realm), &s)) && + s > 0) { + char defrealm[K5_MAXCCH_REALM]; + + UnicodeStrToAnsi(defrealm, sizeof(defrealm), + d->def_realm); + + khm_krb5_set_default_realm(d->def_realm); + + sec_libdefaults[1] = "default_realm"; + + pprofile_clear_relation(profile, sec_libdefaults); + + rv = pprofile_add_relation(profile, sec_libdefaults, + defrealm); + } + d->flags &= ~K5_CDFLAG_MOD_DEF_REALM; + } + if (d->flags & K5_CDFLAG_MOD_DNS_LOOKUP_KDC) { sec_libdefaults[1] = "dns_lookup_kdc"; @@ -628,7 +646,6 @@ k5_write_config_data(k5_config_data * d) { d->flags &= ~K5_CDFLAG_MOD_DNS_LOOKUP_KDC; } - if (d->flags & K5_CDFLAG_MOD_DNS_LOOKUP_RLM) { sec_libdefaults[1] = "dns_lookup_realm"; @@ -995,8 +1012,13 @@ k5_config_dlgproc(HWND hwnd, SendMessage(hw, CB_SELECTSTRING, -1, (LPARAM) d->def_realm); + SetDlgItemText(hwnd, IDC_CFG_DEFREALM, d->def_realm); + SendDlgItemMessage(hwnd, IDC_CFG_DEFREALM, CB_LIMITTEXT, + ARRAYLENGTH(d->def_realm) - 1, 0); SetDlgItemText(hwnd, IDC_CFG_CFGFILE, d->config_file); + SendDlgItemMessage(hwnd, IDC_CFG_CFGFILE, EM_LIMITTEXT, + ARRAYLENGTH(d->config_file) - 1, 0); /* hostname/domain */ if (NetWkstaGetInfo(NULL, 100, (LPBYTE *) &winfo100) == NERR_Success) { @@ -1046,6 +1068,9 @@ k5_config_dlgproc(HWND hwnd, d = &k5_config_dlg_data; + if (d == NULL) + return FALSE; + if (wParam == MAKEWPARAM(IDC_CFG_IMPORT, CBN_SELCHANGE)) { int idx; int modified = FALSE; @@ -1078,6 +1103,100 @@ k5_config_dlgproc(HWND hwnd, KHUI_CNFLAG_MODIFIED); return TRUE; } + + if (wParam == MAKEWPARAM(IDC_CFG_DEFREALM, CBN_EDITCHANGE)) { + wchar_t defrealm[K5_MAXCCH_REALM]; + int t; + + t = GetDlgItemText(hwnd, IDC_CFG_DEFREALM, + defrealm, ARRAYLENGTH(defrealm)); + if (t == 0) { + /* we failed to get the default realm from the + control for some reason. */ + SetDlgItemText(hwnd, IDC_CFG_DEFREALM, L""); + StringCbCopy(d->def_realm, sizeof(d->def_realm), + L""); + } else { + StringCbCopy(d->def_realm, sizeof(d->def_realm), + defrealm); + } + + d->flags |= K5_CDFLAG_MOD_DEF_REALM; + + khui_cfg_set_flags(d->node_main, + KHUI_CNFLAG_MODIFIED, + KHUI_CNFLAG_MODIFIED); + return TRUE; + } + + if (wParam == MAKEWPARAM(IDC_CFG_DEFREALM, CBN_SELCHANGE)) { + wchar_t defrealm[K5_MAXCCH_REALM]; + LRESULT cursel, lr; + + cursel = SendDlgItemMessage(hwnd, IDC_CFG_DEFREALM, CB_GETCURSEL, + 0, 0); + if (cursel == CB_ERR) + return TRUE; + + lr = SendDlgItemMessage(hwnd, IDC_CFG_DEFREALM, CB_GETLBTEXTLEN, + cursel, 0); +#ifdef DEBUG + assert(lr < ARRAYLENGTH(defrealm)); +#endif + if (lr >= ARRAYLENGTH(defrealm)) { + /* we really shouldn't have any string here that + exceeds that many characters. But if we do, we + ignore that since we don't consider it + valid. */ + return TRUE; + } + + lr = SendDlgItemMessage(hwnd, IDC_CFG_DEFREALM, CB_GETLBTEXT, + cursel, (LPARAM) defrealm); + if (lr == CB_ERR) { + /* somehow we failed to copy the value anyway + after all those checks. */ +#ifdef DEBUG + assert(FALSE); +#endif + return TRUE; + } + + StringCbCopy(d->def_realm, sizeof(d->def_realm), + defrealm); + + d->flags |= K5_CDFLAG_MOD_DEF_REALM; + + khui_cfg_set_flags(d->node_main, + KHUI_CNFLAG_MODIFIED, + KHUI_CNFLAG_MODIFIED); + + return TRUE; + } + +#ifdef ALLOW_CHANGING_KRB5_CONFIG_FILE + if (wParam == MAKEWPARAM(IDC_CFG_CFGFILE, EN_CHANGE)) { + wchar_t cfgfile[MAX_PATH]; + int t; + + t = GetDlgItemText(hwnd, IDC_CFG_CFGFILE, + cfgfile, ARRAYLENGTH(cfgfile)); + + if (t == 0) { + StringCbCopy(d->config_file, sizeof(d->config_file), + L""); + } else { + StringCbCopy(d->config_file, sizeof(d->config_file), + cfgfile); + } + + d->flags |= K5_CDFLAG_MOD_CONF_FILE; + + khui_cfg_set_flags(d->node_main, + KHUI_CNFLAG_MODIFIED, + KHUI_CNFLAG_MODIFIED); + } +#endif } break; diff --git a/src/windows/identity/plugins/krb5/krb5configid.c b/src/windows/identity/plugins/krb5/krb5configid.c index 6e3a45173..e09281906 100644 --- a/src/windows/identity/plugins/krb5/krb5configid.c +++ b/src/windows/identity/plugins/krb5/krb5configid.c @@ -324,7 +324,8 @@ k5_id_tab_dlgproc(HWND hwnd, d = (k5_id_dlg_data *) (LONG_PTR) GetWindowLongPtr(hwnd, DWLP_USER); - if (HIWORD(wParam) == EN_CHANGE) + if (HIWORD(wParam) == EN_CHANGE || + HIWORD(wParam) == BN_CLICKED) k5_id_check_mod(hwnd, d); break; diff --git a/src/windows/identity/plugins/krb5/krb5funcs.c b/src/windows/identity/plugins/krb5/krb5funcs.c index 0ce676caf..85cad1175 100644 --- a/src/windows/identity/plugins/krb5/krb5funcs.c +++ b/src/windows/identity/plugins/krb5/krb5funcs.c @@ -106,9 +106,9 @@ khm_convert524(krb5_context alt_ctx) increds.times.endtime = 0; increds.keyblock.enctype = ENCTYPE_DES_CBC_CRC; if ((code = pkrb5_get_credentials(ctx, 0, - cc, - &increds, - &v5creds))) + cc, + &increds, + &v5creds))) { goto cleanup; } @@ -2108,6 +2108,27 @@ khm_krb5_get_temp_profile_file(LPSTR confname, UINT szConfname) return FALSE; } +#ifdef NOT_QUITE_IMPLEMENTED_YET +BOOL +khm_krb5_set_profile_file(krb5_context ctx, LPSTR confname) +{ + char *conffiles[2]; + + if (confname == NULL || + pkrb5_set_config_files == NULL || + ctx == NULL) + return FALSE; + + conffiles[0] = confname; + conffiles[1] = NULL; + + if (pkrb5_set_config_files(ctx, conffiles)) + return FALSE; + else + return TRUE; +} +#endif + BOOL khm_krb5_get_profile_file(LPSTR confname, UINT szConfname) { diff --git a/src/windows/identity/plugins/krb5/lang/en_us/langres.rc b/src/windows/identity/plugins/krb5/lang/en_us/langres.rc index dde30e387..fca26a1eb 100644 --- a/src/windows/identity/plugins/krb5/lang/en_us/langres.rc +++ b/src/windows/identity/plugins/krb5/lang/en_us/langres.rc @@ -115,19 +115,21 @@ BEGIN END IDD_CONFIG DIALOGEX 0, 0, 255, 182 -STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU +STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN LTEXT "Default Realm",IDC_CFG_LBL_REALM,13,9,46,8 COMBOBOX IDC_CFG_DEFREALM,76,7,166,51,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP - PUSHBUTTON "Configure Realms ...",IDC_CFG_CFGREALMS,76,25,84,14,NOT WS_VISIBLE | WS_DISABLED - GROUPBOX "Keberos Configuration File",IDC_CFG_CFGFILEGRP,7,45,241,61 - LTEXT "Location",IDC_CFG_LBL_CFGFILE,13,61,28,8 - EDITTEXT IDC_CFG_CFGFILE,76,58,119,14,ES_AUTOHSCROLL - PUSHBUTTON "Browse...",IDC_CFG_BROWSE,198,58,44,14 - CONTROL "Create file if missing",IDC_CFG_CREATECONFIG,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,76,90,80,10 - CONTROL "Include realms in New Credentials realm list",IDC_CFG_INCREALMS, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,76,78,153,10 + CONTROL "Include all configured realms in New Credentials realm list",IDC_CFG_INCREALMS, + "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,76,26,166,22 + PUSHBUTTON "Configure Realms ...",IDC_CFG_CFGREALMS,76,46,84,14,NOT WS_VISIBLE | WS_DISABLED + GROUPBOX "Keberos Configuration File",IDC_CFG_CFGFILEGRP,7,59,241,47 + LTEXT "Location",IDC_CFG_LBL_CFGFILE,13,74,28,8 + EDITTEXT IDC_CFG_CFGFILE,76,71,166,14,ES_AUTOHSCROLL | ES_READONLY + PUSHBUTTON "Browse...",IDC_CFG_BROWSE,145,89,44,14,NOT WS_VISIBLE + CONTROL "Create file if missing",IDC_CFG_CREATECONFIG,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,76,93,80,10 + PUSHBUTTON "Load into realm editor ...",IDC_CFG_BROWSE2,26,89,100,14,NOT WS_VISIBLE GROUPBOX "Windows® Options",IDC_CFG_WINGRP,7,110,241,65 LTEXT "Hostname",IDC_CFG_LBL_HOSTNAME,13,123,33,8 EDITTEXT IDC_CFG_HOSTNAME,76,120,166,14,ES_AUTOHSCROLL | ES_READONLY diff --git a/src/windows/identity/plugins/krb5/langres.h b/src/windows/identity/plugins/krb5/langres.h index da8a62ffd..9381b99ee 100644 --- a/src/windows/identity/plugins/krb5/langres.h +++ b/src/windows/identity/plugins/krb5/langres.h @@ -166,6 +166,7 @@ #define IDC_CFG_BROWSE 1039 #define IDC_CFG_CFGFILEGRP 1040 #define IDC_CFG_CFGREALMS 1041 +#define IDC_CFG_BROWSE2 1042 #define IDC_CFG_REALMS 1044 #define IDC_CFG_DOMAINGRP 1045 #define IDC_CFG_SERVERSGRP 1046 diff --git a/src/windows/identity/ui/addrchange.c b/src/windows/identity/ui/addrchange.c index 8a671b3c9..3e5467ccc 100644 --- a/src/windows/identity/ui/addrchange.c +++ b/src/windows/identity/ui/addrchange.c @@ -57,8 +57,8 @@ addr_change_thread(LPVOID dummy) { ret = WaitForMultipleObjects(2, h_waits, FALSE, INFINITE); if ( ret == WAIT_OBJECT_0 ) { - kmq_post_message(KMSG_CRED, KMSG_CRED_ADDR_CHANGE, - 0, 0); + Sleep(3000); /* wait for things to settle down */ + kmq_post_message(KMSG_CRED, KMSG_CRED_ADDR_CHANGE, 0, 0); } else { goto _end_thread; } -- 2.26.2