From: Jeffrey Altman Date: Tue, 6 Dec 2005 01:06:13 +0000 (+0000) Subject: KFW 3.0 Final Network Identity Manager updates X-Git-Tag: ms-bug-test-20060525~39 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6122981fdebaef3a11c57bf439133bd410b9523e;p=krb5.git KFW 3.0 Final Network Identity Manager updates Add new documentation files Add new icons Add "set default" functionality to the New Credentials dialog Remove inconsistencies in the Options configuration dialog Replace the menu bar so that it responds to Alt- and keyboard shortcuts Fix an --autoinit race condition many more things.... ticket: new target_version: 1.4.4 status: resolved tags: pullup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17546 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/windows/identity/apiversion.txt b/src/windows/identity/apiversion.txt index c382eb52e..e2367db2a 100644 --- a/src/windows/identity/apiversion.txt +++ b/src/windows/identity/apiversion.txt @@ -44,11 +44,14 @@ Date=NOTRELEASED Version=2 AppVersion=0.1.1.0 Date=Nov 01, 2005 -# Beta 1 release of NetIDMgr +# Alpha 1 release of NetIDMgr, along with KFW 3.0.0 beta #---------------------------------------------------------------- Version=3 AppVersion=0.1.2.0 Date=Nov 30, 2005 -# Beta 2 release +# Alpha 2 release of NetIDMgr, along with KFW 3.0.0 beta 2 +Version=4 +AppVersion=1.0.0.0 +Date=Dec 05, 2005 diff --git a/src/windows/identity/config/Makefile.w32 b/src/windows/identity/config/Makefile.w32 index 49524dfd9..264d19ed2 100644 --- a/src/windows/identity/config/Makefile.w32 +++ b/src/windows/identity/config/Makefile.w32 @@ -3,7 +3,7 @@ # This file will be included by all the makefiles # in the build tree. # -# Copyright (c) 2004 Massachusetts Institute of Technology +# Copyright (c) 2004,2005 Massachusetts Institute of Technology # # Permission is hereby granted, free of charge, to any person # obtaining a copy of this software and associated documentation files @@ -44,11 +44,11 @@ KHIMAIRA_WIN32_CONFIG=1 # SPECIAL : Special build. Typically one with non-mainline patches. # Version info -NETIDMGR_VERSION_MAJOR=0 -NETIDMGR_VERSION_MINOR=1 -NETIDMGR_VERSION_PATCH=3 +NETIDMGR_VERSION_MAJOR=1 +NETIDMGR_VERSION_MINOR=0 +NETIDMGR_VERSION_PATCH=0 NETIDMGR_VERSION_AUX=0 -NETIDMGR_RELEASEDESC=Beta 3 +NETIDMGR_RELEASEDESC= # The API version. This number must be incremented each time the API # changes. Plugins specify the version of the API that they were @@ -57,7 +57,7 @@ NETIDMGR_RELEASEDESC=Beta 3 # # Changes to the API version numbers should be documented in # apiversion.txt at the root of the source tree. -NETIDMGR_VERSION_API=3 +NETIDMGR_VERSION_API=4 NETIDMGR_VERSION=$(NETIDMGR_VERSION_MAJOR).$(NETIDMGR_VERSION_MINOR).$(NETIDMGR_VERSION_PATCH).$(NETIDMGR_VERSION_AUX) NETIDMGR_VERSIONC=$(NETIDMGR_VERSION_MAJOR),$(NETIDMGR_VERSION_MINOR),$(NETIDMGR_VERSION_PATCH),$(NETIDMGR_VERSION_AUX) @@ -81,7 +81,7 @@ KH_BUILD=DEBUG # The default release type is PRIVATE is no other type is specified !if ("$(KH_RELEASE)" != "OFFICIAL") && ("$(KH_RELEASE)" != "PRERELEASE") && ("$(KH_RELEASE)" != "PRIVATE") && ("$(KH_RELEASE)" != "SPECIAL") -KH_RELEASE=PRERELEASE +KH_RELEASE=PRIVATE !endif # Actual build environment settings diff --git a/src/windows/identity/doc/netidmgr.doc b/src/windows/identity/doc/netidmgr.doc new file mode 100755 index 000000000..f6eda5d5a Binary files /dev/null and b/src/windows/identity/doc/netidmgr.doc differ diff --git a/src/windows/identity/doc/netidmgr.pdf b/src/windows/identity/doc/netidmgr.pdf new file mode 100755 index 000000000..0e6ab0297 Binary files /dev/null and b/src/windows/identity/doc/netidmgr.pdf differ diff --git a/src/windows/identity/help/html/about_netidmgr.htm b/src/windows/identity/help/html/about_netidmgr.htm index 76c5f9f22..d6fec057b 100644 --- a/src/windows/identity/help/html/about_netidmgr.htm +++ b/src/windows/identity/help/html/about_netidmgr.htm @@ -19,7 +19,7 @@ Identity Manager.

Network Identity Manager was conceived as an identity management solution to make up for the shortcomings of Leash32 (distributed with -MIT Kerberos for Windows) and AFSCREDS (distributed with OpenAFS). +MIT Kerberos for Windows) and AFSCreds (distributed with OpenAFS).

@@ -33,17 +33,18 @@ source code.

-A presentation given about Khimaira at the AFS and Kerberos Best Practices -Workshop 2005 can be found on the workshop website and . The slides can be found on the workshop website and here.

-The work on Khimaira was funded by MIT Information Services and -Technology. +Technology, NASA Jet Propulsion Laboratory, +and Secure Endpoints Inc..

Design

diff --git a/src/windows/identity/help/html/act_chpw.htm b/src/windows/identity/help/html/act_chpw.htm index 5e39963da..40f97054a 100644 --- a/src/windows/identity/help/html/act_chpw.htm +++ b/src/windows/identity/help/html/act_chpw.htm @@ -1,11 +1,30 @@ - title - - + Change Password + + +

Change Password

+ +

The change password dialog can be invoked from the Credentials menu. This is used to +change the password for the primary credentials provider (currently +Kerberos 5). +

+ +

For the default identity provider (Kerberos 5), there are two input +boxes to specify the identity for which the password is to be changed. +The identity uniquely maps to the Kerberos principal of the same name. +Then the current password must be entered along with the new password +twice. +

+ +

Note that currently, when the password for an identity is being +changed, only the associated Kerberos 5 password is changed. +

+ \ No newline at end of file diff --git a/src/windows/identity/help/html/act_destroy_creds.htm b/src/windows/identity/help/html/act_destroy_creds.htm index 5e39963da..ff24561e8 100644 --- a/src/windows/identity/help/html/act_destroy_creds.htm +++ b/src/windows/identity/help/html/act_destroy_creds.htm @@ -1,11 +1,33 @@ - title - - + Destroy Credentials + + +

Destroy Credentials

+ +

This action will attempt to destroy the credentials that are +currently selected in the credentials window. How the credentials are +destroyed is up to each credentials provider. +

+ +

In some cases, you may need to select all the credentials of a +specific type for the delete operation to succeed. This happens when +the credentials provider does not support deleting individual +credentials, but supports deleting all the credentials stored in one +specific location. +

+ +

The action can be invoked by selecting the credentials and then +pressing the Delete key or by pressing Ctrl + D. You can also select the Delete credentials action from the context menu +(available via right-clicking inside the credentials window) or the +credentials menu. +

+ \ No newline at end of file diff --git a/src/windows/identity/help/html/act_import_creds.htm b/src/windows/identity/help/html/act_import_creds.htm index 5e39963da..550bb39e2 100644 --- a/src/windows/identity/help/html/act_import_creds.htm +++ b/src/windows/identity/help/html/act_import_creds.htm @@ -1,11 +1,27 @@ - title - - + Import Credentials + + +

Import Credentials

+ +

Allows you to import credentials from the Windows LSA credentials +cache into any of the caches under the control of any credentials +provider. Currently, the only credentials provider that supports +importing is Kerberos 5. +

+ +

This action can be invoked via the Credentials menu or by pressing Ctrl + I. In addition, the Kerberos 5 +configuration pane accessible via the Options menu provides an options that +control how the importing of credentials happen. +

+ \ No newline at end of file diff --git a/src/windows/identity/help/html/act_new_creds.htm b/src/windows/identity/help/html/act_new_creds.htm index 5e39963da..01917ffdc 100644 --- a/src/windows/identity/help/html/act_new_creds.htm +++ b/src/windows/identity/help/html/act_new_creds.htm @@ -1,11 +1,114 @@ - title - - + New Credentials + + +

New Credentials

+ +

The new credentials dialog can be invoked from the Credentials menu, by typing Ctrl + N, using the context menu in the credentials +window or using the context menu in the NetIDMgr icon in the system +notification area. +

+ +

Once invoked, you will be presented with a dialog similar to the +following: +

+ +

+New credentials dialog +

New credentials dialog with a valid identity +selected.

Note that the above screenshot is +from an instance of NetIDMgr with Kerberos 5, Kerberos 4 and OpenAFS +plugins with a Kerberos 5 identity manager. Actual display may be +different depending on the plugins that are active.

+

+ +

If the Kerberos 5 identity provider is used, the dialog will ask +for a username and a realm to determine the identity for which new +credentials will be obtained for. Depending on the selected identity, +you may be required to provide a password or other form of +authentication for new credentials to be obtained. +

+ +

Below the prompts is the credentials summary window. This window +provides an overview of the credentals that will be obtained when the +dialog is completed. +

+ +

Expanded view

+ +

If you click any of the hyperlinks in the credentials summary +window or select the Options >> button, +the dialog will switch to the exanded view. An example of this is +shown below: +

+ +

+ + +

Expanded view of the new credetials dialog

+

+ +

+The expanded view provides access to additional options available for +each credential provider. For example, the Kerberos 5 credentials +provider allows you to set the lifetime of the obtained Kerberos +ticket as well as ticket flags such as renewable or +forwardable. +

+ +

Credentials summary window

+ +

+The credentials summary window provides an overview of the credentials +that will be obtained after the successful completion of the new +credentials dialog. The window contains hyperlinks that will take you +to the corresponding credentials option panels where you will be able +to set additional options for each type. +

+ +

+If there is a problem with the selected identity, the credentials +window will display a message describing the problem. For example: +

+ +

+Credentials summary window showing an invalid identity +

+ +

+The above is an example of what you would see if the provided identity +is invalid. Once the identity provider (in this case, Kerberos 5) +indicates that the identity is invalid, it will be displayed as above +along with a brief description of why the identity was found to be +invalid. Here, the Kerberos 5 identity provider is reporting that the +specified principal does not exist in the Kerberos database. +

+ +

Additional notes

+ +

+The new credentials dialog can be invoked from the command line using +the -i or --kinit + command line option. Additionally, if you specify the -a or --autoinit +command line option, the new credentials dialog will be displayed if +there are no credentials available. +

+ +

+Setting the Prompt for new credentials if there +aren't any at startup option is set in the General configuration panel, then the behavior is +similar to the --autoinit option. +

+ \ No newline at end of file diff --git a/src/windows/identity/help/html/bugs.htm b/src/windows/identity/help/html/bugs.htm index a2e8d34ca..fcc563c9a 100644 --- a/src/windows/identity/help/html/bugs.htm +++ b/src/windows/identity/help/html/bugs.htm @@ -18,8 +18,9 @@ enable us to reproduce the problem.

kerberos@MIT.EDU is a mailing list set up for discussing Kerberos issues. It is gatewayed to the Usenet newsgroup 'comp.protocols.kerberos'. If you -prefer to read it via mail, send a request to kerberos-request@MIT.EDU -to get added or subscribe via the web page:

+prefer to read it via mail, send a subscription request to +kerberos-request@MIT.EDU +or subscribe via the web page:

diff --git a/src/windows/identity/help/html/images/screen_new_creds.bmp b/src/windows/identity/help/html/images/screen_new_creds.bmp new file mode 100755 index 000000000..7d7335ab7 Binary files /dev/null and b/src/windows/identity/help/html/images/screen_new_creds.bmp differ diff --git a/src/windows/identity/help/html/images/screen_new_creds_err01.bmp b/src/windows/identity/help/html/images/screen_new_creds_err01.bmp new file mode 100755 index 000000000..44bf0f958 Binary files /dev/null and b/src/windows/identity/help/html/images/screen_new_creds_err01.bmp differ diff --git a/src/windows/identity/help/html/images/screen_new_creds_exp.bmp b/src/windows/identity/help/html/images/screen_new_creds_exp.bmp new file mode 100755 index 000000000..b1711a70f Binary files /dev/null and b/src/windows/identity/help/html/images/screen_new_creds_exp.bmp differ diff --git a/src/windows/identity/help/html/menu_help.htm b/src/windows/identity/help/html/menu_help.htm index d95545448..bceb2a991 100644 --- a/src/windows/identity/help/html/menu_help.htm +++ b/src/windows/identity/help/html/menu_help.htm @@ -27,11 +27,8 @@ needs to be explained, we have decided to include it here just for completeness. It is bad enough that it is the last menu on the menu bar. We didn't want to pile on any more disrespect by not documenting it. We encourage you to not read this and just go ahead and click any -item on this menu. It is guaranteed that nothing bad will happen. -This is not a generalization that would extend to, say, the Credentials menu. If anything bad -happens, please file a bug report at kfw-bugs@mit.edu. +item on this menu. If anything unexpected happens, please file a bug +report at kfw-bugs@mit.edu.

diff --git a/src/windows/identity/help/html/menu_options.htm b/src/windows/identity/help/html/menu_options.htm index 4d5bea9bb..2d60f1ae3 100644 --- a/src/windows/identity/help/html/menu_options.htm +++ b/src/windows/identity/help/html/menu_options.htm @@ -43,6 +43,9 @@ Opens the identities configuration panel.

  • Notifications ...: Opens the Notifications control panel.
  • +
  • Plugins ...: +Opens the Plug-ins and Modules control panel.
  • + diff --git a/src/windows/identity/help/html/menu_view.htm b/src/windows/identity/help/html/menu_view.htm index 94920e126..53a46e189 100644 --- a/src/windows/identity/help/html/menu_view.htm +++ b/src/windows/identity/help/html/menu_view.htm @@ -36,8 +36,9 @@ without invoking the View menu. diff --git a/src/windows/identity/help/html/nidmgr.css b/src/windows/identity/help/html/nidmgr.css index 16c45104b..9ace12229 100644 --- a/src/windows/identity/help/html/nidmgr.css +++ b/src/windows/identity/help/html/nidmgr.css @@ -68,4 +68,5 @@ SPAN.pre { SPAN.title { font-weight: bold; -} \ No newline at end of file +} + diff --git a/src/windows/identity/help/html/using.htm b/src/windows/identity/help/html/using.htm index 2d84df2cd..c3699e841 100644 --- a/src/windows/identity/help/html/using.htm +++ b/src/windows/identity/help/html/using.htm @@ -22,8 +22,7 @@ notification area, select the icon from the start menu, or type

    Once you open the NetIDMgr window, you will be presented with a view of your existing credentials, or a message notifying you that you -don't have any. The credentials view should be fairly self -explanatory, but if there's any doubt, more information can be found here.

    diff --git a/src/windows/identity/help/html/welcome.htm b/src/windows/identity/help/html/welcome.htm index 9cd7bc43e..7423b848d 100644 --- a/src/windows/identity/help/html/welcome.htm +++ b/src/windows/identity/help/html/welcome.htm @@ -14,8 +14,8 @@

    The Network Identity Manager (or NetIDMgr for short) allows you to -manage your credentials (Kerberos tickets, AFS tokens, etc.) on a per -identity basis. +manage your network identities and the associated credentials +(Kerberos tickets, AFS tokens, etc.).

    @@ -28,7 +28,7 @@ installing the appropriate plugins.

    This version is distributed as a part of the MIT Kerberos for Windows product along with the Kerberos 5 and Kerberos 4 plugins. The OpenAFS -plugin, which is required for supporting OpenAFS tokens, is +plugin, which is required for supporting AFS tokens, is distributed separately.

    diff --git a/src/windows/identity/help/khhelp.h b/src/windows/identity/help/khhelp.h index 2e07838c6..88f73c0b3 100644 --- a/src/windows/identity/help/khhelp.h +++ b/src/windows/identity/help/khhelp.h @@ -22,3 +22,12 @@ #define IDH_ACTION_OPT_KHIM 2012 #define IDH_ACTION_OPT_INIT 2013 #define IDH_ACTION_OPT_NOTIF 2014 + +#define IDH_NC_CREDWND 3000 +#define IDH_NC_OK 3001 +#define IDH_NC_CANCEL 3002 +#define IDH_NC_HELP 3003 +#define IDH_NC_TABBUTTON 3004 +#define IDH_NC_OPTIONS 3005 +#define IDH_NC_TABMAIN 3006 +#define IDH_NC_SETDEF 3007 diff --git a/src/windows/identity/help/netidmgr.hhp b/src/windows/identity/help/netidmgr.hhp index 9930dc5bc..9f2ae7332 100644 --- a/src/windows/identity/help/netidmgr.hhp +++ b/src/windows/identity/help/netidmgr.hhp @@ -15,6 +15,8 @@ MainHelpWnd="NetIDMgr Help","toc.hhc","Index.hhk","html/welcome.htm","html/welco [ALIAS] +IDH_ACTION_NEW_ID=html\act_new_creds.htm +IDH_ACTION_PASSWD_ID=html\act_chpw.htm IDH_WELCOME=html\welcome.htm [MAP] @@ -23,6 +25,7 @@ IDH_WELCOME=html\welcome.htm [TEXT POPUPS] khhelp.h popups_newcreds.txt +popups_password.txt [INFOTYPES] Category:Concepts diff --git a/src/windows/identity/help/popups_newcreds.txt b/src/windows/identity/help/popups_newcreds.txt index 7d58703b1..52c61244b 100644 --- a/src/windows/identity/help/popups_newcreds.txt +++ b/src/windows/identity/help/popups_newcreds.txt @@ -1 +1,30 @@ -foo +.topic IDH_NC_TABMAIN +Opens the identity selection panel. + +.topic IDH_NC_TABBUTTON +Opens the option panel for this credentials type. + +.topic IDH_NC_OK +Obtains new credentials using the information that you provided. + +.topic IDH_NC_CANCEL +Cancels the new credentials operation. + +.topic IDH_NC_HELP +Provides help for this dialog box. + +.topic IDH_NC_OPTIONS +Expands the dialog and allows you to set additional +options for the credentials that will be obtained +by this dialog. + +.topic IDH_NC_CREDWND +Provides an overview of the credentials that will be obtained +after the successful completion of the new credentials dialog. +Clicking on the hyperlinks will take you to the corresponding +credentials option panels where you will be able to set +additional options for each type. + +.topic IDH_NC_SETDEF +If checked, once the credentials acquisition operation completes, the +identity will be set as the default. diff --git a/src/windows/identity/include/khmsgtypes.h b/src/windows/identity/include/khmsgtypes.h index dfc39e2f0..9b63455e7 100644 --- a/src/windows/identity/include/khmsgtypes.h +++ b/src/windows/identity/include/khmsgtypes.h @@ -205,6 +205,8 @@ #define KMSG_ACT_BEGIN_CMDLINE 128 +#define KMSG_ACT_CONTINUE_CMDLINE 129 + /*@}*/ /*! \defgroup kmq_msg_cred KMSG_CRED subtypes diff --git a/src/windows/identity/kconfig/api.c b/src/windows/identity/kconfig/api.c index e860e9e51..30e5f488f 100644 --- a/src/windows/identity/kconfig/api.c +++ b/src/windows/identity/kconfig/api.c @@ -183,6 +183,12 @@ khcint_space_release(kconf_conf_space * s) { RegCloseKey(s->regkey_user); s->regkey_machine = NULL; s->regkey_user = NULL; + + if (s->flags & + (KCONF_SPACE_FLAG_DELETE_M | + KCONF_SPACE_FLAG_DELETE_U)) { + khcint_remove_space(s, s->flags); + } } LeaveCriticalSection(&cs_conf_global); @@ -197,7 +203,7 @@ khcint_RegOpenKeyEx(HKEY hkey, LPCWSTR sSubKey, DWORD ulOptions, wchar_t sk_name[KCONF_MAXCCH_NAME]; FILETIME ft; size_t cch; - HKEY hkp; + HKEY hkp = NULL; const wchar_t * t; LONG rv = ERROR_SUCCESS; @@ -1375,7 +1381,7 @@ khc_write_string(khm_handle pconf, LONG hr; size_t cbsize; wchar_t * value = NULL; - int free_space; + int free_space = 0; khm_handle conf = NULL; @@ -1453,7 +1459,7 @@ khc_write_int32(khm_handle pconf, khm_int32 rv = KHM_ERROR_SUCCESS; LONG hr; wchar_t * value = NULL; - int free_space; + int free_space = 0; khm_handle conf = NULL; @@ -1519,7 +1525,7 @@ khc_write_int64(khm_handle pconf, wchar_t * pvalue, khm_int64 buf) { khm_int32 rv = KHM_ERROR_SUCCESS; LONG hr; wchar_t * value = NULL; - int free_space; + int free_space = 0; khm_handle conf = NULL; @@ -1587,7 +1593,7 @@ khc_write_binary(khm_handle pconf, khm_int32 rv = KHM_ERROR_SUCCESS; LONG hr; wchar_t * value = NULL; - int free_space; + int free_space = 0; khm_handle conf = NULL; @@ -1850,10 +1856,58 @@ khc_remove_value(khm_handle conf, wchar_t * value, khm_int32 flags) { return rv; } +khm_int32 +khcint_remove_space(kconf_conf_space * c, khm_int32 flags) { + kconf_conf_space * cc; + kconf_conf_space * cn; + + /* TODO: if this is the last child space and the parent is marked + for deletion, delete the parent as well. */ + + cc = TFIRSTCHILD(c); + while (cc) { + cn = LNEXT(cc); + + khcint_remove_space(cc, flags); + + cc = cn; + } + + cc = TFIRSTCHILD(c); + if (!cc) { + kconf_conf_space * p; + + if (c->refcount) { + c->flags |= (flags & + (KCONF_SPACE_FLAG_DELETE_M | + KCONF_SPACE_FLAG_DELETE_U)); + } else { + p = TPARENT(c); + + TDELCHILD(p, c); + + if (c->regpath) { + if (flags & KCONF_SPACE_FLAG_DELETE_U) + RegDeleteKey(HKEY_CURRENT_USER, + c->regpath); + if (flags & KCONF_SPACE_FLAG_DELETE_M) + RegDeleteKey(HKEY_LOCAL_MACHINE, + c->regpath); + } + + khcint_free_space(c); + } + } else { + c->flags |= (flags & + (KCONF_SPACE_FLAG_DELETE_M | + KCONF_SPACE_FLAG_DELETE_U)); + } + + return KHM_ERROR_SUCCESS; +} + KHMEXP khm_int32 KHMAPI khc_remove_space(khm_handle conf) { - /* TODO: implement this */ - /* - mark this space as well as all child spaces as 'delete-on-close' using flags. Mark should indicate which @@ -1867,9 +1921,32 @@ khc_remove_space(khm_handle conf) { space has any children left. If there are none, check if the parent space is also marked for deletion. */ - assert(FALSE); + HKEY hku = NULL; + HKEY hkm = NULL; + kconf_conf_space * c; + khm_int32 rv = KHM_ERROR_SUCCESS; + khm_int32 flags = 0; + + if(!khc_is_config_running()) + return KHM_ERROR_NOT_READY; + + if(!khc_is_handle(conf)) + return KHM_ERROR_INVALID_PARAM; + + c = khc_space_from_handle(conf); + + EnterCriticalSection(&cs_conf_global); - return 0; + if (khc_is_machine_handle(conf)) + flags |= KCONF_SPACE_FLAG_DELETE_M; + if (khc_is_user_handle(conf)) + flags |= KCONF_SPACE_FLAG_DELETE_U; + + rv = khcint_remove_space(c, flags); + + LeaveCriticalSection(&cs_conf_global); + + return rv; } khm_boolean diff --git a/src/windows/identity/kconfig/kconfig.h b/src/windows/identity/kconfig/kconfig.h index d2226be20..4e9a49e9b 100644 --- a/src/windows/identity/kconfig/kconfig.h +++ b/src/windows/identity/kconfig/kconfig.h @@ -865,6 +865,15 @@ khc_enum_subspaces(khm_handle conf, khm_handle prev, khm_handle * next); +/*! \brief Remove a configuration space + + The configuration space will be marked for removal. Once all the + handles for the space have been released, it will be deleted. The + configuration stores that will be affected are the write enabled + configuration stores for the handle. + */ +KHMEXP khm_int32 KHMAPI +khc_remove_space(khm_handle conf); /*@}*/ #endif diff --git a/src/windows/identity/kconfig/kconfiginternal.h b/src/windows/identity/kconfig/kconfiginternal.h index 3a23af127..64068f4a9 100644 --- a/src/windows/identity/kconfig/kconfiginternal.h +++ b/src/windows/identity/kconfig/kconfiginternal.h @@ -63,7 +63,8 @@ typedef struct kconf_conf_space_t { } kconf_conf_space; //#define KCONF_SPACE_FLAG_SCHEMA 0x00000020 -#define KCONF_SPACE_FLAG_DELETED 0x00000040 +#define KCONF_SPACE_FLAG_DELETE_U 0x00000040 +#define KCONF_SPACE_FLAG_DELETE_M 0x00000080 typedef struct kconf_conf_handle_t { khm_int32 magic; @@ -89,7 +90,7 @@ extern LONG conf_status; #define khc_is_config_running() (conf_init && conf_status) -#define CONFIG_REGPATHW L"SOFTWARE\\MIT\\NetIDMgr" +#define CONFIG_REGPATHW L"Software\\MIT\\NetIDMgr" void init_kconf(void); void exit_kconf(void); @@ -122,4 +123,7 @@ khcint_space_release(kconf_conf_space * s); HKEY khcint_space_open_key(kconf_conf_space * s, khm_int32 flags); +khm_int32 +khcint_remove_space(kconf_conf_space * c, khm_int32 flags); + #endif diff --git a/src/windows/identity/kcreddb/attrib.c b/src/windows/identity/kcreddb/attrib.c index badfb2b49..f77ebccf1 100644 --- a/src/windows/identity/kcreddb/attrib.c +++ b/src/windows/identity/kcreddb/attrib.c @@ -128,28 +128,30 @@ kcdb_attr_sys_cb(khm_handle vcred, case KCDB_ATTR_TIMELEFT: { - /* we are going to make liberal use of __int64 here. It - is equivalent to FILETIME and also the MSDN docs say we - should use it if the compiler supports it */ khm_int32 rv = KHM_ERROR_SUCCESS; - unsigned __int64 ftc; - SYSTEMTIME st; - if(!buf || *pcb_buf < sizeof(__int64)) { - *pcb_buf = sizeof(__int64); + if(!buf || *pcb_buf < sizeof(FILETIME)) { + *pcb_buf = sizeof(FILETIME); rv = KHM_ERROR_TOO_LONG; } else if(!kcdb_cred_buf_exist(c,KCDB_ATTR_EXPIRE)) { - *pcb_buf = sizeof(__int64); + *pcb_buf = sizeof(FILETIME); /* setting the timeleft to _I64_MAX has the interpretation that this credential does not expire, which is the default behavior if the expiration time is not known */ - *((__int64 *) buf) = _I64_MAX; + *((FILETIME *) buf) = IntToFt(_I64_MAX); } else { - GetSystemTime(&st); - SystemTimeToFileTime(&st, (LPFILETIME) &ftc); - *((__int64 *) buf) = - *((__int64 *) kcdb_cred_buf_get(c,KCDB_ATTR_EXPIRE)) - ftc; + FILETIME ftc; + khm_int64 iftc; + + GetSystemTimeAsFileTime(&ftc); + iftc = FtToInt(&ftc); + + *((FILETIME *) buf) = + IntToFt(FtToInt((FILETIME *) + kcdb_cred_buf_get(c,KCDB_ATTR_EXPIRE)) + - iftc); + *pcb_buf = sizeof(FILETIME); } return rv; @@ -157,28 +159,28 @@ kcdb_attr_sys_cb(khm_handle vcred, case KCDB_ATTR_RENEW_TIMELEFT: { - /* we are going to make liberal use of __int64 here. It - is equivalent to FILETIME and also the MSDN docs say we - should use it if the compiler supports it */ khm_int32 rv = KHM_ERROR_SUCCESS; - unsigned __int64 ftc; - SYSTEMTIME st; - if(!buf || *pcb_buf < sizeof(__int64)) { - *pcb_buf = sizeof(__int64); + if(!buf || *pcb_buf < sizeof(FILETIME)) { + *pcb_buf = sizeof(FILETIME); rv = KHM_ERROR_TOO_LONG; } else if(!kcdb_cred_buf_exist(c,KCDB_ATTR_RENEW_EXPIRE)) { - *pcb_buf = sizeof(__int64); + *pcb_buf = sizeof(FILETIME); /* setting the timeleft to _I64_MAX has the interpretation that this credential does not expire, which is the default behavior if the expiration time is not known */ - *((__int64 *) buf) = _I64_MAX; + *((FILETIME *) buf) = IntToFt(_I64_MAX); } else { - GetSystemTime(&st); - SystemTimeToFileTime(&st, (LPFILETIME) &ftc); - *((__int64 *) buf) = - *((__int64 *) kcdb_cred_buf_get(c,KCDB_ATTR_RENEW_EXPIRE)) - ftc; + FILETIME ftc; + + GetSystemTimeAsFileTime(&ftc); + + *((FILETIME *) buf) = + IntToFt(FtToInt(((FILETIME *) + kcdb_cred_buf_get(c,KCDB_ATTR_RENEW_EXPIRE)) + - FtToInt(&ftc))); + *pcb_buf = sizeof(FILETIME); } return rv; @@ -688,7 +690,7 @@ KHMEXP khm_int32 KHMAPI kcdb_attrib_describe( { kcdb_attrib_i * ai; size_t cb_size = 0; - khm_boolean prop; + khm_boolean prop = FALSE; if(!cbsize) return KHM_ERROR_INVALID_PARAM; @@ -697,6 +699,8 @@ KHMEXP khm_int32 KHMAPI kcdb_attrib_describe( prop = FALSE; else if(id >= KCDB_ATTR_MIN_PROP_ID && id <= KCDB_ATTR_MAX_PROP_ID) prop = TRUE; + else + return KHM_ERROR_INVALID_PARAM; if(prop) ai = kcdb_property_tbl[id - KCDB_ATTR_MIN_PROP_ID]; diff --git a/src/windows/identity/kcreddb/credential.c b/src/windows/identity/kcreddb/credential.c index ccad383e6..37f246534 100644 --- a/src/windows/identity/kcreddb/credential.c +++ b/src/windows/identity/kcreddb/credential.c @@ -601,9 +601,9 @@ KHMEXP khm_int32 KHMAPI kcdb_cred_get_attr_string( code = KHM_ERROR_NOT_FOUND; } -_exit: + _exit: kcdb_cred_unlock_read(); -_exit_nolock: + _exit_nolock: if(type) kcdb_type_release_info(type); if(attrib) @@ -990,11 +990,12 @@ kcdb_cred_get_flags(khm_handle vcred, if (!(f & KCDB_CRED_FLAG_EXPIRED) && kcdb_cred_buf_exist(cred, KCDB_ATTR_EXPIRE)) { - khm_int64 ftc; + FILETIME ftc; - GetSystemTimeAsFileTime((LPFILETIME) &ftc); - if (ftc > *((khm_int64 *) - kcdb_cred_buf_get(cred, KCDB_ATTR_EXPIRE))) + GetSystemTimeAsFileTime(&ftc); + if (CompareFileTime(&ftc, ((FILETIME *) + kcdb_cred_buf_get(cred, KCDB_ATTR_EXPIRE))) + >= 0) f |= KCDB_CRED_FLAG_EXPIRED; } @@ -1004,10 +1005,11 @@ kcdb_cred_get_flags(khm_handle vcred, if (!(f & KCDB_CRED_FLAG_INVALID)) { if (f & KCDB_CRED_FLAG_RENEWABLE) { if (kcdb_cred_buf_exist(cred, KCDB_ATTR_RENEW_EXPIRE)) { - khm_int64 ftc; + FILETIME ftc; - GetSystemTimeAsFileTime((LPFILETIME) &ftc); - if (ftc > *((khm_int64 *) kcdb_cred_buf_get(cred, KCDB_ATTR_RENEW_EXPIRE))) + GetSystemTimeAsFileTime(&ftc); + if (CompareFileTime(&ftc, ((FILETIME *) + kcdb_cred_buf_get(cred, KCDB_ATTR_RENEW_EXPIRE))) >= 0) f |= KCDB_CRED_FLAG_INVALID; } } else { diff --git a/src/windows/identity/kcreddb/credset.c b/src/windows/identity/kcreddb/credset.c index 869cd8409..9be551ba1 100644 --- a/src/windows/identity/kcreddb/credset.c +++ b/src/windows/identity/kcreddb/credset.c @@ -79,7 +79,7 @@ void kcdb_credset_buf_assert_size(kcdb_credset * cs, khm_int32 nclist) (((nclist - (KCDB_CREDSET_INITIAL_SIZE + 1)) / KCDB_CREDSET_GROWTH_FACTOR) + 1) * KCDB_CREDSET_GROWTH_FACTOR; - new_clist = calloc(nclist, sizeof(kcdb_credset_credref)); + new_clist = PCALLOC(nclist, sizeof(kcdb_credset_credref)); memcpy(new_clist, cs->clist, cs->nclist * sizeof(kcdb_credset_credref)); @@ -693,8 +693,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credset_find_filtered( khm_int32 rv = KHM_ERROR_SUCCESS; int i; - if((credset && !kcdb_credset_is_credset(credset)) || - (!f || !cred)) + if((credset && !kcdb_credset_is_credset(credset)) || !f) return KHM_ERROR_INVALID_PARAM; if(credset) @@ -724,10 +723,14 @@ KHMEXP khm_int32 KHMAPI kcdb_credset_find_filtered( cs->flags &= ~KCDB_CREDSET_FLAG_ENUM; if(i < cs->nclist) { - *cred = (khm_handle) cs->clist[i].cred; - kcdb_cred_hold(*cred); - if(idx) + if (cred) { + *cred = (khm_handle) cs->clist[i].cred; + kcdb_cred_hold(*cred); + } + + if(idx) { *idx = i; + } } else { rv = KHM_ERROR_NOT_FOUND; } diff --git a/src/windows/identity/kcreddb/identity.c b/src/windows/identity/kcreddb/identity.c index 43dd425c4..896f723c5 100644 --- a/src/windows/identity/kcreddb/identity.c +++ b/src/windows/identity/kcreddb/identity.c @@ -180,8 +180,8 @@ KHMEXP khm_int32 KHMAPI kcdb_identity_create(const wchar_t *name, khm_int32 flags, khm_handle * result) { - kcdb_identity * id; - kcdb_identity * id_tmp; + kcdb_identity * id = NULL; + kcdb_identity * id_tmp = NULL; size_t namesize; if(!result || !name) @@ -823,9 +823,9 @@ kcdb_identity_set_attr(khm_handle vid, void * buffer, khm_size cbbuf) { - kcdb_identity * id; - kcdb_attrib * attrib; - kcdb_type * type; + kcdb_identity * id = NULL; + kcdb_attrib * attrib = NULL; + kcdb_type * type = NULL; khm_size slot; khm_size cbdest; khm_int32 code = KHM_ERROR_SUCCESS; diff --git a/src/windows/identity/kcreddb/kcreddb.h b/src/windows/identity/kcreddb/kcreddb.h index e49c750d5..e1bbfb0bd 100644 --- a/src/windows/identity/kcreddb/kcreddb.h +++ b/src/windows/identity/kcreddb/kcreddb.h @@ -2287,6 +2287,26 @@ FtIntervalToMilliseconds(LPFILETIME pft); KHMEXP long KHMAPI FtCompare(LPFILETIME pft1, LPFILETIME pft2); +/*! \brief Convert a FILETIME to a 64 bit int +*/ +KHMEXP khm_int64 KHMAPI FtToInt(LPFILETIME pft); + +/*! \brief Convert a 64 bit int to a FILETIME +*/ +KHMEXP FILETIME KHMAPI IntToFt(khm_int64 i); + +/*! \brief Calculate the difference between two FILETIMEs + + Returns the value of ft1 - ft2 + */ +KHMEXP FILETIME KHMAPI FtSub(LPFILETIME ft1, LPFILETIME ft2); + +/*! \brief Calculate the sum of two FILETIMEs + + Return the value of ft1 + ft2 + */ +KHMEXP FILETIME KHMAPI FtAdd(LPFILETIME ft1, LPFILETIME ft2); + /*! \brief Convert a FILETIME inverval to a string */ KHMEXP khm_int32 KHMAPI diff --git a/src/windows/identity/kcreddb/lang/en_us/kcredres.rc b/src/windows/identity/kcreddb/lang/en_us/kcredres.rc index 2f733199a..4c221eeeb 100644 --- a/src/windows/identity/kcreddb/lang/en_us/kcredres.rc +++ b/src/windows/identity/kcreddb/lang/en_us/kcredres.rc @@ -72,11 +72,11 @@ END STRINGTABLE BEGIN IDS_CREDDB "Khimaira Credentials Database" - IDS_NAME "Name" + IDS_NAME "Service Name" IDS_IDENTITY "Identity" IDS_ISSUED "Issued on" IDS_EXPIRES "Expires on" - IDS_TIMELEFT "Time left" + IDS_TIMELEFT "Time Remaining" IDS_LOCATION "Location" IDS_PARENT "Parent" IDS_TYPE "Type" @@ -106,7 +106,7 @@ END STRINGTABLE BEGIN - IDS_IVl_W_SPEC "w,wk,wks,weeks" + 128 "w,wk,wks,weeks" IDS_FLAGS "Flags" IDS_RENEW_TIMELEFT "Renewable Time left" IDS_RENEW_EXPIRES "Renewable time expires" diff --git a/src/windows/identity/kcreddb/langres.h b/src/windows/identity/kcreddb/langres.h index ab6620cd5..417b214e0 100644 --- a/src/windows/identity/kcreddb/langres.h +++ b/src/windows/identity/kcreddb/langres.h @@ -1,6 +1,6 @@ //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. -// Used by D:\work\khimaira\src\kcreddb\lang\en_us\kcredres.rc +// Used by D:\work\pismere\athena\auth\krb5\src\windows\identity\kcreddb\lang\en_us\kcredres.rc // #define IDS_CREDDB 101 #define IDS_NAME 102 @@ -31,7 +31,6 @@ #define IDS_IVL_D_SPEC 127 #define IDS_IVl_W_SPEC 128 #define IDS_IVL_W_SPEC 128 -#define IDS_IVl_W_SPEC 128 #define IDS_FLAGS 129 #define IDS_RENEW_TIMELEFT 130 #define IDS_RENEW_EXPIRES 131 diff --git a/src/windows/identity/kcreddb/type.c b/src/windows/identity/kcreddb/type.c index 004beb62f..3df10482c 100644 --- a/src/windows/identity/kcreddb/type.c +++ b/src/windows/identity/kcreddb/type.c @@ -318,14 +318,17 @@ khm_int32 KHMAPI kcdb_type_date_dup( /* returns the number of milliseconds that must elapse away from the interval specified in pft for the representation of pft to change from whatever it is right now */ -KHMEXP long KHMAPI FtIntervalMsToRepChange(LPFILETIME pft) +KHMEXP long KHMAPI +FtIntervalMsToRepChange(LPFILETIME pft) { __int64 ms,s,m,h,d; + __int64 ift; long l; - ms = *((__int64 *) pft) / 10000i64; + ift = FtToInt(pft); + ms = ift / 10000i64; - if(ms < 0 || *((__int64 *) pft) == _I64_MAX) + if(ms < 0 || ift == _I64_MAX) return -1; s = ms / 1000i64; @@ -333,36 +336,44 @@ KHMEXP long KHMAPI FtIntervalMsToRepChange(LPFILETIME pft) h = s / 3600; d = s / (3600*24); - if(d > 0) { + if (d > 0) { /* rep change at next hour change */ l = (long) (ms % (3600*1000i64)); - } else if(h > 0) { + } else if (h > 0) { + /* rep change at next minute change */ + l = (long) (ms % (60*1000i64)); + } else if (m > 5) { /* rep change at next minute change */ l = (long) (ms % (60*1000i64)); } else { + /* rep change at next second change */ l = (long) (ms % 1000); } return l; } -KHMEXP khm_int32 KHMAPI FtIntervalToString(LPFILETIME data, wchar_t * buffer, khm_size * cb_buf) +KHMEXP khm_int32 KHMAPI +FtIntervalToString(LPFILETIME data, wchar_t * buffer, khm_size * cb_buf) { size_t cbsize; __int64 s,m,h,d; + __int64 ift; wchar_t ibuf[256]; wchar_t fbuf[256]; wchar_t * t; if(!cb_buf) return KHM_ERROR_INVALID_PARAM; - s = *((__int64 *) data) / 10000000i64; + + ift = FtToInt(data); + s = ift / 10000000i64; m = s / 60; h = s / 3600; d = s / (3600*24); - if(*((__int64 *) data) == _I64_MAX) { + if(ift == _I64_MAX) { LoadString(hinst_kcreddb, IDS_IVL_UNKNOWN, ibuf, sizeof(ibuf)/sizeof(wchar_t)); } else if(s < 0) { LoadString(hinst_kcreddb, IDS_IVL_EXPIRED, ibuf, sizeof(ibuf)/sizeof(wchar_t)); @@ -385,16 +396,21 @@ KHMEXP khm_int32 KHMAPI FtIntervalToString(LPFILETIME data, wchar_t * buffer, kh StringCbPrintf(t, sizeof(ibuf) - wcslen(ibuf)*sizeof(wchar_t), fbuf, h); } } - } else if(h > 0) { + } else if(h > 0 || m > 5) { m = (s - (h * 3600)) / 60; if(h == 1) { LoadString(hinst_kcreddb, IDS_IVL_1H, ibuf, ARRAYLENGTH(ibuf)); - } else { + } else if (h > 1) { LoadString(hinst_kcreddb, IDS_IVL_H, fbuf, ARRAYLENGTH(fbuf)); StringCbPrintf(ibuf, sizeof(ibuf), fbuf, h); + } else { + *ibuf = L'\0'; } - if(m > 0) { - StringCbCat(ibuf, sizeof(ibuf), L" "); + + if(m > 0 || h == 0) { + if (h >= 1) + StringCbCat(ibuf, sizeof(ibuf), L" "); + t = ibuf + wcslen(ibuf); if(m == 1) { @@ -446,12 +462,12 @@ KHMEXP khm_int32 KHMAPI FtIntervalToString(LPFILETIME data, wchar_t * buffer, kh return KHM_ERROR_SUCCESS; } -khm_int32 KHMAPI kcdb_type_interval_toString( - const void * data, - khm_size cbd, - wchar_t * buffer, - khm_size * cb_buf, - khm_int32 flags) +khm_int32 KHMAPI +kcdb_type_interval_toString(const void * data, + khm_size cbd, + wchar_t * buffer, + khm_size * cb_buf, + khm_int32 flags) { return FtIntervalToString((LPFILETIME) data, buffer, cb_buf); } @@ -471,8 +487,8 @@ khm_int32 KHMAPI kcdb_type_interval_comp( { __int64 i1, i2; - i1 = *((__int64 *) d1); - i2 = *((__int64 *) d2); + i1 = FtToInt((FILETIME *) d1); + i2 = FtToInt((FILETIME *) d2); if(i1 < i2) return -1; @@ -488,12 +504,12 @@ khm_int32 KHMAPI kcdb_type_interval_dup( void * d_dst, khm_size * cbd_dst) { - if(d_dst && *cbd_dst >= sizeof(__int64)) { - *cbd_dst = sizeof(__int64); - *((__int64 *) d_dst) = *((__int64 *) d_src); + if(d_dst && *cbd_dst >= sizeof(FILETIME)) { + *cbd_dst = sizeof(FILETIME); + *((FILETIME *) d_dst) = *((FILETIME *) d_src); return KHM_ERROR_SUCCESS; } else { - *cbd_dst = sizeof(__int64); + *cbd_dst = sizeof(FILETIME); return KHM_ERROR_TOO_LONG; } } @@ -759,8 +775,8 @@ void kcdb_type_init(void) type.toString = kcdb_type_interval_toString; type.name = KCDB_TYPENAME_INTERVAL; type.id = KCDB_TYPE_INTERVAL; - type.cb_max = sizeof(__int64); - type.cb_min = sizeof(__int64); + type.cb_max = sizeof(FILETIME); + type.cb_min = sizeof(FILETIME); type.flags = KCDB_TYPE_FLAG_CB_FIXED; kcdb_type_register(&type, NULL); @@ -1088,39 +1104,92 @@ KHMEXP khm_int32 KHMAPI kcdb_type_get_next_free(khm_int32 * id) KHMEXP void KHMAPI TimetToFileTime( time_t t, LPFILETIME pft ) { - LONGLONG ll = Int32x32To64(t, 10000000) + 116444736000000000i64; + LONGLONG ll; + + if ( sizeof(time_t) == 4 ) + ll = Int32x32To64(t, 10000000) + 116444736000000000i64; + else { + ll = t * 10000000i64 + 116444736000000000i64; + } pft->dwLowDateTime = (DWORD) ll; pft->dwHighDateTime = (DWORD) (ll >> 32); } KHMEXP void KHMAPI TimetToFileTimeInterval(time_t t, LPFILETIME pft) { - LONGLONG ll = Int32x32To64(t, 10000000); + LONGLONG ll; + + if ( sizeof(time_t) == 4 ) + ll = Int32x32To64(t, 10000000); + else { + ll = t * 10000000i64; + } pft->dwLowDateTime = (DWORD) ll; pft->dwHighDateTime = (DWORD) (ll >> 32); } KHMEXP long KHMAPI FtIntervalToSeconds(LPFILETIME pft) { - __int64 i = *((__int64 *) pft); + __int64 i = FtToInt(pft); return (long) (i / 10000000i64); } KHMEXP long KHMAPI FtIntervalToMilliseconds(LPFILETIME pft) { - __int64 i = *((__int64 *) pft); + __int64 i = FtToInt(pft); return (long) (i / 10000i64); } -KHMEXP long KHMAPI FtCompare(LPFILETIME pft1, LPFILETIME pft2) { - __int64 i1 = *((__int64 *) pft1); - __int64 i2 = *((__int64 *) pft2); +KHMEXP khm_int64 KHMAPI FtToInt(LPFILETIME pft) { + LARGE_INTEGER ll; + ll.LowPart = pft->dwLowDateTime; + ll.HighPart = pft->dwHighDateTime; + return ll.QuadPart; +} - if (i1 < i2) - return -1; - if (i1 == i2) - return 0; - return 1; +KHMEXP FILETIME KHMAPI IntToFt(khm_int64 i) { + LARGE_INTEGER ll; + FILETIME ft; + + ll.QuadPart = i; + ft.dwLowDateTime = ll.LowPart; + ft.dwHighDateTime = ll.HighPart; + + return ft; +} + +KHMEXP FILETIME KHMAPI FtSub(LPFILETIME ft1, LPFILETIME ft2) { + FILETIME d; + LARGE_INTEGER l1, l2; + + l1.LowPart = ft1->dwLowDateTime; + l1.HighPart = ft1->dwHighDateTime; + l2.LowPart = ft2->dwLowDateTime; + l2.HighPart = ft2->dwHighDateTime; + + l1.QuadPart -= l2.QuadPart; + + d.dwLowDateTime = l1.LowPart; + d.dwHighDateTime = l1.HighPart; + + return d; +} + +KHMEXP FILETIME KHMAPI FtAdd(LPFILETIME ft1, LPFILETIME ft2) { + FILETIME d; + LARGE_INTEGER l1, l2; + + l1.LowPart = ft1->dwLowDateTime; + l1.HighPart = ft1->dwHighDateTime; + l2.LowPart = ft2->dwLowDateTime; + l2.HighPart = ft2->dwHighDateTime; + + l1.QuadPart += l2.QuadPart; + + d.dwLowDateTime = l1.LowPart; + d.dwHighDateTime = l1.HighPart; + + return d; } KHMEXP int KHMAPI AnsiStrToUnicode( wchar_t * wstr, size_t cbwstr, const char * astr) @@ -1222,10 +1291,9 @@ KHMEXP khm_int32 KHMAPI IntervalStringToFt(FILETIME * pft, wchar_t * str) { size_t cb; wchar_t * b; - __int64 *pr, t; + __int64 t; - pr = (__int64 *) pft; - *pr = 0; + *pft = IntToFt(0); /* ideally we should synchronize this, but it doesn't hurt if two threads do this at the same time, because we only set the ivspecs_loaded @@ -1289,7 +1357,7 @@ KHMEXP khm_int32 KHMAPI IntervalStringToFt(FILETIME * pft, wchar_t * str) b = e; } - *pr = t; + *pft = IntToFt(t); return KHM_ERROR_SUCCESS; } diff --git a/src/windows/identity/kherr/kherr.c b/src/windows/identity/kherr/kherr.c index cc4b9d3cc..d8b145d24 100644 --- a/src/windows/identity/kherr/kherr.c +++ b/src/windows/identity/kherr/kherr.c @@ -26,9 +26,7 @@ #include #include -#ifdef Debug #include -#endif CRITICAL_SECTION cs_error; DWORD tls_error = 0; @@ -679,6 +677,65 @@ _exit: LeaveCriticalSection(&cs_error); } +KHMEXP kherr_event * __cdecl +kherr_reportf(const wchar_t * long_desc_fmt, ...) { + va_list vl; + wchar_t buf[1024]; + kherr_event * e; + + va_start(vl, long_desc_fmt); + StringCbVPrintf(buf, sizeof(buf), long_desc_fmt, vl); +#ifdef DEBUG + OutputDebugString(buf); +#endif + va_end(vl); + + e = kherr_report(KHERR_DEBUG_1, + NULL, NULL, NULL, buf, NULL, 0, + KHERR_SUGGEST_NONE, 0, 0, 0, 0, KHERR_RF_CSTR_LONG_DESC +#ifdef _WIN32 + ,NULL +#endif + ); + if (e) { + kherr_evaluate_event(e); + } + + return e; +} + +KHMEXP kherr_event * __cdecl +kherr_reportf_ex(enum kherr_severity severity, + const wchar_t * facility, + khm_int32 facility_id, +#ifdef _WIN32 + HMODULE hModule, +#endif + const wchar_t * long_desc_fmt, ...) { + va_list vl; + wchar_t buf[1024]; + kherr_event * e; + + va_start(vl, long_desc_fmt); + StringCbVPrintf(buf, sizeof(buf), long_desc_fmt, vl); +#ifdef DEBUG + OutputDebugString(buf); +#endif + va_end(vl); + + e = kherr_report(severity, NULL, facility, NULL, buf, NULL, facility_id, + KHERR_SUGGEST_NONE, 0, 0, 0, 0, KHERR_RF_CSTR_LONG_DESC +#ifdef _WIN32 + ,hModule +#endif + ); + if (e) { + kherr_evaluate_event(e); + } + + return e; +} + KHMEXP kherr_event * KHMAPI kherr_report(enum kherr_severity severity, const wchar_t * short_desc, diff --git a/src/windows/identity/kherr/kherr.h b/src/windows/identity/kherr/kherr.h index 973390f5e..6ae943e4e 100644 --- a/src/windows/identity/kherr/kherr.h +++ b/src/windows/identity/kherr/kherr.h @@ -569,6 +569,34 @@ KHMEXP kherr_event * KHMAPI kherr_report( #endif ); +/*! \brief Report a formatted message + + The format string \a long_desc_fmt should be a string constant and + the format specifiers follow that of \a sprintf. This creates an + event with the long description set to the expansion of the format + string against the arguments. + */ +KHMEXP kherr_event * __cdecl +kherr_reportf_ex(enum kherr_severity severity, + const wchar_t * facility, + khm_int32 facility_id, +#ifdef _WIN32 + HMODULE hModule, +#endif + const wchar_t * long_desc_fmt, + ...); + +/*! \brief Report a formatted message + + The format string \a long_desc_fmt should be a string constant and + the format specifiers follow that of \a sprintf. This creates an + event with the long description set to the expansion of the format + string against the arguments. + */ +KHMEXP kherr_event * __cdecl +kherr_reportf(const wchar_t * long_desc_fmt, + ...); + /*! \brief Create a parameter out of a transient string A parameter is created by duplicating the string that is passed diff --git a/src/windows/identity/kmm/kmm_registrar.c b/src/windows/identity/kmm/kmm_registrar.c index f9fdd4de8..1e632c7ba 100644 --- a/src/windows/identity/kmm/kmm_registrar.c +++ b/src/windows/identity/kmm/kmm_registrar.c @@ -59,14 +59,25 @@ kmmint_remove_from_module_queue(void) { } void -kmmint_add_to_plugin_queue(void) { - InterlockedIncrement(&pending_plugins); +kmmint_add_to_plugin_queue(kmm_plugin_i * plugin) { + EnterCriticalSection(&cs_kmm); + if (!(plugin->flags & KMM_PLUGIN_FLAG_IN_QUEUE)) { + InterlockedIncrement(&pending_plugins); + plugin->flags |= KMM_PLUGIN_FLAG_IN_QUEUE; + } + LeaveCriticalSection(&cs_kmm); } void -kmmint_remove_from_plugin_queue(void) { - InterlockedDecrement(&pending_plugins); +kmmint_remove_from_plugin_queue(kmm_plugin_i * plugin) { + EnterCriticalSection(&cs_kmm); + if (plugin->flags & KMM_PLUGIN_FLAG_IN_QUEUE) { + InterlockedDecrement(&pending_plugins); + plugin->flags &= ~KMM_PLUGIN_FLAG_IN_QUEUE; + } + + LeaveCriticalSection(&cs_kmm); kmmint_check_completion(); } @@ -160,7 +171,7 @@ DWORD WINAPI kmm_plugin_broker(LPVOID lpParameter) /* if it fails to initialize, we exit the plugin */ if(KHM_FAILED(rv)) { - kmmint_remove_from_plugin_queue(); + kmmint_remove_from_plugin_queue(p); rv = 1; goto _exit; } @@ -198,6 +209,7 @@ DWORD WINAPI kmm_plugin_broker(LPVOID lpParameter) pd->n_unresolved--; if(pd->n_unresolved == 0) { + kmmint_add_to_plugin_queue(pd); kmm_hold_plugin(kmm_handle_from_plugin(pd)); kmq_post_message(KMSG_KMM, KMSG_KMM_I_REG, KMM_REG_INIT_PLUGIN, (void *) pd); } @@ -205,7 +217,7 @@ DWORD WINAPI kmm_plugin_broker(LPVOID lpParameter) } while(FALSE); LeaveCriticalSection(&cs_kmm); - kmmint_remove_from_plugin_queue(); + kmmint_remove_from_plugin_queue(p); /* main message loop */ while(KHM_SUCCEEDED(kmq_dispatch(INFINITE))); @@ -402,7 +414,7 @@ void kmm_init_plugin(kmm_plugin_i * p) { goto _exit_post; } - kmmint_add_to_plugin_queue(); + kmmint_add_to_plugin_queue(p); p->ht_thread = CreateThread(NULL, 0, @@ -567,17 +579,19 @@ void kmm_init_module(kmm_module_i * m) { if(KHM_SUCCEEDED(khc_read_int32(csp_mod, L"FailureCount", &i))) { khm_int64 tm; khm_int64 ct; + FILETIME fct; khm_int32 last_reason = 0; /* reset the failure count if the failure count reset time period has elapsed */ tm = 0; khc_read_int64(csp_mod, L"FailureTime", &tm); - GetSystemTimeAsFileTime((LPFILETIME) &ct); - ct -= tm; + GetSystemTimeAsFileTime(&fct); + + ct = (FtToInt(&fct) - tm) / 10000000i64; if(tm > 0 && - FtIntervalToSeconds((LPFILETIME) &ct) > fail_reset_time) { + ct > fail_reset_time) { i = 0; khc_write_int32(csp_mod, L"FailureCount", 0); khc_write_int64(csp_mod, L"FailureTime", 0); @@ -722,7 +736,7 @@ void kmm_init_module(kmm_module_i * m) { _exit: if(csp_mod) { if(record_failure) { - khm_int64 ct; + FILETIME fct; i = 0; khc_read_int32(csp_mod, L"FailureCount", &i); @@ -730,8 +744,8 @@ void kmm_init_module(kmm_module_i * m) { khc_write_int32(csp_mod, L"FailureCount", i); if(i==1) { /* first fault */ - GetSystemTimeAsFileTime((LPFILETIME) &ct); - khc_write_int64(csp_mod, L"FailureTime", ct); + GetSystemTimeAsFileTime(&fct); + khc_write_int64(csp_mod, L"FailureTime", FtToInt(&fct)); } khc_write_int32(csp_mod, L"FailureReason", m->state); diff --git a/src/windows/identity/kmm/kmminternal.h b/src/windows/identity/kmm/kmminternal.h index 3ef45198e..c4e472387 100644 --- a/src/windows/identity/kmm/kmminternal.h +++ b/src/windows/identity/kmm/kmminternal.h @@ -143,6 +143,8 @@ typedef struct kmm_plugin_i_t { /* the plugin is in the module's plugin list */ #define KMM_PLUGIN_FLAG_IN_MODLIST 4 +#define KMM_PLUGIN_FLAG_IN_QUEUE 0x10 + enum kmm_registrar_uparam_t { KMM_REG_INIT_MODULE, KMM_REG_EXIT_MODULE, diff --git a/src/windows/identity/plugins/common/Makefile b/src/windows/identity/plugins/common/Makefile index cbadbc644..5107edca4 100644 --- a/src/windows/identity/plugins/common/Makefile +++ b/src/windows/identity/plugins/common/Makefile @@ -37,6 +37,7 @@ all: mkdirs $(INCFILES) $(OBJFILES) clean:: $(RM) $(INCFILES) + $(RM) $(OBJFILES) {}.c{$(LIBDIR)}.obj: $(C2OBJ) diff --git a/src/windows/identity/plugins/krb4/krb4newcreds.c b/src/windows/identity/plugins/krb4/krb4newcreds.c index fdbe304fa..28ae71a1f 100644 --- a/src/windows/identity/plugins/krb4/krb4newcreds.c +++ b/src/windows/identity/plugins/krb4/krb4newcreds.c @@ -68,8 +68,10 @@ void k4_update_display(k4_dlg_data * d) { EnableWindow(GetDlgItem(d->hwnd, IDC_NCK4_K524), FALSE); } - CheckRadioButton(d->hwnd, IDC_NCK4_AUTO, IDC_NCK4_K524, + CheckRadioButton(d->hwnd, IDC_NCK4_AUTO, IDC_NCK4_PWD, method_to_id[d->method]); + + khui_cw_enable_type(d->nc, credtype_id_krb4, d->k4_enabled); } void k4_update_data(k4_dlg_data * d) { @@ -99,6 +101,30 @@ void k4_update_data(k4_dlg_data * d) { } } +khm_boolean k4_should_identity_get_k4(khm_handle ident) { + khm_int32 idflags = 0; + + if (KHM_FAILED(kcdb_identity_get_flags(ident, &idflags))) + return FALSE; + + if (!(idflags & KCDB_IDENT_FLAG_DEFAULT)) { + /* we only support k4 for one identity, and that is the + default identity. If we are trying to get tickets for + a non-default identity, then we start off as + disabled. */ + + khm_handle defident = NULL; + + if (KHM_SUCCEEDED(kcdb_identity_get_default(&defident))) { + kcdb_identity_release(defident); + + return FALSE; + } + } + + return TRUE; +} + void k4_read_identity_data(k4_dlg_data * d) { khm_handle csp_ident = NULL; khm_handle csp_k4 = NULL; @@ -139,23 +165,10 @@ void k4_read_identity_data(k4_dlg_data * d) { } khc_close_space(csp_ident); - - kcdb_identity_get_flags(d->nc->identities[0], &idflags); } - if (!(idflags & KCDB_IDENT_FLAG_DEFAULT)) { - /* we only support k4 for one identity, and that is the - default identity. If we are trying to get tickets for - a non-default identity, then we start off as - disabled. */ - - khm_handle defident = NULL; - - if (KHM_SUCCEEDED(kcdb_identity_get_default(&defident))) { - kcdb_identity_release(defident); - - d->k4_enabled = FALSE; - } + if (d->k4_enabled) { + d->k4_enabled = k4_should_identity_get_k4(d->nc->identities[0]); } } else { d->k4_enabled = FALSE; @@ -417,6 +430,12 @@ krb4_msg_newcred(khm_int32 msg_type, khm_int32 msg_subtype, nc = (khui_new_creds *) vparam; + if (!nc->ctx.identity) + break; + + if (!k4_should_identity_get_k4(nc->ctx.identity)) + break; + nct = PMALLOC(sizeof(*nct)); #ifdef DEBUG assert(nct); 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 042da77b7..a07dc4b30 100644 --- a/src/windows/identity/plugins/krb4/lang/en_us/langres.rc +++ b/src/windows/identity/plugins/krb4/lang/en_us/langres.rc @@ -63,10 +63,10 @@ BEGIN BS_AUTOCHECKBOX | WS_TABSTOP,7,26,97,10 CONTROL "Automatically determine method",IDC_NCK4_AUTO,"Button", BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,23,58,119,10 - CONTROL "Password",IDC_NCK4_PWD,"Button",BS_AUTORADIOBUTTON | - WS_TABSTOP,23,75,47,10 CONTROL "Kerberos 5 to 4 translation",IDC_NCK4_K524,"Button", - BS_AUTORADIOBUTTON | WS_TABSTOP,23,92,101,10 + BS_AUTORADIOBUTTON | WS_TABSTOP,23,76,101,10 + CONTROL "Password",IDC_NCK4_PWD,"Button",BS_AUTORADIOBUTTON | + WS_TABSTOP,23,94,47,10 GROUPBOX "Obtain Kerberos 4 tickets using",IDC_STATIC,7,43,286,72, WS_GROUP END diff --git a/src/windows/identity/plugins/krb5/errorfuncs.c b/src/windows/identity/plugins/krb5/errorfuncs.c index 28016d3cb..d2fabbad4 100644 --- a/src/windows/identity/plugins/krb5/errorfuncs.c +++ b/src/windows/identity/plugins/krb5/errorfuncs.c @@ -83,6 +83,9 @@ void khm_err_describe(long code, wchar_t * buf, khm_size cbbuf, case kadm_err_base: break; default: + if (code == KRB5KRB_AP_ERR_BAD_INTEGRITY) { + *suggestion = MSG_ERR_S_INTEGRITY; + } *suggest_code = KHERR_SUGGEST_RETRY; AnsiStrToUnicode(buf, cbbuf, com_err_msg); return; diff --git a/src/windows/identity/plugins/krb5/krb5configdlg.c b/src/windows/identity/plugins/krb5/krb5configdlg.c index 63fdc32b6..8cf89c7cd 100644 --- a/src/windows/identity/plugins/krb5/krb5configdlg.c +++ b/src/windows/identity/plugins/krb5/krb5configdlg.c @@ -78,6 +78,8 @@ typedef struct tag_k5_config_data { wchar_t config_file[MAX_PATH]; /* path to configuration file */ khm_boolean create_config_file; /* create config_file if missing? */ + khm_boolean inc_realms; /* include full realm list in new + credentials dialog? */ /* [libdefaults] */ khm_boolean dns_lookup_kdc; @@ -100,15 +102,16 @@ typedef struct tag_k5_config_data { khm_int32 flags; } k5_config_data; -#define K5_CDFLAG_MOD_DEF_REALM 1 -#define K5_CDFLAG_MOD_CONF_FILE 2 -#define K5_CDFLAG_MOD_DNS_LOOKUP_KDC 4 -#define K5_CDFLAG_MOD_DNS_LOOKUP_RLM 8 -#define K5_CDFLAG_MOD_DNS_FALLBACK 0x10 -#define K5_CDFLAG_MOD_NOADDRESSES 0x20 -#define K5_CDFLAG_MOD_LSA_IMPORT 0x40 -#define K5_CDFLAG_MOD_CREATE_CONF 0x80 -#define K5_CDFLAG_MOD_REALMS 0x1000 +#define K5_CDFLAG_MOD_DEF_REALM 0x00000001 +#define K5_CDFLAG_MOD_CONF_FILE 0x00000002 +#define K5_CDFLAG_MOD_DNS_LOOKUP_KDC 0x00000004 +#define K5_CDFLAG_MOD_DNS_LOOKUP_RLM 0x00000008 +#define K5_CDFLAG_MOD_DNS_FALLBACK 0x00000010 +#define K5_CDFLAG_MOD_NOADDRESSES 0x00000020 +#define K5_CDFLAG_MOD_LSA_IMPORT 0x00000040 +#define K5_CDFLAG_MOD_CREATE_CONF 0x00000080 +#define K5_CDFLAG_MOD_INC_REALMS 0x00000100 +#define K5_CDFLAG_MOD_REALMS 0x00001000 static const char *const conf_yes[] = { "y", "yes", "true", "t", "1", "on", @@ -506,16 +509,23 @@ k5_read_config_data(k5_config_data * d) { pprofile_release(profile); } - /* last, read the MSLSA import setting */ { khm_int32 t; + /* last, read the MSLSA import setting */ if (KHM_SUCCEEDED(khc_read_int32(csp_params, L"MsLsaImport", &t))) { d->lsa_import = t; } else { d->lsa_import = K5_LSAIMPORT_ALWAYS; } + + if (KHM_SUCCEEDED(khc_read_int32(csp_params, + L"UseFullRealmList", &t))) { + d->inc_realms = !!t; + } else { + d->inc_realms = TRUE; + } } d->flags = 0; @@ -546,9 +556,11 @@ k5_write_config_data(k5_config_data * d) { /* write the MSLSA import setting */ if (d->flags & K5_CDFLAG_MOD_LSA_IMPORT) { - khc_write_int32(csp_params, L"MsLsaImport", d->lsa_import); + } + if (d->flags & K5_CDFLAG_MOD_INC_REALMS) { + khc_write_int32(csp_params, L"UseFullRealmList", d->inc_realms); } if (!(d->flags & @@ -912,6 +924,9 @@ k5_config_dlgproc(HWND hwnd, d->node_main = (khui_config_node) lParam; + CheckDlgButton(hwnd, IDC_CFG_INCREALMS, + (d->inc_realms)? BST_CHECKED: BST_UNCHECKED); + hw = GetDlgItem(hwnd, IDC_CFG_DEFREALM); #ifdef DEBUG assert(hw); @@ -984,6 +999,21 @@ k5_config_dlgproc(HWND hwnd, KHUI_CNFLAG_MODIFIED); return TRUE; } + + if (wParam == MAKEWPARAM(IDC_CFG_INCREALMS, BN_CLICKED)) { + if (IsDlgButtonChecked(hwnd, IDC_CFG_INCREALMS) == + BST_CHECKED) { + d->inc_realms = TRUE; + } else { + d->inc_realms = FALSE; + } + d->flags |= K5_CDFLAG_MOD_INC_REALMS; + + khui_cfg_set_flags(d->node_main, + KHUI_CNFLAG_MODIFIED, + KHUI_CNFLAG_MODIFIED); + return TRUE; + } } break; diff --git a/src/windows/identity/plugins/krb5/krb5configid.c b/src/windows/identity/plugins/krb5/krb5configid.c index 17ab40929..a4e549d3d 100644 --- a/src/windows/identity/plugins/krb5/krb5configid.c +++ b/src/windows/identity/plugins/krb5/krb5configid.c @@ -60,7 +60,10 @@ k5_id_read_params(k5_id_dlg_data * d) { khm_handle csp_idroot = NULL; cb = sizeof(idname); - khui_cfg_get_name(d->cfg.ctx_node, idname, &cb); + rv = khui_cfg_get_name(d->cfg.ctx_node, idname, &cb); +#ifdef DEBUG + assert(KHM_SUCCEEDED(rv)); +#endif rv = kcdb_identity_create(idname, 0, &d->ident); #ifdef DEBUG @@ -93,8 +96,12 @@ k5_id_read_params(k5_id_dlg_data * d) { cb = sizeof(d->ccache); rv = khc_read_string(csp_ident, L"DefaultCCName", d->ccache, &cb); - if (KHM_FAILED(rv)) - ZeroMemory(d->ccache, sizeof(d->ccache)); + if (KHM_FAILED(rv) || cb <= sizeof(wchar_t)) { + cb = sizeof(d->ccache); + if (KHM_FAILED(kcdb_identity_get_attr(d->ident, attr_id_krb5_ccname, + NULL, d->ccache, &cb))) + ZeroMemory(d->ccache, sizeof(d->ccache)); + } khui_tracker_initialize(&d->tc_life); d->tc_life.current = d->life; diff --git a/src/windows/identity/plugins/krb5/krb5funcs.c b/src/windows/identity/plugins/krb5/krb5funcs.c index 3dfea750c..5c076951a 100644 --- a/src/windows/identity/plugins/krb5/krb5funcs.c +++ b/src/windows/identity/plugins/krb5/krb5funcs.c @@ -220,7 +220,7 @@ static long get_tickets_from_cache(krb5_context ctx, khm_handle ident = NULL; khm_handle cred = NULL; time_t tt; - khm_int64 ft, eft; + FILETIME ft, eft; khm_int32 ti; @@ -372,25 +372,32 @@ static long get_tickets_from_cache(krb5_context ctx, KRBv5Credentials.times.starttime = KRBv5Credentials.times.authtime; tt = KRBv5Credentials.times.starttime; - TimetToFileTime(tt, (LPFILETIME) &ft); + TimetToFileTime(tt, &ft); kcdb_cred_set_attr(cred, KCDB_ATTR_ISSUE, &ft, sizeof(ft)); tt = KRBv5Credentials.times.endtime; - TimetToFileTime(tt, (LPFILETIME) &eft); + TimetToFileTime(tt, &eft); kcdb_cred_set_attr(cred, KCDB_ATTR_EXPIRE, &eft, sizeof(eft)); - eft -= ft; - kcdb_cred_set_attr(cred, KCDB_ATTR_LIFETIME, &eft, sizeof(eft)); + { + FILETIME ftl; + + ftl = FtSub(&eft, &ft); + kcdb_cred_set_attr(cred, KCDB_ATTR_LIFETIME, &ftl, sizeof(ftl)); + } if (KRBv5Credentials.times.renew_till > 0) { + FILETIME ftl; + tt = KRBv5Credentials.times.renew_till; - TimetToFileTime(tt, (LPFILETIME) &eft); + TimetToFileTime(tt, &eft); kcdb_cred_set_attr(cred, KCDB_ATTR_RENEW_EXPIRE, &eft, sizeof(eft)); - eft -= ft; - kcdb_cred_set_attr(cred, KCDB_ATTR_RENEW_LIFETIME, &eft, - sizeof(eft)); + + ftl = FtSub(&eft, &ft); + kcdb_cred_set_attr(cred, KCDB_ATTR_RENEW_LIFETIME, &ftl, + sizeof(ftl)); } ti = KRBv5Credentials.ticket_flags; @@ -441,7 +448,7 @@ static long get_tickets_from_cache(krb5_context ctx, int n = 0; while ( KRBv5Credentials.addresses[n] ) n++; - list->addrList = calloc(1, n * sizeof(char *)); + list->addrList = PCALLOC(1, n * sizeof(char *)); if (!list->addrList) { MessageBox(NULL, "Memory Error", "Error", MB_OK); return ENOMEM; @@ -449,7 +456,7 @@ static long get_tickets_from_cache(krb5_context ctx, list->addrCount = n; for ( n=0; naddrCount; n++ ) { wsprintf(Buffer, "Address: %s", one_addr(KRBv5Credentials.addresses[n])); - list->addrList[n] = (char*) calloc(1, strlen(Buffer)+1); + list->addrList[n] = (char*) PCALLOC(1, strlen(Buffer)+1); if (!list->addrList[n]) { MessageBox(NULL, "Memory Error", "Error", MB_OK); @@ -461,9 +468,9 @@ static long get_tickets_from_cache(krb5_context ctx, #endif if(cred_flags & KCDB_CRED_FLAG_INITIAL) { - __int64 t_issue_new; - __int64 t_expire_old; - __int64 t_expire_new; + FILETIME ft_issue_new; + FILETIME ft_expire_old; + FILETIME ft_expire_new; khm_size cb; /* an initial ticket! If we find one, we generally set @@ -472,30 +479,30 @@ static long get_tickets_from_cache(krb5_context ctx, the current primary credential. */ tt = KRBv5Credentials.times.endtime; - TimetToFileTime(tt, (LPFILETIME) &t_expire_new); + TimetToFileTime(tt, &ft_expire_new); tt = KRBv5Credentials.times.starttime; - TimetToFileTime(tt, (LPFILETIME) &t_issue_new); + TimetToFileTime(tt, &ft_issue_new); - cb = sizeof(t_expire_old); + cb = sizeof(ft_expire_old); if(KHM_FAILED(kcdb_identity_get_attr(tident, KCDB_ATTR_EXPIRE, - NULL, &t_expire_old, + NULL, &ft_expire_old, &cb)) - || t_expire_new > t_expire_old) - { + || CompareFileTime(&ft_expire_new, &ft_expire_old) > 0) { + kcdb_identity_set_attr(tident, attr_id_krb5_ccname, wcc_name, KCDB_CBSIZE_AUTO); kcdb_identity_set_attr(tident, KCDB_ATTR_EXPIRE, - &t_expire_new, - sizeof(t_expire_new)); + &ft_expire_new, + sizeof(ft_expire_new)); kcdb_identity_set_attr(tident, KCDB_ATTR_ISSUE, - &t_issue_new, - sizeof(t_issue_new)); + &ft_issue_new, + sizeof(ft_issue_new)); if (KRBv5Credentials.times.renew_till > 0) { tt = KRBv5Credentials.times.renew_till; - TimetToFileTime(tt, (LPFILETIME) &ft); + TimetToFileTime(tt, &ft); kcdb_identity_set_attr(tident, KCDB_ATTR_RENEW_EXPIRE, &ft, sizeof(ft)); @@ -1515,60 +1522,44 @@ khm_krb5_ms2mit(BOOL save_creds) char *princ_name = NULL; BOOL rc = FALSE; -#ifdef DEBUG - kherr_debug_printf(L"Begin : khm_krb5_ms2mit. save_cred=%d\n", (int) save_creds); -#endif + kherr_reportf(L"Begin : khm_krb5_ms2mit. save_cred=%d\n", (int) save_creds); + if ( !pkrb5_init_context ) goto cleanup; if (code = pkrb5_init_context(&kcontext)) goto cleanup; -#ifdef DEBUG - kherr_debug_printf(L"Resolving MSLSA\n"); -#endif + kherr_reportf(L"Resolving MSLSA\n"); + if (code = pkrb5_cc_resolve(kcontext, "MSLSA:", &mslsa_ccache)) goto cleanup; if ( save_creds ) { -#ifdef DEBUG - kherr_debug_printf(L"Getting principal\n"); -#endif - if (code = pkrb5_cc_get_principal(kcontext, mslsa_ccache, &princ)) + kherr_reportf(L"Getting principal\n"); + if (code = pkrb5_cc_get_principal(kcontext, mslsa_ccache, &princ)) goto cleanup; -#ifdef DEBUG - kherr_debug_printf(L"Unparsing name\n"); -#endif - if (code = pkrb5_unparse_name(kcontext, princ, &princ_name)) + kherr_reportf(L"Unparsing name\n"); + if (code = pkrb5_unparse_name(kcontext, princ, &princ_name)) goto cleanup; -#ifdef DEBUG - kherr_debug_printf(L"Unparsed [%S]. Resolving target cache\n", princ_name); -#endif + kherr_reportf(L"Unparsed [%S]. Resolving target cache\n", princ_name); /* TODO: actually look up the preferred ccache name */ if (code = pkrb5_cc_resolve(kcontext, princ_name, &ccache)) { -#ifdef DEBUG - kherr_debug_printf(L"Cannot resolve cache [%S] with code=%d. Trying default.\n", princ_name, code); -#endif + kherr_reportf(L"Cannot resolve cache [%S] with code=%d. Trying default.\n", princ_name, code); if (code = pkrb5_cc_default(kcontext, &ccache)) { -#ifdef DEBUG - kherr_debug_printf(L"Failed to resolve default ccache. Code=%d", code); -#endif + kherr_reportf(L"Failed to resolve default ccache. Code=%d", code); goto cleanup; } } -#ifdef DEBUG - kherr_debug_printf(L"Initializing ccache\n"); -#endif + kherr_reportf(L"Initializing ccache\n"); if (code = pkrb5_cc_initialize(kcontext, ccache, princ)) goto cleanup; -#ifdef DEBUG - kherr_debug_printf(L"Copying credentials\n"); -#endif + kherr_reportf(L"Copying credentials\n"); if (code = pkrb5_cc_copy_creds(kcontext, mslsa_ccache, ccache)) goto cleanup; @@ -1591,9 +1582,7 @@ khm_krb5_ms2mit(BOOL save_creds) } cleanup: -#ifdef DEBUG - kherr_debug_printf(L" Received code=%d", code); -#endif + kherr_reportf(L" Received code=%d", code); if (princ_name) pkrb5_free_unparsed_name(kcontext, princ_name); diff --git a/src/windows/identity/plugins/krb5/krb5identpro.c b/src/windows/identity/plugins/krb5/krb5identpro.c index 858243daf..2ad904b43 100644 --- a/src/windows/identity/plugins/krb5/krb5identpro.c +++ b/src/windows/identity/plugins/krb5/krb5identpro.c @@ -516,8 +516,39 @@ ui_cb(khui_new_creds * nc, 0, (LPARAM) t); } + _done_adding_lru: + + { + khm_int32 inc_realms = 0; + + if (KHM_FAILED(khc_read_int32(csp_params, + L"UseFullRealmList", + &inc_realms)) || + !inc_realms) + goto _done_adding_all_realms; + } + + if(ms) + PFREE(ms); + + ms = khm_krb5_get_realm_list(); + if(ms) { + for (t = ms; t && *t; t = multi_string_next(t)) { + lr = SendMessage(d->hw_realm, + CB_FINDSTRINGEXACT, + (WPARAM) -1, + (LPARAM) t); + if (lr != CB_ERR) + continue; + + SendMessage(d->hw_realm, + CB_ADDSTRING, + 0, + (LPARAM) t); + } + } + _done_adding_all_realms: - _done_adding_lru: /* set the current selection of the realms list */ if (defrealm) { SendMessage(d->hw_realm, @@ -1080,12 +1111,8 @@ k5_ident_update(khm_int32 msg_type, return KHM_ERROR_SUCCESS; } - -static khm_int32 -k5_ident_init(khm_int32 msg_type, - khm_int32 msg_subtype, - khm_ui_4 uparam, - void * vparam) { +static khm_boolean +k5_refresh_default_identity(krb5_context ctx) { /* just like notify_create, except now we set the default identity based on what we find in the configuration */ krb5_ccache cc = NULL; @@ -1096,31 +1123,23 @@ k5_ident_init(khm_int32 msg_type, khm_handle ident = NULL; khm_boolean found_default = FALSE; - assert(k5_identpro_ctx != NULL); + assert(ctx != NULL); - code = pkrb5_cc_default(k5_identpro_ctx, &cc); + code = pkrb5_cc_default(ctx, &cc); if (code) goto _nc_cleanup; - - code = pkrb5_cc_get_principal(k5_identpro_ctx, - cc, - &princ); + + code = pkrb5_cc_get_principal(ctx, cc, &princ); if (code) goto _nc_cleanup; - code = pkrb5_unparse_name(k5_identpro_ctx, - princ, - &princ_nameA); + code = pkrb5_unparse_name(ctx, princ, &princ_nameA); if (code) goto _nc_cleanup; - AnsiStrToUnicode(princ_nameW, - sizeof(princ_nameW), - princ_nameA); + AnsiStrToUnicode(princ_nameW, sizeof(princ_nameW), princ_nameA); - if (KHM_FAILED(kcdb_identity_create(princ_nameW, - 0, - &ident))) + if (KHM_FAILED(kcdb_identity_create(princ_nameW, 0, &ident))) goto _nc_cleanup; kcdb_identity_set_default_int(ident); @@ -1129,17 +1148,31 @@ k5_ident_init(khm_int32 msg_type, _nc_cleanup: if (princ_nameA) - pkrb5_free_unparsed_name(k5_identpro_ctx, - princ_nameA); + pkrb5_free_unparsed_name(ctx, princ_nameA); + if (princ) - pkrb5_free_principal(k5_identpro_ctx, - princ); + pkrb5_free_principal(ctx, princ); + if (cc) - pkrb5_cc_close(k5_identpro_ctx, cc); + pkrb5_cc_close(ctx, cc); if (ident) kcdb_identity_release(ident); + return found_default; +} + +static khm_int32 +k5_ident_init(khm_int32 msg_type, + khm_int32 msg_subtype, + khm_ui_4 uparam, + void * vparam) { + + khm_boolean found_default; + khm_handle ident; + + found_default = k5_refresh_default_identity(k5_identpro_ctx); + if (!found_default) { wchar_t widname[KCDB_IDENT_MAXCCH_NAME]; khm_size cb; @@ -1284,6 +1317,143 @@ k5_ident_name_comp_func(const void * dl, khm_size cb_dl, return r; } + +/* Identity change notification thread */ + +HANDLE h_ccname_exit_event; +HANDLE h_ccname_thread; + +DWORD WINAPI k5_ccname_monitor_thread(LPVOID lpParameter) { + krb5_context ctx = 0; + + HKEY hk_ccname; + HANDLE h_notify; + HANDLE h_waits[2]; + + khm_int32 rv = KHM_ERROR_SUCCESS; + DWORD dwType; + DWORD dwSize; + DWORD dwDisp; + wchar_t reg_ccname[KRB5_MAXCCH_CCNAME]; + LONG l; + + l = RegOpenKeyEx(HKEY_CURRENT_USER, + L"Software\\MIT\\kerberos5", + 0, + KEY_READ | KEY_WRITE, + &hk_ccname); + + if (l != ERROR_SUCCESS) + l = RegCreateKeyEx(HKEY_CURRENT_USER, + L"Software\\MIT\\kerberos5", + 0, + NULL, + REG_OPTION_NON_VOLATILE, + KEY_READ | KEY_WRITE, + NULL, + &hk_ccname, + &dwDisp); + + if (l != ERROR_SUCCESS) { + rv = KHM_ERROR_UNKNOWN; + goto _exit; + } + + dwSize = sizeof(reg_ccname); + + l = RegQueryValueEx(hk_ccname, + L"ccname", + NULL, + &dwType, + (LPBYTE) reg_ccname, + &dwSize); + + if (l != ERROR_SUCCESS || + dwType != REG_SZ) { + + reg_ccname[0] = L'\0'; + } + + l = pkrb5_init_context(&ctx); + + if (l) + goto _exit_0; + + h_notify = CreateEvent(NULL, FALSE, FALSE, L"Local\\Krb5CCNameChangeNotifier"); + + if (h_notify == NULL) + goto _exit_0; + + /* begin wait loop */ + + h_waits[0] = h_ccname_exit_event; + h_waits[1] = h_notify; + + do { + DWORD dwrv; + + l = RegNotifyChangeKeyValue(hk_ccname, FALSE, + REG_NOTIFY_CHANGE_LAST_SET, + h_notify, TRUE); + + if (l != ERROR_SUCCESS) { + rv = KHM_ERROR_UNKNOWN; + break; + } + + dwrv = WaitForMultipleObjects(2, h_waits, FALSE, INFINITE); + + if (dwrv == WAIT_OBJECT_0) { + /* exit! */ + break; + + } else if (dwrv == WAIT_OBJECT_0 + 1) { + /* change notify! */ + wchar_t new_ccname[KRB5_MAXCCH_CCNAME]; + + dwSize = sizeof(new_ccname); + + l = RegQueryValueEx(hk_ccname, + L"ccname", + NULL, + &dwType, + (LPBYTE) new_ccname, + &dwSize); + + if (l != ERROR_SUCCESS || + dwType != REG_SZ) { + new_ccname[0] = L'\0'; + } + + if (wcsicmp(new_ccname, reg_ccname)) { + k5_refresh_default_identity(ctx); + StringCbCopy(reg_ccname, sizeof(reg_ccname), new_ccname); + } + + } else { + /* something went wrong */ + rv = KHM_ERROR_UNKNOWN; + break; + } + + } while (TRUE); + + CloseHandle(h_notify); + + _exit_0: + + RegCloseKey(hk_ccname); + + if (ctx) + pkrb5_free_context(ctx); + + _exit: + ExitThread(rv); + + /* not reached */ + return rv; +} + khm_int32 k5_msg_system_idpro(khm_int32 msg_type, khm_int32 msg_subtype, khm_ui_4 uparam, void * vparam) { @@ -1329,11 +1499,34 @@ k5_msg_system_idpro(khm_int32 msg_type, khm_int32 msg_subtype, kcdb_attrib_release_info(attr); } + + h_ccname_exit_event = CreateEvent(NULL, FALSE, FALSE, NULL); + if (h_ccname_exit_event) { + h_ccname_thread = CreateThread(NULL, + 200 * 1024, + k5_ccname_monitor_thread, + NULL, + 0, + NULL); + } else { + h_ccname_thread = NULL; + } } break; case KMSG_SYSTEM_EXIT: { + + if (h_ccname_thread) { + SetEvent(h_ccname_exit_event); + WaitForSingleObject(h_ccname_thread, INFINITE); + CloseHandle(h_ccname_thread); + CloseHandle(h_ccname_exit_event); + + h_ccname_exit_event = NULL; + h_ccname_thread = NULL; + } + if (k5_identpro_ctx) { pkrb5_free_context(k5_identpro_ctx); k5_identpro_ctx = NULL; diff --git a/src/windows/identity/plugins/krb5/krb5newcreds.c b/src/windows/identity/plugins/krb5/krb5newcreds.c index a08fb91d9..e6bf6479d 100644 --- a/src/windows/identity/plugins/krb5/krb5newcreds.c +++ b/src/windows/identity/plugins/krb5/krb5newcreds.c @@ -459,6 +459,7 @@ k5_kinit_fiber_proc(PVOID lpParameter) goto _switch_to_main; if (!k5_cp_check_continue()) { + g_fjob.code = KRB5KRB_AP_ERR_BAD_INTEGRITY; goto _switch_to_main; } } @@ -1278,7 +1279,7 @@ k5_msg_cred_dialog(khm_int32 msg_type, nct->type = credtype_id_krb5; nct->ordinal = 1; - LoadString(hResModule, IDS_KRB5_SHORT_DESC, + LoadString(hResModule, IDS_KRB5_NC_NAME, wbuf, ARRAYLENGTH(wbuf)); StringCbLength(wbuf, sizeof(wbuf), &cbsize); cbsize += sizeof(wchar_t); @@ -1343,12 +1344,10 @@ k5_msg_cred_dialog(khm_int32 msg_type, realms = khm_krb5_get_realm_list(); if(realms) { - t = realms; - while(t && *t) { + for (t = realms; t && *t; t = multi_string_next(t)) { SendDlgItemMessage(hwnd, IDC_NCK5_REALM, CB_ADDSTRING, 0, (LPARAM) t); - t = multi_string_next(t); } PFREE(realms); } @@ -1698,7 +1697,6 @@ k5_msg_cred_dialog(khm_int32 msg_type, NULL)))) g_fjob.code = 0; - if(g_fjob.code != 0) { wchar_t tbuf[1024]; DWORD suggestion; @@ -1771,6 +1769,10 @@ k5_msg_cred_dialog(khm_int32 msg_type, khm_krb5_list_tickets(&ctx); + if (nc->set_default) { + kcdb_identity_set_default(nc->identities[0]); + } + /* If there is no default identity, then make this the default */ kcdb_identity_refresh(nc->identities[0]); { @@ -1841,7 +1843,7 @@ k5_msg_cred_dialog(khm_int32 msg_type, wbuf); atsign = wcschr(idname, L'@'); - if (atsign != NULL) + if (atsign == NULL) goto _done_with_LRU; atsign++; @@ -1911,6 +1913,7 @@ k5_msg_cred_dialog(khm_int32 msg_type, if (wbuf) PFREE(wbuf); + } else if (g_fjob.state == FIBER_STATE_NONE) { /* the user cancelled the operation */ r = KHUI_NC_RESPONSE_EXIT | @@ -1942,11 +1945,11 @@ k5_msg_cred_dialog(khm_int32 msg_type, _end_task(); } else if (nc->subtype == KMSG_CRED_RENEW_CREDS) { - __int64 ftidexp = 0; - __int64 ftcurrent; + FILETIME ftidexp = {0,0}; + FILETIME ftcurrent; khm_size cb; - GetSystemTimeAsFileTime((LPFILETIME) &ftcurrent); + GetSystemTimeAsFileTime(&ftcurrent); _begin_task(0); _report_mr0(KHERR_NONE, MSG_CTX_RENEW_CREDS); @@ -1983,7 +1986,7 @@ k5_msg_cred_dialog(khm_int32 msg_type, khui_cw_set_response(nc, credtype_id_krb5, KHUI_NC_RESPONSE_EXIT | KHUI_NC_RESPONSE_FAILED); - } else if (ftcurrent < ftidexp) { + } else if (CompareFileTime(&ftcurrent, &ftidexp) < 0) { wchar_t tbuf[1024]; DWORD suggestion; kherr_suggestion sug_id; diff --git a/src/windows/identity/plugins/krb5/krbconfig.csv b/src/windows/identity/plugins/krb5/krbconfig.csv index 0059f0ab1..9b849c88f 100644 --- a/src/windows/identity/plugins/krb5/krbconfig.csv +++ b/src/windows/identity/plugins/krb5/krbconfig.csv @@ -20,6 +20,7 @@ Krb5Cred,KC_SPACE,0,Kerberos V Credentials Provider DefaultRenewLifetime,KC_INT32,604800,Default renewable lifetime MaxRenewLifetime,KC_INT32,2592000,Maximum renewable lifetime MinRenewLifetime,KC_INT32,60,Maximum renewable lifetime + UseFullRealmList,KC_INT32,0,Use the full list of realms in the New Creds dialog LRURealms,KC_STRING,, LRUPrincipals,KC_STRING,, LastDefaultIdent,KC_STRING,,Last known default identity 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 d95c58d86..d54fc101e 100644 --- a/src/windows/identity/plugins/krb5/lang/en_us/langres.rc +++ b/src/windows/identity/plugins/krb5/lang/en_us/langres.rc @@ -62,7 +62,7 @@ BEGIN COMBOBOX IDC_NCK5_REALM,60,25,233,17,CBS_DROPDOWN | CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Specify &additional realms ...",IDC_NCK5_ADD_REALMS,181, - 43,112,16,BS_NOTIFY | WS_DISABLED + 43,112,16,BS_NOTIFY | NOT WS_VISIBLE | WS_DISABLED LTEXT "&Lifetime",IDC_STATIC,7,67,61,12 EDITTEXT IDC_NCK5_LIFETIME_EDIT,85,67,107,12,ES_AUTOHSCROLL CONTROL "&Renewable for",IDC_NCK5_RENEWABLE,"Button", @@ -131,13 +131,16 @@ BEGIN WS_VSCROLL | WS_TABSTOP PUSHBUTTON "Configure Realms ...",IDC_CFG_CFGREALMS,76,25,84,14, WS_DISABLED - GROUPBOX "Keberos Configuration File",IDC_CFG_CFGFILEGRP,7,57,241, - 48 - LTEXT "Location",IDC_CFG_LBL_CFGFILE,13,71,28,8 - EDITTEXT IDC_CFG_CFGFILE,76,68,119,14,ES_AUTOHSCROLL - PUSHBUTTON "Browse...",IDC_CFG_BROWSE,198,68,44,14 + 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 | WS_DISABLED | WS_TABSTOP,76,89,80,10 + BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,76,76,80,10 + CONTROL "Include realms in New Credentials realm list", + IDC_CFG_INCREALMS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, + 76,91,153,10 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 | @@ -385,7 +388,7 @@ BEGIN IDS_ETYPE_UNKNOWN "(Unknown)" IDS_ETYPE_LOCAL_DES3_HMAC_SHA1 "LOCAL-DES3-HMAC-SHA1" IDS_ETYPE_LOCAL_RC4_MD4 "LOCAL-RC4-MD4" - IDS_KRB5_SHORT_DESC "Kerberos 5" + IDS_KRB5_SHORT_DESC "Kerberos 5 tickets" IDS_KRB5_LONG_DESC "Kerberos 5 tickets" END @@ -480,6 +483,7 @@ BEGIN IDS_NO "No" IDS_CFG_RE_NEWSERVER "" IDS_CFG_RE_NEWDMAP "" + IDS_KRB5_NC_NAME "Kerberos 5" END #endif // English (U.S.) resources diff --git a/src/windows/identity/plugins/krb5/lang/krb5_msgs.mc b/src/windows/identity/plugins/krb5/lang/krb5_msgs.mc index 22f973f93..2b637ac9f 100644 --- a/src/windows/identity/plugins/krb5/lang/krb5_msgs.mc +++ b/src/windows/identity/plugins/krb5/lang/krb5_msgs.mc @@ -145,6 +145,13 @@ Language=English Please select an identity to change the password. . +MessageId= +SymbolicName=MSG_ERR_S_INTEGRITY +Language=English +This is commonly caused by an incorrect password. Please verify that the password is correct and note that passwords are case sensitive. +. + + MessageId= SymbolicName=MSG_ Language=English diff --git a/src/windows/identity/plugins/krb5/langres.h b/src/windows/identity/plugins/krb5/langres.h index 52adc34e3..6f76cc56b 100644 --- a/src/windows/identity/plugins/krb5/langres.h +++ b/src/windows/identity/plugins/krb5/langres.h @@ -114,6 +114,7 @@ #define IDS_NO 196 #define IDS_CFG_RE_NEWSERVER 197 #define IDS_CFG_RE_NEWDMAP 198 +#define IDS_KRB5_NC_NAME 199 #define IDC_NCK5_RENEWABLE 1002 #define IDC_NCK5_FORWARDABLE 1004 #define IDC_NCK5_REALM 1005 @@ -171,6 +172,8 @@ #define IDC_CFG_INCAPI 1066 #define IDC_CFG_INCMSLSA 1067 #define IDC_PPK5_FLAGS 1072 +#define IDC_CHECK1 1073 +#define IDC_CFG_INCREALMS 1073 // Next default values for new objects // @@ -178,7 +181,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 117 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1073 +#define _APS_NEXT_CONTROL_VALUE 1074 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/src/windows/identity/ui/appglobal.h b/src/windows/identity/ui/appglobal.h index 585ec090a..9baa9b9e2 100644 --- a/src/windows/identity/ui/appglobal.h +++ b/src/windows/identity/ui/appglobal.h @@ -73,7 +73,7 @@ void khm_exit_gui(void); void khm_parse_commandline(); void khm_register_window_classes(void); -HWND khm_html_help(HWND hwnd, UINT command, DWORD_PTR data); +HWND khm_html_help(HWND hwnd, wchar_t * suffix, UINT command, DWORD_PTR data); #define MAX_RES_STRING 1024 diff --git a/src/windows/identity/ui/cfg_identities_wnd.c b/src/windows/identity/ui/cfg_identities_wnd.c index d38b338d2..0ec3dcbbb 100644 --- a/src/windows/identity/ui/cfg_identities_wnd.c +++ b/src/windows/identity/ui/cfg_identities_wnd.c @@ -299,6 +299,12 @@ typedef struct tag_ident_data { HWND hwnd; } ident_data; +typedef struct tag_global_props { + BOOL monitor; + BOOL auto_renew; + BOOL sticky; +} global_props; + typedef struct tag_idents_data { BOOL valid; @@ -306,6 +312,11 @@ typedef struct tag_idents_data { khm_size n_idents; khm_size nc_idents; + /* global options */ + global_props saved; + global_props work; + BOOL applied; + int refcount; HIMAGELIST hi_status; @@ -319,7 +330,12 @@ typedef struct tag_idents_data { khui_config_init_data cfg; } idents_data; -static idents_data cfg_idents = {FALSE, NULL, 0, 0, 0, NULL }; +static idents_data cfg_idents = {FALSE, NULL, 0, 0, + {0, 0, 0}, + {0, 0, 0}, + FALSE, + + 0, NULL }; static void read_params_ident(ident_data * d) { @@ -406,16 +422,24 @@ write_params_ident(ident_data * d) { return; } - if (d->saved.monitor != d->work.monitor) - khc_write_int32(csp_ident, L"Monitor", !!d->work.monitor); + if (d->removed) { - if (d->saved.auto_renew != d->work.auto_renew) - khc_write_int32(csp_ident, L"AllowAutoRenew", !!d->work.auto_renew); + khc_remove_space(csp_ident); - if (d->saved.sticky != d->work.sticky) { - kcdb_identity_set_flags(d->ident, - (d->work.sticky)?KCDB_IDENT_FLAG_STICKY:0, - KCDB_IDENT_FLAG_STICKY); + } else { + + if (d->saved.monitor != d->work.monitor) + khc_write_int32(csp_ident, L"Monitor", !!d->work.monitor); + + if (d->saved.auto_renew != d->work.auto_renew) + khc_write_int32(csp_ident, L"AllowAutoRenew", + !!d->work.auto_renew); + + if (d->saved.sticky != d->work.sticky) { + kcdb_identity_set_flags(d->ident, + (d->work.sticky)?KCDB_IDENT_FLAG_STICKY:0, + KCDB_IDENT_FLAG_STICKY); + } } khc_close_space(csp_ident); @@ -432,6 +456,30 @@ write_params_ident(ident_data * d) { static void write_params_idents(void) { int i; + khm_handle csp_cw; + + if (KHM_SUCCEEDED(khc_open_space(NULL, L"CredWindow", + KHM_FLAG_CREATE, &csp_cw))) { + if (cfg_idents.work.monitor != cfg_idents.saved.monitor) { + khc_write_int32(csp_cw, L"DefaultMonitor", + !!cfg_idents.work.monitor); + cfg_idents.work.monitor = cfg_idents.saved.monitor; + cfg_idents.applied = TRUE; + } + if (cfg_idents.work.auto_renew != cfg_idents.saved.auto_renew) { + khc_write_int32(csp_cw, L"DefaultAllowAutoRenew", + !!cfg_idents.work.auto_renew); + cfg_idents.work.auto_renew = cfg_idents.saved.auto_renew; + cfg_idents.applied = TRUE; + } + if (cfg_idents.work.sticky != cfg_idents.saved.sticky) { + khc_write_int32(csp_cw, L"DefaultMonitor", + !!cfg_idents.work.sticky); + cfg_idents.work.sticky = cfg_idents.saved.sticky; + cfg_idents.applied = TRUE; + } + khc_close_space(csp_cw); + } for (i=0; i < (int)cfg_idents.n_idents; i++) { write_params_ident(&cfg_idents.idents[i]); @@ -450,6 +498,7 @@ init_idents_data(void) { khm_size cb; int n_tries = 0; int i; + khm_handle csp_cw; if (cfg_idents.valid) return; @@ -460,6 +509,35 @@ init_idents_data(void) { assert(cfg_idents.nc_idents == 0); #endif + if (KHM_SUCCEEDED(khc_open_space(NULL, L"CredWindow", 0, &csp_cw))) { + khm_int32 t; + + if (KHM_SUCCEEDED(khc_read_int32(csp_cw, L"DefaultMonitor", &t))) + cfg_idents.saved.monitor = !!t; + else + cfg_idents.saved.monitor = TRUE; + + if (KHM_SUCCEEDED(khc_read_int32(csp_cw, L"DefaultAllowAutoRenew", &t))) + cfg_idents.saved.auto_renew = !!t; + else + cfg_idents.saved.auto_renew = TRUE; + + if (KHM_SUCCEEDED(khc_read_int32(csp_cw, L"DefaultSticky", &t))) + cfg_idents.saved.sticky = !!t; + else + cfg_idents.saved.sticky = FALSE; + + } else { + + cfg_idents.saved.monitor = TRUE; + cfg_idents.saved.auto_renew = TRUE; + cfg_idents.saved.sticky = FALSE; + + } + + cfg_idents.work = cfg_idents.saved; + cfg_idents.applied = FALSE; + do { rv = kcdb_identity_enum(KCDB_IDENT_FLAG_CONFIG, KCDB_IDENT_FLAG_CONFIG, @@ -584,251 +662,35 @@ release_idents_data(void) { free_idents_data(); } -#define BS_TRUE 1 -#define BS_FALSE 2 - -static void -refresh_view_idents_sel(HWND hwnd) { - HWND hw; - int sel_count; - int i; - int idx; - ident_data * d; - LVITEM lvi; - - int monitor = 0; - int auto_renew = 0; - int sticky = 0; - - hw = GetDlgItem(hwnd, IDC_CFG_IDENTS); - - sel_count = ListView_GetSelectedCount(hw); - - idx = -1; - for (i=0; i < sel_count; i++) { - idx = ListView_GetNextItem(hw, idx, LVNI_SELECTED); -#ifdef DEBUG - assert(idx != -1); -#endif - ZeroMemory(&lvi, sizeof(lvi)); - - lvi.iItem = idx; - lvi.iSubItem = 0; - lvi.mask = LVIF_PARAM; - - ListView_GetItem(hw, &lvi); - - d = (ident_data *) lvi.lParam; -#ifdef DEBUG - assert(d != NULL); -#endif - - if (d->work.monitor) - monitor |= BS_TRUE; - else - monitor |= BS_FALSE; - - if (d->work.auto_renew) - auto_renew |= BS_TRUE; - else - auto_renew |= BS_FALSE; - - if (d->work.sticky) - sticky |= BS_TRUE; - else - sticky |= BS_FALSE; - } - - CheckDlgButton(hwnd, IDC_CFG_MONITOR, - (monitor == BS_TRUE)? BST_CHECKED: - ((monitor == BS_FALSE)? BST_UNCHECKED: - BST_INDETERMINATE)); - - CheckDlgButton(hwnd, IDC_CFG_RENEW, - (auto_renew == BS_TRUE)? BST_CHECKED: - ((auto_renew == BS_FALSE)? BST_UNCHECKED: - BST_INDETERMINATE)); - - CheckDlgButton(hwnd, IDC_CFG_STICKY, - (sticky == BS_TRUE)? BST_CHECKED: - ((sticky == BS_FALSE)? BST_UNCHECKED: - BST_INDETERMINATE)); - - if (sel_count > 0) { - EnableWindow(GetDlgItem(hwnd, IDC_CFG_MONITOR), TRUE); - EnableWindow(GetDlgItem(hwnd, IDC_CFG_RENEW), TRUE); - EnableWindow(GetDlgItem(hwnd, IDC_CFG_STICKY), TRUE); - EnableWindow(GetDlgItem(hwnd, IDC_CFG_REMOVE), TRUE); - } else { - EnableWindow(GetDlgItem(hwnd, IDC_CFG_MONITOR), FALSE); - EnableWindow(GetDlgItem(hwnd, IDC_CFG_RENEW), FALSE); - EnableWindow(GetDlgItem(hwnd, IDC_CFG_STICKY), FALSE); - EnableWindow(GetDlgItem(hwnd, IDC_CFG_REMOVE), FALSE); - } -} - -#undef BS_TRUE -#undef BS_FALSE static void refresh_data_idents(HWND hwnd) { - HWND hw; - int sel_count; - int i; - int idx; - ident_data * d; - LVITEM lvi; - - UINT monitor = IsDlgButtonChecked(hwnd, IDC_CFG_MONITOR); - UINT auto_renew = IsDlgButtonChecked(hwnd, IDC_CFG_RENEW); - UINT sticky = IsDlgButtonChecked(hwnd, IDC_CFG_STICKY); - - hw = GetDlgItem(hwnd, IDC_CFG_IDENTS); - - sel_count = ListView_GetSelectedCount(hw); - - idx = -1; - for (i=0; i < sel_count; i++) { - idx = ListView_GetNextItem(hw, idx, LVNI_SELECTED); -#ifdef DEBUG - assert(idx != -1); -#endif - ZeroMemory(&lvi, sizeof(lvi)); - - lvi.iItem = idx; - lvi.iSubItem = 0; - lvi.mask = LVIF_PARAM; - - ListView_GetItem(hw, &lvi); - - d = (ident_data *) lvi.lParam; -#ifdef DEBUG - assert(d != NULL); -#endif - - if (monitor == BST_CHECKED) - d->work.monitor = TRUE; - else if (monitor == BST_UNCHECKED) - d->work.monitor = FALSE; - - if (auto_renew == BST_CHECKED) - d->work.auto_renew = TRUE; - else if (auto_renew == BST_UNCHECKED) - d->work.auto_renew = FALSE; - - if (sticky == BST_CHECKED) - d->work.sticky = TRUE; - else if (sticky == BST_UNCHECKED) - d->work.sticky = FALSE; - - if (d->hwnd) - PostMessage(d->hwnd, KHUI_WM_CFG_NOTIFY, - MAKEWPARAM(0, WMCFG_UPDATE_STATE), 0); - } + cfg_idents.work.monitor = + (IsDlgButtonChecked(hwnd, IDC_CFG_MONITOR) == BST_CHECKED); + cfg_idents.work.auto_renew = + (IsDlgButtonChecked(hwnd, IDC_CFG_RENEW) == BST_CHECKED); + cfg_idents.work.sticky = + (IsDlgButtonChecked(hwnd, IDC_CFG_STICKY) == BST_CHECKED); } static void refresh_view_idents_state(HWND hwnd) { - HWND hw; - int i; - LVITEM lvi; - ident_data * d; - - BOOL modified = FALSE; - BOOL applied = FALSE; - - hw = GetDlgItem(hwnd, IDC_CFG_IDENTS); - - for (i = -1;;) { - - i = ListView_GetNextItem(hw, i, LVNI_ALL); - if (i == -1) - break; - - ZeroMemory(&lvi, sizeof(lvi)); - lvi.iItem = i; - lvi.iSubItem = 0; - lvi.mask = LVIF_PARAM; - - ListView_GetItem(hw, &lvi); - - d = (ident_data *) lvi.lParam; -#ifdef DEBUG - assert(d != NULL); -#endif - - ZeroMemory(&lvi, sizeof(lvi)); - - lvi.mask = LVIF_STATE; - lvi.stateMask = LVIS_STATEIMAGEMASK; - lvi.iItem = i; - lvi.iSubItem = 0; - - if (d->removed) { - lvi.state = INDEXTOSTATEIMAGEMASK(cfg_idents.idx_deleted); - modified = TRUE; - } else if (d->saved.monitor != d->work.monitor || - d->saved.auto_renew != d->work.auto_renew || - d->saved.sticky != d->work.sticky) { - lvi.state = INDEXTOSTATEIMAGEMASK(cfg_idents.idx_modified); - modified = TRUE; - } else if (d->applied) { - lvi.state = INDEXTOSTATEIMAGEMASK(cfg_idents.idx_applied); - applied = TRUE; - } else { - lvi.state = INDEXTOSTATEIMAGEMASK(cfg_idents.idx_default); - } - - ListView_SetItem(hw, &lvi); - } - - { - khm_int32 flags = 0; - - if (modified) - flags |= KHUI_CNFLAG_MODIFIED; - if (applied) - flags |= KHUI_CNFLAG_APPLIED; - - khui_cfg_set_flags_inst(&cfg_idents.cfg, flags, - KHUI_CNFLAG_APPLIED | KHUI_CNFLAG_MODIFIED); - } -} - -static void -remove_idents(HWND hwnd) { - HWND hw; - int sel_count; - int i; - int idx; - ident_data * d; - LVITEM lvi; - - hw = GetDlgItem(hwnd, IDC_CFG_IDENTS); - - sel_count = ListView_GetSelectedCount(hw); - - idx = -1; - for (i=0; i < sel_count; i++) { - idx = ListView_GetNextItem(hw, idx, LVNI_SELECTED); -#ifdef DEBUG - assert(idx != -1); -#endif - ZeroMemory(&lvi, sizeof(lvi)); - - lvi.iItem = idx; - lvi.iSubItem = 0; - lvi.mask = LVIF_PARAM; + BOOL modified; + BOOL applied; + khm_int32 flags = 0; - ListView_GetItem(hw, &lvi); + applied = cfg_idents.applied; + modified = (cfg_idents.work.monitor != cfg_idents.saved.monitor || + cfg_idents.work.auto_renew != cfg_idents.saved.auto_renew || + cfg_idents.work.sticky != cfg_idents.saved.sticky); - d = (ident_data *) lvi.lParam; -#ifdef DEBUG - assert(d != NULL); -#endif + if (modified) + flags |= KHUI_CNFLAG_MODIFIED; + if (applied) + flags |= KHUI_CNFLAG_APPLIED; - d->removed = TRUE; - } + khui_cfg_set_flags_inst(&cfg_idents.cfg, flags, + KHUI_CNFLAG_APPLIED | KHUI_CNFLAG_MODIFIED); } INT_PTR CALLBACK @@ -840,37 +702,14 @@ khm_cfg_ids_tab_proc(HWND hwnd, switch(umsg) { case WM_INITDIALOG: { - HWND hw; HICON hicon; - LVCOLUMN lvcol; - LVITEM lvi; - wchar_t coltext[256]; - RECT r; - int i; hold_idents_data(); cfg_idents.hwnd = hwnd; cfg_idents.cfg = *((khui_config_init_data *) lParam); - /* first add the column */ - hw = GetDlgItem(hwnd, IDC_CFG_IDENTS); - - ZeroMemory(&lvcol, sizeof(lvcol)); - lvcol.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_FMT; - - lvcol.fmt = LVCFMT_IMAGE | LVCFMT_LEFT; - - GetWindowRect(hw, &r); - lvcol.cx = ((r.right - r.left) * 95) / 100; - - LoadString(khm_hInstance, IDS_CFG_IDS_IDENTITY, - coltext, ARRAYLENGTH(coltext)); - lvcol.pszText = coltext; - - ListView_InsertColumn(hw, 0, &lvcol); - - /* and the status icons */ + /* add the status icons */ if (cfg_idents.hi_status) goto _done_with_icons; @@ -927,56 +766,29 @@ khm_cfg_ids_tab_proc(HWND hwnd, DestroyIcon(hicon); - ListView_SetImageList(hw, cfg_idents.hi_status, LVSIL_SMALL); - ListView_SetImageList(hw, cfg_idents.hi_status, LVSIL_STATE); - _done_with_icons: - /* now add each identity */ - for(i=0; i < (int)cfg_idents.n_idents; i++) { - ZeroMemory(&lvi, sizeof(lvi)); - - lvi.mask = LVIF_PARAM | LVIF_TEXT | LVIF_STATE | LVIF_IMAGE; - lvi.iImage = cfg_idents.idx_id; - lvi.lParam = (LPARAM) &cfg_idents.idents[i]; - lvi.pszText = cfg_idents.idents[i].idname; - lvi.state = INDEXTOSTATEIMAGEMASK(cfg_idents.idx_default); - lvi.stateMask = LVIS_STATEIMAGEMASK; - - cfg_idents.idents[i].lv_idx = ListView_InsertItem(hw, &lvi); - } + CheckDlgButton(hwnd, IDC_CFG_MONITOR, + (cfg_idents.work.monitor)?BST_CHECKED:BST_UNCHECKED); + CheckDlgButton(hwnd, IDC_CFG_RENEW, + (cfg_idents.work.auto_renew)?BST_CHECKED:BST_UNCHECKED); + CheckDlgButton(hwnd, IDC_CFG_STICKY, + (cfg_idents.work.sticky)?BST_CHECKED:BST_UNCHECKED); } return FALSE; - case WM_NOTIFY: - { - LPNMHDR lpnm = (LPNMHDR) lParam; - - if (lpnm->code == LVN_ITEMCHANGED) { - refresh_view_idents_sel(hwnd); - } - } - return TRUE; - case WM_COMMAND: if (HIWORD(wParam) == BN_CLICKED) { UINT ctrl = LOWORD(wParam); + switch(ctrl) { case IDC_CFG_MONITOR: case IDC_CFG_RENEW: case IDC_CFG_STICKY: - if (IsDlgButtonChecked(hwnd, ctrl) == BST_CHECKED) - CheckDlgButton(hwnd, ctrl, BST_UNCHECKED); - else - CheckDlgButton(hwnd, ctrl, BST_CHECKED); refresh_data_idents(hwnd); break; - - case IDC_CFG_REMOVE: - remove_idents(hwnd); - break; } refresh_view_idents_state(hwnd); @@ -994,7 +806,6 @@ khm_cfg_ids_tab_proc(HWND hwnd, case WMCFG_UPDATE_STATE: refresh_view_idents_state(hwnd); - refresh_view_idents_sel(hwnd); break; } } @@ -1086,6 +897,26 @@ refresh_view_ident(HWND hwnd, khui_config_node node) { (d->work.sticky? BST_CHECKED: BST_UNCHECKED)); } +static void +mark_remove_ident(HWND hwnd, khui_config_init_data * idata) { + ident_data * d; + + d = find_ident_by_node(idata->ctx_node); +#ifdef DEBUG + assert(d); +#endif + + if (d->removed) + return; + + d->removed = TRUE; + + khui_cfg_set_flags_inst(idata, KHUI_CNFLAG_MODIFIED, + KHUI_CNFLAG_MODIFIED); + + EnableWindow(GetDlgItem(hwnd, IDC_CFG_REMOVE), FALSE); +} + static void refresh_data_ident(HWND hwnd, khui_config_init_data * idata) { ident_data * d; @@ -1168,8 +999,16 @@ khm_cfg_id_tab_proc(HWND hwnd, PostMessage(cfg_idents.hwnd, KHUI_WM_CFG_NOTIFY, MAKEWPARAM(1, WMCFG_UPDATE_STATE), 0); break; + + case IDC_CFG_REMOVE: + mark_remove_ident(hwnd, idata); + if (cfg_idents.hwnd) + PostMessage(cfg_idents.hwnd, KHUI_WM_CFG_NOTIFY, + MAKEWPARAM(1, WMCFG_UPDATE_STATE), 0); + break; } } + khm_set_dialog_result(hwnd, 0); return TRUE; diff --git a/src/windows/identity/ui/cfg_notif_wnd.c b/src/windows/identity/ui/cfg_notif_wnd.c index bca18012c..220865113 100644 --- a/src/windows/identity/ui/cfg_notif_wnd.c +++ b/src/windows/identity/ui/cfg_notif_wnd.c @@ -168,6 +168,8 @@ write_params(notif_data * d) { khui_cfg_set_flags(d->node, KHUI_CNFLAG_APPLIED, KHUI_CNFLAG_APPLIED | KHUI_CNFLAG_MODIFIED); + + khm_timer_refresh(hwnd_notifier); } static void diff --git a/src/windows/identity/ui/configwnd.c b/src/windows/identity/ui/configwnd.c index 970599e85..7441b54f8 100644 --- a/src/windows/identity/ui/configwnd.c +++ b/src/windows/identity/ui/configwnd.c @@ -535,6 +535,8 @@ cfgui_dlgproc(HWND hwnd, khui_cfg_clear_params(); + khui_cfg_set_configui_handle(hwnd); + d = PMALLOC(sizeof(*d)); ZeroMemory(d, sizeof(*d)); @@ -565,8 +567,6 @@ cfgui_dlgproc(HWND hwnd, khm_add_dialog(hwnd); khm_enter_modal(hwnd); - khui_cfg_set_configui_handle(hwnd); - return TRUE; case WM_DESTROY: diff --git a/src/windows/identity/ui/credfuncs.c b/src/windows/identity/ui/credfuncs.c index b88f3d14e..7e0756fb4 100644 --- a/src/windows/identity/ui/credfuncs.c +++ b/src/windows/identity/ui/credfuncs.c @@ -32,6 +32,7 @@ static CRITICAL_SECTION cs_dialog; static HANDLE in_dialog_evt = NULL; static LONG init_dialog = 0; static khm_int32 dialog_result = 0; +static wchar_t dialog_identity[KCDB_IDENT_MAXCCH_NAME]; static void dialog_sync_init(void) { @@ -76,7 +77,7 @@ khm_cred_begin_dialog(void) { } void -khm_cred_end_dialog(khm_int32 result) { +khm_cred_end_dialog(khui_new_creds * nc) { dialog_sync_init(); EnterCriticalSection(&cs_dialog); @@ -84,7 +85,20 @@ khm_cred_end_dialog(khm_int32 result) { in_dialog = FALSE; SetEvent(in_dialog_evt); } - dialog_result = result; + dialog_result = nc->result; + if (nc->subtype == KMSG_CRED_NEW_CREDS && + nc->n_identities > 0 && + nc->identities[0]) { + khm_size cb; + + cb = sizeof(dialog_identity); + if (KHM_FAILED(kcdb_identity_get_name(nc->identities[0], + dialog_identity, + &cb))) + dialog_identity[0] = 0; + } else { + dialog_identity[0] = 0; + } LeaveCriticalSection(&cs_dialog); } @@ -102,7 +116,8 @@ khm_cred_is_in_dialog(void) { } khm_int32 -khm_cred_wait_for_dialog(DWORD timeout, khm_int32 * result) { +khm_cred_wait_for_dialog(DWORD timeout, khm_int32 * result, + wchar_t * ident, khm_size cb_ident) { khm_int32 rv; dialog_sync_init(); @@ -122,8 +137,12 @@ khm_cred_wait_for_dialog(DWORD timeout, khm_int32 * result) { if (!in_dialog) { rv = KHM_ERROR_SUCCESS; - if (result) + if (result) { *result = dialog_result; + } + if (ident) { + StringCbCopy(ident, cb_ident, dialog_identity); + } break; } else if(dw == WAIT_TIMEOUT) { rv = KHM_ERROR_TIMEOUT; @@ -289,14 +308,14 @@ kmsg_cred_completion(kmq_message *m) khui_context_reset(); */ - khm_cred_end_dialog(nc->result); + khm_cred_end_dialog(nc); } khui_cw_destroy_cred_blob(nc); kmq_post_message(KMSG_CRED, KMSG_CRED_REFRESH, 0, 0); - khm_cred_process_commandline(); + kmq_post_message(KMSG_ACT, KMSG_ACT_CONTINUE_CMDLINE, 0, 0); } break; @@ -323,11 +342,11 @@ kmsg_cred_completion(kmq_message *m) kmq_post_message(KMSG_CRED, KMSG_CRED_REFRESH, 0, 0); - khm_cred_process_commandline(); + kmq_post_message(KMSG_ACT, KMSG_ACT_CONTINUE_CMDLINE, 0, 0); break; case KMSG_CRED_IMPORT: - khm_cred_process_commandline(); + kmq_post_message(KMSG_ACT, KMSG_ACT_CONTINUE_CMDLINE, 0, 0); break; case KMSG_CRED_REFRESH: @@ -573,8 +592,9 @@ void khm_cred_obtain_new_creds(wchar_t * title) khui_alert_release(a); khui_context_release(&nc->ctx); + nc->result = KHUI_NC_RESULT_CANCEL; + khm_cred_end_dialog(nc); khui_cw_destroy_cred_blob(nc); - khm_cred_end_dialog(KHUI_NC_RESULT_CANCEL); return; } @@ -617,8 +637,9 @@ void khm_cred_obtain_new_creds(wchar_t * title) _end_task(); } else { khui_context_release(&nc->ctx); + nc->result = KHUI_NC_RESULT_CANCEL; + khm_cred_end_dialog(nc); khui_cw_destroy_cred_blob(nc); - khm_cred_end_dialog(KHUI_NC_RESULT_CANCEL); } } @@ -784,7 +805,8 @@ khm_cred_process_commandline(void) { if (khm_startup.init || khm_startup.renew || - khm_startup.destroy) { + khm_startup.destroy || + khm_startup.autoinit) { kcdb_identity_get_default(&defident); } @@ -846,6 +868,15 @@ khm_cred_process_commandline(void) { kcdb_credset_get_size(NULL, &count); if (count == 0) { + if (defident) + khui_context_set(KHUI_SCOPE_IDENT, + defident, + KCDB_CREDTYPE_INVALID, + NULL, NULL, 0, + NULL); + else + khui_context_reset(); + khm_cred_obtain_new_creds(NULL); } khm_startup.autoinit = FALSE; @@ -869,9 +900,27 @@ khm_cred_process_commandline(void) { void khm_cred_begin_commandline(void) { + khm_handle csp_cw; + if (khm_startup.seen) return; + if (KHM_SUCCEEDED(khc_open_space(NULL, L"CredWindow", 0, &csp_cw))) { + khm_int32 t = 0; + + khc_read_int32(csp_cw, L"Autoinit", &t); + if (t) + khm_startup.autoinit = TRUE; + + t = 0; + khc_read_int32(csp_cw, L"AutoImport", &t); + if (t) + khm_startup.import = TRUE; + + khc_close_space(csp_cw); + + } + khm_startup.seen = TRUE; khm_startup.processing = TRUE; @@ -893,9 +942,9 @@ khm_cred_addr_change(void) { khm_size cb; khm_size n_idents; - __int64 ft_now; - __int64 ft_exp; - __int64 ft_issue; + FILETIME ft_now; + FILETIME ft_exp; + FILETIME ft_issue; if (KHM_SUCCEEDED(khc_open_space(NULL, L"CredWindow", 0, &csp_cw))) { @@ -937,7 +986,7 @@ khm_cred_addr_change(void) { if (!ids) return; - GetSystemTimeAsFileTime((LPFILETIME) &ft_now); + GetSystemTimeAsFileTime(&ft_now); for (t=ids; t && *t; t = multi_string_next(t)) { khm_handle ident; @@ -958,11 +1007,21 @@ khm_cred_addr_change(void) { (kcdb_identity_get_attr(ident, KCDB_ATTR_EXPIRE, NULL, &ft_exp, &cb)) && - ft_now > (ft_issue + ft_exp)/2 && - ft_now < ft_exp) { + CompareFileTime(&ft_now, &ft_exp) < 0) { - khm_cred_renew_identity(ident); + khm_int64 i_issue; + khm_int64 i_exp; + khm_int64 i_now; + i_issue = FtToInt(&ft_issue); + i_exp = FtToInt(&ft_exp); + i_now = FtToInt(&ft_now); + + if (i_now > (i_issue + i_exp) / 2) { + + khm_cred_renew_identity(ident); + + } } kcdb_identity_release(ident); diff --git a/src/windows/identity/ui/credfuncs.h b/src/windows/identity/ui/credfuncs.h index 633783098..b9be3d487 100644 --- a/src/windows/identity/ui/credfuncs.h +++ b/src/windows/identity/ui/credfuncs.h @@ -61,7 +61,8 @@ BOOL khm_cred_is_in_dialog(void); khm_int32 -khm_cred_wait_for_dialog(DWORD timeout, khm_int32 * result); +khm_cred_wait_for_dialog(DWORD timeout, khm_int32 * result, + wchar_t * ident, khm_size cb_ident); void khm_cred_begin_commandline(void); @@ -75,4 +76,7 @@ khm_cred_refresh(void); void khm_cred_addr_change(void); +void +khm_cred_import(void); + #endif diff --git a/src/windows/identity/ui/credwnd.c b/src/windows/identity/ui/credwnd.c index be7610497..5211d50b1 100644 --- a/src/windows/identity/ui/credwnd.c +++ b/src/windows/identity/ui/credwnd.c @@ -268,6 +268,7 @@ _skip_col: ADD_BITMAP(IDB_FLAG_WARN); ADD_BITMAP(IDB_FLAG_EXPIRED); ADD_BITMAP(IDB_FLAG_CRITICAL); + ADD_BITMAP(IDB_FLAG_RENEW); ADD_BITMAP(IDB_WDG_STUCK); ADD_BITMAP(IDB_WDG_STUCK_HI); ADD_BITMAP(IDB_WDG_STICK); @@ -458,7 +459,7 @@ cw_get_cred_exp_flags(khui_credwnd_tbl * tbl, khm_handle cred) if(KHM_FAILED(kcdb_cred_get_attr(cred, KCDB_ATTR_TIMELEFT, NULL, &ft, &cbsize))) return 0; - s = FtIntervalToMilliseconds(&ft) / 1000; + s = FtIntervalToSeconds(&ft); flags = 0; if(s < 0) @@ -622,6 +623,7 @@ cw_update_outline(khui_credwnd_tbl * tbl) khm_size cbbuf; khm_int32 flags; int selected; + khm_int32 expstate = 0; /* this is called after calling cw_update_creds, so we assume that the credentials are all loaded and sorted according to @@ -883,6 +885,7 @@ cw_update_outline(khui_credwnd_tbl * tbl) visible = visible && (ol->flags & KHUI_CW_O_EXPAND); flags = cw_get_cred_exp_flags(tbl, thiscred); + expstate |= flags; if(visible) { khm_int32 c_flags; @@ -1040,6 +1043,16 @@ cw_update_outline(khui_credwnd_tbl * tbl) _exit: if(grouping) PFREE(grouping); + + if (tbl->n_rows == 0) + khm_notify_icon_expstate(KHM_NOTIF_EMPTY); + else if (expstate & CW_EXPSTATE_EXPIRED) + khm_notify_icon_expstate(KHM_NOTIF_EXP); + else if ((expstate & CW_EXPSTATE_WARN) || + (expstate & CW_EXPSTATE_CRITICAL)) + khm_notify_icon_expstate(KHM_NOTIF_WARN); + else + khm_notify_icon_expstate(KHM_NOTIF_OK); } void @@ -1125,10 +1138,12 @@ cw_hditem_from_tbl_col(khui_credwnd_col * col, HDITEM *phi) } phi->lParam = col->attr_id; #if (_WIN32_WINNT >= 0x501) - if(col->flags & KHUI_CW_COL_SORT_INC) { - phi->fmt |= HDF_SORTUP; - } else if(col->flags & KHUI_CW_COL_SORT_DEC) { - phi->fmt |= HDF_SORTDOWN; + if (IS_COMMCTL6()) { + if(col->flags & KHUI_CW_COL_SORT_INC) { + phi->fmt |= HDF_SORTUP; + } else if(col->flags & KHUI_CW_COL_SORT_DEC) { + phi->fmt |= HDF_SORTDOWN; + } } #endif if(col->width < 0) { @@ -1365,7 +1380,7 @@ cw_draw_header(HDC hdc, int selected = 0; khm_int32 idf = 0; - /* each header consists of a 'expose' widget and some text */ + /* each header consists of a couple of widgets and some text */ /* we need to figure out the background color first */ cr = &(tbl->rows[row]); @@ -1455,7 +1470,7 @@ cw_draw_header(HDC hdc, hdc, r->left, r->bottom - KHUI_SMICON_CY, 0); - r->left += KHUI_SMICON_CX ; + r->left += KHUI_SMICON_CX * 3 / 2 ; } /* ok, now o->header contains the string representation of the @@ -1576,7 +1591,7 @@ cw_wm_create(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) WS_CHILD | HDS_BUTTONS | HDS_FULLDRAG | HDS_HORZ | HDS_HOTTRACK #if (_WIN32_WINNT >= 0x501) - | HDS_FLAT + | ((IS_COMMCTL6())?HDS_FLAT:0) #endif , 0,0,0,0,hwnd, (HMENU) 0, khm_hInstance, NULL); @@ -1760,14 +1775,17 @@ cw_wm_paint(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) if(j > tbl->rows[i].col) { cbbuf = sizeof(buf); - if(KHM_FAILED(kcdb_cred_get_attr_string((khm_handle) tbl->rows[i].data, tbl->cols[j].attr_id, buf, &cbbuf, KCDB_TS_SHORT))) + if(KHM_FAILED(kcdb_cred_get_attr_string((khm_handle) tbl->rows[i].data, + tbl->cols[j].attr_id, buf, + &cbbuf, KCDB_TS_SHORT))) continue; rh.left += tbl->hpad; rh.right -= tbl->hpad; SetTextAlign(hdc, 0); - DrawText(hdc, buf, (int)((cbbuf / sizeof(wchar_t)) - 1), &rh, DT_LEFT | DT_VCENTER | DT_NOCLIP | DT_SINGLELINE | DT_END_ELLIPSIS); + DrawText(hdc, buf, (int)((cbbuf / sizeof(wchar_t)) - 1), &rh, + DT_LEFT | DT_VCENTER | DT_NOCLIP | DT_SINGLELINE | DT_END_ELLIPSIS); //TextOut(hdc, x, y + tbl->vpad, buf, (cbbuf / sizeof(wchar_t)) - 1); } } @@ -1784,9 +1802,9 @@ cw_wm_paint(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) flag = o->flags; else flag = 0; - } - else + } else { flag = tbl->rows[i].flags; + } flag &= CW_EXPSTATE_MASK; @@ -1802,7 +1820,7 @@ cw_wm_paint(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) if (KHM_SUCCEEDED(kcdb_cred_get_flags((khm_handle) tbl->rows[i].data, &flags)) && (flags & KCDB_CRED_FLAG_RENEWABLE)) { khui_ilist_draw_id(tbl->ilist, - IDB_TK_REFRESH_SM, + IDB_FLAG_RENEW, hdc, x, y, 0); } @@ -2415,6 +2433,12 @@ cw_wm_mouse(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) x >= KHUI_SMICON_CX * 3 / 2 && x < KHUI_SMICON_CX * 5 / 2){ nm_state |= CW_MOUSE_WSTICKY | CW_MOUSE_WIDGET; + } else if (tbl->cols[tbl->rows[row].col].attr_id == + KCDB_ATTR_ID_NAME && + col == tbl->rows[row].col && + x >= KHUI_SMICON_CX * 3 && + x < KHUI_SMICON_CX * 4) { + nm_state |= CW_MOUSE_WICON | CW_MOUSE_WIDGET; } } } @@ -2422,7 +2446,7 @@ cw_wm_mouse(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) /* did the user drag the cursor off the current row? */ if((tbl->mouse_state & CW_MOUSE_LDOWN) && (nm_row != tbl->mouse_row)) { - nm_state &= ~(CW_MOUSE_WIDGET | CW_MOUSE_WOUTLINE | CW_MOUSE_WSTICKY); + nm_state &= ~CW_MOUSE_WMASK; } if(!(nm_state & CW_MOUSE_LDOWN) && @@ -2458,6 +2482,11 @@ cw_wm_mouse(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) tbl->mouse_state = CW_MOUSE_WIDGET | CW_MOUSE_WSTICKY; return 0; + } else if ((nm_state & CW_MOUSE_WICON) && + (tbl->mouse_state & CW_MOUSE_WICON)) { + /* click on an row icon */ + cw_select_row(tbl, nm_row, wParam); + cw_properties(hwnd); } else { /* click on a row */ cw_select_row(tbl, nm_row, wParam); @@ -2644,61 +2673,17 @@ cw_wm_hscroll(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return DefWindowProc(hwnd, uMsg, wParam, lParam); } -LRESULT -cw_wm_vscroll(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - khui_credwnd_tbl * tbl; - SCROLLINFO si; +static void +cw_vscroll_to_pos(HWND hwnd, khui_credwnd_tbl * tbl, int newpos) { RECT cr; RECT sr; RECT lr; int dy; - int newpos; - tbl = (khui_credwnd_tbl *)(LONG_PTR) GetWindowLongPtr(hwnd, 0); GetClientRect(hwnd, &cr); cr.top += tbl->header_height; dy = tbl->scr_top; - switch(LOWORD(wParam)) { - case SB_LEFT: - newpos = 0; - break; - - case SB_BOTTOM: - newpos = tbl->ext_height; - break; - - case SB_LINEUP: - newpos = tbl->scr_top - (tbl->ext_height / 12); - break; - - case SB_LINEDOWN: - newpos = tbl->scr_top + (tbl->ext_height / 12); - break; - - case SB_PAGEUP: - newpos = tbl->scr_top - (cr.bottom - cr.top); - break; - - case SB_PAGEDOWN: - newpos = tbl->scr_top + (cr.bottom - cr.top); - break; - - case SB_THUMBTRACK: - case SB_THUMBPOSITION: - ZeroMemory(&si, sizeof(si)); - si.cbSize = sizeof(si); - si.fMask = SIF_TRACKPOS; - GetScrollInfo(hwnd, SB_VERT, &si); - - newpos = si.nTrackPos; - break; - - default: - return DefWindowProc(hwnd, uMsg, wParam, lParam); - } - tbl->scr_top = newpos; cw_update_extents(tbl, TRUE); @@ -2745,10 +2730,89 @@ cw_wm_vscroll(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) if(lr.top < lr.bottom && lr.left < lr.right) { InvalidateRect(hwnd, &lr, FALSE); } +} + +LRESULT +cw_wm_vscroll(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + khui_credwnd_tbl * tbl; + SCROLLINFO si; + int newpos; + RECT cr; + + tbl = (khui_credwnd_tbl *)(LONG_PTR) GetWindowLongPtr(hwnd, 0); + + GetClientRect(hwnd, &cr); + cr.top += tbl->header_height; + + switch(LOWORD(wParam)) { + case SB_LEFT: + newpos = 0; + break; + + case SB_BOTTOM: + newpos = tbl->ext_height; + break; + + case SB_LINEUP: + newpos = tbl->scr_top - (tbl->ext_height / 12); + break; + + case SB_LINEDOWN: + newpos = tbl->scr_top + (tbl->ext_height / 12); + break; + + case SB_PAGEUP: + newpos = tbl->scr_top - (cr.bottom - cr.top); + break; + + case SB_PAGEDOWN: + newpos = tbl->scr_top + (cr.bottom - cr.top); + break; + + case SB_THUMBTRACK: + case SB_THUMBPOSITION: + ZeroMemory(&si, sizeof(si)); + si.cbSize = sizeof(si); + si.fMask = SIF_TRACKPOS; + GetScrollInfo(hwnd, SB_VERT, &si); + + newpos = si.nTrackPos; + break; + + default: + return DefWindowProc(hwnd, uMsg, wParam, lParam); + } + + cw_vscroll_to_pos(hwnd, tbl, newpos); return DefWindowProc(hwnd, uMsg, wParam, lParam); } +static void +cw_ensure_row_visible(HWND hwnd, khui_credwnd_tbl * tbl, int row) { + RECT r; + int newpos; + + if (row < 0) + row = 0; + else if (row >= (int) tbl->n_rows) + row = (int) tbl->n_rows - 1; + + GetClientRect(hwnd, &r); + r.top += tbl->header_height; + + if (row * tbl->cell_height < tbl->scr_top) { + newpos = row * tbl->cell_height; + } else if ((row + 1) * tbl->cell_height + > tbl->scr_top + (r.bottom - r.top)) { + newpos = ((row + 1) * tbl->cell_height) - (r.bottom - r.top); + } else + return; + + cw_vscroll_to_pos(hwnd, tbl, newpos); +} + static INT_PTR CALLBACK cw_pp_ident_proc(HWND hwnd, UINT uMsg, @@ -2819,7 +2883,10 @@ cw_pp_ident_proc(HWND hwnd, case MAKEWPARAM(IDC_PP_CONFIG, BN_CLICKED): { + khui_config_node cfg_id = NULL; khui_config_node cfg_ids = NULL; + wchar_t idname[KCDB_IDENT_MAXCCH_NAME]; + khm_size cb; khm_int32 rv; khm_refresh_config(); @@ -2831,10 +2898,24 @@ cw_pp_ident_proc(HWND hwnd, if (KHM_FAILED(rv)) return TRUE; - khm_show_config_pane(cfg_ids); + cb = sizeof(idname); + if (KHM_SUCCEEDED(kcdb_identity_get_name(s->identity, + idname, + &cb))) { + rv = khui_cfg_open(cfg_ids, + idname, + &cfg_id); + } + + if (cfg_id) + khm_show_config_pane(cfg_id); + else + khm_show_config_pane(cfg_ids); if (cfg_ids) khui_cfg_release(cfg_ids); + if (cfg_id) + khui_cfg_release(cfg_id); } return TRUE; } @@ -3201,6 +3282,7 @@ cw_wm_command(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) InvalidateRect(tbl->hwnd, NULL, TRUE); khui_check_radio_action(khui_find_menu(KHUI_MENU_LAYOUT), KHUI_ACTION_LAYOUT_ID); + kmq_post_message(KMSG_ACT, KMSG_ACT_REFRESH, 0, 0); } break; @@ -3219,6 +3301,7 @@ cw_wm_command(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) khui_check_radio_action(khui_find_menu(KHUI_MENU_LAYOUT), KHUI_ACTION_LAYOUT_LOC); + kmq_post_message(KMSG_ACT, KMSG_ACT_REFRESH, 0, 0); } break; @@ -3236,7 +3319,7 @@ cw_wm_command(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) if(new_row < 0) new_row = 0; if(new_row >= (int) tbl->n_rows) - new_row = (int) tbl->n_rows; + new_row = (int) tbl->n_rows - 1; if (LOWORD(wParam) == KHUI_PACTION_UP) wp = 0; @@ -3250,6 +3333,7 @@ cw_wm_command(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) #endif cw_select_row(tbl, new_row, wp); + cw_ensure_row_visible(hwnd, tbl, new_row); } break; @@ -3267,7 +3351,7 @@ cw_wm_command(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) if(new_row < 0) new_row = 0; if(new_row >= (int) tbl->n_rows) - new_row = (int) tbl->n_rows; + new_row = (int) tbl->n_rows - 1; if (LOWORD(wParam) == KHUI_PACTION_DOWN) wp = 0; @@ -3280,6 +3364,7 @@ cw_wm_command(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) assert(FALSE); #endif cw_select_row(tbl, new_row, wp); + cw_ensure_row_visible(hwnd, tbl, new_row); } break; diff --git a/src/windows/identity/ui/credwnd.h b/src/windows/identity/ui/credwnd.h index 5d1137f84..33e00bacb 100644 --- a/src/windows/identity/ui/credwnd.h +++ b/src/windows/identity/ui/credwnd.h @@ -216,6 +216,11 @@ typedef struct khui_credwnd_tbl_t { outline widget */ #define CW_MOUSE_WSTICKY 0x00000010 /* mouse is highlighting a sticky widget */ +#define CW_MOUSE_WICON 0x00000020 /* an icon widget. represents + the icon next to identities + and next to credentials. */ + +#define CW_MOUSE_WMASK 0x00000039 /* all widget bits */ void khm_unregister_credwnd_class(void); diff --git a/src/windows/identity/ui/images/app_notify_error.ico b/src/windows/identity/ui/images/app_notify_error.ico index b17c045c7..9fb30c53e 100644 Binary files a/src/windows/identity/ui/images/app_notify_error.ico and b/src/windows/identity/ui/images/app_notify_error.ico differ diff --git a/src/windows/identity/ui/images/app_state_exp.ico b/src/windows/identity/ui/images/app_state_exp.ico new file mode 100644 index 000000000..b365b6bf3 Binary files /dev/null and b/src/windows/identity/ui/images/app_state_exp.ico differ diff --git a/src/windows/identity/ui/images/app_state_ok.ico b/src/windows/identity/ui/images/app_state_ok.ico new file mode 100644 index 000000000..8363fb2c5 Binary files /dev/null and b/src/windows/identity/ui/images/app_state_ok.ico differ diff --git a/src/windows/identity/ui/images/app_state_warn.ico b/src/windows/identity/ui/images/app_state_warn.ico new file mode 100644 index 000000000..3510e5a5c Binary files /dev/null and b/src/windows/identity/ui/images/app_state_warn.ico differ diff --git a/src/windows/identity/ui/images/flag-critical.bmp b/src/windows/identity/ui/images/flag-critical.bmp index 0b4c920e6..d643fb317 100644 Binary files a/src/windows/identity/ui/images/flag-critical.bmp and b/src/windows/identity/ui/images/flag-critical.bmp differ diff --git a/src/windows/identity/ui/images/flag-warning.bmp b/src/windows/identity/ui/images/flag-warning.bmp index f5be298a8..edb3fc3c8 100644 Binary files a/src/windows/identity/ui/images/flag-warning.bmp and b/src/windows/identity/ui/images/flag-warning.bmp differ diff --git a/src/windows/identity/ui/images/flag_expired.bmp b/src/windows/identity/ui/images/flag_expired.bmp index 2815fb448..a3a40feec 100644 Binary files a/src/windows/identity/ui/images/flag_expired.bmp and b/src/windows/identity/ui/images/flag_expired.bmp differ diff --git a/src/windows/identity/ui/images/flag_renewable.bmp b/src/windows/identity/ui/images/flag_renewable.bmp new file mode 100644 index 000000000..3a9dc386f Binary files /dev/null and b/src/windows/identity/ui/images/flag_renewable.bmp differ diff --git a/src/windows/identity/ui/lang/en_us/khapp.rc b/src/windows/identity/ui/lang/en_us/khapp.rc index eb2d4a9bb..b139effdb 100644 --- a/src/windows/identity/ui/lang/en_us/khapp.rc +++ b/src/windows/identity/ui/lang/en_us/khapp.rc @@ -65,6 +65,9 @@ IDI_CFG_MODIFIED ICON "..\\..\\images\\cfg_mod.ico" IDI_CFG_APPLIED ICON "..\\..\\images\\cfg_applied.ico" IDI_CFG_DELETED ICON "..\\..\\images\\cfg_deleted.ico" IDI_ID ICON "..\\..\\images\\id.ico" +IDI_APPICON_WARN ICON "..\\..\\images\\app_state_warn.ico" +IDI_APPICON_EXP ICON "..\\..\\images\\app_state_exp.ico" +IDI_APPICON_OK ICON "..\\..\\images\\app_state_ok.ico" ///////////////////////////////////////////////////////////////////////////// // @@ -132,6 +135,7 @@ IDB_WDG_STUCK_HI BITMAP "..\\..\\images\\wdg_stuck_hi.bm IDB_WDG_STICK BITMAP "..\\..\\images\\wdg_stick.bmp" IDB_WDG_STICK_HI BITMAP "..\\..\\images\\wdg_stick_hi.bmp" IDB_WDG_STUCK BITMAP "..\\..\\images\\wdg_stuck.bmp" +IDB_FLAG_RENEW BITMAP "..\\..\\images\\flag_renewable.bmp" ///////////////////////////////////////////////////////////////////////////// // @@ -264,21 +268,21 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN GROUPBOX "Startup",IDC_CFG_STARTUP_GROUP,7,7,241,50 - CONTROL "&Prompt for new credentials if there aren't any at startup", + CONTROL "&Obtain new credentials at startup (if none are present)", IDC_CFG_AUTOINIT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, 16,22,196,10 - CONTROL "&Start NetIDMgr when Windows starts",IDC_CFG_AUTOSTART, + CONTROL "&Start NetIDMgr during Windows logon",IDC_CFG_AUTOSTART, "Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,16, 38,135,10 - GROUPBOX "Other",IDC_CFG_OTHER,7,63,241,70 - CONTROL "&Keep NetIDMgr running after closing window", + GROUPBOX "Other",IDC_CFG_OTHER,7,63,241,54 + CONTROL "&Run NetIDMgr in system tray after window close", IDC_CFG_KEEPRUNNING,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,16,78,158,10 - CONTROL "Detect network connectivity",IDC_CFG_NETDETECT,"Button", + WS_TABSTOP,16,78,170,10 + CONTROL "Monitor network connectivity",IDC_CFG_NETDETECT,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,16,96,106,10 - CONTROL "A&utomatically import credentials from Windows", - IDC_CFG_AUTOIMPORT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP, - 16,113,165,10 + CONTROL "A&utomatically import Windows logon identity", + IDC_CFG_AUTOIMPORT,"Button",BS_AUTOCHECKBOX | NOT + WS_VISIBLE | WS_TABSTOP,16,147,165,10 END IDD_CFG_IDENTITIES DIALOGEX 0, 0, 255, 182 @@ -296,17 +300,18 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - CONTROL "&Monitor credentials expiration",IDC_NOTIF_MONITOR, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,7,139,10 - CONTROL "&Renew automatically",IDC_NOTIF_RENEW,"Button", - BS_AUTOCHECKBOX | WS_TABSTOP,22,32,82,10 - EDITTEXT IDC_NOTIF_RENEW_THR,122,30,126,14,ES_AUTOHSCROLL - CONTROL "Warn",IDC_NOTIF_WARN1,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,22,57,33,10 - EDITTEXT IDC_NOTIF_WARN1_THR,122,55,126,14,ES_AUTOHSCROLL - CONTROL "Warn again",IDC_NOTIF_WARN2,"Button",BS_AUTOCHECKBOX | - WS_TABSTOP,22,82,67,10 - EDITTEXT IDC_NOTIF_WARN2_THR,122,80,126,14,ES_AUTOHSCROLL + CONTROL "&Monitor credential expiration",IDC_NOTIF_MONITOR, + "Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,7, + 111,139,10 + CONTROL "&Renew automatically at",IDC_NOTIF_RENEW,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,9,100,10 + EDITTEXT IDC_NOTIF_RENEW_THR,122,7,126,14,ES_AUTOHSCROLL + CONTROL "Initial warning at",IDC_NOTIF_WARN1,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,31,100,10 + EDITTEXT IDC_NOTIF_WARN1_THR,122,29,126,14,ES_AUTOHSCROLL + CONTROL "Final warning at",IDC_NOTIF_WARN2,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,53,100,10 + EDITTEXT IDC_NOTIF_WARN2_THR,122,51,126,14,ES_AUTOHSCROLL END IDD_CFG_PLUGINS DIALOGEX 0, 0, 255, 182 @@ -351,31 +356,29 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - CONTROL "",IDC_CFG_IDENTS,"SysListView32",LVS_REPORT | - LVS_SHAREIMAGELISTS | LVS_ALIGNLEFT | WS_BORDER | - WS_TABSTOP,7,7,221,72 - GROUPBOX "Selected identity",IDC_CFG_IDENTITY,7,81,221,63 CONTROL "Monitor credential expiration",IDC_CFG_MONITOR,"Button", - BS_3STATE | WS_DISABLED | WS_TABSTOP,13,92,107,10 - CONTROL "Automatically renew",IDC_CFG_RENEW,"Button",BS_3STATE | - WS_DISABLED | WS_TABSTOP,13,106,81,10 - CONTROL "Always show in the credentials list (Sticky)", - IDC_CFG_STICKY,"Button",BS_3STATE | WS_DISABLED | - WS_TABSTOP,13,120,151,10 - PUSHBUTTON "&Remove",IDC_CFG_REMOVE,174,126,50,14,WS_DISABLED + BS_AUTOCHECKBOX | WS_TABSTOP,7,7,107,10 + CONTROL "Automatically renew",IDC_CFG_RENEW,"Button", + BS_AUTOCHECKBOX | WS_TABSTOP,7,20,81,10 + CONTROL "Always show in the credentials list (Pinned)", + IDC_CFG_STICKY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7, + 34,151,10 END IDD_CFG_ID_TAB DIALOGEX 0, 0, 235, 151 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU +EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - CONTROL "Always show in the credentials list (Sticky)", + CONTROL "Always show in the credentials list (Pinned)", IDC_CFG_STICKY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7, 34,151,10 CONTROL "Monitor credential expiration",IDC_CFG_MONITOR,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,7,7,107,10 CONTROL "Automatically renew",IDC_CFG_RENEW,"Button", BS_AUTOCHECKBOX | WS_TABSTOP,7,20,81,10 + PUSHBUTTON "Remove identity ...",IDC_CFG_REMOVE,139,122,78,14,NOT + WS_VISIBLE END IDD_ABOUT DIALOGEX 0, 0, 268, 170 @@ -544,10 +547,10 @@ BEGIN IDS_MENU_HELP "&Help" IDS_ACTION_PROPERTIES "&Properties ..." IDS_ACTION_EXIT "E&xit" - IDS_CFG_ROOT_NAME "NetIDMgr" + IDS_CFG_ROOT_NAME "Network Identity Manager" IDS_ACTION_SET_DEF_ID "Set as &default" IDS_ACTION_SET_SRCH_ID "Allow applications to &search" - IDS_CFG_ROOT_TITLE "NetIDMgr Configuration" + IDS_CFG_ROOT_TITLE "Network Identity Manager Configuration" IDS_CFG_GENERAL_SHORT "General" IDS_ACTION_NEW_CRED "&New credentials ..." IDS_ACTION_PASSWD_ID "Change &password ..." @@ -571,7 +574,7 @@ BEGIN IDS_ACTION_HELP_CONTENTS "Contents ..." IDS_ACTION_HELP_INDEX "Index ..." IDS_ACTION_HELP_ABOUT "About NetIDMgr ..." - IDS_CFG_GENERAL_LONG "General options for NetIDMgr" + IDS_CFG_GENERAL_LONG "General options" IDS_SAMPLE_STRING "Wxy" IDS_NO_CREDS "
    You currently have no credentials.Click here to obtain new credentials.
    " IDS_WT_INIT_CREDS "Obtain initial credentials" @@ -625,7 +628,7 @@ BEGIN IDS_ACTION_CLOSE_APP "Close NetIDMgr window" IDS_NC_FAILED_TITLE "Failed to acquire credentials" IDS_CFG_IDENTITIES_SHORT "Identities" - IDS_CFG_IDENTITIES_LONG "Options for all identities" + IDS_CFG_IDENTITIES_LONG "Global Identity settings" IDS_CFG_NOTIF_SHORT "Notifications" IDS_CFG_NOTIF_LONG "Notifications" IDS_CFG_PLUGINS_SHORT "Plugins" @@ -685,6 +688,11 @@ BEGIN "This is quite possibly caused by the identity provider module failing to load properly." IDS_NC_REN_FAILED_TITLE "Failed to renew credentials" IDS_CW_DEFAULT "(Default)" + IDS_ACTION_OPT_PLUGINS "Plugins ..." + IDS_NC_SETDEF "&Set as default identity" + IDS_NC_ID_DEF "

    This identity is the default

    " + IDS_NC_ID_WDEF "

    Will be the default. (Don't make default)

    " + IDS_NC_ID_NDEF "

    Not default identity. (make default)

    " END #endif // English (U.S.) resources diff --git a/src/windows/identity/ui/main.c b/src/windows/identity/ui/main.c index 93055d97f..6f7f9bd47 100644 --- a/src/windows/identity/ui/main.c +++ b/src/windows/identity/ui/main.c @@ -376,7 +376,11 @@ khm_module_load_ctx_handler(enum kherr_ctx_event evt, static wchar_t helpfile[MAX_PATH] = L""; -HWND khm_html_help(HWND hwnd, UINT command, DWORD_PTR data) { +HWND khm_html_help(HWND hwnd, wchar_t * suffix, + UINT command, DWORD_PTR data) { + + wchar_t gpath[MAX_PATH + MAX_PATH]; + if (!*helpfile) { DWORD dw; wchar_t ppath[MAX_PATH]; @@ -392,7 +396,12 @@ HWND khm_html_help(HWND hwnd, UINT command, DWORD_PTR data) { } } - return HtmlHelp(hwnd, helpfile, command, data); + StringCbCopy(gpath, sizeof(gpath), helpfile); + + if (suffix) + StringCbCat(gpath, sizeof(gpath), suffix); + + return HtmlHelp(hwnd, gpath, command, data); } void khm_load_default_modules(void) { diff --git a/src/windows/identity/ui/mainmenu.c b/src/windows/identity/ui/mainmenu.c index c7bf94da1..10270f2a0 100644 --- a/src/windows/identity/ui/mainmenu.c +++ b/src/windows/identity/ui/mainmenu.c @@ -129,7 +129,7 @@ void add_action_to_menu(HMENU hm, khui_action * act, def = khui_find_menu(act->cmd); if(def) { mii.fMask |= MIIM_SUBMENU; - mii.hSubMenu = mm_create_menu_from_def(def); + mii.hSubMenu = mm_create_menu_from_def(def, FALSE); } if(flags & KHUI_ACTIONREF_DEFAULT) @@ -139,12 +139,76 @@ void add_action_to_menu(HMENU hm, khui_action * act, InsertMenuItem(hm,idx,TRUE,&mii); } -static HMENU mm_create_menu_from_def(khui_menu_def * def) { +static void refresh_menu(HMENU hm, khui_menu_def * def); + +static void refresh_menu_item(HMENU hm, khui_action * act, + int idx, int flags) { + MENUITEMINFO mii; + + mii.cbSize = sizeof(mii); + mii.fMask = 0; + + if (act == NULL) + return; + else { + khui_menu_def * def; + + if(act->state & KHUI_ACTIONSTATE_DISABLED) { + mii.fMask |= MIIM_STATE; + mii.fState = MFS_DISABLED; + } else { + mii.fMask |= MIIM_STATE; + mii.fState = MFS_ENABLED; + } + + if(act->type & KHUI_ACTIONTYPE_TOGGLE) { + mii.fMask |= MIIM_STATE; + if (act->state & KHUI_ACTIONSTATE_CHECKED) { + mii.fState |= MFS_CHECKED; + } else { + mii.fState |= MFS_UNCHECKED; + } + } + + SetMenuItemInfo(hm, act->cmd, FALSE, &mii); + + def = khui_find_menu(act->cmd); + if(def) { + MENUITEMINFO mii2; + + mii2.cbSize = sizeof(mii2); + mii2.fMask = MIIM_SUBMENU; + + if (GetMenuItemInfo(hm, act->cmd, FALSE, &mii2)) { + refresh_menu(mii2.hSubMenu, def); + } + } + } +} + +static void refresh_menu(HMENU hm, khui_menu_def * def) { + khui_action_ref * act; + int i; + + act = def->items; + i = 0; + while ((def->n_items == -1 && act->action != KHUI_MENU_END) || + (def->n_items >= 0 && i < (int) def->n_items)) { + refresh_menu_item(hm, khui_find_action(act->action), i, act->flags); + act++; i++; + } +} + +static HMENU mm_create_menu_from_def(khui_menu_def * def, BOOL main) { HMENU hm; khui_action_ref * act; int i; - hm = CreatePopupMenu(); + if (main) + hm = CreateMenu(); + else + hm = CreatePopupMenu(); + act = def->items; i = 0; while((def->n_items == -1 && act->action != KHUI_MENU_END) || @@ -163,7 +227,7 @@ static void mm_show_panel_def(khui_menu_def * def, LONG x, LONG y) { HMENU hm; - hm = mm_create_menu_from_def(def); + hm = mm_create_menu_from_def(def, FALSE); mm_hot_track = (mm_last_hot_item >= 0); @@ -218,12 +282,11 @@ LRESULT khm_menu_activate(int menu_id) { } else if(menu_id == MENU_ACTIVATE_NONE) { menu_id = -1; } - SendMessage(khui_main_menu_toolbar, - TB_SETHOTITEM, - menu_id, - 0); + TB_SETHOTITEM, + menu_id, + 0); khm_menu_track_current(); @@ -472,7 +535,36 @@ LRESULT khm_menu_notify_main(LPNMHDR notice) { return ret; } -void khm_menu_create_main(HWND rebar) { +HMENU khui_hmenu_main = NULL; + +void khm_menu_refresh_items(void) { + khui_menu_def * def; + + if (!khui_hmenu_main) + return; + + def = khui_find_menu(KHUI_MENU_MAIN); + + refresh_menu(khui_hmenu_main, def); + + DrawMenuBar(khm_hwnd_main); +} + +void khm_menu_create_main(HWND parent) { + HMENU hmenu; + khui_menu_def * def; + + def = khui_find_menu(KHUI_MENU_MAIN); + + hmenu = mm_create_menu_from_def(def, TRUE); + + SetMenu(parent, hmenu); + + khui_hmenu_main = hmenu; + + return; + +#ifdef USE_EXPLORER_STYLE_MENU_BAR HWND hwtb; REBARBANDINFO rbi; SIZE sz; @@ -566,4 +658,5 @@ void khm_menu_create_main(HWND rebar) { RB_INSERTBAND, 0, (LPARAM) &rbi); +#endif } diff --git a/src/windows/identity/ui/mainmenu.h b/src/windows/identity/ui/mainmenu.h index 59638cdd4..7f718c26c 100644 --- a/src/windows/identity/ui/mainmenu.h +++ b/src/windows/identity/ui/mainmenu.h @@ -45,8 +45,9 @@ void khm_menu_show_panel(int id, LONG x, LONG y); void khm_menu_track_current(void); LRESULT khm_menu_measure_item(WPARAM wParam, LPARAM lparam); LRESULT khm_menu_draw_item(WPARAM wParam, LPARAM lparam); +void khm_menu_refresh_items(void); -static HMENU mm_create_menu_from_def(khui_menu_def * def); +static HMENU mm_create_menu_from_def(khui_menu_def * def, BOOL main); static void mm_show_panel_def(khui_menu_def * def, LONG x, LONG y); void khui_init_menu(void); diff --git a/src/windows/identity/ui/mainwnd.c b/src/windows/identity/ui/mainwnd.c index 8f55005b3..1e00c6d2a 100644 --- a/src/windows/identity/ui/mainwnd.c +++ b/src/windows/identity/ui/mainwnd.c @@ -112,7 +112,7 @@ LRESULT CALLBACK khm_main_wnd_proc( break; case WM_HELP: - MessageBox(khm_hwnd_main, L"WM_HELP", L"Notice", MB_OK); + khm_html_help(khm_hwnd_main, NULL, HH_HELP_CONTEXT, IDH_WELCOME); break; case WM_COMMAND: @@ -175,16 +175,24 @@ LRESULT CALLBACK khm_main_wnd_proc( } break; + case KHUI_ACTION_OPT_PLUGINS: { + khui_config_node node; + + khui_cfg_open(NULL, L"KhmPlugins", &node); + khm_show_config_pane(node); + } + break; + case KHUI_ACTION_HELP_CTX: - khm_html_help(khm_hwnd_main, HH_HELP_CONTEXT, IDH_WELCOME); + khm_html_help(khm_hwnd_main, NULL, HH_HELP_CONTEXT, IDH_WELCOME); break; case KHUI_ACTION_HELP_CONTENTS: - khm_html_help(khm_hwnd_main, HH_DISPLAY_TOC, 0); + khm_html_help(khm_hwnd_main, NULL, HH_DISPLAY_TOC, 0); break; case KHUI_ACTION_HELP_INDEX: - khm_html_help(khm_hwnd_main, HH_DISPLAY_INDEX, (DWORD_PTR) L""); + khm_html_help(khm_hwnd_main, NULL, HH_DISPLAY_INDEX, (DWORD_PTR) L""); break; case KHUI_ACTION_HELP_ABOUT: @@ -400,10 +408,14 @@ LRESULT CALLBACK khm_main_wnd_proc( kmq_wm_begin(lParam, &m); if (m->type == KMSG_ACT && m->subtype == KMSG_ACT_REFRESH) { + khm_menu_refresh_items(); khm_update_standard_toolbar(); } else if (m->type == KMSG_ACT && m->subtype == KMSG_ACT_BEGIN_CMDLINE) { khm_cred_begin_commandline(); + } else if (m->type == KMSG_ACT && + m->subtype == KMSG_ACT_CONTINUE_CMDLINE) { + khm_cred_process_commandline(); } else if (m->type == KMSG_CRED && m->subtype == KMSG_CRED_REFRESH) { mw_restart_refresh_timer(hwnd); @@ -500,6 +512,8 @@ void khm_create_main_window_controls(HWND hwnd_main) { REBARINFO rbi; HWND hwRebar; + khm_menu_create_main(hwnd_main); + hwRebar = CreateWindowEx(WS_EX_TOOLWINDOW, REBARCLASSNAME, @@ -531,7 +545,6 @@ void khm_create_main_window_controls(HWND hwnd_main) { return; /* self attach */ - khm_menu_create_main(hwRebar); khm_create_standard_toolbar(hwRebar); khm_create_statusbar(hwnd_main); diff --git a/src/windows/identity/ui/newcredwnd.c b/src/windows/identity/ui/newcredwnd.c index 6852846fb..619b79687 100644 --- a/src/windows/identity/ui/newcredwnd.c +++ b/src/windows/identity/ui/newcredwnd.c @@ -43,12 +43,20 @@ nc_common_dlg_proc(HWND hwnd, { switch(uMsg) { case WM_INITDIALOG: + { + khui_nc_wnd_data * d; + + d = (khui_nc_wnd_data *) lParam; #pragma warning(push) #pragma warning(disable: 4244) - SetWindowLongPtr(hwnd, DWLP_USER, lParam); + SetWindowLongPtr(hwnd, DWLP_USER, lParam); #pragma warning(pop) - + if (d->nc->subtype == KMSG_CRED_PASSWORD) { + ShowWindow(GetDlgItem(hwnd, IDC_NC_OPTIONS), + SW_HIDE); + } + } return TRUE; case WM_COMMAND: @@ -271,6 +279,7 @@ nc_update_credtext(khui_nc_wnd_data * d) kcdb_identity_get_name(d->nc->identities[0], id_name, &cbbuf); kcdb_identity_get_flags(d->nc->identities[0], &flags); + if (flags & KCDB_IDENT_FLAG_INVALID) { LoadString(khm_hInstance, IDS_NC_CREDTEXT_ID_INVALID, id_fmt, (int) ARRAYLENGTH(id_fmt)); @@ -290,6 +299,21 @@ nc_update_credtext(khui_nc_wnd_data * d) StringCbPrintf(buf, NC_MAXCB_CREDTEXT - cch*sizeof(wchar_t), main_fmt, id_string); + if (flags & KCDB_IDENT_FLAG_VALID) { + if (flags & KCDB_IDENT_FLAG_DEFAULT) + LoadString(khm_hInstance, IDS_NC_ID_DEF, + id_string, ARRAYLENGTH(id_string)); + else if (d->nc->set_default) + LoadString(khm_hInstance, IDS_NC_ID_WDEF, + id_string, ARRAYLENGTH(id_string)); + else + LoadString(khm_hInstance, IDS_NC_ID_NDEF, + id_string, ARRAYLENGTH(id_string)); + + StringCbCat(buf, NC_MAXCB_CREDTEXT - cch * sizeof(wchar_t), + id_string); + } + } else if(d->nc->n_identities > 1) { wchar_t *ids_string; khm_size cb_ids_string; @@ -456,6 +480,12 @@ nc_update_credtext(khui_nc_wnd_data * d) #define CW_PARAM DWLP_USER +static void +nc_add_control_row(khui_nc_wnd_data * d, + HWND label, + HWND input, + khui_control_size size); + static LRESULT nc_handle_wm_create(HWND hwnd, UINT uMsg, @@ -691,6 +721,7 @@ nc_handle_wm_create(HWND hwnd, ShowWindow(ncd->dlg_ts, SW_HIDE); nc_position_credtext(ncd); + } else { /* hide and show stuff */ ShowWindow(ncd->dlg_main, SW_SHOW); @@ -705,6 +736,28 @@ nc_handle_wm_create(HWND hwnd, selector controls */ c->ident_cb(c, WMNC_IDENT_INIT, NULL, 0, 0, (LPARAM) ncd->dlg_main); +#if 0 + { + HWND hw; + wchar_t wcaption[64]; + + LoadString(khm_hInstance, IDS_NC_SETDEF, wcaption, + ARRAYLENGTH(wcaption)); + + /* Now create the set as default button */ + hw = CreateWindow + (L"BUTTON", + wcaption, + WS_CHILD | WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX, + 0, 0, 100, 100, + ncd->dlg_main, + (HMENU) NC_BN_SET_DEF_ID, + khm_hInstance, + NULL); + + nc_add_control_row(ncd, NULL, hw, KHUI_CTRLSIZE_HALF); + } +#endif /* we defer the creation of the tab buttons for later */ /* add this to the dialog chain */ @@ -757,23 +810,27 @@ nc_add_control_row(khui_nc_wnd_data * d, #endif } - SetWindowPos(label, - ((d->hwnd_last_idspec != NULL)? - d->hwnd_last_idspec: - HWND_TOP), - r_label.left, r_label.top, - r_label.right - r_label.left, - r_label.bottom - r_label.top, - SWP_DEFERERASE | SWP_NOACTIVATE | - SWP_NOOWNERZORDER); - - SetWindowPos(input, - label, - r_input.left, r_input.top, - r_input.right - r_input.left, - r_input.bottom - r_input.top, - SWP_DEFERERASE | SWP_NOACTIVATE | - SWP_NOOWNERZORDER); + if (label) + SetWindowPos(label, + ((d->hwnd_last_idspec != NULL)? + d->hwnd_last_idspec: + HWND_TOP), + r_label.left, r_label.top, + r_label.right - r_label.left, + r_label.bottom - r_label.top, + SWP_DEFERERASE | SWP_NOACTIVATE | + SWP_NOOWNERZORDER); + + if (input) + SetWindowPos(input, + (label ? label : ((d->hwnd_last_idspec != NULL)? + d->hwnd_last_idspec: + HWND_TOP)), + r_input.left, r_input.top, + r_input.right - r_input.left, + r_input.bottom - r_input.top, + SWP_DEFERERASE | SWP_NOACTIVATE | + SWP_NOOWNERZORDER); d->hwnd_last_idspec = input; @@ -877,6 +934,10 @@ nc_handle_wm_command(HWND hwnd, } return FALSE; + case IDC_NC_HELP: + khm_html_help(hwnd, NULL, HH_HELP_CONTEXT, IDH_ACTION_NEW_ID); + return FALSE; + case IDC_NC_OPTIONS: /* the Options button in the main window was clicked. we respond by expanding the dialog. */ @@ -958,10 +1019,26 @@ nc_handle_wm_command(HWND hwnd, WMNC_DIALOG_SWITCH_PANEL), 0); } + } else if (!wcsicmp(sid, L"NotDef")) { + d->nc->set_default = FALSE; + nc_update_credtext(d); + } else if (!wcsicmp(sid, L"MakeDef")) { + d->nc->set_default = TRUE; + nc_update_credtext(d); } } return FALSE; +#if 0 + case NC_BN_SET_DEF_ID: + { + d->nc->set_default = + (IsDlgButtonChecked(d->dlg_main, NC_BN_SET_DEF_ID) + == BST_CHECKED); + } + return FALSE; +#endif + default: /* if one of the tab strip buttons were pressed, then we should switch to that panel */ @@ -1271,7 +1348,21 @@ static LRESULT nc_handle_wm_nc_notify(HWND hwnd, nc_notify_types(d->nc, KHUI_WM_NC_NOTIFY, MAKEWPARAM(0, WMNC_IDENTITY_CHANGE), 0); + + if (d->nc->subtype == KMSG_CRED_NEW_CREDS && + d->nc->n_identities > 0 && + d->nc->identities[0]) { + khm_int32 f = 0; + + kcdb_identity_get_flags(d->nc->identities[0], &f); + + if (!(f & KCDB_IDENT_FLAG_DEFAULT)) { + d->nc->set_default = FALSE; + } + } + nc_update_credtext(d); + } break; @@ -1517,7 +1608,11 @@ static LRESULT nc_handle_wm_nc_notify(HWND hwnd, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOSIZE | SWP_SHOWWINDOW); - + + SendMessage(hw, EM_SETLIMITTEXT, + KHUI_MAXCCH_PROMPT_VALUE -1, + 0); + d->nc->prompts[i]->hwnd_edit = hw; hw_prev = hw; @@ -1542,12 +1637,12 @@ static LRESULT nc_handle_wm_nc_notify(HWND hwnd, nc = d->nc; - /* reset state */ - nc->result = KHUI_NC_RESULT_CANCEL; - if(nc->response & KHUI_NC_RESPONSE_NOEXIT) { HWND hw; + /* reset state */ + nc->result = KHUI_NC_RESULT_CANCEL; + hw = GetDlgItem(d->dlg_main, IDOK); EnableWindow(hw, TRUE); hw = GetDlgItem(d->dlg_main, IDCANCEL); @@ -1586,6 +1681,72 @@ static LRESULT nc_handle_wm_nc_notify(HWND hwnd, return TRUE; } +static LRESULT nc_handle_wm_help(HWND hwnd, + UINT uMsg, + WPARAM wParam, + LPARAM lParam) { + static DWORD ctxids[] = { + NC_TS_CTRL_ID_MIN, IDH_NC_TABMAIN, + NC_TS_CTRL_ID_MIN + 1, IDH_NC_TABBUTTON, + NC_TS_CTRL_ID_MIN + 2, IDH_NC_TABBUTTON, + NC_TS_CTRL_ID_MIN + 3, IDH_NC_TABBUTTON, + NC_TS_CTRL_ID_MIN + 4, IDH_NC_TABBUTTON, + NC_TS_CTRL_ID_MIN + 5, IDH_NC_TABBUTTON, + NC_TS_CTRL_ID_MIN + 6, IDH_NC_TABBUTTON, + NC_TS_CTRL_ID_MIN + 7, IDH_NC_TABBUTTON, + IDOK, IDH_NC_OK, + IDCANCEL, IDH_NC_CANCEL, + IDC_NC_HELP, IDH_NC_HELP, + IDC_NC_OPTIONS, IDH_NC_OPTIONS, + IDC_NC_CREDTEXT, IDH_NC_CREDWND, + 0 + }; + + HELPINFO * hlp; + HWND hw = NULL; + HWND hw_ctrl; + khui_nc_wnd_data * d; + + d = (khui_nc_wnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, CW_PARAM); + + hlp = (HELPINFO *) lParam; + + if (d->nc->subtype != KMSG_CRED_NEW_CREDS && + d->nc->subtype != KMSG_CRED_PASSWORD) + return TRUE; + + if (hlp->iContextType != HELPINFO_WINDOW) + return TRUE; + + if (hlp->hItemHandle != NULL && + hlp->hItemHandle != hwnd) { + DWORD id; + int i; + + hw_ctrl =hlp->hItemHandle; + + id = GetWindowLong(hw_ctrl, GWL_ID); + for (i=0; ctxids[i] != 0; i += 2) + if (ctxids[i] == id) + break; + + if (ctxids[i] != 0) + hw = khm_html_help(hw_ctrl, + ((d->nc->subtype == KMSG_CRED_NEW_CREDS)? + L"::popups_newcreds.txt": + L"::popups_password.txt"), + HH_TP_HELP_WM_HELP, + (DWORD_PTR) ctxids); + } + + if (hw == NULL) { + khm_html_help(hwnd, NULL, HH_HELP_CONTEXT, + ((d->nc->subtype == KMSG_CRED_NEW_CREDS)? + IDH_ACTION_NEW_ID: IDH_ACTION_PASSWD_ID)); + } + + return TRUE; +} static LRESULT CALLBACK nc_window_proc(HWND hwnd, UINT uMsg, @@ -1606,6 +1767,9 @@ static LRESULT CALLBACK nc_window_proc(HWND hwnd, case WM_MOVING: return nc_handle_wm_moving(hwnd, uMsg, wParam, lParam); + case WM_HELP: + return nc_handle_wm_help(hwnd, uMsg, wParam, lParam); + case KHUI_WM_NC_NOTIFY: return nc_handle_wm_nc_notify(hwnd, uMsg, wParam, lParam); } diff --git a/src/windows/identity/ui/newcredwnd.h b/src/windows/identity/ui/newcredwnd.h index 22505bc74..7813e1c19 100644 --- a/src/windows/identity/ui/newcredwnd.h +++ b/src/windows/identity/ui/newcredwnd.h @@ -88,6 +88,8 @@ void khm_show_newcredwnd(HWND hwnd); /* Maximum control ID */ #define NC_TS_CTRL_ID_MAX (NC_TS_CTRL_ID_MIN + NC_TS_MAX_CTRLS - 1) +#define NC_BN_SET_DEF_ID 8012 + /* the first control ID that may be used by an identity provider */ #define NC_IS_CTRL_ID_MIN 8016 diff --git a/src/windows/identity/ui/notifier.c b/src/windows/identity/ui/notifier.c index 5d62be5fc..b7ac46262 100644 --- a/src/windows/identity/ui/notifier.c +++ b/src/windows/identity/ui/notifier.c @@ -57,6 +57,8 @@ khui_alert * alert_queue[KHUI_ALERT_QUEUE_MAX]; khm_int32 alert_queue_head = 0; khm_int32 alert_queue_tail = 0; +int iid_normal = IDI_NOTIFY_NONE; + #define is_alert_queue_empty() (alert_queue_head == alert_queue_tail) #define is_alert_queue_full() (((alert_queue_tail + 1) % KHUI_ALERT_QUEUE_MAX) == alert_queue_head) @@ -227,8 +229,8 @@ notifier_wnd_proc(HWND hwnd, case WM_LBUTTONUP: /* fall through */ - case NIN_SELECT: + /* fall through */ case NIN_KEYSELECT: khm_show_main_window(); break; @@ -1025,7 +1027,7 @@ void khm_notify_icon_add(void) { ni.hWnd = hwnd_notifier; ni.uID = KHUI_NOTIFY_ICON_ID; ni.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; - ni.hIcon = LoadIcon(khm_hInstance, MAKEINTRESOURCE(IDI_NOTIFY_NONE)); + ni.hIcon = LoadIcon(khm_hInstance, MAKEINTRESOURCE(iid_normal)); ni.uCallbackMessage = KHUI_WM_NOTIFIER; LoadString(khm_hInstance, IDS_NOTIFY_PREFIX, buf, ARRAYLENGTH(buf)); StringCbCopy(ni.szTip, sizeof(ni.szTip), buf); @@ -1066,7 +1068,7 @@ khm_notify_icon_balloon(khm_int32 severity, iid = IDI_NOTIFY_ERROR; } else { ni.dwInfoFlags = NIIF_NONE; - iid = IDI_NOTIFY_NONE; + iid = iid_normal; } ni.hWnd = hwnd_notifier; @@ -1098,6 +1100,27 @@ khm_notify_icon_balloon(khm_int32 severity, DestroyIcon(ni.hIcon); } +void khm_notify_icon_expstate(enum khm_notif_expstate expseverity) { + int new_iid; + + if (expseverity == KHM_NOTIF_OK) + new_iid = IDI_APPICON_OK; + else if (expseverity == KHM_NOTIF_WARN) + new_iid = IDI_APPICON_WARN; + else if (expseverity == KHM_NOTIF_EXP) + new_iid = IDI_APPICON_EXP; + else + new_iid = IDI_NOTIFY_NONE; + + if (iid_normal == new_iid) + return; + + iid_normal = new_iid; + + if (current_alert == NULL) + khm_notify_icon_change(KHERR_NONE); +} + void khm_notify_icon_change(khm_int32 severity) { NOTIFYICONDATA ni; wchar_t buf[256]; @@ -1110,7 +1133,7 @@ void khm_notify_icon_change(khm_int32 severity) { else if (severity == KHERR_ERROR) iid = IDI_NOTIFY_ERROR; else - iid = IDI_NOTIFY_NONE; + iid = iid_normal; ZeroMemory(&ni, sizeof(ni)); diff --git a/src/windows/identity/ui/notifier.h b/src/windows/identity/ui/notifier.h index de9fb60fa..140d02c44 100644 --- a/src/windows/identity/ui/notifier.h +++ b/src/windows/identity/ui/notifier.h @@ -27,6 +27,15 @@ #ifndef __KHIMAIRA_NOTIFIER_H #define __KHIMAIRA_NOTIFIER_H +extern HWND hwnd_notifier; + +enum khm_notif_expstate { + KHM_NOTIF_EMPTY, + KHM_NOTIF_OK, + KHM_NOTIF_WARN, + KHM_NOTIF_EXP +}; + void khm_init_notifier(void); @@ -42,4 +51,7 @@ khm_notify_icon_balloon(khm_int32 severity, wchar_t * msg, khm_int32 timeout); +void +khm_notify_icon_expstate(enum khm_notif_expstate expseverity); + #endif diff --git a/src/windows/identity/ui/reqdaemon.c b/src/windows/identity/ui/reqdaemon.c index 9c48eed43..04056566d 100644 --- a/src/windows/identity/ui/reqdaemon.c +++ b/src/windows/identity/ui/reqdaemon.c @@ -101,12 +101,13 @@ reqdaemonwnd_proc(HWND hwnd, kcdb_identity_create(widname, KCDB_IDENT_FLAG_CREATE, &identity); - } + widname[0] = 0; + do { if (khm_cred_is_in_dialog()) { - khm_cred_wait_for_dialog(INFINITE, NULL); + khm_cred_wait_for_dialog(INFINITE, NULL, NULL, 0); } if (identity) @@ -122,7 +123,6 @@ reqdaemonwnd_proc(HWND hwnd, else khui_context_reset(); - if (pdlginfo->dlgtype == NETID_DLGTYPE_TGT) SendMessage(khm_hwnd_main, WM_COMMAND, MAKEWPARAM(KHUI_ACTION_NEW_CRED, 0), 0); @@ -132,7 +132,9 @@ reqdaemonwnd_proc(HWND hwnd, else break; - if (KHM_FAILED(khm_cred_wait_for_dialog(INFINITE, &result))) + if (KHM_FAILED(khm_cred_wait_for_dialog(INFINITE, &result, + widname, + sizeof(widname)))) continue; else { lr = (result != KHUI_NC_RESULT_GET_CREDS); @@ -140,15 +142,66 @@ reqdaemonwnd_proc(HWND hwnd, } } while(TRUE); +#ifdef DEBUG + assert(lr || pdlginfo->dlgtype != NETID_DLGTYPE_TGT || + widname[0]); +#endif + + if (!lr && pdlginfo->dlgtype == NETID_DLGTYPE_TGT && + widname[0]) { + khm_handle out_ident; + wchar_t * atsign; + + atsign = wcsrchr(widname, L'@'); + + if (atsign == NULL) + goto _exit; + + if (KHM_SUCCEEDED(kcdb_identity_create(widname, + 0, + &out_ident))) { + khm_size cb; + + pdlginfo->out.ccache[0] = 0; + + cb = sizeof(pdlginfo->out.ccache); + kcdb_identity_get_attrib(out_ident, + L"Krb5CCName", + NULL, + pdlginfo->out.ccache, + &cb); + kcdb_identity_release(out_ident); + } +#ifdef DEBUG + else { + assert(FALSE); + } +#endif + + *atsign++ = 0; + + StringCbCopy(pdlginfo->out.username, + sizeof(pdlginfo->out.username), + widname); + + StringCbCopy(pdlginfo->out.realm, + sizeof(pdlginfo->out.realm), + atsign); + } + + _exit: + if (pdlginfo) UnmapViewOfFile(pdlginfo); if (hmap) CloseHandle(hmap); + if (identity) + kcdb_identity_release(identity); return lr; } -#if 0 +#ifdef DEPRECATED_REMOTE_CALL /* deprecated */ case ID_OBTAIN_TGT_WITH_LPARAM: { @@ -296,6 +349,7 @@ khm_reqdaemon_thread_proc(LPVOID vparam) { #ifdef DEBUG DWORD dw; #endif + khm_register_reqdaemonwnd_class(); #ifdef DEBUG diff --git a/src/windows/identity/ui/resource.h b/src/windows/identity/ui/resource.h index 4bee5f206..b8060c6a0 100644 --- a/src/windows/identity/ui/resource.h +++ b/src/windows/identity/ui/resource.h @@ -198,9 +198,14 @@ #define IDB_WDG_STUCK 201 #define IDS_ACTION_IMPORT 202 #define IDS_CTX_IMPORT 203 +#define IDB_FLAG_RENEW 203 #define IDS_CFG_PI_COL_PLUGINS 204 +#define IDI_APPICON_WARN 204 #define IDS_PISTATE_FAILUNK 205 +#define IDI_APPICON_EXP 205 #define IDS_PISTATE_FAILMAX 206 +#define IDI_ICON4 206 +#define IDI_APPICON_OK 206 #define IDS_PISTATE_FAILREG 207 #define IDS_PISTATE_FAILDIS 208 #define IDS_PISTATE_FAILLOD 209 @@ -222,6 +227,11 @@ #define IDS_ERR_SUGG_NO_IDENTPRO 225 #define IDS_NC_REN_FAILED_TITLE 226 #define IDS_CW_DEFAULT 227 +#define IDS_ACTION_OPT_PLUGINS 228 +#define IDS_NC_SETDEF 229 +#define IDS_NC_ID_DEF 230 +#define IDS_NC_ID_WDEF 231 +#define IDS_NC_ID_NDEF 232 #define IDC_NC_USERNAME 1007 #define IDC_NC_PASSWORD 1008 #define IDC_NC_CREDTEXT_LABEL 1009 @@ -314,9 +324,9 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 202 +#define _APS_NEXT_RESOURCE_VALUE 207 #define _APS_NEXT_COMMAND_VALUE 40010 -#define _APS_NEXT_CONTROL_VALUE 1105 +#define _APS_NEXT_CONTROL_VALUE 1107 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/src/windows/identity/ui/timer.c b/src/windows/identity/ui/timer.c index 98957858c..5d28e6a58 100644 --- a/src/windows/identity/ui/timer.c +++ b/src/windows/identity/ui/timer.c @@ -86,19 +86,22 @@ khm_timer_exit(void) { static void tmr_fire_timer(void) { int i; - __int64 curtime; - __int64 err; - __int64 next_event; + unsigned __int64 curtime; + unsigned __int64 err; + unsigned __int64 next_event; int tmr_count[KHUI_N_TTYPES]; - __int64 tmr_offset[KHUI_N_TTYPES]; + unsigned __int64 tmr_offset[KHUI_N_TTYPES]; int t; khm_handle eff_ident = NULL; khui_timer_type eff_type = 0; /* meaningless */ int fire_count = 0; + FILETIME ft; + + TimetToFileTimeInterval(KHUI_TIMEEQ_ERROR_SMALL, &ft); + err = FtToInt(&ft); + GetSystemTimeAsFileTime(&ft); + curtime = FtToInt(&ft); - TimetToFileTimeInterval(KHUI_TIMEEQ_ERROR_SMALL, - (LPFILETIME) &err); - GetSystemTimeAsFileTime((LPFILETIME) &curtime); next_event = 0; ZeroMemory(tmr_count, sizeof(tmr_count)); @@ -175,7 +178,7 @@ tmr_fire_timer(void) { wchar_t wtime[128]; wchar_t wmsg[256]; wchar_t wtitle[64]; - __int64 ft_second; + unsigned __int64 second; khui_alert * alert = NULL; khm_size cb; @@ -187,12 +190,13 @@ tmr_fire_timer(void) { seconds' instead of '5 mins' and so on when converting to a string. So we add half a second to make the message neater. */ - TimetToFileTimeInterval(1, (LPFILETIME) &ft_second); - next_event += ft_second / 2; + TimetToFileTimeInterval(1, &ft); + second = FtToInt(&ft); + next_event += second / 2; cb = sizeof(wtime); - - FtIntervalToString((LPFILETIME) &next_event, + ft = IntToFt(next_event); + FtIntervalToString(&ft, wtime, &cb); @@ -207,7 +211,7 @@ tmr_fire_timer(void) { cb = sizeof(idname); kcdb_identity_get_name(eff_ident, idname, &cb); - if (next_event < ft_second) { + if (next_event < second) { LoadString(khm_hInstance, IDS_WARN_EXPIRED_ID, fmt, ARRAYLENGTH(fmt)); @@ -219,7 +223,7 @@ tmr_fire_timer(void) { StringCbPrintf(wmsg, sizeof(wmsg), fmt, idname, wtime); } } else { - if (next_event < ft_second) { + if (next_event < second) { LoadString(khm_hInstance, IDS_WARN_EXPIRED, wmsg, ARRAYLENGTH(wmsg)); } else { @@ -325,12 +329,13 @@ tmr_cred_apply_proc(khm_handle cred, void * rock) { khm_handle ident = NULL; int mark_idx; int idx; - __int64 ft_expiry; - __int64 ft_current; - __int64 ft_cred_expiry; - __int64 ft; - __int64 fte; - __int64 ft_reinst; + FILETIME ft_expiry; + FILETIME ft_current; + FILETIME ft_creinst; + FILETIME ft_cred_expiry; + FILETIME ft; + FILETIME fte; + FILETIME ft_reinst; khm_size cb; kcdb_cred_get_identity(cred, &ident); @@ -352,9 +357,11 @@ tmr_cred_apply_proc(khm_handle cred, void * rock) { } /* and the current time */ - GetSystemTimeAsFileTime((LPFILETIME) &ft_current); + GetSystemTimeAsFileTime(&ft_current); + + TimetToFileTimeInterval(KHUI_TIMEEQ_ERROR, &ft_reinst); - TimetToFileTimeInterval(KHUI_TIMEEQ_ERROR, (LPFILETIME) &ft_reinst); + ft_creinst = FtAdd(&ft_current, &ft_reinst); mark_idx = tmr_find(ident, KHUI_TTYPE_ID_MARK, 0, 0); @@ -382,7 +389,7 @@ tmr_cred_apply_proc(khm_handle cred, void * rock) { khm_int32 to_crit = KHUI_DEF_TIMEOUT_CRIT; khm_int32 to_renew = KHUI_DEF_TIMEOUT_RENEW; - if (ft_expiry < ft_current) + if (CompareFileTime(&ft_expiry, &ft_current) < 0) /* already expired */ goto _done_with_ident; @@ -433,8 +440,8 @@ tmr_cred_apply_proc(khm_handle cred, void * rock) { if (monitor && do_renew) { int prev; - TimetToFileTimeInterval(to_renew, (LPFILETIME) &ft); - fte = ft_expiry - ft; + TimetToFileTimeInterval(to_renew, &ft); + fte = FtSub(&ft_expiry, &ft); prev = tmr_find(ident, KHUI_TTYPE_ID_RENEW, 0, 0); @@ -444,15 +451,16 @@ tmr_cred_apply_proc(khm_handle cred, void * rock) { This maybe because that NetIDMgr was started at the last minute, or because for some reason the renew timer could not be triggered earlier. */ - if (fte > ft_current || + if (CompareFileTime(&fte, &ft_current) > 0 || prev == -1 || !(khui_timers[prev].flags & KHUI_TE_FLAG_EXPIRED)) { - if (fte <= ft_current) + if (CompareFileTime(&fte, &ft_current) < 0) fte = ft_current; tmr_update(ident, KHUI_TTYPE_ID_RENEW, - fte, ft, 0, fte > ft_current + ft_reinst); + FtToInt(&fte), FtToInt(&ft), 0, + CompareFileTime(&fte,&ft_creinst) > 0); renew_done = TRUE; } else { /* special case. If the renew timer was in the past @@ -461,32 +469,36 @@ tmr_cred_apply_proc(khm_handle cred, void * rock) { failed we don't want to automatically retry everytime we check the timers. */ tmr_update(ident, KHUI_TTYPE_ID_RENEW, - fte, ft, 0, FALSE); + FtToInt(&fte), FtToInt(&ft), 0, FALSE); } } if (monitor && do_warn && !renew_done) { - TimetToFileTimeInterval(to_warn, (LPFILETIME) &ft); - fte = ft_expiry - ft; - if (fte > ft_current) + TimetToFileTimeInterval(to_warn, &ft); + fte = FtSub(&ft_expiry, &ft); + + if (CompareFileTime(&fte, &ft_current) > 0) tmr_update(ident, KHUI_TTYPE_ID_WARN, - fte, ft, 0, fte > ft_current + ft_reinst); + FtToInt(&fte), FtToInt(&ft), 0, + CompareFileTime(&fte, &ft_creinst) > 0); } if (monitor && do_crit && !renew_done) { - TimetToFileTimeInterval(to_crit, (LPFILETIME) &ft); - fte = ft_expiry - ft; + TimetToFileTimeInterval(to_crit, &ft); + fte = FtSub(&ft_expiry, &ft); - if (fte > ft_current) + if (CompareFileTime(&fte, &ft_current) > 0) tmr_update(ident, KHUI_TTYPE_ID_CRIT, - fte, ft, 0, fte > ft_current + ft_reinst); + FtToInt(&fte), FtToInt(&ft), 0, + CompareFileTime(&fte, &ft_creinst) > 0); } if (monitor && !renew_done) { - if (ft_expiry > ft_current) + if (CompareFileTime(&ft_expiry, &ft_current) > 0) tmr_update(ident, KHUI_TTYPE_ID_EXP, - ft_expiry, 0, 0, fte > ft_current + ft_reinst); + FtToInt(&ft_expiry), 0, 0, + CompareFileTime(&fte, &ft_creinst) > 0); } _done_with_ident: @@ -500,20 +512,27 @@ tmr_cred_apply_proc(khm_handle cred, void * rock) { &cb))) goto _cleanup; - TimetToFileTimeInterval(KHUI_TIMEEQ_ERROR, (LPFILETIME) &ft); + TimetToFileTimeInterval(KHUI_TIMEEQ_ERROR, &ft); - if (ft_cred_expiry >= ft_expiry || - (ft_expiry - ft_cred_expiry) < ft) - goto _cleanup; + { + FILETIME ft_delta; + + ft_delta = FtSub(&ft_expiry, &ft_cred_expiry); + + if (CompareFileTime(&ft_cred_expiry, &ft_expiry) >= 0 || + CompareFileTime(&ft_delta, &ft) < 0) + goto _cleanup; + } if ((idx = tmr_find(ident, KHUI_TTYPE_ID_WARN, 0, 0)) >= 0 && !(khui_timers[idx].flags & KHUI_TE_FLAG_STALE)) { - fte = ft_cred_expiry - khui_timers[idx].offset; - if (fte > ft_current) { - tmr_update(cred, KHUI_TTYPE_CRED_WARN, fte, + fte = IntToFt(FtToInt(&ft_cred_expiry) - khui_timers[idx].offset); + if (CompareFileTime(&fte, &ft_current) > 0) { + tmr_update(cred, KHUI_TTYPE_CRED_WARN, + FtToInt(&fte), khui_timers[idx].offset, 0, - fte > ft_current + ft_reinst); + CompareFileTime(&fte, &ft_creinst) > 0); kcdb_cred_hold(cred); } } @@ -521,11 +540,12 @@ tmr_cred_apply_proc(khm_handle cred, void * rock) { if ((idx = tmr_find(ident, KHUI_TTYPE_ID_CRIT, 0, 0)) >= 0 && !(khui_timers[idx].flags & KHUI_TE_FLAG_STALE)) { - fte = ft_cred_expiry - khui_timers[idx].offset; - if (fte > ft_current) { - tmr_update(cred, KHUI_TTYPE_CRED_CRIT, fte, + fte = IntToFt(FtToInt(&ft_cred_expiry) - khui_timers[idx].offset); + if (CompareFileTime(&fte, &ft_current) > 0) { + tmr_update(cred, KHUI_TTYPE_CRED_CRIT, + FtToInt(&fte), khui_timers[idx].offset, 0, - fte > ft_current + ft_reinst); + CompareFileTime(&fte, &ft_creinst) > 0); kcdb_cred_hold(cred); } } @@ -533,11 +553,12 @@ tmr_cred_apply_proc(khm_handle cred, void * rock) { if ((idx = tmr_find(ident, KHUI_TTYPE_ID_RENEW, 0, 0)) >= 0 && !(khui_timers[idx].flags & KHUI_TE_FLAG_STALE)) { - fte = ft_cred_expiry - khui_timers[idx].offset; - if (fte > ft_current) { - tmr_update(cred, KHUI_TTYPE_CRED_RENEW, fte, + fte = IntToFt(FtToInt(&ft_cred_expiry) - khui_timers[idx].offset); + if (CompareFileTime(&fte, &ft_current) > 0) { + tmr_update(cred, KHUI_TTYPE_CRED_RENEW, + FtToInt(&fte), khui_timers[idx].offset, 0, - fte > ft_current + ft_reinst); + CompareFileTime(&fte, &ft_creinst) > 0); kcdb_cred_hold(cred); } } @@ -545,10 +566,11 @@ tmr_cred_apply_proc(khm_handle cred, void * rock) { if ((idx = tmr_find(ident, KHUI_TTYPE_ID_EXP, 0, 0)) >= 0 && !(khui_timers[idx].flags & KHUI_TE_FLAG_STALE)) { - if (ft_cred_expiry > ft_current) { - tmr_update(cred, KHUI_TTYPE_CRED_EXP, ft_cred_expiry, + if (CompareFileTime(&ft_cred_expiry, &ft_current) > 0) { + tmr_update(cred, KHUI_TTYPE_CRED_EXP, + FtToInt(&ft_cred_expiry), 0, 0, - ft_cred_expiry > ft_current + ft_reinst); + CompareFileTime(&ft_cred_expiry, &ft_creinst) > 0); } } @@ -618,9 +640,9 @@ tmr_purge(void) { void khm_timer_refresh(HWND hwnd) { int i; - __int64 next_event = 0; - __int64 curtime; - __int64 diff; + unsigned __int64 next_event = 0; + unsigned __int64 curtime; + unsigned __int64 diff; EnterCriticalSection(&cs_timers); @@ -655,19 +677,23 @@ khm_timer_refresh(HWND hwnd) { } if (next_event != 0) { - GetSystemTimeAsFileTime((LPFILETIME) &curtime); + FILETIME ft; + + GetSystemTimeAsFileTime(&ft); + curtime = FtToInt(&ft); - TimetToFileTimeInterval(KHUI_TIMEEQ_ERROR_SMALL, - (LPFILETIME) &diff); + TimetToFileTimeInterval(KHUI_TIMEEQ_ERROR_SMALL, &ft); + diff = FtToInt(&ft); if (curtime + diff > next_event) { tmr_fire_timer(); goto _check_next_event; } else { diff = next_event - curtime; + ft = IntToFt(diff); SetTimer(hwnd, KHUI_TRIGGER_TIMER_ID, - FtIntervalToMilliseconds((LPFILETIME) &diff), + FtIntervalToMilliseconds(&ft), NULL); } } diff --git a/src/windows/identity/ui/timer.h b/src/windows/identity/ui/timer.h index 3a5791721..081d27852 100644 --- a/src/windows/identity/ui/timer.h +++ b/src/windows/identity/ui/timer.h @@ -58,8 +58,8 @@ typedef struct tag_khui_timer_event { khm_handle key; khui_timer_type type; - __int64 expire; /* time at which the timer expires */ - __int64 offset; /* time offset at which the event that + unsigned __int64 expire; /* time at which the timer expires */ + unsigned __int64 offset; /* time offset at which the event that the timer warns of happens */ void * data; khm_int32 flags; diff --git a/src/windows/identity/ui/toolbar.c b/src/windows/identity/ui/toolbar.c index fcc0d9ebd..801d6cc52 100644 --- a/src/windows/identity/ui/toolbar.c +++ b/src/windows/identity/ui/toolbar.c @@ -368,6 +368,6 @@ void khm_create_standard_toolbar(HWND rebar) { SendMessage(rebar, RB_INSERTBAND, - 1, + 0, (LPARAM) &rbi); } diff --git a/src/windows/identity/ui/uiconfig.csv b/src/windows/identity/ui/uiconfig.csv index eeb44bbd3..14057dded 100644 --- a/src/windows/identity/ui/uiconfig.csv +++ b/src/windows/identity/ui/uiconfig.csv @@ -2,7 +2,7 @@ Name,Type,Value,Description CredWindow,KC_SPACE,0,Options for the credentials window AutoInit,KC_INT32,0,Prompt for creds if there arent any AutoStart,KC_INT32,0,Start Khimaira when Windows starts - AutoImport,KC_INT32,0,Import Windows creds when Khimaira starts + AutoImport,KC_INT32,1,Import Windows creds when Khimaira starts AutoDetectNet,KC_INT32,1,Automatically detect network connectivity changes KeepRunning,KC_INT32,1,Keep running after closing Khimaira DefaultView,KC_STRING,ByIdentity, @@ -11,6 +11,7 @@ CredWindow,KC_SPACE,0,Options for the credentials window PaddingVertical,KC_INT32,2, PaddingHeader,KC_INT32,16, Monitor,KC_INT32,1,Monitor credentials + DefaultMonitor,KC_INT32,1,Default Monitor value for new identities RefreshTimeout,KC_INT32,60,In seconds WarnThreshold,KC_INT32,900,In seconds AllowWarn,KC_INT32,1,Boolean. Enables warning. @@ -18,6 +19,8 @@ CredWindow,KC_SPACE,0,Options for the credentials window AllowCritical,KC_INT32,1,Boolean. Enables critical. AutoRenewThreshold,KC_INT32,600,In seconds AllowAutoRenew,KC_INT32,1,Boolean. + DefaultAllowAutoRenew,KC_INT32,1,Default AllowAutoRenew value for new identities + DefaultSticky,KC_INT32,0,Default Sticky value for new identities MaxThreshold,KC_INT32,86400,Max value for a threshold (1 day) MinThreshold,KC_INT32,10,Min value for a threshold (0) Windows,KC_SPACE,0,Window parameters @@ -35,16 +38,16 @@ CredWindow,KC_SPACE,0,Options for the credentials window Custom_0,KC_ENDSPACE,0, ByIdentity,KC_SPACE,0,The default view Description,KC_STRING,View grouped by identity and credential type, - ColumnList,KC_STRING,"_CWFlags,_CWTypeIcon,IdentityName,TypeName,Name,TimeLeft", + ColumnList,KC_STRING,"_CWFlags,IdentityName,TypeName,Name,TimeLeft", Columns,KC_SPACE,0,Columns _CWFlags,KC_SPACE,0, Width,KC_INT32,20, Flags,KC_INT32,112, _CWFlags,KC_ENDSPACE,0, - _CWTypeIcon,KC_SPACE,0, - Width,KC_INT32,20, - Flags,KC_INT32,112, - _CWTypeIcon,KC_ENDSPACE,0, +# _CWTypeIcon,KC_SPACE,0, +# Width,KC_INT32,20, +# Flags,KC_INT32,112, +# _CWTypeIcon,KC_ENDSPACE,0, IdentityName,KC_SPACE,0, Width,KC_INT32,100, SortIndex,KC_INT32,0, @@ -68,16 +71,16 @@ CredWindow,KC_SPACE,0,Options for the credentials window ByIdentity,KC_ENDSPACE,0 ByLocation,KC_SPACE,0,View by location Description,KC_STRING,View grouped by location, - ColumnList,KC_STRING,"_CWFlags,_CWTypeIcon,Location,IdentityName,TypeName,Name,TimeLeft", + ColumnList,KC_STRING,"_CWFlags,Location,IdentityName,TypeName,Name,TimeLeft", Columns,KC_SPACE,0,Columns _CWFlags,KC_SPACE,0, Width,KC_INT32,20, Flags,KC_INT32,112, _CWFlags,KC_ENDSPACE,0, - _CWTypeIcon,KC_SPACE,0, - Width,KC_INT32,20, - Flags,KC_INT32,112, - _CWTypeIcon,KC_ENDSPACE,0, +# _CWTypeIcon,KC_SPACE,0, +# Width,KC_INT32,20, +# Flags,KC_INT32,112, +# _CWTypeIcon,KC_ENDSPACE,0, Location,KC_SPACE,0, Width,KC_INT32,100, SortIndex,KC_INT32,0, diff --git a/src/windows/identity/uilib/accel.csv b/src/windows/identity/uilib/accel.csv index 05b945514..a97b37ba4 100644 --- a/src/windows/identity/uilib/accel.csv +++ b/src/windows/identity/uilib/accel.csv @@ -15,4 +15,7 @@ KHUI_ACTION_DESTROY_CRED,FVIRTKEY,VK_DELETE,KHUI_ACCEL_SCOPE_GLOBAL KHUI_ACTION_EXIT,FCONTROL|FVIRTKEY,\'X\',KHUI_ACCEL_SCOPE_GLOBAL KHUI_ACTION_VIEW_REFRESH,FVIRTKEY,VK_F5,KHUI_ACCEL_SCOPE_GLOBAL KHUI_ACTION_NEW_CRED,FCONTROL|FVIRTKEY,\'N\',KHUI_ACCEL_SCOPE_GLOBAL +KHUI_ACTION_RENEW_CRED,FCONTROL|FVIRTKEY,\'R\',KHUI_ACCEL_SCOPE_GLOBAL +KHUI_ACTION_IMPORT,FCONTROL|FVIRTKEY,\'I\',KHUI_ACCEL_SCOPE_GLOBAL +KHUI_ACTION_DESTROY_CRED,FCONTROL|FVIRTKEY,\'D\',KHUI_ACCEL_SCOPE_GLOBAL KHUI_PACTION_SELALL,FCONTROL|FVIRTKEY,\'A\',KHUI_ACCEL_SCOPE_GLOBAL diff --git a/src/windows/identity/uilib/action.c b/src/windows/identity/uilib/action.c index 0ebb9ae0c..b337eb894 100644 --- a/src/windows/identity/uilib/action.c +++ b/src/windows/identity/uilib/action.c @@ -49,14 +49,13 @@ khui_action_ref khui_menu_cred[] = { MENU_ACTION(KHUI_ACTION_NEW_CRED), MENU_SEP(), MENU_ACTION(KHUI_ACTION_RENEW_CRED), + MENU_ACTION(KHUI_ACTION_IMPORT), MENU_ACTION(KHUI_ACTION_DESTROY_CRED), MENU_SEP(), MENU_ACTION(KHUI_ACTION_SET_DEF_ID), MENU_ACTION(KHUI_ACTION_SET_SRCH_ID), MENU_SEP(), MENU_ACTION(KHUI_ACTION_PASSWD_ID), - MENU_SEP(), - MENU_ACTION(KHUI_ACTION_IMPORT), MENU_END() }; @@ -87,6 +86,7 @@ khui_action_ref khui_menu_options[] = { MENU_ACTION(KHUI_ACTION_OPT_KHIM), MENU_ACTION(KHUI_ACTION_OPT_IDENTS), MENU_ACTION(KHUI_ACTION_OPT_NOTIF), + MENU_ACTION(KHUI_ACTION_OPT_PLUGINS), MENU_END() }; diff --git a/src/windows/identity/uilib/actions.csv b/src/windows/identity/uilib/actions.csv index 371fb8798..dd4949849 100644 --- a/src/windows/identity/uilib/actions.csv +++ b/src/windows/identity/uilib/actions.csv @@ -17,13 +17,14 @@ KHUI_ACTION_DESTROY_CRED,KHUI_ACTIONTYPE_TRIGGER,,IDB_TK_DELETE,0,IDB_TK_DELETE_ KHUI_ACTION_LAYOUT_ID,KHUI_ACTIONTYPE_TRIGGER | KHUI_ACTIONTYPE_TOGGLE,,0,0,0,0,0,IDS_ACTION_LAYOUT_ID,0,0,KHUI_ACTIONSTATE_CHECKED KHUI_ACTION_LAYOUT_TYPE,KHUI_ACTIONTYPE_TRIGGER | KHUI_ACTIONTYPE_TOGGLE,,0,0,0,0,0,IDS_ACTION_LAYOUT_TYPE,0,0,KHUI_ACTIONSTATE_DISABLED KHUI_ACTION_LAYOUT_LOC,KHUI_ACTIONTYPE_TRIGGER | KHUI_ACTIONTYPE_TOGGLE,,0,0,0,0,0,IDS_ACTION_LAYOUT_LOC,0,0,0 -KHUI_ACTION_TB_STANDARD,KHUI_ACTIONTYPE_TRIGGER | KHUI_ACTIONTYPE_TOGGLE,,0,0,0,0,0,IDS_ACTION_TB_STANDARD,0,0,KHUI_ACTIONSTATE_CHECKED +KHUI_ACTION_TB_STANDARD,KHUI_ACTIONTYPE_TRIGGER | KHUI_ACTIONTYPE_TOGGLE,,0,0,0,0,0,IDS_ACTION_TB_STANDARD,0,0,KHUI_ACTIONSTATE_CHECKED|KHUI_ACTIONSTATE_DISABLED KHUI_ACTION_CHOOSE_COLS,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_ACTION_CHOOSE_COLS,0,IDH_ACTION_CHOOSE_COLS,KHUI_ACTIONSTATE_DISABLED KHUI_ACTION_DEBUG_WINDOW,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_ACTION_DEBUG_WINDOW,0,IDH_ACTION_DEBUG_WINDOW,KHUI_ACTIONSTATE_DISABLED KHUI_ACTION_VIEW_REFRESH,KHUI_ACTIONTYPE_TRIGGER,,IDB_VW_REFRESH,0,0,IDB_VW_REFRESH_SM,0,IDS_ACTION_VIEW_REFRESH,0,IDH_ACTION_VIEW_REFRESH,0 KHUI_ACTION_OPT_IDENTS,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_ACTION_OPT_IDENTS,0,IDH_ACTION_OPT_INIT,0 KHUI_ACTION_OPT_KHIM,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_ACTION_OPT_KHIM,0,IDH_ACTION_OPT_KHIM,0 KHUI_ACTION_OPT_NOTIF,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_ACTION_OPT_NOTIF,0,IDH_ACTION_OPT_NOTIF,0 +KHUI_ACTION_OPT_PLUGINS,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_ACTION_OPT_PLUGINS,0,IDH_ACTION_OPT_KHIM,0 KHUI_ACTION_HELP_CTX,KHUI_ACTIONTYPE_TRIGGER,,IDB_HELP,0,0,IDB_HELP_SM,0,IDS_ACTION_HELP_CTX,0,0,0 KHUI_ACTION_HELP_CONTENTS,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_ACTION_HELP_CONTENTS,0,0,0 KHUI_ACTION_HELP_INDEX,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_ACTION_HELP_INDEX,0,0,0 diff --git a/src/windows/identity/uilib/creddlg.c b/src/windows/identity/uilib/creddlg.c index 2cb4e92f9..dae98ff68 100644 --- a/src/windows/identity/uilib/creddlg.c +++ b/src/windows/identity/uilib/creddlg.c @@ -342,7 +342,7 @@ cw_create_prompt(khm_size idx, StringCbCopy(p->prompt, cb_prompt, prompt); } - if(def) { + if(def && cb_def > 0) { cb_def += sizeof(wchar_t); p->def = PMALLOC(cb_def); StringCbCopy(p->def, cb_def, def); diff --git a/src/windows/identity/uilib/khactiondef.h b/src/windows/identity/uilib/khactiondef.h index b880721b6..3f1c43073 100644 --- a/src/windows/identity/uilib/khactiondef.h +++ b/src/windows/identity/uilib/khactiondef.h @@ -62,6 +62,7 @@ #define KHUI_ACTION_MENU_ACTIVATE (KHUI_ACTION_BASE + 26) #define KHUI_ACTION_CLOSE_APP (KHUI_ACTION_BASE + 27) #define KHUI_ACTION_IMPORT (KHUI_ACTION_BASE + 28) +#define KHUI_ACTION_OPT_PLUGINS (KHUI_ACTION_BASE + 29) /*@}*/ /*! \name Pseudo actions diff --git a/src/windows/identity/uilib/khnewcred.h b/src/windows/identity/uilib/khnewcred.h index ff693b3b1..257434454 100644 --- a/src/windows/identity/uilib/khnewcred.h +++ b/src/windows/identity/uilib/khnewcred.h @@ -229,6 +229,10 @@ typedef struct tag_khui_new_creds { CRITICAL_SECTION cs; + khm_boolean set_default; /*!< After a successfull credentials + acquisition, set the primary + identity as the default. */ + khm_handle *identities; /*!< The list of identities associated with this request. The first identity in this list (\a diff --git a/src/windows/identity/uilib/khremote.h b/src/windows/identity/uilib/khremote.h index accff416b..5de877da6 100644 --- a/src/windows/identity/uilib/khremote.h +++ b/src/windows/identity/uilib/khremote.h @@ -33,7 +33,7 @@ @{*/ /* Leash compatibility */ -#define ID_OBTAIN_TGT_WITH_LPARAM 32809 +#define ID_OBTAIN_TGT_WITH_LPARAM 32810 #define KHUI_REQDAEMONWND_CLASS L"IDMgrRequestDaemonCls" #define KHUI_REQDAEMONWND_NAME L"IDMgrRequestDaemon" @@ -43,7 +43,7 @@ #define NETID_USERNAME_SZ 128 #define NETID_REALM_SZ 192 #define NETID_TITLE_SZ 256 -#define NETID_CCACHE_NAME_SZ 264 +#define NETID_CCACHE_NAME_SZ 264 #define NETID_DLGTYPE_TGT 0 #define NETID_DLGTYPE_CHPASSWD 1 diff --git a/src/windows/identity/util/hashtable.c b/src/windows/identity/util/hashtable.c index d1b02e64f..1a4233d51 100644 --- a/src/windows/identity/util/hashtable.c +++ b/src/windows/identity/util/hashtable.c @@ -44,7 +44,7 @@ KHMEXP hashtable * KHMAPI hash_new_hashtable(khm_int32 n, h->delr = delr; h->hash = hash; - h->bins = calloc(sizeof(hash_bin *), n); + h->bins = PCALLOC(sizeof(hash_bin *), n); return h; } diff --git a/src/windows/identity/util/perfstat.c b/src/windows/identity/util/perfstat.c index 2ddcedb2c..814920dce 100644 --- a/src/windows/identity/util/perfstat.c +++ b/src/windows/identity/util/perfstat.c @@ -125,6 +125,22 @@ perf_strdup(char * file, int line, const char * str) { return dest; } +KHMEXP void * +perf_calloc(char * file, int line, size_t num, size_t size) { + void * ptr; + size_t tsize; + + tsize = num * size; + + ptr = perf_malloc(file,line,tsize); + + if (ptr) { + ZeroMemory(ptr, tsize); + } + + return ptr; +} + KHMEXP void * perf_malloc(char * file, int line, size_t s) { allocation * a; diff --git a/src/windows/identity/util/perfstat.h b/src/windows/identity/util/perfstat.h index ad620fd57..d8d5951b3 100644 --- a/src/windows/identity/util/perfstat.h +++ b/src/windows/identity/util/perfstat.h @@ -31,6 +31,7 @@ #ifdef DEBUG #define PMALLOC(s) perf_malloc(__FILE__,__LINE__,s) +#define PCALLOC(n,s) perf_calloc(__FILE__,__LINE__,n,s) #define PREALLOC(d,s) perf_realloc(__FILE__,__LINE__,d,s) #define PFREE(p) perf_free(p) #define PDUMP(f) perf_dump(f) @@ -38,6 +39,7 @@ #define PSTRDUP(s) perf_strdup(__FILE__,__LINE__,s) #else #define PMALLOC(s) malloc(s) +#define PCALLOC(n,s) calloc(n,s) #define PREALLOC(d,s) realloc(d,s) #define PFREE(p) free(p) #define PDUMP(f) ((void) 0) @@ -63,4 +65,7 @@ perf_wcsdup(char * file, int line, const wchar_t * str); KHMEXP char * perf_strdup(char * file, int line, const char * str); +KHMEXP void * +perf_calloc(char * file, int line, size_t num, size_t size); + #endif