diff options
| author | Kevin Wasserman <kevin.wasserman@painless-security.com> | 2012-07-01 21:06:46 -0400 |
|---|---|---|
| committer | Ben Kaduk <kaduk@mit.edu> | 2012-08-27 19:27:23 -0400 |
| commit | 16eb02cfaad02444e553c9a7af37917f02c60ba2 (patch) | |
| tree | a61b5dd39dcb8180eccb46e42a7334d4d3a628cd /src/windows/leash | |
| parent | e2b8cf10d536eeb1616f5b5e40fd41c691f24e29 (diff) | |
| download | krb5-16eb02cfaad02444e553c9a7af37917f02c60ba2.tar.gz krb5-16eb02cfaad02444e553c9a7af37917f02c60ba2.tar.xz krb5-16eb02cfaad02444e553c9a7af37917f02c60ba2.zip | |
Update kfw change password dialog
Use combined username/realm principal edit control.
Signed-off-by: Kevin Wasserman <kevin.wasserman@painless-security.com>
ticket: 7297 (new)
queue: kfw
target_version: 1.10.4
tags: pullup
Diffstat (limited to 'src/windows/leash')
| -rw-r--r-- | src/windows/leash/LeashView.cpp | 81 |
1 files changed, 54 insertions, 27 deletions
diff --git a/src/windows/leash/LeashView.cpp b/src/windows/leash/LeashView.cpp index 043ed5fae..7b5ba17d2 100644 --- a/src/windows/leash/LeashView.cpp +++ b/src/windows/leash/LeashView.cpp @@ -1026,47 +1026,74 @@ VOID CLeashView::OnMakeDefault() VOID CLeashView::OnChangePassword() { - if (!m_hWnd) - { - AfxMessageBox("There is a problem finding the Leash Window!", - MB_OK|MB_ICONSTOP); - return; - } + krb5_context ctx; + krb5_ccache ccache = 0; + krb5_principal princ = 0; + char *pname = NULL; + char *username = NULL; + char *realm = NULL; + int code = 0; - if (WaitForSingleObject( ticketinfo.lockObj, INFINITE ) != WAIT_OBJECT_0) - throw("Unable to lock ticketinfo"); + CCacheDisplayData *elem = m_ccacheDisplay; + while (elem != NULL) { + if (elem->m_selected) { + if (elem->m_ccacheName) + break; + } + elem = elem->m_next; + } + if (elem != NULL) { + code = pkrb5_init_context(&ctx); + if (code) { + // TODO: spew error + goto cleanup; + } + code = pkrb5_cc_resolve(ctx, elem->m_ccacheName, &ccache); + if (code) { + // TODO: spew error + goto cleanup; + } + code = pkrb5_cc_get_principal(ctx, ccache, &princ); + if (code) { + goto cleanup; + } + code = pkrb5_unparse_name(ctx, princ, &pname); + if (code) { + goto cleanup; + } + } LSH_DLGINFO_EX ldi; - char username[64]; - char realm[192]; - char * principal = ticketinfo.Krb5.principal; - int i=0, j=0; - if (principal) - for (; principal[i] && principal[i] != '@'; i++) - username[i] = principal[i]; - username[i] = '\0'; - if (principal && principal[i]) - for (i++ ; principal[i] ; i++, j++) - realm[j] = principal[i]; - realm[j] = '\0'; - ReleaseMutex(ticketinfo.lockObj); - + if (pname != NULL) { + username = pname; + realm = strchr(pname, '@'); + if (realm != NULL) + *realm++ = '\0'; + } ldi.size = sizeof(ldi); ldi.dlgtype = DLGTYPE_CHPASSWD; ldi.title = ldi.in.title; - strcpy(ldi.in.title,"Change Password"); + strcpy_s(ldi.in.title, "MIT Kerberos: Change Password"); ldi.username = ldi.in.username; - strcpy(ldi.in.username,username); + strcpy_s(ldi.in.username, username ? username : ""); ldi.realm = ldi.in.realm; - strcpy(ldi.in.realm,realm); + strcpy_s(ldi.in.realm, realm ? realm : ""); ldi.use_defaults = 1; int result = pLeash_changepwd_dlg_ex(m_hWnd, &ldi); - if (-1 == result) - { + if (-1 == result) { AfxMessageBox("There is a problem changing password!", MB_OK|MB_ICONSTOP); } +cleanup: + if (pname != NULL) + pkrb5_free_unparsed_name(ctx, pname); + if (princ != NULL) + pkrb5_free_principal(ctx, princ); + if (ccache != NULL) + pkrb5_cc_close(ctx, ccache); + if (ctx != NULL) + pkrb5_free_context(ctx); } static CCacheDisplayData ** |
