--- /dev/null
+2005-11-29 Jeffrey Altman <jaltman@mit.edu>\r
+\r
+Second Beta of KFW 3.0.0:\r
+\r
+All features completed except for:\r
+\r
+ * Debug Window\r
+\r
+ * KRB5.INI (aka Realm) Editor\r
+\r
+ * Column Selection\r
+\r
+ * Graphics are incomplete\r
+\r
+ * Documentation is incomplete\r
+\r
+\r
+ \r
+\r
start:\r
\r
config: start\r
- $(ECHO) Entering $@:\r
+ $(ECHO) -- Entering $@:\r
$(CD) $@\r
$(RMAKE)\r
$(CD) ..\r
- $(ECHO) Done with $@\r
+ $(ECHO) -- Done with $@\r
\r
include: config\r
- $(ECHO) Entering $@:\r
+ $(ECHO) -- Entering $@:\r
$(CD) $@\r
$(RMAKE)\r
$(CD) ..\r
- $(ECHO) Done with $@\r
+ $(ECHO) -- Done with $@\r
\r
util: include\r
- $(ECHO) Entering $@:\r
+ $(ECHO) -- Entering $@:\r
$(CD) $@\r
$(RMAKE)\r
$(CD) ..\r
- $(ECHO) Done with $@\r
+ $(ECHO) -- Done with $@\r
\r
kherr: util\r
- $(ECHO) Entering $@:\r
+ $(ECHO) -- Entering $@:\r
$(CD) $@\r
$(RMAKE)\r
$(CD) ..\r
- $(ECHO) Done with $@\r
+ $(ECHO) -- Done with $@\r
\r
kconfig: kherr\r
- $(ECHO) Entering $@:\r
+ $(ECHO) -- Entering $@:\r
$(CD) $@\r
$(RMAKE)\r
$(CD) ..\r
- $(ECHO) Done with $@\r
+ $(ECHO) -- Done with $@\r
\r
kmq: kconfig\r
- $(ECHO) Entering $@:\r
+ $(ECHO) -- Entering $@:\r
$(CD) $@\r
$(RMAKE)\r
$(CD) ..\r
- $(ECHO) Done with $@\r
+ $(ECHO) -- Done with $@\r
\r
kcreddb: kmq\r
- $(ECHO) Entering $@:\r
+ $(ECHO) -- Entering $@:\r
$(CD) $@\r
$(RMAKE)\r
$(CD) ..\r
- $(ECHO) Done with $@\r
+ $(ECHO) -- Done with $@\r
\r
kmm: kcreddb\r
- $(ECHO) Entering $@:\r
+ $(ECHO) -- Entering $@:\r
$(CD) $@\r
$(RMAKE)\r
$(CD) ..\r
- $(ECHO) Done with $@\r
+ $(ECHO) -- Done with $@\r
\r
help: kmm\r
- $(ECHO) Entering $@:\r
+ $(ECHO) -- Entering $@:\r
$(CD) $@\r
$(RMAKE)\r
$(CD) ..\r
- $(ECHO) Done with $@\r
+ $(ECHO) -- Done with $@\r
\r
uilib: help\r
- $(ECHO) Entering $@:\r
+ $(ECHO) -- Entering $@:\r
$(CD) $@\r
$(RMAKE)\r
$(CD) ..\r
- $(ECHO) Done with $@\r
+ $(ECHO) -- Done with $@\r
\r
nidmgrdll: uilib\r
- $(ECHO) Entering $@\r
+ $(ECHO) -- Entering $@\r
$(CD) $@\r
$(RMAKE)\r
$(CD) ..\r
- $(ECHO) Done with $@\r
+ $(ECHO) -- Done with $@\r
\r
ui: nidmgrdll\r
- $(ECHO) Entering $@:\r
+ $(ECHO) -- Entering $@:\r
$(CD) $@\r
$(RMAKE)\r
$(CD) ..\r
- $(ECHO) Done with $@\r
+ $(ECHO) -- Done with $@\r
\r
# Now build the plugins\r
plugincommon: ui\r
- $(ECHO) Entering $@\r
+ $(ECHO) -- Entering $@\r
$(CD) plugins\common\r
$(RMAKE)\r
$(CD) ..\..\r
- $(ECHO) Done with $@\r
+ $(ECHO) -- Done with $@\r
\r
krb5plugin: plugincommon\r
- $(ECHO) Entering $@\r
+ $(ECHO) -- Entering $@\r
$(CD) plugins\krb5\r
$(RMAKE)\r
$(CD) ..\..\r
- $(ECHO) Done with $@\r
+ $(ECHO) -- Done with $@\r
\r
!ifndef NO_KRB4\r
finale: krb4plugin\r
\r
krb4plugin: plugincommon\r
- $(ECHO) Entering $@\r
+ $(ECHO) -- Entering $@\r
$(CD) plugins\krb4\r
$(RMAKE)\r
$(CD) ..\..\r
- $(ECHO) Done with $@\r
+ $(ECHO) -- Done with $@\r
+!endif\r
+\r
+!ifdef BUILD_AFS\r
+finale: afsplugin\r
+\r
+afsplugin: plugincommon\r
+ $(ECHO) -- Entering $@\r
+ $(CD) plugins\afs\r
+ $(RMAKE)\r
+ $(CD) ..\..\r
+ $(ECHO) -- Done with $@\r
!endif\r
\r
finale: krb5plugin\r
- $(ECHO) Done.\r
+ $(ECHO) -- Done.\r
\r
pdoc:\r
\r
doc: pdoc\r
- $(ECHO) Entering $@:\r
+ $(ECHO) -- Entering $@:\r
$(CD) $@\r
$(RMAKE)\r
$(CD) ..\r
- $(ECHO) Done with $@\r
+ $(ECHO) -- Done with $@\r
\r
clean::\r
$(MAKECMD) /nologo CLEANRUN=1\r
--- /dev/null
+# Copyright (c) 2004 Massachusetts Institute of Technology\r
+#\r
+# Permission is hereby granted, free of charge, to any person\r
+# obtaining a copy of this software and associated documentation files\r
+# (the "Software"), to deal in the Software without restriction,\r
+# including without limitation the rights to use, copy, modify, merge,\r
+# publish, distribute, sublicense, and/or sell copies of the Software,\r
+# and to permit persons to whom the Software is furnished to do so,\r
+# subject to the following conditions:\r
+#\r
+# The above copyright notice and this permission notice shall be\r
+# included in all copies or substantial portions of the Software.\r
+#\r
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+# SOFTWARE.\r
+\r
+\r
+# This file documents the versions of the API for NetIDMgr. The\r
+# syntax of the file is:\r
+#\r
+# Version=<api-version number>\r
+# AppVersion=<netidmgr-version>\r
+# Date=<release date> | NOTRELEASED\r
+# # <comments>\r
+# <symbol-name>\r
+# # comment\r
+# Schema:<path-to-schema>\r
+# # comment\r
+\r
+\r
+#----------------------------------------------------------------\r
+Version=1\r
+AppVersion=0.1.0.0\r
+Date=NOTRELEASED\r
+# Original Khimaira API.\r
+\r
+#----------------------------------------------------------------\r
+Version=2\r
+AppVersion=0.1.1.0\r
+Date=Nov 01, 2005\r
+# Alpha release of NetIDMgr\r
+\r
+#----------------------------------------------------------------\r
+Version=3\r
+AppVersion=0.1.2.0\r
+Date=NOTRELEASED\r
+# Beta release\r
+\r
MODULE=config\r
!include <Makefile.w32>\r
\r
-all: mkalldirs mkversion\r
+all: showvars mkalldirs mkversion\r
+\r
+showvars:\r
+ $(ECHO) SRC= $(SRC)\r
+ $(ECHO) DESTDIR = $(DESTDIR)\r
+ $(ECHO) OBJDIR = $(OBJDIR)\r
+ $(ECHO).\r
+ $(ECHO) CC = $(CC)\r
+ $(ECHO) DOXYGEN = $(DOXYGEN)\r
+ $(ECHO) HHC = $(HHC)\r
\r
mkalldirs:\r
! if !exist($(DESTROOT))\r
! endif\r
$(ECHO) Done creating directories.\r
\r
-VERSIONINC=$(INCDIR)\khimaira_version.h\r
+VERSIONINT=$(INCDIR)\netidmgr_intver.h\r
+\r
+VERSIONEXT=$(INCDIR)\netidmgr_version.h\r
\r
# Version related defines\r
\r
kh_filetype_app=VFT_APP\r
kh_filetype_dll=VFT_DLL\r
\r
-mkversion: $(VERSIONINC)\r
-\r
-$(VERSIONINC): Makefile\r
- $(CP) << $(VERSIONINC)\r
-/*\r
- * This is an autogenerated file. Do not modify directly.\r
- * \r
- * File generated by running $(MAKE) in $(MAKEDIR)\r
- * To regenerate, run "$(MAKE) clean" and "$(MAKE) all" on $(MAKEDIR)\r
- */\r
-#ifndef __KHIMAIRA_VERSION_H\r
-#define __KHIMAIRA_VERSION_H\r
-\r
-/* Version number macros */\r
-#define KH_VERSION_MAJOR $(KHIMAIRA_VERSION_MAJOR)\r
-#define KH_VERSION_MINOR $(KHIMAIRA_VERSION_MINOR)\r
-#define KH_VERSION_PATCH $(KHIMAIRA_VERSION_PATCH)\r
-#define KH_VERSION_AUX $(KHIMAIRA_VERSION_AUX)\r
-#define KH_VERSION_LIST $(KHIMAIRA_VERSIONC)\r
-#define KH_VERSION_STRING "$(KHIMAIRA_VERSION)"\r
-#define KH_VERSION_STRINGW L"$(KHIMAIRA_VERSION)"\r
-#define KH_VERSION_STRINGC "$(KHIMAIRA_VERSIONC)"\r
-#define KH_VERSION_STRINGCW L"$(KHIMAIRA_VERSIONC)"\r
-\r
-/* Version definition macros */\r
-#define KH_VER_FILEFLAGS $(kh_fileflags)\r
-#define KH_VER_FILEOS $(kh_fileos)\r
-#define KH_VER_FILETYPEDLL $(kh_filetype_dll)\r
-#define KH_VER_FILETYPEAPP $(kh_filetype_app)\r
-\r
-/* Language specific version strings */\r
-#define KH_VERSTR_COMPANY_1033 "$(KHIMAIRA_SRC_COMPANY_1033)"\r
-#define KH_VERSTR_COPYRIGHT_1033 "$(KHIMAIRA_SRC_COPYRIGHT_1033)"\r
-#define KH_VERSTR_PRODUCT_1033 "$(KHIMAIRA_PRODUCT_1033)"\r
-#define KH_VERSTR_VERSION_1033 "$(KHIMAIRA_VERSION_STR_1033)"\r
-\r
-!ifdef KHIMAIRA_COMMENT_STR_1033\r
-#define KH_VERSTR_COMMENT_1033 "$(KHIMAIRA_COMMENT_STR_1033)"\r
-#define KH_VERSTR_BUILDINFO_1033 KH_VERSTR_COMMENT_1033\r
+mkversion: $(VERSIONINT) $(VERSIONEXT)\r
+\r
+# Version and build strings\r
+\r
+!if "$(KH_RELEASE)" == "OFFICIAL"\r
+NETIDMGR_VERSION_STR_1033=$(NETIDMGR_VERSION)\r
+NETIDMGR_COMMENT_STR_1033=Official build. Please send bug reports to kfw-bugs@MIT.EDU\r
+!elseif "$(KH_RELEASE)" == "PRERELEASE"\r
+NETIDMGR_VERSION_STR_1033=$(NETIDMGR_VERSION) Alpha\r
+NETIDMGR_COMMENT_STR_1033=Prerelease build. Please send bug reports to kfw-bugs@MIT.EDU\r
+!elseif "$(KH_RELEASE)" == "PRIVATE"\r
+NETIDMGR_VERSION_STR_1033=$(NETIDMGR_VERSION).PRIVATE\r
+NETIDMGR_PRIVATE_STR_1033=Private build. Please send bug reports to kfw-bugs@MIT.EDU\r
+!elseif "$(KH_RELEASE)" == "SPECIAL"\r
+NETIDMGR_VERSION_STR_1033=$(NETIDMGR_VERSION).SPECIAL\r
+NETIDMGR_SPECIAL_STR_1033=Special build. Please send bug reports to kfw-bugs@MIT.EDU\r
!endif\r
-!ifdef KHIMAIRA_PRIVATE_STR_1033\r
-#define KH_VERSTR_PRIVATE_1033 "$(KHIMAIRA_PRIVATE_STR_1033)"\r
-#define KH_VERSTR_BUILDINFO_1033 KH_VERSTR_PRIVATE_1033\r
-!endif\r
-!ifdef KHIMAIRA_SPECIAL_STR_1033\r
-#define KH_VERSTR_SPECIAL_1033 "$(KHIMAIRA_SPECIAL_STR_1033)"\r
-#define KH_VERSTR_BUILDINFO_1033 KH_VERSTR_SPECIAL_1033\r
+\r
+!if "$(KH_BUILD)" == "DEBUG"\r
+NETIDMGR_VERSION_STR_1033=$(NETIDMGR_VERSION_STR_1033).DEBUG\r
+!else\r
!endif\r
-#endif\r
-<<\r
+\r
+NETIDMGR_PRODUCT_1033=NetIDMgr $(NETIDMGR_VERSION_STR_1033)\r
+\r
+!include netidmgr_version.h.in\r
+\r
+!include netidmgr_intver.h.in\r
\r
clean::\r
-! if exist($(VERSIONINC))\r
- $(RM) $(VERSIONINC)\r
+! if exist($(VERSIONINT))\r
+ $(RM) $(VERSIONINT)\r
+! endif\r
+! if exist($(VERSIONEXT))\r
+ $(RM) $(VERSIONEXT)\r
! endif\r
\r
# SPECIAL : Special build. Typically one with non-mainline patches.\r
\r
# Version info\r
-KHIMAIRA_VERSION_MAJOR=0\r
-KHIMAIRA_VERSION_MINOR=1\r
-KHIMAIRA_VERSION_PATCH=1\r
-KHIMAIRA_VERSION_AUX=0\r
-KHIMAIRA_VERSION=$(KHIMAIRA_VERSION_MAJOR).$(KHIMAIRA_VERSION_MINOR).$(KHIMAIRA_VERSION_PATCH).$(KHIMAIRA_VERSION_AUX)\r
-KHIMAIRA_VERSIONC=$(KHIMAIRA_VERSION_MAJOR),$(KHIMAIRA_VERSION_MINOR),$(KHIMAIRA_VERSION_PATCH),$(KHIMAIRA_VERSION_AUX)\r
+NETIDMGR_VERSION_MAJOR=0\r
+NETIDMGR_VERSION_MINOR=1\r
+NETIDMGR_VERSION_PATCH=2\r
+NETIDMGR_VERSION_AUX=0\r
+\r
+# The API version. This number must be incremented each time the API\r
+# changes. Plugins specify the version of the API that they were\r
+# compiled against and the Module Manager uses the API numbers to\r
+# decide whether the plugin is safe to load or not.\r
+#\r
+# Changes to the API version numbers should be documented in\r
+# apiversion.txt at the root of the source tree.\r
+NETIDMGR_VERSION_API=3\r
\r
-# Source information\r
-KHIMAIRA_SRC_COMPANY_1033=Massachusetts Institute of Technology\r
+NETIDMGR_VERSION=$(NETIDMGR_VERSION_MAJOR).$(NETIDMGR_VERSION_MINOR).$(NETIDMGR_VERSION_PATCH).$(NETIDMGR_VERSION_AUX)\r
+NETIDMGR_VERSIONC=$(NETIDMGR_VERSION_MAJOR),$(NETIDMGR_VERSION_MINOR),$(NETIDMGR_VERSION_PATCH),$(NETIDMGR_VERSION_AUX)\r
\r
-KHIMAIRA_SRC_COPYRIGHT_1033=(C) 2005 Massachusetts Institute of Technology\r
+# Source information\r
+NETIDMGR_SRC_COMPANY_1033=Massachusetts Institute of Technology\r
+NETIDMGR_SRC_COPYRIGHT_1033=(C) 2005 Massachusetts Institute of Technology\r
\r
# Choose the default build type if one is not set\r
!if ("$(KH_BUILD)" != "DEBUG") && ("$(KH_BUILD)" != "RETAIL")\r
KH_RELEASE=PRERELEASE\r
!endif\r
\r
-# Version and build strings\r
-\r
-!if "$(KH_RELEASE)" == "OFFICIAL"\r
-KHIMAIRA_VERSION_STR_1033=$(KHIMAIRA_VERSION)\r
-KHIMAIRA_COMMENT_STR_1033=Official build.\r
-!elseif "$(KH_RELEASE)" == "PRERELEASE"\r
-KHIMAIRA_VERSION_STR_1033=$(KHIMAIRA_VERSION) Alpha\r
-KHIMAIRA_COMMENT_STR_1033=Prerelease build.\r
-!elseif "$(KH_RELEASE)" == "PRIVATE"\r
-KHIMAIRA_VERSION_STR_1033=$(KHIMAIRA_VERSION).PRIVATE\r
-KHIMAIRA_PRIVATE_STR_1033=Private build.\r
-!elseif "$(KH_RELEASE)" == "SPECIAL"\r
-KHIMAIRA_VERSION_STR_1033=$(KHIMAIRA_VERSION).SPECIAL\r
-KHIMAIRA_SPECIAL_STR_1033=Special build.\r
-!endif\r
-\r
-!if "$(KH_BUILD)" == "DEBUG"\r
-KHIMAIRA_VERSION_STR_1033=$(KHIMAIRA_VERSION_STR_1033).DEBUG\r
-!else\r
-!endif\r
-\r
-KHIMAIRA_PRODUCT_1033=NetIDMgr $(KHIMAIRA_VERSION_STR_1033)\r
+# Actual build environment settings\r
\r
# See what compiler we are using\r
# TODO: Update this to support other compilers\r
! error MODULE must be specified\r
!endif\r
!ifndef KH_ROOT\r
+! ifndef PISMERE\r
+! error Either KH_ROOT or PISMERE must be defined\r
+! else\r
KH_ROOT=$(PISMERE)\athena\auth\krb5\src\windows\identity\r
+! endif\r
!endif\r
\r
!ifdef NODEBUG\r
\r
\r
# Output directory structure\r
-DESTROOT=$(KH_ROOT)\dest\r
+DESTROOT=$(KH_ROOT)\obj\r
OBJROOT=$(KH_ROOT)\obj\r
SRC=$(KH_ROOT)\r
\r
OBJDIR=$(OBJROOT)\$(CPU)\$(OUTPRE_DBG)\r
\r
OBJ=$(OBJDIR)\$(MODULE)\r
-INCDIR=$(DESTDIR)\include\r
+INCDIR=$(DESTDIR)\inc\r
#BINDIR=$(DESTDIR)\bin\r
BINDIR=$(KH_ROOT)\$(OUTPRE)\r
#LIBDIR=$(DESTDIR)\lib\r
KFWINCDIR=$(KH_KFWPATH)\inc\r
kfwincflags = -I$(KFWINCDIR)\krb5 -I$(KFWINCDIR)\krb5\KerberosIV -I$(KFWINCDIR)\loadfuncs -I$(KFWINCDIR)\r
KFWLIBDIR=$(KH_KFWPATH)\lib\$(CPU)\r
-!else\r
+!else if defined(PISMERE)\r
KFWINCDIR=$(PISMERE)\athena\auth\krb5\src\include\r
kfwincflags = -I$(KFWINCDIR) -I$(PISMERE)\athena\util\loadfuncs -I$(PISMERE)\athena\auth\krb5\src\include\kerberosIV -I$(PISMERE)\athena\auth\krb4\include\r
KFWLIBDIR=$(PISMERE)\target\lib\$(CPU)\$(OUTPRE_DBG)\r
\r
.SUFFIXES: .h\r
\r
+.SILENT:\r
+\r
!endif\r
--- /dev/null
+$(VERSIONINT): Makefile\r
+ $(CP) << $(VERSIONINT)\r
+/*\r
+ * This is an autogenerated file. Do not modify directly.\r
+ * \r
+ * File generated by running $(MAKE) in $(MAKEDIR)\r
+ * To regenerate, run "$(MAKE) clean" and "$(MAKE) all" on $(MAKEDIR)\r
+ */\r
+#ifndef __NETIDMGR_VERSION_INTERNAL_H\r
+#define __NETIDMGR_VERSION_INTERNAL_H\r
+\r
+#include<netidmgr_version.h>\r
+\r
+/* Language specific version strings */\r
+#define KH_VERSTR_COMPANY_1033 "$(NETIDMGR_SRC_COMPANY_1033)"\r
+#define KH_VERSTR_COPYRIGHT_1033 "$(NETIDMGR_SRC_COPYRIGHT_1033)"\r
+#define KH_VERSTR_PRODUCT_1033 "$(NETIDMGR_PRODUCT_1033)"\r
+#define KH_VERSTR_VERSION_1033 "$(NETIDMGR_VERSION_STR_1033)"\r
+\r
+!ifdef NETIDMGR_COMMENT_STR_1033\r
+#define KH_VERSTR_COMMENT_1033 "$(NETIDMGR_COMMENT_STR_1033)"\r
+#define KH_VERSTR_BUILDINFO_1033 KH_VERSTR_COMMENT_1033\r
+!endif\r
+!ifdef NETIDMGR_PRIVATE_STR_1033\r
+#define KH_VERSTR_PRIVATE_1033 "$(NETIDMGR_PRIVATE_STR_1033)"\r
+#define KH_VERSTR_BUILDINFO_1033 KH_VERSTR_PRIVATE_1033\r
+!endif\r
+!ifdef NETIDMGR_SPECIAL_STR_1033\r
+#define KH_VERSTR_SPECIAL_1033 "$(NETIDMGR_SPECIAL_STR_1033)"\r
+#define KH_VERSTR_BUILDINFO_1033 KH_VERSTR_SPECIAL_1033\r
+!endif\r
+#endif\r
+<<\r
+\r
--- /dev/null
+$(VERSIONEXT): Makefile\r
+ $(CP) << $(VERSIONEXT)\r
+/* Copyright (c) 2004 Massachusetts Institute of Technology\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ *\r
+ */\r
+\r
+#ifndef __NETIDMGR_VERSION_H\r
+#define __NETIDMGR_VERSION_H\r
+\r
+#include<windows.h>\r
+\r
+/* Version number macros */\r
+#define KH_VERSION_MAJOR $(NETIDMGR_VERSION_MAJOR)\r
+#define KH_VERSION_MINOR $(NETIDMGR_VERSION_MINOR)\r
+#define KH_VERSION_PATCH $(NETIDMGR_VERSION_PATCH)\r
+#define KH_VERSION_AUX $(NETIDMGR_VERSION_AUX)\r
+\r
+#define KH_VERSION_API $(NETIDMGR_VERSION_API)\r
+\r
+#define KH_VERSION_LIST $(NETIDMGR_VERSIONC)\r
+#define KH_VERSION_STRING "$(NETIDMGR_VERSION)"\r
+#define KH_VERSION_STRINGW L"$(NETIDMGR_VERSION)"\r
+#define KH_VERSION_STRINGC "$(NETIDMGR_VERSIONC)"\r
+#define KH_VERSION_STRINGCW L"$(NETIDMGR_VERSIONC)"\r
+#define KH_VERSION_STRINGAPI "$(NETIDMGR_VERSION_API)"\r
+\r
+/* Version definition macros */\r
+#define KH_VER_FILEFLAGMASK 0x17L\r
+#define KH_VER_FILEFLAGS $(kh_fileflags)\r
+#define KH_VER_FILEOS $(kh_fileos)\r
+#define KH_VER_FILETYPEDLL $(kh_filetype_dll)\r
+#define KH_VER_FILETYPEAPP $(kh_filetype_app)\r
+\r
+/* Special macros for NetIDMgr special string resources */\r
+#define NIMV_MODULE "NIDM_Module"\r
+#define NIMV_PLUGINS "NIDM_Plugins"\r
+#define NIMV_APIVER "NIDM_APIVers"\r
+#define NIMV_SUPPORT "NIDM_Support"\r
+\r
+#endif\r
+<<\r
+\r
MODULE=doc\r
!include <../config/Makefile.w32>\r
\r
-CONFFILE=$(OBJ)\DoxyConf.cfg\r
-\r
all: mkdirs docs\r
\r
docs:\r
\r
WARN_LOGFILE = "$(OBJ)\doxywarnings.txt"\r
\r
-INPUT = "$(SRC)\include"\r
+INPUT = "$(SRC)\include"\r
INPUT += "$(SRC)\kconfig"\r
INPUT += "$(SRC)\kcreddb"\r
-INPUT += "$(SRC)\khlog"\r
INPUT += "$(SRC)\kmq"\r
INPUT += "$(SRC)\ui"\r
INPUT += "$(SRC)\uilib"\r
INPUT += "$(SRC)\doc"\r
INPUT += "$(SRC)\kmm"\r
INPUT += "$(SRC)\kherr"\r
+!ifndef NO_AFS\r
+INPUT += "$(SRC)\plugins\afs"\r
+!endif\r
\r
IMAGE_PATH = "$(SRC)\doc\images"\r
\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
khui_new_creds_by_type * t;\r
\r
c = (khui_new_creds *) vparam;\r
- t = malloc(sizeof(*t));\r
+ t = PMALLOC(sizeof(*t));\r
ZeroMemory(t, sizeof(*t));\r
\r
t->type = my_cred_type;\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
\r
(Contributor list goes here)\r
\r
+ At the moment, no contributers have come forward to accept\r
+ responsibility.\r
+\r
<a href="http://web.mit.edu/is">Information Services and\r
Technology</a> at <a href="http://web.mit.edu">Massachusetts\r
Institute of Technology</a>\r
/*! \page bugs Reporting bugs\r
\r
NetIDMgr bugs can be reported to \r
- <a href="mailto:khimaira@mit.edu">khimaira@mit.edu</a> for now.\r
+ <a href="mailto:kfw-bugs@mit.edu">kfw-bugs@mit.edu</a> for now.\r
\r
In the future, there will actually be a place to track NetIDMgr bugs.\r
\r
\r
/*! \page releases Prior releases\r
\r
- - <b>0.1.1</b> (Charles Manson) <em>[soon]</em>\n\r
- First alpha release. As stable as Charles Manson, hence the\r
- name.\r
+ - <b>0.1.1</b> First Alpha release <em>Nov 01, 2005</em>\n\r
+ Released along with Kerberos for Windows 3.0.0 beta.\r
\r
- <b>0.1.2</b> (tbd) <em>[tbd]</em>\n\r
- First beta release.\r
*/\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
MODULE=help\r
!include <..\config\Makefile.w32>\r
\r
-CHMFILE=$(DOCDIR)\netidmgr.chm\r
+CHMFILE=$(BINDIR)\netidmgr.chm\r
\r
INCFILES=$(INCDIR)\khhelp.h\r
\r
--- /dev/null
+<html>\r
+<head>\r
+ <title>About Network Identity Manager</title>\r
+ <meta name="description" content="About NetIDMgr">\r
+ <meta name="keywords" content="">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+<h1>About Network Identity Manager</h1>\r
+\r
+<p>\r
+This is strictly an informative page about the origins of Network\r
+Identity Manager.\r
+</p>\r
+\r
+<h3>In the beginning</h3>\r
+\r
+<p>\r
+Network Identity Manager was conceived as an identity management\r
+solution to make up for the shortcomings of Leash32 (distributed with\r
+MIT Kerberos for Windows) and AFSCREDS (distributed with OpenAFS).\r
+</p>\r
+\r
+<p>\r
+The work started as Unified Credentials Manager, a final project for\r
+the MIT course 6.831 : User Interface Design and Implementation,\r
+taught by <a href="http://people.csail.mit.edu/rcm/">Professor Rob\r
+Miller</a>. By the time actual code was written, it was named\r
+Khimaira (which was later changed to Network Identity Manager around\r
+October, 2005). Traces of the name Khimaira might still exist in the\r
+source code.\r
+</p>\r
+\r
+<p>\r
+A presentation given about Khimaira at the <a\r
+href="http://www.pmw.org/afsbpw05/">AFS and Kerberos Best Practices\r
+Workshop 2005</a> can be found on the workshop website and <a\r
+href="http://web.mit.edu/asanka/www/misc.shtml">here</a>.\r
+</p>\r
+\r
+<p>\r
+The work on Khimaira was funded by <a\r
+href="http://web.mit.edu">MIT</a> <a\r
+href="http://web.mit.edu/ist/">Information Services and\r
+Technology</a>.\r
+</p>\r
+\r
+<h3>Design</h3>\r
+\r
+<p>\r
+A plugin based architecture was chosen so that support for additional\r
+credential types and features could be added without making changes to\r
+the mainline code. In addition to making the application easily\r
+extensible, this also allows the AFS plugin to be maintained within\r
+the OpenAFS code base and separates the code supporting Kerberos 5 and\r
+Kerberos 4. Furthermore, it is anticipated that this would encourage\r
+third party developers to develop plugins for NetIDMgr.\r
+</p>\r
+\r
+<p>\r
+More information about the concepts used in the design of Network\r
+Identity Manager can be found <a href="concepts.htm">here</a>.\r
+</p>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
<title>title</title>\r
<meta name="description" content="">\r
<meta name="keywords" content="">\r
- <link rel="stylesheet" type="text/css" href="khm.css">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
</head>\r
+<body>\r
\r
+</body>\r
</html>
\ No newline at end of file
<title>title</title>\r
<meta name="description" content="">\r
<meta name="keywords" content="">\r
- <link rel="stylesheet" type="text/css" href="khm.css">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
</head>\r
+<body>\r
\r
+</body>\r
</html>
\ No newline at end of file
--- /dev/null
+<html>\r
+<head>\r
+ <title>title</title>\r
+ <meta name="description" content="">\r
+ <meta name="keywords" content="">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
--- /dev/null
+<html>\r
+<head>\r
+ <title>title</title>\r
+ <meta name="description" content="">\r
+ <meta name="keywords" content="">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
--- /dev/null
+<html>\r
+<head>\r
+ <title>title</title>\r
+ <meta name="description" content="">\r
+ <meta name="keywords" content="">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
--- /dev/null
+<html>\r
+<head>\r
+ <title>title</title>\r
+ <meta name="description" content="">\r
+ <meta name="keywords" content="">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
--- /dev/null
+<html>\r
+<head>\r
+ <title>Reporting Bugs</title>\r
+ <meta name="description" content="Reporting bugs and feature requests">\r
+ <meta name="keywords" content="bugs,features">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+<h1>Reporting Bugs</h1>\r
+\r
+<p>If you encounter a bug in the software, please email \r
+<a href="mailto:kfw-bugs@MIT.EDU" class="mail">kfw-bugs@MIT.EDU</a>\r
+and report it. Please include as much information as possible to\r
+enable us to reproduce the problem.\r
+</p>\r
+\r
+<p><a href="mailto:kerberos@MIT.EDU" class="mail">kerberos@MIT.EDU</a>\r
+is a mailing list set up for discussing Kerberos issues. It is\r
+gatewayed to the Usenet newsgroup 'comp.protocols.kerberos'. If you\r
+prefer to read it via mail, send a request to kerberos-request@MIT.EDU\r
+to get added or subscribe via the web page:</p>\r
+\r
+<p> <a href="http://mailman.mit.edu/mailman/listinfo/kerberos"\r
+class="external">\r
+http://mailman.mit.edu/mailman/listinfo/kerberos</a></p>\r
+\r
+<p>Information about Kerberos mailing lists can be found at <a\r
+href="http://web.mit.edu/kerberos/mail-lists.html"\r
+class="external">http://web.mit.edu/kerberos/mail-lists.html</a></p>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
--- /dev/null
+<html>\r
+<head>\r
+ <title>title</title>\r
+ <meta name="description" content="">\r
+ <meta name="keywords" content="">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
--- /dev/null
+<html>\r
+<head>\r
+ <title>title</title>\r
+ <meta name="description" content="">\r
+ <meta name="keywords" content="">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
--- /dev/null
+<html>\r
+<head>\r
+ <title>title</title>\r
+ <meta name="description" content="">\r
+ <meta name="keywords" content="">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
--- /dev/null
+<html>\r
+<head>\r
+ <title>title</title>\r
+ <meta name="description" content="">\r
+ <meta name="keywords" content="">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
--- /dev/null
+<html>\r
+<head>\r
+ <title>License</title>\r
+ <meta name="description" content="License agreement">\r
+ <meta name="keywords" content="license">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+<h1>Network Identity Manager License</h1>\r
+\r
+<p>This software is being provided to you, the LICENSEE, by the\r
+Massachusetts Institute of Technology (M.I.T) under the following\r
+license. By obtaining, using and/or copying this software, you agree\r
+that you have read, understood, and will comply with these terms and\r
+conditions:</p>\r
+\r
+<p>Permission to use, copy, modify and distribute this software and its\r
+documentation for any purpose and without fee or royalty is hereby\r
+granted, provided that you agree to comply with the following\r
+copyright notice and statements, including the disclaimer, and that\r
+the same appear on ALL copies of the software and documentation,\r
+including modifications that you make for internal use or for\r
+distribution:</p>\r
+\r
+<p>Copyright 1992-2005 by the Massachusetts Institute of Technology. All\r
+rights reserved.</p>\r
+\r
+<p>THIS SOFTWARE IS PROVIDED "AS IS", AND M.I.T. MAKES NO REPRESENTATIONS\r
+OR WARRANTIES, EXPRESS OR IMPLIED. By way of example, but not\r
+limitation, M.I.T. MAKES NO REPRESENTATIONS OR WARRANTIES OF\r
+MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE\r
+OF THE LICENSED SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD\r
+PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.</p>\r
+\r
+<p>The name of the Massachusetts Institute of Technology or M.I.T. may\r
+NOT be used in advertising or publicity pertaining to distribution of\r
+the software. Title to copyright in this software and any associated\r
+documentation shall at all times remain with M.I.T., and USER agrees\r
+to preserve same.</p>\r
+\r
+<p>Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira,\r
+OLC, X Window System, and Zephyr are trademarks of the Massachusetts\r
+Institute of Technology (MIT). No commercial use of these trademarks\r
+may be made without prior written permission of MIT.</p>\r
+\r
+</body>\r
+</html>\r
--- /dev/null
+<html>\r
+<head>\r
+ <title>How do I ...</title>\r
+ <meta name="description" content="How do I ...">\r
+ <meta name="keywords" content="howto, how do I">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+<h1>How do I ...</h1>\r
+\r
+<h3>Startup</h3>\r
+<ul>\r
+\r
+ <li><a href="use_start.htm">Start NetIDMgr or open the NetIDMgr\r
+ window</a></li>\r
+\r
+</ul>\r
+\r
+<h3>Credentials related actions</h3>\r
+<ul>\r
+\r
+ <li><a href="act_new_creds.htm">Get new credentials</a></li>\r
+\r
+ <li><a href="act_destroy_creds.htm">Destroy credentials</a></li>\r
+\r
+ <li><a href="act_import_creds.htm">Import credentials from the MSLSA\r
+ cache</a></li>\r
+\r
+ <li><a href="act_renew_creds.htm">Renew credentials</a></li>\r
+\r
+ <li><a href="act_chpw.htm">Change password</a></li>\r
+\r
+</ul>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
+++ /dev/null
-BODY { font-family:helvetica,sans-serif;\r
- font-size:8pt; \r
- font-style:normal; \r
- background-color:white; }\r
-\r
-H1 { font-size: 10pt;\r
- border:solid 1px black;\r
- padding:5px;\r
- background-color:lightgrey \r
- }\r
-\r
-H2 { }\r
-\r
--- /dev/null
+<html>\r
+<head>\r
+ <title>The Menu Bar</title>\r
+ <meta name="description" content="The Menu Bar">\r
+ <meta name="keywords" content="menu bar">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+<h1>The Menu Bar</h1>\r
+\r
+<p>\r
+Click an item on the menu to go to the description of the submenu, or\r
+choose from the list below. You can activate the menu bar using <span\r
+class="pre">F10</span>. Alternatively, you can activate each\r
+individual submenu by pressing <span class="pre">Alt +\r
+<key></span> where <span class="pre">key</span> is the\r
+highlighted character on the submenu.\r
+</p>\r
+\r
+<map id="menu_bar_map">\r
+<area shape = "rect" coords = "1,0,24,20" href = "menu_file.htm">\r
+<area shape = "rect" coords = "26,1,84,20" href = "menu_credential.htm">\r
+<area shape = "rect" coords = "85,1,118,20" href = "menu_view.htm">\r
+<area shape = "rect" coords = "122,1,165,20" href = "menu_options.htm">\r
+<area shape = "rect" coords = "166,2,199,20" href = "menu_help.htm">\r
+</map>\r
+\r
+<p>\r
+<img src="images/screen_menu_bar.bmp" usemap="#menu_bar_map"/>\r
+</p>\r
+\r
+<ul>\r
+ <li><a href="menu_file.htm">File menu</li>\r
+ <li><a href="menu_credential.htm">Credential menu</li>\r
+ <li><a href="menu_view.htm">View menu</li>\r
+ <li><a href="menu_options.htm">Options menu</li>\r
+ <li><a href="menu_help.htm">Help menu</li>\r
+</ul>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
--- /dev/null
+<html>\r
+<head>\r
+ <title>Credential Menu</title>\r
+ <meta name="description" content="credential menu">\r
+ <meta name="keywords" content="credential menu">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+<h1>Credential Menu</h1>\r
+\r
+<p>\r
+Click an item on the menu to go to the description of the action, or\r
+choose from the list below. You can activate the by pressing <span\r
+class="pre">Alt + C</span> and you can activate each action by\r
+pressing the highlited character.\r
+</p>\r
+\r
+<p>\r
+Actions which have an associated hot key show this hot key to the\r
+right of the action. You can use the hot key to trigger the action\r
+without invoking the <span class="pre">Credential</span> menu.\r
+</p>\r
+\r
+<map id="menumap">\r
+<area shape = "rect" coords = "10,24,214,45" href = "#new">\r
+<area shape = "rect" coords = "8,49,212,70" href = "#renew">\r
+<area shape = "rect" coords = "11,72,199,89" href = "#destroy">\r
+<area shape = "rect" coords = "13,96,213,113" href = "#def">\r
+<area shape = "rect" coords = "14,114,210,133" href = "#search">\r
+<area shape = "rect" coords = "8,137,211,159" href = "#chpw">\r
+<area shape = "rect" coords = "10,165,213,185" href = "#import">\r
+</map>\r
+\r
+<p>\r
+<img src="images/screen_menu_credential.bmp" usemap="#menumap"/>\r
+</p>\r
+\r
+<ul>\r
+ <li><a name="new" /> <span class="title">New Credentials ...</span>:\r
+ Opens the new credentials acquisition dialog box. If an identity\r
+ was selected, then that identity would be made the default for the\r
+ new credentials acquisition. However, it can easily be changed in\r
+ the dialog.\r
+ <p>\r
+ See <span class="pre"><a href="act_new_creds.htm">New Credentials\r
+ Action</a></span> for more information.\r
+ </p></li>\r
+\r
+ <li><a name="renew"/> <span class="title">Renew credentials</span>:\r
+ Renews the selected credentials or identity. This action requires\r
+ that the selected credentials be renewable.\r
+ <p>\r
+ See <span class="pre"><a href="act_renew_creds.htm">Renew\r
+ Credentials Action</a></span> for more information.</p></li>\r
+ \r
+ <li><a name="destroy"/> <span class="title">Destroy\r
+ credentials...</span>: Destroys the selected credentials.</li>\r
+\r
+ <li><a name="def"/> <span class="title">Set as default</span>: Sets\r
+ the selected identity as the default, if it is not already the\r
+ default. The implications of this operation is dependent on the\r
+ current <a href="concept_ident_pro.htm">identity provider</a>.\r
+ <p>\r
+ See <span class="pre"><a href="act_set_default.htm">Set As Default\r
+ Action</a></span> for more information.</p></li>\r
+\r
+ <li><a name="search" /> <span class="title">Allow applications to\r
+ search</span>: This action is currently not implemented.</li>\r
+\r
+ <li><a name="chpw" /> <span class="title">Change password...</span>:\r
+ Changes the password for the selected identity. However, once the\r
+ new password dialog opens, you can change the identity for which the\r
+ password is getting changed.</li>\r
+\r
+ <li><a name="import" /> <span class="title">Import\r
+ Credentials</span>: Import any existing credentials from external\r
+ sources. With the Kerberos 5 <a\r
+ href="concept_cred_pro.htm">credentials provider</a>, the Kerberos\r
+ tickets from the Microsoft Windows LSA cache will be imported to MIT\r
+ Kerberos ticket caches.</li>\r
+\r
+</ul>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
<html>\r
<head>\r
- <title>File menu</title>\r
- <meta name="description" content="">\r
- <meta name="keywords" content="">\r
- <link rel="stylesheet" type="text/css" href="khm.css">\r
+ <title>File Menu</title>\r
+ <meta name="description" content="File menu">\r
+ <meta name="keywords" content="file menu">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
</head>\r
+<body>\r
\r
-<h1>File menu</h1>\r
+<h1>File Menu</h1>\r
\r
-<p>Menu items</p>\r
+<p>\r
+Click an item on the menu to go to the description of the action, or\r
+choose from the list below. You can activate the by pressing <span\r
+class="pre">Alt + F</span> and you can activate each action by\r
+pressing the highlited character.\r
+</p>\r
+\r
+<p>\r
+Actions which have an associated hot key show this hot key to the\r
+right of the action. You can use the hot key to trigger the action\r
+without invoking the <span class="pre">File</span> menu.\r
+</p>\r
+\r
+<map id="menumap">\r
+<area shape = "rect" coords = "7,24,146,43" href = "#properties">\r
+<area shape = "rect" coords = "8,46,146,67" href = "#exit">\r
+</map>\r
+\r
+<p>\r
+<img src="images/screen_menu_file.bmp" usemap="#menumap"/>\r
+</p>\r
\r
<ul>\r
-<li><a href="menu_properties.htm">Properties...</a></li>\r
-<li><a href="menu_exit.htm">Exit...</a></li>\r
+\r
+ <li><a name="properties"/>\r
+ <span class="title">Properties...</span>: Displays a property\r
+ sheet for the selected credential, identity or credential type.</li>\r
+\r
+ <li><a name="exit" />\r
+ <span class="title">Exit</span>: Exits Network Identity Manager</li>\r
+\r
</ul>\r
\r
+</body>\r
</html>
\ No newline at end of file
--- /dev/null
+<html>\r
+<head>\r
+ <title>Help Menu</title>\r
+ <meta name="description" content="Help Menu">\r
+ <meta name="keywords" content="help menu">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+<h1>Help Menu</h1>\r
+\r
+<p>\r
+You can activate the menu by pressing <span class="pre">Alt + H</span>\r
+and you can activate each action by pressing the highlighted character.\r
+</p>\r
+\r
+<p>\r
+You can invoke help anytime by pressing the <span\r
+class="pre">F1</span> key or if you are in a dialog box, by clicking\r
+the question mark icon in the title bar and then clicking on the\r
+dialog box control that you want help with.\r
+</p>\r
+\r
+<p>\r
+This is the help menu. While it is ironic that the help menu itself\r
+needs to be explained, we have decided to include it here just for\r
+completeness. It is bad enough that it is the last menu on the menu\r
+bar. We didn't want to pile on any more disrespect by not documenting\r
+it. We encourage you to not read this and just go ahead and click any\r
+item on this menu. It is guaranteed that nothing bad will happen.\r
+This is not a generalization that would extend to, say, the <a\r
+href="menu_credential.htm">Credentials</a> menu. If anything bad\r
+happens, please file a bug report at <a\r
+href="mailto:kfw-bugs@mit.edu">kfw-bugs@mit.edu</a>.\r
+</p>\r
+\r
+<p>\r
+<img src="images/screen_menu_help.bmp"/>\r
+</p>\r
+\r
+<ul>\r
+\r
+ <li><a name="ctx" /><span class="title">Context</span>: Provides\r
+ context sensitive help. You can invoke help at any time by pressing\r
+ <span class="pre">F1</span></li>\r
+\r
+ <li><a name="contents" /><span class="title">Contents</span>: Opens\r
+ the table of contents for the user documentation</li>\r
+\r
+ <li><a name="index" /><span class="title">Index</span>: Opens the\r
+ index for the user documentation</li>\r
+\r
+ <li><a name="about" /><span class="title">About</span>: Opens a\r
+ dialog box containing information about this version of NetIDMgr as\r
+ well as the modules that are currently loaded.</li>\r
+\r
+</ul>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
--- /dev/null
+<html>\r
+<head>\r
+ <title>Options Menu</title>\r
+ <meta name="description" content="options menu">\r
+ <meta name="keywords" content="options menu">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+<h1>Options Menu</h1>\r
+\r
+<p>\r
+Click an item on the menu to go to the description of the action, or\r
+choose from the list below. You can activate the by pressing <span\r
+class="pre">Alt + O</span> and you can activate each action by\r
+pressing the highlited character.\r
+</p>\r
+\r
+<p>\r
+Actions which have an associated hot key show this hot key to the\r
+right of the action. You can use the hot key to trigger the action\r
+without invoking the <span class="pre">Options</span> menu.\r
+</p>\r
+\r
+<map id="menumap">\r
+<area shape = "rect" coords = "10,23,93,41" href = "#general">\r
+<area shape = "rect" coords = "12,41,94,60" href = "#idents">\r
+<area shape = "rect" coords = "10,59,104,74" href = "#notifs">\r
+</map>\r
+\r
+<p>\r
+<img src="images/screen_menu_options.bmp" usemap="#menumap"/>\r
+</p>\r
+\r
+<ul>\r
+\r
+<li><a name="general" /><span class="title">General ...</span>: Opens\r
+the NetIDMgr general configuration panel.</li>\r
+\r
+<li><a name="idents" /><span class="title">Identities ...</span>:\r
+Opens the identities configuration panel.</li>\r
+\r
+<li><a name="notifs" /><span class="title">Notifications ...</span>:\r
+Opens the Notifications control panel.</li>\r
+\r
+</ul>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
--- /dev/null
+<html>\r
+<head>\r
+ <title>View Menu</title>\r
+ <meta name="description" content="View menu">\r
+ <meta name="keywords" content="view menu">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+<h1>View Menu</h1>\r
+\r
+<p>\r
+Click an item on the menu to go to the description of the action, or\r
+choose from the list below. You can activate the by pressing <span\r
+class="pre">Alt + V</span> and you can activate each action by\r
+pressing the highlited character.\r
+</p>\r
+\r
+<p>\r
+Actions which have an associated hot key show this hot key to the\r
+right of the action. You can use the hot key to trigger the action\r
+without invoking the <span class="pre">View</span> menu.\r
+</p>\r
+\r
+<map id="menumap">\r
+<area shape = "rect" coords = "4,23,146,40" href = "#choosecol">\r
+<area shape = "rect" coords = "11,40,152,56" href = "#layout">\r
+<area shape = "rect" coords = "10,56,150,74" href = "#toolbars">\r
+<area shape = "rect" coords = "15,80,142,103" href = "#debugwnd">\r
+<area shape = "rect" coords = "8,104,151,128" href = "#refresh">\r
+</map>\r
+\r
+<p>\r
+<img src="images/screen_menu_view.bmp" usemap="#menumap"/>\r
+</p>\r
+\r
+<ul>\r
+\r
+<li><a name="choosecol" /> <span class="title">Choolse Columns\r
+...</span>: Invokes a dialog where you can choose which columns are\r
+displayed in the view window. If you change the columns, or their\r
+order, a new custom layout will be created for you which you can later\r
+use using the <span class="pre">Layout</span> submenu later.</li>\r
+\r
+<li><a name="layout" /> <span class="title">Layout</span>: Opens a\r
+submenu where you can select the layout for the credentials\r
+display.\r
+ <ul>\r
+\r
+ <li><span class="title">By Identity</span>: A predefined layout\r
+ where the credentials will be grouped by identity and by\r
+ credentials type, in that order.</li>\r
+\r
+ <li><span class="title">By Type</span>: A predefined layout\r
+ where the credentials are grouped by credentials type</li>\r
+\r
+ <li><span class="title">By Location</span>: A predefined layout\r
+ where the credentials are grouped by the location where they are\r
+ stored in. For Kerberos 5, the location is the name of the\r
+ credentials cache in which the tickets are stored, and for AFS,\r
+ the locatino is always the cache manager. Individual <a\r
+ href="concept_cred_pro.htm">credential providers</a> choose the\r
+ interpretation of the <span class="pre">location</span> property\r
+ as the concept of location changes from type to type.</li>\r
+\r
+ <li><span class="title">Custom</span>: The custom layout. If\r
+ you customize the layout by adding, removing or reordering the\r
+ columns, then NetIDMgr will create a new custom layout using the\r
+ customizations. You can choose this option to revisit that layout</li>\r
+\r
+ </ul>\r
+</li>\r
+\r
+<li><a name="toolbars" />\r
+<span class="title">Toolbars</span>: Enable or disable toolbars.</li>\r
+\r
+<li><a name="debugwnd" /> <span class="title">Debug window...</span>:\r
+Displays a debug window which contains a history of actions and any\r
+debug information for each action that was supplied by each <a\r
+href="concept_cred_pro.htm">credentials provider</a><li>\r
+\r
+<li><a name="refresh" /> <span class="title">Refresh</span>: Refresh\r
+the credentials view. This queries each <a\r
+href="concept_cred_pro.htm">credential provider</a> for any\r
+credentials and redraws the credentials view.</li>\r
+\r
+</ul>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
--- /dev/null
+BODY {\r
+ font-family:helvetica,sans-serif;\r
+ font-size:8pt; \r
+ font-style:normal; \r
+ background-color:white;\r
+ margin-top: 0;\r
+ margin-left: 0;\r
+ margin-right: 0;\r
+ }\r
+\r
+H1 {\r
+ font-size: 10pt;\r
+ border-bottom:1px solid black;\r
+ padding:5px;\r
+ background-color:#eeeeee;\r
+ }\r
+\r
+H2 {\r
+ }\r
+\r
+H3 {\r
+ font-size: 9pt;\r
+ border-bottom: 1px solid lightgrey;\r
+ padding: 5px;\r
+ }\r
+\r
+H4 {\r
+ font-size: 9pt;\r
+ font-style: italic;\r
+ border-bottom: 1px dashed lightgrey;\r
+ margin-left: 10px;\r
+ }\r
+\r
+P {\r
+ margin-left: 5px;\r
+ margin-right: 5px;\r
+ }\r
+\r
+P.caption {\r
+ margin-left: 5px;\r
+ margin-right: 5px;\r
+ font-style: italic;\r
+}\r
+\r
+DIV.inline {\r
+ float: left;\r
+}\r
+\r
+DIV.sidebar {\r
+ float: right;\r
+ background-color:#ffffb9;\r
+ border: 1px solid #ffff00;\r
+}\r
+\r
+A.external {\r
+}\r
+\r
+A.mail {\r
+}\r
+\r
+IMG {\r
+ border: 0;\r
+}\r
+\r
+SPAN.pre {\r
+ font-family: courier;\r
+}\r
+\r
+SPAN.title {\r
+ font-weight: bold;\r
+}
\ No newline at end of file
--- /dev/null
+<html>\r
+<head>\r
+ <title>Standard Toolbar</title>\r
+ <meta name="description" content="Standard Toolbar">\r
+ <meta name="keywords" content="standard toolbar">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+<h1>Standard Toolbar</h1>\r
+\r
+<p>The standard toolbar appears below along with descriptions of what\r
+each button does.\r
+</p>\r
+\r
+<p>\r
+<img src="images/screen_tb_standard.bmp" />\r
+</p>\r
+\r
+<ol>\r
+\r
+ <li><span class="title">New credentials</span>: Equivalent to\r
+ selecting <span class="pre"><a href="menu_credential.htm#new">New\r
+ credentials...</a></span> from the <span class="pre"><a\r
+ href="menu_credential.htm">Credential</a></span> menu.\r
+ <p>\r
+ See <a href="act_new_creds.htm">New Credentials Action</a> for more\r
+ information.</p></li>\r
+\r
+ <li><span class="title">Renew credentials</span>: Equivalent to\r
+ selecting <span class="pre"><a\r
+ href="menu_credential.htm#renew">Renew Credentials</a></span> from\r
+ the <span class="pre"><a\r
+ href="menu_credential.htm">Credential</a></span> menu.\r
+ <p>\r
+ See <a href="act_renew_creds.htm">Renew Credentials Action</a> for\r
+ more information.</li>\r
+\r
+ <li><span class="title">Import credentials</span>: Equivalent to\r
+ selecting <span class="pre"><a\r
+ href="menu_credential.htm#import">Import Credentials</a></span> from\r
+ the <span class="pre"><a\r
+ href="menu_credential.htm">Credential</a></span> menu.\r
+ </li>\r
+\r
+ <li><span class="title">Destroy credentials</span>: Equivalent to\r
+ selecting <span class="pre"><a\r
+ href="menu_credential.htm#destroy">Destroy Credentials</a></span>\r
+ from the <span class="pre"><a\r
+ href="menu_credential.htm">Credential</a></span> menu.</li>\r
+\r
+ <li><span class="title">Change password</span>: Equivalent to\r
+ selecting <span class="pre"><a\r
+ href="menu_credential.htm#chpw">Change Password ...</a></span> from\r
+ the <span class="pre"><a\r
+ href="menu_credential.htm">Credential</a></span> menu.</li>\r
+\r
+ <li><span class="title">Refresh view</span>: Equivalent to selecting\r
+ <span class="pre"><a href="menu_credential.htm#refresh">Refresh\r
+ View</a></span> from the <span class="pre"><a\r
+ href="menu_credential.htm">Credential</a></span> menu.</li>\r
+\r
+ <li><span class="title">Help</span>: Displays documentation</li>\r
+\r
+</ol>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
<title>title</title>\r
<meta name="description" content="">\r
<meta name="keywords" content="">\r
- <link rel="stylesheet" type="text/css" href="khm.css">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
</head>\r
+<body>\r
\r
+</body>\r
</html>
\ No newline at end of file
--- /dev/null
+<html>\r
+<head>\r
+ <title>Starting NetIDMgr</title>\r
+ <meta name="description" content="starting NetIDMgr">\r
+ <meta name="keywords" content="starting">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+<h1>Starting NetIDMgr</h1>\r
+\r
+<h3>Opening the NetIDMgr window from the notification icon</h3>\r
+\r
+<p>Depending on how you have installed NetIDMgr, it may start as soon\r
+as you login, or it may need to be started manually. NetIDMgr is a\r
+tray application. Hence it doesn't appear on your task bar. This is\r
+based on the assumption that you don't need to run NetIDMgr very\r
+often, and helps reduce clutter on the desktop.</p>\r
+\r
+<div class="sidebar">\r
+<img src="images/screen_tray_icon.bmp"/>\r
+<p class="caption">Figure 1: NetIDMgr notification icon</p>\r
+</div>\r
+\r
+<p>When NetIDMgr is running, it places an icon in the system\r
+notification area (sometimes referred to as the "system tray") as\r
+shown in figure 1.</p>\r
+\r
+<p>Clicking on this icon brings up the NetIDMgr window. Right\r
+clicking on the icon, on the other hand, brings up a menu.</p>\r
+\r
+<h3>Starting NetIDMgr from the Start Menu or command line</h3>\r
+\r
+<div class="sidebar">\r
+<img src="images/screen_app_icon.bmp" />\r
+<p class="caption">Figure 2: NetIDMgr application icon</p>\r
+</div>\r
+\r
+<p>If NetIDMgr was not configured to start automatically when you\r
+login to Windows, then you need to start it either from the\r
+commandline or the start menu. The start menu application icon is\r
+under "Kerberos for Windows" as shown in figure 2.</p>\r
+\r
+<p>Alternatively, you can type 'netidmgr' at a command shell to start\r
+NetIDMgr as well. When starting this way, you may specify additional\r
+<a href="html/cmdline_netidmgr.htm">command line options</a>.</p>\r
+\r
+<h3>Configuring startup options</h3>\r
+\r
+<p>\r
+Note that you can configure options related to the startup of NetIDMgr\r
+by using the NetIDMgr configuration dialog box. You can use the menu\r
+items under the <span class="pre">Options</span> menu to invoke the\r
+configuration dialog.\r
+</p>\r
+\r
+<p>\r
+Only one instance of NetIDMgr can be running at any one time.\r
+Attempting to start NetIDMgr while it is still running will not do\r
+anything, unless you provide any command line options that trigger\r
+some action in the running application instance.\r
+</p>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
--- /dev/null
+<html>\r
+<head>\r
+ <title>Using NetIDMgr</title>\r
+ <meta name="description" content="Using NetIDMgr">\r
+ <meta name="keywords" content="using">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+<h1>Using NetIDMgr</h1>\r
+\r
+<p>\r
+Depending on how NetIDMgr was installed, it might already be running\r
+in the system notification area or it might need to be started\r
+manually. See the topic <a href="html/use_start.htm">starting\r
+NetIDMgr</a> for details. Essentially, to open the NetIDMgr window,\r
+you either have to click the application icon in the system\r
+notification area, select the icon from the start menu, or type\r
+'netidmgr' at a command prompt.\r
+</p>\r
+\r
+<p>\r
+Once you open the NetIDMgr window, you will be presented with a view\r
+of your existing credentials, or a message notifying you that you\r
+don't have any. The credentials view should be fairly self\r
+explanatory, but if there's any doubt, more information <a\r
+href="wnd_main.htm">can be found here.</a>\r
+</p>\r
+\r
+<p>\r
+Brief overviews of how to perform common tasks are linked below:\r
+</p>\r
+\r
+<ul>\r
+ <li><a href="act_new_creds.htm">Getting new credentials</a></li>\r
+ <li><a href="act_destroy_creds.htm">Destroying credentials</a></li>\r
+ <li><a href="act_import_creds.htm">Import credentials from the MSLSA cache</a></li>\r
+ <li><a href="act_renew_creds.htm">Renew credentials</a></li>\r
+ <li><a href="act_chpw.htm">Change password</a></li>\r
+</ul>\r
+\r
+<p>\r
+A more comprehensive list of how-to topics can be found in the <span\r
+class="pre"><a href="howdoi.htm">How do I...</a></span> section.</p>\r
+\r
+</body>\r
+</html>
\ No newline at end of file
<html>\r
<head>\r
- <title>Welcome to Khimaira</title>\r
+ <title>Welcome to the Network Identity Manager</title>\r
<meta name="description" content="Welcome">\r
<meta name="keywords" content="welcome">\r
- <link rel="stylesheet" type="text/css" href="khm.css">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
</head>\r
\r
-<h1>Welcome to Khimaira</h1>\r
+<h1>Welcome to the Network Identity Manager</h1>\r
\r
-<p>Khimaira is a credentials manager that lets you manage Kerberos,\r
-AFS and other types of credentials.\r
+<div class="inline">\r
+<img src="images/logo.jpg"/>\r
+</div>\r
+\r
+<p>\r
+The Network Identity Manager (or NetIDMgr for short) allows you to\r
+manage your credentials (Kerberos tickets, AFS tokens, etc.) on a per\r
+identity basis.\r
+</p>\r
+\r
+<p>\r
+NetIDMgr is extensible using plugins. In fact, most of the features\r
+are implemented in plugins, some of which are themselves extensible.\r
+Support for additional protocols and credential types can be added by\r
+installing the appropriate plugins.\r
+</p>\r
+\r
+<p>\r
+This version is distributed as a part of the MIT Kerberos for Windows\r
+product along with the Kerberos 5 and Kerberos 4 plugins. The OpenAFS\r
+plugin, which is required for supporting OpenAFS tokens, is\r
+distributed separately.\r
</p>\r
\r
-<p>The following web sites provide more information about Kerberos and\r
-AFS:</p>\r
+<ul>\r
+<li><a href="copyright.htm">Legal information</a></li>\r
+<li><a href="bugs.htm">Reporting problems</a></li>\r
+</ul>\r
+\r
+<h3>Getting started</h3>\r
\r
<ul>\r
-<li><a class="external" href="http://web.mit.edu/kerberos">http://web.mit.edu/kerbeors</a></li>\r
-<li><a class="external" href="http://openafs.org">http://openafs.org</a></li>\r
+<li><a href="concepts.htm">NetIDMgr concepts</a></li>\r
+<li><a href="using.htm">Using NetIDMgr</a></li>\r
+<li><a href="howdoi.htm">How do I ...</a></li>\r
</ul>\r
\r
+<h3>Information for developers</h3>\r
+\r
+<p>\r
+If you are interested in developing plugins or extending the features\r
+of NetIDMgr, your first stop should be the NetIDMgr SDK. This is\r
+included in the Kerberos for Windows SDK, which itself is a part of\r
+the Kerberos for Windows distribution.\r
+</p>\r
+\r
+<h3>External links</h3>\r
+\r
+<ul>\r
+<li><a class="external" href="http://web.mit.edu/kerberos">http://web.mit.edu/kerbeors</a>:\r
+\r
+MIT Kerberos distribution\r
+</li>\r
+<li><a class="external" href="http://openafs.org">http://openafs.org</a>:\r
+\r
+OpenAFS\r
+</li>\r
+</ul>\r
\r
</html>
\ No newline at end of file
--- /dev/null
+<html>\r
+<head>\r
+ <title>Main Window</title>\r
+ <meta name="description" content="Main Window">\r
+ <meta name="keywords" content="main window">\r
+ <link rel="stylesheet" type="text/css" href="nidmgr.css">\r
+</head>\r
+<body>\r
+\r
+<h1>Main Window</h1>\r
+\r
+<p>The main window of Network Identity Manager is structured as follows</p>\r
+\r
+<map id="main_wnd_map">\r
+ <area shape = "rect" coords = "7,34,243,56" href = "menu_all.htm" />\r
+ <area shape = "rect" coords = "6,56,364,90" href = "tb_standard.htm" />\r
+ <area shape = "rect" coords = "6,112,613,164" href = "#cred1" />\r
+ <area shape = "rect" coords = "246,162,288,197" href = "#cred2" />\r
+ <area shape = "rect" coords = "72,196,107,245" href = "#credtype1" />\r
+ <area shape = "rect" coords = "69,278,107,315" href = "#credtype2" />\r
+ <area shape = "rect" coords = "236,332,294,367" href = "#cred3" />\r
+</map>\r
+\r
+<img src="images/screen_main_wnd.bmp" usemap="#main_wnd_map"/>\r
+\r
+<ol>\r
+ <li>Menu bar</li>\r
+ <li>Tool bar</li>\r
+\r
+ <li><a name="cred1" /> An identity with a valid Kerberos 5 initial\r
+ ticket</li>\r
+\r
+ <li><a name="cred2" /> An identity with valid Kerberos 5 tickets and\r
+ AFS tokens</li> \r
+\r
+ <li><a name="credtype1" /> A set of Kerberos 5 tickets</li>\r
+\r
+ <li><a name="credtype2" /> A set of AFS tokens</li>\r
+\r
+ <li>An identity with expired Kerberos 5 tickets</li>\r
+\r
+</ol>\r
+\r
+<h3>Identity views</h3>\r
+\r
+<p>\r
+The default credentials view organizes them grouped by identity name\r
+and then by credential type. Each credential is then shown under each\r
+group heading sorted by the credential name. The default headings for\r
+the credential view provides you with a minimal amount of information\r
+to reduce clutter. If you wish you can add columns to the display\r
+using the <span class="pre">Choose columns...</span> action on the\r
+<span class="pre"><a href="html/menu_view.htm">View</a></span> menu.\r
+</p>\r
+\r
+<p>\r
+The header backgrounds and the credential rows change color if the\r
+credentials are about to expire or are expired. \r
+\r
+<ul> \r
+\r
+<li> <span style="background-color:#fbc74d">Headers</span> mean that\r
+credentials at that level will expire unless renewed. Credentials\r
+will have a warning icon next to them.<br/>\r
+\r
+The threshold for this can be set as the <span class="pre">Warn</span>\r
+parameter in the <span class="pre">Notifications</span> configuration\r
+panel.</li>\r
+\r
+<li> <span style="background-color:#f08575">Headers</span> mean that\r
+credentials at that level will expire in a few minutes. Credentials\r
+will have a critical icon next to them.<br/>\r
+\r
+The threshold for this can be set as the <span class="pre">Warn\r
+again</span> parameter in the <span class="pre">Notifications</span>\r
+configuration panel. </li>\r
+\r
+<li> <span style="background-color:#ff9090">Headers</span> mean that\r
+the credentials at that level have expired. Credentials will have an\r
+expired icon next to them.<br/>\r
+\r
+The threshold for this is always zero.\r
+</li>\r
+\r
+</ul> \r
+</p> \r
+\r
+</body>\r
+</html>\r
+#define NIDM_HELPFILE L"netidmgr.chm"\r
\r
#define IDH_WELCOME 1000\r
-#define IDH_MENU_FILE 1001\r
-#define IDH_MENU_CRED 1002\r
-#define IDH_MENU_VIEW 1003\r
-#define IDH_MENU_OPTIONS 1004\r
-#define IDH_MENU_HELP 1005\r
+#define IDH_WIN_MAIN 1001\r
+\r
+#define IDH_MENU_FILE 1501\r
+#define IDH_MENU_CRED 1502\r
+#define IDH_MENU_VIEW 1503\r
+#define IDH_MENU_OPTIONS 1504\r
+#define IDH_MENU_HELP 1505\r
\r
#define IDH_ACTION_PROPERTIES 2000\r
#define IDH_ACTION_EXIT 2001\r
Compatibility=1.1 or later\r
Compiled file=netidmgr.chm\r
Contents file=toc.hhc\r
+Default Window=MainHelpWnd\r
Default topic=html/welcome.htm\r
Display compile progress=No\r
Index file=Index.hhk\r
Language=0x409 English (United States)\r
Title=NetIDMgr\r
\r
+[WINDOWS]\r
+MainHelpWnd="NetIDMgr Help","toc.hhc","Index.hhk","html/welcome.htm","html/welcome.htm",,,,,0x42120,,0x384e,[271,372,593,566],0x830000,,,,,,0\r
+\r
+\r
+[ALIAS]\r
+IDH_WELCOME=html\welcome.htm\r
\r
[MAP]\r
#include khhelp.h\r
\r
+[TEXT POPUPS]\r
+khhelp.h\r
+popups_newcreds.txt\r
+\r
[INFOTYPES]\r
Category:Concepts\r
CategoryDesc:Authentication, authorization and related concepts.\r
<param name="Category" value="Concepts">\r
<param name="CategoryDesc" value="Authentication, authorization and related concepts.">\r
<param name="Category" value="Usage">\r
- <param name="CategoryDesc" value="Usage instructions for Khimaira">\r
+ <param name="CategoryDesc" value="Usage instructions for Network Identity Manager">\r
<param name="Window Styles" value="0x800025">\r
</OBJECT>\r
<UL>\r
<LI> <OBJECT type="text/sitemap">\r
- <param name="Name" value="Welcome to Khimaira">\r
+ <param name="Name" value="Welcome to Network Identity Manager">\r
<param name="Local" value="html\welcome.htm">\r
</OBJECT>\r
<LI> <OBJECT type="text/sitemap">\r
- <param name="Name" value="Using Khimaira">\r
+ <param name="Name" value="How do I ...">\r
+ <param name="Local" value="html\howdoi.htm">\r
+ </OBJECT>\r
+ <LI> <OBJECT type="text/sitemap">\r
+ <param name="Name" value="About NetIDMgr">\r
+ <param name="Local" value="html\about_netidmgr.htm">\r
</OBJECT>\r
<UL>\r
<LI> <OBJECT type="text/sitemap">\r
- <param name="Name" value="Menus">\r
- </OBJECT>\r
- <UL>\r
- <LI> <OBJECT type="text/sitemap">\r
- <param name="Name" value="File...">\r
- <param name="Local" value="html\menu_file.htm">\r
- </OBJECT>\r
- </UL>\r
- <LI> <OBJECT type="text/sitemap">\r
- <param name="Name" value="Actions">\r
- </OBJECT>\r
- <UL>\r
- <LI> <OBJECT type="text/sitemap">\r
- <param name="Name" value="Properties">\r
- <param name="Local" value="html\menu_properties.htm">\r
- </OBJECT>\r
- <LI> <OBJECT type="text/sitemap">\r
- <param name="Name" value="Exit">\r
- <param name="Local" value="html\menu_exit.htm">\r
- </OBJECT>\r
- </UL>\r
+ <param name="Name" value="Reporting bugs">\r
+ <param name="Local" value="html\bugs.htm">\r
+ </OBJECT>\r
+ <LI> <OBJECT type="text/sitemap">\r
+ <param name="Name" value="License agreement">\r
+ <param name="Local" value="html\copyright.htm">\r
+ </OBJECT>\r
+ </UL>\r
+ <LI> <OBJECT type="text/sitemap">\r
+ <param name="Name" value="Concepts">\r
+ <param name="Local" value="html\concepts.htm">\r
+ </OBJECT>\r
+ <UL>\r
+ <LI> <OBJECT type="text/sitemap">\r
+ <param name="Name" value="Identities">\r
+ <param name="Local" value="html\concept_identity.htm">\r
+ </OBJECT>\r
+ <LI> <OBJECT type="text/sitemap">\r
+ <param name="Name" value="Identity Provider">\r
+ <param name="Local" value="html\concept_ident_pro.htm">\r
+ </OBJECT>\r
+ <LI> <OBJECT type="text/sitemap">\r
+ <param name="Name" value="Credentials Provider">\r
+ <param name="Local" value="html\concept_cred_pro.htm">\r
+ </OBJECT>\r
+ </UL>\r
+ <LI> <OBJECT type="text/sitemap">\r
+ <param name="Name" value="Using NetIDMgr">\r
+ <param name="Local" value="html\using.htm">\r
+ </OBJECT>\r
+ <UL>\r
+ <LI> <OBJECT type="text/sitemap">\r
+ <param name="Name" value="Starting">\r
+ <param name="Local" value="html\use_start.htm">\r
+ </OBJECT>\r
+ </UL>\r
+ <LI> <OBJECT type="text/sitemap">\r
+ <param name="Name" value="Menus">\r
+ <param name="Local" value="html\menu_all.htm">\r
+ </OBJECT>\r
+ <UL>\r
+ <LI> <OBJECT type="text/sitemap">\r
+ <param name="Name" value="File Menu">\r
+ <param name="Local" value="html\menu_file.htm">\r
+ </OBJECT>\r
+ <LI> <OBJECT type="text/sitemap">\r
+ <param name="Name" value="Credential menu">\r
+ <param name="Local" value="html\menu_credential.htm">\r
+ </OBJECT>\r
+ <LI> <OBJECT type="text/sitemap">\r
+ <param name="Name" value="View Menu">\r
+ <param name="Local" value="html\menu_view.htm">\r
+ </OBJECT>\r
+ <LI> <OBJECT type="text/sitemap">\r
+ <param name="Name" value="Options Menu">\r
+ <param name="Local" value="html\menu_options.htm">\r
+ </OBJECT>\r
+ <LI> <OBJECT type="text/sitemap">\r
+ <param name="Name" value="Help Menu">\r
+ <param name="Local" value="html\menu_help.htm">\r
+ </OBJECT>\r
+ <LI> <OBJECT type="text/sitemap">\r
+ <param name="Name" value="Standard Toolbar">\r
+ <param name="Local" value="html\tb_standard.htm">\r
+ </OBJECT>\r
+ </UL>\r
+ <LI> <OBJECT type="text/sitemap">\r
+ <param name="Name" value="Actions">\r
+ </OBJECT>\r
+ <UL>\r
+ <LI> <OBJECT type="text/sitemap">\r
+ <param name="Name" value="New Credentials">\r
+ <param name="Local" value="html\act_new_creds.htm">\r
+ </OBJECT>\r
+ <LI> <OBJECT type="text/sitemap">\r
+ <param name="Name" value="Renew Credentials">\r
+ <param name="Local" value="html\act_renew_creds.htm">\r
+ </OBJECT>\r
+ <LI> <OBJECT type="text/sitemap">\r
+ <param name="Name" value="Destroy Credentials">\r
+ <param name="Local" value="html\act_destroy_creds.htm">\r
+ </OBJECT>\r
+ <LI> <OBJECT type="text/sitemap">\r
+ <param name="Name" value="Set As Default">\r
+ <param name="Local" value="html\act_set_default.htm">\r
+ </OBJECT>\r
+ <LI> <OBJECT type="text/sitemap">\r
+ <param name="Name" value="Change Password">\r
+ <param name="Local" value="html\act_chpw.htm">\r
+ </OBJECT>\r
+ </UL>\r
+ <LI> <OBJECT type="text/sitemap">\r
+ <param name="Name" value="Windows and dialogs">\r
+ </OBJECT>\r
+ <UL>\r
+ <LI> <OBJECT type="text/sitemap">\r
+ <param name="Name" value="Main Window">\r
+ <param name="Local" value="html\wnd_main.htm">\r
+ </OBJECT>\r
</UL>\r
</UL>\r
</BODY></HTML>\r
$(INCDIR)\khdefs.h \\r
$(INCDIR)\kherror.h \\r
$(INCDIR)\khlist.h \\r
- $(INCDIR)\khmsgtypes.h\r
+ $(INCDIR)\khmsgtypes.h \\r
+ $(INCDIR)\netidmgr.h\r
\r
all: $(INCFILES)\r
\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
#define KHM_ERROR_TOO_LONG (KHM_ERROR_BASE + 2)\r
\r
/*! \brief One or more parameters supplied to a function were invalid */\r
-#define KHM_ERROR_INVALID_PARM (KHM_ERROR_BASE + 3)\r
+#define KHM_ERROR_INVALID_PARAM (KHM_ERROR_BASE + 3)\r
\r
/*! \brief A duplicate.\r
\r
*/\r
#define KHM_ERROR_PARTIAL (KHM_ERROR_BASE + 20)\r
\r
+/*! \brief An incompatibility was found */\r
+#define KHM_ERROR_INCOMPATIBLE (KHM_ERROR_BASE + 21)\r
+\r
/*@}*/ /*kherror_codes*/\r
\r
/*! \brief Tests whether a return value indicates success */\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
*/\r
#define KMSG_CRED_PP_DESTROY 131\r
\r
+/*! \brief An IP address change occurred\r
+\r
+ There are no parameters for this message. The NetIDMgr\r
+ application handles this message and depending on configuration,\r
+ posts message for the individual credentials providers to either\r
+ obtain new credentials or renew old ones.\r
+ */\r
+#define KMSG_CRED_ADDR_CHANGE 140\r
+\r
/*! \brief Check if a KMSG_CRED subtype is a credentials acquisition message\r
\r
Dialog messages are those that deal with the new or initial\r
*/\r
#define KMSG_ALERT_SHOW 1\r
\r
+/*! \brief Add an alert to the alert queue\r
+\r
+ Message parameters:\r
+ - \b vparam : held pointer to a ::khui_alert object\r
+\r
+ \note the ::khui_alert object will be released when the queued\r
+ messages are displayed.\r
+ */\r
+#define KMSG_ALERT_QUEUE 2\r
+\r
+/*! \brief Show the next queued alert\r
+\r
+ There are no message parameters\r
+ */\r
+#define KMSG_ALERT_SHOW_QUEUED 3\r
+\r
+/*! \brief Check if there are any queued messages and, if so, update the statusbar\r
+\r
+ There are no message parameters\r
+ */\r
+#define KMSG_ALERT_CHECK_QUEUE 4\r
+\r
/*@}*/\r
\r
/*! \defgroup kmq_msg_ident KMSG_IDENT Subtypes\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
\r
/* $Id$ */\r
\r
-/* Not exported */\r
-#ifndef __KHIMAIRA_KTHREAD_H\r
-#define __KHIMAIRA_KTHREAD_H\r
+#ifndef __NETIDMGR_H\r
+#define __NETIDMGR_H\r
\r
-#ifdef _WIN32\r
-#define khm_mutex CRITICAL_SECTION\r
+#include "khdefs.h"\r
\r
-#define khp_mutex_init(pcs) InitializeCriticalSection(pcs)\r
-#define khp_mutex_destroy(pcs) DeleteCriticalSection(pcs)\r
-#define khp_mutex_lock(pcs) EnterCriticalSection(pcs)\r
-#define khp_mutex_unlock(pcs) LeaveCriticalSection(pcs)\r
-#define khp_mutex_trylock(pcs) (!TryEnterCriticalSection(pcs))\r
+#include "utils.h"\r
+#include "khuidefs.h"\r
+#include "kmq.h"\r
+#include "khmsgtypes.h"\r
+#include "kcreddb.h"\r
+#include "kherr.h"\r
+#include "kherror.h"\r
+#include "kconfig.h"\r
+#include "kmm.h"\r
+#include "kplugin.h"\r
\r
#endif\r
-\r
-#endif
\ No newline at end of file
/*\r
-* Copyright (c) 2004 Massachusetts Institute of Technology\r
+* Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/* we are the first */\r
InitializeCriticalSection(&cs_conf_global);\r
EnterCriticalSection(&cs_conf_global);\r
- conf_root = khc_create_empty_space();\r
- conf_root->name = wcsdup(L"Root");\r
- conf_root->regpath = wcsdup(CONFIG_REGPATHW);\r
+ conf_root = khcint_create_empty_space();\r
+ conf_root->name = PWCSDUP(L"Root");\r
+ conf_root->regpath = PWCSDUP(CONFIG_REGPATHW);\r
conf_root->refcount++;\r
conf_status = 1;\r
InitializeCriticalSection(&cs_conf_handle);\r
conf_init = 0;\r
conf_status = 0;\r
\r
- khc_free_space(conf_root);\r
+ khcint_free_space(conf_root);\r
\r
EnterCriticalSection(&cs_conf_handle);\r
while(conf_free_handles) {\r
LPOP(&conf_free_handles, &h);\r
if(h) {\r
- free(h);\r
+ PFREE(h);\r
}\r
}\r
\r
while(conf_handles) {\r
LPOP(&conf_handles, &h);\r
if(h) {\r
- free(h);\r
+ PFREE(h);\r
}\r
}\r
LeaveCriticalSection(&cs_conf_handle);\r
}\r
}\r
\r
-kconf_handle * khc_handle_from_space(kconf_conf_space * s, khm_int32 flags)\r
+kconf_handle * \r
+khcint_handle_from_space(kconf_conf_space * s, khm_int32 flags)\r
{\r
kconf_handle * h;\r
\r
EnterCriticalSection(&cs_conf_handle);\r
LPOP(&conf_free_handles, &h);\r
if(!h) {\r
- h = malloc(sizeof(kconf_handle));\r
- assert(h != NULL);\r
+ h = PMALLOC(sizeof(kconf_handle));\r
+ assert(h != NULL);\r
}\r
ZeroMemory((void *) h, sizeof(kconf_handle));\r
\r
h->magic = KCONF_HANDLE_MAGIC;\r
- khc_space_hold(s);\r
+ khcint_space_hold(s);\r
h->space = s;\r
h->flags = flags;\r
\r
}\r
\r
/* must be called with cs_conf_global held */\r
-void khc_handle_free(kconf_handle * h)\r
+void \r
+khcint_handle_free(kconf_handle * h)\r
{\r
kconf_handle * lower;\r
\r
while(h) {\r
LDELETE(&conf_handles, h);\r
if(h->space) {\r
- khc_space_release(h->space);\r
+ khcint_space_release(h->space);\r
h->space = NULL;\r
}\r
lower = h->lower;\r
LeaveCriticalSection(&cs_conf_handle);\r
}\r
\r
-kconf_handle * khc_handle_dup(kconf_handle * o)\r
+kconf_handle * \r
+khcint_handle_dup(kconf_handle * o)\r
{\r
kconf_handle * h;\r
kconf_handle * r;\r
\r
- r = khc_handle_from_space(o->space, o->flags);\r
+ r = khcint_handle_from_space(o->space, o->flags);\r
h = r;\r
\r
while(o->lower) {\r
- h->lower = khc_handle_from_space(o->lower->space, o->lower->flags);\r
+ h->lower = khcint_handle_from_space(o->lower->space, o->lower->flags);\r
\r
o = o->lower;\r
h = h->lower;\r
return r;\r
}\r
\r
-void khc_space_hold(kconf_conf_space * s) {\r
+void \r
+khcint_space_hold(kconf_conf_space * s) {\r
InterlockedIncrement(&(s->refcount));\r
}\r
\r
-void khc_space_release(kconf_conf_space * s) {\r
+void \r
+khcint_space_release(kconf_conf_space * s) {\r
LONG l = InterlockedDecrement(&(s->refcount));\r
if(!l) {\r
EnterCriticalSection(&cs_conf_global);\r
\r
- if(s->regkey_machine)\r
- RegCloseKey(s->regkey_machine);\r
- if(s->regkey_user)\r
- RegCloseKey(s->regkey_user);\r
- s->regkey_machine = NULL;\r
- s->regkey_user = NULL;\r
+ /* check again */\r
+ if (!l) {\r
+ if(s->regkey_machine)\r
+ RegCloseKey(s->regkey_machine);\r
+ if(s->regkey_user)\r
+ RegCloseKey(s->regkey_user);\r
+ s->regkey_machine = NULL;\r
+ s->regkey_user = NULL;\r
+ }\r
\r
LeaveCriticalSection(&cs_conf_global);\r
}\r
}\r
\r
\r
-HKEY khc_space_open_key(kconf_conf_space * s, khm_int32 flags) {\r
+HKEY \r
+khcint_space_open_key(kconf_conf_space * s, khm_int32 flags) {\r
HKEY hk = NULL;\r
int nflags = 0;\r
DWORD disp;\r
}\r
}\r
\r
-KHMEXP khm_int32 KHMAPI khc_shadow_space(khm_handle upper, khm_handle lower)\r
+KHMEXP khm_int32 KHMAPI \r
+khc_shadow_space(khm_handle upper, khm_handle lower)\r
{\r
kconf_handle * h;\r
\r
return KHM_ERROR_NOT_READY;\r
\r
if(!khc_is_handle(upper))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
h = (kconf_handle *) upper;\r
\r
if(h->lower) {\r
LeaveCriticalSection(&cs_conf_handle);\r
EnterCriticalSection(&cs_conf_global);\r
- khc_handle_free(h->lower);\r
+ khcint_handle_free(h->lower);\r
LeaveCriticalSection(&cs_conf_global);\r
EnterCriticalSection(&cs_conf_handle);\r
h->lower = NULL;\r
\r
l = (kconf_handle *) lower;\r
LeaveCriticalSection(&cs_conf_handle);\r
- lc = khc_handle_dup(l);\r
+ lc = khcint_handle_dup(l);\r
EnterCriticalSection(&cs_conf_handle);\r
h->lower = lc;\r
}\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
-kconf_conf_space * khc_create_empty_space(void) {\r
+kconf_conf_space * \r
+khcint_create_empty_space(void) {\r
kconf_conf_space * r;\r
\r
- r = malloc(sizeof(kconf_conf_space));\r
- assert(r != NULL);\r
+ r = PMALLOC(sizeof(kconf_conf_space));\r
+ assert(r != NULL);\r
ZeroMemory(r,sizeof(kconf_conf_space));\r
\r
return r;\r
}\r
\r
-void khc_free_space(kconf_conf_space * r) {\r
+void \r
+khcint_free_space(kconf_conf_space * r) {\r
kconf_conf_space * c;\r
\r
if(!r)\r
\r
LPOP(&r->children, &c);\r
while(c) {\r
- khc_free_space(c);\r
+ khcint_free_space(c);\r
LPOP(&r->children, &c);\r
}\r
\r
if(r->name)\r
- free(r->name);\r
+ PFREE(r->name);\r
\r
if(r->regpath)\r
- free(r->regpath);\r
+ PFREE(r->regpath);\r
\r
if(r->regkey_machine)\r
RegCloseKey(r->regkey_machine);\r
if(r->regkey_user)\r
RegCloseKey(r->regkey_user);\r
\r
- free(r);\r
+ PFREE(r);\r
}\r
\r
-khm_int32 khcint_open_space_int(kconf_conf_space * parent, wchar_t * sname, size_t n_sname, khm_int32 flags, kconf_conf_space **result) {\r
+khm_int32 \r
+khcint_open_space_int(kconf_conf_space * parent, \r
+ wchar_t * sname, size_t n_sname, \r
+ khm_int32 flags, kconf_conf_space **result) {\r
kconf_conf_space * p;\r
kconf_conf_space * c;\r
HKEY pkey = NULL;\r
p = parent;\r
\r
if(n_sname >= KCONF_MAXCCH_NAME || n_sname <= 0)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
- /*SAFE: buf: buffer size == KCONF_MAXCCH_NAME * wchar_t >\r
- n_sname * wchar_t */\r
+ /*SAFE: buf: buffer size == KCONF_MAXCCH_NAME * wchar_t >\r
+ n_sname * wchar_t */\r
wcsncpy(buf, sname, n_sname);\r
buf[n_sname] = L'\0';\r
\r
LeaveCriticalSection(&cs_conf_global);\r
\r
if(c) {\r
- khc_space_hold(c);\r
+ khcint_space_hold(c);\r
*result = c;\r
return KHM_ERROR_SUCCESS;\r
}\r
registry key in HKLM or HKCU. If it existed as a schema, we\r
would have already retured it above. */\r
if(flags & KCONF_FLAG_USER)\r
- pkey = khc_space_open_key(p, KHM_PERM_READ | KCONF_FLAG_USER);\r
+ pkey = khcint_space_open_key(p, KHM_PERM_READ | KCONF_FLAG_USER);\r
\r
if((!pkey || \r
(khcint_RegOpenKeyEx(pkey, buf, 0, KEY_READ, &ckey) != \r
ERROR_SUCCESS)) \r
&& (flags & KCONF_FLAG_MACHINE)) {\r
\r
- pkey = khc_space_open_key(p, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
+ pkey = khcint_space_open_key(p, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
if(!pkey || \r
(khcint_RegOpenKeyEx(pkey, buf, 0, KEY_READ, &ckey) != \r
ERROR_SUCCESS)) {\r
}\r
}\r
\r
- c = khc_create_empty_space();\r
+ c = khcint_create_empty_space();\r
\r
/*SAFE: buf: is of known length < KCONF_MAXCCH_NAME */\r
- c->name = wcsdup(buf);\r
+ c->name = PWCSDUP(buf);\r
\r
/*SAFE: p->regpath: is valid since it was set using this same\r
function. */\r
/*SAFE: buf: see above */\r
- c->regpath = malloc((wcslen(p->regpath) + wcslen(buf) + 2) * sizeof(wchar_t));\r
+ c->regpath = PMALLOC((wcslen(p->regpath) + wcslen(buf) + 2) * sizeof(wchar_t));\r
\r
assert(c->regpath != NULL);\r
\r
wcscat(c->regpath, buf);\r
#pragma warning( pop )\r
\r
- khc_space_hold(c);\r
+ khcint_space_hold(c);\r
\r
EnterCriticalSection(&cs_conf_global);\r
TADDCHILD(p,c);\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI khc_open_space(khm_handle parent, wchar_t * cspace, khm_int32 flags, khm_handle * result) {\r
+KHMEXP khm_int32 KHMAPI \r
+khc_open_space(khm_handle parent, wchar_t * cspace, khm_int32 flags, \r
+ khm_handle * result) {\r
kconf_handle * h;\r
kconf_conf_space * p;\r
kconf_conf_space * c = NULL;\r
}\r
\r
if(!result || (parent && !khc_is_handle(parent)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if(!parent)\r
p = conf_root;\r
p = khc_space_from_handle(parent);\r
}\r
\r
- khc_space_hold(p);\r
+ khcint_space_hold(p);\r
\r
/* if none of these flags are specified, make it seem like all of\r
them were */\r
flags |= KCONF_FLAG_USER | KCONF_FLAG_MACHINE | KCONF_FLAG_SCHEMA;\r
\r
if(cspace == NULL) {\r
- khc_space_release(p);\r
- *result = (khm_handle) khc_handle_from_space(p, flags);\r
+ khcint_space_release(p);\r
+ *result = (khm_handle) khcint_handle_from_space(p, flags);\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
if(FAILED(StringCbLength(cspace, KCONF_MAXCB_PATH, &cbsize))) {\r
- khc_space_release(p);\r
+ khcint_space_release(p);\r
*result = NULL;\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
str = cspace;\r
if(flags & KCONF_FLAG_TRAILINGVALUE) {\r
/* we are at the value component */\r
c = p;\r
- khc_space_hold(c);\r
+ khcint_space_hold(c);\r
break;\r
} else\r
end = str + wcslen(str); /* safe because cspace was\r
|| *end == L'/'\r
#endif\r
)) {\r
- khc_space_release(p);\r
+ khcint_space_release(p);\r
p = c;\r
c = NULL;\r
str = end+1;\r
break;\r
}\r
\r
- khc_space_release(p);\r
+ khcint_space_release(p);\r
if(KHM_SUCCEEDED(rv)) {\r
- *result = khc_handle_from_space(c, flags);\r
+ *result = khcint_handle_from_space(c, flags);\r
} else\r
*result = NULL;\r
\r
return rv;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI khc_close_space(khm_handle csp) {\r
+KHMEXP khm_int32 KHMAPI \r
+khc_close_space(khm_handle csp) {\r
if(!khc_is_config_running())\r
return KHM_ERROR_NOT_READY;\r
\r
if(!khc_is_handle(csp))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
- khc_handle_free((kconf_handle *) csp);\r
+ khcint_handle_free((kconf_handle *) csp);\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI khc_read_string(khm_handle pconf, \r
- wchar_t * pvalue, \r
- wchar_t * buf, \r
- khm_size * bufsize) \r
+KHMEXP khm_int32 KHMAPI \r
+khc_read_string(khm_handle pconf, \r
+ wchar_t * pvalue, \r
+ wchar_t * buf, \r
+ khm_size * bufsize) \r
{\r
kconf_conf_space * c;\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
c = khc_space_from_handle(conf);\r
\r
if(khc_is_user_handle(conf))\r
- hku = khc_space_open_key(c, KHM_PERM_READ);\r
+ hku = khcint_space_open_key(c, KHM_PERM_READ);\r
\r
if(khc_is_machine_handle(conf))\r
- hkm = khc_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
+ hkm = khcint_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
\r
size = (DWORD) *bufsize;\r
if(hku) {\r
return rv;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI khc_read_int32(khm_handle pconf, wchar_t * pvalue, khm_int32 * buf) {\r
+KHMEXP khm_int32 KHMAPI \r
+khc_read_int32(khm_handle pconf, wchar_t * pvalue, khm_int32 * buf) {\r
kconf_conf_space * c;\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
\r
return KHM_ERROR_NOT_READY;\r
\r
if(!buf || !pvalue)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
do {\r
DWORD size;\r
c = khc_space_from_handle(conf);\r
\r
if(khc_is_user_handle(conf))\r
- hku = khc_space_open_key(c, KHM_PERM_READ);\r
+ hku = khcint_space_open_key(c, KHM_PERM_READ);\r
\r
if(khc_is_machine_handle(conf))\r
- hkm = khc_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
+ hkm = khcint_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
\r
size = sizeof(DWORD);\r
if(hku) {\r
return rv;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI khc_read_int64(khm_handle pconf, wchar_t * pvalue, khm_int64 * buf) {\r
+KHMEXP khm_int32 KHMAPI \r
+khc_read_int64(khm_handle pconf, wchar_t * pvalue, khm_int64 * buf) {\r
kconf_conf_space * c;\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
\r
c = khc_space_from_handle(conf);\r
\r
if(khc_is_user_handle(conf))\r
- hku = khc_space_open_key(c, KHM_PERM_READ);\r
+ hku = khcint_space_open_key(c, KHM_PERM_READ);\r
\r
if(khc_is_machine_handle(conf))\r
- hkm = khc_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
+ hkm = khcint_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
\r
size = sizeof(khm_int64);\r
if(hku) {\r
return rv;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI khc_read_binary(khm_handle pconf, wchar_t * pvalue, void * buf, khm_size * bufsize) {\r
+KHMEXP khm_int32 KHMAPI \r
+khc_read_binary(khm_handle pconf, wchar_t * pvalue, \r
+ void * buf, khm_size * bufsize) {\r
kconf_conf_space * c;\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
\r
c = khc_space_from_handle(conf);\r
\r
if(khc_is_user_handle(conf))\r
- hku = khc_space_open_key(c, KHM_PERM_READ);\r
+ hku = khcint_space_open_key(c, KHM_PERM_READ);\r
\r
if(khc_is_machine_handle(conf))\r
- hkm = khc_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
+ hkm = khcint_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
\r
size = (DWORD) *bufsize;\r
if(hku) {\r
return rv;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI khc_write_string(\r
- khm_handle pconf, \r
- wchar_t * pvalue, \r
- wchar_t * buf) \r
+KHMEXP khm_int32 KHMAPI \r
+khc_write_string(khm_handle pconf, \r
+ wchar_t * pvalue, \r
+ wchar_t * buf) \r
{\r
HKEY pk = NULL;\r
kconf_conf_space * c;\r
pvalue, \r
KCONF_FLAG_TRAILINGVALUE | (pconf?khc_handle_flags(pconf):0), \r
&conf)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
free_space = 1;\r
#if 0\r
wchar_t * back, *forward;\r
}\r
\r
if(!khc_is_handle(conf) || !buf) {\r
- rv = KHM_ERROR_INVALID_PARM;\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
goto _exit;\r
}\r
\r
c = khc_space_from_handle(conf);\r
\r
if(FAILED(StringCbLength(buf, KCONF_MAXCB_STRING, &cbsize))) {\r
- rv = KHM_ERROR_INVALID_PARM;\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
goto _exit;\r
}\r
\r
cbsize += sizeof(wchar_t);\r
\r
if(khc_is_user_handle(conf)) {\r
- pk = khc_space_open_key(c, KHM_PERM_WRITE | KHM_FLAG_CREATE);\r
+ pk = khcint_space_open_key(c, KHM_PERM_WRITE | KHM_FLAG_CREATE);\r
} else {\r
- pk = khc_space_open_key(c, KHM_PERM_WRITE | KCONF_FLAG_MACHINE | KHM_FLAG_CREATE);\r
+ pk = khcint_space_open_key(c, KHM_PERM_WRITE | KCONF_FLAG_MACHINE | KHM_FLAG_CREATE);\r
}\r
\r
hr = RegSetValueEx(pk, value, 0, REG_SZ, (LPBYTE) buf, (DWORD) cbsize);\r
return rv;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI khc_write_int32(\r
- khm_handle pconf, \r
- wchar_t * pvalue, \r
- khm_int32 buf) \r
+KHMEXP khm_int32 KHMAPI \r
+khc_write_int32(khm_handle pconf, \r
+ wchar_t * pvalue, \r
+ khm_int32 buf) \r
{\r
HKEY pk = NULL;\r
kconf_conf_space * c;\r
pvalue, \r
KCONF_FLAG_TRAILINGVALUE | (pconf?khc_handle_flags(pconf):0), \r
&conf)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
free_space = 1;\r
#if 0\r
wchar_t * back, *forward;\r
}\r
\r
if(!khc_is_handle(conf))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
c = khc_space_from_handle( conf);\r
\r
if(khc_is_user_handle(conf)) {\r
- pk = khc_space_open_key(c, KHM_PERM_WRITE | KHM_FLAG_CREATE);\r
+ pk = khcint_space_open_key(c, KHM_PERM_WRITE | KHM_FLAG_CREATE);\r
} else {\r
- pk = khc_space_open_key(c, KHM_PERM_WRITE | KCONF_FLAG_MACHINE | KHM_FLAG_CREATE);\r
+ pk = khcint_space_open_key(c, KHM_PERM_WRITE | KCONF_FLAG_MACHINE | KHM_FLAG_CREATE);\r
}\r
\r
hr = RegSetValueEx(pk, value, 0, REG_DWORD, (LPBYTE) &buf, sizeof(khm_int32));\r
return rv;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI khc_write_int64(khm_handle pconf, wchar_t * pvalue, khm_int64 buf) {\r
+KHMEXP khm_int32 KHMAPI \r
+khc_write_int64(khm_handle pconf, wchar_t * pvalue, khm_int64 buf) {\r
HKEY pk = NULL;\r
kconf_conf_space * c;\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
pvalue, \r
KCONF_FLAG_TRAILINGVALUE | (pconf?khc_handle_flags(pconf):0), \r
&conf)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
free_space = 1;\r
#if 0\r
wchar_t * back, *forward;\r
}\r
\r
if(!khc_is_handle(conf))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
c = khc_space_from_handle( conf);\r
\r
if(khc_is_user_handle(conf)) {\r
- pk = khc_space_open_key(c, KHM_PERM_WRITE | KHM_FLAG_CREATE);\r
+ pk = khcint_space_open_key(c, KHM_PERM_WRITE | KHM_FLAG_CREATE);\r
} else {\r
- pk = khc_space_open_key(c, KHM_PERM_WRITE | KCONF_FLAG_MACHINE | KHM_FLAG_CREATE);\r
+ pk = khcint_space_open_key(c, KHM_PERM_WRITE | KCONF_FLAG_MACHINE | KHM_FLAG_CREATE);\r
}\r
\r
hr = RegSetValueEx(pk, value, 0, REG_QWORD, (LPBYTE) &buf, sizeof(khm_int64));\r
return rv;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI khc_write_binary(khm_handle pconf, wchar_t * pvalue, void * buf, khm_size bufsize) {\r
+KHMEXP khm_int32 KHMAPI \r
+khc_write_binary(khm_handle pconf, \r
+ wchar_t * pvalue, \r
+ void * buf, khm_size bufsize) {\r
HKEY pk = NULL;\r
kconf_conf_space * c;\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
pvalue, \r
KCONF_FLAG_TRAILINGVALUE | (pconf?khc_handle_flags(pconf):0), \r
&conf)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
free_space = 1;\r
#if 0\r
wchar_t * back, *forward;\r
}\r
\r
if(!khc_is_handle(conf))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
c = khc_space_from_handle(conf);\r
\r
if(khc_is_user_handle(conf)) {\r
- pk = khc_space_open_key(c, KHM_PERM_WRITE | KHM_FLAG_CREATE);\r
+ pk = khcint_space_open_key(c, KHM_PERM_WRITE | KHM_FLAG_CREATE);\r
} else {\r
- pk = khc_space_open_key(c, KHM_PERM_WRITE | KCONF_FLAG_MACHINE | KHM_FLAG_CREATE);\r
+ pk = khcint_space_open_key(c, KHM_PERM_WRITE | KCONF_FLAG_MACHINE | KHM_FLAG_CREATE);\r
}\r
\r
hr = RegSetValueEx(pk, value, 0, REG_BINARY, buf, (DWORD) bufsize);\r
return rv;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI khc_get_config_space_name(khm_handle conf, wchar_t * buf, khm_size * bufsize) {\r
+KHMEXP khm_int32 KHMAPI \r
+khc_get_config_space_name(khm_handle conf, \r
+ wchar_t * buf, khm_size * bufsize) {\r
kconf_conf_space * c;\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
\r
return KHM_ERROR_NOT_READY;\r
\r
if(!khc_is_handle(conf))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
c = khc_space_from_handle(conf);\r
\r
return rv;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI khc_get_config_space_parent(khm_handle conf, khm_handle * parent) {\r
+KHMEXP khm_int32 KHMAPI \r
+khc_get_config_space_parent(khm_handle conf, khm_handle * parent) {\r
kconf_conf_space * c;\r
\r
if(!khc_is_config_running())\r
return KHM_ERROR_NOT_READY;\r
\r
if(!khc_is_handle(conf))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
c = khc_space_from_handle(conf);\r
\r
if(c == conf_root || c->parent == conf_root)\r
*parent = NULL;\r
else\r
- *parent = khc_handle_from_space(c->parent, khc_handle_flags(conf));\r
+ *parent = khcint_handle_from_space(c->parent, khc_handle_flags(conf));\r
\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI khc_get_type(khm_handle conf, wchar_t * value) {\r
+KHMEXP khm_int32 KHMAPI \r
+khc_get_type(khm_handle conf, wchar_t * value) {\r
HKEY hkm = NULL;\r
HKEY hku = NULL;\r
kconf_conf_space * c;\r
c = (kconf_conf_space *) conf;\r
\r
if(!khc_is_machine_handle(conf))\r
- hku = khc_space_open_key(c, KHM_PERM_READ);\r
- hkm = khc_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
+ hku = khcint_space_open_key(c, KHM_PERM_READ);\r
+ hkm = khcint_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
\r
if(hku)\r
hr = RegQueryValueEx(hku, value, NULL, &type, NULL, NULL);\r
return rv;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI khc_value_exists(khm_handle conf, wchar_t * value) {\r
+KHMEXP khm_int32 KHMAPI \r
+khc_value_exists(khm_handle conf, wchar_t * value) {\r
HKEY hku = NULL;\r
HKEY hkm = NULL;\r
kconf_conf_space * c;\r
return KHM_ERROR_NOT_READY;\r
\r
if(!khc_is_handle(conf))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
c = khc_space_from_handle(conf);\r
\r
if(!khc_is_machine_handle(conf))\r
- hku = khc_space_open_key(c, KHM_PERM_READ);\r
- hkm = khc_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
+ hku = khcint_space_open_key(c, KHM_PERM_READ);\r
+ hkm = khcint_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
\r
if(hku && (RegQueryValueEx(hku, value, NULL, &t, NULL, NULL) == ERROR_SUCCESS))\r
rv |= KCONF_FLAG_USER;\r
return rv;\r
}\r
\r
-khm_boolean khc_is_valid_name(wchar_t * name)\r
+KHMEXP khm_int32 KHMAPI\r
+khc_remove_value(khm_handle conf, wchar_t * value, khm_int32 flags) {\r
+ HKEY hku = NULL;\r
+ HKEY hkm = NULL;\r
+ kconf_conf_space * c;\r
+ khm_int32 rv = KHM_ERROR_NOT_FOUND;\r
+ DWORD t;\r
+ LONG l;\r
+\r
+ if(!khc_is_config_running())\r
+ return KHM_ERROR_NOT_READY;\r
+\r
+ if(!khc_is_handle(conf))\r
+ return KHM_ERROR_INVALID_PARAM;\r
+\r
+ c = khc_space_from_handle(conf);\r
+\r
+ if(!khc_is_machine_handle(conf))\r
+ hku = khcint_space_open_key(c, KHM_PERM_READ);\r
+ hkm = khcint_space_open_key(c, KHM_PERM_READ | KCONF_FLAG_MACHINE);\r
+\r
+ if((flags == 0 ||\r
+ (flags & KCONF_FLAG_USER)) &&\r
+ hku && (RegQueryValueEx(hku, value, NULL, \r
+ &t, NULL, NULL) == ERROR_SUCCESS)) {\r
+ l = RegDeleteValue(hku, value);\r
+ if (l == ERROR_SUCCESS)\r
+ rv = KHM_ERROR_SUCCESS;\r
+ else\r
+ rv = KHM_ERROR_UNKNOWN;\r
+ }\r
+ if((flags == 0 ||\r
+ (flags & KCONF_FLAG_MACHINE)) &&\r
+ hkm && (RegQueryValueEx(hkm, value, NULL, \r
+ &t, NULL, NULL) == ERROR_SUCCESS)) {\r
+ l = RegDeleteValue(hkm, value);\r
+ if (l == ERROR_SUCCESS)\r
+ rv = (rv == KHM_ERROR_UNKNOWN)?KHM_ERROR_PARTIAL: \r
+ KHM_ERROR_SUCCESS;\r
+ else\r
+ rv = (rv == KHM_ERROR_SUCCESS)?KHM_ERROR_PARTIAL:\r
+ KHM_ERROR_UNKNOWN;\r
+ }\r
+\r
+ return rv;\r
+}\r
+\r
+KHMEXP khm_int32 KHMAPI\r
+khc_remove_space(khm_handle conf) {\r
+ /* TODO: implement this */\r
+\r
+ /*\r
+ - mark this space as well as all child spaces as\r
+ 'delete-on-close' using flags. Mark should indicate which\r
+ repository to delete the space from. (user/machine)\r
+\r
+ - When each subspace is released, check if it has been marked\r
+ for deletion. If so, delete the marked spaces as well as\r
+ removing the space from kconf space tree.\r
+\r
+ - When removing a subspace from a space, check if the parent\r
+ space has any children left. If there are none, check if the\r
+ parent space is also marked for deletion.\r
+ */\r
+ assert(FALSE);\r
+\r
+ return 0;\r
+}\r
+\r
+khm_boolean \r
+khcint_is_valid_name(wchar_t * name)\r
{\r
size_t cbsize;\r
if(FAILED(StringCbLength(name, KCONF_MAXCB_NAME, &cbsize)))\r
return TRUE;\r
}\r
\r
-khm_int32 khc_validate_schema(kconf_schema * schema,\r
- int begin,\r
- int *end)\r
+khm_int32 \r
+khcint_validate_schema(kconf_schema * schema,\r
+ int begin,\r
+ int *end)\r
{\r
int i;\r
int state = 0;\r
while(!end_found) {\r
switch(state) {\r
case 0: /* initial. this record should start a config space */\r
- if(!khc_is_valid_name(schema[i].name) ||\r
+ if(!khcint_is_valid_name(schema[i].name) ||\r
schema[i].type != KC_SPACE)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
state = 1;\r
break;\r
\r
case 1: /* we are inside a config space, in the values area */\r
- if(!khc_is_valid_name(schema[i].name))\r
- return KHM_ERROR_INVALID_PARM;\r
+ if(!khcint_is_valid_name(schema[i].name))\r
+ return KHM_ERROR_INVALID_PARAM;\r
if(schema[i].type == KC_SPACE) {\r
- if(KHM_FAILED(khc_validate_schema(schema, i, &i)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ if(KHM_FAILED(khcint_validate_schema(schema, i, &i)))\r
+ return KHM_ERROR_INVALID_PARAM;\r
state = 2;\r
} else if(schema[i].type == KC_ENDSPACE) {\r
end_found = 1;\r
schema[i].type != KC_INT32 &&\r
schema[i].type != KC_INT64 &&\r
schema[i].type != KC_BINARY)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
break;\r
\r
case 2: /* we are inside a config space, in the subspace area */\r
if(schema[i].type == KC_SPACE) {\r
- if(KHM_FAILED(khc_validate_schema(schema, i, &i)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ if(KHM_FAILED(khcint_validate_schema(schema, i, &i)))\r
+ return KHM_ERROR_INVALID_PARAM;\r
} else if(schema[i].type == KC_ENDSPACE) {\r
end_found = 1;\r
if(end)\r
*end = i;\r
} else {\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
break;\r
\r
default:\r
/* unreachable */\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
i++;\r
}\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
-khm_int32 khc_load_schema_i(khm_handle parent, kconf_schema * schema, int begin, int * end)\r
+khm_int32 \r
+khcint_load_schema_i(khm_handle parent, kconf_schema * schema, \r
+ int begin, int * end)\r
{\r
int i;\r
int state = 0;\r
while(!end_found) {\r
switch(state) {\r
case 0: /* initial. this record should start a config space */\r
- if(KHM_FAILED(khc_open_space(parent, schema[i].name, KHM_FLAG_CREATE, &h)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ if(KHM_FAILED(khc_open_space(parent, schema[i].name, \r
+ KHM_FLAG_CREATE, &h)))\r
+ return KHM_ERROR_INVALID_PARAM;\r
thisconf = khc_space_from_handle(h);\r
thisconf->schema = schema + (begin + 1);\r
state = 1;\r
case 1: /* we are inside a config space, in the values area */\r
if(schema[i].type == KC_SPACE) {\r
thisconf->nSchema = i - (begin + 1);\r
- if(KHM_FAILED(khc_load_schema_i(h, schema, i, &i)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ if(KHM_FAILED(khcint_load_schema_i(h, schema, i, &i)))\r
+ return KHM_ERROR_INVALID_PARAM;\r
state = 2;\r
} else if(schema[i].type == KC_ENDSPACE) {\r
thisconf->nSchema = i - (begin + 1);\r
\r
case 2: /* we are inside a config space, in the subspace area */\r
if(schema[i].type == KC_SPACE) {\r
- if(KHM_FAILED(khc_load_schema_i(h, schema, i, &i)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ if(KHM_FAILED(khcint_load_schema_i(h, schema, i, &i)))\r
+ return KHM_ERROR_INVALID_PARAM;\r
} else if(schema[i].type == KC_ENDSPACE) {\r
end_found = 1;\r
if(end)\r
*end = i;\r
khc_close_space(h);\r
} else {\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
break;\r
\r
default:\r
/* unreachable */\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
i++;\r
}\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI khc_load_schema(khm_handle conf, kconf_schema * schema)\r
+KHMEXP khm_int32 KHMAPI \r
+khc_load_schema(khm_handle conf, kconf_schema * schema)\r
{\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
\r
return KHM_ERROR_NOT_READY;\r
\r
if(conf && !khc_is_handle(conf))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
- if(KHM_FAILED(khc_validate_schema(schema, 0, NULL)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ if(KHM_FAILED(khcint_validate_schema(schema, 0, NULL)))\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_conf_global);\r
- rv = khc_load_schema_i(conf, schema, 0, NULL); \r
+ rv = khcint_load_schema_i(conf, schema, 0, NULL); \r
LeaveCriticalSection(&cs_conf_global);\r
\r
return rv;\r
}\r
\r
-khm_int32 khc_unload_schema_i(khm_handle parent, kconf_schema * schema, int begin, int * end)\r
+khm_int32 \r
+khcint_unload_schema_i(khm_handle parent, kconf_schema * schema, \r
+ int begin, int * end)\r
{\r
int i;\r
int state = 0;\r
switch(state) {\r
case 0: /* initial. this record should start a config space */\r
if(KHM_FAILED(khc_open_space(parent, schema[i].name, 0, &h)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
thisconf = khc_space_from_handle(h);\r
if(thisconf->schema == (schema + (begin + 1))) {\r
thisconf->schema = NULL;\r
\r
case 1: /* we are inside a config space, in the values area */\r
if(schema[i].type == KC_SPACE) {\r
- if(KHM_FAILED(khc_unload_schema_i(h, schema, i, &i)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ if(KHM_FAILED(khcint_unload_schema_i(h, schema, i, &i)))\r
+ return KHM_ERROR_INVALID_PARAM;\r
state = 2;\r
} else if(schema[i].type == KC_ENDSPACE) {\r
end_found = 1;\r
\r
case 2: /* we are inside a config space, in the subspace area */\r
if(schema[i].type == KC_SPACE) {\r
- if(KHM_FAILED(khc_unload_schema_i(h, schema, i, &i)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ if(KHM_FAILED(khcint_unload_schema_i(h, schema, i, &i)))\r
+ return KHM_ERROR_INVALID_PARAM;\r
} else if(schema[i].type == KC_ENDSPACE) {\r
end_found = 1;\r
if(end)\r
*end = i;\r
khc_close_space(h);\r
} else {\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
break;\r
\r
default:\r
/* unreachable */\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
i++;\r
}\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI khc_unload_schema(khm_handle conf, kconf_schema * schema)\r
+KHMEXP khm_int32 KHMAPI \r
+khc_unload_schema(khm_handle conf, kconf_schema * schema)\r
{\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
\r
return KHM_ERROR_NOT_READY;\r
\r
if(conf && !khc_is_handle(conf))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
- if(KHM_FAILED(khc_validate_schema(schema, 0, NULL)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ if(KHM_FAILED(khcint_validate_schema(schema, 0, NULL)))\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_conf_global);\r
- rv = khc_unload_schema_i(conf, schema, 0, NULL); \r
+ rv = khcint_unload_schema_i(conf, schema, 0, NULL); \r
LeaveCriticalSection(&cs_conf_global);\r
\r
return rv;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI khc_enum_subspaces(\r
- khm_handle conf,\r
- khm_handle prev,\r
- khm_handle * next)\r
+KHMEXP khm_int32 KHMAPI \r
+khc_enum_subspaces(khm_handle conf,\r
+ khm_handle prev,\r
+ khm_handle * next)\r
{\r
kconf_conf_space * s;\r
kconf_conf_space * c;\r
\r
if(!khc_is_handle(conf) || next == NULL ||\r
(prev != NULL && !khc_is_handle(prev)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
s = khc_space_from_handle(conf);\r
\r
{\r
HKEY hk_conf;\r
\r
- hk_conf = khc_space_open_key(s, 0);\r
+ hk_conf = khcint_space_open_key(s, 0);\r
if(hk_conf) {\r
wchar_t name[KCONF_MAXCCH_NAME];\r
khm_handle h;\r
{\r
HKEY hk_conf;\r
\r
- hk_conf = khc_space_open_key(s, KCONF_FLAG_MACHINE);\r
+ hk_conf = khcint_space_open_key(s, KCONF_FLAG_MACHINE);\r
if(hk_conf) {\r
wchar_t name[KCONF_MAXCCH_NAME];\r
khm_handle h;\r
khc_close_space(prev);\r
\r
if(c) {\r
- *next = khc_handle_from_space(c, khc_handle_flags(conf));\r
+ *next = khcint_handle_from_space(c, khc_handle_flags(conf));\r
rv = KHM_ERROR_SUCCESS;\r
} else {\r
*next = NULL;\r
return rv;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI khc_write_multi_string(khm_handle conf, wchar_t * value, wchar_t * buf)\r
+KHMEXP khm_int32 KHMAPI \r
+khc_write_multi_string(khm_handle conf, wchar_t * value, wchar_t * buf)\r
{\r
size_t cb;\r
+ wchar_t vbuf[KCONF_MAXCCH_STRING];\r
wchar_t *tb;\r
khm_int32 rv;\r
\r
if(!khc_is_config_running())\r
return KHM_ERROR_NOT_READY;\r
if(!khc_is_handle(conf) || buf == NULL || value == NULL)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if(multi_string_to_csv(NULL, &cb, buf) != KHM_ERROR_TOO_LONG)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
+\r
+ if (cb < sizeof(vbuf))\r
+ tb = vbuf;\r
+ else\r
+ tb = PMALLOC(cb);\r
+\r
+ assert(tb != NULL);\r
\r
- tb = malloc(cb);\r
- assert(tb != NULL);\r
multi_string_to_csv(tb, &cb, buf);\r
rv = khc_write_string(conf, value, tb);\r
\r
- free(tb);\r
+ if (tb != vbuf)\r
+ PFREE(tb);\r
return rv;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI khc_read_multi_string(khm_handle conf, wchar_t * value, wchar_t * buf, khm_size * bufsize)\r
+KHMEXP khm_int32 KHMAPI \r
+khc_read_multi_string(khm_handle conf, wchar_t * value, \r
+ wchar_t * buf, khm_size * bufsize)\r
{\r
+ wchar_t vbuf[KCONF_MAXCCH_STRING];\r
wchar_t * tb;\r
khm_size cbbuf;\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
return KHM_ERROR_NOT_READY;\r
\r
if(!bufsize)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
rv = khc_read_string(conf, value, NULL, &cbbuf);\r
if(rv != KHM_ERROR_TOO_LONG)\r
return rv;\r
\r
- tb = malloc(cbbuf);\r
- assert(tb != NULL);\r
+ if (cbbuf < sizeof(vbuf))\r
+ tb = vbuf;\r
+ else\r
+ tb = PMALLOC(cbbuf);\r
+\r
+ assert(tb != NULL);\r
+\r
rv = khc_read_string(conf, value, tb, &cbbuf);\r
\r
if(KHM_FAILED(rv))\r
rv = csv_to_multi_string(buf, bufsize, tb);\r
\r
_exit:\r
- free(tb);\r
+ if (tb != vbuf)\r
+ PFREE(tb);\r
\r
return rv;\r
}\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
and settings \a flags to the required flags.\r
\r
*/\r
-KHMEXP khm_int32 KHMAPI khc_open_space(khm_handle parent, wchar_t * cspace, khm_int32 flags, khm_handle * result);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_open_space(khm_handle parent, wchar_t * cspace, khm_int32 flags, \r
+ khm_handle * result);\r
\r
/*! \brief Set the shadow space for a configuration handle\r
\r
\r
Specify NULL for \a lower to remove any prior shadow.\r
*/\r
-KHMEXP khm_int32 KHMAPI khc_shadow_space(khm_handle upper, khm_handle lower);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_shadow_space(khm_handle upper, khm_handle lower);\r
\r
/*! \brief Close a handle opened with khc_open_space()\r
*/\r
-KHMEXP khm_int32 KHMAPI khc_close_space(khm_handle conf);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_close_space(khm_handle conf);\r
\r
/*! \brief Read a string value from a configuration space\r
\r
the required buffer if \a buf is NULL or insufficient.\r
\r
\retval KHM_ERROR_NOT_READY The configuration provider has not started\r
- \retval KHM_ERROR_INVALID_PARM One or more of the supplied parameters are not valid\r
+ \retval KHM_ERROR_INVALID_PARAM One or more of the supplied parameters are not valid\r
\retval KHM_ERROR_TYPE_MISMATCH The specified value is not a string\r
\retval KHM_ERROR_TOO_LONG \a buf was NULL or the size of the buffer was insufficient. The required size is in bufsize.\r
\retval KHM_ERROR_SUCCESS Success. The number of bytes copied is in bufsize.\r
\r
\see khc_open_space()\r
*/\r
-KHMEXP khm_int32 KHMAPI khc_read_string(\r
- khm_handle conf, \r
- wchar_t * value, \r
- wchar_t * buf, \r
- khm_size * bufsize);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_read_string(khm_handle conf, \r
+ wchar_t * value, \r
+ wchar_t * buf, \r
+ khm_size * bufsize);\r
\r
/*! \brief Read a multi-string value from a configuration space\r
\r
the required buffer if \a buf is NULL or insufficient.\r
\r
\retval KHM_ERROR_NOT_READY The configuration provider has not started\r
- \retval KHM_ERROR_INVALID_PARM One or more of the supplied parameters are not valid\r
+ \retval KHM_ERROR_INVALID_PARAM One or more of the supplied parameters are not valid\r
\retval KHM_ERROR_TYPE_MISMATCH The specified value is not a string\r
\retval KHM_ERROR_TOO_LONG \a buf was NULL or the size of the buffer was insufficient. The required size is in bufsize.\r
\retval KHM_ERROR_SUCCESS Success. The number of bytes copied is in bufsize.\r
\r
\see khc_open_space()\r
*/\r
-KHMEXP khm_int32 KHMAPI khc_read_multi_string(\r
- khm_handle conf, \r
- wchar_t * value, \r
- wchar_t * buf, \r
- khm_size * bufsize);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_read_multi_string(khm_handle conf, \r
+ wchar_t * value, \r
+ wchar_t * buf, \r
+ khm_size * bufsize);\r
\r
/*! \brief Read a 32 bit integer value from a configuration space\r
\r
\retval KHM_ERROR_NOT_READY The configuration provider has not started.\r
\retval KHM_ERROR_SUCCESS Success. The value that was read was placed in \a buf\r
\retval KHM_ERROR_NOT_FOUND The specified value was not found\r
- \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid\r
+ \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid\r
\retval KHM_ERROR_TYPE_MISMATCH The specified value was found but was not of the correct type.\r
\see khc_open_space()\r
*/\r
-KHMEXP khm_int32 KHMAPI khc_read_int32(\r
- khm_handle conf, \r
- wchar_t * value, \r
- khm_int32 * buf);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_read_int32(khm_handle conf, \r
+ wchar_t * value, \r
+ khm_int32 * buf);\r
\r
/*! \brief Read a 64 bit integer value from a configuration space\r
\r
\retval KHM_ERROR_NOT_READY The configuration provider has not started\r
\retval KHM_ERROR_SUCCESS Success. The value that was read was placed in \a buf\r
\retval KHM_ERROR_NOT_FOUND The specified value was not found\r
- \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid\r
+ \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid\r
\retval KHM_ERROR_TYPE_MISMATCH The specified value was found but was not the correct data type.\r
\r
\see khc_open_space()\r
*/\r
-KHMEXP khm_int32 KHMAPI khc_read_int64(\r
- khm_handle conf, \r
- wchar_t * value, \r
- khm_int64 * buf);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_read_int64(khm_handle conf, \r
+ wchar_t * value, \r
+ khm_int64 * buf);\r
\r
/*! \brief Read a binary value from a configuration space\r
\r
\r
\retval KHM_ERROR_SUCCESS Success. The data was copied to \a buf. The number of bytes copied is stored in \a bufsize\r
\retval KHM_ERROR_NOT_FOUND The specified value was not found\r
- \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid.\r
+ \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid.\r
\r
\see khc_open_space()\r
*/\r
-KHMEXP khm_int32 KHMAPI khc_read_binary(\r
- khm_handle conf, \r
- wchar_t * value, \r
- void * buf, \r
- khm_size * bufsize);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_read_binary(khm_handle conf, \r
+ wchar_t * value, \r
+ void * buf, \r
+ khm_size * bufsize);\r
\r
/*! \brief Write a string value to a configuration space\r
\r
\r
\see khc_open_space()\r
*/\r
-KHMEXP khm_int32 KHMAPI khc_write_string(\r
- khm_handle conf, \r
- wchar_t * value, \r
- wchar_t * buf);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_write_string(khm_handle conf, \r
+ wchar_t * value, \r
+ wchar_t * buf);\r
\r
/*! \brief Write a multi-string value to a configuration space\r
\r
\r
\see khc_open_space()\r
*/\r
-KHMEXP khm_int32 KHMAPI khc_write_multi_string(\r
- khm_handle conf, \r
- wchar_t * value, \r
- wchar_t * buf);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_write_multi_string(khm_handle conf, \r
+ wchar_t * value, \r
+ wchar_t * buf);\r
\r
/*! \brief Write a 32 bit integer value to a configuration space\r
\r
\r
\see khc_open_space()\r
*/\r
-KHMEXP khm_int32 KHMAPI khc_write_int32(\r
- khm_handle conf, \r
- wchar_t * value, \r
- khm_int32 buf);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_write_int32(khm_handle conf, \r
+ wchar_t * value, \r
+ khm_int32 buf);\r
\r
/*! \brief Write a 64 bit integer value to a configuration space\r
\r
\r
\see khc_open_space()\r
*/\r
-KHMEXP khm_int32 KHMAPI khc_write_int64(\r
- khm_handle conf, \r
- wchar_t * value, \r
- khm_int64 buf);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_write_int64(khm_handle conf, \r
+ wchar_t * value, \r
+ khm_int64 buf);\r
\r
/*! \brief Write a binary value to a configuration space\r
\r
\r
\see khc_open_space()\r
*/\r
-KHMEXP khm_int32 KHMAPI khc_write_binary(\r
- khm_handle conf, \r
- wchar_t * value, \r
- void * buf, \r
- khm_size bufsize);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_write_binary(khm_handle conf, \r
+ wchar_t * value, \r
+ void * buf, \r
+ khm_size bufsize);\r
\r
/*! \brief Get the type of a value in a configuration space\r
\r
\return The return value is the type of the specified value, or\r
KC_NONE if the value does not exist.\r
*/\r
-KHMEXP khm_int32 KHMAPI khc_get_type(khm_handle conf, wchar_t * value);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_get_type(khm_handle conf, wchar_t * value);\r
\r
/*! \brief Check which configuration stores contain a specific value.\r
\r
and ::KCONF_FLAG_SCHEMA indicating which stores contain the\r
value.\r
*/\r
-KHMEXP khm_int32 KHMAPI khc_value_exists(khm_handle conf, wchar_t * value);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_value_exists(khm_handle conf, wchar_t * value);\r
+\r
+/*! \brief Remove a value from a configuration space\r
+\r
+ Removes a value from one or more configuration stores.\r
+\r
+ A value can exist in multiple configuration stores. Only the\r
+ values that are stored in writable stores can be removed. When\r
+ the function searches for values to remove, it will only look in\r
+ configuration stores that are specified in the handle. In\r
+ addition, the configuration stores affected can be further\r
+ narrowed by specifying them in the \a flags parameter. If \a\r
+ flags is zero, then all the stores visible to the handle are\r
+ searched. If \a flags specifies ::KCONF_FLAG_USER or\r
+ ::KCONF_FLAG_MACHINE or both, then only the specified stores are\r
+ searched, provided that the stores are visible to the handle.\r
+\r
+ This function only operates on the topmost configuration space\r
+ visible to the handle. If the configuration handle is shadowed,\r
+ the shadowed configuration spaces are unaffected by the removal.\r
+\r
+ \param[in] conf Handle to configuration space to remove value from\r
+\r
+ \param[in] value Value to remove\r
+\r
+ \param[in] flags Specifies which configuration stores will be\r
+ affected by the removal. See above.\r
+\r
+ \retval KHM_ERROR_SUCCESS The value was removed from all the\r
+ specified configuration stores.\r
+\r
+ \retval KHM_ERROR_NOT_FOUND The value was not found.\r
+\r
+ \retval KHM_ERROR_UNKNOWN An unknown error occurred while trying\r
+ to remove the value.\r
+\r
+ \retval KHM_ERROR_PARTIAL The value was successfully removed from\r
+ one or more stores, but the operation failed on one or more\r
+ other stores.\r
+ */\r
+KHMEXP khm_int32 KHMAPI\r
+khc_remove_value(khm_handle conf, wchar_t * value, khm_int32 flags);\r
\r
/*! \brief Get the name of a configuration space\r
\r
pointed to by \a buf. On exit, holds the number of bytes\r
copied into the buffer including the NULL terminator.\r
*/\r
-KHMEXP khm_int32 KHMAPI khc_get_config_space_name(\r
- khm_handle conf, \r
- wchar_t * buf, \r
- khm_size * bufsize);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_get_config_space_name(khm_handle conf, \r
+ wchar_t * buf, \r
+ khm_size * bufsize);\r
\r
/*! \brief Get a handle to the parent space\r
\r
call succeeds. Receives NULL otherwise. The returned handle\r
must be closed using khc_close_space()\r
*/\r
-KHMEXP khm_int32 KHMAPI khc_get_config_space_parent(\r
- khm_handle conf, \r
- khm_handle * parent);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_get_config_space_parent(khm_handle conf, \r
+ khm_handle * parent);\r
\r
/*! \brief Load a configuration schema into the specified configuration space\r
\r
\r
\see khc_unload_schema()\r
*/\r
-KHMEXP khm_int32 KHMAPI khc_load_schema(\r
- khm_handle conf, \r
- kconf_schema * schema);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_load_schema(khm_handle conf, \r
+ kconf_schema * schema);\r
\r
/*! \brief Unload a schema from a configuration space\r
*/\r
-KHMEXP khm_int32 KHMAPI khc_unload_schema(\r
- khm_handle conf, \r
- kconf_schema * schema);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_unload_schema(khm_handle conf, \r
+ kconf_schema * schema);\r
\r
/*! \brief Enumerate the subspaces of a configuration space\r
\r
\retval KHM_ERROR_SUCCESS The call succeeded. There is a valid\r
handle to a configuration space in \a first_subspace.\r
\r
- \retval KHM_ERROR_INVALID_PARM Either \a conf or \a prev was not a\r
+ \retval KHM_ERROR_INVALID_PARAM Either \a conf or \a prev was not a\r
valid configuration space handle or \a first_subspace is NULL.\r
Note that \a prev can be NULL.\r
\r
However, the returned handle has the same domain restrictions\r
as \a conf.\r
*/\r
-KHMEXP khm_int32 KHMAPI khc_enum_subspaces(\r
- khm_handle conf,\r
- khm_handle prev,\r
- khm_handle * next);\r
+KHMEXP khm_int32 KHMAPI \r
+khc_enum_subspaces(khm_handle conf,\r
+ khm_handle prev,\r
+ khm_handle * next);\r
\r
/*@}*/\r
\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
TDCL(struct kconf_conf_space_t);\r
} kconf_conf_space;\r
\r
-#define KCONF_SPACE_FLAG_SCHEMA 32\r
+//#define KCONF_SPACE_FLAG_SCHEMA 0x00000020\r
+#define KCONF_SPACE_FLAG_DELETED 0x00000040\r
\r
typedef struct kconf_conf_handle_t {\r
khm_int32 magic;\r
#define khc_is_machine_handle(h) (((kconf_handle *) h)->flags & KCONF_FLAG_MACHINE)\r
#define khc_handle_flags(h) (((kconf_handle *) h)->flags)\r
\r
-kconf_handle * khc_handle_from_space(kconf_conf_space * s, khm_int32 flags);\r
-void khc_handle_free(kconf_handle * h);\r
+kconf_handle *\r
+khcint_handle_from_space(kconf_conf_space * s, khm_int32 flags);\r
\r
-kconf_conf_space * khc_create_empty_space(void);\r
-void khc_free_space(kconf_conf_space * r);\r
+void\r
+khcint_handle_free(kconf_handle * h);\r
\r
-void khc_space_hold(kconf_conf_space * s);\r
-void khc_space_release(kconf_conf_space * s);\r
+kconf_conf_space *\r
+khcint_create_empty_space(void);\r
\r
-HKEY khc_space_open_key(kconf_conf_space * s, khm_int32 flags);\r
+void\r
+khcint_free_space(kconf_conf_space * r);\r
+\r
+void\r
+khcint_space_hold(kconf_conf_space * s);\r
+\r
+void\r
+khcint_space_release(kconf_conf_space * s);\r
+\r
+HKEY\r
+khcint_space_open_key(kconf_conf_space * s, khm_int32 flags);\r
\r
#endif\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
kcdb_attrib_i ** kcdb_property_tbl = NULL;\r
kcdb_attrib_i * kcdb_attribs = NULL;\r
\r
-void kcdb_attrib_add_ref_func(const void * key, void * va)\r
+void \r
+kcdb_attrib_add_ref_func(const void * key, void * va)\r
{\r
kcdb_attrib_hold((kcdb_attrib_i *) va);\r
}\r
\r
-void kcdb_attrib_del_ref_func(const void * key, void * va)\r
+void \r
+kcdb_attrib_del_ref_func(const void * key, void * va)\r
{\r
kcdb_attrib_release((kcdb_attrib_i *) va);\r
}\r
\r
-void kcdb_attrib_msg_completion(kmq_message * m) \r
+void \r
+kcdb_attrib_msg_completion(kmq_message * m) \r
{\r
if(m && m->vparam) {\r
kcdb_attrib_release((kcdb_attrib_i *) m->vparam);\r
}\r
}\r
\r
-khm_int32 kcdb_attrib_hold(kcdb_attrib_i * ai)\r
+khm_int32 \r
+kcdb_attrib_hold(kcdb_attrib_i * ai)\r
{\r
if(!ai)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_attrib);\r
ai->refcount++;\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
-khm_int32 kcdb_attrib_release(kcdb_attrib_i * ai)\r
+khm_int32 \r
+kcdb_attrib_release(kcdb_attrib_i * ai)\r
{\r
if(!ai)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_attrib);\r
ai->refcount--;\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
-void kcdb_attrib_post_message(khm_int32 op, kcdb_attrib_i * ai)\r
+void \r
+kcdb_attrib_post_message(khm_int32 op, kcdb_attrib_i * ai)\r
{\r
kcdb_attrib_hold(ai);\r
kmq_post_message(KMSG_KCDB, KMSG_KCDB_ATTRIB, op, (void *) ai);\r
}\r
\r
-khm_int32 KHMAPI kcdb_attr_sys_cb(khm_handle vcred, \r
- khm_int32 attr, \r
- void * buf, \r
- khm_size * pcb_buf)\r
+khm_int32 KHMAPI \r
+kcdb_attr_sys_cb(khm_handle vcred, \r
+ khm_int32 attr, \r
+ void * buf, \r
+ khm_size * pcb_buf)\r
{\r
kcdb_cred * c;\r
\r
}\r
}\r
\r
-void kcdb_attrib_init(void)\r
+void \r
+kcdb_attrib_init(void)\r
{\r
kcdb_attrib attrib;\r
wchar_t sbuf[256];\r
\r
InitializeCriticalSection(&cs_attrib);\r
- kcdb_attrib_namemap = hash_new_hashtable(\r
- KCDB_ATTRIB_HASH_SIZE,\r
- hash_string,\r
- hash_string_comp,\r
- kcdb_attrib_add_ref_func,\r
- kcdb_attrib_del_ref_func);\r
+ kcdb_attrib_namemap = \r
+ hash_new_hashtable(KCDB_ATTRIB_HASH_SIZE,\r
+ hash_string,\r
+ hash_string_comp,\r
+ kcdb_attrib_add_ref_func,\r
+ kcdb_attrib_del_ref_func);\r
\r
kcdb_attrib_tbl = \r
- malloc(sizeof(kcdb_attrib_i *) * (KCDB_ATTR_MAX_ID + 1));\r
+ PMALLOC(sizeof(kcdb_attrib_i *) * (KCDB_ATTR_MAX_ID + 1));\r
assert(kcdb_attrib_tbl != NULL);\r
ZeroMemory(kcdb_attrib_tbl, \r
sizeof(kcdb_attrib_i *) * (KCDB_ATTR_MAX_ID + 1));\r
\r
kcdb_property_tbl = \r
- malloc(sizeof(kcdb_attrib_i *) * KCDB_ATTR_MAX_PROPS);\r
+ PMALLOC(sizeof(kcdb_attrib_i *) * KCDB_ATTR_MAX_PROPS);\r
assert(kcdb_property_tbl != NULL);\r
ZeroMemory(kcdb_property_tbl, \r
sizeof(kcdb_attrib_i *) * KCDB_ATTR_MAX_PROPS);\r
kcdb_attrib_register(&attrib, NULL);\r
}\r
\r
-void kcdb_attrib_exit(void)\r
+void \r
+kcdb_attrib_exit(void)\r
{\r
DeleteCriticalSection(&cs_attrib);\r
\r
if(kcdb_attrib_tbl)\r
- free(kcdb_attrib_tbl);\r
+ PFREE(kcdb_attrib_tbl);\r
\r
if(kcdb_property_tbl)\r
- free(kcdb_property_tbl);\r
+ PFREE(kcdb_property_tbl);\r
}\r
\r
-KHMEXP khm_int32 KHMAPI kcdb_attrib_get_id(wchar_t *name, khm_int32 * id)\r
+KHMEXP khm_int32 KHMAPI \r
+kcdb_attrib_get_id(wchar_t *name, khm_int32 * id)\r
{\r
kcdb_attrib_i * ai;\r
\r
if(!name)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_attrib);\r
ai = hash_lookup(kcdb_attrib_namemap, (void *) name);\r
}\r
}\r
\r
-KHMEXP khm_int32 KHMAPI kcdb_attrib_register(kcdb_attrib * attrib, khm_int32 * new_id)\r
+KHMEXP khm_int32 KHMAPI \r
+kcdb_attrib_register(kcdb_attrib * attrib, khm_int32 * new_id)\r
{\r
kcdb_attrib_i * ai;\r
size_t cb_name;\r
if(!attrib ||\r
KHM_FAILED(kcdb_type_get_info(attrib->type, NULL)) ||\r
!attrib->name)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if(FAILED(StringCbLength(attrib->name, KCDB_MAXCB_NAME, &cb_name)))\r
return KHM_ERROR_TOO_LONG;\r
(!attrib->compute_cb ||\r
attrib->compute_min_cbsize <= 0 ||\r
attrib->compute_max_cbsize < attrib->compute_min_cbsize))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if ((attrib->flags & KCDB_ATTR_FLAG_ALTVIEW) &&\r
KHM_FAILED(kcdb_attrib_get_info(attrib->alt_id,\r
NULL)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
prop = !!(attrib->flags & KCDB_ATTR_FLAG_PROPERTY);\r
\r
EnterCriticalSection(&cs_attrib);\r
\r
- if(\r
- !prop && \r
- (attrib->id < 0 || attrib->id > KCDB_ATTR_MAX_ID)) \r
+ if(!prop && \r
+ (attrib->id < 0 || attrib->id > KCDB_ATTR_MAX_ID)) \r
{\r
if(KHM_FAILED(kcdb_attrib_next_free_id(&attr_id))) {\r
LeaveCriticalSection(&cs_attrib);\r
return KHM_ERROR_NO_RESOURCES;\r
}\r
- } else if (\r
- prop &&\r
- (attrib->id < KCDB_ATTR_MIN_PROP_ID || attrib->id > KCDB_ATTR_MAX_PROP_ID))\r
- {\r
+ } else if (prop &&\r
+ (attrib->id < KCDB_ATTR_MIN_PROP_ID || \r
+ attrib->id > KCDB_ATTR_MAX_PROP_ID)) {\r
+\r
if(KHM_FAILED(kcdb_attrib_next_free_prop_id(&attr_id))) {\r
LeaveCriticalSection(&cs_attrib);\r
return KHM_ERROR_NO_RESOURCES;\r
}\r
+\r
} else {\r
attr_id = attrib->id;\r
}\r
\r
#ifdef DEBUG\r
assert(!prop || (attr_id >= KCDB_ATTR_MIN_PROP_ID && attr_id <= KCDB_ATTR_MAX_PROP_ID));\r
- assert(prop || (attr_id >= 0 && attr_id <= KCDB_ATTR_MAX_ID));\r
+ assert(prop || (attr_id >= 0 && attr_id <= KCDB_ATTR_MAX_ID));\r
#endif\r
\r
if((!prop && kcdb_attrib_tbl[attr_id]) ||\r
- (prop && kcdb_property_tbl[attr_id - KCDB_ATTR_MIN_PROP_ID])) \r
- {\r
+ (prop && kcdb_property_tbl[attr_id - KCDB_ATTR_MIN_PROP_ID])) {\r
+\r
LeaveCriticalSection(&cs_attrib);\r
return KHM_ERROR_DUPLICATE;\r
+\r
}\r
\r
- ai = malloc(sizeof(kcdb_attrib_i));\r
+ ai = PMALLOC(sizeof(kcdb_attrib_i));\r
ZeroMemory(ai, sizeof(kcdb_attrib_i));\r
\r
ai->attr.type = attrib->type;\r
ai->attr.compute_cb = attrib->compute_cb;\r
ai->attr.compute_max_cbsize = attrib->compute_max_cbsize;\r
ai->attr.compute_min_cbsize = attrib->compute_min_cbsize;\r
- ai->attr.name = malloc(cb_name);\r
+ ai->attr.name = PMALLOC(cb_name);\r
StringCbCopy(ai->attr.name, cb_name, attrib->name);\r
if(cb_short_desc) {\r
- ai->attr.short_desc = malloc(cb_short_desc);\r
+ ai->attr.short_desc = PMALLOC(cb_short_desc);\r
StringCbCopy(ai->attr.short_desc, cb_short_desc, attrib->short_desc);\r
}\r
if(cb_long_desc) {\r
- ai->attr.long_desc = malloc(cb_long_desc);\r
+ ai->attr.long_desc = PMALLOC(cb_long_desc);\r
StringCbCopy(ai->attr.long_desc, cb_long_desc, attrib->long_desc);\r
}\r
\r
else if(id >= KCDB_ATTR_MIN_PROP_ID && id <= KCDB_ATTR_MAX_PROP_ID)\r
prop = TRUE;\r
else\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_attrib);\r
if(prop)\r
khm_boolean prop;\r
\r
if(!cbsize)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if(id >= 0 && id <= KCDB_ATTR_MAX_ID)\r
prop = FALSE;\r
int i;\r
\r
if(!id)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_attrib);\r
for(i=0;i < KCDB_ATTR_MAX_PROPS; i++) {\r
int i;\r
\r
if(!id)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_attrib);\r
for(i=0;i<= KCDB_ATTR_MAX_ID; i++) {\r
int i;\r
\r
if(pcount == NULL)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
eq_flags &= and_flags;\r
\r
int i;\r
\r
if(plist == NULL || pcsize == NULL)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
eq_flags &= and_flags;\r
\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
void kcdb_attrib_post_message(khm_int32 op, kcdb_attrib_i * ai);\r
khm_int32 KHMAPI kcdb_attr_sys_cb(khm_handle cred, khm_int32 attr, void * buf, khm_size * pcb_buf);\r
\r
-#endif
\ No newline at end of file
+#endif\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
\r
void kcdb_buf_new(kcdb_buf * buf, khm_size n_fields)\r
{\r
- buf->buffer = malloc(KCDB_BUF_CBBUF_INITIAL);\r
+ buf->buffer = PMALLOC(KCDB_BUF_CBBUF_INITIAL);\r
buf->cb_buffer = KCDB_BUF_CBBUF_INITIAL;\r
buf->cb_used = 0;\r
\r
\r
buf->n_fields = n_fields;\r
buf->nc_fields = UBOUNDSS(n_fields, KCDB_BUF_FIELDS_INITIAL, KCDB_BUF_FIELDS_GROWTH);\r
- buf->fields = malloc(sizeof(buf->fields[0]) * buf->n_fields);\r
+ buf->fields = PMALLOC(sizeof(buf->fields[0]) * buf->n_fields);\r
ZeroMemory(buf->fields, sizeof(buf->fields[0]) * buf->n_fields);\r
}\r
\r
buf->cb_buffer = 0;\r
buf->cb_used = 0;\r
if(buf->buffer)\r
- free(buf->buffer);\r
+ PFREE(buf->buffer);\r
buf->buffer = NULL;\r
\r
buf->n_fields = 0;\r
buf->nc_fields = 0;\r
if(buf->fields)\r
- free(buf->fields);\r
+ PFREE(buf->fields);\r
buf->fields = NULL;\r
}\r
\r
\r
assert(new_size > buf->cb_buffer && new_size > 0);\r
\r
- new_buf = malloc(new_size);\r
+ new_buf = PMALLOC(new_size);\r
assert(new_buf != NULL);\r
\r
memcpy(new_buf, buf->buffer, buf->cb_used);\r
- free(buf->buffer);\r
+ PFREE(buf->buffer);\r
buf->buffer = new_buf;\r
}\r
\r
\r
ns = UBOUNDSS((slot + 1), KCDB_BUF_FIELDS_INITIAL, KCDB_BUF_FIELDS_GROWTH);\r
\r
- nf = malloc(sizeof(buf->fields[0]) * ns);\r
+ nf = PMALLOC(sizeof(buf->fields[0]) * ns);\r
memcpy(nf, buf->fields, sizeof(buf->fields[0]) * buf->n_fields);\r
\r
if(ns > buf->n_fields)\r
memset(&(nf[buf->n_fields]), 0, sizeof(buf->fields[0]) * (ns - buf->n_fields));\r
\r
- free(buf->fields);\r
+ PFREE(buf->fields);\r
buf->fields = nf;\r
buf->nc_fields = ns;\r
}\r
\r
dest->cb_buffer = cb_buf;\r
dest->cb_used = src->cb_used;\r
- dest->buffer = malloc(cb_buf);\r
+ dest->buffer = PMALLOC(cb_buf);\r
memcpy(dest->buffer, src->buffer, src->cb_used);\r
\r
nc_fields = UBOUNDSS(src->n_fields, KCDB_BUF_FIELDS_INITIAL, KCDB_BUF_FIELDS_GROWTH);\r
dest->nc_fields = nc_fields;\r
dest->n_fields = src->n_fields;\r
- dest->fields = malloc(nc_fields * sizeof(dest->fields[0]));\r
+ dest->fields = PMALLOC(nc_fields * sizeof(dest->fields[0]));\r
memcpy(dest->fields, src->fields, src->n_fields * sizeof(dest->fields[0]));\r
if(dest->n_fields < dest->nc_fields)\r
memset(&(dest->fields[dest->n_fields]), 0, (src->nc_fields - src->n_fields) * sizeof(dest->fields[0]));\r
else if(kcdb_is_active_identity(record))\r
return kcdb_identity_get_attr(record, attr_id, attr_type, buffer, pcb_buf);\r
else\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
KHMEXP khm_int32 KHMAPI kcdb_buf_get_attrib(\r
else if(kcdb_is_active_identity(record))\r
return kcdb_identity_get_attrib(record, attr_name, attr_type, buffer, pcb_buf);\r
else\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
KHMEXP khm_int32 KHMAPI kcdb_buf_get_attr_string(\r
else if(kcdb_is_active_identity(record))\r
return kcdb_identity_get_attr_string(record, attr_id, buffer, pcbbuf, flags);\r
else\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
KHMEXP khm_int32 KHMAPI kcdb_buf_get_attrib_string(\r
else if(kcdb_is_active_identity(record))\r
return kcdb_identity_get_attrib_string(record, attr_name, buffer, pcbbuf, flags);\r
else\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
KHMEXP khm_int32 KHMAPI kcdb_buf_set_attr(\r
else if(kcdb_is_active_identity(record))\r
return kcdb_identity_set_attr(record, attr_id, buffer, cbbuf);\r
else\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
KHMEXP khm_int32 KHMAPI kcdb_buf_set_attrib(\r
else if(kcdb_is_active_identity(record))\r
return kcdb_identity_set_attrib(record, attr_name, buffer, cbbuf);\r
else\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
KHMEXP khm_int32 KHMAPI kcdb_buf_hold(khm_handle record)\r
else if(kcdb_is_active_identity(record))\r
return kcdb_identity_hold(record);\r
else\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
KHMEXP khm_int32 KHMAPI kcdb_buf_release(khm_handle record)\r
else if(kcdb_is_active_identity(record))\r
return kcdb_identity_release(record);\r
else\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
can be called by kcdb_cred_dup with a write lock on l_creds and in other\r
places with a read lock on l_creds. New credentials must be creatable while\r
holding either lock. */\r
-KHMEXP khm_int32 KHMAPI kcdb_cred_create(\r
- wchar_t * name, \r
- khm_handle identity,\r
- khm_int32 cred_type,\r
- khm_handle * result) \r
+KHMEXP khm_int32 KHMAPI \r
+kcdb_cred_create(wchar_t * name, \r
+ khm_handle identity,\r
+ khm_int32 cred_type,\r
+ khm_handle * result) \r
{\r
kcdb_cred * cred;\r
size_t cb_name;\r
if(!name || !result ||\r
FAILED(StringCbLength(name, KCDB_CRED_MAXCB_NAME, &cb_name)) ||\r
KHM_FAILED(kcdb_credtype_get_info(cred_type, NULL)) ||\r
- KHM_FAILED(kcdb_identity_hold(identity))\r
- )\r
- {\r
- return KHM_ERROR_INVALID_PARM;\r
+ KHM_FAILED(kcdb_identity_hold(identity))) {\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
cb_name += sizeof(wchar_t);\r
\r
- cred = malloc(sizeof(kcdb_cred));\r
+ cred = PMALLOC(sizeof(kcdb_cred));\r
ZeroMemory(cred, sizeof(kcdb_cred));\r
\r
cred->magic = KCDB_CRED_MAGIC;\r
cred->identity = identity;\r
- cred->name = malloc(cb_name);\r
+ cred->name = PMALLOC(cb_name);\r
StringCbCopy(cred->name, cb_name, name);\r
cred->type = cred_type;\r
\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI kcdb_cred_update(\r
- khm_handle vdest,\r
- khm_handle vsrc)\r
+KHMEXP khm_int32 KHMAPI kcdb_cred_update(khm_handle vdest,\r
+ khm_handle vsrc)\r
{\r
khm_int32 rv = KHM_ERROR_EQUIVALENT;\r
kcdb_cred * src;\r
kcdb_cred_lock_write();\r
\r
if(!kcdb_cred_is_active_cred(vsrc) ||\r
- !kcdb_cred_is_active_cred(vdest))\r
+ !kcdb_cred_is_active_cred(vdest))\r
goto _exit;\r
\r
src = (kcdb_cred *) vsrc;\r
khm_handle vnewcred;\r
\r
if(!pnewcred)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
*pnewcred = NULL;\r
\r
kcdb_cred_lock_write();\r
\r
if(!kcdb_cred_is_active_cred(vcred)) {\r
- code = KHM_ERROR_INVALID_PARM;\r
+ code = KHM_ERROR_INVALID_PARAM;\r
goto _exit;\r
}\r
\r
cred = (kcdb_cred *) vcred;\r
\r
- if(KHM_FAILED(kcdb_cred_create(\r
- cred->name,\r
- cred->identity,\r
- cred->type,\r
- &vnewcred))) \r
+ if(KHM_FAILED(kcdb_cred_create(cred->name,\r
+ cred->identity,\r
+ cred->type,\r
+ &vnewcred))) \r
{\r
code = KHM_ERROR_UNKNOWN;\r
goto _exit;\r
kcdb_cred * c;\r
\r
if(!pserial)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
- LockObtainRead(&l_creds);\r
+ kcdb_cred_lock_read();\r
\r
if(!kcdb_cred_is_active_cred(vcred)) {\r
- LockReleaseRead(&l_creds);\r
- return KHM_ERROR_INVALID_PARM;\r
+ kcdb_cred_unlock_read();\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
c = (kcdb_cred *) vcred;\r
\r
*pserial = c->id;\r
\r
- LockReleaseRead(&l_creds);\r
+ kcdb_cred_unlock_read();\r
\r
return KHM_ERROR_SUCCESS;\r
}\r
kcdb_cred * c;\r
\r
if(!kcdb_is_identity(id))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
kcdb_cred_lock_write();\r
if(!kcdb_cred_is_active_cred(vcred)) {\r
kcdb_cred_unlock_write();\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
c = (kcdb_cred *) vcred;\r
kcdb_cred * c;\r
\r
if(!type)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
- LockObtainRead(&l_creds);\r
+ kcdb_cred_lock_read();\r
\r
if(!kcdb_cred_is_active_cred(vcred)) {\r
- LockReleaseRead(&l_creds);\r
- return KHM_ERROR_INVALID_PARM;\r
+ kcdb_cred_unlock_read();\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
c = (kcdb_cred *) vcred;\r
\r
*type = c->type;\r
\r
- LockReleaseRead(&l_creds);\r
+ kcdb_cred_unlock_read();\r
\r
return KHM_ERROR_SUCCESS;\r
}\r
khm_int32 attr_id = -1;\r
\r
if(KHM_FAILED(kcdb_attrib_get_id(name, &attr_id)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
return kcdb_cred_set_attr(\r
cred,\r
khm_int32 code = KHM_ERROR_SUCCESS;\r
\r
if(attr_id < 0 || attr_id > KCDB_ATTR_MAX_ID)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
kcdb_cred_lock_write();\r
\r
if(!kcdb_cred_is_active_cred(vcred)) {\r
kcdb_cred_unlock_write();\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
cred = (kcdb_cred *) vcred;\r
\r
if(KHM_FAILED(kcdb_attrib_get_info(attr_id, &attrib))) {\r
kcdb_cred_unlock_write();\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
if(attrib->flags & KCDB_ATTR_FLAG_COMPUTED)\r
if(KHM_FAILED(kcdb_type_get_info(attrib->type, &type))) {\r
kcdb_cred_unlock_write();\r
kcdb_attrib_release_info(attrib);\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
if(!(type->isValid(buffer,cbbuf))) {\r
}\r
\r
if((type->dup(buffer, cbbuf, NULL, &cbdest)) != KHM_ERROR_TOO_LONG) {\r
- code = KHM_ERROR_INVALID_PARM;\r
+ code = KHM_ERROR_INVALID_PARAM;\r
goto _exit;\r
}\r
\r
flags);\r
}\r
\r
-KHMEXP khm_int32 KHMAPI kcdb_cred_get_attr(\r
- khm_handle vcred, \r
- khm_int32 attr_id,\r
- khm_int32 * attr_type,\r
- void * buffer, \r
- khm_size * pcbbuf)\r
+KHMEXP khm_int32 KHMAPI \r
+kcdb_cred_get_attr(khm_handle vcred, \r
+ khm_int32 attr_id,\r
+ khm_int32 * attr_type,\r
+ void * buffer, \r
+ khm_size * pcbbuf)\r
{\r
khm_int32 code = KHM_ERROR_SUCCESS;\r
kcdb_cred * cred = NULL;\r
kcdb_type * type = NULL;\r
\r
if(attr_id < 0 || attr_id > KCDB_ATTR_MAX_ID)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if(KHM_FAILED(kcdb_attrib_get_info(attr_id, &attrib))) {\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
if(KHM_FAILED(kcdb_type_get_info(attrib->type, &type))) {\r
if(attr_type)\r
*attr_type = attrib->type;\r
\r
- LockObtainRead(&l_creds);\r
+ kcdb_cred_lock_read();\r
if(!kcdb_cred_is_active_cred(vcred)) {\r
- code = KHM_ERROR_INVALID_PARM;\r
+ code = KHM_ERROR_INVALID_PARAM;\r
goto _exit;\r
}\r
\r
}\r
\r
_exit:\r
- LockReleaseRead(&l_creds);\r
+ kcdb_cred_unlock_read();\r
if(type)\r
kcdb_type_release_info(type);\r
if(attrib)\r
kcdb_type * type = NULL;\r
\r
if(attr_id < 0 || attr_id > KCDB_ATTR_MAX_ID)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if(KHM_FAILED(kcdb_attrib_get_info(attr_id, &attrib))) {\r
- code = KHM_ERROR_INVALID_PARM;\r
+ code = KHM_ERROR_INVALID_PARAM;\r
goto _exit;\r
}\r
\r
goto _exit;\r
}\r
\r
- LockObtainRead(&l_creds);\r
+ kcdb_cred_lock_read();\r
if(!kcdb_cred_is_active_cred(vcred)) {\r
- code = KHM_ERROR_INVALID_PARM;\r
+ code = KHM_ERROR_INVALID_PARAM;\r
goto _exit;\r
}\r
\r
cred = (kcdb_cred *) vcred;\r
\r
if(!buffer && !pcbbuf) {\r
- /* in this case the caller is only trying to determine if the field\r
- contains data. We assume that computed fields are always non-null. */\r
+ /* in this case the caller is only trying to determine if the\r
+ field contains data. We assume that computed fields are\r
+ always non-null. */\r
code = (kcdb_cred_val_exist(cred, attr_id) ||\r
(attrib->flags & KCDB_ATTR_FLAG_COMPUTED))?KHM_ERROR_SUCCESS:KHM_ERROR_NOT_FOUND;\r
goto _exit;\r
void * buf;\r
khm_size cbbuf;\r
\r
- code = attrib->compute_cb(\r
- vcred,\r
- attr_id,\r
- NULL,\r
- &cbbuf);\r
+ code = attrib->compute_cb(vcred,\r
+ attr_id,\r
+ NULL,\r
+ &cbbuf);\r
if(code == KHM_ERROR_TOO_LONG) {\r
- buf = malloc(cbbuf);\r
- code = attrib->compute_cb(\r
- vcred,\r
- attr_id,\r
- buf,\r
- &cbbuf);\r
+ wchar_t vbuf[KCDB_MAXCCH_NAME];\r
+\r
+ if (cbbuf < sizeof(vbuf))\r
+ buf = vbuf;\r
+ else\r
+ buf = PMALLOC(cbbuf);\r
+\r
+ code = attrib->compute_cb(vcred,\r
+ attr_id,\r
+ buf,\r
+ &cbbuf);\r
if(KHM_SUCCEEDED(code)) {\r
- code = type->toString(\r
- buf,\r
- cbbuf,\r
- buffer,\r
- pcbbuf,\r
- flags);\r
+ code = type->toString(buf,\r
+ cbbuf,\r
+ buffer,\r
+ pcbbuf,\r
+ flags);\r
}\r
- free(buf);\r
+\r
+ if (buf != vbuf)\r
+ PFREE(buf);\r
}\r
} else {\r
if(kcdb_cred_buf_exist(cred, attr_id)) {\r
}\r
\r
_exit:\r
- LockReleaseRead(&l_creds);\r
+ kcdb_cred_unlock_read();\r
if(type)\r
kcdb_type_release_info(type);\r
if(attrib)\r
size_t cbsize;\r
\r
if(!cbbuf)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
- LockObtainRead(&l_creds);\r
+ kcdb_cred_lock_read();\r
\r
if(!kcdb_cred_is_active_cred(vcred)) {\r
- code = KHM_ERROR_INVALID_PARM;\r
+ code = KHM_ERROR_INVALID_PARAM;\r
goto _exit;\r
}\r
\r
\r
_exit:\r
\r
- LockReleaseRead(&l_creds);\r
+ kcdb_cred_unlock_read();\r
return code;\r
}\r
\r
kcdb_cred * cred;\r
\r
if(!identity)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
- LockObtainRead(&l_creds);\r
+ kcdb_cred_lock_read();\r
\r
if(!kcdb_cred_is_active_cred(vcred)) {\r
- code = KHM_ERROR_INVALID_PARM;\r
+ code = KHM_ERROR_INVALID_PARAM;\r
goto _exit;\r
}\r
\r
*identity = cred->identity;\r
\r
_exit:\r
- LockReleaseRead(&l_creds);\r
+ kcdb_cred_unlock_read();\r
return code;\r
}\r
\r
\r
kcdb_cred_lock_write();\r
\r
- if(!kcdb_cred_is_active_cred(vcred)) {\r
- code = KHM_ERROR_INVALID_PARM;\r
+ if(!kcdb_cred_is_cred(vcred)) {\r
+ code = KHM_ERROR_INVALID_PARAM;\r
goto _exit;\r
}\r
\r
\r
kcdb_cred_lock_write();\r
\r
- if(!kcdb_cred_is_active_cred(vcred)) {\r
- code = KHM_ERROR_INVALID_PARM;\r
+ if(!kcdb_cred_is_cred(vcred)) {\r
+ code = KHM_ERROR_INVALID_PARAM;\r
goto _exit;\r
}\r
\r
{\r
kcdb_cred * cred;\r
\r
- LockObtainRead(&l_creds);\r
+ kcdb_cred_lock_read();\r
if(!kcdb_cred_is_cred(vcred)) {\r
goto _exit;\r
}\r
\r
cred = (kcdb_cred *) vcred;\r
\r
- if(!(cred->flags & KCDB_CRED_FLAG_DELETED))\r
- goto _exit;\r
-\r
if(cred->refcount)\r
goto _exit;\r
\r
- LockReleaseRead(&l_creds);\r
+ kcdb_cred_unlock_read();\r
kcdb_cred_lock_write();\r
if(!kcdb_cred_is_cred(vcred)) {\r
/* did we lose the race? */\r
LeaveCriticalSection(&cs_creds);\r
\r
kcdb_buf_delete(&cred->buf);\r
- free(cred->name);\r
- free(cred);\r
+ PFREE(cred->name);\r
+ PFREE(cred);\r
\r
/*TODO: notifications */\r
\r
return;\r
\r
_exit:\r
- LockReleaseRead(&l_creds);\r
+ kcdb_cred_unlock_read();\r
}\r
\r
KHMEXP khm_int32 KHMAPI kcdb_cred_delete(khm_handle vcred)\r
kcdb_cred_lock_write();\r
\r
if(!kcdb_cred_is_active_cred(vcred)) {\r
- code = KHM_ERROR_INVALID_PARM;\r
+ code = KHM_ERROR_INVALID_PARAM;\r
goto _exit;\r
}\r
\r
return code;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI kcdb_creds_comp_attrib(\r
- khm_handle cred1, \r
- khm_handle cred2, \r
- wchar_t * name)\r
+KHMEXP khm_int32 KHMAPI \r
+kcdb_creds_comp_attrib(khm_handle cred1, \r
+ khm_handle cred2, \r
+ wchar_t * name)\r
{\r
khm_int32 attr_id;\r
\r
return kcdb_creds_comp_attr(cred1, cred2, attr_id);\r
}\r
\r
-KHMEXP khm_int32 KHMAPI kcdb_creds_comp_attr(\r
- khm_handle vcred1, \r
- khm_handle vcred2, \r
- khm_int32 attr_id)\r
+KHMEXP khm_int32 KHMAPI \r
+kcdb_creds_comp_attr(khm_handle vcred1, \r
+ khm_handle vcred2, \r
+ khm_int32 attr_id)\r
{\r
khm_int32 code = 0;\r
kcdb_cred * cred1;\r
cred1 = (kcdb_cred *) vcred1;\r
cred2 = (kcdb_cred *) vcred2;\r
\r
- LockObtainRead(&l_creds);\r
+ kcdb_cred_lock_read();\r
if(\r
!kcdb_cred_is_active_cred(vcred1) ||\r
!kcdb_cred_is_active_cred(vcred2))\r
goto _exit;\r
\r
if(attrib->flags & KCDB_ATTR_FLAG_COMPUTED) {\r
+ khm_octet vbuf[KCDB_MAXCB_NAME * 2];\r
void * buf1 = NULL;\r
void * buf2 = NULL;\r
khm_size cb1;\r
\r
code = 0;\r
\r
- if(attrib->compute_cb(vcred1, attr_id, NULL, &cb1) != KHM_ERROR_TOO_LONG)\r
+ if(attrib->compute_cb(vcred1, attr_id, \r
+ NULL, &cb1) != KHM_ERROR_TOO_LONG)\r
goto _exit_1;\r
\r
- if(attrib->compute_cb(vcred2, attr_id, NULL, &cb2) != KHM_ERROR_TOO_LONG)\r
+ if(attrib->compute_cb(vcred2, attr_id, \r
+ NULL, &cb2) != KHM_ERROR_TOO_LONG)\r
goto _exit_1;\r
\r
if(cb1) {\r
- buf1 = malloc(cb1);\r
+ if (cb1 < sizeof(vbuf))\r
+ buf1 = vbuf;\r
+ else\r
+ buf1 = PMALLOC(cb1);\r
+\r
if(KHM_FAILED(attrib->compute_cb(vcred1, attr_id, buf1, &cb1)))\r
goto _exit_1;\r
}\r
+\r
if(cb2) {\r
- buf2 = malloc(cb2);\r
+ if (cb1 + cb2 < sizeof(vbuf))\r
+ buf2 = vbuf + cb1;\r
+ else\r
+ buf2 = PMALLOC(cb2);\r
+\r
if(KHM_FAILED(attrib->compute_cb(vcred2, attr_id, buf2, &cb2)))\r
goto _exit_1;\r
}\r
- code = type->comp(\r
- buf1, cb1,\r
- buf2, cb2);\r
-_exit_1:\r
- if(buf1)\r
- free(buf1);\r
- if(buf2)\r
- free(buf2);\r
\r
+ code = type->comp(buf1, cb1,\r
+ buf2, cb2);\r
+_exit_1:\r
+ if(buf1 && (buf1 < (void *)vbuf || \r
+ buf1 >= (void*)(vbuf + sizeof(vbuf))))\r
+ PFREE(buf1);\r
+ if(buf2 && (buf2 < (void *)vbuf ||\r
+ buf2 >= (void *)(vbuf + sizeof(vbuf))))\r
+ PFREE(buf2);\r
} else {\r
code = type->comp(\r
kcdb_cred_buf_get(cred1, attr_id),\r
}\r
\r
_exit:\r
- LockReleaseRead(&l_creds);\r
+ kcdb_cred_unlock_read();\r
if(attrib)\r
kcdb_attrib_release_info(attrib);\r
if(type)\r
return code;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI kcdb_creds_is_equal(\r
- khm_handle vcred1,\r
- khm_handle vcred2)\r
+KHMEXP khm_int32 KHMAPI \r
+kcdb_creds_is_equal(khm_handle vcred1,\r
+ khm_handle vcred2)\r
{\r
khm_int32 code = 0;\r
kcdb_cred * cred1;\r
kcdb_cred * cred2;\r
\r
- LockObtainRead(&l_creds);\r
+ kcdb_cred_lock_read();\r
if(!kcdb_cred_is_active_cred(vcred1) ||\r
- !kcdb_cred_is_active_cred(vcred2))\r
+ !kcdb_cred_is_active_cred(vcred2))\r
goto _exit;\r
\r
if(vcred1 == vcred2) {\r
cred2 = vcred2;\r
\r
if(cred1->identity == cred2->identity &&\r
- cred1->type == cred2->type &&\r
- !wcscmp(cred1->name, cred2->name)) {\r
+ cred1->type == cred2->type &&\r
+ !wcscmp(cred1->name, cred2->name)) {\r
+\r
+ kcdb_credtype * type;\r
+\r
code = TRUE;\r
+\r
+ if (KHM_SUCCEEDED(kcdb_credtype_get_info(cred1->type, &type))) {\r
+ if (type->is_equal &&\r
+ (*type->is_equal)(vcred1, vcred2, NULL))\r
+ code = 0;\r
+\r
+ kcdb_credtype_release_info(type);\r
}\r
+ }\r
\r
_exit:\r
- LockReleaseRead(&l_creds);\r
+ kcdb_cred_unlock_read();\r
return code;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI kcdb_cred_get_flags(\r
- khm_handle vcred,\r
- khm_int32 * pflags)\r
+KHMEXP khm_int32 KHMAPI \r
+kcdb_cred_get_flags(khm_handle vcred,\r
+ khm_int32 * pflags)\r
{\r
khm_int32 f;\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
int release_lock = TRUE;\r
\r
if (pflags == NULL)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
- LockObtainRead(&l_creds);\r
+ kcdb_cred_lock_read();\r
if (!kcdb_cred_is_active_cred(vcred)) {\r
*pflags = 0;\r
- rv = KHM_ERROR_INVALID_PARM;\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
goto _exit;\r
}\r
\r
/* Commented out: this is a read operation. We shouldn't attempt\r
to lock for writing */\r
if (f != cred->flags) {\r
- LockReleaseRead(&l_creds);\r
- LockObtainWrite(&l_creds);\r
+ kcdb_cred_unlock_read();\r
+ kcdb_cred_lock_write();\r
/* Did we lose a race? */\r
if (kcdb_cred_is_active_cred(vcred))\r
cred->flags = f;\r
else {\r
- rv = KHM_ERROR_INVALID_PARM;\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
f = 0;\r
}\r
- LockReleaseWrite(&l_creds);\r
+ kcdb_cred_unlock_write();\r
release_lock = FALSE;\r
}\r
#endif\r
\r
_exit:\r
if (release_lock)\r
- LockReleaseRead(&l_creds);\r
+ kcdb_cred_unlock_read();\r
\r
return rv;\r
}\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
kcdb_cred * cred;\r
\r
- LockObtainWrite(&l_creds);\r
+ kcdb_cred_lock_write();\r
if(!kcdb_cred_is_active_cred(vcred)) {\r
- rv = KHM_ERROR_INVALID_PARM;\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
goto _exit;\r
}\r
\r
(flags & mask);\r
\r
_exit:\r
- LockReleaseWrite(&l_creds);\r
+ kcdb_cred_unlock_write();\r
return rv;\r
}\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
\r
#define kcdb_cred_is_cred(c) ((c) && ((kcdb_cred *) c)->magic == KCDB_CRED_MAGIC)\r
#define kcdb_cred_is_active_cred(c) (kcdb_cred_is_cred(c) && !(((kcdb_cred *) c)->flags & KCDB_CRED_FLAG_DELETED))\r
+\r
#define kcdb_cred_lock_read() (LockObtainRead(&l_creds))\r
#define kcdb_cred_unlock_read() (LockReleaseRead(&l_creds))\r
#define kcdb_cred_lock_write() (LockObtainWrite(&l_creds))\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/* called on an unreleased credset, or with credset::cs held */\r
void kcdb_credset_buf_new(kcdb_credset * cs)\r
{\r
- cs->clist = malloc(KCDB_CREDSET_INITIAL_SIZE * sizeof(kcdb_credset_credref));\r
- ZeroMemory(cs->clist, KCDB_CREDSET_INITIAL_SIZE * sizeof(kcdb_credset_credref));\r
+ cs->clist = PMALLOC(KCDB_CREDSET_INITIAL_SIZE * \r
+ sizeof(kcdb_credset_credref));\r
+ ZeroMemory(cs->clist, \r
+ KCDB_CREDSET_INITIAL_SIZE * \r
+ sizeof(kcdb_credset_credref));\r
cs->nc_clist = KCDB_CREDSET_INITIAL_SIZE;\r
cs->nclist = 0;\r
}\r
/* called on an unreleased credset, or with credset::cs held */\r
void kcdb_credset_buf_delete(kcdb_credset * cs)\r
{\r
- free(cs->clist);\r
+ PFREE(cs->clist);\r
cs->nc_clist = 0;\r
cs->nclist = 0;\r
}\r
\r
memcpy(new_clist, cs->clist, cs->nclist * sizeof(kcdb_credset_credref));\r
\r
- free(cs->clist);\r
+ PFREE(cs->clist);\r
\r
cs->clist = new_clist;\r
}\r
{\r
kcdb_credset * cs;\r
\r
- cs = malloc(sizeof(kcdb_credset));\r
+ cs = PMALLOC(sizeof(kcdb_credset));\r
ZeroMemory(cs, sizeof(kcdb_credset));\r
\r
cs->magic = KCDB_CREDSET_MAGIC;\r
int i;\r
\r
if(!kcdb_credset_is_credset(vcredset)) {\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
cs = (kcdb_credset *) vcredset;\r
LeaveCriticalSection(&(cs->cs));\r
DeleteCriticalSection(&(cs->cs));\r
\r
- free(cs);\r
+ PFREE(cs);\r
\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
cl1 and cl2 will be modified.\r
*/\r
-khm_int32 kcdb_credset_collect_core(\r
- kcdb_credset * cs1,\r
- kcdb_cred ** cl1,\r
- khm_int32 ncl1,\r
- kcdb_credset * cs2,\r
- kcdb_cred ** cl2,\r
- khm_int32 ncl2,\r
- khm_int32 * delta)\r
+khm_int32 \r
+kcdb_credset_collect_core(kcdb_credset * cs1,\r
+ kcdb_cred ** cl1,\r
+ khm_int32 ncl1,\r
+ kcdb_credset * cs2,\r
+ kcdb_cred ** cl2,\r
+ khm_int32 ncl2,\r
+ khm_int32 * delta)\r
{\r
int i, j;\r
int ldelta = 0;\r
(cs_dest && !kcdb_credset_is_credset(cs_dest)) ||\r
(cs_src == cs_dest)) /* works because credsets use shared\r
handles */\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if(identity && !kcdb_is_active_identity(identity))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if(cs_src)\r
cs = (kcdb_credset *) cs_src;\r
the ones we want */\r
\r
if(rcs->nclist > 0)\r
- r_sel = malloc(sizeof(kcdb_cred *) * rcs->nclist);\r
+ r_sel = PMALLOC(sizeof(kcdb_cred *) * rcs->nclist);\r
if(cs->nclist > 0)\r
- c_sel = malloc(sizeof(kcdb_cred *) * cs->nclist);\r
+ c_sel = PMALLOC(sizeof(kcdb_cred *) * cs->nclist);\r
nr_sel = 0;\r
nc_sel = 0;\r
\r
LeaveCriticalSection(&(cs->cs));\r
\r
if(r_sel)\r
- free(r_sel);\r
+ PFREE(r_sel);\r
if(c_sel)\r
- free(c_sel);\r
+ PFREE(c_sel);\r
\r
return code;\r
}\r
(cs_dest && !kcdb_credset_is_credset(cs_dest)) ||\r
(cs_src == cs_dest)) /* works because credsets use shared\r
handles */\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if(cs_src)\r
cs = (kcdb_credset *) cs_src;\r
#endif\r
\r
if(rcs->nclist)\r
- r_sel = malloc(sizeof(kcdb_cred *) * rcs->nclist);\r
+ r_sel = PMALLOC(sizeof(kcdb_cred *) * rcs->nclist);\r
if(cs->nclist)\r
- c_sel = malloc(sizeof(kcdb_cred *) * cs->nclist);\r
+ c_sel = PMALLOC(sizeof(kcdb_cred *) * cs->nclist);\r
nr_sel = 0;\r
nc_sel = 0;\r
\r
LeaveCriticalSection(&(cs->cs));\r
\r
if(r_sel)\r
- free(r_sel);\r
+ PFREE(r_sel);\r
if(c_sel)\r
- free(c_sel);\r
+ PFREE(c_sel);\r
\r
return code;\r
}\r
kcdb_credset * cs;\r
\r
if(!kcdb_credset_is_credset(vcredset))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
cs = (kcdb_credset *) vcredset;\r
\r
int i;\r
\r
if(!kcdb_credset_is_credset(destcredset))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if(sourcecredset) {\r
if(!kcdb_credset_is_credset(sourcecredset))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
} else {\r
sourcecredset = kcdb_root_credset;\r
}\r
int i;\r
\r
if(!kcdb_credset_is_credset(destcredset))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if(sourcecredset) {\r
if(!kcdb_credset_is_credset(sourcecredset))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
} else {\r
sourcecredset = kcdb_root_credset;\r
isRoot = 1;\r
int i;\r
\r
if(vcredset != NULL && !kcdb_credset_is_credset(vcredset))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if(vcredset == NULL) {\r
cs = kcdb_root_credset;\r
khm_int32 code = KHM_ERROR_SUCCESS;\r
\r
if(!kcdb_credset_is_credset(vcredset))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
cs = (kcdb_credset *) vcredset;\r
\r
\r
if((credset && !kcdb_credset_is_credset(credset)) ||\r
(!f || !cred))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if(credset)\r
cs = (kcdb_credset *) credset;\r
int idx;\r
\r
if (!kcdb_credset_is_credset(vcredset))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if (!kcdb_cred_is_active_cred(vcred_src))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
cs = (kcdb_credset *) vcredset;\r
\r
khm_int32 code = KHM_ERROR_SUCCESS;\r
\r
if(!kcdb_credset_is_credset(vcredset))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
cs = (kcdb_credset *) vcredset;\r
\r
\r
EnterCriticalSection(&(cs->cs));\r
if(idx < 0 || idx >= cs->nclist) {\r
- code = KHM_ERROR_INVALID_PARM;\r
+ code = KHM_ERROR_INVALID_PARAM;\r
goto _exit;\r
}\r
\r
int i;\r
\r
if(!kcdb_credset_is_credset(credset))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
cs = (kcdb_credset *) credset;\r
\r
int i;\r
\r
if(!kcdb_credset_is_credset(credset))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
cs = (kcdb_credset *) credset;\r
\r
khm_int32 code = KHM_ERROR_SUCCESS;\r
\r
if(!kcdb_credset_is_credset(credset))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
cs = (kcdb_credset *) credset;\r
\r
int i,j;\r
\r
if(!kcdb_credset_is_credset(credset))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
cs = (kcdb_credset *) credset;\r
\r
kcdb_credset * cs;\r
\r
if (!kcdb_credset_is_credset(credset))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
cs = (kcdb_credset *) credset;\r
\r
khm_int32 rv;\r
\r
if (!kcdb_credset_is_credset(credset))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
cs = (kcdb_credset *) credset;\r
\r
return 0;\r
}\r
\r
- return comp((khm_handle) ((kcdb_credset_credref *)a)->cred, (khm_handle) ((kcdb_credset_credref *)b)->cred, rock);\r
+ return comp((khm_handle) ((kcdb_credset_credref *)a)->cred, \r
+ (khm_handle) ((kcdb_credset_credref *)b)->cred, \r
+ rock);\r
}\r
\r
KHMEXP khm_int32 KHMAPI kcdb_credset_sort(\r
kcdb_credset * cs;\r
\r
if(!kcdb_credset_is_credset(credset))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
cs = (kcdb_credset *) credset;\r
\r
int i;\r
khm_int32 r = 0;\r
khm_int32 f1, f2;\r
+ khm_int32 t1, t2;\r
khm_int32 pt;\r
\r
for(i=0; i<o->nFields; i++) {\r
if (o->fields[i].order & KCDB_CRED_COMP_INITIAL_FIRST) {\r
\r
- kcdb_cred_get_flags(cred1, &f1);\r
- kcdb_cred_get_flags(cred2, &f2);\r
+ if (o->fields[i].attrib == KCDB_ATTR_TYPE_NAME ||\r
+ o->fields[i].attrib == KCDB_ATTR_TYPE) {\r
\r
- if (((f1 ^ f2) & KCDB_CRED_FLAG_INITIAL) == 0) {\r
- kcdb_cred_get_type(cred1, &f1);\r
- kcdb_cred_get_type(cred2, &f2);\r
+ kcdb_cred_get_type(cred1, &t1);\r
+ kcdb_cred_get_type(cred2, &t2);\r
kcdb_identity_get_type(&pt);\r
\r
- if (f1 == f2)\r
+ if (t1 == t2)\r
r = 0;\r
- else if (f1 == pt)\r
+ else if (t1 == pt)\r
r = -1;\r
- else if (f2 == pt)\r
+ else if (t2 == pt)\r
r = 1;\r
else\r
r = 0;\r
- } else if (f1 & KCDB_CRED_FLAG_INITIAL)\r
- r = -1;\r
- else\r
- r = 1;\r
+\r
+ } else {\r
+\r
+ kcdb_cred_get_flags(cred1, &f1);\r
+ kcdb_cred_get_flags(cred2, &f2);\r
+\r
+ if (((f1 ^ f2) & KCDB_CRED_FLAG_INITIAL) == 0)\r
+ r = 0;\r
+ else if (f1 & KCDB_CRED_FLAG_INITIAL)\r
+ r = -1;\r
+ else\r
+ r = 1;\r
+\r
+ }\r
+\r
} else {\r
r = 0;\r
}\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
\r
#define kcdb_credset_is_sealed(c) ((c)->seal_count != 0)\r
\r
-#define KCDB_CREDSET_INITIAL_SIZE 1024\r
-#define KCDB_CREDSET_GROWTH_FACTOR 1024\r
+#define KCDB_CREDSET_INITIAL_SIZE 256\r
+#define KCDB_CREDSET_GROWTH_FACTOR 256\r
\r
void kcdb_credset_init(void);\r
void kcdb_credset_exit(void);\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
{\r
InitializeCriticalSection(&cs_credtype);\r
kcdb_credtypes = NULL;\r
- kcdb_credtype_tbl = malloc(sizeof(kcdb_credtype_i *) * (KCDB_CREDTYPE_MAX_ID+1));\r
+\r
+ kcdb_credtype_tbl = PMALLOC(sizeof(kcdb_credtype_i *) * (KCDB_CREDTYPE_MAX_ID+1));\r
ZeroMemory(kcdb_credtype_tbl, sizeof(kcdb_credtype_i *) * (KCDB_CREDTYPE_MAX_ID+1));\r
}\r
\r
void kcdb_credtype_exit(void)\r
{\r
/*TODO:Free up the cred types */\r
- free(kcdb_credtype_tbl);\r
+ PFREE(kcdb_credtype_tbl);\r
DeleteCriticalSection(&cs_credtype);\r
}\r
\r
kcdb_credtype_tbl[id] = NULL;\r
LDELETE(&kcdb_credtypes, ict);\r
\r
- free(ict->ct.name);\r
+ PFREE(ict->ct.name);\r
if(ict->ct.short_desc)\r
- free(ict->ct.short_desc);\r
+ PFREE(ict->ct.short_desc);\r
if(ict->ct.long_desc)\r
- free(ict->ct.long_desc);\r
+ PFREE(ict->ct.long_desc);\r
if(ict->ct.sub)\r
kmq_delete_subscription(ict->ct.sub);\r
\r
- free(ict);\r
+ PFREE(ict);\r
}\r
}\r
\r
-KHMEXP khm_int32 KHMAPI kcdb_credtype_register(kcdb_credtype * type, khm_int32 * new_id) \r
+KHMEXP khm_int32 KHMAPI \r
+kcdb_credtype_register(kcdb_credtype * type, khm_int32 * new_id) \r
{\r
khm_int32 id;\r
kcdb_credtype_i * ict;\r
int i;\r
\r
if(!type)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if(type->id >= KCDB_CREDTYPE_MAX_ID)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if(type->name) {\r
if(FAILED(StringCbLength(type->name, KCDB_MAXCB_NAME, &cb_name)))\r
return KHM_ERROR_TOO_LONG;\r
cb_name += sizeof(wchar_t);\r
} else\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if(type->short_desc) {\r
if(FAILED(StringCbLength(type->short_desc, KCDB_MAXCB_SHORT_DESC, &cb_short_desc)))\r
cb_long_desc = 0;\r
\r
if(type->sub == NULL)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_credtype);\r
\r
}\r
}\r
\r
- ict = malloc(sizeof(kcdb_credtype_i));\r
+ ict = PMALLOC(sizeof(kcdb_credtype_i));\r
ZeroMemory(ict, sizeof(kcdb_credtype_i));\r
\r
- ict->ct.name = malloc(cb_name);\r
+ ict->ct.name = PMALLOC(cb_name);\r
StringCbCopy(ict->ct.name, cb_name, type->name);\r
\r
if(cb_short_desc) {\r
- ict->ct.short_desc = malloc(cb_short_desc);\r
+ ict->ct.short_desc = PMALLOC(cb_short_desc);\r
StringCbCopy(ict->ct.short_desc, cb_short_desc, type->short_desc);\r
}\r
\r
if(cb_long_desc) {\r
- ict->ct.long_desc = malloc(cb_long_desc);\r
+ ict->ct.long_desc = PMALLOC(cb_long_desc);\r
StringCbCopy(ict->ct.long_desc, cb_long_desc, type->long_desc);\r
}\r
\r
\r
ict->ct.sub = type->sub;\r
\r
+ ict->ct.is_equal = type->is_equal;\r
+\r
kcdb_credtype_tbl[id] = ict;\r
\r
LPUSH(&kcdb_credtypes, ict);\r
int found = 0;\r
\r
if(id < 0 || id > KCDB_CREDTYPE_MAX_ID)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_credtype);\r
if(kcdb_credtype_tbl[id] && \r
kcdb_credtype_i * ict;\r
\r
if(!type)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
ict = (kcdb_credtype_i *) type;\r
return kcdb_credtype_release(ict);\r
kcdb_credtype_i * ict;\r
\r
if(id < 0 || id > KCDB_CREDTYPE_MAX_ID)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_credtype);\r
ict = kcdb_credtype_tbl[id];\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
\r
if(!cbbuf || id < 0 || id > KCDB_CREDTYPE_MAX_ID)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_credtype);\r
t = kcdb_credtype_tbl[id];\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
\r
if(!cbbuf || id < 0 || id > KCDB_CREDTYPE_MAX_ID)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_credtype);\r
t = kcdb_credtype_tbl[id];\r
\r
*id = 0;\r
if(!name)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_credtype);\r
for(i=0;i <= KCDB_CREDTYPE_MAX_ID; i++) {\r
khm_int32 kcdb_credtype_hold(kcdb_credtype_i * ict) {\r
\r
if(!ict)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_credtype);\r
ict->refcount++;\r
khm_int32 kcdb_credtype_release(kcdb_credtype_i * ict) {\r
\r
if(!ict)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_credtype);\r
ict->refcount--;\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
void kcdb_credtype_post_message(khm_int32 op, kcdb_credtype * type);\r
khm_int32 kcdb_credtype_get_next_free_id(khm_int32 * id);\r
\r
-#endif
\ No newline at end of file
+#endif\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
#include<kcreddbinternal.h>\r
#include<assert.h>\r
\r
-CRITICAL_SECTION cs_ident;\r
+static CRITICAL_SECTION cs_ident;\r
hashtable * kcdb_identities_namemap = NULL;\r
khm_int32 kcdb_n_identities = 0;\r
kcdb_identity * kcdb_identities = NULL;\r
/* primary credentials type */\r
khm_ui_4 kcdb_ident_refresh_cycle = 0;\r
khm_boolean kcdb_checked_config = FALSE;\r
+khm_boolean kcdb_checking_config = FALSE;\r
+\r
+KHMEXP khm_boolean KHMAPI\r
+kcdb_identity_is_equal(khm_handle identity1,\r
+ khm_handle identity2)\r
+{\r
+\r
+ return (identity1 == identity2);\r
+\r
+}\r
\r
KHMEXP khm_int32 KHMAPI \r
kcdb_identity_set_provider(khm_handle sub)\r
kcdb_identity_get_type(khm_int32 * ptype)\r
{\r
if (!ptype)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_ident);\r
*ptype = kcdb_ident_cred_type;\r
DeleteCriticalSection(&cs_ident);\r
}\r
\r
+/* NOT called with cs_ident held */\r
KHMEXP khm_boolean KHMAPI \r
kcdb_identity_is_valid_name(const wchar_t * name)\r
{\r
size_t namesize;\r
\r
if(!result || !name)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
*result = NULL;\r
\r
/* nope. create it */\r
if((flags & ~KCDB_IDENT_FLAGMASK_RDWR) ||\r
(flags & (KCDB_IDENT_FLAG_DEFAULT |\r
- KCDB_IDENT_FLAG_SEARCHABLE))) {\r
+ KCDB_IDENT_FLAG_SEARCHABLE |\r
+ KCDB_IDENT_FLAG_STICKY))) {\r
/* can't specify this flag in create */\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
if(!kcdb_identity_is_valid_name(name)) {\r
StringCbLength(name, KCDB_IDENT_MAXCB_NAME, &namesize);\r
namesize += sizeof(wchar_t);\r
\r
- id = malloc(sizeof(kcdb_identity));\r
+ id = PMALLOC(sizeof(kcdb_identity));\r
ZeroMemory(id, sizeof(kcdb_identity));\r
id->magic = KCDB_IDENT_MAGIC;\r
- id->name = malloc(namesize);\r
+ id->name = PMALLOC(namesize);\r
StringCbCopy(id->name, namesize, name);\r
\r
- id->flags = (flags & KCDB_IDENT_FLAGMASK_LOCAL);\r
+ id->flags = (flags & KCDB_IDENT_FLAGMASK_RDWR);\r
id->flags |= KCDB_IDENT_FLAG_ACTIVE;\r
LINIT(id);\r
\r
kcdb_identity_hold((khm_handle) id_tmp);\r
*result = (khm_handle) id_tmp;\r
\r
- free(id->name);\r
- free(id);\r
+ PFREE(id->name);\r
+ PFREE(id);\r
\r
id = NULL;\r
} else {\r
0,\r
&h_cfg))) {\r
/* don't need to set the KCDB_IDENT_FLAG_CONFIG flags\r
- since kcdb_identity_get_conifg() sets it for us. */\r
+ since kcdb_identity_get_config() sets it for us. */\r
khm_int32 sticky;\r
\r
if (KHM_SUCCEEDED(khc_read_int32(h_cfg, L"Sticky", &sticky)) &&\r
\r
EnterCriticalSection(&cs_ident);\r
if(!kcdb_is_identity(vid)) {\r
- code = KHM_ERROR_INVALID_PARM;\r
+ code = KHM_ERROR_INVALID_PARAM;\r
goto _exit;\r
}\r
\r
LDELETE(&kcdb_identities, id);\r
\r
if (id->name)\r
- free(id->name);\r
- free(id);\r
+ PFREE(id->name);\r
+ PFREE(id);\r
}\r
/* else, we have an identity that is not active, but has\r
outstanding references. We have to wait until those references\r
\r
KHMEXP khm_int32 KHMAPI \r
kcdb_identity_set_flags(khm_handle vid, \r
- khm_int32 flag) {\r
+ khm_int32 flag,\r
+ khm_int32 mask) {\r
kcdb_identity * id;\r
khm_int32 oldflags;\r
khm_int32 newflags;\r
khm_int32 delta = 0;\r
khm_int32 rv;\r
\r
+ if (mask == 0)\r
+ return KHM_ERROR_SUCCESS;\r
+\r
if(!kcdb_is_active_identity(vid))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
id = (kcdb_identity *) vid;\r
\r
- if((flag & ~(KCDB_IDENT_FLAGMASK_RDWR | KCDB_IDENT_FLAG_INVERT)) ||\r
- ((flag & KCDB_IDENT_FLAG_INVALID) && (flag & KCDB_IDENT_FLAG_VALID)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ flag &= mask;\r
+\r
+ if((mask & ~KCDB_IDENT_FLAGMASK_RDWR) ||\r
+ ((flag & KCDB_IDENT_FLAG_INVALID) && (flag & KCDB_IDENT_FLAG_VALID)))\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
- if(flag & KCDB_IDENT_FLAG_DEFAULT) {\r
+ if((mask & KCDB_IDENT_FLAG_DEFAULT) &&\r
+ (flag & KCDB_IDENT_FLAG_DEFAULT)) {\r
/* kcdb_identity_set_default already does checking for\r
redundant transitions */\r
- rv = kcdb_identity_set_default((flag & KCDB_IDENT_FLAG_INVERT)?NULL: vid);\r
+ rv = kcdb_identity_set_default(vid);\r
\r
if(KHM_FAILED(rv))\r
return rv;\r
\r
+ mask &= ~KCDB_IDENT_FLAG_DEFAULT;\r
flag &= ~KCDB_IDENT_FLAG_DEFAULT;\r
}\r
\r
- if(flag & KCDB_IDENT_FLAG_SEARCHABLE) {\r
- if(flag & KCDB_IDENT_FLAG_INVERT) {\r
- EnterCriticalSection(&cs_ident);\r
+ EnterCriticalSection(&cs_ident);\r
+\r
+ if(mask & KCDB_IDENT_FLAG_SEARCHABLE) {\r
+ if(!(flag & KCDB_IDENT_FLAG_SEARCHABLE)) {\r
if(id->flags & KCDB_IDENT_FLAG_SEARCHABLE) {\r
LeaveCriticalSection(&cs_ident);\r
rv = kcdb_identpro_set_searchable(vid, FALSE);\r
delta |= KCDB_IDENT_FLAG_SEARCHABLE;\r
}\r
}\r
- LeaveCriticalSection(&cs_ident);\r
} else {\r
- EnterCriticalSection(&cs_ident);\r
if(!(id->flags & KCDB_IDENT_FLAG_SEARCHABLE)) {\r
LeaveCriticalSection(&cs_ident);\r
rv = kcdb_identpro_set_searchable(vid, TRUE);\r
delta |= KCDB_IDENT_FLAG_SEARCHABLE;\r
}\r
}\r
- LeaveCriticalSection(&cs_ident);\r
}\r
\r
flag &= ~KCDB_IDENT_FLAG_SEARCHABLE;\r
+ mask &= ~KCDB_IDENT_FLAG_SEARCHABLE;\r
+ }\r
+\r
+ if (mask & KCDB_IDENT_FLAG_STICKY) {\r
+ if ((flag ^ id->flags) & KCDB_IDENT_FLAG_STICKY) {\r
+ khm_handle h_conf;\r
+\r
+ if (KHM_SUCCEEDED(kcdb_identity_get_config(vid, \r
+ KHM_FLAG_CREATE, \r
+ &h_conf))) {\r
+ khc_write_int32(h_conf, L"Sticky",\r
+ !!(flag & KCDB_IDENT_FLAG_STICKY));\r
+ khc_close_space(h_conf);\r
+ }\r
+\r
+ id->flags = \r
+ ((id->flags & ~KCDB_IDENT_FLAG_STICKY) |\r
+ (flag & KCDB_IDENT_FLAG_STICKY));\r
+\r
+ delta |= KCDB_IDENT_FLAG_STICKY;\r
+ }\r
+\r
+ flag &= ~KCDB_IDENT_FLAG_STICKY;\r
+ mask &= ~KCDB_IDENT_FLAG_STICKY;\r
}\r
\r
/* deal with every other flag */\r
\r
- EnterCriticalSection(&cs_ident);\r
oldflags = id->flags;\r
- if(flag & KCDB_IDENT_FLAG_INVERT) {\r
- flag &= ~KCDB_IDENT_FLAG_INVERT;\r
- id->flags &= ~flag;\r
- } else {\r
- id->flags |= flag;\r
\r
- if(flag & KCDB_IDENT_FLAG_VALID)\r
- id->flags &= ~KCDB_IDENT_FLAG_INVALID;\r
- if(flag & KCDB_IDENT_FLAG_INVALID)\r
- id->flags &= ~KCDB_IDENT_FLAG_VALID;\r
- }\r
+ id->flags = (id->flags & ~mask) | (flag & mask);\r
+\r
+ if (flag & KCDB_IDENT_FLAG_VALID)\r
+ id->flags &= ~KCDB_IDENT_FLAG_INVALID;\r
+ if (flag & KCDB_IDENT_FLAG_INVALID)\r
+ id->flags &= ~KCDB_IDENT_FLAG_VALID;\r
+\r
newflags = id->flags;\r
+\r
LeaveCriticalSection(&cs_ident);\r
+\r
delta |= newflags ^ oldflags;\r
\r
if((delta & KCDB_IDENT_FLAG_HIDDEN)) {\r
*flags = 0;\r
\r
if(!kcdb_is_active_identity(vid))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
id = (kcdb_identity *) vid;\r
\r
kcdb_identity * id;\r
\r
if(!kcdb_is_active_identity(vid) || !pcbsize)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
id = (kcdb_identity *) vid;\r
\r
khm_handle def;\r
\r
if (pvid == NULL)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_ident);\r
def = kcdb_def_identity;\r
kcdb_identity * old_def;\r
khm_int32 rv;\r
\r
- if(vid != NULL && !kcdb_is_active_identity(vid))\r
- return KHM_ERROR_INVALID_PARM;\r
+ if (vid != NULL && !kcdb_is_active_identity(vid))\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
new_def = (kcdb_identity *)vid;\r
\r
- if(new_def != NULL && (new_def->flags & KCDB_IDENT_FLAG_DEFAULT))\r
+ if (new_def != NULL && (new_def->flags & KCDB_IDENT_FLAG_DEFAULT))\r
return KHM_ERROR_SUCCESS;\r
\r
- if(new_def == NULL && kcdb_def_identity == NULL)\r
+ if ((new_def == NULL && kcdb_def_identity == NULL) ||\r
+ (new_def == kcdb_def_identity))\r
return KHM_ERROR_SUCCESS;\r
\r
/* first check with the identity provider if this operation\r
if(kcdb_is_active_identity(vid)) {\r
id = (kcdb_identity *) vid;\r
} else {\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
hkcdb = kcdb_get_config();\r
id = vid;\r
InterlockedIncrement(&(id->refcount));\r
} else\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
return ERROR_SUCCESS;\r
}\r
\r
LeaveCriticalSection(&cs_ident);\r
}\r
} else\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
return ERROR_SUCCESS;\r
}\r
\r
\r
if (KHM_SUCCEEDED(kcdb_cred_get_identity(cred, &vid))) {\r
if (result->ident == (kcdb_identity *) vid) {\r
+\r
result->count++;\r
kcdb_cred_get_flags(cred, &flags);\r
\r
kcdb_identity * ident;\r
khm_int32 code = KHM_ERROR_SUCCESS;\r
struct kcdb_idref_result result;\r
- khm_int32 flags;\r
\r
EnterCriticalSection(&cs_ident);\r
\r
if (!kcdb_is_active_identity(vid)) {\r
- code = KHM_ERROR_INVALID_PARM;\r
+ code = KHM_ERROR_INVALID_PARAM;\r
goto _exit;\r
}\r
\r
result.flags = 0;\r
result.count = 0;\r
\r
+ LeaveCriticalSection(&cs_ident);\r
+\r
kcdb_credset_apply(NULL, kcdbint_idref_proc, &result);\r
\r
if (result.count == 0)\r
result.flags |= KCDB_IDENT_FLAG_EMPTY;\r
\r
- kcdb_identity_set_flags(vid, result.flags);\r
- kcdb_identity_get_flags(vid, &flags);\r
- flags &= KCDB_IDENT_FLAGMASK_RDWR;\r
- flags &= ~(KCDB_IDENT_FLAG_DEFAULT |\r
- KCDB_IDENT_FLAG_SEARCHABLE);\r
- flags ^= result.flags;\r
- if (flags != 0)\r
- kcdb_identity_set_flags(vid, flags | KCDB_IDENT_FLAG_INVERT);\r
+ kcdb_identity_set_flags(vid, result.flags,\r
+ KCDB_IDENT_FLAGMASK_RDWR &\r
+ ~(KCDB_IDENT_FLAG_DEFAULT |\r
+ KCDB_IDENT_FLAG_SEARCHABLE |\r
+ KCDB_IDENT_FLAG_STICKY));\r
\r
+ EnterCriticalSection(&cs_ident);\r
ident->refresh_cycle = kcdb_ident_refresh_cycle;\r
\r
_exit:\r
KHMEXP khm_int32 KHMAPI \r
kcdb_identity_refresh_all(void) {\r
kcdb_identity * ident;\r
+ kcdb_identity * next;\r
khm_int32 code = KHM_ERROR_SUCCESS;\r
int hit_count;\r
\r
\r
for (ident = kcdb_identities; \r
ident != NULL;\r
- ident = LNEXT(ident)) {\r
+ ident = next) {\r
+\r
+ next = LNEXT(ident);\r
\r
if (!kcdb_is_active_identity(ident) ||\r
ident->refresh_cycle == kcdb_ident_refresh_cycle)\r
kcdb_identity_hold((khm_handle) ident);\r
\r
LeaveCriticalSection(&cs_ident);\r
+\r
kcdb_identity_refresh((khm_handle) ident);\r
+\r
EnterCriticalSection(&cs_ident);\r
\r
kcdb_identity_release((khm_handle) ident);\r
\r
hit_count++;\r
}\r
+\r
} while (hit_count > 0);\r
\r
LeaveCriticalSection(&cs_ident);\r
EnterCriticalSection(&cs_ident);\r
if(!kcdb_is_active_identity(vid)) {\r
LeaveCriticalSection(&cs_ident);\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
id = (kcdb_identity *) vid;\r
\r
if(KHM_FAILED(kcdb_attrib_get_info(attr_id, &attrib))) {\r
LeaveCriticalSection(&cs_ident);\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
#if 0\r
if(KHM_FAILED(kcdb_type_get_info(attrib->type, &type))) {\r
LeaveCriticalSection(&cs_ident);\r
kcdb_attrib_release_info(attrib);\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
if(!(type->isValid(buffer,cbbuf))) {\r
}\r
\r
if((type->dup(buffer, cbbuf, NULL, &cbdest)) != KHM_ERROR_TOO_LONG) {\r
- code = KHM_ERROR_INVALID_PARM;\r
+ code = KHM_ERROR_INVALID_PARAM;\r
goto _exit;\r
}\r
\r
}\r
\r
KHMEXP khm_int32 KHMAPI \r
-kcdb_identity_set_attrib(\r
- khm_handle vid,\r
+kcdb_identity_set_attrib(khm_handle vid,\r
wchar_t * attr_name,\r
void * buffer,\r
khm_size cbbuf)\r
khm_int32 attr_id = -1;\r
\r
if(KHM_FAILED(kcdb_attrib_get_id(attr_name, &attr_id)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
return kcdb_identity_set_attr(\r
vid,\r
}\r
\r
KHMEXP khm_int32 KHMAPI \r
-kcdb_identity_get_attr(\r
- khm_handle vid,\r
+kcdb_identity_get_attr(khm_handle vid,\r
khm_int32 attr_id,\r
khm_int32 * attr_type,\r
void * buffer,\r
khm_size slot;\r
\r
if(KHM_FAILED(kcdb_attrib_get_info(attr_id, &attrib))) {\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
if(KHM_FAILED(kcdb_type_get_info(attrib->type, &type))) {\r
EnterCriticalSection(&cs_ident);\r
\r
if(!kcdb_is_active_identity(vid)) {\r
- code = KHM_ERROR_INVALID_PARM;\r
+ code = KHM_ERROR_INVALID_PARAM;\r
goto _exit;\r
}\r
\r
}\r
\r
KHMEXP khm_int32 KHMAPI \r
-kcdb_identity_get_attrib(\r
- khm_handle vid,\r
+kcdb_identity_get_attrib(khm_handle vid,\r
wchar_t * attr_name,\r
khm_int32 * attr_type,\r
void * buffer,\r
if(KHM_FAILED(kcdb_attrib_get_id(attr_name, &attr_id)))\r
return KHM_ERROR_NOT_FOUND;\r
\r
- return kcdb_identity_get_attr(\r
- vid,\r
- attr_id,\r
- attr_type,\r
- buffer,\r
- pcbbuf);\r
+ return kcdb_identity_get_attr(vid,\r
+ attr_id,\r
+ attr_type,\r
+ buffer,\r
+ pcbbuf);\r
}\r
\r
KHMEXP khm_int32 KHMAPI \r
khm_size slot;\r
\r
if(KHM_FAILED(kcdb_attrib_get_info(attr_id, &attrib))) {\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
if(KHM_FAILED(kcdb_type_get_info(attrib->type, &type))) {\r
EnterCriticalSection(&cs_ident);\r
\r
if(!kcdb_is_active_identity(vid)) {\r
- code = KHM_ERROR_INVALID_PARM;\r
+ code = KHM_ERROR_INVALID_PARAM;\r
goto _exit;\r
}\r
\r
/*****************************************/\r
/* Identity provider interface functions */\r
\r
+/* NOT called with cs_ident held */\r
KHMEXP khm_int32 KHMAPI \r
kcdb_identpro_validate_name(const wchar_t * name)\r
{\r
khm_handle sub;\r
\r
if(!kcdb_is_active_identity(identity))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_ident);\r
if(kcdb_ident_sub != NULL) {\r
const wchar_t * name2)\r
{\r
khm_handle sub;\r
- kcdb_ident_name_xfer namex;\r
- khm_int32 rv = 0;\r
+ kcdb_ident_name_xfer namex;\r
+ khm_int32 rv = 0;\r
\r
- EnterCriticalSection(&cs_ident);\r
- if(kcdb_ident_sub != NULL) {\r
+ EnterCriticalSection(&cs_ident);\r
+ if(kcdb_ident_sub != NULL) {\r
sub = kcdb_ident_sub;\r
- } else {\r
+ } else {\r
sub = NULL;\r
- /* Generally in kcdb_identpro_* functions we don't emulate\r
- any behavior if the provider is not available, but lacking\r
- a way to make this known, we emulate here */\r
- rv = wcscmp(name1, name2);\r
- }\r
- LeaveCriticalSection(&cs_ident);\r
+ /* Generally in kcdb_identpro_* functions we don't emulate\r
+ any behavior if the provider is not available, but lacking\r
+ a way to make this known, we emulate here */\r
+ rv = wcscmp(name1, name2);\r
+ }\r
+ LeaveCriticalSection(&cs_ident);\r
\r
if(sub != NULL) {\r
- ZeroMemory(&namex, sizeof(namex));\r
- namex.name_src = name1;\r
- namex.name_alt = name2;\r
-\r
- kmq_send_sub_msg(\r
- sub,\r
- KMSG_IDENT,\r
- KMSG_IDENT_COMPARE_NAME,\r
- 0,\r
- (void *) &namex);\r
-\r
- rv = namex.result;\r
- }\r
+ ZeroMemory(&namex, sizeof(namex));\r
+ namex.name_src = name1;\r
+ namex.name_alt = name2;\r
\r
- return rv;\r
+ kmq_send_sub_msg(sub,\r
+ KMSG_IDENT,\r
+ KMSG_IDENT_COMPARE_NAME,\r
+ 0,\r
+ (void *) &namex);\r
+\r
+ rv = namex.result;\r
+ }\r
+ \r
+ return rv;\r
}\r
\r
KHMEXP khm_int32 KHMAPI \r
-kcdb_identpro_set_default(\r
- khm_handle identity)\r
+kcdb_identpro_set_default(khm_handle identity)\r
{\r
khm_handle sub;\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
\r
if((identity != NULL) && \r
!kcdb_is_active_identity(identity))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_ident);\r
if(kcdb_ident_sub != NULL) {\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
\r
if(!kcdb_is_active_identity(identity))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_ident);\r
if(kcdb_ident_sub != NULL) {\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
\r
if(!kcdb_is_active_identity(identity))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_ident);\r
if(kcdb_ident_sub != NULL) {\r
LeaveCriticalSection(&cs_ident);\r
\r
if(sub != NULL) {\r
- rv = kmq_send_sub_msg(\r
- sub,\r
- KMSG_IDENT,\r
- KMSG_IDENT_UPDATE,\r
- 0,\r
- (void *) identity);\r
+ rv = kmq_send_sub_msg(sub,\r
+ KMSG_IDENT,\r
+ KMSG_IDENT_UPDATE,\r
+ 0,\r
+ (void *) identity);\r
}\r
\r
return rv;\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
\r
if(!kcdb_is_active_identity(identity))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_ident);\r
if(kcdb_ident_sub != NULL) {\r
\r
if ((name_buf == NULL && pcb_buf == NULL && pn_idents == NULL) ||\r
(name_buf != NULL && pcb_buf == NULL))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
eq_flags &= and_flags;\r
\r
khm_handle h_idents = NULL;\r
khm_handle h_ident = NULL;\r
\r
+ kcdb_checked_config = TRUE;\r
+ kcdb_checking_config = TRUE;\r
+\r
h_kcdb = kcdb_get_config();\r
if (!h_kcdb)\r
goto _config_check_cleanup;\r
goto _config_check_cleanup;\r
\r
while(KHM_SUCCEEDED(khc_enum_subspaces(h_idents,\r
- h_ident,\r
- &h_ident))) {\r
+ h_ident,\r
+ &h_ident))) {\r
\r
wchar_t wname[KCDB_IDENT_MAXCCH_NAME];\r
khm_size cb;\r
&cb)))\r
continue;\r
\r
+ LeaveCriticalSection(&cs_ident);\r
+\r
if (KHM_SUCCEEDED(kcdb_identity_create(wname,\r
- KCDB_IDENT_FLAG_CREATE,\r
- &t_id)))\r
+ KCDB_IDENT_FLAG_CREATE,\r
+ &t_id)))\r
kcdb_identity_release(t_id);\r
+\r
+ EnterCriticalSection(&cs_ident);\r
}\r
\r
_config_check_cleanup:\r
if (h_idents)\r
khc_close_space(h_idents);\r
\r
- kcdb_checked_config = TRUE;\r
+ kcdb_checking_config = FALSE;\r
}\r
\r
for ( id = kcdb_identities;\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
khm_int32 refcount;\r
kcdb_buf buf;\r
khm_ui_4 refresh_cycle;\r
- struct kcdb_identity_t * next;\r
- struct kcdb_identity_t * prev;\r
+ LDCL(struct kcdb_identity_t);\r
} kcdb_identity;\r
\r
#define KCDB_IDENT_MAGIC 0x31938d4f\r
\r
-extern CRITICAL_SECTION cs_ident;\r
extern hashtable * kcdb_identities_namemap;\r
extern khm_int32 kcdb_n_identities;\r
extern kcdb_identity * kcdb_identities; /* all identities */\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
\note Only to be used with kcdb_identity_create() */\r
#define KCDB_IDENT_FLAG_CREATE 0x10000000L\r
\r
-/*! \brief Inverts the accompanying flags.\r
-\r
- \note Only to be used with kcdb_identity_set_flags()\r
- \see kcdb_identity_set_flags() */\r
-#define KCDB_IDENT_FLAG_INVERT 0x40000000L\r
-\r
/*! \brief Has configuration information\r
\r
Indicates that the identity has persistent configuration\r
no longer have this flag. */\r
#define KCDB_IDENT_FLAG_ACTIVE 0x02000000L\r
\r
-/*! \brief Sticky identity\r
-\r
- Sticky identities are identities that are always visible in the\r
- credentials display even if no credentials are associated with it.\r
- */\r
-#define KCDB_IDENT_FLAG_STICKY 0x04000000L\r
\r
/*! \brief The identity has custom attributes assigned\r
*/\r
*/\r
#define KCDB_IDENT_FLAG_CRED_RENEW 0x00000400L\r
\r
-/*! \brief Bit mask for local flags\r
+/*! \brief Sticky identity\r
\r
- Local flags are those local to the KCDB.\r
+ Sticky identities are identities that are always visible in the\r
+ credentials display even if no credentials are associated with it.\r
*/\r
-#define KCDB_IDENT_FLAGMASK_LOCAL 0x0000ffffL\r
+#define KCDB_IDENT_FLAG_STICKY 0x00000800L\r
\r
/*! \brief Read/write flags mask.\r
\r
A bitmask that correspond to all the read/write flags in the mask.\r
*/\r
-#define KCDB_IDENT_FLAGMASK_RDWR 0x000007ffL\r
+#define KCDB_IDENT_FLAGMASK_RDWR 0x00000fffL\r
\r
/*@}*/\r
\r
\r
/*! \brief Set or unset the specified flags in the specified identity.\r
\r
- Only flags that are in KCDB_IDENT_FLAGMASK_RDWR can be specifed\r
- in the flags parameter. The only exception is the\r
- KCDB_IDENT_FLAG_INVERT flag which controls whether the flags are\r
- to be set or reset.\r
-\r
- If the ::KCDB_IDENT_FLAG_INVERT flag is not specified in \a flags,\r
- then any flags set in \a flags will also be set in the identity.\r
- If the ::KCDB_IDENT_FLAG_INVERT is specified, then any flag set in\r
- \a flags will be reset in the identity.\r
+ Only flags that are in KCDB_IDENT_FLAGMASK_RDWR can be specifed in\r
+ the \a flags parameter or the \a mask parameter. The flags set in\r
+ the \a mask parameter of the identity will be set to the\r
+ corresponding values in the \a flags parameter.\r
\r
If ::KCDB_IDENT_FLAG_INVALID is set using this function, then the\r
::KCDB_IDENT_FLAG_VALID will be automatically reset, and vice\r
- ::KCDB_IDENT_FLAG_SEARCHABLE : Setting this will result in the\r
identity provider getting notified of the change. If the\r
identity provider indicates that searchable flag should not be\r
- set or reset (according to KCDB_IDENT_FLAG_INVERT setting) on\r
- the identity, then kcdb_identity_set_flags() will return an\r
- error.\r
+ set or reset on the identity, then kcdb_identity_set_flags()\r
+ will return an error.\r
\r
\note kcdb_identity_set_flags() is not atomic. Even if the\r
function returns a failure code, some flags in the identity may\r
*/\r
KHMEXP khm_int32 KHMAPI \r
kcdb_identity_set_flags(khm_handle id, \r
- khm_int32 flags);\r
+ khm_int32 flags,\r
+ khm_int32 mask);\r
\r
/*! \brief Return all the flags for the identity\r
\r
KHMEXP khm_int32 KHMAPI \r
kcdb_identity_get_type(khm_int32 * ptype);\r
\r
+/*! \brief Returns TRUE if the two identities are equal\r
+\r
+ Also returns TRUE if both identities are NULL.\r
+ */\r
+KHMEXP khm_boolean KHMAPI\r
+kcdb_identity_is_equal(khm_handle identity1,\r
+ khm_handle identity2);\r
+\r
/*! \brief Set an attribute in an identity by attribute id\r
\r
\param[in] buffer A pointer to a buffer containing the data to\r
\retval KHM_ERROR_SUCCESS Success\r
\retval KHM_ERROR_NOT_FOUND The given attribute was either invalid\r
or was not defined for this identity\r
- \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid\r
+ \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid\r
\retval KHM_ERROR_TOO_LONG Either \a buffer was NULL or the\r
supplied buffer was insufficient\r
*/\r
buffer was insufficient. If \a pn_idents was valid, it\r
contains the number of identities.\r
\r
- \retval KHM_ERROR_INVALID_PARM None of the parameters \a name_buf,\r
+ \retval KHM_ERROR_INVALID_PARAM None of the parameters \a name_buf,\r
\a pcb_buf and \a pn_idents were supplied, or \a pcb_buf was\r
NULL when \a name_buf was not.\r
\r
- zero if \a cred1 == \a cred2\r
- a postive value if \a cred1 > \a cred2\r
\see kcdb_credset_sort()\r
+ \see ::kcdb_credtype\r
*/\r
typedef khm_int32 \r
(KHMAPI *kcdb_cred_comp_func)(khm_handle cred1, \r
\retval KHM_ERROR_EXIT The supplied function signalled the\r
processing to be aborted.\r
\r
- \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid.\r
+ \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid.\r
*/\r
KHMEXP khm_int32 KHMAPI \r
kcdb_credset_apply(khm_handle credset, \r
*/\r
#define KCDB_CRED_FLAGMASK_ALL 0x0000ffff\r
\r
+/*! \brief External flags\r
+\r
+ These are flags that are provided by the credentials providers.\r
+ The other flags are internal to KCDB and should not be modified.\r
+ */\r
+#define KCDB_CRED_FLAGMASK_EXT (KCDB_CRED_FLAG_INITIAL | KCDB_CRED_FLAG_EXPIRED | KCDB_CRED_FLAG_INVALID | KCDB_CRED_FLAG_RENEWABLE)\r
+\r
/*! \brief Bitmask indicating dditive flags \r
\r
Additive flags are special flags which are added to exiting\r
\retval KHM_ERROR_SUCCESS Success\r
\retval KHM_ERROR_NOT_FOUND The given attribute was either invalid\r
or was not defined for this credential\r
- \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid\r
+ \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid\r
\retval KHM_ERROR_TOO_LONG Either \a buffer was NULL or the\r
supplied buffer was insufficient\r
*/\r
field was successfully copied to \a s_buf and the size of the\r
buffer used was copied to \a pcb_s_buf.\r
\r
- \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid\r
+ \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid\r
\r
\retval KHM_ERROR_TOO_LONG Either \a s_buf was \a NULL or the size\r
indicated by \a pcb_s_buf was too small to contain the string\r
\retval KHM_ERROR_SUCCESS The data was successfully copied. The\r
number of bytes copied is in \a pcb_data_dst\r
\r
- \retval KHM_ERROR_INVALID_PARM One or more parameters is incorrect.\r
+ \retval KHM_ERROR_INVALID_PARAM One or more parameters is incorrect.\r
\r
\retval KHM_ERROR_TOO_LONG Either \a data_dst was NULL or the size\r
of the buffer was insufficient. The required size is in \a\r
order in which the \a number \a unit specifications are given and\r
the same unit may be repeated multiple times.\r
\r
- \retval KHM_ERROR_INVALID_PARM The given string was invalid or had\r
+ \retval KHM_ERROR_INVALID_PARAM The given string was invalid or had\r
a token that could not be parsed. It can also mean that \a\r
pft was NULL or \a str was NULL.\r
\r
khm_int32 flags; /*!< Flags. Combination of \ref\r
kcdb_credattr_flags "attribute\r
flags" */\r
+\r
khm_int32 type; /*!< Type of the attribute. Must be valid. */\r
+\r
wchar_t * short_desc; /*!< Short description. (Localized,\r
optional) */\r
+\r
wchar_t * long_desc; /*!< Long description. (Localized,\r
optional) */\r
\r
kcdb_attrib_compute_cb compute_cb;\r
/*!< Callback. Required if \a flags\r
specify ::KCDB_ATTR_FLAG_COMPUTED. */\r
+\r
khm_size compute_min_cbsize;\r
/*!< Minimum number of bytes required\r
to store this attribute. Required\r
wchar_t * name; /*!< name (less than KCDB_MAXCB_NAME bytes) */\r
khm_int32 id;\r
wchar_t * short_desc; /*!< short localized description (less\r
- than KCDB_MAXCB_SHORT_DESC\r
- bytes) */\r
+ than KCDB_MAXCB_SHORT_DESC bytes) */\r
wchar_t * long_desc; /*!< long localized descriptionn (less\r
- than KCDB_MAXCB_LONG_DESC\r
- bytes) */\r
+ than KCDB_MAXCB_LONG_DESC bytes) */\r
khm_handle sub; /*!< Subscription for credentials type\r
- hander. This should be a valid\r
- subscription constructed through\r
- a call to\r
- kmq_create_subscription() and\r
- must handle KMSG_CRED messages\r
- that are marked as being sent to\r
- type specific subscriptions.\r
-\r
- The subscription will be\r
- automatically deleted with a call\r
- to kmq_delete_subscription() when\r
- the credentials type is\r
- unregistered.*/\r
+ hander. This should be a valid\r
+ subscription constructed through a\r
+ call to kmq_create_subscription()\r
+ and must handle KMSG_CRED messages\r
+ that are marked as being sent to\r
+ type specific subscriptions.\r
+\r
+ The subscription will be\r
+ automatically deleted with a call to\r
+ kmq_delete_subscription() when the\r
+ credentials type is unregistered.*/\r
+\r
+ kcdb_cred_comp_func is_equal; /*!< Used to as an additional clause\r
+ when comparing two credentials for\r
+ equality. The function this is\r
+ actually a comparison function, it\r
+ should return zero if the two\r
+ credentials are equal and non-zero\r
+ if they are not. The addtional \a\r
+ rock parameter is always zero.\r
+\r
+ It can be assumed that the identity,\r
+ name and credentials have already\r
+ been found to be equal among the\r
+ credentials and the credential type\r
+ is the type that is being\r
+ registered.*/\r
\r
#ifdef _WIN32\r
HICON icon;\r
\r
\retval KHM_ERROR_SUCCESS The credential type was successfully registered.\r
\r
- \retval KHM_ERROR_INVALID_PARM One or more of the parameters were invalid\r
+ \retval KHM_ERROR_INVALID_PARAM One or more of the parameters were invalid\r
\r
\retval KHM_ERROR_TOO_LONG One or more of the string fields in \a\r
type exceeded the character limit for that field.\r
\retval KHM_ERROR_TOO_LONG Either \a buf was NULL or the supplied\r
buffer was not large enough. The required size is in \a cbbuf.\r
\r
- \retval KHM_ERROR_INVALID_PARM Invalid parameter.\r
+ \retval KHM_ERROR_INVALID_PARAM Invalid parameter.\r
*/\r
KHMEXP khm_int32 KHMAPI \r
kcdb_credtype_get_name(khm_int32 id,\r
\r
\retval KHM_ERROR_SUCCESS The call succeeded\r
\retval KHM_ERROR_TOO_LONG Either \a buf was NULL or the supplied buffer was insufficient. The required size is specified in \a cbbuf.\r
- \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid.\r
+ \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid.\r
*/\r
KHMEXP khm_int32 KHMAPI \r
kcdb_credtype_describe(khm_int32 id,\r
\retval KHM_ERROR_SUCCESS Success\r
\retval KHM_ERROR_NOT_FOUND The given attribute was either invalid\r
or was not defined for this record\r
- \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid\r
+ \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid\r
\retval KHM_ERROR_TOO_LONG Either \a buffer was NULL or the\r
supplied buffer was insufficient\r
*/\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
void kcdb_exit(void);\r
khm_handle kcdb_get_config(void);\r
\r
-#endif
\ No newline at end of file
+\r
+#endif\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
size_t cbsize;\r
\r
if(!cb_buf)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
cbsize = sizeof(GENERIC_VOID_STR);\r
\r
khm_size * cbd_dst)\r
{\r
if(!cbd_dst)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
*cbd_dst = 0;\r
\r
wchar_t * sd;\r
\r
if(!cb_buf)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
sd = (wchar_t *) d;\r
\r
if(FAILED(StringCbLength(sd, KCDB_TYPE_MAXCB, &cbsize)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
cbsize += sizeof(wchar_t);\r
\r
size_t cbsize;\r
\r
if(!cbd_dst)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if(cbd_src == KCDB_CBSIZE_AUTO) {\r
cbd_src = KCDB_TYPE_MAXCB;\r
int today = 0;\r
\r
if(!cb_buf)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
ft = (FILETIME *) d;\r
\r
wchar_t * t;\r
\r
if(!cb_buf)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
s = *((__int64 *) data) / 10000000i64;\r
\r
m = s / 60;\r
wchar_t ibuf[12];\r
\r
if(!cb_buf)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
StringCbPrintf(ibuf, sizeof(ibuf), L"%d", *((khm_int32 *) d));\r
StringCbLength(ibuf, sizeof(ibuf), &cbsize);\r
wchar_t ibuf[22];\r
\r
if(!cb_buf)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
StringCbPrintf(ibuf, sizeof(ibuf), L"%I64d", *((__int64 *) d));\r
StringCbLength(ibuf, sizeof(ibuf), &cbsize);\r
size_t cbsize;\r
\r
if(!cb_buf)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
cbsize = sizeof(GENERIC_DATA_STR);\r
\r
khm_size * cbd_dst)\r
{\r
if(!cbd_dst)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
*cbd_dst = cbd_src;\r
\r
hash_string_comp,\r
kcdb_type_add_ref,\r
kcdb_type_del_ref);\r
- kcdb_type_tbl = malloc(sizeof(kcdb_type_i *) * (KCDB_TYPE_MAX_ID + 1));\r
+ kcdb_type_tbl = PMALLOC(sizeof(kcdb_type_i *) * (KCDB_TYPE_MAX_ID + 1));\r
ZeroMemory(kcdb_type_tbl, sizeof(kcdb_type_i *) * (KCDB_TYPE_MAX_ID + 1));\r
kcdb_types = NULL;\r
\r
khm_int32 kcdb_type_hold(kcdb_type_i * t)\r
{\r
if(!t)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_type);\r
t->refcount++;\r
khm_int32 kcdb_type_release(kcdb_type_i * t)\r
{\r
if(!t)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_type);\r
t->refcount--;\r
void kcdb_type_exit(void)\r
{\r
EnterCriticalSection(&cs_type);\r
- free(kcdb_type_tbl);\r
+ PFREE(kcdb_type_tbl);\r
/*TODO: free up the individual types */\r
LeaveCriticalSection(&cs_type);\r
DeleteCriticalSection(&cs_type);\r
LDELETE(&kcdb_types, t);\r
/* must already be out of the hash-table, otherwise refcount should not\r
be zero */\r
- free(t->type.name);\r
- free(t);\r
+ PFREE(t->type.name);\r
+ PFREE(t);\r
}\r
LeaveCriticalSection(&cs_type);\r
}\r
\r
if(FAILED(StringCbLength(name, KCDB_MAXCB_NAME, &cbsize))) {\r
/* also fails of name is NULL */\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
EnterCriticalSection(&cs_type);\r
kcdb_type_i * t;\r
\r
if(id < 0 || id > KCDB_TYPE_MAX_ID)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_type);\r
t = kcdb_type_tbl[id];\r
kcdb_type_i * t;\r
\r
if(id < 0 || id > KCDB_TYPE_MAX_ID || !cbbuf)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
t = kcdb_type_tbl[id];\r
\r
!type->isValid || \r
!type->toString || \r
!type->name)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if((type->flags & KCDB_TYPE_FLAG_CB_MIN) &&\r
(type->cb_min < 0 || type->cb_min > KCDB_TYPE_MAXCB))\r
{\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
if((type->flags & KCDB_TYPE_FLAG_CB_MAX) &&\r
(type->cb_max < 0 || type->cb_max > KCDB_TYPE_MAXCB))\r
{\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
if((type->flags & KCDB_TYPE_FLAG_CB_MIN) &&\r
(type->flags & KCDB_TYPE_FLAG_CB_MAX) &&\r
(type->cb_max < type->cb_min))\r
{\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
if(FAILED(StringCbLength(type->name, KCDB_MAXCB_NAME, &cbsize)))\r
kcdb_type_get_next_free(&type_id);\r
} else if(type->id < 0 || type->id > KCDB_TYPE_MAX_ID) {\r
LeaveCriticalSection(&cs_type);\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
} else if(kcdb_type_tbl[type->id]) {\r
LeaveCriticalSection(&cs_type);\r
return KHM_ERROR_DUPLICATE;\r
return KHM_ERROR_NO_RESOURCES;\r
}\r
\r
- t = malloc(sizeof(kcdb_type_i));\r
+ t = PMALLOC(sizeof(kcdb_type_i));\r
ZeroMemory(t, sizeof(kcdb_type_i));\r
\r
- t->type.name = malloc(cbsize);\r
+ t->type.name = PMALLOC(cbsize);\r
StringCbCopy(t->type.name, cbsize, type->name);\r
\r
t->type.comp = type->comp;\r
kcdb_type_i * t;\r
\r
if(id < 0 || id > KCDB_TYPE_MAX_ID)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_type);\r
t = kcdb_type_tbl[id];\r
int i;\r
\r
if(!id)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
/* do a linear search because this function only gets called a few times */\r
EnterCriticalSection(&cs_type);\r
}\r
\r
if(!str || FAILED(StringCbLength(str, MAX_IVL_SPECLIST_LEN, &cb)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
b = str;\r
t = 0;\r
b++;\r
\r
if(!*b) /* no unit specified */\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
e = b;\r
\r
}\r
\r
if(i==MAX_IVL_UNITS)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
t += f * ivspecs[i].mul;\r
\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
void * d_dst,\r
khm_size * cbd_dst);\r
\r
-#endif
\ No newline at end of file
+#endif\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
khm_size n_ctx_handlers;\r
khm_size nc_ctx_handlers;\r
\r
-khm_ui_4 ctx_serial = 0;\r
+kherr_serial ctx_serial = 0;\r
\r
#ifdef DEBUG\r
-static void DebugPrintf(wchar_t * fmt, ...) {\r
+#define DEBUG_CONTEXT\r
+\r
+KHMEXP void kherr_debug_printf(wchar_t * fmt, ...) {\r
va_list vl;\r
wchar_t buf[1024];\r
\r
#endif\r
\r
KHMEXP void KHMAPI kherr_add_ctx_handler(kherr_ctx_handler h,\r
- khm_int32 filter) {\r
+ khm_int32 filter,\r
+ kherr_serial serial) {\r
\r
assert(h);\r
\r
if( ctx_handlers == NULL) {\r
nc_ctx_handlers = CTX_ALLOC_INCR;\r
n_ctx_handlers = 0;\r
- ctx_handlers = malloc(sizeof(*ctx_handlers) * nc_ctx_handlers);\r
+ ctx_handlers = PMALLOC(sizeof(*ctx_handlers) * nc_ctx_handlers);\r
/* No need to initialize */\r
} else if (n_ctx_handlers == nc_ctx_handlers) {\r
khm_size new_nc;\r
kherr_handler_node * new_ctxs;\r
\r
new_nc = nc_ctx_handlers + CTX_ALLOC_INCR;\r
- new_ctxs = malloc(sizeof(*new_ctxs) * new_nc);\r
- memmove(new_ctxs, ctx_handlers, n_ctx_handlers);\r
+ new_ctxs = PMALLOC(sizeof(*new_ctxs) * new_nc);\r
+ memcpy(new_ctxs, ctx_handlers, n_ctx_handlers * sizeof(*new_ctxs));\r
\r
- free(ctx_handlers);\r
+ PFREE(ctx_handlers);\r
ctx_handlers = new_ctxs;\r
nc_ctx_handlers = new_nc;\r
}\r
\r
ctx_handlers[n_ctx_handlers].h = h;\r
ctx_handlers[n_ctx_handlers].filter = filter;\r
+ ctx_handlers[n_ctx_handlers].serial = serial;\r
+\r
+ n_ctx_handlers++;\r
+\r
LeaveCriticalSection(&cs_error);\r
}\r
\r
-KHMEXP void KHMAPI kherr_remove_ctx_handler(kherr_ctx_handler h) {\r
+KHMEXP void KHMAPI kherr_remove_ctx_handler(kherr_ctx_handler h,\r
+ kherr_serial serial) {\r
khm_size i;\r
EnterCriticalSection(&cs_error);\r
\r
for (i=0 ; i < n_ctx_handlers; i++) {\r
- if (ctx_handlers[i].h == h) {\r
+ if (ctx_handlers[i].h == h &&\r
+ ctx_handlers[i].serial == serial) {\r
break;\r
}\r
}\r
void notify_ctx_event(enum kherr_ctx_event e, kherr_context * c) {\r
khm_size i;\r
\r
+ kherr_ctx_handler h;\r
+\r
for (i=0; i<n_ctx_handlers; i++) {\r
- if (ctx_handlers[i].filter & e)\r
- ctx_handlers[i].h(e,c);\r
+ if (ctx_handlers[i].h && (ctx_handlers[i].filter & e) &&\r
+ (ctx_handlers[i].serial == 0 ||\r
+ ctx_handlers[i].serial == c->serial)) {\r
+ if (IsBadCodePtr((FARPROC) ctx_handlers[i].h)) {\r
+ ctx_handlers[i].h = NULL;\r
+ } else {\r
+ h = ctx_handlers[i].h;\r
+ (*h)(e,c);\r
+\r
+ /* a context handler is allowed to remove itself\r
+ during a callback. It is, however, not allowed to\r
+ remove anything else. */\r
+ if (h != ctx_handlers[i].h)\r
+ i--;\r
+ }\r
+ }\r
}\r
}\r
\r
if (t)\r
return;\r
\r
- t = malloc(sizeof(kherr_thread) + \r
- sizeof(kherr_context *) * THREAD_STACK_SIZE);\r
+ t = PMALLOC(sizeof(kherr_thread) + \r
+ sizeof(kherr_context *) * THREAD_STACK_SIZE);\r
t->nc_ctx = THREAD_STACK_SIZE;\r
t->n_ctx = 0;\r
t->ctx = (kherr_context **) &t[1];\r
for(i=0; i < t->n_ctx; i++) {\r
kherr_release_context(t->ctx[i]);\r
}\r
- free(t);\r
+ PFREE(t);\r
TlsSetValue(tls_error, 0);\r
}\r
}\r
cb_new = sizeof(kherr_thread) + \r
sizeof(kherr_context *) * nc_new;\r
\r
- nt = malloc(cb_new);\r
+ nt = PMALLOC(cb_new);\r
memcpy(nt, t, sizeof(kherr_thread) +\r
sizeof(kherr_context *) * t->n_ctx);\r
nt->ctx = (kherr_context **) &nt[1];\r
nt->nc_ctx = nc_new;\r
\r
- free(t);\r
+ PFREE(t);\r
t = nt;\r
TlsSetValue(tls_error, t);\r
}\r
kherr_event * e;\r
\r
EnterCriticalSection(&cs_error);\r
- if(evt_free_list)\r
+ if(evt_free_list) {\r
LPOP(&evt_free_list, &e);\r
- else\r
- e = malloc(sizeof(*e));\r
+ } else {\r
+ e = PMALLOC(sizeof(*e));\r
+ }\r
LeaveCriticalSection(&cs_error);\r
ZeroMemory(e, sizeof(*e));\r
e->severity = KHERR_NONE;\r
void free_event_params(kherr_event * e) {\r
if(parm_type(e->p1) == KEPT_STRINGT) {\r
assert((void *) parm_data(e->p1));\r
- free((void*) parm_data(e->p1));\r
+ PFREE((void*) parm_data(e->p1));\r
e->p1 = (kherr_param) 0;\r
}\r
if(parm_type(e->p2) == KEPT_STRINGT) {\r
assert((void *) parm_data(e->p2));\r
- free((void*) parm_data(e->p2));\r
+ PFREE((void*) parm_data(e->p2));\r
e->p2 = (kherr_param) 0;\r
}\r
if(parm_type(e->p3) == KEPT_STRINGT) {\r
assert((void *) parm_data(e->p3));\r
- free((void*) parm_data(e->p3));\r
+ PFREE((void*) parm_data(e->p3));\r
e->p3 = (kherr_param) 0;\r
}\r
if(parm_type(e->p4) == KEPT_STRINGT) {\r
assert((void *) parm_data(e->p4));\r
- free((void*) parm_data(e->p4));\r
+ PFREE((void*) parm_data(e->p4));\r
e->p4 = (kherr_param) 0;\r
}\r
}\r
\r
void free_event(kherr_event * e) {\r
+\r
+ EnterCriticalSection(&cs_error);\r
+\r
assert(e->magic == KHERR_EVENT_MAGIC);\r
\r
-#ifdef DEBUG\r
- DebugPrintf(L"Freeing event 0x%x\n", e);\r
+#ifdef DEBUG_CONTEXT\r
+ kherr_debug_printf(L"Freeing event 0x%x\n", e);\r
if (!(e->flags & KHERR_RF_STR_RESOLVED))\r
resolve_event_strings(e);\r
if (e->short_desc)\r
- DebugPrintf(L" Desc(S):[%s]\n", e->short_desc);\r
+ kherr_debug_printf(L" Desc(S):[%s]\n", e->short_desc);\r
if (e->long_desc)\r
- DebugPrintf(L" Desc(L):[%s]\n", e->long_desc);\r
+ kherr_debug_printf(L" Desc(L):[%s]\n", e->long_desc);\r
if (e->suggestion)\r
- DebugPrintf(L" Suggest:[%s]\n", e->suggestion);\r
+ kherr_debug_printf(L" Suggest:[%s]\n", e->suggestion);\r
if (e->facility)\r
- DebugPrintf(L" Facility:[%s]\n", e->facility);\r
+ kherr_debug_printf(L" Facility:[%s]\n", e->facility);\r
#endif\r
\r
if(e->flags & KHERR_RF_FREE_SHORT_DESC) {\r
assert(e->short_desc);\r
- free((void *) e->short_desc);\r
+ PFREE((void *) e->short_desc);\r
}\r
if(e->flags & KHERR_RF_FREE_LONG_DESC) {\r
assert(e->long_desc);\r
- free((void *) e->long_desc);\r
+ PFREE((void *) e->long_desc);\r
}\r
if(e->flags & KHERR_RF_FREE_SUGGEST) {\r
assert(e->suggestion);\r
- free((void *) e->suggestion);\r
+ PFREE((void *) e->suggestion);\r
}\r
\r
free_event_params(e);\r
\r
ZeroMemory(e, sizeof(e));\r
\r
- EnterCriticalSection(&cs_error);\r
LPUSH(&evt_free_list, e);\r
LeaveCriticalSection(&cs_error);\r
}\r
if(ctx_free_list)\r
LPOP(&ctx_free_list, &c);\r
else {\r
- c = malloc(sizeof(kherr_context));\r
+ c = PMALLOC(sizeof(kherr_context));\r
}\r
\r
ZeroMemory(c,sizeof(*c));\r
kherr_event * e;\r
\r
assert(c->magic == KHERR_CONTEXT_MAGIC);\r
-#ifdef DEBUG\r
- DebugPrintf(L"Freeing context 0x%x\n", c);\r
+#ifdef DEBUG_CONTEXT\r
+ kherr_debug_printf(L"Freeing context 0x%x\n", c);\r
#endif\r
\r
EnterCriticalSection(&cs_error);\r
LPUSH(&ctx_free_list,c);\r
LeaveCriticalSection(&cs_error);\r
\r
-#ifdef DEBUG\r
- DebugPrintf(L"Done with context 0x%x\n", c);\r
+#ifdef DEBUG_CONTEXT\r
+ kherr_debug_printf(L"Done with context 0x%x\n", c);\r
#endif\r
}\r
\r
-\r
void add_event(kherr_context * c, kherr_event * e)\r
{\r
EnterCriticalSection(&cs_error);\r
*str = NULL;\r
} else {\r
bytes = (chars + 1) * sizeof(wchar_t);\r
- s = malloc(bytes);\r
+ s = PMALLOC(bytes);\r
assert(s);\r
StringCbCopy(s, bytes, tbuf);\r
*str = s;\r
tbuf[--chars] = L'\0';\r
\r
bytes = (chars + 1) * sizeof(wchar_t);\r
- s = malloc(bytes);\r
+ s = PMALLOC(bytes);\r
assert(s);\r
StringCbCopy(s, bytes, tbuf);\r
*str = s;\r
(va_list *) args);\r
\r
if ((e->flags & mask) == free_if) {\r
- free((void *) *str);\r
+ PFREE((void *) *str);\r
}\r
\r
e->flags &= ~mask;\r
wchar_t * s;\r
\r
bytes = (chars + 1) * sizeof(wchar_t);\r
- s = malloc(bytes);\r
+ s = PMALLOC(bytes);\r
assert(s);\r
StringCbCopy(s, bytes, tbuf);\r
*str = s;\r
if(!c) {\r
/* the reason why we are doing it this way is because p1..p4,\r
the descriptions and the suggestion may contain allocations\r
- that has to be freed. In terms of performance we are\r
- assuming that this case doesn't happen that much. Har\r
- har */\r
+ that has to be freed. */\r
free_event(e);\r
e = NULL;\r
} else {\r
\r
kherr_param dup_parm(kherr_param p) {\r
if(parm_type(p) == KEPT_STRINGT) {\r
- wchar_t * d = wcsdup((wchar_t *)parm_data(p));\r
+ wchar_t * d = PWCSDUP((wchar_t *)parm_data(p));\r
return kherr_val(KEPT_STRINGT, d);\r
} else\r
return p;\r
else\r
cb_s += sizeof(wchar_t);\r
\r
- dest = malloc(cb_s);\r
+ dest = PMALLOC(cb_s);\r
assert(dest != NULL);\r
dest[0] = L'\0';\r
\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
longer considered significant. */\r
};\r
\r
+/*! \brief Serial number for error contexts */\r
+typedef khm_ui_4 kherr_serial;\r
+\r
/*! \brief An error context\r
*/\r
typedef struct tag_kherr_context {\r
khm_int32 magic; /*!< Magic number. Always set to\r
KHERR_CONTEXT_MAGIC */\r
\r
- khm_ui_4 serial; /*!< Context instance serial number.\r
+ kherr_serial serial; /*!< Context instance serial number.\r
Context objects themselves may be\r
reused for different contexts as\r
they are freed and reallocated.\r
\r
\see kherr_add_ctx_handler()\r
*/\r
-typedef void (*kherr_ctx_handler)(enum kherr_ctx_event, kherr_context *);\r
+typedef void (KHMAPI * kherr_ctx_handler)(enum kherr_ctx_event, \r
+ kherr_context *);\r
\r
/*! \brief Add a context event handler\r
\r
indication which notifications should be sent to the handler.\r
If a \a filter value of zero is provided, all of the events\r
will be sent to the handler.\r
+\r
+ \param[in] serial The serial number of the error context that\r
+ should be tracked. If this is zero, all error contexts can\r
+ trigger the handler.\r
*/\r
KHMEXP void KHMAPI kherr_add_ctx_handler(kherr_ctx_handler h, \r
- khm_int32 filter);\r
+ khm_int32 filter,\r
+ kherr_serial serial);\r
\r
/*! \brief Remove a context event handler\r
\r
\r
\see kherr_add_ctx_handler()\r
*/\r
-KHMEXP void KHMAPI kherr_remove_ctx_handler(kherr_ctx_handler h);\r
+KHMEXP void KHMAPI kherr_remove_ctx_handler(kherr_ctx_handler h,\r
+ kherr_serial serial);\r
\r
\r
/*! \brief Report an error\r
\r
/*@}*/\r
\r
+/* In debug mode, outputs the formatted string to the debug console */\r
+#ifdef DEBUG\r
+KHMEXP void kherr_debug_printf(wchar_t * fmt, ...);\r
+#endif\r
+\r
#endif\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
\r
#include<windows.h>\r
#include<kherr.h>\r
+#include<utils.h>\r
#include<strsafe.h>\r
\r
typedef struct tag_kherr_thread {\r
#define THREAD_STACK_SIZE 8\r
\r
typedef struct tag_kherr_handler_node {\r
- khm_int32 filter;\r
+ khm_int32 filter;\r
kherr_ctx_handler h;\r
+ kherr_serial serial;\r
} kherr_handler_node;\r
\r
#define CTX_ALLOC_INCR 4\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/* $Id$ */\r
\r
#include<kmminternal.h>\r
+#include<assert.h>\r
\r
-khm_boolean kmm_load_locale_lib(kmm_module_i * m, kmm_module_locale * l)\r
+khm_boolean kmmint_load_locale_lib(kmm_module_i * m, kmm_module_locale * l)\r
{\r
HMODULE h;\r
\r
if(l->filename != NULL) {\r
- h = LoadLibrary(l->filename);\r
+ wchar_t path[MAX_PATH];\r
+ DWORD dw;\r
+\r
+ /* construct the path name */\r
+ assert(m->h_module != NULL);\r
+\r
+ dw = PathIsFileSpec(l->filename);\r
+\r
+ assert(dw);\r
+ if (!dw)\r
+ return FALSE;\r
+\r
+ dw = GetModuleFileName(m->h_module, path, ARRAYLENGTH(path));\r
+ assert(dw != 0);\r
+ if (dw == 0)\r
+ return FALSE;\r
+\r
+ PathRemoveFileSpec(path);\r
+ dw = PathAppend(path, l->filename);\r
+ assert(dw);\r
+ if (!dw)\r
+ return FALSE;\r
+\r
+ h = LoadLibrary(path);\r
if(!h)\r
return FALSE;\r
\r
LeaveCriticalSection(&cs_kmm);\r
\r
return TRUE;\r
+\r
} else {\r
/* in this case, the language resources are assumed to be in the\r
main module library itself. */\r
return KHM_ERROR_INVALID_OPERATION;\r
\r
if(!locales || n_locales < 0)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
- f = malloc(n_locales * sizeof(int));\r
+ f = PMALLOC(n_locales * sizeof(int));\r
if(!f)\r
return KHM_ERROR_UNKNOWN;\r
ZeroMemory(f, sizeof(int) * n_locales);\r
for(i=0; i<n_locales; i++) {\r
if(locales[i].language == lcid) {\r
f[i] = TRUE;\r
- if(kmm_load_locale_lib(m, &locales[i]))\r
+ if(kmmint_load_locale_lib(m, &locales[i]))\r
break;\r
}\r
}\r
for(i=0; i<n_locales; i++) {\r
if(!f[i] && (PRIMARYLANGID(locales[i].language) == PRIMARYLANGID(lcid))) {\r
f[i] = TRUE;\r
- if(kmm_load_locale_lib(m,&locales[i]))\r
+ if(kmmint_load_locale_lib(m,&locales[i]))\r
break;\r
}\r
}\r
for(i=0; i<n_locales; i++) {\r
if(!f[i] && (locales[i].flags & KMM_MLOC_FLAG_DEFAULT)) {\r
f[i] = TRUE;\r
- if(kmm_load_locale_lib(m,&locales[i]))\r
+ if(kmmint_load_locale_lib(m,&locales[i]))\r
break;\r
}\r
}\r
rv = KHM_ERROR_NOT_FOUND;\r
\r
_exit:\r
- free(f);\r
+ PFREE(f);\r
return rv;\r
}\r
\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
#define KMM_MAXCCH_DESC 512\r
\r
/*! \brief Maximum number of bytes in a description in KMM including the terminating NULL */\r
-#define KMM_MAXCB_DESC (sizeof(wchar_t) * KMM_MAXCB_NAME)\r
+#define KMM_MAXCB_DESC (sizeof(wchar_t) * KMM_MAXCCH_NAME)\r
+\r
+/*! \brief Maximum number of characters in a vendor string in KMM including the terminating NULL */\r
+#define KMM_MAXCCH_VENDOR 256\r
+\r
+/*! \brief Maximum number of bytes in a vendor string in KMM including the terminating NULL */\r
+#define KMM_MAXCB_VENDOR (sizeof(wchar_t) * KMM_MAXCCH_VENDOR)\r
+\r
+/*! \brief Maximum number of characters in a support URI in KMM including the terminating NULL */\r
+#define KMM_MAXCCH_SUPPORT 256\r
+\r
+/*! \brief Maximum number of bytes in a vendor string in KMM including the terminating NULL */\r
+#define KMM_MAXCB_SUPPORT (sizeof(wchar_t) * KMM_MAXCCH_SUPPORT)\r
\r
/*! \brief Maximum number of dependencies per plugin\r
*/\r
\r
/*! \brief Maximum number of dependants per plugin\r
*/\r
-#define KMM_MAX_DEPENDANTS 16\r
+#define KMM_MAX_DEPENDANTS 32\r
\r
/*! \brief Maximum number of characters a dependency string including trailing double NULL */\r
#define KMM_MAXCCH_DEPS (KMM_MAXCCH_NAME * KMM_MAX_DEPENDENCIES + 1)\r
/*! \brief A credentials provider\r
\r
\see \ref pi_pt_cred for more information.\r
-*/\r
+ */\r
#define KHM_PITYPE_CRED 1\r
\r
+/*! \brief A identity provider \r
+\r
+ \see \ref pi_pt_cred for more information\r
+ */\r
+#define KHM_PITYPE_IDENT 2\r
+\r
/*! \brief A configuration provider\r
\r
\see \ref pi_pt_conf for more information.\r
-*/\r
-#define KHM_PITYPE_CONFIG 2\r
+ */\r
+#define KHM_PITYPE_CONFIG 3\r
\r
-/*@}*/\r
+/*! \brief Undefined plugin type\r
\r
-/*! \name Plugin flags\r
-@{*/\r
+ The plugin doesn't provide any credential type.\r
+ */\r
+#define KHM_PITYPE_MISC 4\r
\r
-/*! \brief The plugin is an identity provider\r
-*/\r
-#define KHM_PIFLAG_IDENTITY_PROVIDER 1\r
/*@}*/\r
\r
/*! \brief Plugin states */\r
\r
wchar_t * vendor; /*!< Vendor/copyright string */\r
\r
+ wchar_t * support; /*!< Support URL/contact */\r
+\r
khm_int32 n_plugins; /*!< Number of plugins that are\r
active */\r
kmm_plugin_reg * plugin_reg_info; /*!< Array of kmm_plugin_reg\r
/*! \brief Module states\r
*/\r
enum KMM_MODULE_STATES {\r
+ KMM_MODULE_STATE_FAIL_INCOMPAT=-12, /*!< The library containing\r
+ the module was not\r
+ compatible with this version\r
+ of NetIDMgr. */\r
+ KMM_MODULE_STATE_FAIL_INV_MODULE=-11, /*!< The library containing\r
+ the module was invalid. */\r
KMM_MODULE_STATE_FAIL_UNKNOWN=-10, /*!< Module could not be\r
loaded due to unknown\r
reasons. */\r
kmm_load_pending(void);\r
\r
#ifdef _WIN32\r
-/*! \brief Returns the Windows module handle from a handle to a NetIDMgr module.\r
\r
+/*! \brief Returns the Windows module handle from a handle to a NetIDMgr module.\r
Although it is possible to obtain the Windows module handle and\r
use it to call Windows API functions, it is not recommended to do\r
so. This is because that might cause the state of the module to\r
change in ways which are inconsistent from the internal data\r
structures that kmm maintains.\r
-*/\r
+ */\r
KHMEXP HMODULE KHMAPI \r
kmm_get_hmodule(kmm_module m);\r
#endif\r
\retval KHM_ERROR_SUCCESS Succeeded.\r
\retval KHM_ERROR_INVALID_OPERATION The function was not called\r
during init_module()\r
- \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid\r
+ \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid\r
\retval KHM_ERROR_DUPLICATE The plugin was already provided\r
\r
\note This can only be called when handing init_module()\r
copied.\r
\r
\retval KHM_ERROR_SUCCESS The requested information was copied\r
- \retval KHM_ERROR_INVALID_PARM One of the parameters was invalid\r
+ \retval KHM_ERROR_INVALID_PARAM One of the parameters was invalid\r
\retval KHM_ERROR_TOO_LONG The buffer was not large enough or was\r
NULL. The number of bytes requied is in \a cb_buffer.\r
\retval KHM_ERROR_NOT_FOUND The specified module is not a\r
\retval KHM_ERROR_TOO_LONG The buffer was either \a NULL or\r
insufficient to hold the requested information. The required\r
size of the buffer was stored in \a cb_buffer\r
- \retval KHM_ERROR_INVALID_PARM One or more parameters were\r
+ \retval KHM_ERROR_INVALID_PARAM One or more parameters were\r
invlaid.\r
\retval KHM_ERROR_NOT_FOUND The specified plugin was not found\r
among the registered plugins.\r
zero, in which case \a plugin_info can be \a NULL. Plugins can be\r
registered separately using kmm_register_plugin().\r
\r
- \param[in] module Information about the module. All members are\r
- required, however \a plugin_info can be \a NULL if \a\r
- n_plugins is zero.\r
+ \param[in] module Information about the module. The name and path\r
+ fields are required. The \a plugin_info field can only be \a\r
+ NULL if \a n_plugins is zero.\r
\r
\param[in] config_flags Flags used to call khc_open_space(). This\r
can be used to choose the configuration store in which the\r
kmm_get_resource_hmodule(). This function does not return until a\r
matched library is loaded.\r
\r
+ Note that the ::kmm_module_locale structure only specifies a\r
+ module name for the resource module. This resource module must\r
+ exist in the same directory as the \a module.\r
+\r
\param[in] module The module handle\r
\param[in] locales An array of ::kmm_module_locale objects\r
\param[in] n_locales The number of objects in the array pointed to by \a locales\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/* $Id$ */\r
\r
#include<kmminternal.h>\r
+#include<netidmgr_version.h>\r
+#include<assert.h>\r
\r
-kmm_module_i * kmm_get_module_i(wchar_t * name)\r
+kmm_module_i * kmmint_get_module_i(wchar_t * name)\r
{\r
kmm_module_i * m;\r
size_t sz;\r
m = (kmm_module_i *) hash_lookup(hash_modules, (void *) name);\r
\r
if(m == NULL) {\r
- m = malloc(sizeof(kmm_module_i));\r
+ m = PMALLOC(sizeof(kmm_module_i));\r
ZeroMemory(m, sizeof(kmm_module_i));\r
\r
m->magic = KMM_MODULE_MAGIC;\r
- m->name = malloc(sz);\r
+ m->name = PMALLOC(sz);\r
StringCbCopy(m->name, sz, name);\r
m->state = KMM_MODULE_STATE_NONE;\r
\r
return m;\r
}\r
\r
-kmm_module_i * kmm_find_module_i(wchar_t * name)\r
+kmm_module_i * kmmint_find_module_i(wchar_t * name)\r
{\r
kmm_module_i * m;\r
\r
}\r
\r
/* called with cs_kmm held */\r
-void kmm_free_module(kmm_module_i * m)\r
+void kmmint_free_module(kmm_module_i * m)\r
{\r
m->magic = 0;\r
\r
LDELETE(&kmm_all_modules, m);\r
\r
if (m->name)\r
- free(m->name);\r
+ PFREE(m->name);\r
+\r
+ if (m->description)\r
+ PFREE(m->description);\r
+\r
if (m->path)\r
- free(m->path);\r
+ PFREE(m->path);\r
+\r
if (m->vendor)\r
- free(m->vendor);\r
+ PFREE(m->vendor);\r
+\r
+ if (m->support)\r
+ PFREE(m->support);\r
+\r
if (m->version_info)\r
- free(m->version_info);\r
- free(m);\r
+ PFREE(m->version_info);\r
+\r
+ PFREE(m);\r
\r
if (kmm_all_modules == NULL)\r
SetEvent(evt_exit);\r
KHMEXP khm_int32 KHMAPI kmm_hold_module(kmm_module module)\r
{\r
if(!kmm_is_module(module))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
EnterCriticalSection(&cs_kmm);\r
kmm_module_from_handle(module)->refcount++;\r
LeaveCriticalSection(&cs_kmm);\r
{\r
kmm_module_i * m;\r
if(!kmm_is_module(vm))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_kmm);\r
m = kmm_module_from_handle(vm);\r
{\r
/* note that a 0 ref count means that there are no active\r
plugins */\r
- kmm_free_module(m);\r
+ kmmint_free_module(m);\r
}\r
LeaveCriticalSection(&cs_kmm);\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
+khm_int32\r
+kmmint_check_api_version(DWORD v) {\r
+ /* for now, we require an exact match. In the future when we are\r
+ swamped with so much time that we don't know what to do with\r
+ it, we can actually parse the apiversion.txt file and create a\r
+ compatibility table which we can check against the functions\r
+ used by the module and decide whether or not it is\r
+ compatible. */\r
+\r
+ if (v != KH_VERSION_API)\r
+ return KHM_ERROR_INCOMPATIBLE;\r
+ else\r
+ return KHM_ERROR_SUCCESS;\r
+}\r
+\r
+struct lang_code {\r
+ WORD language;\r
+ WORD codepage;\r
+};\r
+\r
+khm_int32\r
+kmmint_read_module_info(kmm_module_i * m) {\r
+ /* the only fields we can count on at this point are m->name and\r
+ m->path */\r
+ DWORD t;\r
+ size_t cb;\r
+ WORD lang;\r
+ khm_int32 rv = KHM_ERROR_SUCCESS;\r
+ struct lang_code *languages;\r
+ int n_languages;\r
+ int i;\r
+ wchar_t resname[256]; /* the resource names are a lot shorter */\r
+ wchar_t * r;\r
+ VS_FIXEDFILEINFO *vff;\r
+\r
+ assert(m->name);\r
+ assert(m->path);\r
+\r
+ t = TRUE;\r
+ cb = GetFileVersionInfoSize(m->path,\r
+ &t);\r
+ /* if successful, cb gets the size in bytes of the version info\r
+ structure and sets t to zero */\r
+ if (t) {\r
+ return KHM_ERROR_NOT_FOUND;\r
+ } else if (cb == 0) {\r
+ _report_mr1(KHERR_WARNING, MSG_RMI_NOT_FOUND, _dupstr(m->path));\r
+ return KHM_ERROR_INVALID_PARAM;\r
+ }\r
+\r
+ if (m->version_info) {\r
+ PFREE(m->version_info);\r
+ m->version_info = NULL;\r
+ }\r
+\r
+ m->version_info = PMALLOC(cb);\r
+#ifdef DEBUG\r
+ assert(m->version_info);\r
+#endif\r
+\r
+ if(!GetFileVersionInfo(m->path,\r
+ t, (DWORD) cb, m->version_info)) {\r
+ rv = KHM_ERROR_NOT_FOUND;\r
+ _report_mr1(KHERR_WARNING, MSG_RMI_NOT_FOUND, _dupstr(m->path));\r
+ _location(L"GetFileVersionInfo");\r
+ goto _cleanup;\r
+ }\r
+\r
+ if(!VerQueryValue(m->version_info,\r
+ L"\\VarFileInfo\\Translation",\r
+ (LPVOID*) &languages,\r
+ &cb)) {\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
+ _report_mr1(KHERR_WARNING, MSG_RMI_NO_TRANS, _dupstr(m->path));\r
+ _location(L"VerQueryValue");\r
+ goto _cleanup;\r
+ }\r
+\r
+ n_languages = (int) (cb / sizeof(*languages));\r
+ lang = GetUserDefaultLangID();\r
+ for (i = 0; i < n_languages; i++) {\r
+ if(languages[i].language == lang)\r
+ break;\r
+ }\r
+\r
+ if (i >= n_languages) {\r
+ lang = GetSystemDefaultLangID();\r
+ for (i=0; i<n_languages; i++)\r
+ if (languages[i].language == lang)\r
+ break;\r
+ }\r
+\r
+ if (i >= n_languages) {\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
+ _report_mr0(KHERR_WARNING, MSG_RMI_NO_LOCAL);\r
+ goto _cleanup;\r
+ }\r
+\r
+ /* check module name */\r
+ StringCbPrintf(resname, sizeof(resname),\r
+ L"\\StringFileInfo\\%04x%04x\\" TEXT(NIMV_MODULE),\r
+ languages[i].language,\r
+ languages[i].codepage);\r
+\r
+ if (!VerQueryValue(m->version_info,\r
+ resname, (LPVOID *) &r, &cb)) {\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
+ _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING, \r
+ _cstr(TEXT(NIMV_MODULE)));\r
+ goto _cleanup;\r
+ }\r
+\r
+ if (cb > KMM_MAXCB_NAME ||\r
+ FAILED(StringCbLength(r, KMM_MAXCB_NAME, &cb))) {\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
+ _report_mr1(KHERR_WARNING, MSG_RMI_RES_TOO_LONG,\r
+ _cstr(TEXT(NIMV_MODULE)));\r
+ goto _cleanup;\r
+ \r
+ }\r
+\r
+ if (wcscmp(r, m->name)) {\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
+ _report_mr2(KHERR_WARNING, MSG_RMI_MOD_MISMATCH,\r
+ _dupstr(r), _dupstr(m->name));\r
+ goto _cleanup;\r
+ }\r
+\r
+ /* check API version */\r
+ StringCbPrintf(resname, sizeof(resname),\r
+ L"\\StringFileInfo\\%04x%04x\\" TEXT(NIMV_APIVER),\r
+ languages[i].language,\r
+ languages[i].codepage);\r
+\r
+ if (!VerQueryValue(m->version_info,\r
+ resname, (LPVOID *) &r, &cb)) {\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
+ _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING, \r
+ _cstr(TEXT(NIMV_APIVER)));\r
+ goto _cleanup;\r
+ }\r
+\r
+ if (cb > KMM_MAXCB_NAME ||\r
+ FAILED(StringCbLength(r, KMM_MAXCB_NAME, &cb))) {\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
+ _report_mr1(KHERR_WARNING, MSG_RMI_RES_TOO_LONG,\r
+ _cstr(TEXT(NIMV_APIVER)));\r
+ goto _cleanup;\r
+ }\r
+\r
+ t = wcstol(r, NULL, 10);\r
+\r
+ rv = kmmint_check_api_version(t);\r
+\r
+ if (KHM_FAILED(rv)) {\r
+ _report_mr2(KHERR_WARNING, MSG_RMI_API_MISMATCH,\r
+ _int32(t), _int32(KH_VERSION_API));\r
+ goto _cleanup;\r
+ }\r
+\r
+ /* Looks good. Now load the description, copyright, support URI\r
+ and file versions */\r
+ if (m->description) {\r
+ PFREE(m->description);\r
+ m->description = NULL;\r
+ }\r
+\r
+ StringCbPrintf(resname, sizeof(resname),\r
+ L"\\StringFileInfo\\%04x%04x\\FileDescription",\r
+ languages[i].language,\r
+ languages[i].codepage);\r
+\r
+ if (!VerQueryValue(m->version_info,\r
+ resname, (LPVOID *) &r, &cb)) {\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
+ _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING, \r
+ _cstr(L"FileDescription"));\r
+ goto _cleanup;\r
+ }\r
+\r
+ if (cb > KMM_MAXCB_DESC ||\r
+ FAILED(StringCbLength(r, KMM_MAXCB_DESC, &cb))) {\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
+ _report_mr1(KHERR_WARNING, MSG_RMI_RES_TOO_LONG,\r
+ _cstr(L"FileDescription"));\r
+ goto _cleanup;\r
+ }\r
+\r
+ cb += sizeof(wchar_t);\r
+\r
+ m->description = PMALLOC(cb);\r
+#ifdef DEBUG\r
+ assert(m->description);\r
+#endif\r
+ StringCbCopy(m->description, cb, r);\r
+\r
+ /* on to the support URI */\r
+ if (m->support) {\r
+ PFREE(m->support);\r
+ m->support = NULL;\r
+ }\r
+\r
+ StringCbPrintf(resname, sizeof(resname),\r
+ L"\\StringFileInfo\\%04x%04x\\" TEXT(NIMV_SUPPORT),\r
+ languages[i].language,\r
+ languages[i].codepage);\r
+\r
+ if (!VerQueryValue(m->version_info,\r
+ resname, (LPVOID *) &r, &cb)) {\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
+ _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING,\r
+ _cstr(TEXT(NIMV_SUPPORT)));\r
+ goto _cleanup;\r
+ }\r
+\r
+ if (cb > KMM_MAXCB_SUPPORT ||\r
+ FAILED(StringCbLength(r, KMM_MAXCB_SUPPORT, &cb))) {\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
+ _report_mr1(KHERR_WARNING, MSG_RMI_RES_TOO_LONG,\r
+ _cstr(TEXT(NIMV_SUPPORT)));\r
+ goto _cleanup;\r
+ }\r
+\r
+ cb += sizeof(wchar_t);\r
+\r
+ m->support = PMALLOC(cb);\r
+#ifdef DEBUG\r
+ assert(m->support);\r
+#endif\r
+ StringCbCopy(m->support, cb, r);\r
+\r
+ /* the vendor/copyright */\r
+ if (m->vendor) {\r
+ PFREE(m->vendor);\r
+ m->vendor = NULL;\r
+ }\r
+\r
+ StringCbPrintf(resname, sizeof(resname),\r
+ L"\\StringFileInfo\\%04x%04x\\LegalCopyright",\r
+ languages[i].language,\r
+ languages[i].codepage);\r
+\r
+ if (!VerQueryValue(m->version_info,\r
+ resname, (LPVOID *) &r, &cb)) {\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
+ _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING, \r
+ _cstr(L"LegalCopyright"));\r
+ goto _cleanup;\r
+ }\r
+\r
+ if (cb > KMM_MAXCB_SUPPORT ||\r
+ FAILED(StringCbLength(r, KMM_MAXCB_SUPPORT, &cb))) {\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
+ _report_mr1(KHERR_WARNING, MSG_RMI_RES_TOO_LONG,\r
+ _cstr(L"LegalCopyright"));\r
+ goto _cleanup;\r
+ }\r
+\r
+ cb += sizeof(wchar_t);\r
+\r
+ m->vendor = PMALLOC(cb);\r
+#ifdef DEBUG\r
+ assert(m->vendor);\r
+#endif\r
+ StringCbCopy(m->vendor, cb, r);\r
+\r
+ if (!VerQueryValue(m->version_info,\r
+ L"\\",\r
+ (LPVOID *) &vff,\r
+ &cb) ||\r
+ cb != sizeof(*vff)) {\r
+\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
+ _report_mr1(KHERR_WARNING, MSG_RMI_RES_MISSING, \r
+ _cstr(L"Fixed Version Info"));\r
+ goto _cleanup;\r
+ }\r
+\r
+ m->file_version.major = HIWORD(vff->dwFileVersionMS);\r
+ m->file_version.minor = LOWORD(vff->dwFileVersionMS);\r
+ m->file_version.patch = HIWORD(vff->dwFileVersionLS);\r
+ m->file_version.aux = LOWORD(vff->dwFileVersionLS);\r
+\r
+ m->prod_version.major = HIWORD(vff->dwProductVersionMS);\r
+ m->prod_version.minor = LOWORD(vff->dwProductVersionMS);\r
+ m->prod_version.patch = HIWORD(vff->dwProductVersionLS);\r
+ m->prod_version.aux = LOWORD(vff->dwProductVersionLS);\r
+\r
+ rv = KHM_ERROR_SUCCESS;\r
+\r
+ _cleanup:\r
+ if (KHM_FAILED(rv)) {\r
+ if (m->version_info) {\r
+ PFREE(m->version_info);\r
+ m->version_info = NULL;\r
+ }\r
+ }\r
+\r
+ return rv;\r
+}\r
+\r
KHMEXP khm_int32 KHMAPI kmm_load_module(wchar_t * modname, \r
khm_int32 flags, \r
kmm_module * result)\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
\r
if(FAILED(StringCbLength(modname, KMM_MAXCB_NAME, &cbsize)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
cbsize += sizeof(wchar_t);\r
\r
EnterCriticalSection(&cs_kmm);\r
- mi = kmm_find_module_i(modname);\r
+ mi = kmmint_find_module_i(modname);\r
\r
if(mi != NULL) {\r
kmm_hold_module(kmm_handle_from_module(mi));\r
if(mi) {\r
m = mi;\r
} else {\r
- m = kmm_get_module_i(modname);\r
+ m = kmmint_get_module_i(modname);\r
m->state = KMM_MODULE_STATE_PREINIT;\r
kmm_hold_module(kmm_handle_from_module(m));\r
}\r
return rv;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI kmm_get_module_state(kmm_module m)\r
+KHMEXP khm_int32 KHMAPI \r
+kmm_get_module_state(kmm_module m)\r
{\r
if(!kmm_is_module(m))\r
return KMM_MODULE_STATE_NONE;\r
\r
EnterCriticalSection(&cs_kmm);\r
if (!kmm_is_module(vm) || !info)\r
- rv = KHM_ERROR_INVALID_PARM;\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
else {\r
m = kmm_module_from_handle(vm);\r
\r
}\r
\r
\r
-KHMEXP khm_int32 KHMAPI kmm_unload_module(kmm_module module)\r
+KHMEXP khm_int32 KHMAPI \r
+kmm_unload_module(kmm_module module)\r
{\r
if(!kmm_is_module(module))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
kmm_hold_module(module);\r
kmq_post_message(KMSG_KMM, \r
return KHM_ERROR_SUCCESS;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI kmm_load_default_modules(void) {\r
+KHMEXP khm_int32 KHMAPI \r
+kmm_load_default_modules(void) {\r
khm_handle csm = NULL;\r
+ khm_handle cs_mod = NULL;\r
khm_int32 rv;\r
- wchar_t * ll = NULL;\r
- wchar_t *str;\r
wchar_t buf[KMM_MAXCCH_NAME];\r
khm_size s;\r
\r
if(KHM_FAILED(rv))\r
return rv;\r
\r
- _begin_task(KHERR_CF_TRANSITIVE);\r
_report_mr0(KHERR_NONE, MSG_LOAD_DEFAULT);\r
_describe();\r
\r
- rv = khc_read_multi_string(csm, KMM_VALNAME_LOADLIST, NULL, &s);\r
- if(rv != KHM_ERROR_TOO_LONG)\r
- goto _exit;\r
+ kmmint_add_to_module_queue();\r
+\r
+ while(KHM_SUCCEEDED(khc_enum_subspaces(csm, cs_mod, &cs_mod))) {\r
\r
- ll = malloc(s);\r
- rv = khc_read_multi_string(csm, KMM_VALNAME_LOADLIST, ll, &s);\r
- if(KHM_FAILED(rv))\r
- goto _exit;\r
+ s = sizeof(buf);\r
+ if (KHM_FAILED(khc_get_config_space_name(cs_mod, buf, &s)))\r
+ continue;\r
\r
- kmmint_add_to_module_queue();\r
+ /* check for schema subspace. This is not an actual module. */\r
+ if (!wcscmp(buf, L"_Schema"))\r
+ continue;\r
\r
- str = ll;\r
- while(str && *str) {\r
- if(SUCCEEDED(StringCbCopy(buf, sizeof(buf), str))) {\r
- kmm_load_module(buf, 0, NULL);\r
- }\r
- str = multi_string_next(str);\r
+ kmm_load_module(buf, 0, NULL);\r
}\r
\r
kmmint_remove_from_module_queue();\r
\r
-_exit:\r
- if(ll)\r
- free(ll);\r
if(csm)\r
khc_close_space(csm);\r
\r
- _end_task();\r
-\r
return rv;\r
}\r
\r
#ifdef _WIN32\r
-KHMEXP HMODULE KHMAPI kmm_get_hmodule(kmm_module m)\r
+KHMEXP HMODULE KHMAPI \r
+kmm_get_hmodule(kmm_module m)\r
{\r
if(!kmm_is_module(m))\r
return NULL;\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
*/\r
\r
kmm_plugin_i * \r
-kmm_get_plugin_i(wchar_t * name)\r
+kmmint_get_plugin_i(wchar_t * name)\r
{\r
kmm_plugin_i * p;\r
size_t cb;\r
p = (kmm_plugin_i *) hash_lookup(hash_plugins, (void *) name);\r
\r
if(p == NULL) {\r
- p = malloc(sizeof(kmm_plugin_i));\r
+ p = PMALLOC(sizeof(kmm_plugin_i));\r
ZeroMemory(p, sizeof(kmm_plugin_i));\r
p->magic = KMM_PLUGIN_MAGIC;\r
- p->p.name = malloc(cb);\r
+ p->p.name = PMALLOC(cb);\r
StringCbCopy(p->p.name, cb, name);\r
p->state = KMM_PLUGIN_STATE_NONE;\r
\r
hash_add(hash_plugins, (void *) p->p.name, (void *) p);\r
- kmm_list_plugin(p);\r
+ kmmint_list_plugin(p);\r
}\r
LeaveCriticalSection(&cs_kmm);\r
\r
}\r
\r
kmm_plugin_i * \r
-kmm_find_plugin_i(wchar_t * name)\r
+kmmint_find_plugin_i(wchar_t * name)\r
{\r
kmm_plugin_i * p;\r
size_t cb;\r
\r
/* the plugin must be delisted before calling this */\r
void \r
-kmm_list_plugin(kmm_plugin_i * p)\r
+kmmint_list_plugin(kmm_plugin_i * p)\r
{\r
EnterCriticalSection(&cs_kmm);\r
if((p->flags & KMM_PLUGIN_FLAG_IN_MODLIST) ||\r
}\r
\r
void \r
-kmm_delist_plugin(kmm_plugin_i * p)\r
+kmmint_delist_plugin(kmm_plugin_i * p)\r
{\r
EnterCriticalSection(&cs_kmm);\r
if(p->flags & KMM_PLUGIN_FLAG_IN_LIST) {\r
kmm_plugin_i * pi;\r
\r
if(!kmm_is_plugin(p))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_kmm);\r
pi = kmm_plugin_from_handle(p);\r
\r
/* called with cs_kmm held */\r
void \r
-kmm_free_plugin(kmm_plugin_i * pi)\r
+kmmint_free_plugin(kmm_plugin_i * pi)\r
{\r
int i;\r
pi->magic = 0;\r
\r
hash_del(hash_plugins, (void *) pi->p.name);\r
\r
- kmm_delist_plugin(pi);\r
+ kmmint_delist_plugin(pi);\r
\r
for(i=0; i<pi->n_dependants; i++) {\r
kmm_release_plugin(kmm_handle_from_plugin(pi->dependants[i]));\r
pi->p.module = NULL;\r
\r
if(pi->p.name)\r
- free(pi->p.name);\r
+ PFREE(pi->p.name);\r
pi->p.name = NULL;\r
\r
if(pi->p.description)\r
- free(pi->p.description);\r
+ PFREE(pi->p.description);\r
pi->p.description = NULL;\r
\r
if(pi->p.dependencies)\r
- free(pi->p.dependencies);\r
+ PFREE(pi->p.dependencies);\r
pi->p.dependencies = NULL;\r
\r
- free(pi);\r
+ PFREE(pi);\r
}\r
\r
KHMEXP khm_int32 KHMAPI\r
khm_handle csp_plugin;\r
\r
if (!info)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_kmm);\r
if (!kmm_is_plugin(p)) {\r
- rv = KHM_ERROR_INVALID_PARM;\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
goto _cleanup;\r
}\r
\r
khm_int32 rv;\r
\r
if (!info || !info->h_plugin)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
rv = kmm_release_plugin(info->h_plugin);\r
\r
kmm_plugin_i * pi;\r
\r
if(!kmm_is_plugin(p))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_kmm);\r
pi = kmm_plugin_from_handle(p);\r
pi->refcount--;\r
if(pi->refcount == 0) {\r
- kmm_free_plugin(pi);\r
+ kmmint_free_plugin(pi);\r
}\r
LeaveCriticalSection(&cs_kmm);\r
\r
return KHM_ERROR_INVALID_OPERATION;\r
\r
if(!plugin || \r
- FAILED(StringCbLength(plugin->name, KMM_MAXCB_NAME - sizeof(wchar_t), &cb_name)) ||\r
- (plugin->description && \r
- FAILED(StringCbLength(plugin->description, KMM_MAXCB_DESC - sizeof(wchar_t), &cb_desc))) ||\r
- (plugin->dependencies && \r
- KHM_FAILED(multi_string_length_cb(plugin->dependencies, KMM_MAXCB_DEPS, &cb_dep)))\r
- )\r
- {\r
- return KHM_ERROR_INVALID_PARM;\r
+ FAILED(StringCbLength(plugin->name, KMM_MAXCB_NAME - sizeof(wchar_t), \r
+ &cb_name)) ||\r
+ (plugin->description && \r
+ FAILED(StringCbLength(plugin->description, \r
+ KMM_MAXCB_DESC - sizeof(wchar_t), \r
+ &cb_desc))) ||\r
+ (plugin->dependencies && \r
+ KHM_FAILED(multi_string_length_cb(plugin->dependencies, \r
+ KMM_MAXCB_DEPS, &cb_dep)))) {\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
cb_name += sizeof(wchar_t);\r
cb_desc += sizeof(wchar_t);\r
\r
- p = kmm_get_plugin_i(plugin->name);\r
+ p = kmmint_get_plugin_i(plugin->name);\r
\r
/* released below or in kmm_init_module() */\r
kmm_hold_plugin(kmm_handle_from_plugin(p));\r
p->p.type = plugin->type;\r
\r
if(plugin->description) {\r
- p->p.description = malloc(cb_desc);\r
+ p->p.description = PMALLOC(cb_desc);\r
StringCbCopy(p->p.description, cb_desc, plugin->description);\r
} else\r
p->p.description = NULL;\r
\r
if(plugin->dependencies) {\r
- p->p.dependencies = malloc(cb_dep);\r
+ p->p.dependencies = PMALLOC(cb_dep);\r
multi_string_copy_cb(p->p.dependencies, cb_dep, plugin->dependencies);\r
} else\r
p->p.dependencies = NULL;\r
\r
p->state = KMM_PLUGIN_STATE_REG;\r
\r
- kmm_delist_plugin(p);\r
+ kmmint_delist_plugin(p);\r
EnterCriticalSection(&cs_kmm);\r
LPUSH(&(m->plugins), p);\r
p->flags |= KMM_PLUGIN_FLAG_IN_MODLIST;\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
khm_int32 rv;\r
\r
if(!plugin || wcschr(plugin, L'/') || wcschr(plugin, L'\\'))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if(KHM_FAILED(kmm_get_plugins_config(flags, &csplugins)))\r
return KHM_ERROR_UNKNOWN;\r
khm_int32 rv;\r
\r
if(!module || wcschr(module, L'/') || wcschr(module, L'\\'))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if(KHM_FAILED(kmm_get_modules_config(flags, &csmodules)))\r
return KHM_ERROR_UNKNOWN;\r
config_flags &= ~KHM_FLAG_CREATE;\r
\r
if((plugin == NULL) ||\r
- (plugin->dependencies && \r
- KHM_FAILED(multi_string_length_cch(plugin->dependencies, KMM_MAXCCH_DEPS, &cch))) ||\r
- FAILED(StringCchLength(plugin->module, KMM_MAXCCH_NAME - 1, &cch)) ||\r
- (plugin->description && \r
- FAILED(StringCchLength(plugin->description, KMM_MAXCCH_DESC - 1, &cch))) ||\r
- FAILED(StringCchLength(plugin->name, KMM_MAXCCH_NAME - 1, &cch)))\r
+ (plugin->dependencies && \r
+ KHM_FAILED(multi_string_length_cch(plugin->dependencies, \r
+ KMM_MAXCCH_DEPS, &cch))) ||\r
+ FAILED(StringCchLength(plugin->module, KMM_MAXCCH_NAME, &cch)) ||\r
+ (plugin->description &&\r
+ FAILED(StringCchLength(plugin->description,\r
+ KMM_MAXCCH_DESC, &cch))) ||\r
+ FAILED(StringCchLength(plugin->name, KMM_MAXCCH_NAME, &cch)))\r
{\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
/* note that we are retaining the length of the plugin name in\r
rv = khc_write_string(csp_plugin, L"Description", plugin->description);\r
CKRV;\r
}\r
+\r
if(plugin->dependencies) {\r
- rv = khc_write_multi_string(csp_plugin, L"Dependencies", plugin->dependencies);\r
+ rv = khc_write_multi_string(csp_plugin, L"Dependencies", \r
+ plugin->dependencies);\r
CKRV;\r
}\r
+\r
rv = khc_write_int32(csp_plugin, L"Type", plugin->type);\r
CKRV;\r
rv = khc_write_int32(csp_plugin, L"Flags", plugin->flags);\r
cb += cch * sizeof(wchar_t);\r
scb = cb;\r
\r
- pl = malloc(cb);\r
+ pl = PMALLOC(cb);\r
\r
- rv = khc_read_multi_string(csp_module, L"PluginList", NULL, &cb);\r
+ rv = khc_read_multi_string(csp_module, L"PluginList", pl, &cb);\r
if(KHM_FAILED(rv)) {\r
if(pl)\r
- free(pl);\r
+ PFREE(pl);\r
goto _exit;\r
}\r
\r
rv = khc_write_multi_string(csp_module, L"PluginList", pl);\r
}\r
\r
- free(pl);\r
+ PFREE(pl);\r
CKRV;\r
}\r
\r
int i;\r
\r
if((module == NULL) ||\r
- FAILED(StringCchLength(module->name, KMM_MAXCCH_NAME - 1, &cch)) ||\r
+ FAILED(StringCchLength(module->name, KMM_MAXCCH_NAME, &cch)) ||\r
(module->description && \r
- FAILED(StringCchLength(module->description, KMM_MAXCCH_DESC - 1, &cch))) ||\r
+ FAILED(StringCchLength(module->description, \r
+ KMM_MAXCCH_DESC, &cch))) ||\r
FAILED(StringCchLength(module->path, MAX_PATH, &cch)) ||\r
- (module->n_plugins > 0 && module->plugin_reg_info == NULL))\r
- {\r
- return KHM_ERROR_INVALID_PARM;\r
+ (module->n_plugins > 0 && module->plugin_reg_info == NULL)) {\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
#define CKRV if(KHM_FAILED(rv)) goto _exit\r
\r
- rv = kmm_get_module_config(module->name, config_flags | KHM_FLAG_CREATE, &csp_module);\r
+ rv = kmm_get_module_config(module->name, config_flags | KHM_FLAG_CREATE, \r
+ &csp_module);\r
CKRV;\r
\r
- if(module->description) {\r
- rv = khc_write_string(csp_module, L"Description", module->description);\r
- CKRV;\r
- }\r
rv = khc_write_string(csp_module, L"ImagePath", module->path);\r
CKRV;\r
\r
is loaded for the first time */\r
\r
for(i=0; i<module->n_plugins; i++) {\r
- rv = kmm_register_plugin(module->plugin_reg_info + i, config_flags);\r
+ rv = kmm_register_plugin(&(module->plugin_reg_info[i]), config_flags);\r
CKRV;\r
}\r
\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
InterlockedIncrement(&startup_signal) == 1) {\r
\r
load_done = TRUE;\r
+\r
+ /* TODO: check for orphaned plugins */\r
+\r
kmq_post_message(KMSG_KMM, KMSG_KMM_I_DONE, 0, 0);\r
}\r
}\r
\r
p->tid_thread = GetCurrentThreadId();\r
\r
- rv = (p->p.msg_proc(KMSG_SYSTEM, KMSG_SYSTEM_INIT, 0, (void *) &(p->p)));\r
+ if (IsBadCodePtr(p->p.msg_proc)) {\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
+ } else {\r
+ rv = (p->p.msg_proc(KMSG_SYSTEM, KMSG_SYSTEM_INIT, \r
+ 0, (void *) &(p->p)));\r
+ }\r
\r
/* if it fails to initialize, we exit the plugin */\r
if(KHM_FAILED(rv)) {\r
- kmmint_remove_from_plugin_queue();\r
+ kmmint_remove_from_plugin_queue();\r
rv = 1;\r
goto _exit;\r
}\r
\r
/* subscribe to default message classes by plugin type */\r
- if(p->p.type & KHM_PITYPE_CRED) {\r
+ if(p->p.type == KHM_PITYPE_CRED) {\r
kmq_subscribe(KMSG_SYSTEM, p->p.msg_proc);\r
kmq_subscribe(KMSG_KCDB, p->p.msg_proc);\r
kmq_subscribe(KMSG_CRED, p->p.msg_proc);\r
- }\r
-\r
- if(p->p.flags & KHM_PIFLAG_IDENTITY_PROVIDER) {\r
+ } else if(p->p.type == KHM_PITYPE_IDENT) {\r
khm_handle h = NULL;\r
\r
+ kmq_subscribe(KMSG_SYSTEM, p->p.msg_proc);\r
+ kmq_subscribe(KMSG_KCDB, p->p.msg_proc);\r
+\r
kmq_create_subscription(p->p.msg_proc, &h);\r
kcdb_identity_set_provider(h);\r
/* kcdb deletes the subscription when it's done with it */\r
- }\r
-\r
- if(p->p.type == KHM_PITYPE_CONFIG) {\r
+ } else if(p->p.type == KHM_PITYPE_CONFIG) {\r
/*TODO: subscribe to configuration provider messages here */\r
}\r
\r
while(KHM_SUCCEEDED(kmq_dispatch(INFINITE)));\r
\r
/* unsubscribe from default message classes by plugin type */\r
- if(p->p.type & KHM_PITYPE_CRED) {\r
+ if(p->p.type == KHM_PITYPE_CRED) {\r
kmq_unsubscribe(KMSG_SYSTEM, p->p.msg_proc);\r
kmq_unsubscribe(KMSG_KCDB, p->p.msg_proc);\r
kmq_unsubscribe(KMSG_CRED, p->p.msg_proc);\r
- }\r
-\r
- if(p->p.flags & KHM_PIFLAG_IDENTITY_PROVIDER) {\r
+ } else if (p->p.type == KHM_PITYPE_IDENT) {\r
+ kmq_unsubscribe(KMSG_KCDB, p->p.msg_proc);\r
+ kmq_unsubscribe(KMSG_SYSTEM, p->p.msg_proc);\r
kcdb_identity_set_provider(NULL);\r
- }\r
-\r
- if(p->p.type == KHM_PITYPE_CONFIG) {\r
+ } else if(p->p.type == KHM_PITYPE_CONFIG) {\r
/*TODO: unsubscribe from configuration provider messages here */\r
}\r
\r
p->state = KMM_PLUGIN_STATE_EXITED;\r
\r
/* the following call will automatically release the plugin */\r
- kmq_post_message(KMSG_KMM, KMSG_KMM_I_REG, KMM_REG_EXIT_PLUGIN, (void *) p);\r
+ kmq_post_message(KMSG_KMM, KMSG_KMM_I_REG, \r
+ KMM_REG_EXIT_PLUGIN, (void *) p);\r
\r
TlsSetValue(tls_kmm, (LPVOID) 0);\r
\r
}\r
\r
if(KHM_FAILED(kmm_get_plugin_config(p->p.name, 0, &csp_plugin)) ||\r
- KHM_FAILED(khc_read_int32(csp_plugin, L"Flags", &t)))\r
- {\r
+ KHM_FAILED(khc_read_int32(csp_plugin, L"Flags", &t))) {\r
if(KHM_FAILED(kmm_register_plugin(&(p->p), 0))) {\r
_report_mr0(KHERR_ERROR, MSG_IP_NOT_REGISTERED);\r
\r
wchar_t * d;\r
khm_size sz = 0;\r
\r
- if(khc_read_multi_string(csp_plugin, L"Dependencies", NULL, &sz) != KHM_ERROR_TOO_LONG)\r
+ if(khc_read_multi_string(csp_plugin, L"Dependencies", \r
+ NULL, &sz) != KHM_ERROR_TOO_LONG)\r
break;\r
\r
- deps = malloc(sz);\r
- if(KHM_FAILED(khc_read_multi_string(csp_plugin, L"Dependencies", deps, &sz))) {\r
+ deps = PMALLOC(sz);\r
+ if(KHM_FAILED(khc_read_multi_string(csp_plugin, L"Dependencies", \r
+ deps, &sz))) {\r
if(deps)\r
- free(deps);\r
+ PFREE(deps);\r
break;\r
}\r
\r
kmm_plugin_i * pd;\r
int i;\r
\r
- pd = kmm_get_plugin_i(d);\r
+ pd = kmmint_get_plugin_i(d);\r
\r
if(pd->state == KMM_PLUGIN_STATE_NONE) {\r
/* the dependant was not previously known */\r
pd->state = KMM_PLUGIN_STATE_PLACEHOLDER;\r
}\r
\r
- for(i=0; i<pd->n_dependants; i++) {\r
+ for(i=0; i < pd->n_dependants; i++) {\r
if(pd->dependants[i] == p)\r
break;\r
}\r
RaiseException(1, EXCEPTION_NONCONTINUABLE, 0, NULL);\r
}\r
\r
- /* released in kmm_free_plugin() */\r
+ /* released in kmmint_free_plugin() */\r
kmm_hold_plugin(kmm_handle_from_plugin(p));\r
pd->dependants[pd->n_dependants] = p;\r
pd->n_dependants++;\r
p->state = KMM_PLUGIN_STATE_HOLD;\r
}\r
\r
- free(deps);\r
+ PFREE(deps);\r
\r
} while(FALSE);\r
LeaveCriticalSection(&cs_kmm);\r
\r
EnterCriticalSection(&cs_kmm);\r
p->module->plugin_count++;\r
- kmm_delist_plugin(p);\r
- kmm_list_plugin(p);\r
+ kmmint_delist_plugin(p);\r
+ kmmint_list_plugin(p);\r
LeaveCriticalSection(&cs_kmm);\r
\r
if(p->state == KMM_PLUGIN_STATE_HOLD) {\r
\r
kmmint_add_to_plugin_queue();\r
\r
- p->ht_thread = CreateThread(\r
- NULL,\r
- 0,\r
- kmm_plugin_broker,\r
- (LPVOID) p,\r
- CREATE_SUSPENDED,\r
- &dummy);\r
+ p->ht_thread = CreateThread(NULL,\r
+ 0,\r
+ kmm_plugin_broker,\r
+ (LPVOID) p,\r
+ CREATE_SUSPENDED,\r
+ &dummy);\r
\r
p->state = KMM_PLUGIN_STATE_INIT;\r
\r
goto _exit;\r
}\r
\r
- if(KHM_SUCCEEDED(khc_read_int32(csp_mod, L"Flags", &i))) {\r
- if(i & KMM_MODULE_FLAG_DISABLED) {\r
- _report_mr0(KHERR_ERROR, MSG_IM_DISABLED);\r
+ if(KHM_SUCCEEDED(khc_read_int32(csp_mod, L"Flags", &i)) &&\r
+ (i & KMM_MODULE_FLAG_DISABLED)) {\r
\r
- m->state = KMM_MODULE_STATE_FAIL_DISABLED;\r
- goto _exit;\r
- }\r
+ _report_mr0(KHERR_ERROR, MSG_IM_DISABLED);\r
+\r
+ m->state = KMM_MODULE_STATE_FAIL_DISABLED;\r
+ goto _exit;\r
}\r
\r
if(KHM_SUCCEEDED(khc_read_int32(csp_mod, L"FailureCount", &i))) {\r
khm_int64 tm;\r
khm_int64 ct;\r
+ khm_int32 last_reason = 0;\r
\r
/* reset the failure count if the failure count reset time\r
period has elapsed */\r
\r
}\r
\r
- if(i > max_fail_count) {\r
+ khc_read_int32(csp_mod, L"FailureReason", &last_reason);\r
+\r
+ /* did we exceed the max failure count? However, we ignore\r
+ the max failure count if the reason why it didn't load the\r
+ last time was because the module wasn't found. */\r
+ if(i > max_fail_count && \r
+ last_reason != KMM_MODULE_STATE_FAIL_NOT_FOUND) {\r
/* failed too many times */\r
_report_mr0(KHERR_ERROR, MSG_IM_MAX_FAIL);\r
\r
}\r
}\r
\r
- if(khc_read_string(csp_mod, L"ImagePath", NULL, &sz) == KHM_ERROR_TOO_LONG) {\r
+ if(khc_read_string(csp_mod, L"ImagePath", NULL, &sz) == \r
+ KHM_ERROR_TOO_LONG) {\r
if(m->path)\r
- free(m->path);\r
- m->path = malloc(sz);\r
+ PFREE(m->path);\r
+ m->path = PMALLOC(sz);\r
khc_read_string(csp_mod, L"ImagePath", m->path, &sz);\r
} else {\r
_report_mr0(KHERR_ERROR, MSG_IM_NOT_REGISTERED);\r
goto _exit;\r
}\r
\r
- if (khc_read_string(csp_mod, L"Vendor", NULL, &sz) == KHM_ERROR_TOO_LONG) {\r
- if (m->vendor)\r
- free(m->vendor);\r
- m->vendor = malloc(sz);\r
- khc_read_string(csp_mod, L"Vendor", m->vendor, &sz);\r
+ rv = kmmint_read_module_info(m);\r
+\r
+ if (KHM_FAILED(rv)) {\r
+ if (rv == KHM_ERROR_INCOMPATIBLE) {\r
+ _report_mr0(KHERR_ERROR, MSG_IM_INCOMPATIBLE);\r
+\r
+ m->state = KMM_MODULE_STATE_FAIL_INCOMPAT;\r
+ } else if (rv == KHM_ERROR_NOT_FOUND) {\r
+ _report_mr1(KHERR_ERROR, MSG_IM_NOT_FOUND, _dupstr(m->path));\r
+\r
+ m->state = KMM_MODULE_STATE_FAIL_NOT_FOUND;\r
+ } else {\r
+ _report_mr0(KHERR_ERROR, MSG_IM_INVALID_MODULE);\r
+\r
+ m->state = KMM_MODULE_STATE_FAIL_INV_MODULE;\r
+ }\r
+ goto _exit;\r
}\r
\r
/* check again */\r
goto _exit;\r
}\r
\r
+ /* from this point on, we must record any failure codes */\r
+ record_failure = TRUE;\r
+\r
hm = LoadLibrary(m->path);\r
if(!hm) {\r
m->h_module = NULL;\r
m->state = KMM_MODULE_STATE_FAIL_NOT_FOUND;\r
- record_failure = TRUE;\r
\r
_report_mr1(KHERR_ERROR, MSG_IM_NOT_FOUND, _dupstr(m->path));\r
\r
exit_module */\r
release_module = FALSE;\r
exit_module = TRUE;\r
- record_failure = TRUE;\r
\r
m->flags |= KMM_MODULE_FLAG_LOADED;\r
m->h_module = hm;\r
\r
- /*TODO: check signatures */\r
+ /* TODO: check signatures */\r
\r
p_init_module = (init_module_t) GetProcAddress(hm, EXP_INIT_MODULE);\r
\r
\r
m->state = KMM_MODULE_STATE_INIT;\r
\r
-\r
/* call init_module() */\r
rv = (*p_init_module)(kmm_handle_from_module(m));\r
\r
\r
ResetEvent(evt_exit);\r
\r
-_exit:\r
+ _exit:\r
if(csp_mod) {\r
if(record_failure) {\r
khm_int64 ct;\r
GetSystemTimeAsFileTime((LPFILETIME) &ct);\r
khc_write_int64(csp_mod, L"FailureTime", ct);\r
}\r
+\r
+ khc_write_int32(csp_mod, L"FailureReason", m->state);\r
}\r
khc_close_space(csp_mod);\r
}\r
+\r
if(csp_mods)\r
khc_close_space(csp_mods);\r
\r
_report_mr2(KHERR_INFO, MSG_IM_MOD_STATE, \r
_dupstr(m->name), _int32(m->state));\r
\r
- if(release_module)\r
- kmm_release_module(kmm_handle_from_module(m));\r
-\r
kmmint_remove_from_module_queue();\r
\r
/* if something went wrong after init_module was called on the\r
if(exit_module)\r
kmm_exit_module(m);\r
\r
+ if(release_module)\r
+ kmm_release_module(kmm_handle_from_module(m));\r
+\r
+ if (kherr_is_error()) {\r
+ kherr_context * c;\r
+ kherr_event * err_e = NULL;\r
+ kherr_event * warn_e = NULL;\r
+ kherr_event * e;\r
+\r
+ c = kherr_peek_context();\r
+ err_e = kherr_get_err_event(c);\r
+ for(e = kherr_get_first_event(c);\r
+ e;\r
+ e = kherr_get_next_event(e)) {\r
+ if (e != err_e &&\r
+ e->severity == KHERR_WARNING) {\r
+ warn_e = e;\r
+ break;\r
+ }\r
+ }\r
+\r
+ kherr_evaluate_event(err_e);\r
+ if (warn_e)\r
+ kherr_evaluate_event(warn_e);\r
+\r
+ kherr_clear_error();\r
+\r
+ e = kherr_report(KHERR_ERROR,\r
+ (wchar_t *) MSG_IMERR_TITLE,\r
+ KHERR_FACILITY,\r
+ NULL,\r
+ err_e->long_desc,\r
+ ((warn_e)? (wchar_t *)MSG_IMERR_SUGGEST: NULL),\r
+ KHERR_FACILITY_ID,\r
+ KHERR_SUGGEST_NONE,\r
+ _cstr(m->name),\r
+ ((warn_e)? _cstr(warn_e->long_desc):0),\r
+ 0,0,\r
+ KHERR_RF_MSG_SHORT_DESC |\r
+ ((warn_e)? KHERR_RF_MSG_SUGGEST: 0),\r
+ KHERR_HMODULE);\r
+\r
+ kherr_evaluate_event(e);\r
+\r
+ kherr_release_context(c);\r
+ }\r
+\r
_end_task();\r
}\r
\r
while(p) {\r
if(p->module == m) {\r
kmm_hold_plugin(kmm_handle_from_plugin(p));\r
- kmq_post_message(KMSG_KMM, KMSG_KMM_I_REG, KMM_REG_EXIT_PLUGIN, (void *) p);\r
+ kmq_post_message(KMSG_KMM, KMSG_KMM_I_REG, \r
+ KMM_REG_EXIT_PLUGIN, (void *) p);\r
np++;\r
}\r
\r
Description,KC_STRING,<Description>,Description of the plugin\r
Dependencies,KC_STRING,<Dependencies>,Multi string of plugin names of plugins that this plugin depends on\r
Type,KC_INT32,0,The type of the plugin\r
- Flags,KC_INT32,0,Flags. Currently unused\r
+ Flags,KC_INT32,0,Flags\r
FailureCount,KC_INT32,0,Number of failed loads\r
FailureTime,KC_INT64,0,FILETIME of first failure\r
FailureReason,KC_INT32,0,Reason for first failure. One of the plugin status values.\r
ModuleMaxFailureCount,KC_INT32,3,Maximum number of failure counts before module is disabled\r
ModuleFailureCountResetTime,KC_INT64,72000,Time after first failure at which the failure count is reset\r
_Schema,KC_SPACE,0,Module schema\r
- ImagePath,KC_STRING,<Path to the library binary>,Path to the DLL\r
- Description,KC_STRING,<Description>,Description of the module\r
- Vendor,KC_STRING,<Vendor string>,Vendor or copyright string\r
- Flags,KC_INT32,0,Flags. Currently unused.\r
+ ImagePath,KC_STRING,<Path to the library binary>,Path to the DLL (including DLL name)\r
+ Flags,KC_INT32,0,Flags\r
FailureCount,KC_INT32,0,Number of failed loads\r
FailureTime,KC_INT64,0,FILETIME of first failure\r
- FailureReason,KC_INT32,0,Reason for first failure. One of the module status values.\r
- FileVersion,KC_INT64,0,khm_version of file\r
- ProductVersion,KC_INT64,0,khm_version of product\r
+ FailureReason,KC_INT32,0,Reason for last failure. One of the module status values.\r
PluginList,KC_STRING,<plugins>,List of plugins implemented in the module\r
_Schema,KC_ENDSPACE,0,\r
OpenAFS,KC_SPACE,0,OpenAFS Module\r
ImagePath,KC_STRING,afscred.dll,\r
PluginList,KC_STRING,AfsCred,\r
- Vendor,KC_STRING,OpenAFS.org,\r
OpenAFS,KC_ENDSPACE,0,\r
MITKrb5,KC_SPACE,0,MIT Kerberos V\r
ImagePath,KC_STRING,krb5cred.dll,\r
PluginList,KC_STRING,Krb5Cred,\r
- Vendor,KC_STRING,Massachusetts Institute of Technology,\r
MITKrb5,KC_ENDSPACE,0,\r
MITKrb4,KC_SPACE,0,MIT Kerberos IV\r
ImagePath,KC_STRING,krb4cred.dll,\r
PluginList,KC_STRING,Krb4Cred,\r
- Vendor,KC_STRING,Massachusetts Institute of Technology,\r
MITKrb4,KC_ENDSPACE,0,\r
Modules,KC_ENDSPACE,0,\r
PluginManager,KC_ENDSPACE,0,\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
#define __KHIMAIRA_KMMINTERNAL_H\r
\r
#include<windows.h>\r
+#include<shlwapi.h>\r
#include<strsafe.h>\r
\r
#define KHERR_FACILITY kmm_facility\r
#include<kcreddb.h>\r
#include<kmm_msgs.h>\r
\r
-\r
struct kmm_plugin_i_t; /* forward dcl */\r
\r
typedef struct kmm_module_i_t {\r
\r
wchar_t * name;\r
wchar_t * path;\r
-\r
+ wchar_t * description;\r
wchar_t * vendor;\r
+ wchar_t * support;\r
+\r
+ khm_version file_version;\r
+ khm_version prod_version;\r
\r
HMODULE h_module;\r
\r
#define kmm_module_from_handle(m) ((kmm_module_i *) m)\r
#define kmm_handle_from_module(m) ((kmm_module) m)\r
\r
-/* the resources have been loaded */\r
-#define KMM_MODULE_FLAG_RES_LOADED 8\r
-\r
-/* the signature has been verified */\r
-#define KMM_MODULE_FLAG_SIG 16\r
-\r
/* LoadLibrary succeeded for module */\r
#define KMM_MODULE_FLAG_LOADED 1\r
\r
/* init_module entry called */\r
#define KMM_MODULE_FLAG_INITP 2\r
\r
+/* the resources have been loaded */\r
+#define KMM_MODULE_FLAG_RES_LOADED 8\r
+\r
+/* the signature has been verified */\r
+#define KMM_MODULE_FLAG_SIG 16\r
+\r
/* the module is disabled by the user\r
(option specifed in configuration) */\r
#define KMM_MODULE_FLAG_DISABLED 1024\r
\r
+\r
typedef struct kmm_plugin_i_t {\r
kmm_plugin_reg p;\r
\r
void kmm_exit_module(kmm_module_i * m);\r
\r
/* Modules */\r
-kmm_module_i * kmm_get_module_i(wchar_t * name);\r
-kmm_module_i * kmm_find_module_i(wchar_t * name);\r
-void kmm_free_module(kmm_module_i * m);\r
+kmm_module_i * \r
+kmmint_get_module_i(wchar_t * name);\r
+\r
+kmm_module_i * \r
+kmmint_find_module_i(wchar_t * name);\r
+\r
+void \r
+kmmint_free_module(kmm_module_i * m);\r
+\r
+khm_int32\r
+kmmint_read_module_info(kmm_module_i * m);\r
\r
/* Plugins */\r
-kmm_plugin_i * kmm_get_plugin_i(wchar_t * name);\r
-kmm_plugin_i * kmm_find_plugin_i(wchar_t * name);\r
-void kmm_free_plugin(kmm_plugin_i * pi);\r
-void kmm_list_plugin(kmm_plugin_i * p);\r
-void kmm_delist_plugin(kmm_plugin_i * p);\r
+kmm_plugin_i * \r
+kmmint_get_plugin_i(wchar_t * name);\r
+\r
+kmm_plugin_i * \r
+kmmint_find_plugin_i(wchar_t * name);\r
+\r
+void \r
+kmmint_free_plugin(kmm_plugin_i * pi);\r
+\r
+void \r
+kmmint_list_plugin(kmm_plugin_i * p);\r
+\r
+void \r
+kmmint_delist_plugin(kmm_plugin_i * p);\r
\r
-khm_boolean kmm_load_locale_lib(kmm_module_i * m, kmm_module_locale * l);\r
+khm_boolean \r
+kmmint_load_locale_lib(kmm_module_i * m, kmm_module_locale * l);\r
\r
#define KMM_CSNAME_ROOT L"PluginManager"\r
#define KMM_CSNAME_PLUGINS L"Plugins"\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
kmm_plugin_i * pn;\r
\r
pn = LNEXT(p);\r
- /* plugins that were never resolved should be kicked off\r
- the list. Flipping the refcount will do that if no\r
- other references exist for the plugin */\r
+ /* plugins that were never resolved should be kicked off the\r
+ list. Flipping the refcount will do that if no other\r
+ references exist for the plugin. The plugins that were\r
+ waiting for unresolved dependencies will automatically get\r
+ freed when the placeholders and other plugins get freed. */\r
if(p->state == KMM_PLUGIN_STATE_PLACEHOLDER) {\r
kmm_hold_plugin(kmm_handle_from_plugin(p));\r
kmm_release_plugin(kmm_handle_from_plugin(p));\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
Module has failed too many times\r
.\r
\r
+MessageId=\r
+SymbolicName=MSG_IM_INVALID_MODULE\r
+Language=English\r
+The DLL containing the module was not of the correct format.\r
+.\r
+\r
+MessageId=\r
+SymbolicName=MSG_IM_INCOMPATIBLE\r
+Language=English \r
+The DLL containing the module was not compatible with this version of NetIDMgr.\r
+.\r
+\r
Messageid=\r
SymbolicName=MSG_IM_NOT_FOUND\r
Language=English\r
Module [%1] is in state [%2!d!]\r
.\r
\r
+MessageId=\r
+SymbolicName=MSG_IMERR_TITLE\r
+Language=English\r
+Failed to load module %1!s!\r
+.\r
+\r
+MessageId=\r
+SymbolicName=MSG_IMERR_SUGGEST\r
+Language=English\r
+The following information may help resolve this issue:\r
+\r
+%2!s!\r
+.\r
+\r
MessageId=\r
SymbolicName=MSG_IP_TASK_DESC\r
Language=English\r
Language=English\r
The plugin [%1] is in error state [%2!d!]. Exiting plugin.\r
.\r
+\r
+MessageId=\r
+SymbolicName=MSG_RMI_NOT_FOUND\r
+Language=English\r
+Can't get file version information for path [%1!s!]\r
+.\r
+\r
+MessageId=\r
+SymbolicName=MSG_RMI_NO_TRANS\r
+Language=English\r
+Can't get version resource tranlations list for path [%1!s!]\r
+.\r
+\r
+MessageId=\r
+SymbolicName=MSG_RMI_NO_LOCAL\r
+Language=English\r
+The list of version translations were empty or did not contain a resource for the current user or system locale.\r
+.\r
+\r
+MessageId=\r
+SymbolicName=MSG_RMI_RES_MISSING\r
+Language=English\r
+Required resource %1!s! missing\r
+.\r
+\r
+MessageId=\r
+SymbolicName=MSG_RMI_MOD_MISMATCH\r
+Language=English\r
+The module name specified in the resource is [%1!s!] while the module name as registered is [%2!s!]\r
+.\r
+\r
+MessageId=\r
+SymbolicName=MSG_RMI_RES_TOO_LONG\r
+Language=English\r
+The resource %1!s! is malformed or too long\r
+.\r
+\r
+MessageId=\r
+SymbolicName=MSG_RMI_API_MISMATCH\r
+Language=English\r
+The module was compile for API version %1!d!. However the current API version is %2!d!.\r
+.\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
\r
LPOP(&kmq_msg_ref_free, &r);\r
if(!r) {\r
- r = malloc(sizeof(kmq_message_ref));\r
+ r = PMALLOC(sizeof(kmq_message_ref));\r
}\r
ZeroMemory(r, sizeof(kmq_message_ref));\r
\r
\r
if(try_send && q->thread == GetCurrentThreadId()) {\r
khm_int32 rv;\r
- /* we are sending a message from this thread to this thread.\r
- just call the recipient directly, bypassing the message queue. */\r
+ /* we are sending a message from this thread to this\r
+ thread. just call the recipient directly, bypassing\r
+ the message queue. */\r
m->refcount++;\r
m->nSent++;\r
- rv = s->recipient.cb(m->type, m->subtype, m->uparam, m->vparam);\r
+ if (IsBadCodePtr(s->recipient.cb)) {\r
+ rv = KHM_ERROR_INVALID_OPERATION;\r
+ } else {\r
+ if (IsBadCodePtr(s->recipient.cb))\r
+ rv = KHM_ERROR_INVALID_OPERATION;\r
+ else\r
+ rv = s->recipient.cb(m->type, m->subtype, \r
+ m->uparam, m->vparam);\r
+ }\r
m->refcount--;\r
if(KHM_SUCCEEDED(rv))\r
m->nCompleted++;\r
else if(s->rcpt_type == KMQ_RCPTTYPE_HWND) {\r
m->refcount++;\r
\r
- if(try_send && GetCurrentThreadId() == GetWindowThreadProcessId(s->recipient.hwnd, NULL)) {\r
- /* kmqint_post does not know whether there are any other messages\r
- waiting to be posted at this point. Hence, simply sending the\r
- message is not the right thing to do as the recipient may\r
- incorrectly assume that the message has completed when\r
- (m->nCompleted + m->nFailed == m->nSent). Therefore, we only\r
- increment nSent after the message is sent. */\r
- SendMessage(s->recipient.hwnd, KMQ_WM_DISPATCH, m->type, (LPARAM) m);\r
+ if(try_send && \r
+ GetCurrentThreadId() == GetWindowThreadProcessId(s->recipient.hwnd, \r
+ NULL)) {\r
+ /* kmqint_post does not know whether there are any other\r
+ messages waiting to be posted at this point. Hence,\r
+ simply sending the message is not the right thing to do\r
+ as the recipient may incorrectly assume that the\r
+ message has completed when (m->nCompleted + m->nFailed\r
+ == m->nSent). Therefore, we only increment nSent after\r
+ the message is sent. */\r
+ SendMessage(s->recipient.hwnd, KMQ_WM_DISPATCH, \r
+ m->type, (LPARAM) m);\r
m->nSent++;\r
} else {\r
m->nSent++;\r
- PostMessage(s->recipient.hwnd, KMQ_WM_DISPATCH, m->type, (LPARAM) m);\r
+ PostMessage(s->recipient.hwnd, KMQ_WM_DISPATCH, \r
+ m->type, (LPARAM) m);\r
}\r
- } \r
+ }\r
#endif\r
\r
else {\r
- /* This could either be because we were passed in an invalid subscription\r
- or because we lost a race to a thread that deleted an ad-hoc\r
- subscription. */\r
+ /* This could either be because we were passed in an invalid\r
+ subscription or because we lost a race to a thread that\r
+ deleted an ad-hoc subscription. */\r
#ifdef DEBUG\r
assert(FALSE);\r
#else\r
KHMEXP khm_int32 KHMAPI kmq_subscribe_hwnd(khm_int32 type, HWND hwnd) {\r
kmq_msg_subscription * s;\r
\r
- s = malloc(sizeof(kmq_msg_subscription));\r
+ s = PMALLOC(sizeof(kmq_msg_subscription));\r
LINIT(s);\r
s->queue = NULL;\r
s->rcpt_type = KMQ_RCPTTYPE_HWND;\r
KHMEXP khm_int32 KHMAPI kmq_subscribe(khm_int32 type, kmq_callback_t cb) {\r
kmq_msg_subscription * s;\r
\r
- s = malloc(sizeof(kmq_msg_subscription));\r
+ s = PMALLOC(sizeof(kmq_msg_subscription));\r
LINIT(s);\r
s->queue = kmqint_get_thread_queue();\r
s->rcpt_type = KMQ_RCPTTYPE_CB;\r
/*! \internal\r
\note Obtains ::cs_kmq_global\r
*/\r
-KHMEXP khm_int32 KHMAPI kmq_create_subscription(kmq_callback_t cb, khm_handle * result)\r
+KHMEXP khm_int32 KHMAPI kmq_create_subscription(kmq_callback_t cb, \r
+ khm_handle * result)\r
{\r
kmq_msg_subscription * s;\r
\r
- s = malloc(sizeof(kmq_msg_subscription));\r
+ s = PMALLOC(sizeof(kmq_msg_subscription));\r
LINIT(s);\r
s->queue = kmqint_get_thread_queue();\r
s->rcpt_type = KMQ_RCPTTYPE_CB;\r
LDELETE(&kmq_adhoc_subs, s);\r
LeaveCriticalSection(&cs_kmq_global);\r
\r
- free(s);\r
+ PFREE(s);\r
\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
s = kmqint_msg_type_del_sub_hwnd(type, hwnd);\r
if(s)\r
- free(s);\r
+ PFREE(s);\r
return (s)?KHM_ERROR_SUCCESS:KHM_ERROR_NOT_FOUND;\r
}\r
\r
\r
s = kmqint_msg_type_del_sub_cb(type,cb);\r
if(s)\r
- free(s);\r
+ PFREE(s);\r
\r
return (s)?KHM_ERROR_SUCCESS:KHM_ERROR_NOT_FOUND;\r
}\r
}\r
\r
/*! \internal\r
+\r
\note Obtains ::cs_kmq_global, kmq_queue::cs, ::cs_kmq_msg_ref, ::cs_kmq_msg, \r
*/\r
KHMEXP khm_int32 KHMAPI kmq_dispatch(kmq_timer timeout) {\r
\r
q = kmqint_get_thread_queue();\r
\r
+ assert(q->wait_o);\r
+\r
hr = WaitForSingleObject(q->wait_o, timeout);\r
if(hr == WAIT_OBJECT_0) {\r
/* signalled */\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
if(!q) {\r
EnterCriticalSection(&cs_kmq_global);\r
\r
- q = malloc(sizeof(kmq_queue));\r
+ q = PMALLOC(sizeof(kmq_queue));\r
\r
InitializeCriticalSection(&q->cs);\r
q->thread = GetCurrentThreadId();\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
\r
\see kmq_find_type() and kmq_unregister_type()\r
\r
- \retval KHM_ERROR_INVALID_PARM The \a name parameter was invalid.\r
+ \retval KHM_ERROR_INVALID_PARAM The \a name parameter was invalid.\r
\retval KHM_ERROR_EXISTS A message type with that name already exists.\r
\retval KHM_ERROR_NO_RESOURCES Can't register any more message types.\r
\retval KHM_ERROR_SUCCESS The operation succeeded.\r
\r
\retval KHM_ERROR_SUCCESS The call completed\r
\retval KHM_ERROR_TIMEOUT The timeout period expired\r
- \retval KHM_ERROR_INVALID_PARM One of the parameters were invalid.\r
+ \retval KHM_ERROR_INVALID_PARAM One of the parameters were invalid.\r
*/\r
KHMEXP khm_int32 KHMAPI kmq_wait(kmq_call call, kmq_timer timeout);\r
\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
#include<kherror.h>\r
#include<khmsgtypes.h>\r
#include<kconfig.h>\r
+#include<utils.h>\r
#include<strsafe.h>\r
\r
#define KMQ_CONF_SPACE_NAME L"KMQ"\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
EnterCriticalSection(&cs_kmq_types);\r
if(!msg_types[t]) {\r
kmq_msg_type * mt;\r
- mt = malloc(sizeof(kmq_msg_type));\r
+ mt = PMALLOC(sizeof(kmq_msg_type));\r
ZeroMemory(mt, sizeof(kmq_msg_type));\r
mt->id = t;\r
LINIT(mt);\r
size_t sz;\r
\r
if(FAILED(StringCbLength(name, KMQ_MAXCB_TYPE_NAME, &sz)) ||\r
- sz == 0)\r
- return KHM_ERROR_INVALID_PARM;\r
+ sz == 0)\r
+ return KHM_ERROR_INVALID_PARAM;\r
sz += sizeof(wchar_t);\r
\r
EnterCriticalSection(&cs_kmq_types);\r
if(msg_types[i] == NULL) {\r
if(first_free == 0)\r
first_free = i;\r
+ /* continue searching since we might find that this type\r
+ is already registered. */\r
} else {\r
if(msg_types[i]->name != NULL && \r
- !wcscmp(msg_types[i]->name, name))\r
+ !wcscmp(msg_types[i]->name, name)) {\r
+\r
registered = TRUE;\r
+ if (new_id)\r
+ *new_id = i;\r
+ break;\r
+ }\r
}\r
}\r
\r
rv = KHM_ERROR_NO_RESOURCES;\r
} else {\r
kmqint_msg_type_create(first_free);\r
- msg_types[first_free]->name = malloc(sz);\r
+ msg_types[first_free]->name = PMALLOC(sz);\r
StringCbCopy(msg_types[first_free]->name, sz, name);\r
\r
if(new_id != NULL)\r
}\r
\r
return KHM_ERROR_NOT_FOUND;\r
-\r
}\r
\r
KHMEXP khm_int32 KHMAPI kmq_unregister_type(khm_int32 id)\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
\r
if(id < KMSGBASE_USER || id > KMQ_MSG_TYPE_MAX)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_kmq_types);\r
if(msg_types[id] != NULL) {\r
LeaveCriticalSection(&cs_kmq_types);\r
}\r
\r
+\r
/*! \internal\r
\brief Deletes a window subscription from a message type\r
\note Obtains ::cs_kmq_types\r
s = msg_types[t]->subs;\r
while(s) {\r
kmq_msg_subscription * n = LNEXT(s);\r
- if(s->rcpt_type == KMQ_RCPTTYPE_CB && s->recipient.cb == cb && s->queue == q) {\r
+ if(s->rcpt_type == KMQ_RCPTTYPE_CB && \r
+ s->recipient.cb == cb && \r
+ s->queue == q) {\r
/*TODO: do more here? */\r
LDELETE(&msg_types[t]->subs, s);\r
break;\r
*/\r
khm_int32 kmqint_msg_publish(kmq_message * m, khm_boolean try_send) {\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
+\r
if(msg_types[m->type]) {\r
kmq_msg_type *t;\r
kmq_msg_subscription * s;\r
khm_int32 kmqint_msg_type_set_handler(khm_int32 type, kmq_msg_completion_handler handler) {\r
\r
if (type == KMSG_SYSTEM)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if(!msg_types[type])\r
kmqint_msg_type_create(type);\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*! \internal\r
\brief Get a message object\r
\note called with ::cs_kmq_msg held */\r
-kmq_message * kmqint_get_message(void) {\r
+kmq_message * \r
+kmqint_get_message(void) {\r
kmq_message * m;\r
\r
LPOP(&msg_free,&m);\r
if(!m) {\r
/* allocate one */\r
- m = malloc(sizeof(kmq_message));\r
+ m = PMALLOC(sizeof(kmq_message));\r
}\r
ZeroMemory((void*)m, sizeof(kmq_message));\r
\r
\brief Frees a message object\r
\note called with ::cs_kmq_msg held\r
*/\r
-void kmqint_put_message(kmq_message *m) {\r
+void \r
+kmqint_put_message(kmq_message *m) {\r
int queued;\r
/* we can only free a message if the refcount is zero.\r
Otherwise we have to wait until the call is freed. */\r
/*! \internal\r
\note Obtains ::cs_kmq_msg, ::cs_kmq_types, ::cs_kmq_msg_ref, kmq_queue::cs\r
*/\r
-KHMEXP khm_int32 KHMAPI kmq_send_message(khm_int32 type, khm_int32 subtype, khm_ui_4 uparam, void * blob) {\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_send_message(khm_int32 type, khm_int32 subtype, \r
+ khm_ui_4 uparam, void * blob) {\r
kmq_call c;\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
\r
/*! \internal\r
\note Obtains ::cs_kmq_msg, ::cs_kmq_types, ::cs_kmq_msg_ref, kmq_queue::cs\r
*/\r
-KHMEXP khm_int32 KHMAPI kmq_post_message(khm_int32 type, khm_int32 subtype, khm_ui_4 uparam, void * blob) {\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_post_message(khm_int32 type, khm_int32 subtype, \r
+ khm_ui_4 uparam, void * blob) {\r
return kmqint_post_message_ex(type, subtype, uparam, blob, NULL, FALSE);\r
}\r
\r
\brief Frees a call\r
\note Obtains ::cs_kmq_msg\r
*/\r
-KHMEXP khm_int32 KHMAPI kmq_free_call(kmq_call call) {\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_free_call(kmq_call call) {\r
kmq_message * m;\r
\r
m = call;\r
/*! \internal\r
\note Obtains ::cs_kmq_msg, ::cs_kmq_types, ::cs_kmq_msg_ref, kmq_queue::cs \r
*/\r
-khm_int32 kmqint_post_message_ex(\r
- khm_int32 type, \r
- khm_int32 subtype, \r
- khm_ui_4 uparam, \r
- void * blob, \r
- kmq_call * call,\r
- khm_boolean try_send) {\r
+khm_int32 \r
+kmqint_post_message_ex(khm_int32 type, khm_int32 subtype, khm_ui_4 uparam, \r
+ void * blob, kmq_call * call, khm_boolean try_send) \r
+{\r
kmq_message * m;\r
kherr_context * ctx;\r
\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI kmq_post_message_ex(khm_int32 type, khm_int32 subtype, khm_ui_4 uparam, void * blob, kmq_call * call)\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_post_message_ex(khm_int32 type, khm_int32 subtype, \r
+ khm_ui_4 uparam, void * blob, kmq_call * call)\r
{\r
return kmqint_post_message_ex(type, subtype, uparam, blob, call, FALSE);\r
}\r
\r
/*! \internal\r
*/\r
-KHMEXP khm_int32 KHMAPI kmq_post_sub_msg(khm_handle sub, khm_int32 type, khm_int32 subtype, khm_ui_4 uparam, void * vparam)\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_post_sub_msg(khm_handle sub, khm_int32 type, khm_int32 subtype, \r
+ khm_ui_4 uparam, void * vparam)\r
{\r
return kmq_post_sub_msg_ex(sub, type, subtype, uparam, vparam, NULL);\r
}\r
\r
/*! \internal\r
*/\r
-khm_int32 kmqint_post_sub_msg_ex(\r
- khm_handle sub, \r
- khm_int32 type, \r
- khm_int32 subtype, \r
- khm_ui_4 uparam, \r
- void * vparam, \r
- kmq_call * call,\r
- khm_boolean try_send)\r
+khm_int32 \r
+kmqint_post_sub_msg_ex(khm_handle sub, khm_int32 type, khm_int32 subtype, \r
+ khm_ui_4 uparam, void * vparam, \r
+ kmq_call * call, khm_boolean try_send)\r
{\r
kmq_message * m;\r
kherr_context * ctx;\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI kmq_post_sub_msg_ex(khm_handle sub, khm_int32 type, khm_int32 subtype, khm_ui_4 uparam, void * vparam, kmq_call * call)\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_post_sub_msg_ex(khm_handle sub, khm_int32 type, khm_int32 subtype, \r
+ khm_ui_4 uparam, void * vparam, kmq_call * call)\r
{\r
- return kmqint_post_sub_msg_ex(sub, type, subtype, uparam, vparam, call, FALSE);\r
+ return kmqint_post_sub_msg_ex(sub, type, subtype, \r
+ uparam, vparam, call, FALSE);\r
}\r
\r
-khm_int32 kmqint_post_subs_msg_ex(\r
- khm_handle * subs, \r
- khm_size n_subs, \r
- khm_int32 type, \r
- khm_int32 subtype, \r
- khm_ui_4 uparam, \r
- void * vparam, \r
- kmq_call * call,\r
- khm_boolean try_send)\r
+khm_int32 \r
+kmqint_post_subs_msg_ex(khm_handle * subs, khm_size n_subs, khm_int32 type, \r
+ khm_int32 subtype, khm_ui_4 uparam, void * vparam, \r
+ kmq_call * call, khm_boolean try_send)\r
{\r
kmq_message * m;\r
kherr_context * ctx;\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI kmq_post_subs_msg(\r
- khm_handle * subs, \r
- khm_size n_subs, \r
- khm_int32 type, \r
- khm_int32 subtype, \r
- khm_ui_4 uparam, \r
- void * vparam)\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_post_subs_msg(khm_handle * subs, \r
+ khm_size n_subs, \r
+ khm_int32 type, \r
+ khm_int32 subtype, \r
+ khm_ui_4 uparam, \r
+ void * vparam)\r
{\r
- return kmqint_post_subs_msg_ex(\r
- subs,\r
- n_subs,\r
- type,\r
- subtype,\r
- uparam,\r
- vparam,\r
- NULL,\r
- FALSE);\r
+ return kmqint_post_subs_msg_ex(subs,\r
+ n_subs,\r
+ type,\r
+ subtype,\r
+ uparam,\r
+ vparam,\r
+ NULL,\r
+ FALSE);\r
}\r
\r
-KHMEXP khm_int32 KHMAPI kmq_post_subs_msg_ex(\r
- khm_handle * subs, \r
- khm_int32 n_subs, \r
- khm_int32 type, \r
- khm_int32 subtype, \r
- khm_ui_4 uparam, \r
- void * vparam, \r
- kmq_call * call)\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_post_subs_msg_ex(khm_handle * subs, \r
+ khm_int32 n_subs, \r
+ khm_int32 type, \r
+ khm_int32 subtype, \r
+ khm_ui_4 uparam, \r
+ void * vparam, \r
+ kmq_call * call)\r
{\r
- return kmqint_post_subs_msg_ex(subs, n_subs, type, subtype, uparam, vparam, call, FALSE);\r
+ return kmqint_post_subs_msg_ex(subs, n_subs, type, subtype, \r
+ uparam, vparam, call, FALSE);\r
}\r
\r
-KHMEXP khm_int32 KHMAPI kmq_send_subs_msg(\r
- khm_handle *subs, \r
- khm_int32 n_subs,\r
- khm_int32 type, \r
- khm_int32 subtype, \r
- khm_ui_4 uparam, \r
- void * vparam)\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_send_subs_msg(khm_handle *subs, \r
+ khm_int32 n_subs,\r
+ khm_int32 type, \r
+ khm_int32 subtype, \r
+ khm_ui_4 uparam, \r
+ void * vparam)\r
{\r
kmq_call c;\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
\r
- rv = kmqint_post_subs_msg_ex(subs, n_subs, type, subtype, uparam, vparam, &c, TRUE);\r
+ rv = kmqint_post_subs_msg_ex(subs, n_subs, type, subtype,\r
+ uparam, vparam, &c, TRUE);\r
if(KHM_FAILED(rv))\r
return rv;\r
\r
\r
/*! \internal\r
*/\r
-KHMEXP khm_int32 KHMAPI kmq_send_sub_msg(khm_handle sub, khm_int32 type, khm_int32 subtype, khm_ui_4 uparam, void * vparam)\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_send_sub_msg(khm_handle sub, khm_int32 type, khm_int32 subtype, \r
+ khm_ui_4 uparam, void * vparam)\r
{\r
kmq_call c;\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
/*! \internal\r
\note Obtains ::cs_kmq_global, ::cs_kmq_msg, ::cs_kmq_msg_ref, kmq_queue::cs\r
*/\r
-KHMEXP khm_int32 KHMAPI kmq_send_thread_quit_message(kmq_thread_id thread, khm_ui_4 uparam) {\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_send_thread_quit_message(kmq_thread_id thread, khm_ui_4 uparam) {\r
kmq_call c;\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
\r
/*! \internal\r
\note Obtains ::cs_kmq_global, ::cs_kmq_msg, ::cs_kmq_msg_ref, kmq_queue::cs\r
*/ \r
-KHMEXP khm_int32 KHMAPI kmq_post_thread_quit_message(kmq_thread_id thread, khm_ui_4 uparam, kmq_call * call) {\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_post_thread_quit_message(kmq_thread_id thread, \r
+ khm_ui_4 uparam, kmq_call * call) {\r
kmq_message * m;\r
kmq_queue * q;\r
\r
}\r
\r
/* TODO:Implement these */\r
-KHMEXP khm_int32 KHMAPI kmq_get_next_response(kmq_call call, void ** resp) {\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_get_next_response(kmq_call call, void ** resp) {\r
return 0;\r
}\r
\r
-KHMEXP khm_boolean KHMAPI kmq_has_completed(kmq_call call) {\r
+KHMEXP khm_boolean KHMAPI \r
+kmq_has_completed(kmq_call call) {\r
return (call->nCompleted + call->nFailed == call->nSent);\r
}\r
\r
-KHMEXP khm_int32 KHMAPI kmq_wait(kmq_call call, kmq_timer timeout) {\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_wait(kmq_call call, kmq_timer timeout) {\r
kmq_message * m = call;\r
DWORD rv;\r
/*TODO: check for call free */\r
else\r
return KHM_ERROR_TIMEOUT;\r
} else\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
/*! \internal\r
\note Obtains ::cs_kmq_types\r
*/\r
-KHMEXP khm_int32 KHMAPI kmq_set_completion_handler(khm_int32 type, kmq_msg_completion_handler handler) {\r
+KHMEXP khm_int32 KHMAPI \r
+kmq_set_completion_handler(khm_int32 type, \r
+ kmq_msg_completion_handler handler) {\r
return kmqint_msg_type_set_handler(type, handler);\r
}\r
\r
$(UTILDIR)\hashtable.obj \\r
$(UTILDIR)\sync.obj \\r
$(UTILDIR)\mstring.obj \\r
+ $(UTILDIR)\perfstat.obj \\r
$(KHERRDIR)\kherrmain.obj \\r
$(KHERRDIR)\kherr.obj \\r
$(KCONFIGDIR)\kconfigmain.obj \\r
SDKLIBFILES= \\r
advapi32.lib \\r
strsafe.lib \\r
- comctl32.lib\r
+ comctl32.lib \\r
+ shlwapi.lib \\r
+ version.lib\r
\r
$(DLLFILE): $(OBJFILES) $(RESFILES)\r
$(DLLGUILINK) $(LIBFILES) $(SDKLIBFILES)\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/* $Id$ */\r
\r
#include<afxres.h>\r
-#include<khimaira_version.h>\r
+#include<netidmgr_intver.h>\r
\r
#ifdef _WIN32\r
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\r
/*\r
-* Copyright (c) 2004 Massachusetts Institute of Technology\r
+* Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
DECL_FUNC_PTR(krb5_get_default_config_files);\r
DECL_FUNC_PTR(krb5_free_config_files);\r
DECL_FUNC_PTR(krb5_get_default_realm);\r
+DECL_FUNC_PTR(krb5_set_default_realm);\r
DECL_FUNC_PTR(krb5_free_ticket);\r
DECL_FUNC_PTR(krb5_decode_ticket);\r
DECL_FUNC_PTR(krb5_get_host_realm);\r
\r
// Profile functions\r
DECL_FUNC_PTR(profile_init); \r
+DECL_FUNC_PTR(profile_flush);\r
DECL_FUNC_PTR(profile_release); \r
DECL_FUNC_PTR(profile_get_subsection_names);\r
DECL_FUNC_PTR(profile_free_list);\r
DECL_FUNC_PTR(profile_get_string);\r
+DECL_FUNC_PTR(profile_get_values);\r
+DECL_FUNC_PTR(profile_get_relation_names);\r
+DECL_FUNC_PTR(profile_clear_relation);\r
+DECL_FUNC_PTR(profile_add_relation);\r
+DECL_FUNC_PTR(profile_update_relation);\r
DECL_FUNC_PTR(profile_release_string);\r
\r
// Service functions\r
\r
FUNC_INFO k5_fi[] = {\r
MAKE_FUNC_INFO(krb5_change_password),\r
- MAKE_FUNC_INFO(krb5_get_init_creds_opt_init),\r
- MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_tkt_life),\r
- MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_renew_life),\r
- MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_forwardable),\r
- MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_proxiable),\r
- MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_address_list),\r
- MAKE_FUNC_INFO(krb5_get_init_creds_password),\r
- MAKE_FUNC_INFO(krb5_get_prompt_types),\r
- MAKE_FUNC_INFO(krb5_build_principal_ext),\r
- MAKE_FUNC_INFO(krb5_cc_get_name),\r
- MAKE_FUNC_INFO(krb5_cc_resolve),\r
- MAKE_FUNC_INFO(krb5_cc_default),\r
- MAKE_FUNC_INFO(krb5_cc_default_name),\r
- MAKE_FUNC_INFO(krb5_cc_set_default_name),\r
- MAKE_FUNC_INFO(krb5_cc_initialize),\r
- MAKE_FUNC_INFO(krb5_cc_destroy),\r
- MAKE_FUNC_INFO(krb5_cc_close),\r
- MAKE_FUNC_INFO(krb5_cc_copy_creds),\r
- MAKE_FUNC_INFO(krb5_cc_store_cred),\r
- MAKE_FUNC_INFO(krb5_cc_retrieve_cred),\r
- MAKE_FUNC_INFO(krb5_cc_get_principal),\r
- MAKE_FUNC_INFO(krb5_cc_start_seq_get),\r
- MAKE_FUNC_INFO(krb5_cc_next_cred),\r
- MAKE_FUNC_INFO(krb5_cc_end_seq_get),\r
- MAKE_FUNC_INFO(krb5_cc_remove_cred),\r
- MAKE_FUNC_INFO(krb5_cc_set_flags),\r
- // MAKE_FUNC_INFO(krb5_cc_get_type),\r
- MAKE_FUNC_INFO(krb5_free_context),\r
- MAKE_FUNC_INFO(krb5_free_cred_contents),\r
- MAKE_FUNC_INFO(krb5_free_principal),\r
- MAKE_FUNC_INFO(krb5_get_in_tkt_with_password),\r
- MAKE_FUNC_INFO(krb5_init_context),\r
- MAKE_FUNC_INFO(krb5_parse_name),\r
- MAKE_FUNC_INFO(krb5_timeofday),\r
- MAKE_FUNC_INFO(krb5_timestamp_to_sfstring),\r
- MAKE_FUNC_INFO(krb5_unparse_name),\r
- MAKE_FUNC_INFO(krb5_get_credentials),\r
- MAKE_FUNC_INFO(krb5_mk_req),\r
- MAKE_FUNC_INFO(krb5_sname_to_principal),\r
- MAKE_FUNC_INFO(krb5_get_credentials_renew),\r
- MAKE_FUNC_INFO(krb5_free_data),\r
- MAKE_FUNC_INFO(krb5_free_data_contents),\r
- // MAKE_FUNC_INFO(krb5_get_realm_domain),\r
- MAKE_FUNC_INFO(krb5_free_unparsed_name),\r
- MAKE_FUNC_INFO(krb5_os_localaddr),\r
- MAKE_FUNC_INFO(krb5_copy_keyblock_contents),\r
- MAKE_FUNC_INFO(krb5_copy_data),\r
- MAKE_FUNC_INFO(krb5_free_creds),\r
- MAKE_FUNC_INFO(krb5_build_principal),\r
- MAKE_FUNC_INFO(krb5_get_renewed_creds),\r
- MAKE_FUNC_INFO(krb5_free_addresses),\r
- MAKE_FUNC_INFO(krb5_get_default_config_files),\r
- MAKE_FUNC_INFO(krb5_free_config_files),\r
- MAKE_FUNC_INFO(krb5_get_default_realm),\r
- MAKE_FUNC_INFO(krb5_free_ticket),\r
- MAKE_FUNC_INFO(krb5_decode_ticket),\r
- MAKE_FUNC_INFO(krb5_get_host_realm),\r
- MAKE_FUNC_INFO(krb5_free_host_realm),\r
- MAKE_FUNC_INFO(krb5_c_random_make_octets),\r
- MAKE_FUNC_INFO(krb5_free_default_realm),\r
- END_FUNC_INFO\r
+ MAKE_FUNC_INFO(krb5_get_init_creds_opt_init),\r
+ MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_tkt_life),\r
+ MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_renew_life),\r
+ MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_forwardable),\r
+ MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_proxiable),\r
+ MAKE_FUNC_INFO(krb5_get_init_creds_opt_set_address_list),\r
+ MAKE_FUNC_INFO(krb5_get_init_creds_password),\r
+ MAKE_FUNC_INFO(krb5_get_prompt_types),\r
+ MAKE_FUNC_INFO(krb5_build_principal_ext),\r
+ MAKE_FUNC_INFO(krb5_cc_get_name),\r
+ MAKE_FUNC_INFO(krb5_cc_resolve),\r
+ MAKE_FUNC_INFO(krb5_cc_default),\r
+ MAKE_FUNC_INFO(krb5_cc_default_name),\r
+ MAKE_FUNC_INFO(krb5_cc_set_default_name),\r
+ MAKE_FUNC_INFO(krb5_cc_initialize),\r
+ MAKE_FUNC_INFO(krb5_cc_destroy),\r
+ MAKE_FUNC_INFO(krb5_cc_close),\r
+ MAKE_FUNC_INFO(krb5_cc_copy_creds),\r
+ MAKE_FUNC_INFO(krb5_cc_store_cred),\r
+ MAKE_FUNC_INFO(krb5_cc_retrieve_cred),\r
+ MAKE_FUNC_INFO(krb5_cc_get_principal),\r
+ MAKE_FUNC_INFO(krb5_cc_start_seq_get),\r
+ MAKE_FUNC_INFO(krb5_cc_next_cred),\r
+ MAKE_FUNC_INFO(krb5_cc_end_seq_get),\r
+ MAKE_FUNC_INFO(krb5_cc_remove_cred),\r
+ MAKE_FUNC_INFO(krb5_cc_set_flags),\r
+ // MAKE_FUNC_INFO(krb5_cc_get_type),\r
+ MAKE_FUNC_INFO(krb5_free_context),\r
+ MAKE_FUNC_INFO(krb5_free_cred_contents),\r
+ MAKE_FUNC_INFO(krb5_free_principal),\r
+ MAKE_FUNC_INFO(krb5_get_in_tkt_with_password),\r
+ MAKE_FUNC_INFO(krb5_init_context),\r
+ MAKE_FUNC_INFO(krb5_parse_name),\r
+ MAKE_FUNC_INFO(krb5_timeofday),\r
+ MAKE_FUNC_INFO(krb5_timestamp_to_sfstring),\r
+ MAKE_FUNC_INFO(krb5_unparse_name),\r
+ MAKE_FUNC_INFO(krb5_get_credentials),\r
+ MAKE_FUNC_INFO(krb5_mk_req),\r
+ MAKE_FUNC_INFO(krb5_sname_to_principal),\r
+ MAKE_FUNC_INFO(krb5_get_credentials_renew),\r
+ MAKE_FUNC_INFO(krb5_free_data),\r
+ MAKE_FUNC_INFO(krb5_free_data_contents),\r
+ // MAKE_FUNC_INFO(krb5_get_realm_domain),\r
+ MAKE_FUNC_INFO(krb5_free_unparsed_name),\r
+ MAKE_FUNC_INFO(krb5_os_localaddr),\r
+ MAKE_FUNC_INFO(krb5_copy_keyblock_contents),\r
+ MAKE_FUNC_INFO(krb5_copy_data),\r
+ MAKE_FUNC_INFO(krb5_free_creds),\r
+ MAKE_FUNC_INFO(krb5_build_principal),\r
+ MAKE_FUNC_INFO(krb5_get_renewed_creds),\r
+ MAKE_FUNC_INFO(krb5_free_addresses),\r
+ MAKE_FUNC_INFO(krb5_get_default_config_files),\r
+ MAKE_FUNC_INFO(krb5_free_config_files),\r
+ MAKE_FUNC_INFO(krb5_get_default_realm),\r
+ MAKE_FUNC_INFO(krb5_set_default_realm),\r
+ MAKE_FUNC_INFO(krb5_free_ticket),\r
+ MAKE_FUNC_INFO(krb5_decode_ticket),\r
+ MAKE_FUNC_INFO(krb5_get_host_realm),\r
+ MAKE_FUNC_INFO(krb5_free_host_realm),\r
+ MAKE_FUNC_INFO(krb5_c_random_make_octets),\r
+ MAKE_FUNC_INFO(krb5_free_default_realm),\r
+ END_FUNC_INFO\r
};\r
\r
FUNC_INFO k524_fi[] = {\r
\r
FUNC_INFO profile_fi[] = {\r
MAKE_FUNC_INFO(profile_init),\r
- MAKE_FUNC_INFO(profile_release), \r
- MAKE_FUNC_INFO(profile_get_subsection_names),\r
- MAKE_FUNC_INFO(profile_free_list),\r
- MAKE_FUNC_INFO(profile_get_string),\r
- MAKE_FUNC_INFO(profile_release_string),\r
- END_FUNC_INFO\r
+ MAKE_FUNC_INFO(profile_flush),\r
+ MAKE_FUNC_INFO(profile_release), \r
+ MAKE_FUNC_INFO(profile_get_subsection_names),\r
+ MAKE_FUNC_INFO(profile_free_list),\r
+ MAKE_FUNC_INFO(profile_get_string),\r
+ MAKE_FUNC_INFO(profile_get_values),\r
+ MAKE_FUNC_INFO(profile_get_relation_names),\r
+ MAKE_FUNC_INFO(profile_clear_relation),\r
+ MAKE_FUNC_INFO(profile_add_relation),\r
+ MAKE_FUNC_INFO(profile_update_relation),\r
+ MAKE_FUNC_INFO(profile_release_string),\r
+ END_FUNC_INFO\r
};\r
\r
FUNC_INFO ce_fi[] = {\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
extern DECL_FUNC_PTR(krb5_get_default_config_files);\r
extern DECL_FUNC_PTR(krb5_free_config_files);\r
extern DECL_FUNC_PTR(krb5_get_default_realm);\r
+extern DECL_FUNC_PTR(krb5_set_default_realm);\r
extern DECL_FUNC_PTR(krb5_free_ticket);\r
extern DECL_FUNC_PTR(krb5_decode_ticket);\r
extern DECL_FUNC_PTR(krb5_get_host_realm);\r
\r
// Profile functions\r
extern DECL_FUNC_PTR(profile_init);\r
+extern DECL_FUNC_PTR(profile_flush);\r
extern DECL_FUNC_PTR(profile_release);\r
extern DECL_FUNC_PTR(profile_get_subsection_names);\r
extern DECL_FUNC_PTR(profile_free_list);\r
extern DECL_FUNC_PTR(profile_get_string);\r
+extern DECL_FUNC_PTR(profile_get_values);\r
+extern DECL_FUNC_PTR(profile_get_relation_names);\r
+extern DECL_FUNC_PTR(profile_clear_relation);\r
+extern DECL_FUNC_PTR(profile_add_relation);\r
+extern DECL_FUNC_PTR(profile_update_relation);\r
extern DECL_FUNC_PTR(profile_release_string);\r
\r
// Service functions\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/* $Id$ */\r
\r
#include<windows.h>\r
-#include<kcreddb.h>\r
-#include<kherror.h>\r
+#include<netidmgr.h>\r
#include<dynimport.h>\r
+#include<krb5common.h>\r
+#ifdef DEBUG\r
+#include<assert.h>\r
+#endif\r
\r
/**************************************/\r
/* khm_krb5_error(): */\r
if (pkrb5_init_context == NULL)\r
return 1;\r
\r
- if (*ctx == 0 && (rc = (*pkrb5_init_context)(ctx)))\r
- {\r
+ if (*ctx == 0 && (rc = (*pkrb5_init_context)(ctx))) {\r
functionName = "krb5_init_context()";\r
freeContextFlag = 0;\r
goto on_error;\r
}\r
\r
if(*cache == 0) {\r
- wchar_t wccname[256];\r
+ wchar_t wccname[MAX_PATH];\r
khm_size cbwccname;\r
\r
if(ident != NULL) {\r
do {\r
char ccname[256];\r
\r
- if(KHM_FAILED(kcdb_identity_get_attrib(ident, L"Krb5CCName", NULL, wccname, &cbwccname)))\r
- break;\r
+ if(KHM_FAILED(kcdb_identity_get_attrib(ident, L"Krb5CCName",\r
+ NULL, wccname,\r
+ &cbwccname))) {\r
+ cbwccname = sizeof(wccname);\r
+ if (KHM_FAILED\r
+ (khm_krb5_find_ccache_for_identity(ident,\r
+ ctx,\r
+ wccname,\r
+ &cbwccname))) {\r
+#ifdef DEBUG_LIKE_A_MADMAN\r
+ assert(FALSE);\r
+#endif\r
+ break;\r
+ }\r
+ }\r
\r
if(UnicodeStrToAnsi(ccname, sizeof(ccname), wccname) == 0)\r
break;\r
} while(FALSE);\r
}\r
\r
- if (*cache == 0 && (rc = (*pkrb5_cc_default)(*ctx, cache)))\r
- {\r
+ if (*cache == 0\r
+#ifdef FAILOVER_TO_DEFAULT_CCACHE\r
+ && (rc = (*pkrb5_cc_default)(*ctx, cache))\r
+#endif\r
+ ) {\r
functionName = "krb5_cc_default()";\r
freeContextFlag = 1;\r
goto on_error;\r
if (rc != KRB5_FCC_NOFILE && rc != KRB5_CC_NOTFOUND)\r
khm_krb5_error(rc, "krb5_cc_set_flags()", 0, ctx, \r
cache);\r
- else if ((rc == KRB5_FCC_NOFILE || rc == KRB5_CC_NOTFOUND) && *ctx != NULL)\r
- {\r
+ else if ((rc == KRB5_FCC_NOFILE || rc == KRB5_CC_NOTFOUND) && *ctx != NULL) {\r
if (*cache != NULL)\r
(*pkrb5_cc_close)(*ctx, *cache);\r
}\r
return khm_krb5_error(rc, functionName, freeContextFlag, ctx, cache);\r
#endif //!NO_KRB5\r
}\r
+\r
+#define TIMET_TOLERANCE (60*5)\r
+\r
+khm_int32 KHMAPI\r
+khm_get_identity_expiration_time(krb5_context ctx, krb5_ccache cc, \r
+ khm_handle ident, \r
+ krb5_timestamp * pexpiration)\r
+{\r
+ krb5_principal principal = 0;\r
+ char * princ_name = NULL;\r
+ krb5_creds creds;\r
+ krb5_error_code code;\r
+ krb5_error_code cc_code;\r
+ krb5_cc_cursor cur;\r
+ krb5_timestamp now, expiration = 0;\r
+\r
+ wchar_t w_ident_name[KCDB_IDENT_MAXCCH_NAME];\r
+ char ident_name[KCDB_IDENT_MAXCCH_NAME];\r
+ khm_size cb;\r
+\r
+ khm_int32 rv = KHM_ERROR_NOT_FOUND;\r
+\r
+ if (!ctx || !cc || !ident || !pexpiration)\r
+ return KHM_ERROR_GENERAL;\r
+\r
+ code = pkrb5_cc_get_principal(ctx, cc, &principal);\r
+\r
+ if ( code )\r
+ return KHM_ERROR_INVALID_PARAM;\r
+\r
+ cb = sizeof(w_ident_name);\r
+ kcdb_identity_get_name(ident, w_ident_name, &cb);\r
+ UnicodeStrToAnsi(ident_name, sizeof(ident_name), w_ident_name);\r
+\r
+ code = pkrb5_unparse_name(ctx, principal, &princ_name);\r
+\r
+ /* compare principal to ident. */\r
+\r
+ if ( code || !princ_name ||\r
+ strcmp(princ_name, ident_name) ) {\r
+ if (princ_name)\r
+ pkrb5_free_unparsed_name(ctx, princ_name);\r
+ pkrb5_free_principal(ctx, principal);\r
+ return KHM_ERROR_UNKNOWN;\r
+ }\r
+\r
+ pkrb5_free_unparsed_name(ctx, princ_name);\r
+ pkrb5_free_principal(ctx, principal);\r
+\r
+ code = pkrb5_timeofday(ctx, &now);\r
+\r
+ if (code)\r
+ return KHM_ERROR_UNKNOWN;\r
+\r
+ cc_code = pkrb5_cc_start_seq_get(ctx, cc, &cur);\r
+\r
+ while (!(cc_code = pkrb5_cc_next_cred(ctx, cc, &cur, &creds))) {\r
+ krb5_data * c0 = krb5_princ_name(ctx, creds.server);\r
+ krb5_data * c1 = krb5_princ_component(ctx, creds.server, 1);\r
+ krb5_data * r = krb5_princ_realm(ctx, creds.server);\r
+\r
+ if ( c0 && c1 && r && c1->length == r->length && \r
+ !strncmp(c1->data,r->data,r->length) &&\r
+ !strncmp("krbtgt",c0->data,c0->length) ) {\r
+\r
+ /* we have a TGT, check for the expiration time.\r
+ * if it is valid and renewable, use the renew time \r
+ */\r
+\r
+ if (!(creds.ticket_flags & TKT_FLG_INVALID) &&\r
+ creds.times.starttime < (now + TIMET_TOLERANCE) && \r
+ (creds.times.endtime + TIMET_TOLERANCE) > now) {\r
+ expiration = creds.times.endtime;\r
+\r
+ if ((creds.ticket_flags & TKT_FLG_RENEWABLE) && \r
+ (creds.times.renew_till > creds.times.endtime)) {\r
+ expiration = creds.times.renew_till;\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ if (cc_code == KRB5_CC_END) {\r
+ cc_code = pkrb5_cc_end_seq_get(ctx, cc, &cur);\r
+ rv = KHM_ERROR_SUCCESS;\r
+ *pexpiration = expiration;\r
+ }\r
+\r
+ return rv;\r
+}\r
+\r
+khm_int32 KHMAPI\r
+khm_krb5_find_ccache_for_identity(khm_handle ident, krb5_context *pctx,\r
+ void * buffer, khm_size * pcbbuf)\r
+{\r
+ krb5_context ctx = 0;\r
+ krb5_ccache cache = 0;\r
+ krb5_error_code code;\r
+ apiCB * cc_ctx = 0;\r
+ struct _infoNC ** pNCi = NULL;\r
+ int i;\r
+ khm_int32 t;\r
+ wchar_t * ms = NULL;\r
+ khm_size cb;\r
+ krb5_timestamp expiration = 0;\r
+ krb5_timestamp best_match_expiration = 0;\r
+ char best_match_ccname[256] = "";\r
+ khm_handle csp_params = NULL;\r
+ khm_handle csp_plugins = NULL;\r
+\r
+ if (!buffer || !pcbbuf)\r
+ return KHM_ERROR_GENERAL;\r
+\r
+ ctx = *pctx;\r
+\r
+ code = pcc_initialize(&cc_ctx, CC_API_VER_2, NULL, NULL);\r
+ if (code)\r
+ goto _exit;\r
+\r
+ code = pcc_get_NC_info(cc_ctx, &pNCi);\r
+\r
+ if (code) \r
+ goto _exit;\r
+\r
+ for(i=0; pNCi[i]; i++) {\r
+ if (pNCi[i]->vers != CC_CRED_V5)\r
+ continue;\r
+\r
+ code = (*pkrb5_cc_resolve)(ctx, pNCi[i]->name, &cache);\r
+ if (code)\r
+ continue;\r
+\r
+ /* need a function to check the cache for the identity\r
+ * and determine if it has valid tickets. If it has \r
+ * the right identity and valid tickets, store the \r
+ * expiration time and the cache name. If it has the\r
+ * right identity but no valid tickets, store the ccache\r
+ * name and an expiration time of zero. if it does not\r
+ * have the right identity don't save the name.\r
+ * \r
+ * Keep searching to find the best cache available.\r
+ */\r
+\r
+ if (KHM_SUCCEEDED(khm_get_identity_expiration_time(ctx, cache, \r
+ ident, \r
+ &expiration))) {\r
+ if ( expiration > best_match_expiration ) {\r
+ best_match_expiration = expiration;\r
+ StringCbCopyA(best_match_ccname, \r
+ sizeof(best_match_ccname),\r
+ "API:");\r
+ StringCbCatA(best_match_ccname,\r
+ sizeof(best_match_ccname),\r
+ pNCi[i]->name);\r
+ expiration = 0;\r
+ }\r
+ }\r
+\r
+ if(ctx != NULL && cache != NULL)\r
+ (*pkrb5_cc_close)(ctx, cache);\r
+ cache = 0;\r
+ }\r
+\r
+ if (KHM_SUCCEEDED(kmm_get_plugins_config(0, &csp_plugins))) {\r
+ khc_open_space(csp_plugins, L"Krb5Cred\\Parameters", 0, &csp_params);\r
+ khc_close_space(csp_plugins);\r
+ csp_plugins = NULL;\r
+ }\r
+\r
+#ifdef DEBUG\r
+ if (csp_params == NULL) {\r
+ assert(FALSE);\r
+ }\r
+#endif\r
+\r
+ if (csp_params &&\r
+ KHM_SUCCEEDED(khc_read_int32(csp_params, L"MsLsaList", &t)) && t) {\r
+ code = (*pkrb5_cc_resolve)(ctx, "MSLSA:", &cache);\r
+ if (code == 0 && cache) {\r
+ if (KHM_SUCCEEDED(khm_get_identity_expiration_time(ctx, cache, \r
+ ident, \r
+ &expiration))) {\r
+ if ( expiration > best_match_expiration ) {\r
+ best_match_expiration = expiration;\r
+ StringCbCopyA(best_match_ccname, sizeof(best_match_ccname),\r
+ "MSLSA:");\r
+ expiration = 0;\r
+ }\r
+ }\r
+ }\r
+\r
+ if (ctx != NULL && cache != NULL)\r
+ (*pkrb5_cc_close)(ctx, cache);\r
+\r
+ cache = 0;\r
+ }\r
+\r
+ if (csp_params &&\r
+ khc_read_multi_string(csp_params, L"FileCCList", NULL, &cb)\r
+ == KHM_ERROR_TOO_LONG &&\r
+ cb > sizeof(wchar_t) * 2) {\r
+\r
+ wchar_t * t;\r
+ char ccname[MAX_PATH + 6];\r
+\r
+ ms = PMALLOC(cb);\r
+\r
+#ifdef DEBUG\r
+ assert(ms);\r
+#endif\r
+\r
+ khc_read_multi_string(csp_params, L"FileCCList", ms, &cb);\r
+ for(t = ms; t && *t; t = multi_string_next(t)) {\r
+ StringCchPrintfA(ccname, ARRAYLENGTH(ccname),\r
+ "FILE:%S", t);\r
+\r
+ code = (*pkrb5_cc_resolve)(ctx, ccname, &cache);\r
+ if (code)\r
+ continue;\r
+\r
+ if (KHM_SUCCEEDED(khm_get_identity_expiration_time(ctx, cache, \r
+ ident, \r
+ &expiration))) {\r
+ if ( expiration > best_match_expiration ) {\r
+ best_match_expiration = expiration;\r
+ StringCbCopyA(best_match_ccname,\r
+ sizeof(best_match_ccname),\r
+ ccname);\r
+ expiration = 0;\r
+ }\r
+ }\r
+\r
+ if (ctx != NULL && cache != NULL)\r
+ (*pkrb5_cc_close)(ctx, cache);\r
+ cache = 0;\r
+ }\r
+\r
+ PFREE(ms);\r
+ }\r
+ _exit:\r
+ if (csp_params)\r
+ khc_close_space(csp_params);\r
+\r
+ if (pNCi)\r
+ (*pcc_free_NC_info)(cc_ctx, &pNCi);\r
+\r
+ if (cc_ctx)\r
+ (*pcc_shutdown)(&cc_ctx);\r
+\r
+ if (best_match_ccname[0]) {\r
+ \r
+ if (*pcbbuf = AnsiStrToUnicode((wchar_t *)buffer, \r
+ *pcbbuf,\r
+ best_match_ccname)) {\r
+\r
+ *pcbbuf = (*pcbbuf + 1) * sizeof(wchar_t);\r
+\r
+ return KHM_ERROR_SUCCESS;\r
+ }\r
+\r
+ }\r
+\r
+ return KHM_ERROR_GENERAL;\r
+}\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
\r
\r
int khm_krb5_initialize(khm_handle ident, krb5_context *, krb5_ccache *);\r
+\r
+khm_int32 KHMAPI\r
+khm_krb5_find_ccache_for_identity(khm_handle ident, krb5_context *pctx,\r
+ void * buffer, khm_size * pcbbuf);\r
+\r
+khm_int32 KHMAPI\r
+khm_get_identity_expiration_time(krb5_context ctx, krb5_ccache cc, \r
+ khm_handle ident, \r
+ krb5_timestamp * pexpiration);\r
#endif /* NO_KRB5 */\r
\r
-#endif
\ No newline at end of file
+#endif\r
OBJFILES= \\r
$(LIBDIR)\dynimport.obj \\r
$(LIBDIR)\krb5common.obj \\r
- $(OBJ)\main.obj \\r
+ $(OBJ)\krb4main.obj \\r
$(OBJ)\krb4plugin.obj \\r
$(OBJ)\krb4funcs.obj \\r
$(OBJ)\errorfuncs.obj \\r
$(OBJ)\krb4config.obj \\r
- $(OBJ)\krb4configdlg.obj\r
+ $(OBJ)\krb4configdlg.obj \\r
+ $(OBJ)\krb4newcreds.obj\r
\r
LIBFILES= \\r
$(LIBDIR)\nidmgr32.lib \\r
\r
SDKLIBFILES=\r
\r
+VERRESFILE=$(OBJ)\version.res\r
+\r
$(OBJ)\krb4config.c: krbconfig.csv $(CONFDIR)\csvschema.cfg\r
$(CCSV) $** $@\r
\r
-$(DLLFILE): $(OBJFILES)\r
+$(DLLFILE): $(OBJFILES) $(VERRESFILE)\r
$(DLLGUILINK) $(LIBFILES) $(SDKLIBFILES)\r
\r
all: mkdirs $(DLLFILE) lang\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
}\r
\r
\r
-LPSTR err_describe(LPSTR buf, long code)\r
+LPSTR err_describe(LPSTR buf, size_t len, long code)\r
{\r
LPSTR cp, com_err_msg;\r
int offset;\r
case kadm_err_base:\r
break;\r
default:\r
- strcpy(buf, com_err_msg);\r
+ strncpy(buf, com_err_msg, len);\r
+ buf[len-1] = '\0';\r
return buf;\r
}\r
\r
/* no extra error msg */\r
break;\r
}\r
- if(com_err_msg != buf)\r
- strcpy(buf, com_err_msg);\r
+ if(com_err_msg != buf) {\r
+ strncpy(buf, com_err_msg, len);\r
+ buf[len-1] = '\0';\r
+ }\r
cp = buf + strlen(buf);\r
*cp++ = '\n';\r
switch(table_num) {\r
etype = Lerror_table_name(table_num);\r
break;\r
}\r
- wsprintfA((LPSTR) cp, (LPSTR) "(%s error %d"\r
+ StringCbPrintfA((LPSTR) cp, len - (cp-buf), (LPSTR) "(%s error %d"\r
#ifdef DEBUG_COM_ERR\r
" (absolute error %ld)"\r
#endif\r
return (LPSTR)buf;\r
}\r
\r
-int lsh_com_err_proc (LPSTR whoami, long code,\r
- LPSTR fmt, va_list args)\r
-{\r
- int retval;\r
- HWND hOldFocus;\r
- char buf[1024], *cp; /* changed to 512 by jms 8/23/93 */\r
- WORD mbformat = MB_OK | MB_ICONEXCLAMATION;\r
- \r
- cp = buf;\r
- memset(buf, '\0', sizeof(buf));\r
- cp[0] = '\0';\r
- \r
- if (code)\r
- {\r
- err_describe(buf, code);\r
- while (*cp)\r
- cp++;\r
- }\r
- \r
- if (fmt)\r
- {\r
- if (fmt[0] == '%' && fmt[1] == 'b')\r
- {\r
- fmt += 2;\r
- mbformat = va_arg(args, WORD);\r
- /* if the first arg is a %b, we use it for the message\r
- box MB_??? flags. */\r
- }\r
- if (code)\r
- {\r
- *cp++ = '\n';\r
- *cp++ = '\n';\r
- }\r
- wvsprintfA((LPSTR)cp, fmt, args);\r
- }\r
- hOldFocus = GetFocus();\r
- retval = MessageBoxA(/*GetRootParent(hOldFocus)*/NULL, buf, whoami, \r
- mbformat | MB_ICONHAND | MB_TASKMODAL);\r
- SetFocus(hOldFocus);\r
- return retval;\r
-}\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
#endif\r
\r
#include <krberr.h>\r
-extern void Leash_initialize_krb_error_func(err_func func,struct et_list **);\r
-#undef init_krb_err_func\r
-#define init_krb_err_func(erf) Leash_initialize_krb_error_func(erf,&_et_list)\r
-\r
#include <kadm_err.h>\r
\r
-extern void Leash_initialize_kadm_error_table(struct et_list **);\r
-#undef init_kadm_err_tbl\r
-#define init_kadm_err_tbl() Leash_initialize_kadm_error_table(&_et_list)\r
#define kadm_err_base ERROR_TABLE_BASE_kadm\r
\r
-#define krb_err_func Leash_krb_err_func\r
-\r
#include <stdarg.h>\r
-int lsh_com_err_proc (LPSTR whoami, long code,\r
- LPSTR fmt, va_list args);\r
-void FAR Leash_load_com_err_callback(FARPROC,FARPROC,FARPROC);\r
\r
#ifndef KRBERR\r
#define KRBERR(code) (code + krb_err_base)\r
#endif\r
\r
-int lsh_com_err_proc (LPSTR whoami, long code, LPSTR fmt, va_list args);\r
-int DoNiftyErrorReport(long errnum, LPSTR what);\r
-\r
-LPSTR err_describe(LPSTR buf, long code);\r
+LPSTR err_describe(LPSTR buf, size_t len, long code);\r
\r
\r
/* */\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
#include<kherror.h>\r
#include<khuidefs.h>\r
#include<strsafe.h>\r
+#include<assert.h>\r
+\r
+typedef struct tag_k4_ids_data {\r
+ khui_config_init_data cfg;\r
+\r
+ khm_int32 get_tix;\r
+} k4_ids_data;\r
+\r
+static void\r
+k4_ids_read_params(k4_ids_data * d) {\r
+ khm_int32 t;\r
+#ifdef DEBUG\r
+ assert(csp_params);\r
+#endif\r
+\r
+ t = 1;\r
+ khc_read_int32(csp_params, L"Krb4NewCreds", &t);\r
+ d->get_tix = !!t;\r
+}\r
+\r
+static void\r
+k4_ids_write_params(HWND hw, k4_ids_data * d) {\r
+ khm_int32 nv;\r
+ khm_boolean applied = FALSE;\r
+\r
+ if (IsDlgButtonChecked(hw, IDC_CFG_GETTIX) == BST_CHECKED)\r
+ nv = TRUE;\r
+ else\r
+ nv = FALSE;\r
+\r
+ if (!!nv != !!d->get_tix) {\r
+ d->get_tix = !!nv;\r
+ khc_write_int32(csp_params, L"Krb4NewCreds", d->get_tix);\r
+ applied = TRUE;\r
+ }\r
+\r
+ khui_cfg_set_flags_inst(&d->cfg,\r
+ (applied)?KHUI_CNFLAG_APPLIED:0,\r
+ KHUI_CNFLAG_APPLIED | KHUI_CNFLAG_MODIFIED);\r
+}\r
+\r
+static void\r
+k4_ids_check_mod(HWND hw, k4_ids_data * d) {\r
+ khm_int32 nv;\r
+\r
+ if (IsDlgButtonChecked(hw, IDC_CFG_GETTIX) == BST_CHECKED)\r
+ nv = TRUE;\r
+ else\r
+ nv = FALSE;\r
+\r
+ khui_cfg_set_flags_inst(&d->cfg,\r
+ (!!nv != !!d->get_tix)? KHUI_CNFLAG_MODIFIED: 0,\r
+ KHUI_CNFLAG_MODIFIED);\r
+}\r
+\r
+INT_PTR CALLBACK\r
+krb4_ids_config_proc(HWND hwnd,\r
+ UINT uMsg,\r
+ WPARAM wParam,\r
+ LPARAM lParam) {\r
+ k4_ids_data * d;\r
+\r
+ switch(uMsg) {\r
+ case WM_INITDIALOG:\r
+ d = PMALLOC(sizeof(*d));\r
+ ZeroMemory(d, sizeof(*d));\r
+\r
+ d->cfg = *((khui_config_init_data *) lParam);\r
+\r
+#pragma warning(push)\r
+#pragma warning(disable: 4244)\r
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d);\r
+#pragma warning(pop)\r
+\r
+ k4_ids_read_params(d);\r
+\r
+ CheckDlgButton(hwnd, IDC_CFG_GETTIX,\r
+ (d->get_tix)? BST_CHECKED: BST_UNCHECKED);\r
+\r
+ break;\r
+\r
+ case WM_COMMAND:\r
+ d = (k4_ids_data *) (LONG_PTR)\r
+ GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+ if (HIWORD(wParam) == BN_CLICKED) {\r
+ k4_ids_check_mod(hwnd, d);\r
+ }\r
+ break;\r
+\r
+ case KHUI_WM_CFG_NOTIFY:\r
+ d = (k4_ids_data *) (LONG_PTR)\r
+ GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+ if (HIWORD(wParam) == WMCFG_APPLY) {\r
+ k4_ids_write_params(hwnd, d);\r
+ }\r
+ break;\r
+\r
+ case WM_DESTROY:\r
+ d = (k4_ids_data *) (LONG_PTR)\r
+ GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+ PFREE(d);\r
+ break;\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r
+INT_PTR CALLBACK\r
+krb4_id_config_proc(HWND hwnd,\r
+ UINT uMsg,\r
+ WPARAM wParam,\r
+ LPARAM lParam) {\r
+ switch(uMsg) {\r
+ case WM_INITDIALOG:\r
+ {\r
+ wchar_t idname[KCDB_IDENT_MAXCCH_NAME];\r
+ khm_size cb;\r
+ khui_config_init_data * d;\r
+ khm_handle ident = NULL;\r
+ khm_int32 gettix = 0;\r
+ khm_int32 flags = 0;\r
+\r
+ d = (khui_config_init_data *) lParam;\r
+\r
+ khc_read_int32(csp_params, L"Krb4NewCreds", &gettix);\r
+ if (gettix == 0)\r
+ goto set_ui;\r
+\r
+ *idname = 0;\r
+ cb = sizeof(idname);\r
+ khui_cfg_get_name(d->ctx_node, idname, &cb);\r
+\r
+ kcdb_identity_create(idname, 0, &ident);\r
+\r
+ if (ident == NULL) {\r
+ gettix = 0;\r
+ goto set_ui;\r
+ }\r
+\r
+ kcdb_identity_get_flags(ident, &flags);\r
+\r
+ kcdb_identity_release(ident);\r
+\r
+ if (!(flags & KCDB_IDENT_FLAG_DEFAULT))\r
+ gettix = 0;\r
+\r
+ set_ui:\r
+ CheckDlgButton(hwnd, IDC_CFG_GETTIX,\r
+ (gettix)?BST_CHECKED: BST_UNCHECKED);\r
+ }\r
+ break;\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r
\r
INT_PTR CALLBACK\r
krb4_confg_proc(HWND hwnd,\r
/*\r
-* Copyright (c) 2004 Massachusetts Institute of Technology\r
+* Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
long \r
khm_krb4_list_tickets(void) \r
{\r
+ char ptktname[MAX_PATH + 5];\r
char pname[ANAME_SZ];\r
char pinst[INST_SZ];\r
char prealm[REALM_SZ];\r
wchar_t wbuf[256];\r
- int k_errno;\r
+ int k_errno = 0;\r
CREDENTIALS c;\r
int newtickets = 0;\r
int open = 0;\r
time_t tt;\r
FILETIME ft;\r
\r
+ kcdb_credset_flush(krb4_credset);\r
+\r
// Since krb_get_tf_realm will return a ticket_file error,\r
// we will call tf_init and tf_close first to filter out\r
// things like no ticket file. Otherwise, the error that\r
// klist: can't find realm of ticket file: No ticket file (tf_util)\r
// instead of klist: No ticket file (tf_util)\r
if (ptf_init == NULL)\r
- return(KSUCCESS);\r
+ goto collect;\r
\r
com_addr();\r
\r
goto cleanup;\r
}\r
\r
+ StringCchCopyA(ptktname, ARRAYLENGTH(ptktname), (*ptkt_string)());\r
+\r
open = 1;\r
\r
// Get principal name and instance \r
goto cleanup;\r
}\r
\r
- kcdb_credset_flush(krb4_credset);\r
-\r
// Get KRB4 tickets\r
while ((k_errno = (*ptf_get_cred)(&c)) == KSUCCESS)\r
{\r
TimetToFileTimeInterval(tt, &ft);\r
kcdb_cred_set_attr(cred, KCDB_ATTR_LIFETIME, &ft, sizeof(ft));\r
\r
+ AnsiStrToUnicode(wbuf, sizeof(wbuf), ptktname);\r
+ kcdb_cred_set_attr(cred, KCDB_ATTR_LOCATION, wbuf, KCDB_CBSIZE_AUTO);\r
+\r
kcdb_credset_add_cred(krb4_credset, cred, -1);\r
\r
} // while\r
\r
- kcdb_credset_collect(NULL, krb4_credset, ident, credtype_id_krb4, NULL);\r
-\r
cleanup:\r
if (ptf_close == NULL)\r
return(KSUCCESS);\r
MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_SETFOREGROUND);\r
}\r
#endif\r
+\r
+ collect:\r
+ kcdb_credset_collect(NULL, krb4_credset, ident, credtype_id_krb4, NULL);\r
+\r
return k_errno;\r
}\r
\r
#define KRB5_FILE "KRB5.INI"\r
\r
BOOL \r
-khm_get_profile_file(LPSTR confname, UINT szConfname)\r
+khm_krb5_get_profile_file(LPSTR confname, UINT szConfname)\r
{\r
char **configFile = NULL;\r
if (pkrb5_get_default_config_files(&configFile)) \r
LPSTR pFind;\r
\r
//strcpy(krbConFile, CLeashApp::m_krbv5_profile->first_file->filename);\r
- if (khm_get_profile_file(krbConFile, sizeof(krbConFile))) \r
+ if (khm_krb5_get_profile_file(krbConFile, sizeof(krbConFile))) \r
{\r
GetWindowsDirectoryA(krbConFile,sizeof(krbConFile));\r
krbConFile[MAX_PATH-1] = '\0';\r
\r
char krb5_conf[MAX_PATH+1];\r
\r
- if (!khm_get_profile_file(krb5_conf,sizeof(krb5_conf))) {\r
+ if (!khm_krb5_get_profile_file(krb5_conf,sizeof(krb5_conf))) {\r
profile_t profile;\r
long retval;\r
const char *filenames[2];\r
}\r
cbsize += sizeof(wchar_t); /* double null terminated */\r
\r
- rlist = malloc(cbsize);\r
+ rlist = PMALLOC(cbsize);\r
d = rlist;\r
for (cpp = sections; *cpp; cpp++)\r
{\r
\r
/*TODO: compute the actual required buffer size instead of hardcoding */\r
cbsize = 16384; // arbitrary\r
- rlist = malloc(cbsize);\r
+ rlist = PMALLOC(cbsize);\r
d = rlist;\r
\r
// Skip the default realm\r
\r
if (def) {\r
cch = strlen(def) + 1;\r
- realm = malloc(sizeof(wchar_t) * cch);\r
+ realm = PMALLOC(sizeof(wchar_t) * cch);\r
AnsiStrToUnicode(realm, sizeof(wchar_t) * cch, def);\r
pkrb5_free_default_realm(ctx, def);\r
} else\r
\r
return realm;\r
}\r
+\r
+static\r
+char *\r
+make_postfix(const char * base,\r
+ const char * postfix,\r
+ char ** rcopy)\r
+{\r
+ int base_size;\r
+ int ret_size;\r
+ char * copy = 0;\r
+ char * ret = 0;\r
+\r
+ base_size = (int) strlen(base) + 1;\r
+ ret_size = base_size + (int) strlen(postfix) + 1;\r
+ copy = malloc(base_size);\r
+ ret = malloc(ret_size);\r
+\r
+ if (!copy || !ret)\r
+ goto cleanup;\r
+\r
+ strncpy(copy, base, base_size);\r
+ copy[base_size - 1] = 0;\r
+\r
+ strncpy(ret, base, base_size);\r
+ strncpy(ret + (base_size - 1), postfix, ret_size - (base_size - 1));\r
+ ret[ret_size - 1] = 0;\r
+\r
+ cleanup:\r
+ if (!copy || !ret) {\r
+ if (copy)\r
+ free(copy);\r
+ if (ret)\r
+ free(ret);\r
+ copy = ret = 0;\r
+ }\r
+ // INVARIANT: (ret ==> copy) && (copy ==> ret)\r
+ *rcopy = copy;\r
+ return ret;\r
+}\r
+\r
+\r
+static\r
+long\r
+make_temp_cache_v4(const char * postfix)\r
+{\r
+ static char * old_cache = 0;\r
+\r
+ if (!pkrb_set_tkt_string || !ptkt_string || !pdest_tkt)\r
+ return 0; // XXX - is this appropriate?\r
+\r
+ if (old_cache) {\r
+ pdest_tkt();\r
+ pkrb_set_tkt_string(old_cache);\r
+ free(old_cache);\r
+ old_cache = 0;\r
+ }\r
+\r
+ if (postfix)\r
+ {\r
+ char * tmp_cache = make_postfix(ptkt_string(), postfix, &old_cache);\r
+\r
+ if (!tmp_cache)\r
+ return KFAILURE;\r
+\r
+ pkrb_set_tkt_string(tmp_cache);\r
+ free(tmp_cache);\r
+ }\r
+ return 0;\r
+}\r
+\r
+long\r
+khm_krb4_changepwd(char * principal,\r
+ char * password,\r
+ char * newpassword,\r
+ char** error_str)\r
+{\r
+ long k_errno;\r
+\r
+ if (!pkrb_set_tkt_string || !ptkt_string || !pkadm_change_your_password ||\r
+ !pdest_tkt)\r
+ return KFAILURE;\r
+\r
+ k_errno = make_temp_cache_v4("_chgpwd");\r
+ if (k_errno) return k_errno;\r
+ k_errno = pkadm_change_your_password(principal, password, newpassword, \r
+ error_str);\r
+ make_temp_cache_v4(0);\r
+ return k_errno;\r
+}\r
+\r
+long\r
+khm_convert524(khm_handle identity)\r
+{\r
+#ifdef NO_KRB5\r
+ return(0);\r
+#else\r
+ krb5_context ctx = 0;\r
+ krb5_error_code code = 0;\r
+ int icode = 0;\r
+ krb5_principal me = 0;\r
+ krb5_principal server = 0;\r
+ krb5_creds *v5creds = 0;\r
+ krb5_creds increds;\r
+ krb5_ccache cc = 0;\r
+ CREDENTIALS * v4creds = NULL;\r
+ static int init_ets = 1;\r
+\r
+ if (!pkrb5_init_context ||\r
+ !pkrb_in_tkt ||\r
+ !pkrb524_init_ets ||\r
+ !pkrb524_convert_creds_kdc)\r
+ return 0;\r
+\r
+ v4creds = (CREDENTIALS *) malloc(sizeof(CREDENTIALS));\r
+ memset((char *) v4creds, 0, sizeof(CREDENTIALS));\r
+\r
+ memset((char *) &increds, 0, sizeof(increds));\r
+ /*\r
+ From this point on, we can goto cleanup because increds is\r
+ initialized.\r
+ */\r
+\r
+ code = khm_krb5_initialize(identity, &ctx, &cc);\r
+ if (code)\r
+ goto cleanup;\r
+\r
+ if ( init_ets ) {\r
+ pkrb524_init_ets(ctx);\r
+ init_ets = 0;\r
+ }\r
+\r
+ if (code = pkrb5_cc_get_principal(ctx, cc, &me))\r
+ goto cleanup;\r
+\r
+ if ((code = pkrb5_build_principal(ctx,\r
+ &server,\r
+ krb5_princ_realm(ctx, me)->length,\r
+ krb5_princ_realm(ctx, me)->data,\r
+ "krbtgt",\r
+ krb5_princ_realm(ctx, me)->data,\r
+ NULL))) {\r
+ goto cleanup;\r
+ }\r
+ \r
+ increds.client = me;\r
+ increds.server = server;\r
+ increds.times.endtime = 0;\r
+ increds.keyblock.enctype = ENCTYPE_DES_CBC_CRC;\r
+ if ((code = pkrb5_get_credentials(ctx, 0,\r
+ cc,\r
+ &increds,\r
+ &v5creds))) {\r
+ goto cleanup;\r
+ }\r
+\r
+ if ((icode = pkrb524_convert_creds_kdc(ctx,\r
+ v5creds,\r
+ v4creds))) {\r
+ goto cleanup;\r
+ }\r
+\r
+ /* initialize ticket cache */\r
+ if ((icode = pkrb_in_tkt(v4creds->pname, v4creds->pinst, v4creds->realm)\r
+ != KSUCCESS)) {\r
+ goto cleanup;\r
+ }\r
+ /* stash ticket, session key, etc. for future use */\r
+ if ((icode = pkrb_save_credentials(v4creds->service,\r
+ v4creds->instance,\r
+ v4creds->realm,\r
+ v4creds->session,\r
+ v4creds->lifetime,\r
+ v4creds->kvno,\r
+ &(v4creds->ticket_st),\r
+ v4creds->issue_date))) {\r
+ goto cleanup;\r
+ }\r
+\r
+ cleanup:\r
+ memset(v4creds, 0, sizeof(v4creds));\r
+ free(v4creds);\r
+\r
+ if (v5creds) {\r
+ pkrb5_free_creds(ctx, v5creds);\r
+ }\r
+ if (increds.client == me)\r
+ me = 0;\r
+ if (increds.server == server)\r
+ server = 0;\r
+\r
+ if (ctx)\r
+ pkrb5_free_cred_contents(ctx, &increds);\r
+\r
+ if (server) {\r
+ pkrb5_free_principal(ctx, server);\r
+ }\r
+\r
+ if (me) {\r
+ pkrb5_free_principal(ctx, me);\r
+ }\r
+\r
+ if (ctx && cc)\r
+ pkrb5_cc_close(ctx, cc);\r
+\r
+ if (ctx) {\r
+ pkrb5_free_context(ctx);\r
+ }\r
+\r
+ return (code || icode);\r
+#endif /* NO_KRB5 */ \r
+}\r
+\r
+long\r
+khm_krb4_kinit(char * aname,\r
+ char * inst,\r
+ char * realm,\r
+ long lifetime,\r
+ char * password) {\r
+\r
+ wchar_t * functionName = NULL;\r
+ wchar_t * err_context = NULL;\r
+ int rc4 = 0;\r
+ int msg = 0;\r
+\r
+ if (pkname_parse == NULL) {\r
+ goto cleanup;\r
+ }\r
+\r
+ err_context = L"getting realm";\r
+ if (!*realm && (rc4 = (int)(*pkrb_get_lrealm)(realm, 1))) {\r
+ functionName = L"krb_get_lrealm()";\r
+ msg = IDS_ERR_REALM;\r
+ goto cleanup;\r
+ }\r
+\r
+ err_context = L"checking principal";\r
+ if ((!*aname) || (!(rc4 = (int)(*pk_isname)(aname)))) {\r
+ functionName = L"krb_get_lrealm()";\r
+ msg = IDS_ERR_PRINCIPAL;\r
+ goto cleanup;\r
+ }\r
+\r
+ /* optional instance */\r
+ if (!(rc4 = (int)(*pk_isinst)(inst))) {\r
+ functionName = L"k_isinst()";\r
+ msg = IDS_ERR_INVINST;\r
+ goto cleanup;\r
+ }\r
+\r
+ if (!(rc4 = (int)(*pk_isrealm)(realm))) {\r
+ functionName = L"k_isrealm()";\r
+ msg = IDS_ERR_REALM;\r
+ goto cleanup;\r
+ }\r
+\r
+ err_context = L"fetching ticket"; \r
+ rc4 = (*pkrb_get_pw_in_tkt)(aname, inst, realm, "krbtgt", realm, \r
+ lifetime, password);\r
+\r
+ if (rc4) /* XXX: do we want: && (rc != NO_TKT_FIL) as well? */ { \r
+ functionName = L"krb_get_pw_in_tkt()";\r
+ msg = IDS_ERR_PWINTKT;\r
+ goto cleanup;\r
+ }\r
+\r
+ return 0;\r
+\r
+ cleanup:\r
+ {\r
+ _report_sr0(KHERR_ERROR, msg);\r
+ _location(functionName);\r
+ }\r
+ return rc4;\r
+}\r
+\r
+\r
+int khm_krb4_kdestroy(void) {\r
+ int k_errno = 0;\r
+\r
+ if (pdest_tkt != NULL)\r
+ {\r
+ k_errno = (*pdest_tkt)();\r
+ if (k_errno && (k_errno != RET_TKFIL))\r
+ return KRBERR(k_errno);\r
+ }\r
+\r
+ return k_errno;\r
+}\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
\r
#define KRB5_DEFAULT_LIFE 60*60*10 /* 10 hours */\r
\r
-// Function Prototypes.\r
-BOOL khm_krb5_ms2mit(BOOL);\r
-\r
-int\r
-khm_krb5_kinit(krb5_context alt_ctx,\r
- char * principal_name,\r
- char * password,\r
- krb5_deltat lifetime,\r
- DWORD forwardable,\r
- DWORD proxiable,\r
- krb5_deltat renew_life,\r
- DWORD addressless,\r
- DWORD publicIP,\r
- krb5_prompter_fct prompter,\r
- void * p_data\r
- );\r
-\r
-long\r
-Leash_int_kinit_ex(\r
- krb5_context ctx,\r
- HWND hParent,\r
- char * principal, \r
- char * password, \r
- int lifetime,\r
- int forwardable,\r
- int proxiable,\r
- int renew_life,\r
- int addressless,\r
- unsigned long publicIP,\r
- int displayErrors\r
- );\r
\r
long\r
-Leash_int_checkpwd(\r
- char * principal,\r
- char * password,\r
- int displayErrors\r
- );\r
-\r
-long\r
-Leash_int_changepwd(\r
- char * principal, \r
- char * password, \r
- char * newpassword,\r
- char** result_string,\r
- int displayErrors\r
- );\r
-\r
-int\r
-Leash_krb5_kdestroy(\r
- void\r
- );\r
-\r
-int\r
-Leash_krb5_kinit(\r
- krb5_context,\r
- HWND hParent,\r
- char * principal_name, \r
- char * password,\r
- krb5_deltat lifetime,\r
- DWORD forwardable,\r
- DWORD proxiable,\r
- krb5_deltat renew_life,\r
- DWORD addressless,\r
- DWORD publicIP\r
- );\r
+khm_convert524(khm_handle identity);\r
\r
long\r
-khm_convert524(\r
- krb5_context ctx\r
- );\r
- \r
-int\r
-Leash_afs_unlog(\r
- void\r
- );\r
+khm_krb4_kinit(char * aname,\r
+ char * inst,\r
+ char * realm,\r
+ long lifetime,\r
+ char * password); \r
\r
-int\r
-Leash_afs_klog(\r
- char *, \r
- char *, \r
- char *, \r
- int\r
- );\r
+long \r
+khm_krb4_list_tickets(void);\r
\r
-int \r
-LeashKRB5_renew(void);\r
+int khm_krb4_kdestroy(void);\r
\r
LONG\r
write_registry_setting(\r
const char *s\r
);\r
\r
-\r
wchar_t * khm_krb5_get_default_realm(void);\r
wchar_t * khm_krb5_get_realm_list(void);\r
-long khm_krb5_list_tickets(krb5_context *krbv5Context);\r
-long khm_krb4_list_tickets(void);\r
-\r
\r
#endif\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
khm_int32 attr_id_tkt_enctype = -1;\r
khm_int32 attr_id_addr_list = -1;\r
khm_int32 attr_id_krb5_flags = -1;\r
-khm_int32 attr_id_renew_till = -1;\r
-khm_int32 attr_id_renew_for = -1;\r
\r
khm_handle csp_plugins = NULL;\r
khm_handle csp_krbcred = NULL;\r
if(KHM_FAILED(rv = init_error_funcs()))\r
goto _exit;\r
\r
- /* Lookup common data types */\r
- if(KHM_FAILED(kcdb_type_get_id(TYPENAME_ENCTYPE, &type_id_enctype))) {\r
- goto _exit;\r
- }\r
-\r
- if(KHM_FAILED(kcdb_type_get_id(TYPENAME_ADDR_LIST, &type_id_addr_list))) {\r
- goto _exit;\r
- }\r
-\r
- if(KHM_FAILED(kcdb_type_get_id(TYPENAME_KRB5_FLAGS, &type_id_krb5_flags))) {\r
- goto _exit;\r
- }\r
-\r
- /* Lookup common attributes */\r
- if(KHM_FAILED(kcdb_attrib_get_id(ATTRNAME_KEY_ENCTYPE, &attr_id_key_enctype))) {\r
- goto _exit;\r
- }\r
-\r
- if(KHM_FAILED(kcdb_attrib_get_id(ATTRNAME_TKT_ENCTYPE, &attr_id_tkt_enctype))) {\r
- goto _exit;\r
- }\r
-\r
- if(KHM_FAILED(kcdb_attrib_get_id(ATTRNAME_ADDR_LIST, &attr_id_addr_list))) {\r
- goto _exit;\r
- }\r
-\r
- if(KHM_FAILED(kcdb_attrib_get_id(ATTRNAME_KRB5_FLAGS, &attr_id_krb5_flags))) {\r
- goto _exit;\r
- }\r
-\r
- if(KHM_FAILED(kcdb_attrib_get_id(ATTRNAME_RENEW_TILL, &attr_id_renew_till))) {\r
- goto _exit;\r
- }\r
-\r
- if(KHM_FAILED(kcdb_attrib_get_id(ATTRNAME_RENEW_FOR, &attr_id_renew_for))) {\r
- goto _exit;\r
- }\r
-\r
rv = kmm_get_plugins_config(0, &csp_plugins);\r
if(KHM_FAILED(rv)) goto _exit;\r
\r
--- /dev/null
+/*\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#include<krbcred.h>\r
+#include<kherror.h>\r
+#include<khmsgtypes.h>\r
+#include<khuidefs.h>\r
+#include<utils.h>\r
+#include<commctrl.h>\r
+#include<strsafe.h>\r
+#include<krb5.h>\r
+#include<assert.h>\r
+\r
+#define K4_METHOD_AUTO 0\r
+#define K4_METHOD_PASSWORD 1\r
+#define K4_METHOD_K524 2\r
+\r
+int method_to_id[] = {\r
+ IDC_NCK4_AUTO,\r
+ IDC_NCK4_PWD,\r
+ IDC_NCK4_K524\r
+};\r
+\r
+typedef struct tag_k4_dlg_data {\r
+ HWND hwnd;\r
+ khui_new_creds * nc;\r
+ khui_new_creds_by_type * nct;\r
+\r
+ khm_boolean k4_enabled;\r
+ khm_int32 method;\r
+ time_t lifetime;\r
+} k4_dlg_data;\r
+\r
+void k4_update_display(k4_dlg_data * d) {\r
+ CheckDlgButton(d->hwnd, IDC_NCK4_OBTAIN,\r
+ (d->k4_enabled)?BST_CHECKED: BST_UNCHECKED);\r
+\r
+ if (d->k4_enabled) {\r
+ EnableWindow(GetDlgItem(d->hwnd, IDC_NCK4_AUTO), TRUE);\r
+ EnableWindow(GetDlgItem(d->hwnd, IDC_NCK4_PWD ), TRUE);\r
+ EnableWindow(GetDlgItem(d->hwnd, IDC_NCK4_K524), TRUE);\r
+ } else {\r
+ EnableWindow(GetDlgItem(d->hwnd, IDC_NCK4_AUTO), FALSE);\r
+ EnableWindow(GetDlgItem(d->hwnd, IDC_NCK4_PWD ), FALSE);\r
+ EnableWindow(GetDlgItem(d->hwnd, IDC_NCK4_K524), FALSE);\r
+ }\r
+\r
+ CheckRadioButton(d->hwnd, IDC_NCK4_AUTO, IDC_NCK4_K524,\r
+ method_to_id[d->method]);\r
+}\r
+\r
+void k4_update_data(k4_dlg_data * d) {\r
+ int i;\r
+ khm_boolean oldstate;\r
+\r
+ oldstate = d->k4_enabled;\r
+\r
+ if (IsDlgButtonChecked(d->hwnd, IDC_NCK4_OBTAIN) == BST_CHECKED)\r
+ d->k4_enabled = TRUE;\r
+ else\r
+ d->k4_enabled = FALSE;\r
+\r
+ if ((oldstate && !d->k4_enabled) ||\r
+ (!oldstate && d->k4_enabled)) {\r
+\r
+ khui_cw_enable_type(d->nc, credtype_id_krb4, d->k4_enabled);\r
+ }\r
+\r
+ d->method = 0;\r
+\r
+ for (i=K4_METHOD_AUTO; i<=K4_METHOD_K524; i++) {\r
+ if (IsDlgButtonChecked(d->hwnd, method_to_id[i]) == BST_CHECKED) {\r
+ d->method = i;\r
+ break;\r
+ }\r
+ }\r
+}\r
+\r
+void k4_read_identity_data(k4_dlg_data * d) {\r
+ khm_handle csp_ident = NULL;\r
+ khm_handle csp_k4 = NULL;\r
+\r
+ khm_int32 idflags = 0;\r
+ khm_int32 t;\r
+\r
+ if (KHM_SUCCEEDED(khc_read_int32(csp_params, L"Krb4NewCreds", &t)))\r
+ d->k4_enabled = !!t;\r
+ else\r
+ d->k4_enabled = TRUE;\r
+\r
+ if (KHM_SUCCEEDED(khc_read_int32(csp_params, L"Krb4Method", &t)))\r
+ d->method = t;\r
+ else\r
+ d->method = K4_METHOD_AUTO;\r
+\r
+ if (KHM_SUCCEEDED(khc_read_int32(csp_params, L"DefaultLifetime", &t)))\r
+ d->lifetime = t;\r
+ else\r
+ d->lifetime = 10 * 60 * 60; /* 10 hours */\r
+\r
+ if (d->nc->n_identities > 0 &&\r
+ d->nc->identities[0]) {\r
+\r
+ if (KHM_SUCCEEDED(kcdb_identity_get_config(d->nc->identities[0],\r
+ 0,\r
+ &csp_ident))) {\r
+\r
+ khc_open_space(csp_ident, CSNAME_KRB4CRED, 0, &csp_k4);\r
+ \r
+ if (csp_k4) {\r
+ if (KHM_SUCCEEDED(khc_read_int32(csp_k4, L"Krb4NewCreds", &t)))\r
+ d->k4_enabled = !!t;\r
+ if (KHM_SUCCEEDED(khc_read_int32(csp_k4, L"Krb4Method", &t)))\r
+ d->method = t;\r
+ khc_close_space(csp_k4);\r
+ }\r
+\r
+ khc_close_space(csp_ident);\r
+\r
+ kcdb_identity_get_flags(d->nc->identities[0], &idflags);\r
+ }\r
+\r
+ if (!(idflags & KCDB_IDENT_FLAG_DEFAULT)) {\r
+ /* we only support k4 for one identity, and that is the\r
+ default identity. If we are trying to get tickets for\r
+ a non-default identity, then we start off as\r
+ disabled. */\r
+\r
+ khm_handle defident = NULL;\r
+\r
+ if (KHM_SUCCEEDED(kcdb_identity_get_default(&defident))) {\r
+ kcdb_identity_release(defident);\r
+\r
+ d->k4_enabled = FALSE;\r
+ }\r
+ }\r
+ } else {\r
+ d->k4_enabled = FALSE;\r
+ }\r
+\r
+ if (d->method < 0 || d->method > K4_METHOD_K524)\r
+ d->method = K4_METHOD_AUTO;\r
+}\r
+\r
+void k4_write_identity_data(k4_dlg_data * d) {\r
+ khm_handle csp_ident = NULL;\r
+ khm_handle csp_k4 = NULL;\r
+\r
+ if (d->nc->n_identities > 0 &&\r
+ d->nc->identities[0] &&\r
+ KHM_SUCCEEDED(kcdb_identity_get_config(d->nc->identities[0],\r
+ KHM_FLAG_CREATE,\r
+ &csp_ident))) {\r
+ khc_open_space(csp_ident, CSNAME_KRB4CRED, KHM_FLAG_CREATE, &csp_k4);\r
+\r
+ if (csp_k4) {\r
+ khc_write_int32(csp_k4, L"Krb4NewCreds", !!d->k4_enabled);\r
+ khc_write_int32(csp_k4, L"Krb4Method", d->method);\r
+\r
+ khc_close_space(csp_k4);\r
+ }\r
+\r
+ khc_close_space(csp_ident);\r
+ }\r
+}\r
+\r
+void k4_handle_wmnc_notify(k4_dlg_data * d,\r
+ WPARAM wParam,\r
+ LPARAM lParam) {\r
+ switch(HIWORD(wParam)) {\r
+ case WMNC_UPDATE_CREDTEXT:\r
+ {\r
+ if (d->nct->credtext) {\r
+ PFREE(d->nct->credtext);\r
+ d->nct->credtext = NULL;\r
+ }\r
+\r
+ if (d->nc->n_identities > 0 &&\r
+ d->nc->identities[0]) {\r
+\r
+ khm_int32 flags = 0;\r
+ wchar_t idname[KCDB_IDENT_MAXCCH_NAME];\r
+ wchar_t * atsign;\r
+ wchar_t * realm;\r
+ khm_size cb;\r
+\r
+ kcdb_identity_get_flags(d->nc->identities[0], &flags);\r
+\r
+ if (flags & KCDB_IDENT_FLAG_INVALID)\r
+ break;\r
+\r
+ cb = sizeof(idname);\r
+ kcdb_identity_get_name(d->nc->identities[0], idname,\r
+ &cb);\r
+\r
+ atsign = wcsrchr(idname, L'@');\r
+\r
+ if (atsign == NULL || !atsign[1])\r
+ break;\r
+\r
+ realm = ++atsign;\r
+\r
+ if (d->k4_enabled) {\r
+ wchar_t wmethod[128];\r
+ wchar_t wfmt[128];\r
+ wchar_t wct[512];\r
+\r
+ LoadString(hResModule, IDS_CT_TGTFOR,\r
+ wfmt, ARRAYLENGTH(wfmt));\r
+\r
+ if (d->method == K4_METHOD_AUTO)\r
+ LoadString(hResModule, IDS_METHOD_AUTO, wmethod,\r
+ ARRAYLENGTH(wmethod));\r
+ else if (d->method == K4_METHOD_PASSWORD)\r
+ LoadString(hResModule, IDS_METHOD_PWD, wmethod,\r
+ ARRAYLENGTH(wmethod));\r
+ else if (d->method == K4_METHOD_K524)\r
+ LoadString(hResModule, IDS_METHOD_K524, wmethod,\r
+ ARRAYLENGTH(wmethod));\r
+ else {\r
+ assert(FALSE);\r
+ }\r
+\r
+ StringCbPrintf(wct, sizeof(wct), wfmt, realm, wmethod);\r
+\r
+ StringCbLength(wct, sizeof(wct), &cb);\r
+ cb += sizeof(wchar_t);\r
+\r
+ d->nct->credtext = PMALLOC(cb);\r
+\r
+ StringCbCopy(d->nct->credtext, cb, wct);\r
+ } else {\r
+ wchar_t wct[256];\r
+\r
+ LoadString(hResModule, IDS_CT_DISABLED,\r
+ wct, ARRAYLENGTH(wct));\r
+\r
+ StringCbLength(wct, sizeof(wct), &cb);\r
+ cb += sizeof(wchar_t);\r
+\r
+ d->nct->credtext = PMALLOC(cb);\r
+\r
+ StringCbCopy(d->nct->credtext, cb, wct);\r
+ }\r
+ }\r
+ /* no identities were selected. it is not the\r
+ responsibility of krb4 to complain about this. */\r
+ }\r
+ break;\r
+\r
+ case WMNC_IDENTITY_CHANGE:\r
+ k4_read_identity_data(d);\r
+ k4_update_display(d);\r
+ break;\r
+\r
+ case WMNC_CREDTEXT_LINK:\r
+ {\r
+ wchar_t wid[KHUI_MAXCCH_HTLINK_FIELD];\r
+ wchar_t * wids;\r
+ khui_htwnd_link * l;\r
+\r
+ l = (khui_htwnd_link *) lParam;\r
+\r
+ wcsncpy(wid, l->id, l->id_len);\r
+ wid[l->id_len] = 0;\r
+ wids = wcschr(wid, L':');\r
+\r
+ if (!wids)\r
+ break;\r
+ else\r
+ wids++;\r
+\r
+ if (!wcscmp(wids, L"Enable")) {\r
+ d->k4_enabled = TRUE;\r
+\r
+ k4_update_display(d);\r
+ khui_cw_enable_type(d->nc, credtype_id_krb4, TRUE);\r
+ }\r
+ }\r
+ break;\r
+ }\r
+}\r
+\r
+INT_PTR CALLBACK k4_nc_dlg_proc(HWND hwnd,\r
+ UINT uMsg,\r
+ WPARAM wParam,\r
+ LPARAM lParam) {\r
+\r
+ k4_dlg_data * d;\r
+\r
+ switch(uMsg) {\r
+ case WM_INITDIALOG:\r
+ {\r
+ d = PMALLOC(sizeof(*d));\r
+ ZeroMemory(d, sizeof(*d));\r
+\r
+ d->nc = (khui_new_creds *) lParam;\r
+ khui_cw_find_type(d->nc, credtype_id_krb4, &d->nct);\r
+\r
+#pragma warning(push)\r
+#pragma warning(disable: 4244)\r
+ SetWindowLongPtr(hwnd, DWLP_USER, (LPARAM) d);\r
+#pragma warning(pop)\r
+\r
+ d->nct->aux = (LPARAM) d;\r
+ d->hwnd = hwnd;\r
+\r
+ d->k4_enabled = TRUE;\r
+ d->method = K4_METHOD_AUTO;\r
+\r
+ k4_update_display(d);\r
+ }\r
+ break;\r
+\r
+ case WM_COMMAND:\r
+ {\r
+ d = (k4_dlg_data *) (LONG_PTR)\r
+ GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+ k4_update_data(d);\r
+ k4_update_display(d);\r
+ }\r
+ break;\r
+\r
+ case KHUI_WM_NC_NOTIFY:\r
+ {\r
+ d = (k4_dlg_data *) (LONG_PTR)\r
+ GetWindowLongPtr(hwnd, DWLP_USER);\r
+ k4_handle_wmnc_notify(d, wParam, lParam);\r
+ }\r
+ break;\r
+\r
+ case WM_DESTROY:\r
+ {\r
+ d = (k4_dlg_data *) (LONG_PTR)\r
+ GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+ d->nct->aux = 0;\r
+\r
+ PFREE(d);\r
+ }\r
+ break;\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r
+khm_int32\r
+krb4_msg_newcred(khm_int32 msg_type, khm_int32 msg_subtype,\r
+ khm_ui_4 uparam, void * vparam) {\r
+\r
+ switch(msg_subtype) {\r
+ case KMSG_CRED_NEW_CREDS:\r
+ {\r
+ khui_new_creds * nc;\r
+ khui_new_creds_by_type * nct;\r
+ khm_size cbsize;\r
+ wchar_t wbuf[256];\r
+\r
+ nc = (khui_new_creds *) vparam;\r
+\r
+ nct = PMALLOC(sizeof(*nct));\r
+#ifdef DEBUG\r
+ assert(nct);\r
+#endif\r
+ ZeroMemory(nct, sizeof(*nct));\r
+\r
+ nct->type = credtype_id_krb4;\r
+ nct->ordinal = 3;\r
+ LoadString(hResModule, IDS_NC_K4_SHORT,\r
+ wbuf, ARRAYLENGTH(wbuf));\r
+ StringCbLength(wbuf, sizeof(wbuf), &cbsize);\r
+ cbsize += sizeof(wchar_t);\r
+\r
+ nct->name = PMALLOC(cbsize);\r
+ StringCbCopy(nct->name, cbsize, wbuf);\r
+\r
+ nct->type_deps[nct->n_type_deps++] = credtype_id_krb5;\r
+\r
+ nct->h_module = hResModule;\r
+ nct->dlg_proc = k4_nc_dlg_proc;\r
+ nct->dlg_template = MAKEINTRESOURCE(IDD_NC_KRB4);\r
+\r
+ khui_cw_add_type(nc, nct);\r
+ }\r
+ break;\r
+\r
+ case KMSG_CRED_RENEW_CREDS:\r
+ {\r
+ khui_new_creds * nc;\r
+ khui_new_creds_by_type * nct;\r
+ khm_size cbsize;\r
+ wchar_t wbuf[256];\r
+\r
+ nc = (khui_new_creds *) vparam;\r
+\r
+ nct = PMALLOC(sizeof(*nct));\r
+#ifdef DEBUG\r
+ assert(nct);\r
+#endif\r
+\r
+ ZeroMemory(nct, sizeof(*nct));\r
+\r
+ nct->type = credtype_id_krb4;\r
+ nct->ordinal = 3;\r
+ LoadString(hResModule, IDS_NC_K4_SHORT,\r
+ wbuf, ARRAYLENGTH(wbuf));\r
+ StringCbLength(wbuf, sizeof(wbuf), &cbsize);\r
+ cbsize += sizeof(wchar_t);\r
+\r
+ nct->name = PMALLOC(cbsize);\r
+ StringCbCopy(nct->name, cbsize, wbuf);\r
+\r
+ nct->type_deps[nct->n_type_deps++] = credtype_id_krb5;\r
+\r
+ khui_cw_add_type(nc, nct);\r
+ }\r
+ break;\r
+\r
+ case KMSG_CRED_DIALOG_SETUP:\r
+ break;\r
+\r
+ case KMSG_CRED_PROCESS:\r
+ {\r
+ khui_new_creds * nc;\r
+ khui_new_creds_by_type * nct = NULL;\r
+ khm_handle ident = NULL;\r
+ k4_dlg_data * d = NULL;\r
+ long code = 0;\r
+\r
+ nc = (khui_new_creds *) vparam;\r
+ if (KHM_FAILED(khui_cw_find_type(nc, credtype_id_krb4, &nct)))\r
+ break;\r
+\r
+ if (nc->subtype == KMSG_CRED_NEW_CREDS ||\r
+ nc->subtype == KMSG_CRED_RENEW_CREDS) {\r
+ khm_int32 method;\r
+\r
+ if (nc->subtype == KMSG_CRED_NEW_CREDS) {\r
+\r
+ d = (k4_dlg_data *) nct->aux;\r
+ if (!d ||\r
+ nc->n_identities == 0 ||\r
+ nc->identities[0] == NULL ||\r
+ nc->result != KHUI_NC_RESULT_GET_CREDS)\r
+ break;\r
+\r
+ if (!d->k4_enabled) {\r
+ k4_write_identity_data(d);\r
+ break;\r
+ }\r
+\r
+ method = d->method;\r
+ ident = nc->identities[0];\r
+\r
+ } else if (nc->subtype == KMSG_CRED_RENEW_CREDS) {\r
+\r
+ if ((nc->ctx.scope == KHUI_SCOPE_IDENT &&\r
+ nc->ctx.identity != NULL) ||\r
+\r
+ (nc->ctx.scope == KHUI_SCOPE_CREDTYPE &&\r
+ nc->ctx.cred_type == credtype_id_krb4 &&\r
+ nc->ctx.identity != NULL) ||\r
+\r
+ (nc->ctx.scope == KHUI_SCOPE_CRED &&\r
+ nc->ctx.cred_type == credtype_id_krb4 &&\r
+ nc->ctx.identity != NULL &&\r
+ nc->ctx.cred != NULL)) {\r
+\r
+ ident = nc->ctx.identity;\r
+\r
+ } else {\r
+ break;\r
+ }\r
+\r
+ method = K4_METHOD_K524; /* only k524 is supported\r
+ for renewals */\r
+ } else {\r
+ assert(FALSE);\r
+ }\r
+\r
+ if ((method == K4_METHOD_AUTO ||\r
+ method == K4_METHOD_K524) &&\r
+ khui_cw_type_succeeded(nc, credtype_id_krb5)) {\r
+\r
+ code = khm_convert524(ident);\r
+\r
+ if (code == 0) {\r
+ khui_cw_set_response(nc, credtype_id_krb4,\r
+ KHUI_NC_RESPONSE_SUCCESS |\r
+ KHUI_NC_RESPONSE_EXIT);\r
+\r
+ if (nc->subtype == KMSG_CRED_NEW_CREDS) {\r
+ assert(d != NULL);\r
+\r
+ k4_write_identity_data(d);\r
+ }\r
+ break;\r
+ } else if (method == K4_METHOD_K524) {\r
+ khui_cw_set_response(nc, credtype_id_krb4,\r
+ KHUI_NC_RESPONSE_FAILED |\r
+ KHUI_NC_RESPONSE_EXIT);\r
+ break;\r
+ }\r
+ }\r
+\r
+ /* only supported for new credentials */\r
+ if (method == K4_METHOD_AUTO ||\r
+ method == K4_METHOD_PASSWORD) {\r
+ \r
+ khm_size n_prompts = 0;\r
+ khm_size idx;\r
+ khm_size cb;\r
+ wchar_t wpwd[KHUI_MAXCCH_PROMPT_VALUE];\r
+ char pwd[KHUI_MAXCCH_PROMPT_VALUE];\r
+ wchar_t widname[KCDB_IDENT_MAXCCH_NAME];\r
+ char idname[KCDB_IDENT_MAXCCH_NAME];\r
+\r
+ char * aname = NULL;\r
+ char * inst = NULL;\r
+ char * realm = NULL;\r
+\r
+ assert(nc->subtype == KMSG_CRED_NEW_CREDS);\r
+\r
+ code = TRUE; /* just has to be non-zero */\r
+\r
+ khui_cw_get_prompt_count(nc, &n_prompts);\r
+\r
+ if (n_prompts == 0)\r
+ goto _skip_pwd;\r
+\r
+ for (idx = 0; idx < n_prompts; idx++) {\r
+ khui_new_creds_prompt * p;\r
+\r
+ if (KHM_FAILED(khui_cw_get_prompt(nc, idx, &p)))\r
+ continue;\r
+\r
+ if (p->type == KHUI_NCPROMPT_TYPE_PASSWORD)\r
+ break;\r
+ }\r
+\r
+ if (idx >= n_prompts)\r
+ goto _skip_pwd;\r
+\r
+ khui_cw_sync_prompt_values(nc);\r
+\r
+ cb = sizeof(wpwd);\r
+ if (KHM_FAILED(khui_cw_get_prompt_value(nc, idx,\r
+ wpwd,\r
+ &cb)))\r
+ goto _skip_pwd;\r
+\r
+ UnicodeStrToAnsi(pwd, sizeof(pwd), wpwd);\r
+\r
+ cb = sizeof(widname);\r
+ kcdb_identity_get_name(ident,\r
+ widname,\r
+ &cb);\r
+\r
+ UnicodeStrToAnsi(idname, sizeof(idname), widname);\r
+\r
+ {\r
+ char * atsign;\r
+\r
+ atsign = strchr(idname, '@');\r
+ if (atsign == NULL)\r
+ goto _skip_pwd;\r
+\r
+ *atsign++ = 0;\r
+\r
+ realm = atsign;\r
+ }\r
+\r
+ {\r
+ char * slash;\r
+\r
+ slash = strchr(idname, '/');\r
+ if (slash != NULL) {\r
+ *slash++ = 0;\r
+ inst = slash;\r
+ } else {\r
+ inst = "";\r
+ }\r
+ }\r
+\r
+ aname = idname;\r
+\r
+ code = khm_krb4_kinit(aname, inst, realm,\r
+ (long) d->lifetime, pwd);\r
+ _skip_pwd:\r
+\r
+ if (code) {\r
+ khui_cw_set_response(nc, credtype_id_krb4,\r
+ KHUI_NC_RESPONSE_EXIT |\r
+ KHUI_NC_RESPONSE_FAILED);\r
+\r
+ } else {\r
+ khui_cw_set_response(nc, credtype_id_krb4,\r
+ KHUI_NC_RESPONSE_EXIT |\r
+ KHUI_NC_RESPONSE_SUCCESS);\r
+\r
+ if (nc->subtype == KMSG_CRED_NEW_CREDS) {\r
+\r
+ assert(d != NULL);\r
+ k4_write_identity_data(d);\r
+\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ break;\r
+\r
+ case KMSG_CRED_END:\r
+ {\r
+ khui_new_creds * nc;\r
+ khui_new_creds_by_type * nct = NULL;\r
+\r
+ nc = (khui_new_creds *) vparam;\r
+ if (KHM_FAILED(khui_cw_find_type(nc, credtype_id_krb4, &nct)))\r
+ break;\r
+\r
+ khui_cw_del_type(nc, credtype_id_krb4);\r
+\r
+ if (nct->name)\r
+ PFREE(nct->name);\r
+\r
+ PFREE(nct);\r
+ }\r
+ break;\r
+ }\r
+\r
+ return KHM_ERROR_SUCCESS;\r
+}\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
#include<kherror.h>\r
#include<khmsgtypes.h>\r
#include<khuidefs.h>\r
+#include<utils.h>\r
#include<commctrl.h>\r
#include<strsafe.h>\r
#include<krb5.h>\r
\r
khm_int32 credtype_id_krb4 = KCDB_CREDTYPE_INVALID;\r
+khm_int32 credtype_id_krb5 = KCDB_CREDTYPE_INVALID;\r
+\r
khm_boolean krb4_initialized = FALSE;\r
khm_handle krb4_credset = NULL;\r
\r
{\r
StringCbLength(buf, KCDB_MAXCB_SHORT_DESC, &cbsize);\r
cbsize += sizeof(wchar_t);\r
- ct.short_desc = malloc(cbsize);\r
+ ct.short_desc = PMALLOC(cbsize);\r
StringCbCopy(ct.short_desc, cbsize, buf);\r
}\r
\r
{\r
StringCbLength(buf, KCDB_MAXCB_SHORT_DESC, &cbsize);\r
cbsize += sizeof(wchar_t);\r
- ct.long_desc = malloc(cbsize);\r
+ ct.long_desc = PMALLOC(cbsize);\r
StringCbCopy(ct.long_desc, cbsize, buf);\r
}\r
\r
if(KHM_SUCCEEDED(rv))\r
rv = kcdb_credset_create(&krb4_credset);\r
\r
+ if (KHM_SUCCEEDED(rv))\r
+ rv = kcdb_credtype_get_id(KRB5_CREDTYPE_NAME, \r
+ &credtype_id_krb5);\r
+\r
if(ct.short_desc)\r
- free(ct.short_desc);\r
+ PFREE(ct.short_desc);\r
\r
if(ct.long_desc)\r
- free(ct.long_desc);\r
+ PFREE(ct.long_desc);\r
+\r
+ if (KHM_SUCCEEDED(rv)) {\r
+ khui_config_node idents;\r
+\r
+ ZeroMemory(®, sizeof(reg));\r
+\r
+ reg.name = KRB4_CONFIG_NODE_NAME;\r
+ reg.short_desc = wshort_desc;\r
+ reg.long_desc = wlong_desc;\r
+ reg.h_module = hResModule;\r
+ reg.dlg_template = MAKEINTRESOURCE(IDD_CFG_KRB4);\r
+ reg.dlg_proc = krb4_confg_proc;\r
+ reg.flags = 0;\r
+\r
+ LoadString(hResModule, IDS_CFG_KRB4_LONG,\r
+ wlong_desc, ARRAYLENGTH(wlong_desc));\r
+ LoadString(hResModule, IDS_CFG_KRB4_SHORT,\r
+ wshort_desc, ARRAYLENGTH(wshort_desc));\r
+\r
+ khui_cfg_register(NULL, ®);\r
+\r
+ khui_cfg_open(NULL, L"KhmIdentities", &idents);\r
+\r
+ ZeroMemory(®, sizeof(reg));\r
+\r
+ reg.name = KRB4_IDS_CONFIG_NODE_NAME;\r
+ reg.short_desc = wshort_desc;\r
+ reg.long_desc = wlong_desc;\r
+ reg.h_module = hResModule;\r
+ reg.dlg_template = MAKEINTRESOURCE(IDD_CFG_IDS_KRB4);\r
+ reg.dlg_proc = krb4_ids_config_proc;\r
+ reg.flags = KHUI_CNFLAG_SUBPANEL;\r
+\r
+ LoadString(hResModule, IDS_CFG_KRB4_SHORT,\r
+ wlong_desc, ARRAYLENGTH(wlong_desc));\r
+ LoadString(hResModule, IDS_CFG_KRB4_SHORT,\r
+ wshort_desc, ARRAYLENGTH(wshort_desc));\r
+\r
+ khui_cfg_register(idents, ®);\r
\r
- ZeroMemory(®, sizeof(reg));\r
+ ZeroMemory(®, sizeof(reg));\r
\r
- reg.name = KRB4_CONFIG_NODE_NAME;\r
- reg.short_desc = wshort_desc;\r
- reg.long_desc = wlong_desc;\r
- reg.h_module = hResModule;\r
- reg.dlg_template = MAKEINTRESOURCE(IDD_CFG_KRB4);\r
- reg.dlg_proc = krb4_confg_proc;\r
- reg.flags = 0;\r
+ reg.name = KRB4_ID_CONFIG_NODE_NAME;\r
+ reg.short_desc = wshort_desc;\r
+ reg.long_desc = wlong_desc;\r
+ reg.h_module = hResModule;\r
+ reg.dlg_template = MAKEINTRESOURCE(IDD_CFG_ID_KRB4);\r
+ reg.dlg_proc = krb4_id_config_proc;\r
+ reg.flags = KHUI_CNFLAG_SUBPANEL | KHUI_CNFLAG_PLURAL;\r
\r
- LoadString(hResModule, IDS_CFG_KRB4_LONG,\r
- wlong_desc, ARRAYLENGTH(wlong_desc));\r
- LoadString(hResModule, IDS_CFG_KRB4_SHORT,\r
- wshort_desc, ARRAYLENGTH(wshort_desc));\r
+ LoadString(hResModule, IDS_CFG_KRB4_SHORT,\r
+ wlong_desc, ARRAYLENGTH(wlong_desc));\r
+ LoadString(hResModule, IDS_CFG_KRB4_SHORT,\r
+ wshort_desc, ARRAYLENGTH(wshort_desc));\r
\r
- khui_cfg_register(NULL, ®);\r
+ khui_cfg_register(idents, ®);\r
+\r
+ khui_cfg_release(idents);\r
\r
- if(KHM_SUCCEEDED(rv)) {\r
krb4_initialized = TRUE;\r
\r
khm_krb4_list_tickets();\r
}\r
+\r
+ /* Lookup common data types */\r
+ if(KHM_FAILED(kcdb_type_get_id(TYPENAME_ENCTYPE, \r
+ &type_id_enctype))) {\r
+ rv = KHM_ERROR_UNKNOWN;\r
+ }\r
+\r
+ if(KHM_FAILED(kcdb_type_get_id(TYPENAME_ADDR_LIST, \r
+ &type_id_addr_list))) {\r
+ rv = KHM_ERROR_UNKNOWN;\r
+ }\r
+\r
+ if(KHM_FAILED(kcdb_type_get_id(TYPENAME_KRB5_FLAGS, \r
+ &type_id_krb5_flags))) {\r
+ rv = KHM_ERROR_UNKNOWN;\r
+ }\r
+\r
+ /* Lookup common attributes */\r
+ if(KHM_FAILED(kcdb_attrib_get_id(ATTRNAME_KEY_ENCTYPE, \r
+ &attr_id_key_enctype))) {\r
+ rv = KHM_ERROR_UNKNOWN;\r
+ }\r
+\r
+ if(KHM_FAILED(kcdb_attrib_get_id(ATTRNAME_TKT_ENCTYPE, \r
+ &attr_id_tkt_enctype))) {\r
+ rv = KHM_ERROR_UNKNOWN;\r
+ }\r
+\r
+ if(KHM_FAILED(kcdb_attrib_get_id(ATTRNAME_ADDR_LIST, \r
+ &attr_id_addr_list))) {\r
+ rv = KHM_ERROR_UNKNOWN;\r
+ }\r
+\r
+ if(KHM_FAILED(kcdb_attrib_get_id(ATTRNAME_KRB5_FLAGS, \r
+ &attr_id_krb5_flags))) {\r
+ rv = KHM_ERROR_UNKNOWN;\r
+ }\r
+\r
}\r
break;\r
\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
\r
switch(msg_subtype) {\r
- case KMSG_CRED_REFRESH:\r
- {\r
- khm_krb4_list_tickets();\r
+ case KMSG_CRED_REFRESH:\r
+ {\r
+ khm_krb4_list_tickets();\r
+ }\r
+ break;\r
+\r
+ case KMSG_CRED_DESTROY_CREDS:\r
+ {\r
+ khui_action_context * ctx;\r
+ khm_handle credset;\r
+ khm_size nc_root = 0;\r
+ khm_size nc_sel = 0;\r
+\r
+ ctx = (khui_action_context *) vparam;\r
+\r
+ /* if all krb4 tickets are selected, then we destroy all\r
+ of them. Otherwise, we do nothing. */\r
+\r
+ kcdb_credset_create(&credset);\r
+\r
+ kcdb_credset_extract(credset, ctx->credset,\r
+ NULL, credtype_id_krb4);\r
+ kcdb_credset_get_size(credset, &nc_sel);\r
+\r
+ kcdb_credset_flush(credset);\r
+\r
+ kcdb_credset_extract(credset, NULL,\r
+ NULL, credtype_id_krb4);\r
+ kcdb_credset_get_size(credset, &nc_root);\r
+\r
+ kcdb_credset_delete(credset);\r
+\r
+ if (nc_root == nc_sel) {\r
+ khm_krb4_kdestroy();\r
}\r
- break;\r
+ }\r
+ break;\r
+\r
+ default:\r
+ if (IS_CRED_ACQ_MSG(msg_subtype))\r
+ return krb4_msg_newcred(msg_type, msg_subtype, uparam, vparam);\r
}\r
\r
return rv;\r
Type,KC_INT32,1,\r
Flags,KC_INT32,0,\r
Parameters,KC_SPACE,0,Parameters for KrbCred\r
+ Krb4NewCreds,KC_INT32,1,Obtain Kerberos 4 tickets\r
+ Krb4Method,KC_INT32,0,Method for acquiring K4 tix. 0-Auto;1-Password;2-K524\r
CreateMissingConfig,KC_INT32,0,Create missing configuration files\r
- MsLsaImport,KC_INT32,2,Automatically import MSLSA credentials\r
- AutoRenewTickets,KC_INT32,1,Automatically renew expiring tickets\r
DefaultLifetime,KC_INT32,36000,Default ticket lifetime\r
MaxLifetime,KC_INT32,86400,Maximum lifetime\r
MinLifetime,KC_INT32,60,Minimum lifetime\r
- Forwardable,KC_INT32,1,Obtain forwardable tickets (boolean)\r
- Proxiable,KC_INT32,0,Obtain proxiable tickets (boolean)\r
- Addressless,KC_INT32,1,Obtain addressless tickets (boolean)\r
- Renewable,KC_INT32,1,Obtain renewable tickets (boolean)\r
- DefaultRenewLifetime,KC_INT32,604800,Default renewable lifetime\r
- MaxRenewLifetime,KC_INT32,2592000,Maximum renewable lifetime\r
- MinRenewLifetime,KC_INT32,60,Maximum renewable lifetime\r
Parameters,KC_ENDSPACE,0,\r
Krb4Cred,KC_ENDSPACE,0,\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
\r
#include<windows.h>\r
\r
-#include<khdefs.h>\r
-#include<kcreddb.h>\r
-#include<kmm.h>\r
-#include<kconfig.h>\r
+#define KHERR_FACILITY L"Kerberos4"\r
+#define KHERR_FACILITY_ID 65\r
+#define KHERR_HMODULE hResModule\r
\r
+#include<netidmgr.h>\r
\r
#include<krb4funcs.h>\r
#include<krb5common.h>\r
#include<dynimport.h>\r
\r
#include<langres.h>\r
-#include<datarep.h>\r
\r
#define TYPENAME_ENCTYPE L"EncType"\r
#define TYPENAME_ADDR_LIST L"AddrList"\r
\r
#define KRB4_CREDTYPE_NAME L"Krb4Cred"\r
\r
+#define KRB5_CREDTYPE_NAME L"Krb5Cred"\r
+\r
#define KRB4_CONFIG_NODE_NAME L"Krb4Config"\r
\r
+#define KRB4_ID_CONFIG_NODE_NAME L"Krb4IdentConfig"\r
+#define KRB4_IDS_CONFIG_NODE_NAME L"Krb4IdentsConfig"\r
+\r
extern khm_handle csp_plugins;\r
extern khm_handle csp_krbcred;\r
extern khm_handle csp_params;\r
\r
/* other globals */\r
extern khm_int32 credtype_id_krb4;\r
+extern khm_int32 credtype_id_krb5;\r
\r
extern khm_boolean krb4_initialized;\r
\r
UINT uMsg,\r
WPARAM wParam,\r
LPARAM lParam);\r
+\r
+INT_PTR CALLBACK\r
+krb4_ids_config_proc(HWND hwnd,\r
+ UINT uMsg,\r
+ WPARAM wParam,\r
+ LPARAM lParam);\r
+\r
+INT_PTR CALLBACK\r
+krb4_id_config_proc(HWND hwnd,\r
+ UINT uMsg,\r
+ WPARAM wParam,\r
+ LPARAM lParam);\r
+\r
+khm_int32\r
+krb4_msg_newcred(khm_int32 msg_type, khm_int32 msg_subtype,\r
+ khm_ui_4 uparam, void * vparam);\r
#endif\r
EXSTYLE WS_EX_CONTROLPARENT\r
FONT 8, "MS Shell Dlg", 400, 0, 0x1\r
BEGIN\r
- LTEXT "kRB4",IDC_STATIC,38,43,71,24\r
+ CONTROL "Kerberos 4 Ticket Options",IDC_STATIC,"Static",\r
+ SS_LEFTNOWORDWRAP | SS_SUNKEN | WS_GROUP,7,7,286,11\r
+ CONTROL "Obtain Kerberos 4 tickets",IDC_NCK4_OBTAIN,"Button",\r
+ BS_AUTOCHECKBOX | WS_TABSTOP,7,26,97,10\r
+ CONTROL "Automatically determine method",IDC_NCK4_AUTO,"Button",\r
+ BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,23,58,119,10\r
+ CONTROL "Password",IDC_NCK4_PWD,"Button",BS_AUTORADIOBUTTON | \r
+ WS_TABSTOP,23,75,47,10\r
+ CONTROL "Kerberos 5 to 4 translation",IDC_NCK4_K524,"Button",\r
+ BS_AUTORADIOBUTTON | WS_TABSTOP,23,92,101,10\r
+ GROUPBOX "Obtain Kerberos 4 tickets using",IDC_STATIC,7,43,286,72,\r
+ WS_GROUP\r
END\r
\r
IDD_CFG_KRB4 DIALOGEX 0, 0, 255, 182\r
PUSHBUTTON "Browse...",IDC_CFG_RLMBROW,200,47,48,14\r
END\r
\r
+IDD_CFG_IDS_KRB4 DIALOGEX 0, 0, 235, 151\r
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU\r
+EXSTYLE WS_EX_CONTROLPARENT\r
+FONT 8, "MS Shell Dlg", 400, 0, 0x1\r
+BEGIN\r
+ CONTROL "Obtain Kerberos 4 tickets",IDC_CFG_GETTIX,"Button",\r
+ BS_AUTOCHECKBOX | WS_TABSTOP,7,7,221,17\r
+ LTEXT "Note that, if enabled, Kerberos 4 tickets will be acquired during initial credential acquisition and during credential renewals.\n\nHowever, currently Kerberos 4 tickets can only be obtained for the default identity.",\r
+ IDC_STATIC,7,91,221,53,SS_SUNKEN\r
+END\r
+\r
+IDD_CFG_ID_KRB4 DIALOGEX 0, 0, 235, 151\r
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU\r
+EXSTYLE WS_EX_CONTROLPARENT\r
+FONT 8, "MS Shell Dlg", 400, 0, 0x1\r
+BEGIN\r
+ CONTROL "Obtain Kerberos 4 tickets for this identity",\r
+ IDC_CFG_GETTIX,"Button",BS_AUTOCHECKBOX | WS_DISABLED | \r
+ WS_TABSTOP,7,7,147,10\r
+END\r
+\r
\r
/////////////////////////////////////////////////////////////////////////////\r
//\r
TOPMARGIN, 7\r
BOTTOMMARGIN, 175\r
END\r
+\r
+ IDD_CFG_IDS_KRB4, DIALOG\r
+ BEGIN\r
+ LEFTMARGIN, 7\r
+ RIGHTMARGIN, 228\r
+ TOPMARGIN, 7\r
+ BOTTOMMARGIN, 144\r
+ END\r
+\r
+ IDD_CFG_ID_KRB4, DIALOG\r
+ BEGIN\r
+ LEFTMARGIN, 7\r
+ RIGHTMARGIN, 228\r
+ TOPMARGIN, 7\r
+ BOTTOMMARGIN, 144\r
+ END\r
END\r
#endif // APSTUDIO_INVOKED\r
\r
STRINGTABLE \r
BEGIN\r
IDS_PLUGIN_DESC "Kerberos 4 Credentials Provider"\r
+ IDS_NC_K4_SHORT "Kerberos 4"\r
+ IDS_ERR_REALM "Could not resolve realm"\r
+ IDS_ERR_PRINCIPAL "Invalid principal"\r
+ IDS_ERR_INVINST "Invalid instance"\r
+ IDS_ERR_PWINTKT "Could not get Kerberos 4 tickets"\r
+ IDS_CT_DISABLED "<p><a id=""SwitchPanel"" param=""Krb4Cred""><b>Krb4</b></a><tab>: Disabled (click <a id=""Krb4Cred:Enable"">here</a> to enable)</p>"\r
+ IDS_CT_TGTFOR "<p><a id=""SwitchPanel"" param=""Krb4Cred""><b>Krb4</b></a><tab>: Tickets for realm %s</p>"\r
+ IDS_METHOD_AUTO "Automatically determined method"\r
END\r
\r
STRINGTABLE \r
IDS_CFG_KRB4_SHORT "Kerberos 4"\r
END\r
\r
+STRINGTABLE \r
+BEGIN\r
+ IDS_METHOD_PWD "Password"\r
+ IDS_METHOD_K524 "Kerberos 5 to 4 translation"\r
+ IDS_CFG_IDS_KRB4_SHORT "Kerberos 4"\r
+END\r
+\r
#endif // English (U.S.) resources\r
/////////////////////////////////////////////////////////////////////////////\r
\r
//{{NO_DEPENDENCIES}}\r
// Microsoft Visual C++ generated include file.\r
-// Used by D:\work\khimaira\src\plugins\krb4\lang\en_us\langres.rc\r
+// Used by D:\work\pismere\athena\auth\krb5\src\windows\identity\plugins\krb4\lang\en_us\langres.rc\r
//\r
#define IDS_UNK_ADDR_FMT 101\r
#define IDS_KRB5_CREDTEXT_0 102\r
#define IDS_PLUGIN_DESC 103\r
#define IDS_KEY_ENCTYPE_SHORT_DESC 104\r
#define IDD_CFG_KRB4 104\r
+#define IDS_NC_K4_SHORT 104\r
#define IDS_TKT_ENCTYPE_SHORT_DESC 105\r
+#define IDS_ERR_REALM 105\r
+#define IDD_CFG_IDS_KRB4 105\r
#define IDS_KEY_ENCTYPE_LONG_DESC 106\r
+#define IDS_ERR_PRINCIPAL 106\r
+#define IDD_CFG_ID_KRB4 106\r
#define IDS_TKT_ENCTYPE_LONG_DESC 107\r
+#define IDS_ERR_INVINST 107\r
#define IDS_ADDR_LIST_SHORT_DESC 108\r
+#define IDS_ERR_PWINTKT 108\r
#define IDS_ADDR_LIST_LONG_DESC 109\r
+#define IDS_CT_DISABLED 109\r
#define IDS_ETYPE_NULL 110\r
+#define IDS_CT_TGTFOR 110\r
#define IDS_ETYPE_DES_CBC_CRC 111\r
+#define IDS_METHOD_AUTO 111\r
#define IDS_ETYPE_DES_CBC_MD4 112\r
+#define IDS_METHOD_PWD 112\r
#define IDS_ETYPE_DES_CBC_MD5 113\r
+#define IDS_METHOD_K524 113\r
#define IDS_ETYPE_DES_CBC_RAW 114\r
+#define IDS_CFG_IDS_KRB4_SHORT 114\r
#define IDS_ETYPE_DES3_CBC_SHA 115\r
#define IDS_ETYPE_DES3_CBC_RAW 116\r
#define IDS_ETYPE_DES_HMAC_SHA1 117\r
#define IDC_CFG_RLMPATH 1030\r
#define IDC_CFG_CFGBROW 1031\r
#define IDC_CFG_RLMBROW 1032\r
+#define IDC_NCK4_OBTAIN 1033\r
+#define IDC_NCK4_PWD 1034\r
+#define IDC_NCK4_K524 1035\r
+#define IDC_NCK4_AUTO 1036\r
+#define IDC_CFG_GETTIX 1037\r
+#define IDC_CHECK1 1038\r
\r
// Next default values for new objects\r
// \r
#ifdef APSTUDIO_INVOKED\r
#ifndef APSTUDIO_READONLY_SYMBOLS\r
-#define _APS_NEXT_RESOURCE_VALUE 105\r
+#define _APS_NEXT_RESOURCE_VALUE 107\r
#define _APS_NEXT_COMMAND_VALUE 40001\r
-#define _APS_NEXT_CONTROL_VALUE 1033\r
+#define _APS_NEXT_CONTROL_VALUE 1039\r
#define _APS_NEXT_SYMED_VALUE 101\r
#endif\r
#endif\r
--- /dev/null
+/* Copyright (c) 2004 Massachusetts Institute of Technology\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ *\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#include<netidmgr_intver.h>\r
+\r
+1 VERSIONINFO \r
+ FILEVERSION KH_VERSION_LIST\r
+ PRODUCTVERSION KH_VERSION_LIST\r
+ FILEFLAGSMASK KH_VER_FILEFLAGMASK\r
+ FILEFLAGS KH_VER_FILEFLAGS\r
+ FILEOS KH_VER_FILEOS\r
+ FILETYPE KH_VER_FILETYPEDLL\r
+ FILESUBTYPE 0\r
+ {\r
+\r
+ BLOCK "StringFileInfo"\r
+ {\r
+ BLOCK "040904b0"\r
+ {\r
+ VALUE "CompanyName", KH_VERSTR_COMPANY_1033\r
+ VALUE "FileDescription", "Kerberos 4 plugin for NetIDMgr"\r
+ VALUE "FileVersion", KH_VERSTR_VERSION_1033\r
+ VALUE "InternalName", "krb4cred"\r
+ VALUE "LegalCopyright", KH_VERSTR_COPYRIGHT_1033\r
+ VALUE "OriginalFilename", "krb4cred.dll"\r
+ VALUE "ProductName", "NetIDMgr"\r
+ VALUE "ProductVersion", KH_VERSTR_PRODUCT_1033\r
+#ifdef KH_VERSTR_COMMENT_1033\r
+ VALUE "Comment", KH_VERSTR_COMMENT_1033\r
+#endif\r
+ VALUE NIMV_MODULE, "MITKrb4"\r
+ VALUE NIMV_PLUGINS, "Krb4Cred"\r
+ VALUE NIMV_APIVER, KH_VERSION_STRINGAPI\r
+ VALUE NIMV_SUPPORT, "http://web.mit.edu/kerberos"\r
+ }\r
+ }\r
+\r
+ BLOCK "VarFileInfo"\r
+ {\r
+ VALUE "Translation", 0x409, 1200\r
+ }\r
+\r
+ }\r
OBJFILES= \\r
$(LIBDIR)\dynimport.obj \\r
$(LIBDIR)\krb5common.obj \\r
- $(OBJ)\main.obj \\r
+ $(OBJ)\krb5main.obj \\r
$(OBJ)\datarep.obj \\r
$(OBJ)\errorfuncs.obj \\r
$(OBJ)\krb5plugin.obj \\r
$(OBJ)\krb5funcs.obj \\r
$(OBJ)\krb5config.obj \\r
$(OBJ)\krb5identpro.obj \\r
- $(OBJ)\krb5configdlg.obj\r
+ $(OBJ)\krb5configdlg.obj \\r
+ $(OBJ)\krb5configcc.obj \\r
+ $(OBJ)\krb5configid.obj \\r
+ $(OBJ)\krb5configids.obj\r
\r
LIBFILES= \\r
$(LIBDIR)\nidmgr32.lib \\r
$(KFWLIBDIR)\loadfuncs.lib\r
\r
SDKLIBFILES= \\r
- netapi32.lib\r
+ netapi32.lib \\r
+ shlwapi.lib \\r
+ comctl32.lib\r
\r
MSGRESFILE=$(OBJ)\krb5_msgs.res\r
\r
+VERRESFILE=$(OBJ)\version.res\r
+\r
$(OBJ)\krb5config.c: krbconfig.csv $(CONFDIR)\csvschema.cfg\r
$(CCSV) $** $@\r
\r
-$(DLLFILE): $(MSGRESFILE) $(OBJFILES)\r
+$(DLLFILE): $(MSGRESFILE) $(VERRESFILE) $(OBJFILES)\r
$(DLLGUILINK) $(LIBFILES) $(SDKLIBFILES)\r
\r
$(MSGRESFILE): $(OBJ)\krb5_msgs.rc\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
size_t cblength;\r
\r
if(cbdata != sizeof(khm_int32))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
etype = *((khm_int32 *) data);\r
\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
khm_int32 KHMAPI renew_for_cb(khm_handle cred, khm_int32 id, void * buffer, khm_size * pcbsize);\r
\r
\r
-#endif
\ No newline at end of file
+#endif\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
--- /dev/null
+/*\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#include<krbcred.h>\r
+#include<krb5.h>\r
+#include<assert.h>\r
+#include<lm.h>\r
+#include<commctrl.h>\r
+\r
+#pragma warning(push)\r
+#pragma warning(disable: 4995)\r
+#include<shlwapi.h>\r
+#pragma warning(pop)\r
+\r
+typedef struct tag_k5_file_cc {\r
+ wchar_t path[MAX_PATH];\r
+ khm_int32 flags;\r
+} k5_file_cc;\r
+\r
+#define K5_FCC_ALLOC_INCR 8\r
+\r
+#define K5_FCC_FLAG_EXISTS 1\r
+\r
+typedef struct tag_k5_ccc_data {\r
+ khm_boolean inc_api;\r
+ khm_boolean inc_mslsa;\r
+ k5_file_cc * file_ccs;\r
+ khm_size n_file_ccs;\r
+ khm_size nc_file_ccs;\r
+} k5_ccc_data;\r
+\r
+typedef struct tag_k5_ccc_dlg_data {\r
+ khui_config_node node;\r
+ k5_ccc_data save;\r
+ k5_ccc_data work;\r
+} k5_ccc_dlg_data;\r
+\r
+void k5_free_file_ccs(k5_ccc_data * d) {\r
+ if (d->file_ccs)\r
+ PFREE(d->file_ccs);\r
+ d->n_file_ccs = 0;\r
+ d->nc_file_ccs = 0;\r
+}\r
+\r
+void k5_flush_file_ccs(k5_ccc_data * d) {\r
+ d->n_file_ccs = 0;\r
+}\r
+\r
+void k5_del_file_cc(k5_ccc_data * d, khm_size idx) {\r
+ if (idx > d->n_file_ccs)\r
+ return;\r
+\r
+ if (idx < d->n_file_ccs - 1) {\r
+ MoveMemory(&d->file_ccs[idx],\r
+ &d->file_ccs[idx + 1],\r
+ sizeof(d->file_ccs[0]) * (d->n_file_ccs - (idx + 1)));\r
+ }\r
+\r
+ d->n_file_ccs--;\r
+}\r
+\r
+void k5_add_file_cc(k5_ccc_data * d, wchar_t * path) {\r
+ khm_size i;\r
+ khm_size cch;\r
+\r
+ if (FAILED(StringCchLength(path, MAX_PATH, &cch)) ||\r
+ cch == 0)\r
+ return;\r
+\r
+ /* see if it's there first */\r
+ for (i=0; i < d->n_file_ccs; i++) {\r
+ if(!wcsicmp(d->file_ccs[i].path, path))\r
+ return;\r
+ }\r
+\r
+ if (d->n_file_ccs == d->nc_file_ccs) {\r
+ k5_file_cc * f;\r
+\r
+ d->nc_file_ccs = UBOUNDSS(d->n_file_ccs + 1,\r
+ K5_FCC_ALLOC_INCR,\r
+ K5_FCC_ALLOC_INCR);\r
+#ifdef DEBUG\r
+ assert(d->nc_file_ccs > d->n_file_ccs);\r
+#endif\r
+ f = PMALLOC(sizeof(*f) * d->nc_file_ccs);\r
+ ZeroMemory(f, sizeof(*f) * d->nc_file_ccs);\r
+\r
+ if (d->n_file_ccs > 0) {\r
+#ifdef DEBUG\r
+ assert(d->file_ccs != NULL);\r
+#endif\r
+ memcpy(f, d->file_ccs, sizeof(*f) * d->n_file_ccs);\r
+ }\r
+ if (d->file_ccs)\r
+ PFREE(d->file_ccs);\r
+ d->file_ccs = f;\r
+ }\r
+\r
+ StringCbCopy(d->file_ccs[d->n_file_ccs].path,\r
+ sizeof(d->file_ccs[0].path),\r
+ path);\r
+ if(PathFileExists(path))\r
+ d->file_ccs[d->n_file_ccs].flags = K5_FCC_FLAG_EXISTS;\r
+ else\r
+ d->file_ccs[d->n_file_ccs].flags = 0;\r
+\r
+ d->n_file_ccs++;\r
+}\r
+\r
+void k5_read_file_cc_data(k5_ccc_data * d) {\r
+ khm_int32 t;\r
+ wchar_t * fclist = NULL;\r
+ wchar_t * fc;\r
+ khm_size cb;\r
+\r
+#ifdef DEBUG\r
+ assert(csp_params);\r
+#endif\r
+\r
+ d->inc_api = TRUE;\r
+ t = TRUE;\r
+ khc_read_int32(csp_params, L"MsLsaList", &t);\r
+ d->inc_mslsa = t;\r
+\r
+ if (khc_read_multi_string(csp_params, L"FileCCList", NULL, &cb)\r
+ != KHM_ERROR_TOO_LONG ||\r
+ cb <= sizeof(wchar_t) * 2) {\r
+\r
+ k5_flush_file_ccs(d);\r
+ } else {\r
+ fclist = PMALLOC(cb);\r
+#ifdef DEBUG\r
+ assert(fclist);\r
+#endif\r
+ khc_read_multi_string(csp_params, L"FileCCList", fclist, &cb);\r
+\r
+ for(fc = fclist; fc && *fc; fc = multi_string_next(fc)) {\r
+ k5_add_file_cc(d, fc);\r
+ }\r
+\r
+ PFREE(fclist);\r
+ }\r
+}\r
+\r
+void k5_write_file_cc_data(k5_ccc_data * d) {\r
+ wchar_t * ms;\r
+ khm_size cb;\r
+ khm_size cbt;\r
+ khm_int32 t;\r
+ khm_size i;\r
+\r
+#ifdef DEBUG\r
+ assert(csp_params);\r
+#endif\r
+ if (KHM_FAILED(khc_read_int32(csp_params, L"MsLsaList", &t)) ||\r
+ !!t != !!d->inc_mslsa) {\r
+ khc_write_int32(csp_params, L"MsLsaList", !!d->inc_mslsa);\r
+ }\r
+\r
+ if (d->n_file_ccs > 0) {\r
+ cb = d->n_file_ccs * MAX_PATH * sizeof(wchar_t);\r
+ ms = PMALLOC(cb);\r
+#ifdef DEBUG\r
+ assert(ms);\r
+#endif\r
+ multi_string_init(ms, cb);\r
+\r
+ for(i=0; i<d->n_file_ccs; i++) {\r
+ cbt = cb;\r
+ multi_string_append(ms, &cbt, d->file_ccs[i].path);\r
+ }\r
+\r
+ khc_write_multi_string(csp_params, L"FileCCList", ms);\r
+\r
+ PFREE(ms);\r
+ } else {\r
+ if (khc_read_multi_string(csp_params, L"FileCCList", NULL, &cb)\r
+ != KHM_ERROR_TOO_LONG ||\r
+ cb != sizeof(wchar_t) * 2)\r
+\r
+ khc_write_multi_string(csp_params, L"FileCCList", L"\0\0");\r
+ }\r
+}\r
+\r
+void k5_copy_file_cc_data(k5_ccc_data * dest, const k5_ccc_data * src) {\r
+ khm_size i;\r
+\r
+ k5_flush_file_ccs(dest);\r
+ dest->inc_mslsa = src->inc_mslsa;\r
+ dest->inc_api = src->inc_api;\r
+\r
+ for (i=0; i < src->n_file_ccs; i++) {\r
+ k5_add_file_cc(dest, src->file_ccs[i].path);\r
+ }\r
+}\r
+\r
+BOOL k5_ccc_get_mod(k5_ccc_dlg_data * d) {\r
+ khm_size i, j;\r
+\r
+ if (!!d->work.inc_mslsa != !!d->save.inc_mslsa ||\r
+ !!d->work.inc_api != !!d->save.inc_api ||\r
+ d->work.n_file_ccs != d->save.n_file_ccs)\r
+ return TRUE;\r
+\r
+ for (i=0; i < d->work.n_file_ccs; i++) {\r
+ for (j=0; j < d->save.n_file_ccs; j++) {\r
+ if (!wcsicmp(d->work.file_ccs[i].path,\r
+ d->save.file_ccs[j].path))\r
+ break;\r
+ }\r
+ if (j >= d->save.n_file_ccs)\r
+ return TRUE;\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r
+void k5_ccc_update_ui(HWND hwnd, k5_ccc_dlg_data * d) {\r
+ khm_size i;\r
+ HWND lv;\r
+\r
+ if (d->work.inc_api)\r
+ CheckDlgButton(hwnd, IDC_CFG_INCAPI, BST_CHECKED);\r
+ else\r
+ CheckDlgButton(hwnd, IDC_CFG_INCAPI, BST_UNCHECKED);\r
+ if (d->work.inc_mslsa)\r
+ CheckDlgButton(hwnd, IDC_CFG_INCMSLSA, BST_CHECKED);\r
+ else\r
+ CheckDlgButton(hwnd, IDC_CFG_INCMSLSA, BST_UNCHECKED);\r
+\r
+ lv = GetDlgItem(hwnd, IDC_CFG_FCLIST);\r
+#ifdef DEBUG\r
+ assert(lv);\r
+#endif\r
+ ListView_DeleteAllItems(lv);\r
+\r
+ for (i=0; i<d->work.n_file_ccs; i++) {\r
+ LVITEM lvi;\r
+\r
+ ZeroMemory(&lvi, sizeof(lvi));\r
+\r
+ lvi.mask = LVIF_PARAM | LVIF_TEXT;\r
+ lvi.lParam = (LPARAM) i;\r
+ lvi.pszText = d->work.file_ccs[i].path;\r
+\r
+ ListView_InsertItem(lv, &lvi);\r
+ }\r
+\r
+ if (k5_ccc_get_mod(d)) {\r
+ khui_cfg_set_flags(d->node,\r
+ KHUI_CNFLAG_MODIFIED,\r
+ KHUI_CNFLAG_MODIFIED);\r
+ } else {\r
+ khui_cfg_set_flags(d->node,\r
+ 0,\r
+ KHUI_CNFLAG_MODIFIED);\r
+ }\r
+}\r
+\r
+void k5_ccc_update_data(HWND hwnd, k5_ccc_data * d) {\r
+ if (IsDlgButtonChecked(hwnd, IDC_CFG_INCAPI) == BST_CHECKED)\r
+ d->inc_api = TRUE;\r
+ else\r
+ d->inc_api = FALSE;\r
+\r
+ if (IsDlgButtonChecked(hwnd, IDC_CFG_INCMSLSA) == BST_CHECKED)\r
+ d->inc_mslsa = TRUE;\r
+ else\r
+ d->inc_mslsa = FALSE;\r
+ /* everything else is controlled by buttons */\r
+}\r
+\r
+INT_PTR CALLBACK \r
+k5_ccconfig_dlgproc(HWND hwnd,\r
+ UINT uMsg,\r
+ WPARAM wParam,\r
+ LPARAM lParam) {\r
+\r
+ k5_ccc_dlg_data * d;\r
+\r
+ switch(uMsg) {\r
+ case WM_INITDIALOG:\r
+ d = PMALLOC(sizeof(*d));\r
+#ifdef DEBUG\r
+ assert(d);\r
+#endif\r
+ ZeroMemory(d, sizeof(*d));\r
+ k5_read_file_cc_data(&d->save);\r
+ k5_copy_file_cc_data(&d->work, &d->save);\r
+\r
+ d->node = (khui_config_node) lParam;\r
+\r
+#pragma warning(push)\r
+#pragma warning(disable: 4244)\r
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d);\r
+#pragma warning(pop)\r
+\r
+ {\r
+ LVCOLUMN lvc;\r
+ HWND lv;\r
+ wchar_t buf[256];\r
+ RECT r;\r
+\r
+ lv = GetDlgItem(hwnd, IDC_CFG_FCLIST);\r
+#ifdef DEBUG\r
+ assert(lv);\r
+#endif\r
+ ZeroMemory(&lvc, sizeof(lvc));\r
+ lvc.mask = LVCF_TEXT | LVCF_WIDTH;\r
+\r
+ LoadString(hResModule, IDS_CFG_FCTITLE,\r
+ buf, ARRAYLENGTH(buf));\r
+\r
+ GetWindowRect(lv, &r);\r
+\r
+ lvc.pszText = buf;\r
+ lvc.cx = (r.right - r.left) * 9 / 10;\r
+\r
+ ListView_InsertColumn(lv, 0, &lvc);\r
+ }\r
+\r
+ SendDlgItemMessage(hwnd, IDC_CFG_FCNAME, EM_SETLIMITTEXT, \r
+ MAX_PATH - 1, 0);\r
+\r
+ k5_ccc_update_ui(hwnd, d);\r
+ break;\r
+\r
+ case WM_COMMAND:\r
+ d = (k5_ccc_dlg_data *) (DWORD_PTR)\r
+ GetWindowLongPtr(hwnd, DWLP_USER);\r
+ switch(wParam) {\r
+ case MAKEWPARAM(IDC_CFG_ADD, BN_CLICKED):\r
+ {\r
+ wchar_t path[MAX_PATH];\r
+ wchar_t cpath[MAX_PATH];\r
+ khm_size i;\r
+\r
+ GetDlgItemText(hwnd, IDC_CFG_FCNAME, \r
+ cpath, ARRAYLENGTH(cpath));\r
+\r
+ PathCanonicalize(path, cpath);\r
+\r
+ if (!*path)\r
+ return TRUE; /* nothing to add */\r
+\r
+ for (i=0; i < d->work.n_file_ccs; i++) {\r
+ if (!wcsicmp(path, d->work.file_ccs[i].path)) {\r
+\r
+ /* allow the user to correct case, as appropriate */\r
+ StringCbCopy(d->work.file_ccs[i].path,\r
+ sizeof(d->work.file_ccs[i].path),\r
+ path);\r
+ k5_ccc_update_ui(hwnd, d);\r
+ return TRUE;\r
+ }\r
+ }\r
+\r
+ /* not there. we need to add. but check a few things\r
+ first */\r
+ if (!PathFileExists(path)) {\r
+ EDITBALLOONTIP bt;\r
+ wchar_t title[64];\r
+ wchar_t text[128];\r
+\r
+ bt.cbStruct = sizeof(bt);\r
+ bt.pszTitle = title;\r
+ LoadString(hResModule, IDS_CFG_FCN_WARNING,\r
+ title, ARRAYLENGTH(title));\r
+ bt.pszText = text;\r
+ LoadString(hResModule, IDS_CFG_FCN_W_NOTFOUND,\r
+ text, ARRAYLENGTH(text));\r
+ bt.ttiIcon = TTI_WARNING;\r
+\r
+ SendDlgItemMessage(hwnd, IDC_CFG_FCNAME,\r
+ EM_SHOWBALLOONTIP,\r
+ 0,\r
+ (LPARAM) &bt);\r
+\r
+ } else if (PathIsRelative(path)) {\r
+ EDITBALLOONTIP bt;\r
+ wchar_t title[64];\r
+ wchar_t text[128];\r
+\r
+ bt.cbStruct = sizeof(bt);\r
+ bt.pszTitle = title;\r
+ LoadString(hResModule, IDS_CFG_FCN_WARNING,\r
+ title, ARRAYLENGTH(title));\r
+ bt.pszText = text;\r
+ LoadString(hResModule, IDS_CFG_FCN_W_RELATIVE,\r
+ text, ARRAYLENGTH(text));\r
+ bt.ttiIcon = TTI_WARNING;\r
+\r
+ SendDlgItemMessage(hwnd, IDC_CFG_FCNAME,\r
+ EM_SHOWBALLOONTIP,\r
+ 0,\r
+ (LPARAM) &bt);\r
+ }\r
+\r
+ k5_add_file_cc(&d->work, path);\r
+\r
+ k5_ccc_update_ui(hwnd, d);\r
+ }\r
+ return TRUE;\r
+\r
+ case MAKEWPARAM(IDC_CFG_BROWSE, BN_CLICKED):\r
+ {\r
+ OPENFILENAME ofn;\r
+ wchar_t path[MAX_PATH * 8];\r
+ wchar_t title[128];\r
+\r
+ ZeroMemory(&ofn, sizeof(ofn));\r
+ ZeroMemory(path, sizeof(path));\r
+\r
+ GetDlgItemText(hwnd, IDC_CFG_FCNAME,\r
+ path, ARRAYLENGTH(path));\r
+\r
+ /* don't pass in invalid paths */\r
+ if (!PathFileExists(path))\r
+ *path = 0;\r
+\r
+ ofn.lStructSize = sizeof(ofn);\r
+ ofn.hwndOwner = hwnd;\r
+ ofn.lpstrFilter = L"All files\0*.*\0\0";\r
+ ofn.nFilterIndex = 1;\r
+ ofn.lpstrFile = path;\r
+ ofn.nMaxFile = ARRAYLENGTH(path);\r
+ ofn.lpstrTitle = title;\r
+\r
+ LoadString(hResModule, IDS_CFG_FCOPENTITLE,\r
+ title, ARRAYLENGTH(title));\r
+\r
+ ofn.Flags = OFN_ALLOWMULTISELECT |\r
+ OFN_DONTADDTORECENT |\r
+ OFN_FORCESHOWHIDDEN |\r
+ OFN_EXPLORER;\r
+\r
+ if (GetOpenFileName(&ofn)) {\r
+ wchar_t * p;\r
+ wchar_t spath[MAX_PATH];\r
+\r
+ p = multi_string_next(path);\r
+ if (p) {\r
+ /* multi select */\r
+ for(;p && *p; p = multi_string_next(p)) {\r
+ StringCbCopy(spath, sizeof(spath), path);\r
+ PathAppend(spath, p);\r
+\r
+ k5_add_file_cc(&d->work, spath);\r
+ }\r
+ } else {\r
+ /* single select */\r
+ k5_add_file_cc(&d->work, path);\r
+ }\r
+ k5_ccc_update_ui(hwnd, d);\r
+ }\r
+ }\r
+ return TRUE;\r
+\r
+ case MAKEWPARAM(IDC_CFG_REMOVE, BN_CLICKED):\r
+ {\r
+ khm_size i;\r
+ int lv_idx;\r
+ HWND lv;\r
+ wchar_t buf[MAX_PATH];\r
+\r
+ lv = GetDlgItem(hwnd, IDC_CFG_FCLIST);\r
+#ifdef DEBUG\r
+ assert(lv);\r
+#endif\r
+\r
+ lv_idx = -1;\r
+ while((lv_idx = ListView_GetNextItem(lv, lv_idx, \r
+ LVNI_SELECTED)) != -1) {\r
+ ListView_GetItemText(lv, lv_idx, 0, buf, ARRAYLENGTH(buf));\r
+ for (i=0; i < d->work.n_file_ccs; i++) {\r
+ if (!wcsicmp(buf, d->work.file_ccs[i].path)) {\r
+ k5_del_file_cc(&d->work, i);\r
+ break;\r
+ }\r
+ }\r
+ }\r
+\r
+ k5_ccc_update_ui(hwnd, d);\r
+ }\r
+ return TRUE;\r
+\r
+ case MAKEWPARAM(IDC_CFG_INCAPI, BN_CLICKED):\r
+ case MAKEWPARAM(IDC_CFG_INCMSLSA, BN_CLICKED):\r
+ k5_ccc_update_data(hwnd, &d->work);\r
+ k5_ccc_update_ui(hwnd, d);\r
+ return TRUE;\r
+ }\r
+ break;\r
+\r
+ case WM_DESTROY:\r
+ d = (k5_ccc_dlg_data *) (DWORD_PTR)\r
+ GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+ k5_free_file_ccs(&d->work);\r
+ k5_free_file_ccs(&d->save);\r
+ PFREE(d);\r
+ return TRUE;\r
+\r
+ case KHUI_WM_CFG_NOTIFY:\r
+ d = (k5_ccc_dlg_data *) (DWORD_PTR)\r
+ GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+ switch(HIWORD(wParam)) {\r
+ case WMCFG_APPLY:\r
+ if (k5_ccc_get_mod(d)) {\r
+ k5_write_file_cc_data(&d->work);\r
+ k5_copy_file_cc_data(&d->save, &d->work);\r
+ khui_cfg_set_flags(d->node,\r
+ KHUI_CNFLAG_APPLIED,\r
+ KHUI_CNFLAG_APPLIED);\r
+ k5_ccc_update_ui(hwnd, d);\r
+\r
+ kmq_post_sub_msg(k5_sub, KMSG_CRED, KMSG_CRED_REFRESH, 0, 0);\r
+ }\r
+ break;\r
+ }\r
+ }\r
+ return FALSE;\r
+}\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
#include<krb5.h>\r
#include<assert.h>\r
#include<lm.h>\r
+#include<commctrl.h>\r
+\r
+#pragma warning(push)\r
+#pragma warning(disable: 4995)\r
+#include<shlwapi.h>\r
+#pragma warning(pop)\r
+\r
+\r
+typedef struct tag_k5_realm_kdc {\r
+ wchar_t name[K5_MAXCCH_HOST];\r
+ khm_boolean admin; /* admin server? */\r
+ khm_boolean master; /* master kdc? */\r
+ khm_int32 flags;\r
+} k5_realm_kdc;\r
+\r
+#define K5_RKFLAG_DELETED 1\r
+#define K5_RKFLAG_NEW 2\r
+#define K5_RKFLAG_MOD_ADMIN 4\r
+#define K5_RKFLAG_MOD_MASTER 8\r
+\r
+typedef struct tag_k5_domain_map {\r
+ wchar_t name[K5_MAXCCH_HOST]; /* name of host that maps to a\r
+ realm */\r
+ khm_int32 flags;\r
+} k5_domain_map;\r
+\r
+#define K5_DMFLAG_DELETED 1\r
+#define K5_DMFLAG_NEW 2\r
+\r
+typedef struct tag_k5_realm_data {\r
+ wchar_t realm[K5_MAXCCH_REALM];\r
+ k5_realm_kdc kdcs[K5_MAX_KDC];\r
+ khm_size n_kdcs;\r
+ k5_domain_map domain_maps[K5_MAX_DOMAIN_MAPPINGS];\r
+ khm_size n_domain_maps;\r
+\r
+ khm_int32 flags;\r
+} k5_realm_data;\r
+\r
+#define K5_RDFLAG_DELETED 1\r
+#define K5_RDFLAG_NEW 2\r
+#define K5_RDFLAG_MODIFED 4\r
+\r
+#define K5_REALMS_ALLOC_INCR 8\r
+\r
+typedef struct tag_k5_config_data {\r
+ wchar_t def_realm[K5_MAXCCH_REALM]; /* default realm */\r
+\r
+ wchar_t config_file[MAX_PATH]; /* path to configuration file */\r
+ khm_boolean create_config_file; /* create config_file if missing? */\r
+\r
+ /* [libdefaults] */\r
+ khm_boolean dns_lookup_kdc;\r
+ khm_boolean dns_lookup_realm;\r
+ khm_boolean dns_fallback;\r
+\r
+ khm_boolean noaddresses;\r
+\r
+ k5_lsa_import lsa_import; /* import mslsa creds? */\r
+\r
+ /* [realms] */\r
+ k5_realm_data *realms;\r
+ khm_size n_realms;\r
+ khm_size nc_realms;\r
+ khm_size c_realm;\r
+\r
+ khui_config_node node_main;\r
+ khui_config_node node_realm;\r
+\r
+ khm_int32 flags;\r
+} k5_config_data;\r
+\r
+#define K5_CDFLAG_MOD_DEF_REALM 1\r
+#define K5_CDFLAG_MOD_CONF_FILE 2\r
+#define K5_CDFLAG_MOD_DNS_LOOKUP_KDC 4\r
+#define K5_CDFLAG_MOD_DNS_LOOKUP_RLM 8\r
+#define K5_CDFLAG_MOD_DNS_FALLBACK 0x10\r
+#define K5_CDFLAG_MOD_NOADDRESSES 0x20\r
+#define K5_CDFLAG_MOD_LSA_IMPORT 0x40\r
+#define K5_CDFLAG_MOD_CREATE_CONF 0x80\r
+#define K5_CDFLAG_MOD_REALMS 0x1000\r
+\r
+static const char *const conf_yes[] = {\r
+ "y", "yes", "true", "t", "1", "on",\r
+ 0,\r
+};\r
+\r
+static const char *const conf_no[] = {\r
+ "n", "no", "false", "nil", "0", "off",\r
+ 0,\r
+};\r
+\r
+int\r
+k5_parse_boolean(const char *s)\r
+{\r
+ const char *const *p;\r
+\r
+ for(p=conf_yes; *p; p++) {\r
+ if (!stricmp(*p,s))\r
+ return 1;\r
+ }\r
+\r
+ for(p=conf_no; *p; p++) {\r
+ if (!stricmp(*p,s))\r
+ return 0;\r
+ }\r
+\r
+ /* Default to "no" */\r
+ return 0;\r
+}\r
+\r
+void\r
+k5_init_config_data(k5_config_data * d) {\r
+ ZeroMemory(d, sizeof(*d));\r
+}\r
+\r
+void\r
+k5_free_config_data(k5_config_data * d) {\r
+ if (d->realms)\r
+ PFREE(d->realms);\r
+\r
+ k5_init_config_data(d);\r
+}\r
+\r
+static void\r
+k5_assert_n_realms(k5_config_data * d, khm_size n) {\r
+ khm_size nc_realms;\r
+\r
+ if (n <= d->nc_realms)\r
+ return;\r
+\r
+ nc_realms = UBOUNDSS(n, K5_REALMS_ALLOC_INCR, K5_REALMS_ALLOC_INCR);\r
+ assert(nc_realms > d->nc_realms);\r
+\r
+ d->realms = PREALLOC(d->realms, nc_realms * sizeof(*(d->realms)));\r
+ d->nc_realms = nc_realms;\r
+\r
+ ZeroMemory(&d->realms[d->n_realms],\r
+ (d->nc_realms - d->n_realms) * sizeof(*(d->realms)));\r
+}\r
+\r
+void\r
+k5_purge_config_data(k5_config_data * d,\r
+ khm_boolean purge_realms,\r
+ khm_boolean purge_kdcs,\r
+ khm_boolean purge_dmap) {\r
+ khm_size r;\r
+ khm_size k;\r
+ khm_size m;\r
+\r
+ for (r=0; r < d->n_realms; r++) {\r
+ if (purge_realms &&\r
+ (d->realms[r].flags & K5_RDFLAG_NEW) &&\r
+ (d->realms[r].flags & K5_RDFLAG_DELETED)) {\r
+\r
+ if (d->n_realms > r+1)\r
+ MoveMemory(&d->realms[r], &d->realms[r+1],\r
+ sizeof(d->realms[0]) * (d->n_realms - (r+1)));\r
+ r--;\r
+ d->n_realms--;\r
+ continue;\r
+ }\r
+\r
+ for (k=0; k < d->realms[r].n_kdcs; k++) {\r
+ if (purge_kdcs &&\r
+ (d->realms[r].kdcs[k].flags & K5_RKFLAG_NEW) &&\r
+ (d->realms[r].kdcs[k].flags & K5_RKFLAG_DELETED)) {\r
+ if (d->realms[r].n_kdcs > k + 1)\r
+ MoveMemory(&d->realms[r].kdcs[k],\r
+ &d->realms[r].kdcs[k+1],\r
+ sizeof(d->realms[0].kdcs[0]) *\r
+ (d->realms[r].n_kdcs - (k+1)));\r
+ k--;\r
+ d->realms[r].n_kdcs--;\r
+ continue;\r
+ }\r
+ }\r
+\r
+ if (K5_MAX_KDC > k+1)\r
+ ZeroMemory(&d->realms[r].kdcs[k],\r
+ sizeof(d->realms[0].kdcs[0]) *\r
+ (K5_MAX_KDC - (k + 1)));\r
+\r
+ for (m=0; m < d->realms[r].n_domain_maps; m++) {\r
+ if (purge_dmap &&\r
+ (d->realms[r].domain_maps[m].flags & K5_DMFLAG_NEW) &&\r
+ (d->realms[r].domain_maps[m].flags & K5_DMFLAG_DELETED)) {\r
+ if (d->realms[r].n_domain_maps > m + 1)\r
+ MoveMemory(&d->realms[r].domain_maps[m],\r
+ &d->realms[r].domain_maps[m+1],\r
+ sizeof(d->realms[0].domain_maps[0]) *\r
+ (d->realms[r].n_domain_maps - (m+1)));\r
+ m--;\r
+ d->realms[r].n_domain_maps--;\r
+ continue;\r
+ }\r
+ }\r
+\r
+ if (K5_MAX_DOMAIN_MAPPINGS > m+1)\r
+ ZeroMemory(&d->realms[r].domain_maps[m],\r
+ sizeof(d->realms[0].domain_maps[0]) *\r
+ (K5_MAX_DOMAIN_MAPPINGS - (m+1)));\r
+ }\r
+\r
+ if (d->nc_realms > r + 1)\r
+ ZeroMemory(&d->realms[r],\r
+ sizeof(d->realms[0]) *\r
+ (d->nc_realms - (r + 1)));\r
+}\r
+\r
+static khm_boolean\r
+k5_is_profile_loaded(void) {\r
+#ifdef DEBUG\r
+ assert(pprofile_init);\r
+ assert(pprofile_get_subsection_names);\r
+ assert(pprofile_get_values);\r
+ assert(pprofile_get_string);\r
+ assert(pprofile_get_relation_names);\r
+ assert(pprofile_free_list);\r
+ assert(pprofile_release_string);\r
+ assert(pprofile_release);\r
+ assert(pprofile_clear_relation);\r
+ assert(pprofile_add_relation);\r
+ assert(pprofile_update_relation);\r
+ assert(pprofile_flush);\r
+#endif\r
+\r
+ if (!pprofile_init ||\r
+ !pprofile_get_subsection_names ||\r
+ !pprofile_get_values ||\r
+ !pprofile_get_string ||\r
+ !pprofile_get_relation_names ||\r
+ !pprofile_free_list ||\r
+ !pprofile_release_string ||\r
+ !pprofile_release ||\r
+ !pprofile_clear_relation ||\r
+ !pprofile_add_relation ||\r
+ !pprofile_update_relation ||\r
+ !pprofile_flush)\r
+\r
+ return FALSE;\r
+\r
+ return TRUE;\r
+}\r
+\r
+void\r
+k5_read_config_data(k5_config_data * d) {\r
+ wchar_t * defrealm;\r
+ char config_file[MAX_PATH];\r
+ profile_t profile = NULL;\r
+ const char *filenames[2];\r
+ long rv;\r
+ khm_size s;\r
+\r
+ if (!k5_is_profile_loaded())\r
+ return;\r
+\r
+ defrealm = khm_krb5_get_default_realm();\r
+\r
+ if (defrealm) {\r
+ StringCbCopy(d->def_realm, sizeof(d->def_realm), defrealm);\r
+ PFREE(defrealm);\r
+ } else {\r
+ StringCbCopy(d->def_realm, sizeof(d->def_realm), L"");\r
+ }\r
+\r
+ khm_krb5_get_profile_file(config_file, ARRAYLENGTH(config_file));\r
+\r
+ AnsiStrToUnicode(d->config_file, sizeof(d->config_file), config_file);\r
+\r
+ filenames[0] = config_file;\r
+ filenames[1] = NULL;\r
+\r
+ rv = pprofile_init(filenames, &profile);\r
+\r
+ if (!rv) {\r
+ const char * sec_realms[] = { "realms", NULL };\r
+ const char * sec_domain_realm[] = { "domain_realm", NULL };\r
+ char ** sections;\r
+ char ** dr_from;\r
+ char * boolv;\r
+\r
+ /* first fish out a few values from [libdefaults] */\r
+\r
+ rv = pprofile_get_string(profile, "libdefaults", "dns_lookup_kdc",\r
+ NULL, NULL, &boolv);\r
+ if (!rv && boolv) {\r
+ d->dns_lookup_kdc = k5_parse_boolean(boolv);\r
+ pprofile_release_string(boolv);\r
+ } else\r
+ d->dns_lookup_kdc = FALSE;\r
+\r
+ rv = pprofile_get_string(profile, "libdefaults", "dns_lookup_realm",\r
+ NULL, NULL, &boolv);\r
+ if (!rv && boolv) {\r
+ d->dns_lookup_realm = k5_parse_boolean(boolv);\r
+ pprofile_release_string(boolv);\r
+ } else\r
+ d->dns_lookup_realm = FALSE;\r
+\r
+ rv = pprofile_get_string(profile, "libdefaults", "dns_fallback",\r
+ NULL, NULL, &boolv);\r
+ if (!rv && boolv) {\r
+ d->dns_fallback = k5_parse_boolean(boolv);\r
+ pprofile_release_string(boolv);\r
+ } else\r
+ d->dns_fallback = FALSE;\r
+\r
+ rv = pprofile_get_string(profile, "libdefaults", "noaddresses",\r
+ NULL, NULL, &boolv);\r
+ if (!rv && boolv) {\r
+ d->noaddresses = k5_parse_boolean(boolv);\r
+ pprofile_release_string(boolv);\r
+ } else\r
+ d->noaddresses = TRUE;\r
+\r
+ /* now we look at the [realms] section */\r
+ rv = pprofile_get_subsection_names(profile, sec_realms, §ions);\r
+\r
+ /* what? no realms? whatever */\r
+ if (rv) goto _skip_realms;\r
+\r
+ /* get a count first */\r
+ for (s=0; sections[s] && sections[s][0]; s++);\r
+\r
+ k5_assert_n_realms(d, s);\r
+ d->n_realms = s;\r
+\r
+ /* now go through each and fish out the kdcs, admin_server\r
+ and master_kdc. */\r
+ for (s=0; sections[s] && sections[s][0]; s++) {\r
+ const char * sec_kdcs[] = \r
+ { "realms", sections[s], "kdc", NULL };\r
+\r
+ const char * sec_admin[] =\r
+ { "realms", sections[s], "admin_server", NULL };\r
+\r
+ const char * sec_master[] =\r
+ { "realms", sections[s], "master_kdc", NULL };\r
+\r
+ char ** values;\r
+\r
+ AnsiStrToUnicode(d->realms[s].realm, sizeof(d->realms[s].realm),\r
+ sections[s]);\r
+ d->realms[s].n_kdcs = 0;\r
+ d->realms[s].n_domain_maps = 0;\r
+\r
+ rv = pprofile_get_values(profile, sec_kdcs, &values);\r
+ if (!rv) {\r
+ khm_size i;\r
+\r
+ for (i=0 ; values[i] && values[i][0] && i < K5_MAX_KDC; i++) {\r
+ AnsiStrToUnicode(d->realms[s].kdcs[i].name,\r
+ sizeof(d->realms[s].kdcs[i].name),\r
+ values[i]);\r
+\r
+ }\r
+ d->realms[s].n_kdcs = i;\r
+\r
+ pprofile_free_list(values);\r
+ }\r
+\r
+ rv = pprofile_get_values(profile, sec_admin, &values);\r
+ if (!rv) {\r
+ khm_size i;\r
+ khm_size j;\r
+ wchar_t kdc_name[K5_MAXCCH_HOST];\r
+\r
+ for (i=0; values[i] && values[i][0]; i++) {\r
+ AnsiStrToUnicode(kdc_name,\r
+ sizeof(kdc_name), values[i]);\r
+\r
+ for (j=0; j < d->realms[s].n_kdcs; j++)\r
+ if (!wcsicmp(kdc_name, d->realms[s].kdcs[j].name))\r
+ break;\r
+\r
+ if (j < d->realms[s].n_kdcs) {\r
+ d->realms[s].kdcs[j].admin = TRUE;\r
+ } else if (d->realms[s].n_kdcs < K5_MAX_KDC) {\r
+ j = d->realms[s].n_kdcs;\r
+ StringCbCopy(d->realms[s].kdcs[j].name,\r
+ sizeof(d->realms[s].kdcs[j].name),\r
+ kdc_name);\r
+ d->realms[s].kdcs[j].admin = TRUE;\r
+ d->realms[s].n_kdcs ++;\r
+ }\r
+ }\r
+ pprofile_free_list(values);\r
+ }\r
+\r
+ rv = pprofile_get_values(profile, sec_master, &values);\r
+ if (!rv) {\r
+ khm_size i;\r
+ khm_size j;\r
+ wchar_t kdc_name[K5_MAXCCH_HOST];\r
+\r
+ for (i=0; values[i] && values[i][0]; i++) {\r
+ AnsiStrToUnicode(kdc_name, sizeof(kdc_name), values[i]);\r
+\r
+ for (j=0; j < d->realms[s].n_kdcs; j++)\r
+ if (!wcsicmp(kdc_name, d->realms[s].kdcs[j].name))\r
+ break;\r
+\r
+ if (j < d->realms[s].n_kdcs) {\r
+ d->realms[s].kdcs[j].master = TRUE;\r
+ } else if (d->realms[s].n_kdcs < K5_MAX_KDC) {\r
+ j = d->realms[s].n_kdcs;\r
+ StringCbCopy(d->realms[s].kdcs[j].name,\r
+ sizeof(d->realms[s].kdcs[j].name),\r
+ kdc_name);\r
+ d->realms[s].kdcs[j].master = TRUE;\r
+ d->realms[s].n_kdcs ++;\r
+ }\r
+ }\r
+\r
+ pprofile_free_list(values);\r
+ }\r
+ }\r
+ pprofile_free_list(sections);\r
+\r
+ _skip_realms:\r
+\r
+ rv = pprofile_get_relation_names(profile, sec_domain_realm, &dr_from);\r
+ if (!rv) {\r
+ khm_size i;\r
+ khm_size j;\r
+ char * dr_to;\r
+ wchar_t wdr_from[K5_MAXCCH_HOST];\r
+ wchar_t wdr_to[K5_MAXCCH_HOST];\r
+\r
+ for (i=0; dr_from[i] && dr_from[i][0]; i++) {\r
+ AnsiStrToUnicode(wdr_from, sizeof(wdr_from), dr_from[i]);\r
+\r
+ rv = pprofile_get_string(profile, "domain_realm", dr_from[i],\r
+ NULL, NULL, &dr_to);\r
+\r
+ if (rv || !dr_to)\r
+ continue;\r
+\r
+ AnsiStrToUnicode(wdr_to, sizeof(wdr_to), dr_to);\r
+\r
+ for (j=0; j < d->n_realms; j++) {\r
+ if (!wcsicmp(wdr_to, d->realms[j].realm))\r
+ break;\r
+ }\r
+\r
+ if (j >= d->n_realms) {\r
+ j = d->n_realms;\r
+ k5_assert_n_realms(d, j + 1);\r
+\r
+ StringCbCopy(d->realms[j].realm,\r
+ sizeof(d->realms[j].realm),\r
+ wdr_to);\r
+ d->realms[j].n_kdcs = 0;\r
+ d->realms[j].n_domain_maps = 0;\r
+\r
+ d->n_realms++;\r
+ }\r
+\r
+ if (d->realms[j].n_domain_maps < K5_MAX_DOMAIN_MAPPINGS) {\r
+ khm_size k;\r
+\r
+ k = d->realms[j].n_domain_maps;\r
+\r
+ StringCbCopy(d->realms[j].domain_maps[k].name,\r
+ sizeof(d->realms[j].domain_maps[k].name),\r
+ wdr_from);\r
+\r
+ d->realms[j].n_domain_maps++;\r
+ }\r
+\r
+ pprofile_release_string(dr_to);\r
+ }\r
+ pprofile_free_list(dr_from);\r
+ }\r
+ pprofile_release(profile);\r
+ }\r
+\r
+ /* last, read the MSLSA import setting */\r
+ {\r
+ khm_int32 t;\r
+\r
+ if (KHM_SUCCEEDED(khc_read_int32(csp_params,\r
+ L"MsLsaImport", &t))) {\r
+ d->lsa_import = t;\r
+ } else {\r
+ d->lsa_import = K5_LSAIMPORT_ALWAYS;\r
+ }\r
+ }\r
+\r
+ d->flags = 0;\r
+}\r
+\r
+void\r
+k5_write_config_data(k5_config_data * d) {\r
+ char astr[MAX_PATH * 2];\r
+ char config_file[MAX_PATH];\r
+ profile_t profile = NULL;\r
+ const char *filenames[2];\r
+ long rv;\r
+ khm_size s;\r
+\r
+ if (d->flags == 0)\r
+ return;\r
+\r
+ if (!k5_is_profile_loaded())\r
+ return;\r
+\r
+ if (d->flags & K5_CDFLAG_MOD_DEF_REALM) {\r
+ if (SUCCEEDED(StringCbLength(d->def_realm,\r
+ sizeof(d->def_realm), &s)) &&\r
+ s > 0) {\r
+ khm_krb5_set_default_realm(d->def_realm);\r
+ }\r
+ }\r
+\r
+ /* write the MSLSA import setting */\r
+ if (d->flags & K5_CDFLAG_MOD_LSA_IMPORT) {\r
+\r
+ khc_write_int32(csp_params, L"MsLsaImport", d->lsa_import);\r
+\r
+ }\r
+\r
+ if (!(d->flags & \r
+ (K5_CDFLAG_MOD_CONF_FILE |\r
+ K5_CDFLAG_MOD_DNS_FALLBACK |\r
+ K5_CDFLAG_MOD_DNS_LOOKUP_RLM |\r
+ K5_CDFLAG_MOD_DNS_LOOKUP_KDC |\r
+ K5_CDFLAG_MOD_NOADDRESSES |\r
+ K5_CDFLAG_MOD_CREATE_CONF |\r
+ K5_CDFLAG_MOD_REALMS))) {\r
+\r
+ d->flags = 0;\r
+ return;\r
+\r
+ }\r
+\r
+ khm_krb5_get_profile_file(config_file, ARRAYLENGTH(config_file));\r
+\r
+ UnicodeStrToAnsi(astr, sizeof(astr), d->config_file);\r
+\r
+ if (stricmp(config_file, astr)) {\r
+ assert(FALSE);\r
+ }\r
+\r
+ filenames[0] = config_file;\r
+ filenames[1] = NULL;\r
+\r
+ rv = pprofile_init(filenames, &profile);\r
+\r
+#if FAILOVER_TO_TEMPORARY_FILE\r
+ if (rv) {\r
+ char temp_file[MAX_PATH];\r
+\r
+ khm_krb5_get_temp_profile_file(temp_file,\r
+ ARRAYLENGTH(temp_file));\r
+\r
+ filenames[0] = temp_file;\r
+\r
+ rv = pprofile_init(filenames, &profile);\r
+\r
+ ?? TODO: Also warn if we are doing this\r
+ }\r
+#endif\r
+\r
+\r
+ if (!rv) {\r
+ const char * sec_realms[] = { "realms", NULL };\r
+ const char * sec_domain_realm[] = { "domain_realm", NULL };\r
+ const char * sec_libdefaults[] = { "libdefaults", NULL, NULL };\r
+ khm_size r;\r
+\r
+ if (d->flags & K5_CDFLAG_MOD_DNS_LOOKUP_KDC) {\r
+\r
+ sec_libdefaults[1] = "dns_lookup_kdc";\r
+\r
+ pprofile_clear_relation(profile, sec_libdefaults);\r
+\r
+ rv = pprofile_add_relation(profile, sec_libdefaults,\r
+ (d->dns_lookup_kdc)?\r
+ conf_yes[0]:\r
+ conf_no[0]);\r
+ }\r
+\r
+\r
+ if (d->flags & K5_CDFLAG_MOD_DNS_LOOKUP_RLM) {\r
+\r
+ sec_libdefaults[1] = "dns_lookup_realm";\r
+\r
+ pprofile_clear_relation(profile, sec_libdefaults);\r
+\r
+ rv = pprofile_add_relation(profile, sec_libdefaults,\r
+ (d->dns_lookup_realm)?\r
+ conf_yes[0]:\r
+ conf_no[0]);\r
+\r
+ }\r
+\r
+ if (d->flags & K5_CDFLAG_MOD_DNS_FALLBACK) {\r
+\r
+ sec_libdefaults[1] = "dns_fallback";\r
+\r
+ pprofile_clear_relation(profile, sec_libdefaults);\r
+\r
+ rv = pprofile_add_relation(profile, sec_libdefaults,\r
+ (d->dns_fallback)?\r
+ conf_yes[0]:\r
+ conf_no[0]);\r
+ }\r
+\r
+ if (d->flags & K5_CDFLAG_MOD_NOADDRESSES) {\r
+\r
+ sec_libdefaults[1] = "noaddresses";\r
+\r
+ pprofile_clear_relation(profile, sec_libdefaults);\r
+\r
+ rv = pprofile_add_relation(profile, sec_libdefaults,\r
+ (d->noaddresses)?\r
+ conf_yes[0]:\r
+ conf_no[0]);\r
+ }\r
+\r
+ /* now we look at the [realms] section */\r
+\r
+ for (r=0; r < d->n_realms; r++) {\r
+ char realm[K5_MAXCCH_REALM];\r
+ char host[K5_MAXCCH_HOST];\r
+\r
+ const char * sec_kdcs[] = \r
+ { "realms", realm, "kdc", NULL };\r
+\r
+ const char * sec_admin[] =\r
+ { "realms", realm, "admin_server", NULL };\r
+\r
+ const char * sec_master[] =\r
+ { "realms", realm, "master_kdc", NULL };\r
+\r
+ const char * sec_domain_map[] =\r
+ { "domain_realm", host, NULL };\r
+\r
+ char ** values;\r
+\r
+ UnicodeStrToAnsi(realm, sizeof(realm),\r
+ d->realms[r].realm);\r
+\r
+ if (!(d->realms[r].flags & K5_RDFLAG_DELETED) &&\r
+ (d->realms[r].flags & K5_RDFLAG_NEW)) {\r
+\r
+ khm_size k;\r
+ khm_size m;\r
+\r
+ /* this is a new realm */\r
+\r
+ for (k=0; k < d->realms[r].n_kdcs; k++) {\r
+ if (!(d->realms[r].kdcs[k].flags & K5_RKFLAG_DELETED)) {\r
+ UnicodeStrToAnsi(host, sizeof(host),\r
+ d->realms[r].kdcs[k].name);\r
+\r
+ if (d->realms[r].kdcs[k].master)\r
+ pprofile_add_relation(profile, sec_master,\r
+ host);\r
+ else\r
+ pprofile_add_relation(profile, sec_kdcs,\r
+ host);\r
+\r
+ if (d->realms[r].kdcs[k].admin)\r
+ pprofile_add_relation(profile, sec_admin,\r
+ host);\r
+ }\r
+ }\r
+\r
+ for (m=0; m < d->realms[r].n_domain_maps; m++) {\r
+\r
+ UnicodeStrToAnsi(host, sizeof(host),\r
+ d->realms[r].domain_maps[m].name);\r
+\r
+ if ((d->realms[r].domain_maps[m].flags &\r
+ K5_DMFLAG_DELETED) &&\r
+ !(d->realms[r].domain_maps[m].flags &\r
+ K5_DMFLAG_NEW))\r
+ pprofile_clear_relation(profile, sec_domain_map);\r
+ else if (!(d->realms[r].domain_maps[m].flags &\r
+ K5_DMFLAG_DELETED) &&\r
+ (d->realms[r].domain_maps[m].flags &\r
+ K5_DMFLAG_NEW))\r
+ pprofile_add_relation(profile, sec_domain_map,\r
+ realm);\r
+ }\r
+ } else if ((d->realms[r].flags & K5_RDFLAG_DELETED) &&\r
+ !(d->realms[r].flags & K5_RDFLAG_NEW)) {\r
+\r
+ const char * sec_all[] =\r
+ { "realms", realm, NULL, NULL };\r
+ khm_size v;\r
+\r
+ /* this realm should be deleted */\r
+\r
+ rv = pprofile_get_relation_names(profile, sec_all,\r
+ &values);\r
+ if (!rv) {\r
+ for (v=0; values[v] && values[v][0]; v++) {\r
+ sec_all[2] = values[v];\r
+ pprofile_clear_relation(profile, sec_all);\r
+ }\r
+ pprofile_free_list(values);\r
+ }\r
+\r
+ rv = pprofile_get_relation_names(profile, sec_domain_realm,\r
+ &values);\r
+ if (!rv) {\r
+ char * maprealm;\r
+\r
+ for (v=0; values[v] && values[v][0]; v++) {\r
+\r
+ rv = pprofile_get_string(profile, "domain_realm",\r
+ values[v], NULL, NULL,\r
+ &maprealm);\r
+\r
+ if (!rv) {\r
+ if (!strcmp(maprealm, realm)) {\r
+ StringCbCopyA(host, sizeof(host), \r
+ values[v]);\r
+ pprofile_clear_relation(profile, \r
+ sec_domain_map);\r
+ }\r
+ pprofile_release_string(maprealm);\r
+ }\r
+ }\r
+\r
+ pprofile_free_list(values);\r
+ }\r
+ } else if (!(d->realms[r].flags & K5_RDFLAG_DELETED)) {\r
+ khm_size k;\r
+ khm_size m;\r
+\r
+ /* same as before. check if we have to update the kdc\r
+ list or the domain_realm mappings */\r
+\r
+ for (k=0; k < d->realms[r].n_kdcs; k++) {\r
+ UnicodeStrToAnsi(host, sizeof(host),\r
+ d->realms[r].kdcs[k].name);\r
+ if (d->realms[r].kdcs[k].flags & K5_RKFLAG_DELETED) {\r
+ pprofile_update_relation(profile, sec_kdcs,\r
+ host, NULL);\r
+ pprofile_update_relation(profile, sec_admin,\r
+ host, NULL);\r
+ pprofile_update_relation(profile, sec_master,\r
+ host, NULL);\r
+\r
+ continue;\r
+ }\r
+\r
+ if (d->realms[r].kdcs[k].flags & K5_RKFLAG_NEW) {\r
+ if (d->realms[r].kdcs[k].master)\r
+ pprofile_add_relation(profile, sec_master,\r
+ host);\r
+ else\r
+ pprofile_add_relation(profile, sec_kdcs,\r
+ host);\r
+\r
+ if (d->realms[r].kdcs[k].admin)\r
+ pprofile_add_relation(profile, sec_admin,\r
+ host);\r
+ continue;\r
+ }\r
+\r
+ if (d->realms[r].kdcs[k].flags & K5_RKFLAG_MOD_MASTER) {\r
+ if (!d->realms[r].kdcs[k].master) {\r
+ pprofile_add_relation(profile, sec_kdcs,\r
+ host);\r
+ pprofile_update_relation(profile, sec_master,\r
+ host, NULL);\r
+ } else {\r
+ pprofile_add_relation(profile, sec_master,\r
+ host);\r
+ pprofile_update_relation(profile, sec_kdcs,\r
+ host, NULL);\r
+ }\r
+ }\r
+\r
+ if (d->realms[r].kdcs[k].flags & K5_RKFLAG_MOD_ADMIN) {\r
+ if (d->realms[r].kdcs[k].admin)\r
+ pprofile_add_relation(profile, sec_admin,\r
+ host);\r
+ else\r
+ pprofile_update_relation(profile, sec_admin,\r
+ host, NULL);\r
+ }\r
+ }\r
+\r
+ for (m=0; m < d->realms[r].n_domain_maps; m++) {\r
+\r
+ UnicodeStrToAnsi(host, sizeof(host),\r
+ d->realms[r].domain_maps[m].name);\r
+\r
+ if ((d->realms[r].domain_maps[m].flags &\r
+ K5_DMFLAG_DELETED) &&\r
+ !(d->realms[r].domain_maps[m].flags &\r
+ K5_DMFLAG_NEW))\r
+ pprofile_clear_relation(profile, sec_domain_map);\r
+ else if (!(d->realms[r].domain_maps[m].flags &\r
+ K5_DMFLAG_DELETED) &&\r
+ (d->realms[r].domain_maps[m].flags &\r
+ K5_DMFLAG_NEW))\r
+ pprofile_add_relation(profile, sec_domain_map,\r
+ realm);\r
+ }\r
+ }\r
+ }\r
+\r
+ rv = pprofile_flush(profile);\r
+\r
+ pprofile_release(profile);\r
+ }\r
+\r
+ if (rv) {\r
+ khui_alert * alert;\r
+ wchar_t title[KHUI_MAXCCH_TITLE];\r
+ wchar_t fmsg[KHUI_MAXCCH_MESSAGE];\r
+ wchar_t msg[KHUI_MAXCCH_MESSAGE];\r
+ wchar_t sugg[KHUI_MAXCCH_SUGGESTION];\r
+\r
+ LoadString(hResModule, IDS_K5ERR_CANTWRITEPROFILE,\r
+ title, ARRAYLENGTH(title));\r
+ if (rv)\r
+ LoadString(hResModule, IDS_K5ERR_PROFNOWRITE,\r
+ fmsg, ARRAYLENGTH(fmsg));\r
+\r
+ LoadString(hResModule, IDS_K5ERR_PROFSUGGEST,\r
+ sugg, ARRAYLENGTH(sugg));\r
+\r
+ StringCbPrintf(msg, sizeof(msg), fmsg, config_file);\r
+\r
+ khui_alert_create_empty(&alert);\r
+ khui_alert_set_severity(alert, (rv)?KHERR_ERROR:KHERR_WARNING);\r
+ khui_alert_set_title(alert, title);\r
+ khui_alert_set_message(alert, msg);\r
+ khui_alert_set_suggestion(alert, sugg);\r
+ \r
+ khui_alert_show(alert);\r
+ }\r
+\r
+ d->flags = 0;\r
+}\r
+\r
+/* actual dialog stuff */\r
+\r
+#define IDX_NORMAL 1\r
+#define IDX_MODIFIED 2\r
+#define IDX_NEW 3\r
+#define IDX_DELETED 4\r
+\r
+static k5_config_data k5_config_dlg_data;\r
+static khm_boolean k5_dlg_data_valid = FALSE;\r
\r
INT_PTR CALLBACK \r
k5_config_dlgproc(HWND hwnd,\r
case WM_INITDIALOG:\r
{\r
HWND hw;\r
- wchar_t * realms;\r
- wchar_t * defrealm;\r
+ khm_size i;\r
+ k5_config_data * d;\r
+\r
wchar_t * t;\r
- char conffile[MAX_PATH];\r
- wchar_t wconffile[MAX_PATH];\r
wchar_t importopts[256];\r
WKSTA_INFO_100 * winfo100;\r
\r
- hw = GetDlgItem(hwnd, IDC_CFG_DEFREALM);\r
#ifdef DEBUG\r
- assert(hw);\r
+ assert(!k5_dlg_data_valid);\r
#endif\r
- realms = khm_krb5_get_realm_list();\r
- defrealm = khm_krb5_get_default_realm();\r
+\r
+ k5_init_config_data(&k5_config_dlg_data);\r
+ k5_read_config_data(&k5_config_dlg_data);\r
+\r
+ k5_dlg_data_valid = TRUE;\r
+\r
+ d = &k5_config_dlg_data;\r
+\r
+ d->node_main = (khui_config_node) lParam;\r
+\r
+ hw = GetDlgItem(hwnd, IDC_CFG_DEFREALM);\r
#ifdef DEBUG\r
- assert(realms);\r
- assert(defrealm);\r
+ assert(hw);\r
#endif\r
\r
SendMessage(hw, CB_RESETCONTENT, 0, 0);\r
\r
- for(t = realms; t && *t; t = multi_string_next(t)) {\r
- SendMessage(hw, CB_ADDSTRING, 0, (LPARAM) t);\r
+ for (i=0; i < d->n_realms; i++) {\r
+ SendMessage(hw, CB_ADDSTRING, 0,\r
+ (LPARAM) d->realms[i].realm);\r
}\r
\r
- SendMessage(hw, CB_SELECTSTRING, -1, (LPARAM) defrealm);\r
-\r
- free(defrealm);\r
- free(realms);\r
-\r
- khm_get_profile_file(conffile, sizeof(conffile));\r
+ SendMessage(hw, CB_SELECTSTRING, -1,\r
+ (LPARAM) d->def_realm);\r
\r
- AnsiStrToUnicode(wconffile, sizeof(wconffile), conffile);\r
-\r
- SetDlgItemText(hwnd, IDC_CFG_CFGFILE, wconffile);\r
+ SetDlgItemText(hwnd, IDC_CFG_CFGFILE, d->config_file);\r
\r
/* hostname/domain */\r
if (NetWkstaGetInfo(NULL, 100, (LPBYTE *) &winfo100) == NERR_Success) {\r
SendMessage(hw, CB_ADDSTRING, 0, (LPARAM) t);\r
}\r
\r
- SendMessage(hw, CB_SETCURSEL, 0, 0);\r
- \r
+ SendMessage(hw, CB_SETCURSEL, 0, d->lsa_import);\r
+ t = importopts;\r
+ SendMessage(hw, CB_GETLBTEXT, d->lsa_import,(LPARAM) t);\r
+ SendMessage(hw, CB_SELECTSTRING, -1, (LPARAM) t);\r
}\r
break;\r
\r
- case WM_DESTROY:\r
+ case WM_COMMAND:\r
+ {\r
+ k5_config_data * d;\r
+\r
+ d = &k5_config_dlg_data;\r
+\r
+ if (wParam == MAKEWPARAM(IDC_CFG_IMPORT, CBN_SELCHANGE)) {\r
+ int idx;\r
+ int modified = FALSE;\r
+\r
+ idx = (int) SendDlgItemMessage(hwnd, IDC_CFG_IMPORT,\r
+ CB_GETCURSEL, 0, 0);\r
+ if (idx != CB_ERR && idx != d->lsa_import) {\r
+ d->lsa_import = idx;\r
+ d->flags |= K5_CDFLAG_MOD_LSA_IMPORT;\r
+ modified = TRUE;\r
+ }\r
+\r
+ khui_cfg_set_flags(d->node_main,\r
+ (modified)?KHUI_CNFLAG_MODIFIED:0,\r
+ KHUI_CNFLAG_MODIFIED);\r
+ return TRUE;\r
+ }\r
+ }\r
break;\r
- }\r
- return FALSE;\r
-}\r
\r
-INT_PTR CALLBACK \r
-k5_realms_dlgproc(HWND hwndDlg,\r
- UINT uMsg,\r
- WPARAM wParam,\r
- LPARAM lParam) {\r
- switch(uMsg) {\r
- case WM_INITDIALOG:\r
+ case KHUI_WM_CFG_NOTIFY:\r
+ {\r
+ k5_config_data * d;\r
+\r
+ d = &k5_config_dlg_data;\r
+\r
+ if (HIWORD(wParam) == WMCFG_APPLY) {\r
+ khm_int32 oflags;\r
+\r
+ oflags = d->flags;\r
+ k5_write_config_data(d);\r
+\r
+ if (d->flags != oflags) {\r
+ khui_cfg_set_flags(d->node_main,\r
+ KHUI_CNFLAG_APPLIED,\r
+ KHUI_CNFLAG_APPLIED |\r
+ KHUI_CNFLAG_MODIFIED);\r
+ }\r
+ return TRUE;\r
+ }\r
+ }\r
break;\r
\r
case WM_DESTROY:\r
+ {\r
+ k5_free_config_data(&k5_config_dlg_data);\r
+ k5_dlg_data_valid = FALSE;\r
+ }\r
break;\r
}\r
return FALSE;\r
}\r
\r
-typedef struct tag_k5_ids_dlg_data {\r
- khui_tracker tc_life;\r
- khui_tracker tc_renew;\r
- khui_tracker tc_life_min;\r
- khui_tracker tc_life_max;\r
- khui_tracker tc_renew_min;\r
- khui_tracker tc_renew_max;\r
-\r
- time_t life;\r
- time_t renew_life;\r
- time_t life_min;\r
- time_t life_max;\r
- time_t renew_min;\r
- time_t renew_max;\r
-} k5_ids_dlg_data;\r
+static HIMAGELIST\r
+k5_get_state_image_list(void) {\r
+ HIMAGELIST hil;\r
+ HICON hicon;\r
+\r
+ hil = ImageList_Create(GetSystemMetrics(SM_CXSMICON),\r
+ GetSystemMetrics(SM_CYSMICON),\r
+ ILC_COLOR | ILC_MASK,\r
+ 4,\r
+ 2);\r
+\r
+ hicon = LoadImage(hResModule,\r
+ MAKEINTRESOURCE(IDI_NORMAL),\r
+ IMAGE_ICON,\r
+ GetSystemMetrics(SM_CXSMICON),\r
+ GetSystemMetrics(SM_CYSMICON),\r
+ LR_DEFAULTCOLOR);\r
+\r
+ ImageList_AddIcon(hil, hicon);\r
+\r
+ DestroyIcon(hicon);\r
+\r
+ hicon = LoadImage(hResModule,\r
+ MAKEINTRESOURCE(IDI_MODIFIED),\r
+ IMAGE_ICON,\r
+ GetSystemMetrics(SM_CXSMICON),\r
+ GetSystemMetrics(SM_CYSMICON),\r
+ LR_DEFAULTCOLOR);\r
+\r
+ ImageList_AddIcon(hil, hicon);\r
+\r
+ DestroyIcon(hicon);\r
+\r
+ hicon = LoadImage(hResModule,\r
+ MAKEINTRESOURCE(IDI_NEW),\r
+ IMAGE_ICON,\r
+ GetSystemMetrics(SM_CXSMICON),\r
+ GetSystemMetrics(SM_CYSMICON),\r
+ LR_DEFAULTCOLOR);\r
+\r
+ ImageList_AddIcon(hil, hicon);\r
+\r
+ DestroyIcon(hicon);\r
+\r
+ hicon = LoadImage(hResModule,\r
+ MAKEINTRESOURCE(IDI_DELETED),\r
+ IMAGE_ICON,\r
+ GetSystemMetrics(SM_CXSMICON),\r
+ GetSystemMetrics(SM_CYSMICON),\r
+ LR_DEFAULTCOLOR);\r
+\r
+ ImageList_AddIcon(hil, hicon);\r
+\r
+ DestroyIcon(hicon);\r
+\r
+ return hil;\r
+}\r
+\r
+static void\r
+k5_update_realms_display(HWND hw_list, k5_config_data * d) {\r
+ khm_size i;\r
+ LVITEM lvi;\r
+ wchar_t buf[64];\r
+\r
+ ListView_DeleteAllItems(hw_list);\r
+\r
+ for (i=0; i < d->n_realms; i++) {\r
+ if ((d->realms[i].flags & K5_RDFLAG_DELETED) &&\r
+ (d->realms[i].flags & K5_RDFLAG_NEW))\r
+ continue;\r
+\r
+ ZeroMemory(&lvi, sizeof(lvi));\r
+ lvi.mask = LVIF_PARAM | LVIF_STATE | LVIF_TEXT;\r
+ lvi.iItem = 0;\r
+ lvi.iSubItem = 0;\r
+ lvi.pszText = d->realms[i].realm;\r
+ lvi.lParam = i;\r
+\r
+ if (d->realms[i].flags & K5_RDFLAG_DELETED) {\r
+ lvi.state = INDEXTOSTATEIMAGEMASK(IDX_DELETED);\r
+ } else if (d->realms[i].flags & K5_RDFLAG_NEW) {\r
+ lvi.state = INDEXTOSTATEIMAGEMASK(IDX_NEW);\r
+ } else if (d->realms[i].flags & K5_RDFLAG_MODIFED) {\r
+ lvi.state = INDEXTOSTATEIMAGEMASK(IDX_MODIFIED);\r
+ } else {\r
+ lvi.state = INDEXTOSTATEIMAGEMASK(IDX_NORMAL);\r
+ }\r
+ lvi.stateMask = LVIS_STATEIMAGEMASK;\r
+\r
+ ListView_InsertItem(hw_list, &lvi);\r
+ }\r
+\r
+ ZeroMemory(&lvi, sizeof(lvi));\r
+ lvi.mask = LVIF_PARAM | LVIF_STATE | LVIF_TEXT;\r
+ lvi.iItem = 0;\r
+ lvi.iSubItem = 0;\r
+ lvi.pszText = buf;\r
+ lvi.lParam = (LPARAM) -1;\r
+\r
+ LoadString(hResModule, IDS_CFG_RE_NEWREALM,\r
+ buf, ARRAYLENGTH(buf));\r
+\r
+ lvi.state = INDEXTOSTATEIMAGEMASK(IDX_NEW);\r
+ lvi.stateMask = LVIS_STATEIMAGEMASK;\r
+\r
+ ListView_InsertItem(hw_list, &lvi);\r
+\r
+ if (d->flags & K5_CDFLAG_MOD_REALMS) {\r
+ khui_cfg_set_flags(d->node_realm, KHUI_CNFLAG_MODIFIED,\r
+ KHUI_CNFLAG_MODIFIED);\r
+ } else {\r
+ khui_cfg_set_flags(d->node_realm, 0,\r
+ KHUI_CNFLAG_MODIFIED);\r
+ }\r
+}\r
\r
static void\r
-k5_ids_read_params(k5_ids_dlg_data * d) {\r
- khm_int32 t;\r
- khm_int32 rv;\r
+k5_update_kdcs_display(HWND hw_kdc, k5_config_data * d, khm_size idx_rlm) {\r
+ khm_size k;\r
+ LVITEM lvi;\r
+ int idx_item;\r
+ k5_realm_kdc * pkdc;\r
+ wchar_t wyes[8];\r
+ wchar_t wno[8];\r
+ wchar_t wbuf[64];\r
+\r
+ ListView_DeleteAllItems(hw_kdc);\r
+\r
+ if (d == NULL)\r
+ return;\r
\r
#ifdef DEBUG\r
- assert(csp_params);\r
+ assert(idx_rlm < d->n_realms);\r
#endif\r
+ LoadString(hResModule, IDS_YES, wyes, ARRAYLENGTH(wyes));\r
+ LoadString(hResModule, IDS_NO, wno, ARRAYLENGTH(wno));\r
+\r
+ for (k=0; k < d->realms[idx_rlm].n_kdcs; k++) {\r
+ if ((d->realms[idx_rlm].kdcs[k].flags & K5_RKFLAG_DELETED) &&\r
+ (d->realms[idx_rlm].kdcs[k].flags & K5_RKFLAG_NEW))\r
+ continue;\r
+\r
+ pkdc = &(d->realms[idx_rlm].kdcs[k]);\r
+\r
+ ZeroMemory(&lvi, sizeof(lvi));\r
+ lvi.mask = LVIF_PARAM | LVIF_STATE | LVIF_TEXT;\r
+ lvi.iItem = K5_MAX_KDC;\r
+ lvi.iSubItem = 0;\r
+ lvi.lParam = k;\r
+ lvi.pszText = pkdc->name;\r
+ if (pkdc->flags & K5_RKFLAG_DELETED) {\r
+ lvi.state = INDEXTOSTATEIMAGEMASK(IDX_DELETED);\r
+ } else if (pkdc->flags & K5_RKFLAG_NEW) {\r
+ lvi.state = INDEXTOSTATEIMAGEMASK(IDX_NEW);\r
+ } else if ((pkdc->flags & K5_RKFLAG_MOD_ADMIN) ||\r
+ (pkdc->flags & K5_RKFLAG_MOD_MASTER)) {\r
+ lvi.state = INDEXTOSTATEIMAGEMASK(IDX_MODIFIED);\r
+ } else {\r
+ lvi.state = INDEXTOSTATEIMAGEMASK(IDX_NORMAL);\r
+ }\r
+ lvi.stateMask = LVIS_STATEIMAGEMASK;\r
+\r
+ idx_item = ListView_InsertItem(hw_kdc, &lvi);\r
+\r
+ lvi.mask = LVIF_TEXT;\r
+ lvi.iItem = idx_item;\r
+ lvi.iSubItem = 1;\r
+ if (pkdc->admin)\r
+ lvi.pszText = wyes;\r
+ else\r
+ lvi.pszText = wno;\r
+ ListView_SetItem(hw_kdc, &lvi);\r
+\r
+ lvi.iSubItem = 2;\r
+ if (pkdc->master)\r
+ lvi.pszText = wyes;\r
+ else\r
+ lvi.pszText = wno;\r
+ ListView_SetItem(hw_kdc, &lvi);\r
+ }\r
+\r
+ ZeroMemory(&lvi, sizeof(lvi));\r
+ lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;\r
+ lvi.iItem = 0;\r
+ lvi.iSubItem = 0;\r
+ lvi.pszText = wbuf;\r
+ lvi.lParam = (LPARAM) -1;\r
+ lvi.state = INDEXTOSTATEIMAGEMASK(IDX_NEW);\r
+ lvi.stateMask = LVIS_STATEIMAGEMASK;\r
\r
- rv = khc_read_int32(csp_params, L"DefaultLifetime", &t);\r
- assert(KHM_SUCCEEDED(rv));\r
- d->life = t;\r
-\r
- rv = khc_read_int32(csp_params, L"DefaultRenewLifetime", &t);\r
- assert(KHM_SUCCEEDED(rv));\r
- d->renew_life = t;\r
-\r
- rv = khc_read_int32(csp_params, L"MaxLifetime", &t);\r
- assert(KHM_SUCCEEDED(rv));\r
- d->life_max = t;\r
-\r
- rv = khc_read_int32(csp_params, L"MinLifetime", &t);\r
- assert(KHM_SUCCEEDED(rv));\r
- d->life_min = t;\r
-\r
- rv = khc_read_int32(csp_params, L"MaxRenewLifetime", &t);\r
- assert(KHM_SUCCEEDED(rv));\r
- d->renew_max = t;\r
-\r
- rv = khc_read_int32(csp_params, L"MinRenewLifetime", &t);\r
- assert(KHM_SUCCEEDED(rv));\r
- d->renew_min = t;\r
-\r
- khui_tracker_initialize(&d->tc_life);\r
- d->tc_life.current = d->life;\r
- d->tc_life.min = 0;\r
- d->tc_life.max = 3600 * 24 * 7;\r
-\r
- khui_tracker_initialize(&d->tc_renew);\r
- d->tc_renew.current = d->renew_life;\r
- d->tc_renew.min = 0;\r
- d->tc_renew.max = 3600 * 24 * 30;\r
-\r
- khui_tracker_initialize(&d->tc_life_min);\r
- d->tc_life_min.current = d->life_min;\r
- d->tc_life_min.min = d->tc_life.min;\r
- d->tc_life_min.max = d->tc_life.max;\r
-\r
- khui_tracker_initialize(&d->tc_life_max);\r
- d->tc_life_max.current = d->life_max;\r
- d->tc_life_max.min = d->tc_life.min;\r
- d->tc_life_max.max = d->tc_life.max;\r
-\r
- khui_tracker_initialize(&d->tc_renew_min);\r
- d->tc_renew_min.current = d->renew_min;\r
- d->tc_renew_min.min = d->tc_renew.min;\r
- d->tc_renew_min.max = d->tc_renew.max;\r
-\r
- khui_tracker_initialize(&d->tc_renew_max);\r
- d->tc_renew_max.current = d->renew_max;\r
- d->tc_renew_max.min = d->tc_renew.min;\r
- d->tc_renew_max.max = d->tc_renew.max;\r
+ LoadString(hResModule, IDS_CFG_RE_NEWSERVER,\r
+ wbuf, ARRAYLENGTH(wbuf));\r
+\r
+ ListView_InsertItem(hw_kdc, &lvi);\r
}\r
\r
-INT_PTR CALLBACK \r
-k5_ids_tab_dlgproc(HWND hwnd,\r
- UINT uMsg,\r
- WPARAM wParam,\r
- LPARAM lParam) {\r
- k5_ids_dlg_data * d;\r
+static void\r
+k5_update_dmap_display(HWND hw_dm, k5_config_data * d, khm_size idx_rlm) {\r
+ khm_size m;\r
+ LVITEM lvi;\r
+ k5_domain_map * map;\r
+ wchar_t wbuf[64];\r
+\r
+ ListView_DeleteAllItems(hw_dm);\r
+\r
+ if (d == NULL)\r
+ return;\r
\r
- switch(uMsg) {\r
- case WM_INITDIALOG:\r
- d = malloc(sizeof(*d));\r
#ifdef DEBUG\r
- assert(d);\r
+ assert(idx_rlm < d->n_realms);\r
#endif\r
- ZeroMemory(d, sizeof(*d));\r
-#pragma warning(push)\r
-#pragma warning(disable: 4244)\r
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d);\r
-#pragma warning(pop)\r
\r
- k5_ids_read_params(d);\r
-\r
- khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_DEFLIFE),\r
- &d->tc_life);\r
- khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_DEFRLIFE),\r
- &d->tc_renew);\r
- khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_LRNG_MIN),\r
- &d->tc_life_min);\r
- khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_LRNG_MAX),\r
- &d->tc_life_max);\r
- khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_RLRNG_MIN),\r
- &d->tc_renew_min);\r
- khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_RLRNG_MAX),\r
- &d->tc_renew_max);\r
- khui_tracker_refresh(&d->tc_life);\r
- khui_tracker_refresh(&d->tc_life_min);\r
- khui_tracker_refresh(&d->tc_life_max);\r
- khui_tracker_refresh(&d->tc_renew);\r
- khui_tracker_refresh(&d->tc_renew_min);\r
- khui_tracker_refresh(&d->tc_renew_max);\r
- break;\r
+ for (m=0; m < d->realms[idx_rlm].n_domain_maps; m++) {\r
+ map = &(d->realms[idx_rlm].domain_maps[m]);\r
\r
- case WM_DESTROY:\r
- d = (k5_ids_dlg_data *) (LONG_PTR)\r
- GetWindowLongPtr(hwnd, DWLP_USER);\r
-\r
- khui_tracker_kill_controls(&d->tc_life);\r
- khui_tracker_kill_controls(&d->tc_renew);\r
- khui_tracker_kill_controls(&d->tc_life_min);\r
- khui_tracker_kill_controls(&d->tc_life_max);\r
- khui_tracker_kill_controls(&d->tc_renew_min);\r
- khui_tracker_kill_controls(&d->tc_renew_max);\r
- break;\r
+ if ((map->flags & K5_DMFLAG_NEW) &&\r
+ (map->flags & K5_DMFLAG_DELETED))\r
+ continue;\r
+\r
+ ZeroMemory(&lvi, sizeof(lvi));\r
+\r
+ lvi.mask = LVIF_TEXT | LVIF_STATE | LVIF_PARAM;\r
+ lvi.pszText = map->name;\r
+ if (map->flags & K5_DMFLAG_DELETED)\r
+ lvi.state = INDEXTOSTATEIMAGEMASK(IDX_DELETED);\r
+ else if (map->flags & K5_DMFLAG_NEW)\r
+ lvi.state = INDEXTOSTATEIMAGEMASK(IDX_NEW);\r
+ else\r
+ lvi.state = INDEXTOSTATEIMAGEMASK(IDX_NORMAL);\r
+ lvi.stateMask = LVIS_STATEIMAGEMASK;\r
+ lvi.lParam = m;\r
+\r
+ lvi.iItem = K5_MAX_DOMAIN_MAPPINGS;\r
+ lvi.iSubItem = 0;\r
+\r
+ ListView_InsertItem(hw_dm, &lvi);\r
}\r
- return FALSE;\r
+\r
+ ZeroMemory(&lvi, sizeof(lvi));\r
+ lvi.mask = LVIF_PARAM | LVIF_TEXT | LVIF_STATE;\r
+ lvi.pszText = wbuf;\r
+ lvi.lParam = (LPARAM) -1;\r
+ lvi.state = INDEXTOSTATEIMAGEMASK(IDX_NEW);\r
+ lvi.stateMask = LVIS_STATEIMAGEMASK;\r
+ lvi.iItem = 0;\r
+ lvi.iSubItem = 0;\r
+\r
+ LoadString(hResModule, IDS_CFG_RE_NEWDMAP,\r
+ wbuf, ARRAYLENGTH(wbuf));\r
+\r
+ ListView_InsertItem(hw_dm, &lvi);\r
}\r
\r
INT_PTR CALLBACK \r
-k5_id_tab_dlgproc(HWND hwndDlg,\r
+k5_realms_dlgproc(HWND hwnd,\r
UINT uMsg,\r
WPARAM wParam,\r
LPARAM lParam) {\r
+ k5_config_data * d;\r
+\r
+ d = &k5_config_dlg_data;\r
+\r
switch(uMsg) {\r
case WM_INITDIALOG:\r
+ {\r
+ LVCOLUMN lvc;\r
+ HWND hw;\r
+ RECT r;\r
+ wchar_t buf[256];\r
+\r
+ assert(k5_dlg_data_valid);\r
+\r
+ d->node_realm = (khui_config_node) lParam;\r
+\r
+ /* set up columns for the Realms list */\r
+ hw = GetDlgItem(hwnd, IDC_CFG_REALMS);\r
+#ifdef DEBUG\r
+ assert(hw);\r
+#endif\r
+ GetWindowRect(hw, &r);\r
+ r.right -= 5; /* shave a few pixels off the width */\r
+ ZeroMemory(&lvc, sizeof(lvc));\r
+ lvc.mask = LVCF_TEXT | LVCF_WIDTH;\r
+ lvc.pszText = buf;\r
+ lvc.cx = (r.right - r.left);\r
+ LoadString(hResModule, IDS_CFG_RE_REALMS,\r
+ buf, ARRAYLENGTH(buf));\r
+\r
+ ListView_InsertColumn(hw, 0, &lvc);\r
+\r
+ ListView_SetImageList(hw,\r
+ k5_get_state_image_list(),\r
+ LVSIL_STATE);\r
+\r
+ k5_update_realms_display(hw, d);\r
+\r
+ /* set up columns for the servers list */\r
+ hw = GetDlgItem(hwnd, IDC_CFG_KDC);\r
+#ifdef DEBUG\r
+ assert(hw);\r
+#endif\r
+ GetWindowRect(hw, &r);\r
+ r.right -= 5;\r
+ ZeroMemory(&lvc, sizeof(lvc));\r
+ lvc.mask = LVCF_TEXT | LVCF_WIDTH;\r
+ lvc.pszText = buf;\r
+ lvc.cx = (r.right - r.left) * 2 / 4;\r
+ LoadString(hResModule, IDS_CFG_RE_HEAD_SVR,\r
+ buf, ARRAYLENGTH(buf));\r
+\r
+ ListView_InsertColumn(hw, 0, &lvc);\r
+\r
+ lvc.cx = (r.right - r.left) * 1 / 4;\r
+ LoadString(hResModule, IDS_CFG_RE_HEAD_ADMIN,\r
+ buf, ARRAYLENGTH(buf));\r
+ ListView_InsertColumn(hw, 1, &lvc);\r
+\r
+ LoadString(hResModule, IDS_CFG_RE_HEAD_MASTER,\r
+ buf, ARRAYLENGTH(buf));\r
+ ListView_InsertColumn(hw, 2, &lvc);\r
+\r
+ ListView_SetImageList(hw,\r
+ k5_get_state_image_list(),\r
+ LVSIL_STATE);\r
+\r
+ /* set up columns for the domain/host mapping list */\r
+ hw = GetDlgItem(hwnd, IDC_CFG_DMAP);\r
+#ifdef DEBUG\r
+ assert(hw);\r
+#endif\r
+ GetWindowRect(hw, &r);\r
+ r.right -= 5;\r
+ ZeroMemory(&lvc, sizeof(lvc));\r
+ lvc.mask = LVCF_TEXT | LVCF_WIDTH;\r
+ lvc.pszText = buf;\r
+ lvc.cx = (r.right - r.left);\r
+ LoadString(hResModule, IDS_CFG_RE_HEAD_DOMAIN,\r
+ buf, ARRAYLENGTH(buf));\r
+\r
+ ListView_InsertColumn(hw, 0, &lvc);\r
+\r
+\r
+ ListView_SetImageList(hw,\r
+ k5_get_state_image_list(),\r
+ LVSIL_STATE);\r
+ }\r
+ break;\r
+\r
+ case WM_NOTIFY:\r
+ {\r
+ LPNMHDR pnmh;\r
+ HWND hw_rlm = NULL;\r
+ HWND hw_kdc = NULL;\r
+ HWND hw_dmp = NULL;\r
+ int i;\r
+\r
+ pnmh = (LPNMHDR) lParam;\r
+\r
+ if (pnmh->idFrom == IDC_CFG_REALMS) {\r
+\r
+ hw_rlm = pnmh->hwndFrom;\r
+\r
+ switch(pnmh->code) {\r
+ case LVN_ITEMCHANGED:\r
+ i = ListView_GetSelectedCount(hw_rlm);\r
+ hw_kdc = GetDlgItem(hwnd, IDC_CFG_KDC);\r
+ hw_dmp = GetDlgItem(hwnd, IDC_CFG_DMAP);\r
+\r
+ d->c_realm = (khm_size) -1;\r
+ \r
+ if (i == 1) {\r
+ LVITEM lvi;\r
+\r
+ i = ListView_GetNextItem(hw_rlm, -1,\r
+ LVNI_SELECTED);\r
+ if (i == -1)\r
+ goto _no_selection;\r
+\r
+ ZeroMemory(&lvi, sizeof(lvi));\r
+\r
+ lvi.iItem = i;\r
+ lvi.iSubItem = 0;\r
+ lvi.mask = LVIF_PARAM;\r
+\r
+ ListView_GetItem(hw_rlm, &lvi);\r
+\r
+ if (lvi.lParam == -1)\r
+ goto _no_selection;\r
+\r
+ d->c_realm = lvi.lParam;\r
+\r
+ k5_update_kdcs_display(hw_kdc, d, lvi.lParam);\r
+ k5_update_dmap_display(hw_dmp, d, lvi.lParam);\r
+ return TRUE;\r
+ }\r
+\r
+ _no_selection:\r
+ ListView_DeleteAllItems(hw_kdc);\r
+ ListView_DeleteAllItems(hw_dmp);\r
+ break;\r
+\r
+ case LVN_BEGINLABELEDIT:\r
+ {\r
+ NMLVDISPINFO * pdisp;\r
+ LVITEM lvi;\r
+\r
+ pdisp = (NMLVDISPINFO *) lParam;\r
+\r
+ ZeroMemory(&lvi, sizeof(lvi));\r
+ lvi.iItem = pdisp->item.iItem;\r
+ lvi.mask = LVIF_PARAM;\r
+\r
+ ListView_GetItem(hw_rlm, &lvi);\r
+\r
+ if (pdisp->item.iItem == -1 ||\r
+ lvi.lParam != -1) {\r
+ SetWindowLongPtr(hwnd, DWL_MSGRESULT, TRUE);\r
+ } else {\r
+ /* allow editing */\r
+ HWND hw_edit;\r
+\r
+ hw_edit = ListView_GetEditControl(hw_rlm);\r
+ if (hw_edit != NULL) {\r
+ SendMessage(hw_edit,\r
+ EM_SETLIMITTEXT,\r
+ K5_MAXCCH_REALM - 1,\r
+ 0);\r
+ }\r
+ SetWindowLongPtr(hwnd, DWL_MSGRESULT, FALSE);\r
+ }\r
+\r
+ return TRUE;\r
+ }\r
+ break;\r
+\r
+ case LVN_ENDLABELEDIT:\r
+ {\r
+ NMLVDISPINFO * pdisp;\r
+ khm_size n;\r
+\r
+ pdisp = (NMLVDISPINFO *) lParam;\r
+\r
+ if (pdisp->item.pszText) {\r
+ n = d->n_realms;\r
+ k5_assert_n_realms(d, n+1);\r
+ StringCbCopy(d->realms[n].realm,\r
+ sizeof(d->realms[n].realm),\r
+ pdisp->item.pszText);\r
+ d->realms[n].flags = K5_RDFLAG_NEW;\r
+ d->n_realms++;\r
+\r
+ d->flags |= K5_CDFLAG_MOD_REALMS;\r
+\r
+ k5_update_realms_display(hw_rlm, d);\r
+ }\r
+\r
+ return TRUE;\r
+ }\r
+ break;\r
+\r
+ case LVN_KEYDOWN:\r
+ {\r
+ NMLVKEYDOWN * pnmk;\r
+ LVITEM lvi;\r
+ khm_size r;\r
+ int idx;\r
+ BOOL modified = FALSE;\r
+\r
+ pnmk = (NMLVKEYDOWN *) lParam;\r
+\r
+ if (pnmk->wVKey == VK_DELETE) {\r
+ idx = -1;\r
+ while((idx = ListView_GetNextItem(hw_rlm, idx,\r
+ LVNI_SELECTED))\r
+ != -1) {\r
+ ZeroMemory(&lvi, sizeof(lvi));\r
+ lvi.iItem = idx;\r
+ lvi.iSubItem = 0;\r
+ lvi.mask = LVIF_PARAM;\r
+\r
+ ListView_GetItem(hw_rlm, &lvi);\r
+\r
+ if (lvi.lParam != -1 &&\r
+ (r = lvi.lParam) < d->n_realms) {\r
+ d->realms[r].flags ^= K5_RDFLAG_DELETED;\r
+ modified = TRUE;\r
+ }\r
+ }\r
+\r
+ if (modified) {\r
+ d->flags |= K5_CDFLAG_MOD_REALMS;\r
+\r
+ k5_purge_config_data(d, TRUE, TRUE, TRUE);\r
+ k5_update_realms_display(hw_rlm, d);\r
+ k5_update_dmap_display(GetDlgItem(hwnd, IDC_CFG_DMAP), NULL, 0);\r
+ k5_update_kdcs_display(GetDlgItem(hwnd, IDC_CFG_KDC), NULL, 0);\r
+ }\r
+ return TRUE;\r
+ }\r
+ }\r
+ break;\r
+ }\r
+ } else if (pnmh->idFrom == IDC_CFG_KDC) {\r
+ hw_kdc = pnmh->hwndFrom;\r
+\r
+ switch (pnmh->code) {\r
+ case LVN_BEGINLABELEDIT:\r
+ {\r
+ NMLVDISPINFO * pdisp;\r
+ LVITEM lvi;\r
+\r
+ pdisp = (NMLVDISPINFO *) lParam;\r
+\r
+ ZeroMemory(&lvi, sizeof(lvi));\r
+ lvi.iItem = pdisp->item.iItem;\r
+ lvi.mask = LVIF_PARAM;\r
+\r
+ ListView_GetItem(hw_kdc, &lvi);\r
+\r
+ if (pdisp->item.iItem == -1 ||\r
+ lvi.lParam != -1) {\r
+ SetWindowLongPtr(hwnd, DWL_MSGRESULT, TRUE);\r
+ } else {\r
+ /* allow editing */\r
+ HWND hw_edit;\r
+\r
+ hw_edit = ListView_GetEditControl(hw_kdc);\r
+ if (hw_edit != NULL) {\r
+ SendMessage(hw_edit,\r
+ EM_SETLIMITTEXT,\r
+ K5_MAXCCH_HOST - 1,\r
+ 0);\r
+ }\r
+ SetWindowLongPtr(hwnd, DWL_MSGRESULT, FALSE);\r
+ }\r
+ return TRUE;\r
+ }\r
+ break;\r
+\r
+ case LVN_ENDLABELEDIT:\r
+ {\r
+ NMLVDISPINFO * pdisp;\r
+ khm_size r;\r
+ khm_size k;\r
+\r
+ r = d->c_realm;\r
+\r
+ pdisp = (NMLVDISPINFO *) lParam;\r
+\r
+ if (pdisp->item.pszText) {\r
+ k = d->realms[r].n_kdcs;\r
+\r
+ if (k >= K5_MAX_KDC) {\r
+ SetWindowLongPtr(hwnd, DWL_MSGRESULT, FALSE);\r
+ /* TODO: show a message box saying\r
+ there are too many KDC's\r
+ already. */\r
+ return TRUE;\r
+ }\r
+\r
+ StringCbCopy(d->realms[r].kdcs[k].name,\r
+ sizeof(d->realms[0].kdcs[0].name),\r
+ pdisp->item.pszText);\r
+ d->realms[r].kdcs[k].flags = K5_RKFLAG_NEW;\r
+ d->realms[r].n_kdcs++;\r
+\r
+ d->realms[r].flags |= K5_RDFLAG_MODIFED;\r
+\r
+ k5_update_kdcs_display(hw_kdc, d, d->c_realm);\r
+ }\r
+ return TRUE;\r
+ }\r
+ break;\r
+\r
+ case LVN_KEYDOWN:\r
+ {\r
+#if 0\r
+ NMLVKEYDOWN * pnmk;\r
+ LVITEM lvi;\r
+ khm_size r;\r
+ int idx;\r
+ BOOL modified = FALSE;\r
+\r
+ pnmk = (NMLVKEYDOWN *) lParam;\r
+\r
+ if (pnmk->wVKey == VK_DELETE) {\r
+ idx = -1;\r
+ while((idx = ListView_GetNextItem(hw_rlm, idx,\r
+ LVNI_SELECTED))\r
+ != -1) {\r
+ ZeroMemory(&lvi, sizeof(lvi));\r
+ lvi.iItem = idx;\r
+ lvi.iSubItem = 0;\r
+ lvi.mask = LVIF_PARAM;\r
+\r
+ ListView_GetItem(hw_rlm, &lvi);\r
+\r
+ if (lvi.lParam != -1 &&\r
+ (r = lvi.lParam) < d->n_realms) {\r
+ d->realms[r].flags ^= K5_RDFLAG_DELETED;\r
+ modified = TRUE;\r
+ }\r
+ }\r
+\r
+ if (modified) {\r
+ d->flags |= K5_CDFLAG_MOD_REALMS;\r
+\r
+ k5_purge_config_data(d, TRUE, TRUE, TRUE);\r
+ k5_update_realms_display(hw_rlm, d);\r
+ k5_update_dmap_display(GetDlgItem(hwnd, IDC_CFG_DMAP), NULL, 0);\r
+ k5_update_kdcs_display(GetDlgItem(hwnd, IDC_CFG_KDC), NULL, 0);\r
+ }\r
+ return TRUE;\r
+ }\r
+#endif\r
+ }\r
+ break;\r
+ }\r
+ }\r
+ }\r
break;\r
\r
case WM_DESTROY:\r
return FALSE;\r
}\r
\r
-\r
void\r
k5_register_config_panels(void) {\r
khui_config_node node;\r
#endif\r
}\r
\r
+#ifdef REALM_EDITOR\r
ZeroMemory(®, sizeof(reg));\r
\r
LoadString(hResModule, IDS_K5RLM_SHORT_DESC,\r
reg.flags = 0;\r
\r
khui_cfg_register(node, ®);\r
+#endif\r
+\r
+ ZeroMemory(®, sizeof(reg));\r
+\r
+ LoadString(hResModule, IDS_K5CCC_SHORT_DESC,\r
+ wshort, ARRAYLENGTH(wshort));\r
+ LoadString(hResModule, IDS_K5CCC_LONG_DESC,\r
+ wlong, ARRAYLENGTH(wlong));\r
+\r
+ reg.name = L"KerberosCCaches";\r
+ reg.short_desc = wshort;\r
+ reg.long_desc = wlong;\r
+ reg.h_module = hResModule;\r
+ reg.dlg_template = MAKEINTRESOURCE(IDD_CFG_CACHES);\r
+ reg.dlg_proc = k5_ccconfig_dlgproc;\r
+ reg.flags = 0;\r
+\r
+ khui_cfg_register(node, ®);\r
\r
khui_cfg_release(node);\r
\r
void\r
k5_unregister_config_panels(void) {\r
khui_config_node node_main;\r
+#ifdef REALM_EDITOR\r
khui_config_node node_realms;\r
+#endif\r
khui_config_node node_ids;\r
khui_config_node node_tab;\r
+ khui_config_node node_ccaches;\r
\r
if (KHM_FAILED(khui_cfg_open(NULL, L"Kerberos5", &node_main))) {\r
node_main = NULL;\r
#endif\r
}\r
\r
+#ifdef REALM_EDITOR\r
if (KHM_SUCCEEDED(khui_cfg_open(node_main, L"KerberosRealms", \r
&node_realms))) {\r
khui_cfg_remove(node_realms);\r
else\r
assert(FALSE);\r
#endif\r
+#endif\r
+\r
+ if (KHM_SUCCEEDED(khui_cfg_open(node_main, L"KerberosCCaches",\r
+ &node_ccaches))) {\r
+ khui_cfg_remove(node_ccaches);\r
+ khui_cfg_release(node_ccaches);\r
+ }\r
+#ifdef DEBUG\r
+ else\r
+ assert(FALSE);\r
+#endif\r
\r
if (node_main) {\r
khui_cfg_remove(node_main);\r
--- /dev/null
+/*\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#include<krbcred.h>\r
+#include<krb5.h>\r
+#include<assert.h>\r
+#include<lm.h>\r
+#include<commctrl.h>\r
+\r
+#pragma warning(push)\r
+#pragma warning(disable: 4995)\r
+#include<shlwapi.h>\r
+#pragma warning(pop)\r
+\r
+typedef struct tag_k5_id_dlg_data {\r
+ khui_config_init_data cfg;\r
+\r
+ khm_handle ident;\r
+\r
+ khui_tracker tc_life;\r
+ khui_tracker tc_renew;\r
+\r
+ wchar_t ccache[KRB5_MAXCCH_CCNAME];\r
+\r
+ time_t life;\r
+ time_t renew_life;\r
+} k5_id_dlg_data;\r
+\r
+static void\r
+k5_id_read_params(k5_id_dlg_data * d) {\r
+\r
+ wchar_t idname[KCDB_IDENT_MAXCCH_NAME];\r
+ khm_size cb;\r
+ khm_int32 rv;\r
+ khm_int32 t;\r
+ khm_handle csp_ident;\r
+ khm_handle csp_idroot = NULL;\r
+\r
+ cb = sizeof(idname);\r
+ khui_cfg_get_name(d->cfg.ctx_node, idname, &cb);\r
+\r
+ rv = kcdb_identity_create(idname, 0, &d->ident);\r
+#ifdef DEBUG\r
+ assert(KHM_SUCCEEDED(rv));\r
+#endif\r
+\r
+ rv = kcdb_identity_get_config(d->ident, 0, &csp_idroot);\r
+ if (KHM_SUCCEEDED(rv) &&\r
+ KHM_SUCCEEDED(khc_open_space(csp_idroot, CSNAME_KRB5CRED, 0,\r
+ &csp_ident))) {\r
+ khc_shadow_space(csp_ident, csp_params);\r
+ } else {\r
+ csp_ident = csp_params;\r
+ }\r
+\r
+ if (csp_idroot)\r
+ khc_close_space(csp_idroot);\r
+\r
+ rv = khc_read_int32(csp_ident, L"DefaultLifetime", &t);\r
+ if (KHM_SUCCEEDED(rv))\r
+ d->life = t;\r
+ else\r
+ d->life = 36000;\r
+\r
+ rv = khc_read_int32(csp_ident, L"DefaultRenewLifetime", &t);\r
+ if (KHM_SUCCEEDED(rv))\r
+ d->renew_life = t;\r
+ else\r
+ d->renew_life = 604800;\r
+\r
+ cb = sizeof(d->ccache);\r
+ rv = khc_read_string(csp_ident, L"DefaultCCName", d->ccache, &cb);\r
+ if (KHM_FAILED(rv))\r
+ ZeroMemory(d->ccache, sizeof(d->ccache));\r
+\r
+ khui_tracker_initialize(&d->tc_life);\r
+ d->tc_life.current = d->life;\r
+ d->tc_life.min = 0;\r
+ d->tc_life.max = 3600 * 24 * 7;\r
+\r
+ khui_tracker_initialize(&d->tc_renew);\r
+ d->tc_renew.current = d->renew_life;\r
+ d->tc_renew.min = 0;\r
+ d->tc_renew.max = 3600 * 24 * 30;\r
+\r
+ if (csp_ident != csp_params)\r
+ khc_close_space(csp_ident);\r
+}\r
+\r
+static khm_boolean\r
+k5_id_is_mod(HWND hw, k5_id_dlg_data * d) {\r
+ wchar_t ccache[KRB5_MAXCCH_CCNAME];\r
+\r
+ GetDlgItemText(hw, IDC_CFG_CCACHE, ccache, ARRAYLENGTH(ccache));\r
+\r
+ if (wcsicmp(ccache, d->ccache) ||\r
+ d->tc_renew.current != d->renew_life ||\r
+ d->tc_life.current != d->life)\r
+ return TRUE;\r
+ return FALSE;\r
+}\r
+\r
+static void\r
+k5_id_check_mod(HWND hw, k5_id_dlg_data * d) {\r
+ BOOL modified = k5_id_is_mod(hw, d);\r
+\r
+ khui_cfg_set_flags_inst(&d->cfg,\r
+ (modified)?KHUI_CNFLAG_MODIFIED:0,\r
+ KHUI_CNFLAG_MODIFIED);\r
+}\r
+\r
+static void\r
+k5_id_write_params(HWND hw, k5_id_dlg_data * d) {\r
+\r
+ khm_handle csp_idroot = NULL;\r
+ khm_handle csp_ident = NULL;\r
+ wchar_t ccache[KRB5_MAXCCH_CCNAME];\r
+ khm_size cb;\r
+ khm_int32 rv;\r
+\r
+ if (!k5_id_is_mod(hw, d))\r
+ return;\r
+\r
+ rv = kcdb_identity_get_config(d->ident, KHM_FLAG_CREATE, &csp_idroot);\r
+ if (KHM_SUCCEEDED(rv)) {\r
+ khc_open_space(csp_idroot, CSNAME_KRB5CRED,\r
+ KHM_FLAG_CREATE,\r
+ &csp_ident);\r
+ }\r
+\r
+ if (csp_idroot)\r
+ khc_close_space(csp_idroot);\r
+\r
+ if (!csp_ident)\r
+ return;\r
+\r
+ if (d->life != d->tc_life.current) {\r
+ d->life = d->tc_life.current;\r
+ khc_write_int32(csp_ident, L"DefaultLifetime", (khm_int32) d->life);\r
+ }\r
+\r
+ if (d->renew_life != d->tc_renew.current) {\r
+ d->renew_life = d->tc_renew.current;\r
+ khc_write_int32(csp_ident, L"DefaultRenewLifetime", (khm_int32) d->renew_life);\r
+ }\r
+\r
+ GetDlgItemText(hw, IDC_CFG_CCACHE, ccache, ARRAYLENGTH(ccache));\r
+\r
+ if (SUCCEEDED(StringCbLength(ccache, sizeof(ccache), &cb)) &&\r
+ wcsicmp(ccache, d->ccache)) {\r
+ khc_write_string(csp_ident, L"DefaultCCName", ccache);\r
+ StringCbCopy(d->ccache, sizeof(d->ccache), ccache);\r
+ } else {\r
+ khc_remove_value(csp_ident, L"DefaultCCName", KCONF_FLAG_USER);\r
+ }\r
+\r
+ if (csp_ident)\r
+ khc_close_space(csp_ident);\r
+\r
+ khui_cfg_set_flags_inst(&d->cfg,\r
+ KHUI_CNFLAG_APPLIED,\r
+ KHUI_CNFLAG_APPLIED | KHUI_CNFLAG_MODIFIED);\r
+}\r
+\r
+INT_PTR CALLBACK \r
+k5_id_tab_dlgproc(HWND hwnd,\r
+ UINT uMsg,\r
+ WPARAM wParam,\r
+ LPARAM lParam) {\r
+\r
+ k5_id_dlg_data * d;\r
+\r
+ switch(uMsg) {\r
+ case WM_INITDIALOG:\r
+ d = PMALLOC(sizeof(*d));\r
+#ifdef DEBUG\r
+ assert(d);\r
+#endif\r
+ ZeroMemory(d, sizeof(*d));\r
+\r
+ d->cfg = *((khui_config_init_data *) lParam);\r
+\r
+#pragma warning(push)\r
+#pragma warning(disable: 4244)\r
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d);\r
+#pragma warning(pop)\r
+\r
+ k5_id_read_params(d);\r
+\r
+ khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_DEFLIFE),\r
+ &d->tc_life);\r
+ khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_DEFRLIFE),\r
+ &d->tc_renew);\r
+ khui_tracker_refresh(&d->tc_life);\r
+ khui_tracker_refresh(&d->tc_renew);\r
+\r
+ SetDlgItemText(hwnd, IDC_CFG_CCACHE, d->ccache);\r
+ break;\r
+\r
+ case WM_COMMAND:\r
+ d = (k5_id_dlg_data *) (LONG_PTR)\r
+ GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+ if (HIWORD(wParam) == EN_CHANGE)\r
+ k5_id_check_mod(hwnd, d);\r
+ break;\r
+\r
+ case KHUI_WM_CFG_NOTIFY:\r
+ d = (k5_id_dlg_data *) (LONG_PTR)\r
+ GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+ if (HIWORD(wParam) == WMCFG_APPLY) {\r
+ k5_id_write_params(hwnd, d);\r
+ }\r
+ break;\r
+\r
+ case WM_DESTROY:\r
+ d = (k5_id_dlg_data *) (LONG_PTR)\r
+ GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+ khui_tracker_kill_controls(&d->tc_life);\r
+ khui_tracker_kill_controls(&d->tc_renew);\r
+\r
+ if (d->ident)\r
+ kcdb_identity_release(d->ident);\r
+\r
+ PFREE(d);\r
+ break;\r
+ }\r
+ return FALSE;\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#include<krbcred.h>\r
+#include<krb5.h>\r
+#include<assert.h>\r
+#include<lm.h>\r
+#include<commctrl.h>\r
+\r
+#pragma warning(push)\r
+#pragma warning(disable: 4995)\r
+#include<shlwapi.h>\r
+#pragma warning(pop)\r
+\r
+typedef struct tag_k5_ids_dlg_data {\r
+ khui_config_init_data cfg;\r
+\r
+ khui_tracker tc_life;\r
+ khui_tracker tc_renew;\r
+ khui_tracker tc_life_min;\r
+ khui_tracker tc_life_max;\r
+ khui_tracker tc_renew_min;\r
+ khui_tracker tc_renew_max;\r
+\r
+ time_t life;\r
+ time_t renew_life;\r
+ time_t life_min;\r
+ time_t life_max;\r
+ time_t renew_min;\r
+ time_t renew_max;\r
+} k5_ids_dlg_data;\r
+\r
+static khm_boolean\r
+k5_ids_is_mod(k5_ids_dlg_data * d) {\r
+ if (d->life != d->tc_life.current ||\r
+ d->renew_life != d->tc_renew.current ||\r
+ d->life_max != d->tc_life_max.current ||\r
+ d->life_min != d->tc_life_min.current ||\r
+ d->renew_max != d->tc_renew_max.current ||\r
+ d->renew_min != d->tc_renew_min.current)\r
+ return TRUE;\r
+ return FALSE;\r
+}\r
+\r
+static void\r
+k5_ids_check_mod(k5_ids_dlg_data * d) {\r
+ BOOL modified = k5_ids_is_mod(d);\r
+\r
+ khui_cfg_set_flags_inst(&d->cfg,\r
+ (modified)?KHUI_CNFLAG_MODIFIED:0,\r
+ KHUI_CNFLAG_MODIFIED);\r
+}\r
+\r
+static void\r
+k5_ids_write_params(k5_ids_dlg_data * d) {\r
+\r
+ khm_int32 rv;\r
+\r
+#ifdef DEBUG\r
+ assert(csp_params);\r
+#endif\r
+\r
+ if (!k5_ids_is_mod(d))\r
+ return;\r
+\r
+#define WRITEPARAM(po,pn,vn) \\r
+ if (po != pn) { \\r
+ po = pn; \\r
+ rv = khc_write_int32(csp_params, vn, (khm_int32) po); \\r
+ assert(KHM_SUCCEEDED(rv)); \\r
+ }\r
+ \r
+ WRITEPARAM(d->life,d->tc_life.current, L"DefaultLifetime");\r
+ WRITEPARAM(d->renew_life,d->tc_renew.current, L"DefaultRenewLifetime");\r
+ WRITEPARAM(d->life_max,d->tc_life_max.current, L"MaxLifetime");\r
+ WRITEPARAM(d->life_min,d->tc_life_min.current, L"MinLifetime");\r
+ WRITEPARAM(d->renew_max,d->tc_renew_max.current, L"MaxRenewLifetime");\r
+ WRITEPARAM(d->renew_min,d->tc_renew_min.current, L"MinRenewLifetime");\r
+\r
+#undef WRITEPARAM\r
+\r
+ khui_cfg_set_flags_inst(&d->cfg,\r
+ KHUI_CNFLAG_APPLIED,\r
+ KHUI_CNFLAG_APPLIED | KHUI_CNFLAG_MODIFIED);\r
+}\r
+\r
+static void\r
+k5_ids_read_params(k5_ids_dlg_data * d) {\r
+ khm_int32 t;\r
+ khm_int32 rv;\r
+\r
+#ifdef DEBUG\r
+ assert(csp_params);\r
+#endif\r
+\r
+ rv = khc_read_int32(csp_params, L"DefaultLifetime", &t);\r
+ assert(KHM_SUCCEEDED(rv));\r
+ d->life = t;\r
+\r
+ rv = khc_read_int32(csp_params, L"DefaultRenewLifetime", &t);\r
+ assert(KHM_SUCCEEDED(rv));\r
+ d->renew_life = t;\r
+\r
+ rv = khc_read_int32(csp_params, L"MaxLifetime", &t);\r
+ assert(KHM_SUCCEEDED(rv));\r
+ d->life_max = t;\r
+\r
+ rv = khc_read_int32(csp_params, L"MinLifetime", &t);\r
+ assert(KHM_SUCCEEDED(rv));\r
+ d->life_min = t;\r
+\r
+ rv = khc_read_int32(csp_params, L"MaxRenewLifetime", &t);\r
+ assert(KHM_SUCCEEDED(rv));\r
+ d->renew_max = t;\r
+\r
+ rv = khc_read_int32(csp_params, L"MinRenewLifetime", &t);\r
+ assert(KHM_SUCCEEDED(rv));\r
+ d->renew_min = t;\r
+\r
+ khui_tracker_initialize(&d->tc_life);\r
+ d->tc_life.current = d->life;\r
+ d->tc_life.min = 0;\r
+ d->tc_life.max = 3600 * 24 * 7;\r
+\r
+ khui_tracker_initialize(&d->tc_renew);\r
+ d->tc_renew.current = d->renew_life;\r
+ d->tc_renew.min = 0;\r
+ d->tc_renew.max = 3600 * 24 * 30;\r
+\r
+ khui_tracker_initialize(&d->tc_life_min);\r
+ d->tc_life_min.current = d->life_min;\r
+ d->tc_life_min.min = d->tc_life.min;\r
+ d->tc_life_min.max = d->tc_life.max;\r
+\r
+ khui_tracker_initialize(&d->tc_life_max);\r
+ d->tc_life_max.current = d->life_max;\r
+ d->tc_life_max.min = d->tc_life.min;\r
+ d->tc_life_max.max = d->tc_life.max;\r
+\r
+ khui_tracker_initialize(&d->tc_renew_min);\r
+ d->tc_renew_min.current = d->renew_min;\r
+ d->tc_renew_min.min = d->tc_renew.min;\r
+ d->tc_renew_min.max = d->tc_renew.max;\r
+\r
+ khui_tracker_initialize(&d->tc_renew_max);\r
+ d->tc_renew_max.current = d->renew_max;\r
+ d->tc_renew_max.min = d->tc_renew.min;\r
+ d->tc_renew_max.max = d->tc_renew.max;\r
+}\r
+\r
+INT_PTR CALLBACK \r
+k5_ids_tab_dlgproc(HWND hwnd,\r
+ UINT uMsg,\r
+ WPARAM wParam,\r
+ LPARAM lParam) {\r
+ k5_ids_dlg_data * d;\r
+\r
+ switch(uMsg) {\r
+ case WM_INITDIALOG:\r
+ d = PMALLOC(sizeof(*d));\r
+#ifdef DEBUG\r
+ assert(d);\r
+#endif\r
+ ZeroMemory(d, sizeof(*d));\r
+#pragma warning(push)\r
+#pragma warning(disable: 4244)\r
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) d);\r
+#pragma warning(pop)\r
+\r
+ d->cfg = *((khui_config_init_data *) lParam);\r
+\r
+ k5_ids_read_params(d);\r
+\r
+ khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_DEFLIFE),\r
+ &d->tc_life);\r
+ khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_DEFRLIFE),\r
+ &d->tc_renew);\r
+ khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_LRNG_MIN),\r
+ &d->tc_life_min);\r
+ khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_LRNG_MAX),\r
+ &d->tc_life_max);\r
+ khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_RLRNG_MIN),\r
+ &d->tc_renew_min);\r
+ khui_tracker_install(GetDlgItem(hwnd, IDC_CFG_RLRNG_MAX),\r
+ &d->tc_renew_max);\r
+ khui_tracker_refresh(&d->tc_life);\r
+ khui_tracker_refresh(&d->tc_life_min);\r
+ khui_tracker_refresh(&d->tc_life_max);\r
+ khui_tracker_refresh(&d->tc_renew);\r
+ khui_tracker_refresh(&d->tc_renew_min);\r
+ khui_tracker_refresh(&d->tc_renew_max);\r
+ break;\r
+\r
+ case WM_COMMAND:\r
+ d = (k5_ids_dlg_data *) (LONG_PTR)\r
+ GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+ if (HIWORD(wParam) == EN_CHANGE) {\r
+ k5_ids_check_mod(d);\r
+ }\r
+ break;\r
+\r
+ case KHUI_WM_CFG_NOTIFY:\r
+ d = (k5_ids_dlg_data *) (LONG_PTR)\r
+ GetWindowLongPtr(hwnd, DWLP_USER);\r
+ if (HIWORD(wParam) == WMCFG_APPLY) {\r
+ k5_ids_write_params(d);\r
+ }\r
+ break;\r
+\r
+ case WM_DESTROY:\r
+ d = (k5_ids_dlg_data *) (LONG_PTR)\r
+ GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+ khui_tracker_kill_controls(&d->tc_life);\r
+ khui_tracker_kill_controls(&d->tc_renew);\r
+ khui_tracker_kill_controls(&d->tc_life_min);\r
+ khui_tracker_kill_controls(&d->tc_life_max);\r
+ khui_tracker_kill_controls(&d->tc_renew_min);\r
+ khui_tracker_kill_controls(&d->tc_renew_max);\r
+\r
+ PFREE(d);\r
+ break;\r
+ }\r
+ return FALSE;\r
+}\r
+\r
/*\r
-* Copyright (c) 2004 Massachusetts Institute of Technology\r
+* Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
!pkrb524_convert_creds_kdc)\r
return 0;\r
\r
- v4creds = (CREDENTIALS *) malloc(sizeof(CREDENTIALS));\r
+ v4creds = (CREDENTIALS *) PMALLOC(sizeof(CREDENTIALS));\r
memset((char *) v4creds, 0, sizeof(CREDENTIALS));\r
\r
memset((char *) &increds, 0, sizeof(increds));\r
\r
cleanup:\r
memset(v4creds, 0, sizeof(v4creds));\r
- free(v4creds);\r
+ PFREE(v4creds);\r
\r
if (v5creds) {\r
pkrb5_free_creds(ctx, v5creds);\r
cc_name = (*pkrb5_cc_get_name)(ctx, cache);\r
if(cc_name) {\r
namelen = strlen(cc_name);\r
- namelen = (namelen + 1 + 4) * sizeof(wchar_t);\r
- /* the +4 is for the possible addtion of API: during the\r
- cannonicalization process */\r
- wcc_name = malloc(namelen);\r
+ namelen = (namelen + 1 + 5) * sizeof(wchar_t);\r
+ /* the +5 is for the possible addtion of API: or FILE:\r
+ during the cannonicalization process */\r
+ wcc_name = PMALLOC(namelen);\r
AnsiStrToUnicode(wcc_name, namelen, cc_name);\r
khm_krb5_canon_cc_name(wcc_name, namelen);\r
}\r
&KRBv5Credentials))) \r
{\r
khm_handle tident = NULL;\r
+ khm_int32 cred_flags = 0;\r
\r
if(ClientName != NULL)\r
(*pkrb5_free_unparsed_name)(ctx, ClientName);\r
eft -= ft;\r
kcdb_cred_set_attr(cred, KCDB_ATTR_LIFETIME, &eft, sizeof(eft));\r
\r
- if (KRBv5Credentials.times.renew_till >= 0) {\r
+ if (KRBv5Credentials.times.renew_till > 0) {\r
tt = KRBv5Credentials.times.renew_till;\r
TimetToFileTime(tt, (LPFILETIME) &eft);\r
kcdb_cred_set_attr(cred, KCDB_ATTR_RENEW_EXPIRE, &eft, \r
\r
/* special flags understood by NetIDMgr */\r
{\r
- khm_int32 oflags, nflags;\r
-\r
- kcdb_cred_get_flags(cred, &oflags);\r
- nflags = oflags;\r
+ khm_int32 nflags = 0;\r
\r
if (ti & TKT_FLG_RENEWABLE)\r
nflags |= KCDB_CRED_FLAG_RENEWABLE;\r
if (ti & TKT_FLG_INITIAL)\r
nflags |= KCDB_CRED_FLAG_INITIAL;\r
+ else {\r
+ krb5_data * c0, *c1, *r;\r
+\r
+ /* these are macros that do not allocate any memory */\r
+ c0 = krb5_princ_component(ctx,KRBv5Credentials.server,0);\r
+ c1 = krb5_princ_component(ctx,KRBv5Credentials.server,1);\r
+ r = krb5_princ_realm(ctx,KRBv5Credentials.server);\r
+\r
+ if ( c0 && c1 && r && c1->length == r->length && \r
+ !strncmp(c1->data,r->data,r->length) &&\r
+ !strncmp("krbtgt",c0->data,c0->length) )\r
+ nflags |= KCDB_CRED_FLAG_INITIAL;\r
+ }\r
+\r
+ kcdb_cred_set_flags(cred, nflags, KCDB_CRED_FLAGMASK_EXT);\r
\r
- if (oflags != nflags)\r
- kcdb_cred_set_flags(cred, nflags, KCDB_CRED_FLAGMASK_ALL);\r
+ cred_flags = nflags;\r
}\r
\r
if ( !pkrb5_decode_ticket(&KRBv5Credentials.ticket, &tkt)) {\r
\r
ti = KRBv5Credentials.keyblock.enctype;\r
kcdb_cred_set_attr(cred, attr_id_key_enctype, &ti, sizeof(ti));\r
-\r
- kcdb_cred_set_attr(cred, KCDB_ATTR_LOCATION, wcc_name, KCDB_CBSIZE_AUTO);\r
+ kcdb_cred_set_attr(cred, KCDB_ATTR_LOCATION, wcc_name, \r
+ KCDB_CBSIZE_AUTO);\r
\r
/*TODO: going here */\r
#if 0\r
}\r
#endif\r
\r
- if(KRBv5Credentials.ticket_flags & TKT_FLG_INITIAL) {\r
+ if(cred_flags & KCDB_CRED_FLAG_INITIAL) {\r
+ __int64 t_issue_new;\r
__int64 t_expire_old;\r
__int64 t_expire_new;\r
khm_size cb;\r
tt = KRBv5Credentials.times.endtime;\r
TimetToFileTime(tt, (LPFILETIME) &t_expire_new);\r
\r
+ tt = KRBv5Credentials.times.starttime;\r
+ TimetToFileTime(tt, (LPFILETIME) &t_issue_new);\r
+\r
cb = sizeof(t_expire_old);\r
if(KHM_FAILED(kcdb_identity_get_attr(tident, \r
KCDB_ATTR_EXPIRE, \r
kcdb_identity_set_attr(tident, KCDB_ATTR_EXPIRE, \r
&t_expire_new, \r
sizeof(t_expire_new));\r
+ kcdb_identity_set_attr(tident, KCDB_ATTR_ISSUE,\r
+ &t_issue_new,\r
+ sizeof(t_issue_new));\r
\r
- if (KRBv5Credentials.times.renew_till >= 0) {\r
+ if (KRBv5Credentials.times.renew_till > 0) {\r
tt = KRBv5Credentials.times.renew_till;\r
TimetToFileTime(tt, (LPFILETIME) &ft);\r
kcdb_identity_set_attr(tident, \r
\r
_exit:\r
if(wcc_name)\r
- free(wcc_name);\r
+ PFREE(wcc_name);\r
\r
return code;\r
}\r
khm_krb5_list_tickets(krb5_context *krbv5Context)\r
{\r
krb5_context ctx;\r
- krb5_ccache cache;\r
+ krb5_ccache cache = 0;\r
krb5_error_code code;\r
- apiCB * cc_ctx = 0;\r
- struct _infoNC ** pNCi = NULL;\r
- int i;\r
+ apiCB * cc_ctx = 0;\r
+ struct _infoNC ** pNCi = NULL;\r
+ int i;\r
+ khm_int32 t;\r
+ wchar_t * ms = NULL;\r
+ khm_size cb;\r
\r
ctx = NULL;\r
cache = NULL;\r
cache = 0;\r
}\r
\r
+ if (KHM_SUCCEEDED(khc_read_int32(csp_params, L"MsLsaList", &t)) && t) {\r
+ code = (*pkrb5_cc_resolve)(ctx, "MSLSA:", &cache);\r
+\r
+ if (code == 0 && cache) {\r
+ code = get_tickets_from_cache(ctx, cache);\r
+ }\r
+\r
+ if (ctx != NULL && cache != NULL)\r
+ (*pkrb5_cc_close)(ctx, cache);\r
+ cache = 0;\r
+ }\r
+\r
+ if (khc_read_multi_string(csp_params, L"FileCCList", NULL, &cb)\r
+ == KHM_ERROR_TOO_LONG &&\r
+ cb > sizeof(wchar_t) * 2) {\r
+ wchar_t * t;\r
+ char ccname[MAX_PATH + 6];\r
+\r
+ ms = PMALLOC(cb);\r
+#ifdef DEBUG\r
+ assert(ms);\r
+#endif\r
+ khc_read_multi_string(csp_params, L"FileCCList", ms, &cb);\r
+\r
+ for(t = ms; t && *t; t = multi_string_next(t)) {\r
+ StringCchPrintfA(ccname, ARRAYLENGTH(ccname),\r
+ "FILE:%S", t);\r
+\r
+ code = (*pkrb5_cc_resolve)(ctx, ccname, &cache);\r
+\r
+ if (code)\r
+ continue;\r
+\r
+ code = get_tickets_from_cache(ctx, cache);\r
+\r
+ if (ctx != NULL && cache != NULL)\r
+ (*pkrb5_cc_close)(ctx, cache);\r
+ cache = 0;\r
+ }\r
+\r
+ PFREE(ms);\r
+ }\r
+\r
_exit:\r
if (pNCi)\r
(*pcc_free_NC_info)(cc_ctx, &pNCi);\r
kcdb_credset_collect(NULL, krb5_credset, NULL, credtype_id_krb5, NULL);\r
\r
return(code);\r
-\r
}\r
\r
int\r
realm = krb5_princ_realm(ctx, me);\r
\r
code = pkrb5_build_principal_ext(ctx, &server,\r
- realm->length,realm->data,\r
- KRB5_TGS_NAME_SIZE, KRB5_TGS_NAME,\r
- realm->length,realm->data,\r
- 0);\r
+ realm->length,realm->data,\r
+ KRB5_TGS_NAME_SIZE, KRB5_TGS_NAME,\r
+ realm->length,realm->data,\r
+ 0);\r
\r
if (code) \r
goto cleanup;\r
while ( local_addrs[i++] );\r
addr_count = i + 1;\r
\r
- addrs = (krb5_address **) malloc((addr_count+1) * sizeof(krb5_address *));\r
+ addrs = (krb5_address **) PMALLOC((addr_count+1) * sizeof(krb5_address *));\r
if ( !addrs ) {\r
pkrb5_free_addresses(ctx, local_addrs);\r
assert(0);\r
memset(addrs, 0, sizeof(krb5_address *) * (addr_count+1));\r
i = 0;\r
while ( local_addrs[i] ) {\r
- addrs[i] = (krb5_address *)malloc(sizeof(krb5_address));\r
+ addrs[i] = (krb5_address *)PMALLOC(sizeof(krb5_address));\r
if (addrs[i] == NULL) {\r
pkrb5_free_addresses(ctx, local_addrs);\r
assert(0);\r
addrs[i]->magic = local_addrs[i]->magic;\r
addrs[i]->addrtype = local_addrs[i]->addrtype;\r
addrs[i]->length = local_addrs[i]->length;\r
- addrs[i]->contents = (unsigned char *)malloc(addrs[i]->length);\r
+ addrs[i]->contents = (unsigned char *)PMALLOC(addrs[i]->length);\r
if (!addrs[i]->contents) {\r
pkrb5_free_addresses(ctx, local_addrs);\r
assert(0);\r
}\r
pkrb5_free_addresses(ctx, local_addrs);\r
\r
- addrs[i] = (krb5_address *)malloc(sizeof(krb5_address));\r
+ addrs[i] = (krb5_address *)PMALLOC(sizeof(krb5_address));\r
if (addrs[i] == NULL)\r
assert(0);\r
\r
addrs[i]->magic = KV5M_ADDRESS;\r
addrs[i]->addrtype = AF_INET;\r
addrs[i]->length = 4;\r
- addrs[i]->contents = (unsigned char *)malloc(addrs[i]->length);\r
+ addrs[i]->contents = (unsigned char *)PMALLOC(addrs[i]->length);\r
if (!addrs[i]->contents)\r
assert(0);\r
\r
for ( i=0;i<addr_count;i++ ) {\r
if ( addrs[i] ) {\r
if ( addrs[i]->contents )\r
- free(addrs[i]->contents);\r
- free(addrs[i]);\r
+ PFREE(addrs[i]->contents);\r
+ PFREE(addrs[i]);\r
}\r
}\r
}\r
\r
colon = wcschr(wcc_name, L':');\r
\r
- if (colon)\r
+ if (colon) {\r
+ /* if the colon is just 1 character away from the beginning,\r
+ it's a FILE: cc */\r
+ if (colon - wcc_name == 1) {\r
+ if (cb_len + 5 * sizeof(wchar_t) > cb_cc_name)\r
+ return KHM_ERROR_TOO_LONG;\r
+\r
+ memmove(&wcc_name[5], &wcc_name[0], cb_len);\r
+ memmove(&wcc_name[0], L"FILE:", sizeof(wchar_t) * 5);\r
+ }\r
+\r
return 0;\r
+ }\r
\r
if (cb_len + 4 * sizeof(wchar_t) > cb_cc_name)\r
return KHM_ERROR_TOO_LONG;\r
#define KRB_FILE "KRB.CON"\r
#define KRBREALM_FILE "KRBREALM.CON"\r
#define KRB5_FILE "KRB5.INI"\r
+#define KRB5_TMP_FILE "KRB5.INI.TMP"\r
+\r
+BOOL \r
+khm_krb5_get_temp_profile_file(LPSTR confname, UINT szConfname)\r
+{\r
+ GetTempPathA(szConfname, confname);\r
+ confname[szConfname-1] = '\0';\r
+ StringCchCatA(confname, szConfname, KRB5_TMP_FILE);\r
+ confname[szConfname-1] = '\0';\r
+ return FALSE;\r
+}\r
\r
BOOL \r
-khm_get_profile_file(LPSTR confname, UINT szConfname)\r
+khm_krb5_get_profile_file(LPSTR confname, UINT szConfname)\r
{\r
char **configFile = NULL;\r
if (pkrb5_get_default_config_files(&configFile)) \r
{\r
GetWindowsDirectoryA(confname,szConfname);\r
confname[szConfname-1] = '\0';\r
- strncat(confname, "\\",sizeof(confname)-strlen(confname));\r
+ strncat(confname, "\\",sizeof(confname)-strlen(confname));\r
confname[szConfname-1] = '\0';\r
- strncat(confname, KRB5_FILE,sizeof(confname)-strlen(confname));\r
+ strncat(confname, KRB5_FILE,sizeof(confname)-strlen(confname));\r
confname[szConfname-1] = '\0';\r
return FALSE;\r
}\r
{\r
GetWindowsDirectoryA(confname,szConfname);\r
confname[szConfname-1] = '\0';\r
- strncat(confname, "\\",sizeof(confname)-strlen(confname));\r
+ strncat(confname, "\\",sizeof(confname)-strlen(confname));\r
confname[szConfname-1] = '\0';\r
- strncat(confname, KRB5_FILE,sizeof(confname)-strlen(confname));\r
+ strncat(confname, KRB5_FILE,sizeof(confname)-strlen(confname));\r
confname[szConfname-1] = '\0';\r
}\r
\r
LPSTR pFind;\r
\r
//strcpy(krbConFile, CLeashApp::m_krbv5_profile->first_file->filename);\r
- if (khm_get_profile_file(krbConFile, sizeof(krbConFile))) {\r
+ if (khm_krb5_get_profile_file(krbConFile, sizeof(krbConFile))) {\r
GetWindowsDirectoryA(krbConFile,sizeof(krbConFile));\r
krbConFile[MAX_PATH-1] = '\0';\r
strncat(krbConFile, "\\",sizeof(krbConFile)-strlen(krbConFile));\r
\r
char krb5_conf[MAX_PATH+1];\r
\r
- if (!khm_get_profile_file(krb5_conf,sizeof(krb5_conf))) {\r
+ if (!khm_krb5_get_profile_file(krb5_conf,sizeof(krb5_conf))) {\r
profile_t profile;\r
long retval;\r
const char *filenames[2];\r
}\r
cbsize += sizeof(wchar_t); /* double null terminated */\r
\r
- rlist = malloc(cbsize);\r
+ rlist = PMALLOC(cbsize);\r
d = rlist;\r
for (cpp = sections; *cpp; cpp++)\r
{\r
\r
/*TODO: compute the actual required buffer size instead of hardcoding */\r
cbsize = 16384; // arbitrary\r
- rlist = malloc(cbsize);\r
+ rlist = PMALLOC(cbsize);\r
d = rlist;\r
\r
// Skip the default realm\r
\r
if (def) {\r
cch = strlen(def) + 1;\r
- realm = malloc(sizeof(wchar_t) * cch);\r
+ realm = PMALLOC(sizeof(wchar_t) * cch);\r
AnsiStrToUnicode(realm, sizeof(wchar_t) * cch, def);\r
pkrb5_free_default_realm(ctx, def);\r
} else\r
return realm;\r
}\r
\r
+long\r
+khm_krb5_set_default_realm(wchar_t * realm) {\r
+ krb5_context ctx=0;\r
+ char * def = 0;\r
+ long rv = 0;\r
+ char astr[K5_MAXCCH_REALM];\r
+\r
+ UnicodeStrToAnsi(astr, sizeof(astr), realm);\r
+\r
+ pkrb5_init_context(&ctx);\r
+ pkrb5_get_default_realm(ctx,&def);\r
+\r
+ if ((def && strcmp(def, astr)) ||\r
+ !def) {\r
+ rv = pkrb5_set_default_realm(ctx, astr);\r
+ }\r
+\r
+ if (def) {\r
+ pkrb5_free_default_realm(ctx, def);\r
+ }\r
+\r
+ pkrb5_free_context(ctx);\r
+\r
+ return rv;\r
+}\r
+\r
wchar_t * khm_get_realm_from_princ(wchar_t * princ) {\r
wchar_t * t;\r
\r
(result_string.length ? (sizeof(": ") - 1) : 0) +\r
result_string.length;\r
if (len && error_str) {\r
- *error_str = malloc(len + 1);\r
+ *error_str = PMALLOC(len + 1);\r
if (*error_str)\r
StringCchPrintfA(*error_str, len+1,\r
"%.*s%s%.*s",\r
\r
return rc;\r
}\r
+\r
+khm_int32 KHMAPI\r
+khm_krb5_creds_is_equal(khm_handle vcred1, khm_handle vcred2, void * dummy) {\r
+ if (kcdb_creds_comp_attr(vcred1, vcred2, KCDB_ATTR_LOCATION) ||\r
+ kcdb_creds_comp_attr(vcred1, vcred2, attr_id_key_enctype) ||\r
+ kcdb_creds_comp_attr(vcred1, vcred2, attr_id_tkt_enctype))\r
+ return 1;\r
+ else\r
+ return 0;\r
+}\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
wchar_t * \r
khm_krb5_get_default_realm(void);\r
\r
+long\r
+khm_krb5_set_default_realm(wchar_t * realm);\r
+\r
wchar_t * \r
khm_krb5_get_realm_list(void);\r
\r
const wchar_t * cc_name_2);\r
\r
BOOL \r
-khm_get_profile_file(LPSTR confname, UINT szConfname);\r
+khm_krb5_get_profile_file(LPSTR confname, UINT szConfname);\r
+\r
+BOOL \r
+khm_krb5_get_temp_profile_file(LPSTR confname, UINT szConfname);\r
+\r
+khm_int32 KHMAPI\r
+khm_krb5_creds_is_equal(khm_handle vcred1, khm_handle vcred2, void * dummy);\r
\r
#endif\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
HWND hw_realm;\r
} k5_new_cred_data;\r
\r
+/* Runs in the UI thread */\r
int \r
k5_get_realm_from_nc(khui_new_creds * nc, \r
wchar_t * buf, \r
return;\r
}\r
\r
+/* runs in the UI thread */\r
static BOOL\r
update_crossfeed(khui_new_creds * nc,\r
k5_new_cred_data * d,\r
wchar_t realm[KCDB_IDENT_MAXCCH_NAME];\r
khm_size cch;\r
khm_size cch_left;\r
+ int idx;\r
\r
cch = (khm_size) GetWindowTextLength(d->hw_username);\r
#ifdef DEBUG\r
return FALSE;\r
\r
if (ctrl_id_src == K5_NCID_UN) {\r
+\r
+ idx = (int)SendMessage(d->hw_realm,\r
+ CB_FINDSTRINGEXACT,\r
+ (WPARAM) -1,\r
+ (LPARAM) un_realm);\r
+\r
+ if (idx != CB_ERR) {\r
+ wchar_t srealm[KCDB_IDENT_MAXCCH_NAME];\r
+\r
+ cch = SendMessage(d->hw_realm,\r
+ CB_GETLBTEXTLEN,\r
+ (WPARAM) idx,\r
+ 0);\r
+\r
+#ifdef DEBUG\r
+ assert(cch < ARRAYLENGTH(srealm) - 1);\r
+#endif\r
+ SendMessage(d->hw_realm,\r
+ CB_GETLBTEXT,\r
+ (WPARAM) idx,\r
+ (LPARAM) srealm);\r
+\r
+ if (!wcsicmp(srealm, un_realm) && wcscmp(srealm, un_realm)) {\r
+ /* differ only by case */\r
+\r
+ StringCchCopy(un_realm, ARRAYLENGTH(un) - (un_realm - un),\r
+ srealm);\r
+\r
+ SetWindowText(d->hw_username, un);\r
+ }\r
+ }\r
+\r
SendMessage(d->hw_realm,\r
CB_SELECTSTRING,\r
(WPARAM) -1,\r
GetWindowText(d->hw_realm, realm,\r
ARRAYLENGTH(realm));\r
\r
+ idx = (int)SendMessage(d->hw_realm,\r
+ CB_FINDSTRINGEXACT,\r
+ (WPARAM) -1,\r
+ (LPARAM) realm);\r
+\r
+ if (idx != CB_ERR) {\r
+ wchar_t srealm[KCDB_IDENT_MAXCCH_NAME];\r
+\r
+ SendMessage(d->hw_realm,\r
+ CB_GETLBTEXT,\r
+ (WPARAM) idx,\r
+ (LPARAM) srealm);\r
+\r
+ if (!wcsicmp(srealm, realm) && wcscmp(srealm, realm)) {\r
+ StringCbCopy(realm, sizeof(realm), srealm);\r
+\r
+ SetWindowText(d->hw_realm, srealm);\r
+ }\r
+ }\r
+\r
StringCchCopy(un_realm, cch_left, realm);\r
\r
SendMessage(d->hw_username,\r
UINT uMsg,\r
WPARAM wParam,\r
LPARAM lParam) {\r
+\r
k5_new_cred_data * d;\r
\r
d = (k5_new_cred_data *) nc->ident_aux;\r
assert(hw_parent != NULL);\r
#endif\r
\r
- d = malloc(sizeof(*d));\r
+ d = PMALLOC(sizeof(*d));\r
assert(d);\r
ZeroMemory(d, sizeof(*d));\r
\r
if (rv != KHM_ERROR_TOO_LONG)\r
goto _add_lru_realms;\r
\r
- ms = malloc(cb_ms);\r
+ ms = PMALLOC(cb_ms);\r
assert(ms != NULL);\r
\r
cb = cb_ms;\r
\r
if (ms != NULL) {\r
if (cb_ms < cb) {\r
- free(ms);\r
- ms = malloc(cb);\r
+ PFREE(ms);\r
+ ms = PMALLOC(cb);\r
assert(ms);\r
cb_ms = cb;\r
}\r
} else {\r
- ms = malloc(cb);\r
+ ms = PMALLOC(cb);\r
cb_ms = cb;\r
}\r
\r
}\r
\r
if (defrealm)\r
- free(defrealm);\r
+ PFREE(defrealm);\r
\r
if (ms)\r
- free(ms);\r
+ PFREE(ms);\r
\r
/* now see about that default identity */\r
if (nc->ctx.identity) {\r
/* since we created all the windows as child windows of\r
the new creds window, they will be destroyed when that\r
window is destroyed. */\r
- free(d);\r
+ PFREE(d);\r
}\r
return TRUE;\r
}\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
+static void\r
+k5_update_last_default_identity(khm_handle ident) {\r
+ wchar_t idname[KCDB_IDENT_MAXCCH_NAME];\r
+ khm_size cb;\r
+\r
+ cb = sizeof(idname);\r
+ if (KHM_FAILED(kcdb_identity_get_name(ident, idname, &cb)))\r
+ return;\r
+\r
+ assert(csp_params);\r
+\r
+ khc_write_string(csp_params, L"LastDefaultIdent", idname);\r
+}\r
+\r
static khm_int32\r
k5_ident_set_default(khm_int32 msg_type,\r
khm_int32 msg_subtype,\r
\r
RegCloseKey(hk_ccname);\r
\r
- if (l == ERROR_SUCCESS)\r
+ if (l == ERROR_SUCCESS) {\r
+ k5_update_last_default_identity(def_ident);\r
return KHM_ERROR_SUCCESS;\r
- else\r
+ } else\r
return KHM_ERROR_UNKNOWN;\r
\r
} else if (dw > ARRAYLENGTH(env_ccname)) {\r
\r
/* if the %KRB5CCNAME is the same as the identity\r
ccache, then it is already the default. */\r
- if (!khm_krb5_cc_name_cmp(id_ccname, env_ccname))\r
+ if (!khm_krb5_cc_name_cmp(id_ccname, env_ccname)) {\r
+ k5_update_last_default_identity(def_ident);\r
return KHM_ERROR_SUCCESS;\r
+ }\r
\r
/* if not, we have to copy the contents of id_ccname\r
to env_ccname */\r
env_ccname, \r
id_ccname);\r
\r
- if (code == 0)\r
+ if (code == 0) {\r
+ k5_update_last_default_identity(def_ident);\r
khm_krb5_list_tickets(&ctx);\r
+ }\r
\r
if (ctx)\r
pkrb5_free_context(ctx);\r
khm_size cb;\r
khm_handle ident;\r
\r
+ /* if there is a default identity already, we assume we don't need\r
+ to check this one. */\r
+\r
+ khm_handle def_ident;\r
+\r
+ if (KHM_SUCCEEDED(kcdb_identity_get_default(&def_ident))) {\r
+ kcdb_identity_release(def_ident);\r
+\r
+ return KHM_ERROR_SUCCESS;\r
+ }\r
+\r
ident = (khm_handle) vparam;\r
\r
assert(k5_identpro_ctx != NULL);\r
if (cc)\r
pkrb5_cc_close(k5_identpro_ctx, cc);\r
\r
-\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
khm_int32 t;\r
khm_int32 flags;\r
__int64 t_expire;\r
+ __int64 t_cexpire;\r
__int64 t_rexpire;\r
khm_size cb;\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
KHM_FAILED(kcdb_cred_get_identity(cred, &ident)))\r
return KHM_ERROR_SUCCESS;\r
\r
- if (ident != tident)\r
+ if (!kcdb_identity_is_equal(ident,tident))\r
goto _cleanup;\r
\r
if (KHM_FAILED(kcdb_cred_get_flags(cred, &flags)))\r
flags = 0;\r
\r
- cb = sizeof(t_expire);\r
- if (KHM_SUCCEEDED(kcdb_cred_get_attr(cred,\r
- KCDB_ATTR_EXPIRE,\r
- NULL,\r
- &t_expire,\r
- &cb))) {\r
- __int64 t_cexpire;\r
-\r
+ if (flags & KCDB_CRED_FLAG_INITIAL) {\r
cb = sizeof(t_cexpire);\r
- if ((flags & KCDB_CRED_FLAG_INITIAL) ||\r
- KHM_FAILED(kcdb_identity_get_attr(tident,\r
- KCDB_ATTR_EXPIRE,\r
- NULL,\r
- &t_cexpire,\r
- &cb)) ||\r
- t_cexpire > t_expire)\r
- kcdb_identity_set_attr(tident, KCDB_ATTR_EXPIRE,\r
- &t_expire, sizeof(t_expire));\r
- } else if (flags & KCDB_CRED_FLAG_INITIAL) {\r
- kcdb_identity_set_attr(tident, KCDB_ATTR_EXPIRE, NULL, 0);\r
+ if (KHM_SUCCEEDED(kcdb_cred_get_attr(cred,\r
+ KCDB_ATTR_EXPIRE,\r
+ NULL,\r
+ &t_cexpire,\r
+ &cb))) { \r
+ t_expire = 0;\r
+ cb = sizeof(t_expire);\r
+ if (KHM_FAILED(kcdb_identity_get_attr(tident,\r
+ KCDB_ATTR_EXPIRE,\r
+ NULL,\r
+ &t_expire,\r
+ &cb)) ||\r
+ (t_cexpire > t_expire))\r
+ kcdb_identity_set_attr(tident, KCDB_ATTR_EXPIRE,\r
+ &t_cexpire, sizeof(t_cexpire));\r
+ } else {\r
+ kcdb_identity_set_attr(tident, KCDB_ATTR_EXPIRE, NULL, 0);\r
+ }\r
+ } else {\r
+ goto _cleanup;\r
}\r
\r
cb = sizeof(ccname);\r
kcdb_identity_set_attr(tident, attr_id_krb5_ccname,\r
NULL, 0);\r
}\r
-\r
- if (!(flags & KCDB_CRED_FLAG_INITIAL))\r
- goto _cleanup;\r
-\r
+ \r
cb = sizeof(t);\r
if (KHM_SUCCEEDED(kcdb_cred_get_attr(cred,\r
attr_id_krb5_flags,\r
NULL,\r
&t,\r
&cb))) {\r
+\r
kcdb_identity_set_attr(tident, attr_id_krb5_flags, \r
&t, sizeof(t));\r
\r
void * vparam) {\r
\r
khm_handle ident;\r
+ khm_handle tident;\r
+ krb5_ccache cc = NULL;\r
+ char * ccname;\r
+ krb5_error_code code;\r
+ khm_size cb;\r
+ wchar_t wid_ccname[MAX_PATH];\r
+ wchar_t w_ccname[MAX_PATH];\r
\r
ident = (khm_handle) vparam;\r
if (ident == NULL)\r
k5_ident_update_apply_proc,\r
(void *) ident);\r
\r
+ if (KHM_SUCCEEDED(kcdb_identity_get_default(&tident))) {\r
+ kcdb_identity_release(tident);\r
+ goto _iu_cleanup;\r
+ }\r
+\r
+ cb = sizeof(wid_ccname);\r
+ if (KHM_FAILED(kcdb_identity_get_attr(ident,\r
+ attr_id_krb5_ccname,\r
+ NULL,\r
+ wid_ccname,\r
+ &cb)))\r
+ goto _iu_cleanup;\r
+\r
+ if(k5_identpro_ctx == NULL)\r
+ goto _iu_cleanup;\r
+\r
+ code = pkrb5_cc_default(k5_identpro_ctx, &cc);\r
+ if (code)\r
+ goto _iu_cleanup;\r
+\r
+ ccname = pkrb5_cc_get_name(k5_identpro_ctx, cc);\r
+ if (ccname == NULL)\r
+ goto _iu_cleanup;\r
+\r
+ AnsiStrToUnicode(w_ccname, sizeof(w_ccname), ccname);\r
+\r
+ khm_krb5_canon_cc_name(w_ccname, sizeof(w_ccname));\r
+ khm_krb5_canon_cc_name(wid_ccname, sizeof(wid_ccname));\r
+\r
+ if (!wcsicmp(w_ccname, wid_ccname))\r
+ kcdb_identity_set_default_int(ident);\r
+\r
+ _iu_cleanup:\r
+ if (cc && k5_identpro_ctx)\r
+ pkrb5_cc_close(k5_identpro_ctx, cc);\r
+\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
char * princ_nameA = NULL;\r
wchar_t princ_nameW[KCDB_IDENT_MAXCCH_NAME];\r
khm_handle ident = NULL;\r
+ khm_boolean found_default = FALSE;\r
\r
assert(k5_identpro_ctx != NULL);\r
\r
\r
kcdb_identity_set_default_int(ident);\r
\r
+ found_default = TRUE;\r
+\r
_nc_cleanup:\r
if (princ_nameA)\r
pkrb5_free_unparsed_name(k5_identpro_ctx,\r
if (ident)\r
kcdb_identity_release(ident);\r
\r
+ if (!found_default) {\r
+ wchar_t widname[KCDB_IDENT_MAXCCH_NAME];\r
+ khm_size cb;\r
+\r
+ cb = sizeof(widname);\r
+\r
+ assert(csp_params);\r
+\r
+ if (KHM_SUCCEEDED(khc_read_string(csp_params, L"LastDefaultIdent",\r
+ widname, &cb))) {\r
+ ident = NULL;\r
+ kcdb_identity_create(widname, KCDB_IDENT_FLAG_CREATE, &ident);\r
+ if (ident) {\r
+ kcdb_identity_set_default_int(ident);\r
+ kcdb_identity_release(ident);\r
+ }\r
+ }\r
+ }\r
+\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
\r
return KHM_ERROR_SUCCESS;\r
}\r
+\r
+khm_int32 KHMAPI\r
+k5_ident_name_comp_func(const void * dl, khm_size cb_dl,\r
+ const void * dr, khm_size cb_dr) {\r
+ wchar_t * idl = (wchar_t *) dl;\r
+ wchar_t * idr = (wchar_t *) dr;\r
+ wchar_t * rl;\r
+ wchar_t * rr;\r
+ khm_int32 r;\r
+\r
+ rl = khm_get_realm_from_princ(idl);\r
+ rr = khm_get_realm_from_princ(idr);\r
+\r
+ if (rl == NULL && rr == NULL)\r
+ return wcscmp(idl, idr);\r
+ else if (rl == NULL)\r
+ return 1;\r
+ else if (rr == NULL)\r
+ return -1;\r
+\r
+ r = wcscmp(rl, rr);\r
+ if (r == 0)\r
+ return wcscmp(idl, idr);\r
+ else\r
+ return r;\r
+}\r
+\r
+khm_int32\r
+k5_msg_system_idpro(khm_int32 msg_type, khm_int32 msg_subtype,\r
+ khm_ui_4 uparam, void * vparam) {\r
+\r
+ switch(msg_subtype) {\r
+ case KMSG_SYSTEM_INIT:\r
+ {\r
+\r
+ pkrb5_init_context(&k5_identpro_ctx);\r
+ kcdb_identity_set_type(credtype_id_krb5);\r
+\r
+ if (KHM_FAILED(kcdb_type_get_id(TYPENAME_KRB5_PRINC, \r
+ &type_id_krb5_princ))) {\r
+ kcdb_type dt;\r
+ kcdb_type * pstr;\r
+\r
+ kcdb_type_get_info(KCDB_TYPE_STRING, &pstr);\r
+\r
+ ZeroMemory(&dt, sizeof(dt));\r
+ dt.name = TYPENAME_KRB5_PRINC;\r
+ dt.id = KCDB_TYPE_INVALID;\r
+ dt.flags = KCDB_TYPE_FLAG_CB_AUTO;\r
+ dt.cb_min = pstr->cb_min;\r
+ dt.cb_max = pstr->cb_max;\r
+ dt.toString = pstr->toString;\r
+ dt.isValid = pstr->isValid;\r
+ dt.comp = k5_ident_name_comp_func;\r
+ dt.dup = pstr->dup;\r
+\r
+ kcdb_type_register(&dt, &type_id_krb5_princ);\r
+\r
+ type_regd_krb5_princ = TRUE;\r
+\r
+ kcdb_type_release_info(pstr);\r
+ }\r
+\r
+ if (type_id_krb5_princ != -1) {\r
+ kcdb_attrib * attr;\r
+\r
+ kcdb_attrib_get_info(KCDB_ATTR_ID_NAME, &attr);\r
+\r
+ attr->type = type_id_krb5_princ;\r
+\r
+ kcdb_attrib_release_info(attr);\r
+ }\r
+ }\r
+ break;\r
+\r
+ case KMSG_SYSTEM_EXIT:\r
+ {\r
+ if (k5_identpro_ctx) {\r
+ pkrb5_free_context(k5_identpro_ctx);\r
+ k5_identpro_ctx = NULL;\r
+ }\r
+\r
+ if (type_id_krb5_princ != -1) {\r
+ kcdb_attrib * attr;\r
+\r
+ kcdb_attrib_get_info(KCDB_ATTR_ID_NAME, &attr);\r
+\r
+ attr->type = KCDB_TYPE_STRING;\r
+\r
+ kcdb_attrib_release_info(attr);\r
+ }\r
+\r
+ /* allow a brief moment for any stale references to die */\r
+ Sleep(100);\r
+\r
+ if (type_regd_krb5_princ) {\r
+ kcdb_type_unregister(type_id_krb5_princ);\r
+ }\r
+ }\r
+ break;\r
+ }\r
+\r
+ return KHM_ERROR_SUCCESS;\r
+}\r
+\r
+khm_int32 KHMAPI\r
+k5_ident_callback(khm_int32 msg_type, khm_int32 msg_subtype,\r
+ khm_ui_4 uparam, void * vparam) {\r
+ switch(msg_type) {\r
+ case KMSG_SYSTEM:\r
+ return k5_msg_system_idpro(msg_type, msg_subtype, uparam, vparam);\r
+\r
+ case KMSG_IDENT:\r
+ return k5_msg_ident(msg_type, msg_subtype, uparam, vparam);\r
+ }\r
+\r
+ return KHM_ERROR_SUCCESS;\r
+}\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
khm_int32 type_id_enctype = -1;\r
khm_int32 type_id_addr_list = -1;\r
khm_int32 type_id_krb5_flags = -1;\r
+khm_int32 type_id_krb5_princ = -1;\r
\r
BOOL type_regd_enctype = FALSE;\r
BOOL type_regd_addr_list = FALSE;\r
BOOL type_regd_krb5_flags = FALSE;\r
+BOOL type_regd_krb5_princ = FALSE;\r
\r
khm_int32 attr_id_key_enctype = -1;\r
khm_int32 attr_id_tkt_enctype = -1;\r
pi.name = KRB5_PLUGIN_NAME;\r
pi.type = KHM_PITYPE_CRED;\r
pi.icon = NULL; /*TODO: Assign icon */\r
- pi.flags = KHM_PIFLAG_IDENTITY_PROVIDER;\r
+ pi.flags = 0;\r
pi.msg_proc = k5_msg_callback;\r
pi.description = buf;\r
LoadString(hResModule, IDS_PLUGIN_DESC,\r
buf, ARRAYLENGTH(buf));\r
kmm_provide_plugin(h_module, &pi);\r
\r
+ ZeroMemory(&pi, sizeof(pi));\r
+ pi.name = KRB5_IDENTPRO_NAME;\r
+ pi.type = KHM_PITYPE_IDENT;\r
+ pi.icon = NULL; /* ignored */\r
+ pi.flags = 0;\r
+ pi.msg_proc = k5_ident_callback;\r
+ pi.description = buf;\r
+ pi.dependencies = KRB5_PLUGIN_NAME L"\0";\r
+ LoadString(hResModule, IDS_IDENTPRO_DESC,\r
+ buf, ARRAYLENGTH(buf));\r
+ kmm_provide_plugin(h_module, &pi);\r
+\r
if(KHM_FAILED(rv = init_imports()))\r
goto _exit;\r
\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
k5_dlg_data * d;\r
khui_new_creds_by_type * nct;\r
\r
- d = malloc(sizeof(*d));\r
+ d = PMALLOC(sizeof(*d));\r
ZeroMemory(d, sizeof(*d));\r
/* lParam is a pointer to a khui_new_creds structure */\r
d->nc = (khui_new_creds *) lParam;\r
khui_tracker_kill_controls(&d->tc_lifetime);\r
}\r
\r
- free(d);\r
+ PFREE(d);\r
\r
return TRUE;\r
}\r
break;\r
\r
if(nct->credtext)\r
- free(nct->credtext);\r
+ PFREE(nct->credtext);\r
nct->credtext = NULL;\r
\r
tbuf[0] = L'\0';\r
StringCbLength(sbuf, sizeof(sbuf), &cbsize);\r
cbsize += sizeof(wchar_t);\r
\r
- nct->credtext = malloc(cbsize);\r
+ nct->credtext = PMALLOC(cbsize);\r
\r
StringCbCopy(nct->credtext, cbsize, sbuf);\r
} else if (nc->n_identities > 0 &&\r
StringCbLength(sbuf, sizeof(sbuf), &cbsize);\r
cbsize += sizeof(wchar_t);\r
\r
- nct->credtext = malloc(cbsize);\r
+ nct->credtext = PMALLOC(cbsize);\r
\r
StringCbCopy(nct->credtext, cbsize, sbuf);\r
} else {\r
&cbsize);\r
cbsize += sizeof(wchar_t);\r
\r
- nct->credtext = malloc(cbsize);\r
+ nct->credtext = PMALLOC(cbsize);\r
\r
StringCbCopy(nct->credtext, cbsize, d->cred_message);\r
}\r
g_fjob.nc = nc;\r
g_fjob.nct = nct;\r
g_fjob.dialog = nct->hwnd_panel;\r
- g_fjob.principal = malloc(size);\r
+ g_fjob.principal = PMALLOC(size);\r
UnicodeStrToAnsi(g_fjob.principal, size, idname);\r
g_fjob.password = NULL;\r
g_fjob.lifetime = (krb5_deltat) d->tc_lifetime.current;\r
SUCCEEDED(StringCchLength(pdlginfo->in.ccache,\r
NETID_CCACHE_NAME_SZ,\r
&size))) {\r
- g_fjob.ccache = malloc(sizeof(char) * (size + 1));\r
+ g_fjob.ccache = PMALLOC(sizeof(char) * (size + 1));\r
#ifdef DEBUG\r
assert(g_fjob.ccache);\r
#endif\r
k5_free_kinit_job(void)\r
{\r
if (g_fjob.principal)\r
- free(g_fjob.principal);\r
+ PFREE(g_fjob.principal);\r
\r
if (g_fjob.password)\r
- free(g_fjob.password);\r
+ PFREE(g_fjob.password);\r
\r
if (g_fjob.identity)\r
kcdb_identity_release(g_fjob.identity);\r
\r
if (g_fjob.ccache)\r
- free(g_fjob.ccache);\r
+ PFREE(g_fjob.ccache);\r
\r
ZeroMemory(&g_fjob, sizeof(g_fjob));\r
}\r
\r
nc = (khui_new_creds *) vparam;\r
\r
- nct = malloc(sizeof(*nct));\r
+ nct = PMALLOC(sizeof(*nct));\r
ZeroMemory(nct, sizeof(*nct));\r
\r
nct->type = credtype_id_krb5;\r
StringCbLength(wbuf, sizeof(wbuf), &cbsize);\r
cbsize += sizeof(wchar_t);\r
\r
- nct->name = malloc(cbsize);\r
+ nct->name = PMALLOC(cbsize);\r
StringCbCopy(nct->name, cbsize, wbuf);\r
\r
nct->h_module = hResModule;\r
\r
nc = (khui_new_creds *) vparam;\r
\r
- nct = malloc(sizeof(*nct));\r
+ nct = PMALLOC(sizeof(*nct));\r
ZeroMemory(nct, sizeof(*nct));\r
\r
nct->type = credtype_id_krb5;\r
0, (LPARAM) t);\r
t = multi_string_next(t);\r
}\r
- free(realms);\r
+ PFREE(realms);\r
}\r
\r
/* and set the default realm */\r
SendDlgItemMessage(hwnd, IDC_NCK5_REALM, \r
WM_SETTEXT, \r
0, (LPARAM) defrealm);\r
- free(defrealm);\r
+ PFREE(defrealm);\r
}\r
} else { /* if krb5 is the identity provider */\r
HWND hw_realms;\r
password */\r
if(g_fjob.code) {\r
if (is_k5_identpro)\r
- kcdb_identity_set_flags(ident, \r
+ kcdb_identity_set_flags(ident,\r
+ KCDB_IDENT_FLAG_INVALID,\r
KCDB_IDENT_FLAG_INVALID);\r
\r
khui_cw_clear_prompts(nc);\r
}\r
\r
if (d->cred_message) {\r
- free(d->cred_message);\r
+ PFREE(d->cred_message);\r
d->cred_message = NULL;\r
}\r
\r
StringCbLength(msg, sizeof(msg), &cb);\r
cb += sizeof(wchar_t);\r
\r
- d->cred_message = malloc(cb);\r
+ d->cred_message = PMALLOC(cb);\r
StringCbCopy(d->cred_message, cb, msg);\r
}\r
\r
\r
if(is_k5_identpro)\r
kcdb_identity_set_flags(ident, \r
+ KCDB_IDENT_FLAG_VALID,\r
KCDB_IDENT_FLAG_VALID);\r
} else {\r
/* huh?? */\r
(nc->n_identities == 0 ||\r
nc->identities[0] == NULL ||\r
KHM_SUCCEEDED(kcdb_credset_find_filtered\r
- (NULL,\r
- -1,\r
- k5_find_tgt_filter,\r
- nc->identities[0],\r
- NULL,\r
- NULL))))\r
+ (NULL,\r
+ -1,\r
+ k5_find_tgt_filter,\r
+ nc->identities[0],\r
+ NULL,\r
+ NULL))))\r
g_fjob.code = 0;\r
\r
\r
&cb);\r
assert(rv == KHM_ERROR_TOO_LONG);\r
\r
- idname = malloc(cb);\r
+ idname = PMALLOC(cb);\r
assert(idname);\r
\r
rv = kcdb_identity_get_name(nc->identities[0],\r
else\r
cb_ms += cb + sizeof(wchar_t);\r
\r
- wbuf = malloc(cb_ms);\r
+ wbuf = PMALLOC(cb_ms);\r
assert(wbuf);\r
\r
cb = cb_ms;\r
&cb);\r
\r
if (rv == KHM_ERROR_TOO_LONG) {\r
- free(wbuf);\r
- wbuf = malloc(cb);\r
+ PFREE(wbuf);\r
+ wbuf = PMALLOC(cb);\r
assert(wbuf);\r
\r
cb_ms = cb;\r
pkrb5_free_context(ctx);\r
\r
if (idname)\r
- free(idname);\r
+ PFREE(idname);\r
\r
if (wbuf)\r
- free(wbuf);\r
+ PFREE(wbuf);\r
} else if (g_fjob.state == FIBER_STATE_NONE) {\r
/* the user cancelled the operation */\r
r = KHUI_NC_RESPONSE_EXIT | \r
_end_task();\r
} else if (nc->subtype == KMSG_CRED_RENEW_CREDS) {\r
\r
+ __int64 ftidexp = 0;\r
+ __int64 ftcurrent;\r
+ khm_size cb;\r
+\r
+ GetSystemTimeAsFileTime((LPFILETIME) &ftcurrent);\r
+\r
_begin_task(0);\r
_report_mr0(KHERR_NONE, MSG_CTX_RENEW_CREDS);\r
_describe();\r
nc->ctx.cred_type == credtype_id_krb5)) {\r
int code;\r
\r
- if (nc->ctx.identity != 0)\r
+ if (nc->ctx.identity != 0) {\r
+ /* get the current identity expiration time */\r
+ cb = sizeof(ftidexp);\r
+\r
+ kcdb_identity_get_attr(nc->ctx.identity,\r
+ KCDB_ATTR_EXPIRE,\r
+ NULL,\r
+ &ftidexp,\r
+ &cb);\r
+\r
code = khm_krb5_renew(nc->ctx.identity);\r
- else\r
+ } else {\r
code = 1; /* it just has to be non-zero */\r
+ }\r
\r
if (code == 0) {\r
khui_cw_set_response(nc, credtype_id_krb5, \r
khui_cw_set_response(nc, credtype_id_krb5, \r
KHUI_NC_RESPONSE_EXIT | \r
KHUI_NC_RESPONSE_FAILED);\r
+ } else if (ftcurrent < ftidexp) {\r
+ wchar_t tbuf[1024];\r
+ DWORD suggestion;\r
+ kherr_suggestion sug_id;\r
+\r
+ /* if we failed to get new tickets, but the\r
+ identity isstill valid, then we assume that\r
+ the current tickets are still good enough\r
+ for other credential types to obtain their\r
+ credentials. */\r
+\r
+ khm_err_describe(code, tbuf, sizeof(tbuf),\r
+ &suggestion, &sug_id);\r
+\r
+ _report_cs0(KHERR_WARNING, tbuf);\r
+ if (suggestion)\r
+ _suggest_mr(suggestion, sug_id);\r
+\r
+ _resolve();\r
+\r
+ khui_cw_set_response(nc, credtype_id_krb5, \r
+ KHUI_NC_RESPONSE_EXIT |\r
+ KHUI_NC_RESPONSE_SUCCESS);\r
} else {\r
wchar_t tbuf[1024];\r
DWORD suggestion;\r
}\r
\r
if (wcscmp(wnpwd, wnpwd2)) {\r
- rv = KHM_ERROR_INVALID_PARM;\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
_report_mr0(KHERR_ERROR, MSG_PWD_NOT_SAME);\r
_suggest_mr(MSG_PWD_S_NOT_SAME, KHERR_SUGGEST_INTERACT);\r
goto _pwd_exit;\r
}\r
\r
if (!wcscmp(wpwd, wnpwd)) {\r
- rv = KHM_ERROR_INVALID_PARM;\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
_report_mr0(KHERR_ERROR, MSG_PWD_SAME);\r
_suggest_mr(MSG_PWD_S_SAME, KHERR_SUGGEST_INTERACT);\r
goto _pwd_exit;\r
\r
StringCchLengthA(result, KHERR_MAXCCH_STRING,\r
&len);\r
- wresult = malloc((len + 1) * sizeof(wchar_t));\r
+ wresult = PMALLOC((len + 1) * sizeof(wchar_t));\r
#ifdef DEBUG\r
assert(wresult);\r
#endif\r
_report_cs1(KHERR_ERROR, L"%1!s!", _cstr(wresult));\r
_resolve();\r
\r
- free(result);\r
- free(wresult);\r
+ PFREE(result);\r
+ PFREE(wresult);\r
\r
/* leave wresult. It will get freed when the\r
reported event is freed. */\r
\r
khui_cw_del_type(nc, credtype_id_krb5);\r
\r
- if(nct->name)\r
- free(nct->name);\r
+ if (nct->name)\r
+ PFREE(nct->name);\r
+ if (nct->credtext)\r
+ PFREE(nct->credtext);\r
\r
- free(nct);\r
+ PFREE(nct);\r
}\r
break;\r
\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/* The system message handler.\r
\r
Runs in the context of the plugin thread */\r
-khm_int32 KHMAPI k5_msg_system(khm_int32 msg_type, khm_int32 msg_subtype, khm_ui_4 uparam, void * vparam)\r
+khm_int32 KHMAPI \r
+k5_msg_system(khm_int32 msg_type, khm_int32 msg_subtype, \r
+ khm_ui_4 uparam, void * vparam)\r
{\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
\r
switch(msg_subtype) {\r
- case KMSG_SYSTEM_INIT:\r
- {\r
- kcdb_credtype ct;\r
- wchar_t buf[KCDB_MAXCCH_SHORT_DESC];\r
- size_t cbsize;\r
-\r
- /* perform critical registrations and initialization\r
- stuff */\r
- ZeroMemory(&ct, sizeof(ct));\r
- ct.id = KCDB_CREDTYPE_AUTO;\r
- ct.name = KRB5_CREDTYPE_NAME;\r
-\r
- if(LoadString(hResModule, IDS_KRB5_SHORT_DESC, buf, ARRAYLENGTH(buf)))\r
- {\r
- StringCbLength(buf, KCDB_MAXCB_SHORT_DESC, &cbsize);\r
- cbsize += sizeof(wchar_t);\r
- ct.short_desc = malloc(cbsize);\r
- StringCbCopy(ct.short_desc, cbsize, buf);\r
- }\r
-\r
- /* even though ideally we should be setting limits\r
- based KCDB_MAXCB_LONG_DESC, our long description\r
- actually fits nicely in KCDB_MAXCB_SHORT_DESC */\r
- if(LoadString(hResModule, IDS_KRB5_LONG_DESC, buf, ARRAYLENGTH(buf)))\r
- {\r
- StringCbLength(buf, KCDB_MAXCB_SHORT_DESC, &cbsize);\r
- cbsize += sizeof(wchar_t);\r
- ct.long_desc = malloc(cbsize);\r
- StringCbCopy(ct.long_desc, cbsize, buf);\r
- }\r
+ case KMSG_SYSTEM_INIT:\r
+ {\r
+ kcdb_credtype ct;\r
+ wchar_t buf[KCDB_MAXCCH_SHORT_DESC];\r
+ size_t cbsize;\r
+\r
+ /* perform critical registrations and initialization\r
+ stuff */\r
+ ZeroMemory(&ct, sizeof(ct));\r
+ ct.id = KCDB_CREDTYPE_AUTO;\r
+ ct.name = KRB5_CREDTYPE_NAME;\r
+\r
+ if(LoadString(hResModule, IDS_KRB5_SHORT_DESC, \r
+ buf, ARRAYLENGTH(buf))) {\r
+ StringCbLength(buf, KCDB_MAXCB_SHORT_DESC, &cbsize);\r
+ cbsize += sizeof(wchar_t);\r
+ ct.short_desc = PMALLOC(cbsize);\r
+ StringCbCopy(ct.short_desc, cbsize, buf);\r
+ }\r
\r
- ct.icon = NULL; /* TODO: set a proper icon */\r
+ /* even though ideally we should be setting limits\r
+ based KCDB_MAXCB_LONG_DESC, our long description\r
+ actually fits nicely in KCDB_MAXCB_SHORT_DESC */\r
+ if(LoadString(hResModule, IDS_KRB5_LONG_DESC, \r
+ buf, ARRAYLENGTH(buf))) {\r
+ StringCbLength(buf, KCDB_MAXCB_SHORT_DESC, &cbsize);\r
+ cbsize += sizeof(wchar_t);\r
+ ct.long_desc = PMALLOC(cbsize);\r
+ StringCbCopy(ct.long_desc, cbsize, buf);\r
+ }\r
\r
- kmq_create_subscription(k5_msg_callback, &ct.sub);\r
+ ct.icon = NULL; /* TODO: set a proper icon */\r
\r
- rv = kcdb_credtype_register(&ct, &credtype_id_krb5);\r
+ kmq_create_subscription(k5_msg_callback, &ct.sub);\r
\r
- if(KHM_SUCCEEDED(rv))\r
- rv = kcdb_credset_create(&krb5_credset);\r
+ ct.is_equal = khm_krb5_creds_is_equal;\r
\r
- if(ct.short_desc)\r
- free(ct.short_desc);\r
+ rv = kcdb_credtype_register(&ct, &credtype_id_krb5);\r
\r
- if(ct.long_desc)\r
- free(ct.long_desc);\r
+ if(KHM_SUCCEEDED(rv))\r
+ rv = kcdb_credset_create(&krb5_credset);\r
\r
- if (is_k5_identpro)\r
- kcdb_identity_set_type(credtype_id_krb5);\r
+ if(ct.short_desc)\r
+ PFREE(ct.short_desc);\r
\r
- if(KHM_SUCCEEDED(rv)) {\r
- krb5_context ctx = NULL;\r
+ if(ct.long_desc)\r
+ PFREE(ct.long_desc);\r
\r
- krb5_initialized = TRUE;\r
+ if(KHM_SUCCEEDED(rv)) {\r
+ krb5_context ctx = NULL;\r
\r
- khm_krb5_list_tickets(&ctx);\r
+ krb5_initialized = TRUE;\r
\r
- if(ctx != NULL)\r
- pkrb5_free_context(ctx);\r
+ if(ctx != NULL)\r
+ pkrb5_free_context(ctx);\r
\r
- /* now convert this thread to a fiber and create a\r
- separate fiber to do kinit stuff */\r
- k5_main_fiber = ConvertThreadToFiber(NULL);\r
- k5_kinit_fiber = CreateFiber(0,k5_kinit_fiber_proc,NULL);\r
+ /* now convert this thread to a fiber and create a\r
+ separate fiber to do kinit stuff */\r
+ k5_main_fiber = ConvertThreadToFiber(NULL);\r
+ k5_kinit_fiber = CreateFiber(0,k5_kinit_fiber_proc,NULL);\r
\r
- ZeroMemory(&g_fjob, sizeof(g_fjob));\r
+ ZeroMemory(&g_fjob, sizeof(g_fjob));\r
\r
- kmq_create_subscription(k5_msg_callback, &k5_sub);\r
+ kmq_create_subscription(k5_msg_callback, &k5_sub);\r
\r
- pkrb5_init_context(&k5_identpro_ctx);\r
+ k5_register_config_panels();\r
\r
- k5_register_config_panels();\r
- }\r
+ khm_krb5_list_tickets(&ctx);\r
}\r
- break;\r
+ }\r
+ break;\r
\r
- case KMSG_SYSTEM_EXIT:\r
+ case KMSG_SYSTEM_EXIT:\r
\r
- k5_unregister_config_panels();\r
+ k5_unregister_config_panels();\r
\r
- if(credtype_id_krb5 >= 0)\r
+ if(credtype_id_krb5 >= 0)\r
{\r
/* basically just unregister the credential type */\r
kcdb_credtype_unregister(credtype_id_krb5);\r
krb5_credset = NULL;\r
}\r
\r
- if(k5_main_fiber != NULL) {\r
- ConvertFiberToThread();\r
- k5_main_fiber = NULL;\r
- }\r
+ if(k5_main_fiber != NULL) {\r
+#if (_WIN32_WINNT >= 0x0501)\r
+ ConvertFiberToThread();\r
+#endif\r
+ k5_main_fiber = NULL;\r
+ }\r
\r
- if(k5_sub != NULL) {\r
- kmq_delete_subscription(k5_sub);\r
- k5_sub = NULL;\r
- }\r
+ if(k5_sub != NULL) {\r
+ kmq_delete_subscription(k5_sub);\r
+ k5_sub = NULL;\r
+ }\r
\r
- if (k5_identpro_ctx) {\r
- pkrb5_free_context(k5_identpro_ctx);\r
- k5_identpro_ctx = NULL;\r
- }\r
-\r
- break;\r
+ break;\r
}\r
\r
return rv;\r
\r
Runs in the context of the Krb5 plugin\r
*/\r
-khm_int32 KHMAPI k5_msg_cred(khm_int32 msg_type, khm_int32 msg_subtype, khm_ui_4 uparam, void * vparam)\r
+khm_int32 KHMAPI \r
+k5_msg_cred(khm_int32 msg_type, khm_int32 msg_subtype, \r
+ khm_ui_4 uparam, void * vparam)\r
{\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
\r
switch(msg_subtype) {\r
- case KMSG_CRED_REFRESH:\r
- {\r
- krb5_context ctx = NULL;\r
+ case KMSG_CRED_REFRESH:\r
+ {\r
+ krb5_context ctx = NULL;\r
\r
- khm_krb5_list_tickets(&ctx);\r
+ khm_krb5_list_tickets(&ctx);\r
\r
- if(ctx != NULL)\r
- pkrb5_free_context(ctx);\r
- }\r
- break;\r
+ if(ctx != NULL)\r
+ pkrb5_free_context(ctx);\r
+ }\r
+ break;\r
\r
- case KMSG_CRED_DESTROY_CREDS:\r
- {\r
- khui_action_context * ctx;\r
+ case KMSG_CRED_DESTROY_CREDS:\r
+ {\r
+ khui_action_context * ctx;\r
\r
- ctx = (khui_action_context *) vparam;\r
+ ctx = (khui_action_context *) vparam;\r
\r
- if (ctx->credset)\r
- khm_krb5_destroy_by_credset(ctx->credset);\r
- }\r
- break;\r
-\r
- case KMSG_CRED_PP_BEGIN:\r
- k5_pp_begin((khui_property_sheet *) vparam);\r
- break;\r
-\r
- case KMSG_CRED_PP_END:\r
- k5_pp_end((khui_property_sheet *) vparam);\r
- break;\r
-\r
- default:\r
- if(IS_CRED_ACQ_MSG(msg_subtype))\r
- return k5_msg_cred_dialog(msg_type, msg_subtype, \r
- uparam, vparam);\r
+ if (ctx->credset)\r
+ khm_krb5_destroy_by_credset(ctx->credset);\r
+ }\r
+ break;\r
+\r
+ case KMSG_CRED_PP_BEGIN:\r
+ k5_pp_begin((khui_property_sheet *) vparam);\r
+ break;\r
+\r
+ case KMSG_CRED_PP_END:\r
+ k5_pp_end((khui_property_sheet *) vparam);\r
+ break;\r
+\r
+ default:\r
+ if(IS_CRED_ACQ_MSG(msg_subtype))\r
+ return k5_msg_cred_dialog(msg_type, msg_subtype, \r
+ uparam, vparam);\r
}\r
\r
return rv;\r
\r
Runs in the context of the Krb5 plugin\r
*/\r
-khm_int32 KHMAPI k5_msg_callback(khm_int32 msg_type, khm_int32 msg_subtype, khm_ui_4 uparam, void * vparam)\r
+khm_int32 KHMAPI \r
+k5_msg_callback(khm_int32 msg_type, khm_int32 msg_subtype, \r
+ khm_ui_4 uparam, void * vparam)\r
{\r
switch(msg_type) {\r
- case KMSG_SYSTEM:\r
- return k5_msg_system(msg_type, msg_subtype, uparam, vparam);\r
- case KMSG_CRED:\r
- return k5_msg_cred(msg_type, msg_subtype, uparam, vparam);\r
- case KMSG_IDENT:\r
- return k5_msg_ident(msg_type, msg_subtype, uparam, vparam);\r
+ case KMSG_SYSTEM:\r
+ return k5_msg_system(msg_type, msg_subtype, uparam, vparam);\r
+ case KMSG_CRED:\r
+ return k5_msg_cred(msg_type, msg_subtype, uparam, vparam);\r
}\r
return KHM_ERROR_SUCCESS;\r
}\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
#include<commctrl.h>\r
#include<strsafe.h>\r
#include<krb5.h>\r
+#ifdef DEBUG\r
+#include<assert.h>\r
+#endif\r
\r
/* Property page\r
\r
) \r
{\r
switch(uMsg) {\r
- case WM_INITDIALOG:\r
- {\r
- khui_property_sheet * s;\r
- PROPSHEETPAGE * p;\r
- wchar_t buf[512];\r
- khm_size cbsize;\r
-\r
- p = (PROPSHEETPAGE *) lParam;\r
- s = (khui_property_sheet *) p->lParam;\r
+ case WM_INITDIALOG:\r
+ {\r
+ khui_property_sheet * s;\r
+ PROPSHEETPAGE * p;\r
+ wchar_t buf[512];\r
+ wchar_t unavailable[64];\r
+ khm_size cbsize;\r
+ khm_int32 rv;\r
+ khm_int32 tflags;\r
+\r
+ p = (PROPSHEETPAGE *) lParam;\r
+ s = (khui_property_sheet *) p->lParam;\r
\r
#pragma warning(push)\r
#pragma warning(disable: 4244)\r
- SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) s);\r
+ SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR) s);\r
#pragma warning(pop)\r
\r
- if(s->cred) {\r
- cbsize = sizeof(buf);\r
- kcdb_cred_get_name(s->cred, buf, &cbsize);\r
- SetDlgItemText(hwnd, IDC_PPK5_NAME, buf);\r
+ LoadString(hResModule, IDS_UNAVAILABLE,\r
+ unavailable, ARRAYLENGTH(unavailable));\r
\r
- cbsize = sizeof(buf);\r
- kcdb_cred_get_attr_string(s->cred, KCDB_ATTR_ISSUE, buf, &cbsize, 0);\r
- SetDlgItemText(hwnd, IDC_PPK5_ISSUE, buf);\r
+ if(s->cred) {\r
+ cbsize = sizeof(buf);\r
+ kcdb_cred_get_name(s->cred, buf, &cbsize);\r
+ SetDlgItemText(hwnd, IDC_PPK5_NAME, buf);\r
\r
- cbsize = sizeof(buf);\r
- kcdb_cred_get_attr_string(s->cred, KCDB_ATTR_EXPIRE, buf, &cbsize, 0);\r
+ cbsize = sizeof(buf);\r
+ rv = kcdb_cred_get_attr_string(s->cred, \r
+ KCDB_ATTR_ISSUE, \r
+ buf, &cbsize, 0);\r
+ if (KHM_SUCCEEDED(rv))\r
+ SetDlgItemText(hwnd, IDC_PPK5_ISSUE, buf);\r
+ else\r
+ SetDlgItemText(hwnd, IDC_PPK5_ISSUE, unavailable);\r
+\r
+ cbsize = sizeof(buf);\r
+ rv = kcdb_cred_get_attr_string(s->cred, \r
+ KCDB_ATTR_EXPIRE, \r
+ buf, &cbsize, 0);\r
+ if (KHM_SUCCEEDED(rv))\r
SetDlgItemText(hwnd, IDC_PPK5_VALID, buf);\r
-\r
- cbsize = sizeof(buf);\r
- kcdb_cred_get_attr_string(s->cred, KCDB_ATTR_RENEW_EXPIRE, buf, &cbsize, 0);\r
+ else\r
+ SetDlgItemText(hwnd, IDC_PPK5_VALID, unavailable);\r
+\r
+ cbsize = sizeof(buf);\r
+ rv = kcdb_cred_get_attr_string(s->cred, \r
+ KCDB_ATTR_RENEW_EXPIRE, \r
+ buf, &cbsize, 0);\r
+ if (KHM_SUCCEEDED(rv))\r
SetDlgItemText(hwnd, IDC_PPK5_RENEW, buf);\r
+ else\r
+ SetDlgItemText(hwnd, IDC_PPK5_RENEW, unavailable);\r
+\r
+ tflags = 0;\r
+ cbsize = sizeof(tflags);\r
+ rv = kcdb_cred_get_attr(s->cred,\r
+ attr_id_krb5_flags,\r
+ NULL,\r
+ &tflags,\r
+ &cbsize);\r
+ if (KHM_SUCCEEDED(rv)) {\r
+\r
+#define ADDBITFLAG(f,s) \\r
+ if (tflags & f) { \\r
+ LoadString(hResModule, s, buf, ARRAYLENGTH(buf)); \\r
+ SendDlgItemMessage(hwnd, IDC_PPK5_FLAGS, LB_ADDSTRING, 0, (LPARAM) buf); \\r
+ }\r
+\r
+ ADDBITFLAG(TKT_FLG_FORWARDABLE, IDS_FLG_FORWARDABLE);\r
+ ADDBITFLAG(TKT_FLG_FORWARDED, IDS_FLG_FORWARDED);\r
+ ADDBITFLAG(TKT_FLG_PROXIABLE, IDS_FLG_PROXIABLE);\r
+ ADDBITFLAG(TKT_FLG_PROXY, IDS_FLG_PROXY);\r
+ ADDBITFLAG(TKT_FLG_MAY_POSTDATE, IDS_FLG_MAY_POSTDATE);\r
+ ADDBITFLAG(TKT_FLG_POSTDATED, IDS_FLG_POSTDATED);\r
+ ADDBITFLAG(TKT_FLG_INVALID, IDS_FLG_INVALID);\r
+ ADDBITFLAG(TKT_FLG_RENEWABLE, IDS_FLG_RENEWABLE);\r
+ ADDBITFLAG(TKT_FLG_INITIAL, IDS_FLG_INITIAL);\r
+ ADDBITFLAG(TKT_FLG_PRE_AUTH, IDS_FLG_PRE_AUTH);\r
+ ADDBITFLAG(TKT_FLG_HW_AUTH, IDS_FLG_HW_AUTH);\r
+ ADDBITFLAG(TKT_FLG_TRANSIT_POLICY_CHECKED, IDS_FLG_TRANSIT_POL);\r
+ ADDBITFLAG(TKT_FLG_OK_AS_DELEGATE, IDS_FLG_OK_DELEGATE);\r
+ ADDBITFLAG(TKT_FLG_ANONYMOUS, IDS_FLG_ANONYMOUS);\r
+\r
+#undef ADDBITFLAG\r
\r
- /*TODO: select other properties */\r
- } else {\r
- /*TODO: select properties */\r
}\r
+ } else {\r
+#ifdef DEBUG\r
+ assert(FALSE);\r
+#endif\r
}\r
- return FALSE;\r
+ }\r
+ return FALSE;\r
}\r
\r
return FALSE;\r
{\r
PROPSHEETPAGE *p;\r
\r
- if(s->credtype == credtype_id_krb5) {\r
- p = malloc(sizeof(*p));\r
+ if(s->credtype == credtype_id_krb5 &&\r
+ s->cred) {\r
+ p = PMALLOC(sizeof(*p));\r
ZeroMemory(p, sizeof(*p));\r
\r
p->dwSize = sizeof(*p);\r
p->dwFlags = 0;\r
p->hInstance = hResModule;\r
- p->pszTemplate = (s->cred)? MAKEINTRESOURCE(IDD_PP_KRB5C): MAKEINTRESOURCE(IDD_PP_KRB5);\r
+ p->pszTemplate = MAKEINTRESOURCE(IDD_PP_KRB5C);\r
p->pfnDlgProc = krb5_pp_proc;\r
p->lParam = (LPARAM) s;\r
khui_ps_add_page(s, credtype_id_krb5, 0, p, NULL);\r
khui_ps_find_page(s, credtype_id_krb5, &p);\r
if(p) {\r
if(p->p_page)\r
- free(p->p_page);\r
+ PFREE(p->p_page);\r
p->p_page = NULL;\r
}\r
}\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
\r
base_size = strlen(base) + 1;\r
ret_size = base_size + strlen(postfix) + 1;\r
- copy = malloc(base_size);\r
- ret = malloc(ret_size);\r
+ copy = PMALLOC(base_size);\r
+ ret = PMALLOC(ret_size);\r
\r
if (!copy || !ret)\r
goto cleanup;\r
cleanup:\r
if (!copy || !ret) {\r
if (copy)\r
- free(copy);\r
+ PFREE(copy);\r
if (ret)\r
- free(ret);\r
+ PFREE(ret);\r
copy = ret = 0;\r
}\r
// INVARIANT: (ret ==> copy) && (copy ==> ret)\r
if (old_cache) {\r
pdest_tkt();\r
pkrb_set_tkt_string(old_cache);\r
- free(old_cache);\r
+ PFREE(old_cache);\r
old_cache = 0;\r
}\r
\r
return KFAILURE;\r
\r
pkrb_set_tkt_string(tmp_cache);\r
- free(tmp_cache);\r
+ PFREE(tmp_cache);\r
}\r
return 0;\r
}\r
if (!pkrb5_cc_resolve(ctx, pkrb5_cc_default_name(ctx), &cc))\r
pkrb5_cc_destroy(ctx, cc);\r
pkrb5_cc_set_default_name(ctx, old_cache);\r
- free(old_cache);\r
+ PFREE(old_cache);\r
old_cache = 0;\r
}\r
if (ctx) {\r
ctx = 0;\r
}\r
if (tmp_cache)\r
- free(tmp_cache);\r
+ PFREE(tmp_cache);\r
if (pctx)\r
*pctx = ctx;\r
return rc;\r
(result_string.length ? (sizeof(": ") - 1) : 0) +\r
result_string.length;\r
if (len && error_str) {\r
- *error_str = malloc(len + 1);\r
+ *error_str = PMALLOC(len + 1);\r
if (*error_str)\r
_snprintf(*error_str, len + 1,\r
"%.*s%s%.*s",\r
if (v4_error_str)\r
len += sizeof(sep) + sizeof(v4_prefix) + strlen(v4_error_str) + \r
sizeof(sep);\r
- error_str = malloc(len + 1);\r
+ error_str = PMALLOC(len + 1);\r
if (error_str) {\r
char* p = error_str;\r
int size = len + 1;\r
killList = tempList;\r
\r
tempList = (TicketList*)tempList->next;\r
- free(killList->theTicket);\r
+ PFREE(killList->theTicket);\r
if (killList->tktEncType)\r
- free(killList->tktEncType);\r
+ PFREE(killList->tktEncType);\r
if (killList->keyEncType)\r
- free(killList->keyEncType);\r
+ PFREE(killList->keyEncType);\r
if (killList->addrCount) {\r
int n;\r
for ( n=0; n<killList->addrCount; n++) {\r
if (killList->addrList[n])\r
- free(killList->addrList[n]);\r
+ PFREE(killList->addrList[n]);\r
}\r
}\r
if (killList->addrList)\r
- free(killList->addrList);\r
+ PFREE(killList->addrList);\r
if (killList->name)\r
- free(killList->name);\r
+ PFREE(killList->name);\r
if (killList->inst)\r
- free(killList->inst);\r
+ PFREE(killList->inst);\r
if (killList->realm)\r
- free(killList->realm);\r
- free(killList);\r
+ PFREE(killList->realm);\r
+ PFREE(killList);\r
}\r
\r
*ticketList = NULL;\r
Flags,KC_INT32,0,\r
Parameters,KC_SPACE,0,Parameters for KrbCred\r
CreateMissingConfig,KC_INT32,0,Create missing configuration files\r
- MsLsaImport,KC_INT32,2,Automatically import MSLSA credentials\r
+ MsLsaImport,KC_INT32,1,Automatically import MSLSA credentials: 0-never 1-always 2-if principle matches\r
+ MsLsaList,KC_INT32,1,Include MSLSA in the credentials list\r
+ FileCCList,KC_STRING,,List of file CCaches to include in listing\r
AutoRenewTickets,KC_INT32,1,Automatically renew expiring tickets\r
DefaultLifetime,KC_INT32,36000,Default ticket lifetime\r
MaxLifetime,KC_INT32,86400,Maximum lifetime\r
MinRenewLifetime,KC_INT32,60,Maximum renewable lifetime\r
LRURealms,KC_STRING,,\r
LRUPrincipals,KC_STRING,,\r
+ LastDefaultIdent,KC_STRING,,Last known default identity\r
+ DefaultCCName,KC_STRING,,Default CC name (only per identity)\r
PromptCache,KC_SPACE,0,Cache of prompts (only per identity)\r
Name,KC_STRING,,\r
Banner,KC_STRING,,\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
#include<kconfig.h>\r
#include<khuidefs.h>\r
#include<kherr.h>\r
+#include<utils.h>\r
\r
#include<krb5funcs.h>\r
#include<krb5common.h>\r
#include<datarep.h>\r
#include<krb5_msgs.h>\r
\r
+typedef enum tag_k5_lsa_import {\r
+ K5_LSAIMPORT_NEVER = 0,\r
+ K5_LSAIMPORT_ALWAYS = 1,\r
+ K5_LSAIMPORT_MATCH = 2, /* only when the principal name matches */\r
+} k5_lsa_import;\r
+\r
#define TYPENAME_ENCTYPE L"EncType"\r
#define TYPENAME_ADDR_LIST L"AddrList"\r
#define TYPENAME_KRB5_FLAGS L"Krb5Flags"\r
+#define TYPENAME_KRB5_PRINC L"Krb5Principal"\r
\r
#define ATTRNAME_KEY_ENCTYPE L"KeyEncType"\r
#define ATTRNAME_TKT_ENCTYPE L"TktEncType"\r
extern khm_int32 type_id_enctype;\r
extern khm_int32 type_id_addr_list;\r
extern khm_int32 type_id_krb5_flags;\r
+extern khm_int32 type_id_krb5_princ;\r
+\r
+extern BOOL type_regd_krb5_princ;\r
\r
extern khm_int32 attr_id_key_enctype;\r
extern khm_int32 attr_id_tkt_enctype;\r
\r
/* plugin constants */\r
#define KRB5_PLUGIN_NAME L"Krb5Cred"\r
+#define KRB5_IDENTPRO_NAME L"Krb5Ident"\r
\r
#define KRB5_CREDTYPE_NAME L"Krb5Cred"\r
\r
+/* limits */\r
+/* maximum number of characters in a realm name */\r
+#define K5_MAXCCH_REALM 256\r
+\r
+/* maximum number of characters in a host name */\r
+#define K5_MAXCCH_HOST 128\r
+\r
+/* maximum number of KDC's per realm */\r
+#define K5_MAX_KDC 64\r
+\r
+/* maximum number of domains that map to a realm */\r
+#define K5_MAX_DOMAIN_MAPPINGS 32\r
+\r
extern khm_handle csp_plugins;\r
extern khm_handle csp_krbcred;\r
extern khm_handle csp_params;\r
\r
/* plugin callbacks */\r
khm_int32 KHMAPI k5_msg_callback(khm_int32 msg_type, khm_int32 msg_subtype, khm_ui_4 uparam, void * vparam);\r
+khm_int32 KHMAPI k5_ident_callback(khm_int32 msg_type, khm_int32 msg_subtype, khm_ui_4 uparam, void * vparam);\r
\r
/* kinit fiber */\r
typedef struct _fiber_job_t {\r
void\r
k5_unregister_config_panels(void);\r
\r
+INT_PTR CALLBACK \r
+k5_ccconfig_dlgproc(HWND hwnd,\r
+ UINT uMsg,\r
+ WPARAM wParam,\r
+ LPARAM lParam);\r
+\r
+INT_PTR CALLBACK \r
+k5_id_tab_dlgproc(HWND hwndDlg,\r
+ UINT uMsg,\r
+ WPARAM wParam,\r
+ LPARAM lParam);\r
+\r
+INT_PTR CALLBACK \r
+k5_ids_tab_dlgproc(HWND hwnd,\r
+ UINT uMsg,\r
+ WPARAM wParam,\r
+ LPARAM lParam);\r
+\r
#endif\r
LTEXT "Name",IDC_STATIC,7,7,19,8\r
LTEXT "Valid till",IDC_STATIC,7,39,24,8\r
LTEXT "Renewable till",IDC_STATIC,7,55,45,12\r
- CONTROL "Renewable",IDC_PPK5_CRENEW,"Button",BS_AUTOCHECKBOX | \r
- WS_DISABLED | WS_TABSTOP,31,125,51,10\r
- CONTROL "Forwardable",IDC_PPK5_CFORWARD,"Button",BS_AUTOCHECKBOX | \r
- WS_DISABLED | WS_TABSTOP,91,125,56,10\r
- CONTROL "Proxiable",IDC_PPK5_CPROXY,"Button",BS_AUTOCHECKBOX | \r
- WS_DISABLED | WS_TABSTOP,156,125,45,10\r
LTEXT "Issued on",IDC_STATIC,7,23,32,8\r
- GROUPBOX "Ticket flags",IDC_STATIC,7,108,221,41\r
- LTEXT "Static",IDC_PPK5_NAME,72,7,156,12,NOT WS_GROUP,\r
- WS_EX_CLIENTEDGE\r
- LTEXT "Static",IDC_PPK5_ISSUE,72,23,156,12,NOT WS_GROUP,\r
- WS_EX_CLIENTEDGE\r
- LTEXT "Static",IDC_PPK5_VALID,72,39,156,12,NOT WS_GROUP,\r
- WS_EX_CLIENTEDGE\r
- LTEXT "Static",IDC_PPK5_RENEW,72,55,156,12,NOT WS_GROUP,\r
- WS_EX_CLIENTEDGE\r
+ LTEXT "Ticket flags",IDC_STATIC,7,75,37,8\r
+ EDITTEXT IDC_PPK5_NAME,72,7,156,12,ES_AUTOHSCROLL | ES_READONLY\r
+ EDITTEXT IDC_PPK5_ISSUE,72,23,156,12,ES_AUTOHSCROLL | ES_READONLY\r
+ EDITTEXT IDC_PPK5_VALID,72,39,156,12,ES_AUTOHSCROLL | ES_READONLY\r
+ EDITTEXT IDC_PPK5_RENEW,72,55,156,12,ES_AUTOHSCROLL | ES_READONLY\r
+ LISTBOX IDC_PPK5_FLAGS,72,74,156,75,LBS_SORT | \r
+ LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP\r
END\r
\r
IDD_PP_KRB5 DIALOGEX 0, 0, 235, 156\r
LTEXT "Default Realm",IDC_CFG_LBL_REALM,13,9,46,8\r
COMBOBOX IDC_CFG_DEFREALM,76,7,166,30,CBS_DROPDOWN | CBS_SORT | \r
WS_VSCROLL | WS_TABSTOP\r
- PUSHBUTTON "Configure Realms ...",IDC_CFG_CFGREALMS,76,25,84,14\r
+ PUSHBUTTON "Configure Realms ...",IDC_CFG_CFGREALMS,76,25,84,14,\r
+ WS_DISABLED\r
GROUPBOX "Keberos Configuration File",IDC_CFG_CFGFILEGRP,7,57,241,\r
48\r
LTEXT "Location",IDC_CFG_LBL_CFGFILE,13,71,28,8\r
EDITTEXT IDC_CFG_CFGFILE,76,68,119,14,ES_AUTOHSCROLL\r
PUSHBUTTON "Browse...",IDC_CFG_BROWSE,198,68,44,14\r
CONTROL "Create file if missing",IDC_CFG_CREATECONFIG,"Button",\r
- BS_AUTOCHECKBOX | WS_TABSTOP,76,89,80,10\r
+ BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,76,89,80,10\r
GROUPBOX "Windows® Options",IDC_CFG_WINGRP,7,110,241,65\r
LTEXT "Hostname",IDC_CFG_LBL_HOSTNAME,13,123,33,8\r
EDITTEXT IDC_CFG_HOSTNAME,76,120,166,14,ES_AUTOHSCROLL | \r
EDITTEXT IDC_CFG_DOMAIN,76,138,166,14,ES_AUTOHSCROLL | \r
ES_READONLY\r
LTEXT "Import tickets",IDC_LBL_IMPORT,13,158,45,8\r
- COMBOBOX IDC_CFG_IMPORT,76,156,166,30,CBS_DROPDOWNLIST | CBS_SORT | \r
+ COMBOBOX IDC_CFG_IMPORT,76,156,166,30,CBS_DROPDOWNLIST | \r
WS_VSCROLL | WS_TABSTOP\r
END\r
\r
EXSTYLE WS_EX_CONTROLPARENT\r
FONT 8, "MS Shell Dlg", 400, 0, 0x1\r
BEGIN\r
- CONTROL "",IDC_CFG_REALMS,"SysListView32",LVS_ALIGNLEFT | \r
- WS_BORDER | WS_TABSTOP,7,19,81,148\r
- GROUPBOX "Servers",IDC_CFG_SERVERSGRP,93,7,155,91\r
- GROUPBOX "Domain/Hostname mappings",IDC_CFG_DOMAINGRP,93,101,155,\r
- 74\r
- CONTROL "",IDC_LIST3,"SysListView32",LVS_ALIGNLEFT | WS_BORDER | \r
- WS_TABSTOP,99,19,143,72\r
- CONTROL "",IDC_LIST4,"SysListView32",LVS_ALIGNLEFT | WS_BORDER | \r
- WS_TABSTOP,99,111,143,56\r
+ CONTROL "",IDC_CFG_REALMS,"SysListView32",LVS_REPORT | \r
+ LVS_SHOWSELALWAYS | LVS_SORTASCENDING | LVS_EDITLABELS | \r
+ LVS_ALIGNLEFT | LVS_NOCOLUMNHEADER | WS_TABSTOP,7,19,81,\r
+ 148\r
+ GROUPBOX "Kerberos Servers",IDC_CFG_SERVERSGRP,93,7,155,91\r
+ GROUPBOX "Domain mappings",IDC_CFG_DOMAINGRP,93,101,155,74\r
+ CONTROL "",IDC_CFG_KDC,"SysListView32",LVS_REPORT | \r
+ LVS_EDITLABELS | LVS_ALIGNLEFT | WS_TABSTOP,99,19,143,72\r
+ CONTROL "",IDC_CFG_DMAP,"SysListView32",LVS_REPORT | \r
+ LVS_EDITLABELS | LVS_ALIGNLEFT | WS_TABSTOP,99,111,143,\r
+ 56\r
END\r
\r
IDD_CFG_IDS_TAB DIALOGEX 0, 0, 235, 151\r
\r
IDD_CFG_ID_TAB DIALOGEX 0, 0, 235, 151\r
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU\r
+EXSTYLE WS_EX_CONTROLPARENT\r
FONT 8, "MS Shell Dlg", 400, 0, 0x1\r
BEGIN\r
LTEXT "Ticket lifetime",IDC_CFG_LBL_DEFLIFE,7,10,44,8\r
43,112,16,BS_NOTIFY | WS_DISABLED\r
END\r
\r
+IDD_CFG_CACHES DIALOGEX 0, 0, 255, 182\r
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU\r
+EXSTYLE WS_EX_CONTROLPARENT\r
+FONT 8, "MS Shell Dlg", 400, 0, 0x1\r
+BEGIN\r
+ GROUPBOX "File Caches",IDC_CFG_FCGRP,7,38,241,137\r
+ CONTROL "",IDC_CFG_FCLIST,"SysListView32",LVS_REPORT | \r
+ LVS_SORTASCENDING | LVS_ALIGNLEFT | WS_BORDER | \r
+ WS_TABSTOP,13,48,229,86\r
+ EDITTEXT IDC_CFG_FCNAME,13,139,173,14,ES_AUTOHSCROLL\r
+ PUSHBUTTON "&Browse ...",IDC_CFG_BROWSE,192,139,50,14\r
+ PUSHBUTTON "Add",IDC_CFG_ADD,13,156,50,14\r
+ PUSHBUTTON "Remove Selected",IDC_CFG_REMOVE,88,156,80,14\r
+ CHECKBOX "Include all API: credentials caches",IDC_CFG_INCAPI,13,\r
+ 7,125,10\r
+ CONTROL "Include Windows LSA cache (MSLSA:)",IDC_CFG_INCMSLSA,\r
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,22,136,10\r
+END\r
+\r
\r
/////////////////////////////////////////////////////////////////////////////\r
//\r
TOPMARGIN, 7\r
BOTTOMMARGIN, 159\r
END\r
+\r
+ IDD_CFG_CACHES, DIALOG\r
+ BEGIN\r
+ LEFTMARGIN, 7\r
+ RIGHTMARGIN, 248\r
+ VERTGUIDE, 7\r
+ VERTGUIDE, 13\r
+ VERTGUIDE, 242\r
+ TOPMARGIN, 7\r
+ BOTTOMMARGIN, 175\r
+ END\r
END\r
#endif // APSTUDIO_INVOKED\r
\r
\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Icon\r
+//\r
+\r
+// Icon with lowest ID value placed first to ensure application icon\r
+// remains consistent on all systems.\r
+IDI_PLUGIN ICON "..\\..\\images\\krb5plugin.ico"\r
+IDI_DELETED ICON "..\\..\\images\\deleted.ico"\r
+IDI_NEW ICON "..\\..\\images\\new.ico"\r
+IDI_NORMAL ICON "..\\..\\images\\normal.ico"\r
+IDI_MODIFIED ICON "..\\..\\images\\modified.ico"\r
+\r
/////////////////////////////////////////////////////////////////////////////\r
//\r
// String Table\r
IDS_NC_PWD_NPWD_AGAIN "New Password again"\r
IDS_KRB5_CREDTEXT_P0 "<p><a id=""SwitchPanel"" param=""Krb5Cred""><b>Krb5</b></a><tab>: Changing password for %s</p>"\r
IDS_K5CFG_IMPORT_OPTIONS \r
- "Never\000Always\000Only when the principal name matches\000 \000"\r
+ "Never\000Always\000Only when the principal name matches\000 "\r
+ IDS_IDENTPRO_DESC "Kerberos 5 Identity Provider"\r
+ IDS_K5CCC_SHORT_DESC "Credentials Caches"\r
+END\r
+\r
+STRINGTABLE \r
+BEGIN\r
+ IDS_K5CCC_LONG_DESC "Kerberos 5 Credentials Caches"\r
+ IDS_CFG_FCTITLE "File based Credential Caches"\r
+ IDS_CFG_FCN_WARNING "Warning:"\r
+ IDS_CFG_FCN_W_NOTFOUND "The credentials cache you specified does not exist."\r
+ IDS_CFG_FCN_W_RELATIVE "The path you specified not an absolute path."\r
+ IDS_CFG_FCOPENTITLE "Select a credential cache to add"\r
+ IDS_UNAVAILABLE "(Not available)"\r
+ IDS_FLG_FORWARDABLE "Forwardable"\r
+ IDS_FLG_FORWARDED "Forwarded"\r
+ IDS_FLG_PROXIABLE "Proxiable"\r
+ IDS_FLG_PROXY "Proxy"\r
+ IDS_FLG_MAY_POSTDATE "May postdate"\r
+ IDS_FLG_POSTDATED "Postdated"\r
+ IDS_FLG_INVALID "Invalid"\r
+ IDS_FLG_RENEWABLE "Renewable"\r
+ IDS_FLG_INITIAL "Initial"\r
+END\r
+\r
+STRINGTABLE \r
+BEGIN\r
+ IDS_FLG_PRE_AUTH "Pre-authenticated"\r
+ IDS_FLG_HW_AUTH "Hardware authentication"\r
+ IDS_FLG_TRANSIT_POL "Transit policy checked"\r
+ IDS_FLG_OK_DELEGATE "Approved for delegation"\r
+ IDS_FLG_ANONYMOUS "Anonymous"\r
+ IDS_K5ERR_CANTWRITEPROFILE \r
+ "The Kerberos 5 profile file could not be written"\r
+ IDS_K5ERR_PROFNOWRITE "The file %s could not be opened as a profile file for writing."\r
+ IDS_K5ERR_PROFUSETEMP "The file %s could not be opened for writing. The current changes will be saved to %s temporarily."\r
+ IDS_K5ERR_PROFSUGGEST "This may be due to not having privileges to modify the configuration file. Please contact your system administrator to resolve the issue."\r
+ IDS_CFG_RE_REALMS "Kerberos Realms"\r
+ IDS_CFG_RE_KDCS "Kerberos Servers"\r
+ IDS_CFG_RE_DMAPS "Domain mappings"\r
+ IDS_CFG_RE_KDCS_R "Kerberos Servers for %s"\r
+ IDS_CFG_RE_DMAPS_R "Domains that map to %s"\r
+ IDS_CFG_RE_HEAD_SVR "Server"\r
+ IDS_CFG_RE_HEAD_ADMIN "Admin"\r
+END\r
+\r
+STRINGTABLE \r
+BEGIN\r
+ IDS_CFG_RE_HEAD_MASTER "Master"\r
+ IDS_CFG_RE_HEAD_DOMAIN "Domain"\r
+ IDS_CFG_RE_NEWREALM "<New realm...>"\r
+ IDS_YES "Yes"\r
+ IDS_NO "No"\r
+ IDS_CFG_RE_NEWSERVER "<New server...>"\r
+ IDS_CFG_RE_NEWDMAP "<New domain mapping...>"\r
END\r
\r
#endif // English (U.S.) resources\r
//{{NO_DEPENDENCIES}}\r
// Microsoft Visual C++ generated include file.\r
-// Used by D:\work\khimaira\src\plugins\krb5\lang\en_us\langres.rc\r
+// Used by D:\work\pismere\athena\auth\krb5\src\windows\identity\plugins\krb5\lang\en_us\langres.rc\r
//\r
#define IDS_UNK_ADDR_FMT 101\r
#define IDD_NC_KRB5 102\r
#define IDS_ETYPE_NULL 110\r
#define IDD_NC_KRB5_PASSWORD 110\r
#define IDS_ETYPE_DES_CBC_CRC 111\r
+#define IDD_CFG_CACHES 111\r
#define IDS_ETYPE_DES_CBC_MD4 112\r
+#define IDI_PLUGIN 112\r
#define IDS_ETYPE_DES_CBC_MD5 113\r
+#define IDI_DELETED 113\r
#define IDS_ETYPE_DES_CBC_RAW 114\r
+#define IDI_NEW 114\r
#define IDS_ETYPE_DES3_CBC_SHA 115\r
+#define IDI_NORMAL 115\r
#define IDS_ETYPE_DES3_CBC_RAW 116\r
+#define IDI_MODIFIED 116\r
#define IDS_ETYPE_DES_HMAC_SHA1 117\r
#define IDS_ETYPE_DES3_CBC_SHA1 118\r
#define IDS_ETYPE_AES128_CTS_HMAC_SHA1_96 119\r
#define IDS_NC_PWD_NPWD_AGAIN 155\r
#define IDS_KRB5_CREDTEXT_P0 156\r
#define IDS_K5CFG_IMPORT_OPTIONS 157\r
+#define IDS_IDENTPRO_DESC 158\r
+#define IDS_K5CCC_SHORT_DESC 159\r
+#define IDS_K5CCC_LONG_DESC 160\r
+#define IDS_CFG_FCTITLE 161\r
+#define IDS_CFG_FCN_WARNING 162\r
+#define IDS_CFG_FCN_W_NOTFOUND 163\r
+#define IDS_CFG_FCN_W_RELATIVE 164\r
+#define IDS_CFG_FCOPENTITLE 165\r
+#define IDS_UNAVAILABLE 166\r
+#define IDS_FLG_FORWARDABLE 167\r
+#define IDS_FLG_FORWARDED 168\r
+#define IDS_FLG_PROXIABLE 169\r
+#define IDS_FLG_PROXY 170\r
+#define IDS_FLG_MAY_POSTDATE 171\r
+#define IDS_FLG_POSTDATED 172\r
+#define IDS_FLG_INVALID 173\r
+#define IDS_FLG_RENEWABLE 174\r
+#define IDS_FLG_INITIAL 175\r
+#define IDS_FLG_PRE_AUTH 176\r
+#define IDS_FLG_HW_AUTH 177\r
+#define IDS_FLG_TRANSIT_POL 178\r
+#define IDS_FLG_OK_DELEGATE 179\r
+#define IDS_FLG_ANONYMOUS 180\r
+#define IDS_K5ERR_CANTWRITEPROFILE 181\r
+#define IDS_K5ERR_PROFNOWRITE 182\r
+#define IDS_K5ERR_PROFUSETEMP 183\r
+#define IDS_K5ERR_PROFSUGGEST 184\r
+#define IDS_CFG_RE_REALMS 185\r
+#define IDS_CFG_RE_KDCS 186\r
+#define IDS_CFG_RE_DMAPS 187\r
+#define IDS_CFG_RE_KDCS_R 188\r
+#define IDS_CFG_RE_DMAPS_R 189\r
+#define IDS_CFG_RE_HEAD_SVR 190\r
+#define IDS_CFG_RE_HEAD_ADMIN 191\r
+#define IDS_CFG_RE_HEAD_MASTER 192\r
+#define IDS_CFG_RE_HEAD_DOMAIN 193\r
+#define IDS_CFG_RE_NEWREALM 194\r
+#define IDS_YES 195\r
+#define IDS_NO 196\r
+#define IDS_CFG_RE_NEWSERVER 197\r
+#define IDS_CFG_RE_NEWDMAP 198\r
#define IDC_NCK5_RENEWABLE 1002\r
#define IDC_NCK5_FORWARDABLE 1004\r
#define IDC_NCK5_REALM 1005\r
#define IDC_CFG_DOMAINGRP 1045\r
#define IDC_CFG_SERVERSGRP 1046\r
#define IDC_LIST3 1047\r
+#define IDC_CFG_KDC 1047\r
#define IDC_LIST4 1048\r
+#define IDC_CFG_DMAP 1048\r
#define IDC_CFG_LBL_DEFLIFE 1049\r
#define IDC_CFG_DEFLIFE 1050\r
#define IDC_CFG_LBL_DEFRLIFE 1051\r
#define IDC_CFG_RLRNG_MIN 1056\r
#define IDC_CFG_RLRNG_MAX 1057\r
#define IDC_CFG_CCACHE 1058\r
+#define IDC_CFG_FCGRP 1059\r
+#define IDC_CFG_FCLIST 1060\r
+#define IDC_CFG_FCNAME 1062\r
+#define IDC_CFG_ADD 1064\r
+#define IDC_CFG_REMOVE 1065\r
+#define IDC_CFG_INCAPI 1066\r
+#define IDC_CFG_INCMSLSA 1067\r
+#define IDC_PPK5_FLAGS 1072\r
\r
// Next default values for new objects\r
// \r
#ifdef APSTUDIO_INVOKED\r
#ifndef APSTUDIO_READONLY_SYMBOLS\r
-#define _APS_NEXT_RESOURCE_VALUE 111\r
+#define _APS_NEXT_RESOURCE_VALUE 117\r
#define _APS_NEXT_COMMAND_VALUE 40001\r
-#define _APS_NEXT_CONTROL_VALUE 1059\r
+#define _APS_NEXT_CONTROL_VALUE 1073\r
#define _APS_NEXT_SYMED_VALUE 101\r
#endif\r
#endif\r
--- /dev/null
+/* Copyright (c) 2004 Massachusetts Institute of Technology\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ *\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#include<netidmgr_intver.h>\r
+\r
+1 VERSIONINFO \r
+ FILEVERSION KH_VERSION_LIST\r
+ PRODUCTVERSION KH_VERSION_LIST\r
+ FILEFLAGSMASK KH_VER_FILEFLAGMASK\r
+ FILEFLAGS KH_VER_FILEFLAGS\r
+ FILEOS KH_VER_FILEOS\r
+ FILETYPE KH_VER_FILETYPEDLL\r
+ FILESUBTYPE 0\r
+ {\r
+ BLOCK "StringFileInfo"\r
+ {\r
+ BLOCK "040904b0"\r
+ {\r
+ VALUE "CompanyName", KH_VERSTR_COMPANY_1033\r
+ VALUE "FileDescription", "Kerberos 5 plugin for NetIDMgr"\r
+ VALUE "FileVersion", KH_VERSTR_VERSION_1033\r
+ VALUE "InternalName", "krb5cred"\r
+ VALUE "LegalCopyright", KH_VERSTR_COPYRIGHT_1033\r
+ VALUE "OriginalFilename", "krb5cred.dll"\r
+ VALUE "ProductName", "NetIDMgr"\r
+ VALUE "ProductVersion", KH_VERSTR_PRODUCT_1033\r
+#ifdef KH_VERSTR_COMMENT_1033\r
+ VALUE "Comment", KH_VERSTR_COMMENT_1033\r
+#endif\r
+ VALUE NIMV_MODULE, "MITKrb5"\r
+ VALUE NIMV_PLUGINS, "Krb5Cred,Krb5Ident"\r
+ VALUE NIMV_APIVER, KH_VERSION_STRINGAPI\r
+ VALUE NIMV_SUPPORT, "http://web.mit.edu/kerberos"\r
+ }\r
+ }\r
+\r
+ BLOCK "VarFileInfo"\r
+ {\r
+ VALUE "Translation", 0x409, 0x4b0\r
+ }\r
+ }\r
$(OBJ)\configwnd.obj \\r
$(OBJ)\aboutwnd.obj \\r
$(OBJ)\reqdaemon.obj \\r
+ $(OBJ)\addrchange.obj \\r
$(OBJ)\cfg_general_wnd.obj \\r
$(OBJ)\cfg_identities_wnd.obj \\r
$(OBJ)\cfg_notif_wnd.obj \\r
$(OBJ)\cfg_plugins_wnd.obj\r
\r
-RESFILE=$(OBJ)\khapp.res\r
+RESFILES= \\r
+ $(OBJ)\khapp.res \\r
+ $(OBJ)\appver.res\r
\r
LIBFILES= \\r
$(LIBDIR)\nidmgr32.lib\r
\r
SDKLIBFILES= \\r
comctl32.lib \\r
- shell32.lib\r
+ shell32.lib \\r
+ htmlhelp.lib \\r
+ iphlpapi.lib\r
\r
$(OBJ)\uiconfig.c: uiconfig.csv $(CONFDIR)\csvschema.cfg\r
$(CCSV) $** $@\r
\r
-$(RESFILE): lang\en_us\khapp.rc\r
+$(OBJ)\khapp.res: lang\en_us\khapp.rc\r
+ $(RC2RES)\r
+\r
+$(OBJ)\appver.res: appver.rc\r
$(RC2RES)\r
\r
!if "$(KH_BUILD)"=="RETAIL"\r
!endif\r
$(CP) $** $@\r
\r
-$(EXEFILE): $(OBJFILES) $(RESFILE) $(LIBFILES)\r
+$(EXEFILE): $(OBJFILES) $(RESFILES) $(LIBFILES)\r
$(EXEGUILINK) $(SDKLIBFILES)\r
\r
all: mkdirs $(EXEFILE) $(MANIFESTFILE)\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/* $Id$ */\r
\r
#include<khmapp.h>\r
-#include<khimaira_version.h>\r
+#include<netidmgr_intver.h>\r
#include<tlhelp32.h>\r
\r
#if DEBUG\r
mod.dwSize = sizeof(mod);\r
} while(Module32Next(hsnap, &mod));\r
\r
+#if (_WIN32_WINNT >= 0x501)\r
+ /* we are also setting the report style when creating\r
+ the control. this is actually optional. */\r
ListView_SetView(hw, LV_VIEW_DETAILS);\r
+#endif\r
\r
_done_with_modules:\r
CloseHandle(hsnap);\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
--- /dev/null
+/*\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#include<khmapp.h>\r
+#include<iphlpapi.h>\r
+\r
+static HANDLE evt_terminate = NULL;\r
+static HANDLE h_thread = NULL;\r
+\r
+DWORD WINAPI\r
+addr_change_thread(LPVOID dummy) {\r
+\r
+ HANDLE h_waits[2];\r
+ HANDLE h_notify;\r
+\r
+ OVERLAPPED overlap;\r
+ DWORD ret;\r
+\r
+ ZeroMemory(&overlap, sizeof(overlap));\r
+\r
+ h_notify = NULL;\r
+ overlap.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);\r
+\r
+ do {\r
+ ret = NotifyAddrChange(&h_notify, &overlap);\r
+\r
+ if (ret != ERROR_IO_PENDING) {\r
+ goto _end_thread; /* some error */\r
+ }\r
+\r
+ h_waits[0] = overlap.hEvent;\r
+ h_waits[1] = evt_terminate;\r
+\r
+ ret = WaitForMultipleObjects(2, h_waits, FALSE, INFINITE);\r
+\r
+ if ( ret == WAIT_OBJECT_0 ) {\r
+ kmq_post_message(KMSG_CRED, KMSG_CRED_ADDR_CHANGE,\r
+ 0, 0);\r
+ } else {\r
+ goto _end_thread;\r
+ }\r
+ } while(TRUE);\r
+ \r
+ _end_thread:\r
+ ExitThread(0);\r
+ return 0; /* unreachable */\r
+}\r
+\r
+void\r
+khm_addr_change_notifier_init(void) {\r
+ evt_terminate = CreateEvent(NULL, FALSE, FALSE, NULL);\r
+ h_thread = CreateThread(NULL,\r
+ 64 * 4096,\r
+ addr_change_thread,\r
+ NULL,\r
+ 0,\r
+ NULL);\r
+}\r
+\r
+void\r
+khm_addr_change_notifier_exit(void) {\r
+ if (h_thread && evt_terminate) {\r
+ SetEvent(evt_terminate);\r
+ WaitForSingleObject(h_thread, INFINITE);\r
+\r
+ CloseHandle(h_thread);\r
+ CloseHandle(evt_terminate);\r
+ }\r
+}\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
\r
/* $Id$ */\r
\r
-#ifndef __KHIMAIRA_KRB_DATAREP_H\r
-#define __KHIMAIRA_KRB_DATAREP_H\r
+#ifndef __NETIDMGR_ADDRCHANGE_H\r
+#define __NETIDMGR_ADDRCHANGE_H\r
\r
+void\r
+khm_addr_change_notifier_init(void);\r
\r
-khm_int32 KHMAPI enctype_toString(const void * data, khm_int32 cbdata, wchar_t *destbuf, khm_int32 *pcbdestbuf, khm_int32 flags);\r
-khm_int32 KHMAPI addr_list_toString(const void *, khm_int32, wchar_t *, khm_int32 *, khm_int32);\r
-khm_int32 KHMAPI krb5flags_toString(const void *, khm_int32, wchar_t *, khm_int32 *, khm_int32);\r
-khm_int32 KHMAPI renew_for_cb(khm_handle cred, khm_int32 id, void * buffer, khm_int32 * pcbsize);\r
+void\r
+khm_addr_change_notifier_exit(void);\r
\r
-\r
-#endif
\ No newline at end of file
+#endif\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
--- /dev/null
+\r
+#include<windows.h>\r
+#include<netidmgr_intver.h>\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
+//\r
+// Version\r
+//\r
+\r
+VS_VERSION_INFO VERSIONINFO\r
+ FILEVERSION KH_VERSION_LIST\r
+ PRODUCTVERSION KH_VERSION_LIST\r
+ FILEFLAGSMASK 0x17L\r
+ FILEFLAGS KH_VER_FILEFLAGS\r
+ FILEOS KH_VER_FILEOS\r
+ FILETYPE 0x0L\r
+ FILESUBTYPE 0x0L\r
+BEGIN\r
+ BLOCK "StringFileInfo"\r
+ BEGIN\r
+ BLOCK "040904b0"\r
+ BEGIN\r
+ VALUE "CompanyName", KH_VERSTR_COMPANY_1033\r
+ VALUE "FileDescription", "Network Identity Manager"\r
+ VALUE "FileVersion", KH_VERSTR_VERSION_1033\r
+ VALUE "InternalName", "NetIDMgr"\r
+ VALUE "LegalCopyright", KH_VERSTR_COPYRIGHT_1033\r
+ VALUE "OriginalFilename", "netidmgr.exe"\r
+ VALUE "ProductName", "NetIDMgr"\r
+ VALUE "ProductVersion", KH_VERSTR_PRODUCT_1033\r
+#ifdef KH_VERSTR_COMMENT_1033\r
+ VALUE "Comment", KH_VERSTR_COMMENT_1033\r
+#endif\r
+ END\r
+ END\r
+ BLOCK "VarFileInfo"\r
+ BEGIN\r
+ VALUE "Translation", 0x409, 1200\r
+ END\r
+END\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
write_params(dlg_data * dd) {\r
cfg_data * d, * s;\r
khm_handle csp_cw;\r
+ BOOL applied = FALSE;\r
\r
d = &dd->work;\r
s = &dd->saved;\r
return;\r
}\r
\r
- if (!!d->auto_init != !!s->auto_init)\r
+ if (!!d->auto_init != !!s->auto_init) {\r
khc_write_int32(csp_cw, L"AutoInit", d->auto_init);\r
+ applied = TRUE;\r
+ }\r
\r
- if (!!d->auto_start != !!s->auto_start)\r
+ if (!!d->auto_start != !!s->auto_start) {\r
khc_write_int32(csp_cw, L"AutoStart", d->auto_start);\r
+ applied = TRUE;\r
+ }\r
\r
- if (!!d->auto_import != !!s->auto_import)\r
+ if (!!d->auto_import != !!s->auto_import) {\r
khc_write_int32(csp_cw, L"AutoImport", d->auto_import);\r
+ applied = TRUE;\r
+ }\r
\r
- if (!!d->keep_running != !!s->keep_running)\r
+ if (!!d->keep_running != !!s->keep_running) {\r
khc_write_int32(csp_cw, L"KeepRunning", d->keep_running);\r
+ applied = TRUE;\r
+ }\r
\r
- if (!!d->auto_detect_net != !!s->auto_detect_net)\r
+ if (!!d->auto_detect_net != !!s->auto_detect_net) {\r
khc_write_int32(csp_cw, L"AutoDetectNet", d->auto_detect_net);\r
+ applied = TRUE;\r
+ }\r
\r
khc_close_space(csp_cw);\r
\r
khui_cfg_set_flags(dd->node,\r
- KHUI_CNFLAG_APPLIED,\r
+ (applied) ? KHUI_CNFLAG_APPLIED : 0,\r
KHUI_CNFLAG_APPLIED | KHUI_CNFLAG_MODIFIED);\r
\r
*s = *d;\r
\r
switch(uMsg) {\r
case WM_INITDIALOG:\r
- d = malloc(sizeof(*d));\r
+ d = PMALLOC(sizeof(*d));\r
#ifdef DEBUG\r
assert(d != NULL);\r
#endif\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
add_subpanels(HWND hwnd, \r
khui_config_node ctx_node,\r
khui_config_node ref_node) {\r
+\r
HWND hw_tab;\r
HWND hw_target;\r
khui_config_node sub;\r
int idx_deleted;\r
\r
HWND hwnd;\r
+ khui_config_init_data cfg;\r
} idents_data;\r
\r
static idents_data cfg_idents = {FALSE, NULL, 0, 0, 0, NULL };\r
khc_write_int32(csp_ident, L"AllowAutoRenew", !!d->work.auto_renew);\r
\r
if (d->saved.sticky != d->work.sticky) {\r
- khc_write_int32(csp_ident, L"Sticky", !!d->work.sticky);\r
- if (d->work.sticky) {\r
- kcdb_identity_set_flags(d->ident, KCDB_IDENT_FLAG_STICKY);\r
- } else {\r
- kcdb_identity_set_flags(d->ident, \r
- KCDB_IDENT_FLAG_STICKY |\r
- KCDB_IDENT_FLAG_INVERT);\r
- }\r
+ kcdb_identity_set_flags(d->ident,\r
+ (d->work.sticky)?KCDB_IDENT_FLAG_STICKY:0,\r
+ KCDB_IDENT_FLAG_STICKY);\r
}\r
\r
khc_close_space(csp_ident);\r
break;\r
\r
if (widnames)\r
- free(widnames);\r
- widnames = malloc(cb);\r
+ PFREE(widnames);\r
+ widnames = PMALLOC(cb);\r
#ifdef DEBUG\r
assert(widnames);\r
#endif\r
goto _cleanup;\r
}\r
\r
- cfg_idents.idents = malloc(sizeof(*cfg_idents.idents) * \r
+ cfg_idents.idents = PMALLOC(sizeof(*cfg_idents.idents) * \r
cfg_idents.n_idents);\r
#ifdef DEBUG\r
assert(cfg_idents.idents);\r
StringCbLength(t, KCDB_IDENT_MAXCB_NAME, &cb);\r
cb += sizeof(wchar_t);\r
\r
- cfg_idents.idents[i].idname = malloc(cb);\r
+ cfg_idents.idents[i].idname = PMALLOC(cb);\r
#ifdef DEBUG\r
assert(cfg_idents.idents[i].idname);\r
#endif\r
cfg_idents.valid = TRUE;\r
\r
if (widnames)\r
- free(widnames);\r
+ PFREE(widnames);\r
}\r
\r
static void\r
if (cfg_idents.idents[i].ident)\r
kcdb_identity_release(cfg_idents.idents[i].ident);\r
if (cfg_idents.idents[i].idname)\r
- free(cfg_idents.idents[i].idname);\r
+ PFREE(cfg_idents.idents[i].idname);\r
}\r
\r
if (cfg_idents.idents)\r
- free(cfg_idents.idents);\r
+ PFREE(cfg_idents.idents);\r
\r
cfg_idents.idents = NULL;\r
cfg_idents.n_idents = 0;\r
BST_INDETERMINATE));\r
\r
if (sel_count > 0) {\r
+ EnableWindow(GetDlgItem(hwnd, IDC_CFG_MONITOR), TRUE);\r
+ EnableWindow(GetDlgItem(hwnd, IDC_CFG_RENEW), TRUE);\r
+ EnableWindow(GetDlgItem(hwnd, IDC_CFG_STICKY), TRUE);\r
EnableWindow(GetDlgItem(hwnd, IDC_CFG_REMOVE), TRUE);\r
} else {\r
+ EnableWindow(GetDlgItem(hwnd, IDC_CFG_MONITOR), FALSE);\r
+ EnableWindow(GetDlgItem(hwnd, IDC_CFG_RENEW), FALSE);\r
+ EnableWindow(GetDlgItem(hwnd, IDC_CFG_STICKY), FALSE);\r
EnableWindow(GetDlgItem(hwnd, IDC_CFG_REMOVE), FALSE);\r
}\r
}\r
\r
{\r
khm_int32 flags = 0;\r
- khui_config_node node = NULL;\r
\r
if (modified)\r
flags |= KHUI_CNFLAG_MODIFIED;\r
if (applied)\r
flags |= KHUI_CNFLAG_APPLIED;\r
\r
- khui_cfg_open(NULL, L"KhmIdentities", &node);\r
-#ifdef DEBUG\r
- assert(node);\r
-#endif\r
- khui_cfg_set_flags(node, flags,\r
- KHUI_CNFLAG_APPLIED | KHUI_CNFLAG_MODIFIED);\r
+ khui_cfg_set_flags_inst(&cfg_idents.cfg, flags,\r
+ KHUI_CNFLAG_APPLIED | KHUI_CNFLAG_MODIFIED);\r
}\r
}\r
\r
hold_idents_data();\r
\r
cfg_idents.hwnd = hwnd;\r
+ cfg_idents.cfg = *((khui_config_init_data *) lParam);\r
\r
/* first add the column */\r
hw = GetDlgItem(hwnd, IDC_CFG_IDENTS);\r
if (cfg_idents.hi_status)\r
goto _done_with_icons;\r
\r
- cfg_idents.hi_status = ImageList_Create(SM_CXICON, SM_CYICON, \r
- ILC_COLOR8 | ILC_MASK,\r
- 4,4);\r
+ cfg_idents.hi_status = \r
+ ImageList_Create(GetSystemMetrics(SM_CXSMICON),\r
+ GetSystemMetrics(SM_CYSMICON), \r
+ ILC_COLOR8 | ILC_MASK,\r
+ 4,4);\r
\r
- hicon = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_ID),\r
- IMAGE_ICON, SM_CXICON, SM_CYICON, LR_DEFAULTCOLOR);\r
+ hicon =\r
+ LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_ID),\r
+ IMAGE_ICON,\r
+ GetSystemMetrics(SM_CXSMICON),\r
+ GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);\r
\r
cfg_idents.idx_id = ImageList_AddIcon(cfg_idents.hi_status,\r
hicon);\r
DestroyIcon(hicon);\r
\r
hicon = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_CFG_DEFAULT),\r
- IMAGE_ICON, SM_CXICON, SM_CYICON, LR_DEFAULTCOLOR);\r
+ IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), \r
+ GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);\r
\r
cfg_idents.idx_default = ImageList_AddIcon(cfg_idents.hi_status, \r
hicon) + 1;\r
DestroyIcon(hicon);\r
\r
hicon = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_CFG_MODIFIED),\r
- IMAGE_ICON, SM_CXICON, SM_CYICON, LR_DEFAULTCOLOR);\r
+ IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), \r
+ GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);\r
\r
cfg_idents.idx_modified = ImageList_AddIcon(cfg_idents.hi_status, \r
hicon) + 1;\r
DestroyIcon(hicon);\r
\r
hicon = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_CFG_APPLIED),\r
- IMAGE_ICON, SM_CXICON, SM_CYICON, LR_DEFAULTCOLOR);\r
+ IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), \r
+ GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);\r
\r
cfg_idents.idx_applied = ImageList_AddIcon(cfg_idents.hi_status, \r
hicon) + 1;\r
DestroyIcon(hicon);\r
\r
hicon = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_CFG_DELETED),\r
- IMAGE_ICON, SM_CXICON, SM_CYICON, LR_DEFAULTCOLOR);\r
+ IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), \r
+ GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);\r
\r
cfg_idents.idx_deleted = ImageList_AddIcon(cfg_idents.hi_status, \r
hicon) + 1;\r
cfg_idents.idents[i].lv_idx = ListView_InsertItem(hw, &lvi);\r
}\r
\r
+#if (_WIN32_WINNT >= 0x501)\r
ListView_SetView(hw, LV_VIEW_DETAILS);\r
+#endif\r
}\r
return FALSE;\r
\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
typedef struct tag_notif_data {\r
khui_config_node node;\r
\r
+ BOOL modified;\r
+\r
BOOL monitor;\r
BOOL renew;\r
BOOL warn1;\r
d->tc_warn2.min = t;\r
\r
khc_close_space(csp_cw);\r
+\r
+ d->modified = FALSE;\r
}\r
\r
static void\r
KHUI_CNFLAG_MODIFIED,\r
KHUI_CNFLAG_MODIFIED);\r
\r
+ d->modified = TRUE;\r
+\r
} else {\r
khui_cfg_set_flags(d->node,\r
0,\r
KHUI_CNFLAG_MODIFIED);\r
+\r
+ d->modified = FALSE;\r
}\r
}\r
\r
khm_handle csp_cw;\r
khm_int32 rv;\r
\r
+ if (!d->modified)\r
+ return;\r
+\r
rv = khc_open_space(NULL, L"CredWindow", KHM_PERM_WRITE, &csp_cw);\r
assert(KHM_SUCCEEDED(rv));\r
\r
case WM_INITDIALOG: {\r
HWND hw;\r
\r
- d = malloc(sizeof(*d));\r
+ d = PMALLOC(sizeof(*d));\r
#ifdef DEBUG\r
assert(d != NULL);\r
#endif\r
khui_tracker_kill_controls(&d->tc_warn1);\r
khui_tracker_kill_controls(&d->tc_warn2);\r
\r
- free(d);\r
+ PFREE(d);\r
\r
SetWindowLongPtr(hwnd, DWLP_USER, 0);\r
\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
wchar_t buf[256];\r
\r
\r
- d = malloc(sizeof(*d));\r
+ d = PMALLOC(sizeof(*d));\r
#ifdef DEBUG\r
assert(d);\r
#endif\r
#ifdef DEBUG\r
assert(d->info[i] == NULL);\r
#endif\r
- d->info[i] = malloc(sizeof(*(d->info[i])));\r
+ d->info[i] = PMALLOC(sizeof(*(d->info[i])));\r
#ifdef DEBUG\r
assert(d->info[i]);\r
#endif\r
\r
if (KHM_FAILED(kmm_get_plugin_info_i(p, &d->info[i]->plugin))) {\r
- free(d->info[i]);\r
+ PFREE(d->info[i]);\r
d->info[i] = NULL;\r
break;\r
}\r
#ifdef DEBUG\r
assert(hw);\r
#endif\r
+#if (_WIN32_WINNT >= 0x501)\r
ListView_SetView(hw, LV_VIEW_DETAILS);\r
-\r
+#endif\r
ZeroMemory(&lvc, sizeof(lvc));\r
\r
lvc.mask = LVCF_TEXT | LVCF_WIDTH;\r
#endif\r
kmm_release_plugin_info_i(&d->info[i]->plugin);\r
kmm_release_module_info_i(&d->info[i]->module);\r
- free(d->info[i]);\r
+ PFREE(d->info[i]);\r
}\r
\r
- free(d);\r
+ PFREE(d);\r
\r
khm_set_dialog_result(hwnd, 0);\r
}\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
\r
/* create and fill the image list for the treeview */\r
\r
- d->hi_status = ImageList_Create(SM_CXICON, SM_CYICON, \r
+ d->hi_status = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), \r
ILC_COLOR8 | ILC_MASK,\r
4,4);\r
\r
hicon = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_CFG_DEFAULT),\r
- IMAGE_ICON, SM_CXICON, SM_CYICON, LR_DEFAULTCOLOR);\r
+ IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);\r
\r
/* note that we can't use index 0 because that is used to indicate\r
that there is no state image for the node */\r
DestroyIcon(hicon);\r
\r
hicon = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_CFG_MODIFIED),\r
- IMAGE_ICON, SM_CXICON, SM_CYICON, LR_DEFAULTCOLOR);\r
+ IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);\r
\r
d->idx_modified = ImageList_AddIcon(d->hi_status, hicon);\r
\r
DestroyIcon(hicon);\r
\r
hicon = LoadImage(khm_hInstance, MAKEINTRESOURCE(IDI_CFG_APPLIED),\r
- IMAGE_ICON, SM_CXICON, SM_CYICON, LR_DEFAULTCOLOR);\r
+ IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR);\r
\r
d->idx_applied = ImageList_AddIcon(d->hi_status, hicon);\r
\r
ImageList_Destroy(d->hi_status);\r
}\r
\r
+static HWND\r
+cfgui_create_config_node_window(HWND hwnd, khui_config_node node) {\r
+ khui_config_node_reg reg;\r
+ khm_int32 rv;\r
+ HWND hw_new;\r
+\r
+ khui_config_node parent;\r
+\r
+ if (KHM_SUCCEEDED(khui_cfg_get_parent(node, &parent))) {\r
+ HWND hwp;\r
+\r
+ hwp = khui_cfg_get_hwnd(parent);\r
+\r
+ if (hwp == NULL)\r
+ cfgui_create_config_node_window(hwnd, parent);\r
+\r
+ khui_cfg_release(parent);\r
+ }\r
+\r
+ rv = khui_cfg_get_reg(node, ®);\r
+#ifdef DEBUG\r
+ assert(KHM_SUCCEEDED(rv));\r
+#endif\r
+ hw_new = CreateDialogParam(reg.h_module,\r
+ reg.dlg_template,\r
+ hwnd,\r
+ reg.dlg_proc,\r
+ (LPARAM) node);\r
+#ifdef DEBUG\r
+ assert(hw_new);\r
+#endif\r
+ khui_cfg_set_hwnd(node, hw_new);\r
+\r
+ return hw_new;\r
+}\r
+\r
static void\r
cfgui_activate_node(HWND hwnd, khui_config_node node) {\r
\r
if (node == NULL) {\r
hw_new = d->hw_generic_pane;\r
} else {\r
- khui_config_node_reg reg;\r
- khm_int32 rv;\r
\r
hw_new = khui_cfg_get_hwnd(node);\r
\r
if (hw_new == NULL) {\r
- rv = khui_cfg_get_reg(node, ®);\r
-#ifdef DEBUG\r
- assert(KHM_SUCCEEDED(rv));\r
-#endif\r
- hw_new = CreateDialogParam(reg.h_module,\r
- reg.dlg_template,\r
- hwnd,\r
- reg.dlg_proc,\r
- (LPARAM) node);\r
-#ifdef DEBUG\r
- assert(hw_new);\r
-#endif\r
- khui_cfg_set_hwnd(node, hw_new);\r
+ hw_new = cfgui_create_config_node_window(hwnd, node);\r
}\r
}\r
\r
\r
khui_cfg_clear_params();\r
\r
- d = malloc(sizeof(*d));\r
+ d = PMALLOC(sizeof(*d));\r
ZeroMemory(d, sizeof(*d));\r
\r
d->hbr_white = CreateSolidBrush(RGB(255,255,255));\r
return;\r
\r
if (idents)\r
- free(idents);\r
- idents = malloc(cb);\r
+ PFREE(idents);\r
+ idents = PMALLOC(cb);\r
#ifdef DEBUG\r
assert(idents);\r
#endif\r
khui_cfg_release(cfg_ids);\r
\r
if (idents)\r
- free(idents);\r
+ PFREE(idents);\r
}\r
\r
void khm_init_config(void) {\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
khui_alert * alert;\r
kherr_event * evt;\r
kherr_context * ctx;\r
- wchar_t ws_title[1024];\r
+ wchar_t ws_tfmt[512];\r
+ wchar_t w_idname[KCDB_IDENT_MAXCCH_NAME];\r
+ wchar_t ws_title[ARRAYLENGTH(ws_tfmt) + KCDB_IDENT_MAXCCH_NAME];\r
+ khm_size cb;\r
\r
ctx = kherr_peek_context();\r
evt = kherr_get_err_event(ctx);\r
\r
if (nc->subtype == KMSG_CRED_PASSWORD)\r
LoadString(khm_hInstance, IDS_NC_PWD_FAILED_TITLE,\r
- ws_title, ARRAYLENGTH(ws_title));\r
+ ws_tfmt, ARRAYLENGTH(ws_tfmt));\r
+ else if (nc->subtype == KMSG_CRED_RENEW_CREDS)\r
+ LoadString(khm_hInstance, IDS_NC_REN_FAILED_TITLE,\r
+ ws_tfmt, ARRAYLENGTH(ws_tfmt));\r
else\r
LoadString(khm_hInstance, IDS_NC_FAILED_TITLE,\r
- ws_title, ARRAYLENGTH(ws_title));\r
+ ws_tfmt, ARRAYLENGTH(ws_tfmt));\r
+\r
+ if (nc->n_identities > 0) {\r
+ cb = sizeof(w_idname);\r
+ if (KHM_FAILED(kcdb_identity_get_name(nc->identities[0], \r
+ w_idname, &cb)))\r
+ StringCbCopy(w_idname, sizeof(w_idname), L"(?)");\r
+ } else {\r
+ StringCbCopy(w_idname, sizeof(w_idname), L"(?)");\r
+ }\r
+\r
+ StringCbPrintf(ws_title, sizeof(ws_title), ws_tfmt, w_idname);\r
\r
khui_alert_set_title(alert, ws_title);\r
khui_alert_set_severity(alert, evt->severity);\r
if (nc->subtype == KMSG_CRED_NEW_CREDS ||\r
nc->subtype == KMSG_CRED_PASSWORD) {\r
\r
+ /*\r
if (nc->subtype == KMSG_CRED_NEW_CREDS)\r
khui_context_reset();\r
+ */\r
\r
khm_cred_end_dialog(nc->result);\r
}\r
assert(m->vparam != NULL);\r
#endif\r
khui_context_release((khui_action_context *) m->vparam);\r
- free(m->vparam);\r
+ PFREE(m->vparam);\r
\r
kmq_post_message(KMSG_CRED, KMSG_CRED_REFRESH, 0, 0);\r
\r
case KMSG_CRED_IMPORT:\r
khm_cred_process_commandline();\r
break;\r
+\r
+ case KMSG_CRED_REFRESH:\r
+ kcdb_identity_refresh_all();\r
+ break;\r
}\r
}\r
\r
{\r
khui_action_context * pctx;\r
\r
- pctx = malloc(sizeof(*pctx));\r
+ pctx = PMALLOC(sizeof(*pctx));\r
#ifdef DEBUG\r
assert(pctx);\r
#endif\r
KHERR_WARNING);\r
\r
khui_context_release(pctx);\r
- free(pctx);\r
+ PFREE(pctx);\r
} else {\r
_begin_task(KHERR_CF_TRANSITIVE);\r
_report_sr0(KHERR_NONE, IDS_CTX_RENEW_CREDS);\r
if (SUCCEEDED(StringCbLength(title, KHUI_MAXCB_TITLE, &cb))) {\r
cb += sizeof(wchar_t);\r
\r
- nc->window_title = malloc(cb);\r
+ nc->window_title = PMALLOC(cb);\r
#ifdef DEBUG\r
assert(nc->window_title);\r
#endif\r
&cb))) {\r
\r
cb = (cb + 1) * sizeof(wchar_t);\r
- nc->window_title = malloc(cb);\r
+ nc->window_title = PMALLOC(cb);\r
#ifdef DEBUG\r
assert(nc->window_title);\r
#endif\r
\r
kcdb_identpro_get_ui_cb((void *) &nc->ident_cb);\r
\r
- assert(nc->ident_cb);\r
+ if (nc->ident_cb == NULL) {\r
+ wchar_t title[256];\r
+ wchar_t msg[512];\r
+ wchar_t suggestion[512];\r
+ khui_alert * a;\r
+\r
+ LoadString(khm_hInstance, IDS_ERR_TITLE_NO_IDENTPRO,\r
+ title, ARRAYLENGTH(title));\r
+ LoadString(khm_hInstance, IDS_ERR_MSG_NO_IDENTPRO,\r
+ msg, ARRAYLENGTH(msg));\r
+ LoadString(khm_hInstance, IDS_ERR_SUGG_NO_IDENTPRO,\r
+ suggestion, ARRAYLENGTH(suggestion));\r
+\r
+ khui_alert_create_simple(title,\r
+ msg,\r
+ KHERR_ERROR,\r
+ &a);\r
+ khui_alert_set_suggestion(a, suggestion);\r
+\r
+ khui_alert_show(a);\r
+\r
+ khui_alert_release(a);\r
+\r
+ khui_context_release(&nc->ctx);\r
+ khui_cw_destroy_cred_blob(nc);\r
+ khm_cred_end_dialog(KHUI_NC_RESULT_CANCEL);\r
+ return;\r
+ }\r
\r
if (title) {\r
if (SUCCEEDED(StringCbLength(title, KHUI_MAXCB_TITLE, &cb))) {\r
cb += sizeof(wchar_t);\r
\r
- nc->window_title = malloc(cb);\r
+ nc->window_title = PMALLOC(cb);\r
#ifdef DEBUG\r
assert(nc->window_title);\r
#endif\r
&cb))) {\r
\r
cb = (cb + 1) * sizeof(wchar_t);\r
- nc->window_title = malloc(cb);\r
+ nc->window_title = PMALLOC(cb);\r
#ifdef DEBUG\r
assert(nc->window_title);\r
#endif\r
\r
_end_task();\r
} else {\r
+ khui_context_release(&nc->ctx);\r
khui_cw_destroy_cred_blob(nc);\r
+ khm_cred_end_dialog(KHUI_NC_RESULT_CANCEL);\r
}\r
}\r
\r
\r
khm_cred_process_commandline();\r
}\r
+\r
+void\r
+khm_cred_refresh(void) {\r
+ kmq_post_message(KMSG_CRED, KMSG_CRED_REFRESH, 0, NULL);\r
+}\r
+\r
+void\r
+khm_cred_addr_change(void) {\r
+ khm_handle csp_cw = NULL;\r
+ khm_int32 check_net = 0;\r
+\r
+ wchar_t * ids = NULL;\r
+ wchar_t * t;\r
+ khm_size cb;\r
+ khm_size n_idents;\r
+\r
+ __int64 ft_now;\r
+ __int64 ft_exp;\r
+ __int64 ft_issue;\r
+\r
+ if (KHM_SUCCEEDED(khc_open_space(NULL, L"CredWindow",\r
+ 0, &csp_cw))) {\r
+ khc_read_int32(csp_cw, L"AutoDetectNet", &check_net);\r
+\r
+ khc_close_space(csp_cw);\r
+ }\r
+\r
+ if (!check_net)\r
+ return;\r
+\r
+ while(TRUE) {\r
+ if (ids)\r
+ PFREE(ids);\r
+ ids = NULL;\r
+\r
+ if (kcdb_identity_enum(KCDB_IDENT_FLAG_VALID |\r
+ KCDB_IDENT_FLAG_RENEWABLE,\r
+ KCDB_IDENT_FLAG_VALID |\r
+ KCDB_IDENT_FLAG_RENEWABLE,\r
+ NULL,\r
+ &cb,\r
+ &n_idents) != KHM_ERROR_TOO_LONG)\r
+ break;\r
+\r
+ ids = PMALLOC(cb);\r
+\r
+ if (KHM_SUCCEEDED\r
+ (kcdb_identity_enum(KCDB_IDENT_FLAG_VALID |\r
+ KCDB_IDENT_FLAG_RENEWABLE,\r
+ KCDB_IDENT_FLAG_VALID |\r
+ KCDB_IDENT_FLAG_RENEWABLE,\r
+ ids,\r
+ &cb,\r
+ &n_idents)))\r
+ break;\r
+ }\r
+\r
+ if (!ids)\r
+ return;\r
+\r
+ GetSystemTimeAsFileTime((LPFILETIME) &ft_now);\r
+\r
+ for (t=ids; t && *t; t = multi_string_next(t)) {\r
+ khm_handle ident;\r
+\r
+\r
+ if (KHM_FAILED\r
+ (kcdb_identity_create(t, 0, &ident)))\r
+ continue;\r
+\r
+ cb = sizeof(ft_issue);\r
+\r
+ if (KHM_SUCCEEDED\r
+ (kcdb_identity_get_attr(ident, KCDB_ATTR_ISSUE, NULL,\r
+ &ft_issue, &cb)) &&\r
+\r
+ (cb = sizeof(ft_exp)) &&\r
+ KHM_SUCCEEDED\r
+ (kcdb_identity_get_attr(ident, KCDB_ATTR_EXPIRE, NULL,\r
+ &ft_exp, &cb)) &&\r
+\r
+ ft_now > (ft_issue + ft_exp)/2 &&\r
+ ft_now < ft_exp) {\r
+\r
+ khm_cred_renew_identity(ident);\r
+\r
+ }\r
+\r
+ kcdb_identity_release(ident);\r
+ }\r
+}\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
void\r
khm_cred_process_commandline(void);\r
\r
+void\r
+khm_cred_refresh(void);\r
+\r
+void\r
+khm_cred_addr_change(void);\r
+\r
#endif\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
\r
if(KHM_FAILED(khc_open_space(NULL, L"CredWindow", KHM_PERM_READ, &hc_cw)))\r
return;\r
+\r
if(KHM_FAILED(khc_open_space(hc_cw, L"Views", KHM_PERM_READ, &hc_vs)))\r
goto _exit;\r
\r
if(khc_read_multi_string(hc_v, L"ColumnList", NULL, &cbsize) != KHM_ERROR_TOO_LONG)\r
goto _exit;\r
\r
- clist = malloc(cbsize);\r
+ /* temporary */\r
+ clist = PMALLOC(cbsize);\r
\r
if(KHM_FAILED(khc_read_multi_string(hc_v, L"ColumnList", clist, &cbsize)))\r
goto _exit;\r
\r
tbl->n_cols = (int) multi_string_length_n(clist);\r
tbl->n_total_cols = UBOUNDSS(tbl->n_cols, KHUI_CW_COL_INITIAL, KHUI_CW_COL_INCREMENT);\r
- tbl->cols = malloc(sizeof(khui_credwnd_col) * tbl->n_total_cols);\r
+ tbl->cols = PMALLOC(sizeof(khui_credwnd_col) * tbl->n_total_cols);\r
ZeroMemory(tbl->cols, sizeof(khui_credwnd_col) * tbl->n_total_cols);\r
\r
iter = clist;\r
if(kcdb_attrib_describe(attr_id, NULL, &cbsize, KCDB_TS_SHORT) != KHM_ERROR_TOO_LONG ||\r
cbsize == 0)\r
goto _skip_col;\r
- tbl->cols[i].title = malloc(cbsize);\r
+ tbl->cols[i].title = PMALLOC(cbsize);\r
kcdb_attrib_describe(attr_id, tbl->cols[i].title, &cbsize, KCDB_TS_SHORT);\r
} else {\r
/* All current custom attributes are represented by icons,\r
tbl->hb_hdr_bg_crit = CreateSolidBrush(RGB(240,133,117));\r
tbl->hb_hdr_bg_warn = CreateSolidBrush(RGB(251,199,77));\r
tbl->hb_hdr_bg_exp = CreateSolidBrush(RGB(255,144,144));\r
+ tbl->hb_hdr_bg_def = CreateSolidBrush(RGB(186,254,184));\r
\r
tbl->cr_normal = RGB(0,0,0);\r
tbl->cr_sel = RGB(0,0,0);\r
tbl->cr_hdr_normal = RGB(0,0,0);\r
tbl->cr_hdr_sel = RGB(255,255,255);\r
\r
- tbl->ilist = khui_create_ilist(KHUI_SMICON_CX, KHUI_SMICON_CY-1, 16, 8, 0);\r
+ tbl->ilist = khui_create_ilist(KHUI_SMICON_CX, KHUI_SMICON_CY-1, 20, 8, 0);\r
{\r
HBITMAP hbm;\r
\r
ADD_BITMAP(IDB_FLAG_WARN);\r
ADD_BITMAP(IDB_FLAG_EXPIRED);\r
ADD_BITMAP(IDB_FLAG_CRITICAL);\r
+ ADD_BITMAP(IDB_WDG_STUCK);\r
+ ADD_BITMAP(IDB_WDG_STUCK_HI);\r
+ ADD_BITMAP(IDB_WDG_STICK);\r
+ ADD_BITMAP(IDB_WDG_STICK_HI);\r
\r
#undef ADD_BITMAP\r
}\r
if(hc_cs)\r
khc_close_space(hc_cs);\r
if(clist)\r
- free(clist);\r
+ PFREE(clist);\r
}\r
\r
void \r
&delta);\r
\r
/* now we need to figure out how to sort the credentials */\r
- fields = malloc(sizeof(kcdb_cred_comp_field) * tbl->n_cols);\r
+ fields = PMALLOC(sizeof(kcdb_cred_comp_field) * tbl->n_cols);\r
ZeroMemory(fields, sizeof(kcdb_cred_comp_field) * tbl->n_cols);\r
\r
for(i=0, n=0; i<tbl->n_cols; i++) {\r
if((tbl->cols[i].flags & KHUI_CW_COL_SORT_INC) ||\r
- (tbl->cols[i].flags & KHUI_CW_COL_SORT_DEC) ||\r
- (tbl->cols[i].flags & KHUI_CW_COL_GROUP))\r
+ (tbl->cols[i].flags & KHUI_CW_COL_SORT_DEC) ||\r
+ (tbl->cols[i].flags & KHUI_CW_COL_GROUP))\r
{\r
int si;\r
/* we need to sort by this column */\r
\r
kcdb_credset_get_size(tbl->credset, &s);\r
for(i=0;i<s;i++) {\r
- if(KHM_FAILED(kcdb_credset_get_cred(tbl->credset, (khm_int32) i, &hc)))\r
+ if(KHM_FAILED(kcdb_credset_get_cred(tbl->credset, \r
+ (khm_int32) i, &hc)))\r
continue; /* lost a race */\r
- if(KHM_FAILED(kcdb_cred_get_attr(hc, khui_cw_flag_id, NULL, NULL, NULL))) {\r
+ if(KHM_FAILED(kcdb_cred_get_attr(hc, khui_cw_flag_id, NULL, \r
+ NULL, NULL))) {\r
flags = 0;\r
kcdb_cred_set_attr(hc, khui_cw_flag_id, &flags, sizeof(flags));\r
}\r
kcdb_cred_release(hc);\r
}\r
}\r
+\r
+ if (fields)\r
+ PFREE(fields);\r
}\r
\r
void \r
return;\r
\r
if(o->header)\r
- free(o->header);\r
+ PFREE(o->header);\r
if ((o->flags & KHUI_CW_O_DATAALLOC) &&\r
o->data)\r
- free(o->data);\r
+ PFREE(o->data);\r
+\r
+ if ((o->flags & KHUI_CW_O_STICKY) &&\r
+ o->data)\r
+ kcdb_identity_release((khm_handle) o->data);\r
\r
LPOP(&(o->children), &c);\r
while(c) {\r
LPOP(&(o->children), &c);\r
}\r
\r
- free(o);\r
+ PFREE(o);\r
}\r
\r
khui_credwnd_outline * \r
khui_credwnd_outline * o;\r
size_t cblen;\r
\r
- o = malloc(sizeof(khui_credwnd_outline));\r
+ o = PMALLOC(sizeof(khui_credwnd_outline));\r
ZeroMemory(o, sizeof(khui_credwnd_outline));\r
\r
if(SUCCEEDED(StringCbLength(heading, KHUI_MAXCB_HEADING, &cblen))) {\r
cblen += sizeof(wchar_t);\r
- o->header = malloc(cblen);\r
+ o->header = PMALLOC(cblen);\r
StringCbCopy(o->header, cblen, heading);\r
}\r
\r
khm_size newsize;\r
\r
newsize = UBOUNDSS(row+1,KHUI_CW_ROW_INITIAL, KHUI_CW_ROW_INCREMENT);\r
- newrows = malloc(sizeof(khui_credwnd_row) * newsize);\r
+ newrows = PMALLOC(sizeof(khui_credwnd_row) * newsize);\r
memcpy(newrows, tbl->rows, sizeof(khui_credwnd_row) * tbl->n_rows);\r
- free(tbl->rows);\r
+ PFREE(tbl->rows);\r
tbl->rows = newrows;\r
tbl->n_total_rows = newsize;\r
}\r
khm_size newsize;\r
\r
newsize = UBOUNDSS(row+1,KHUI_CW_ROW_INITIAL, KHUI_CW_ROW_INCREMENT);\r
- newrows = malloc(sizeof(khui_credwnd_row) * newsize);\r
+ newrows = PMALLOC(sizeof(khui_credwnd_row) * newsize);\r
memcpy(newrows, tbl->rows, sizeof(khui_credwnd_row) * tbl->n_rows);\r
- free(tbl->rows);\r
+ PFREE(tbl->rows);\r
tbl->rows = newrows;\r
tbl->n_total_rows = newsize;\r
}\r
}\r
}\r
\r
-\r
/* determine the grouping order */\r
- grouping = malloc(sizeof(khm_int32) * tbl->n_cols);\r
+ grouping = PMALLOC(sizeof(khm_int32) * tbl->n_cols);\r
for(i=0; i < (int) tbl->n_cols; i++)\r
grouping[i] = -1;\r
n_grouping = 0;\r
/* we haven't allocated memory yet */\r
tbl->n_total_rows = KHUI_CW_ROW_INITIAL;\r
tbl->n_rows = 0;\r
- tbl->rows = malloc(sizeof(khui_credwnd_row) * tbl->n_total_rows);\r
+ tbl->rows = PMALLOC(sizeof(khui_credwnd_row) * tbl->n_total_rows);\r
} else {\r
/* kill any pending timers */\r
for(i=0; i < (int) tbl->n_rows; i++) \r
this view, we skip it */\r
if(prevcred) {\r
for(j=0; j < (int) tbl->n_cols; j++) {\r
- if(kcdb_creds_comp_attr(prevcred, thiscred, tbl->cols[j].attr_id))\r
+ if(kcdb_creds_comp_attr(prevcred, thiscred,\r
+ tbl->cols[j].attr_id))\r
break;\r
}\r
\r
for(j=0; j < n_grouping; j++) {\r
/* determine the grouping level at which thiscred\r
differs from prevcred */\r
- if(kcdb_creds_comp_attr(prevcred,thiscred,tbl->cols[grouping[j]].attr_id))\r
+ if(kcdb_creds_comp_attr(prevcred,thiscred,\r
+ tbl->cols[grouping[j]].attr_id))\r
break;\r
}\r
level = j;\r
} else if(tbl->cols[grouping[j]].attr_id == \r
KCDB_ATTR_TYPE_NAME) {\r
khm_int32 t;\r
+\r
ol->attr_id = KCDB_ATTR_TYPE;\r
if(KHM_SUCCEEDED(kcdb_cred_get_type(thiscred, &t)))\r
ol->data = (void *)(ssize_t) t;\r
if (rv != KHM_ERROR_TOO_LONG || cbbuf == 0) {\r
ol->data = NULL;\r
} else {\r
- ol->data = malloc(cbbuf);\r
+ ol->data = PMALLOC(cbbuf);\r
assert(ol->data);\r
rv = kcdb_cred_get_attr(thiscred,\r
alt_id,\r
cb_names == 0)\r
goto _cleanup_sticky;\r
\r
- idnames = malloc(cb_names);\r
- idarray = malloc(n_idents * sizeof(*idarray));\r
+ idnames = PMALLOC(cb_names);\r
+ idarray = PMALLOC(n_idents * sizeof(*idarray));\r
#ifdef DEBUG\r
assert(idnames);\r
assert(idarray);\r
qsort(idarray, n_idents, sizeof(*idarray), iwcscmp);\r
\r
for (i=0; i < (int) n_idents; i++) {\r
+ khm_handle h;\r
+\r
+ if (KHM_FAILED(kcdb_identity_create(idarray[i], \r
+ KCDB_IDENT_FLAG_CREATE, &h)))\r
+ continue;\r
+\r
for (o = tbl->outline; o; o = LNEXT(o)) {\r
if (!wcscmp(idarray[i], o->header))\r
break;\r
/* found it */\r
if (o->start != -1) /* already visible? */\r
continue;\r
+ o->flags &= KHUI_CW_O_STICKY;\r
+ o->flags |= KHUI_CW_O_VISIBLE;\r
} else {\r
/* not found. create */\r
o = cw_new_outline_node(idarray[i]);\r
o->flags = KHUI_CW_O_VISIBLE;\r
o->level = 0;\r
o->col = grouping[0];\r
+ o->data = (void *) h;\r
}\r
\r
- o->flags |= KHUI_CW_O_STICKY;\r
+ if (o->flags & KHUI_CW_O_STICKY)\r
+ kcdb_identity_release(h);\r
+ else\r
+ /* leave identity held in this case */\r
+ o->flags |= KHUI_CW_O_STICKY;\r
+\r
o->flags &= ~KHUI_CW_O_EXPAND;\r
o->start = n_rows;\r
o->length = 1;\r
\r
_cleanup_sticky:\r
if (idnames)\r
- free(idnames);\r
+ PFREE(idnames);\r
if (idarray)\r
- free(idarray);\r
+ PFREE(idarray);\r
}\r
\r
tbl->n_rows = n_rows;\r
tbl->flags &= ~KHUI_CW_TBL_COL_DIRTY;\r
_exit:\r
if(grouping)\r
- free(grouping);\r
+ PFREE(grouping);\r
}\r
\r
void \r
SafeDeleteObject(tbl->hb_hdr_bg_crit);\r
SafeDeleteObject(tbl->hb_hdr_bg_exp);\r
SafeDeleteObject(tbl->hb_hdr_bg_warn);\r
+ SafeDeleteObject(tbl->hb_hdr_bg_def);\r
\r
#undef SafeDeleteObject\r
\r
khm_size i;\r
for(i=0; i < tbl->n_cols; i++) {\r
if(tbl->cols[i].title)\r
- free(tbl->cols[i].title);\r
+ PFREE(tbl->cols[i].title);\r
Header_DeleteItem(tbl->hwnd_header, 0);\r
}\r
- free(tbl->cols);\r
+ PFREE(tbl->cols);\r
tbl->cols = NULL;\r
tbl->n_cols = 0;\r
tbl->n_total_cols = 0;\r
}\r
\r
if(tbl->rows) {\r
- free(tbl->rows);\r
+ PFREE(tbl->rows);\r
tbl->rows = NULL;\r
tbl->n_rows = 0;\r
tbl->n_total_rows = 0;\r
phi->fmt = HDF_CENTER | HDF_STRING;\r
}\r
phi->lParam = col->attr_id;\r
+#if (_WIN32_WINNT >= 0x501)\r
if(col->flags & KHUI_CW_COL_SORT_INC) {\r
phi->fmt |= HDF_SORTUP;\r
} else if(col->flags & KHUI_CW_COL_SORT_DEC) {\r
phi->fmt |= HDF_SORTDOWN;\r
}\r
+#endif\r
if(col->width < 0) {\r
/*TODO: come up with a better way to handle this case */\r
col->width = 200;\r
khui_credwnd_row * cr;\r
khui_credwnd_outline * o;\r
int selected = 0;\r
- \r
+ khm_int32 idf = 0;\r
+\r
/* each header consists of a 'expose' widget and some text */\r
/* we need to figure out the background color first */\r
\r
\r
colattr = tbl->cols[cr->col].attr_id;\r
\r
+ if (colattr == KCDB_ATTR_ID_NAME) {\r
+ khm_handle ident = o->data;\r
+\r
+ kcdb_identity_get_flags(ident, &idf);\r
+ }\r
+\r
selected = o->flags & KHUI_CW_O_SELECTED;\r
\r
{\r
HBRUSH hbr;\r
if(selected)\r
hbr = tbl->hb_hdr_bg_sel;\r
- else if((o->flags & CW_EXPSTATE_MASK) == CW_EXPSTATE_EXPIRED)\r
+ else if ((o->flags & CW_EXPSTATE_MASK) == CW_EXPSTATE_EXPIRED)\r
hbr = tbl->hb_hdr_bg_exp;\r
- else if((o->flags & CW_EXPSTATE_MASK) == CW_EXPSTATE_CRITICAL)\r
+ else if ((o->flags & CW_EXPSTATE_MASK) == CW_EXPSTATE_CRITICAL)\r
hbr = tbl->hb_hdr_bg_crit;\r
- else if((o->flags & CW_EXPSTATE_MASK) == CW_EXPSTATE_WARN)\r
+ else if ((o->flags & CW_EXPSTATE_MASK) == CW_EXPSTATE_WARN)\r
hbr = tbl->hb_hdr_bg_warn;\r
+ else if (idf & KCDB_IDENT_FLAG_DEFAULT)\r
+ hbr = tbl->hb_hdr_bg_def;\r
else\r
hbr = tbl->hb_hdr_bg;\r
\r
if (o->flags & KHUI_CW_O_STICKY) {\r
/* khui_ilist_draw_id(tbl->ilist, IDB_TK_NEW_SM, hdc, \r
r->left, r->bottom - KHUI_SMICON_CY, 0); */\r
- } else if((tbl->mouse_state & CW_MOUSE_OUTLINE) && tbl->mouse_row == row) {\r
+ } else if((tbl->mouse_state & CW_MOUSE_WOUTLINE) && \r
+ tbl->mouse_row == row) {\r
if(o->flags & KHUI_CW_O_EXPAND) {\r
- khui_ilist_draw_id(tbl->ilist, IDB_WDG_EXPAND_HI, hdc, r->left, r->bottom - KHUI_SMICON_CY, 0);\r
+ khui_ilist_draw_id(tbl->ilist, IDB_WDG_EXPAND_HI,\r
+ hdc, r->left, r->bottom - KHUI_SMICON_CY, 0);\r
} else {\r
- khui_ilist_draw_id(tbl->ilist, IDB_WDG_COLLAPSE_HI, hdc, r->left, r->bottom - KHUI_SMICON_CY, 0);\r
+ khui_ilist_draw_id(tbl->ilist, IDB_WDG_COLLAPSE_HI,\r
+ hdc, r->left, r->bottom - KHUI_SMICON_CY, 0);\r
}\r
} else {\r
if(o->flags & KHUI_CW_O_EXPAND) {\r
- khui_ilist_draw_id(tbl->ilist, IDB_WDG_EXPAND, hdc, r->left, r->bottom - KHUI_SMICON_CY, 0);\r
+ khui_ilist_draw_id(tbl->ilist, IDB_WDG_EXPAND,\r
+ hdc, r->left, r->bottom - KHUI_SMICON_CY, 0);\r
} else {\r
- khui_ilist_draw_id(tbl->ilist, IDB_WDG_COLLAPSE, hdc, r->left, r->bottom - KHUI_SMICON_CY, 0);\r
+ khui_ilist_draw_id(tbl->ilist, IDB_WDG_COLLAPSE,\r
+ hdc, r->left, r->bottom - KHUI_SMICON_CY, 0);\r
}\r
}\r
\r
- r->left += KHUI_SMICON_CX * 2;\r
+ r->left += KHUI_SMICON_CX * 3 / 2;\r
\r
/* try to draw the icon, if there is one */\r
if(colattr == KCDB_ATTR_ID_NAME) {\r
+\r
+ khui_ilist_draw_id(tbl->ilist,\r
+ (((tbl->mouse_state & CW_MOUSE_WSTICKY) &&\r
+ tbl->mouse_row == row)?\r
+ ((idf & KCDB_IDENT_FLAG_STICKY)?\r
+ IDB_WDG_STUCK_HI:\r
+ IDB_WDG_STICK_HI):\r
+ ((idf & KCDB_IDENT_FLAG_STICKY)?\r
+ IDB_WDG_STUCK:\r
+ IDB_WDG_STICK)),\r
+ hdc,\r
+ r->left, r->bottom - KHUI_SMICON_CY,\r
+ 0);\r
+\r
+ r->left += KHUI_SMICON_CX * 3 / 2;\r
+\r
khui_ilist_draw_id(tbl->ilist, \r
((o->flags & KHUI_CW_O_STICKY)?\r
IDB_ID_DIS_SM:\r
SetTextColor(hdc, tbl->cr_hdr_normal);\r
\r
TextOut(hdc, r->left, r->bottom - tbl->vpad, o->header, (int) wcslen(o->header));\r
+\r
+ if (colattr == KCDB_ATTR_ID_NAME &&\r
+ (idf & KCDB_IDENT_FLAG_DEFAULT)) {\r
+ wchar_t defstr[64];\r
+ SIZE size;\r
+\r
+ LoadString(khm_hInstance, IDS_CW_DEFAULT,\r
+ defstr, ARRAYLENGTH(defstr));\r
+\r
+ GetTextExtentPoint32(hdc, o->header, (int) wcslen(o->header),\r
+ &size);\r
+\r
+ r->left += size.cx + KHUI_SMICON_CX * 2;\r
+\r
+ TextOut(hdc, r->left, r->bottom - tbl->vpad, \r
+ defstr, (int) wcslen(defstr));\r
+ }\r
}\r
\r
LRESULT \r
khui_credwnd_tbl * tbl;\r
\r
kmq_subscribe_hwnd(KMSG_CRED, hwnd);\r
+ kmq_subscribe_hwnd(KMSG_KCDB, hwnd);\r
\r
- tbl = malloc(sizeof(*tbl));\r
+ /* freed in cw_wm_destroy */\r
+ tbl = PMALLOC(sizeof(*tbl));\r
ZeroMemory(tbl, sizeof(*tbl));\r
\r
/* some versions of VC generate portability warnings for\r
WC_HEADER,\r
(LPWSTR) NULL,\r
WS_CHILD | HDS_BUTTONS |\r
- HDS_FULLDRAG | HDS_HORZ | HDS_HOTTRACK | HDS_FLAT,\r
+ HDS_FULLDRAG | HDS_HORZ | HDS_HOTTRACK\r
+#if (_WIN32_WINNT >= 0x501)\r
+ | HDS_FLAT\r
+#endif\r
+ ,\r
0,0,0,0,hwnd, (HMENU) 0, khm_hInstance, NULL);\r
\r
cw_load_view(tbl, NULL /* default view */, hwnd);\r
khui_credwnd_tbl * tbl;\r
\r
kmq_unsubscribe_hwnd(KMSG_CRED, hwnd);\r
+ kmq_unsubscribe_hwnd(KMSG_KCDB, hwnd);\r
\r
tbl = (khui_credwnd_tbl *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);\r
\r
cw_unload_view(tbl);\r
\r
- free(tbl);\r
+ PFREE(tbl);\r
return DefWindowProc(hwnd, uMsg, wParam, lParam);\r
}\r
\r
\r
kmq_wm_begin(lParam, &m);\r
if(m->type == KMSG_CRED) {\r
- if(m->subtype == KMSG_CRED_ROOTDELTA) {\r
+ switch (m->subtype) {\r
+ case KMSG_CRED_ROOTDELTA:\r
cw_update_creds(tbl);\r
cw_update_outline(tbl);\r
cw_update_extents(tbl, TRUE);\r
InvalidateRect(hwnd, NULL, FALSE);\r
- } else if(m->subtype == KMSG_CRED_PP_BEGIN) {\r
+ break;\r
+\r
+ case KMSG_CRED_PP_BEGIN:\r
cw_pp_begin((khui_property_sheet *) m->vparam);\r
- } else if(m->subtype == KMSG_CRED_PP_PRECREATE) {\r
+ break;\r
+\r
+ case KMSG_CRED_PP_PRECREATE:\r
cw_pp_precreate((khui_property_sheet *) m->vparam);\r
- } else if(m->subtype == KMSG_CRED_PP_END) {\r
+ break;\r
+\r
+ case KMSG_CRED_PP_END:\r
cw_pp_end((khui_property_sheet *) m->vparam);\r
- } else if(m->subtype == KMSG_CRED_PP_DESTROY) {\r
+ break;\r
+\r
+ case KMSG_CRED_PP_DESTROY:\r
cw_pp_destroy((khui_property_sheet *) m->vparam);\r
+ break;\r
+ }\r
+ } else if (m->type == KMSG_KCDB) {\r
+ if (m->subtype == KMSG_KCDB_IDENT &&\r
+ m->uparam == KCDB_OP_MODIFY) {\r
+\r
+ cw_update_outline(tbl);\r
+ cw_update_extents(tbl, TRUE);\r
+ InvalidateRect(hwnd, NULL, FALSE);\r
+ }\r
+ else if (m->subtype == KMSG_KCDB_IDENT && \r
+ m->uparam == KCDB_OP_NEW_DEFAULT) {\r
+\r
+ InvalidateRect(hwnd, NULL, FALSE);\r
}\r
}\r
return kmq_wm_end(m, rv);\r
khui_credwnd_outline * o;\r
BOOL set_context = TRUE;\r
\r
+ if (row < 0 || row >= (int) tbl->n_rows) {\r
+ if (tbl->n_rows > 0)\r
+ row = 0;\r
+ else {\r
+ khui_context_reset();\r
+ return;\r
+ }\r
+ }\r
+\r
if (tbl->rows[row].flags & KHUI_CW_ROW_HEADER) {\r
\r
o = (khui_credwnd_outline *) tbl->rows[row].data;\r
}\r
}\r
\r
+static void\r
+cw_select_all(khui_credwnd_tbl * tbl)\r
+{\r
+ khm_size i;\r
+\r
+ for(i=0; i<tbl->n_rows; i++) {\r
+ tbl->rows[i].flags |= KHUI_CW_ROW_SELECTED;\r
+ if (!(tbl->rows[i].flags & KHUI_CW_ROW_HEADER))\r
+ kcdb_cred_set_flags((khm_handle) tbl->rows[i].data,\r
+ KCDB_CRED_FLAG_SELECTED,\r
+ KCDB_CRED_FLAG_SELECTED);\r
+ }\r
+\r
+ cw_select_outline_level(tbl->outline, TRUE);\r
+\r
+ cw_update_selection_state(tbl);\r
+\r
+ cw_set_row_context(tbl, tbl->cursor_row);\r
+\r
+ InvalidateRect(tbl->hwnd, NULL, FALSE);\r
+}\r
+\r
static void \r
cw_select_row(khui_credwnd_tbl * tbl, int row, WPARAM wParam)\r
{\r
tbl = (khui_credwnd_tbl *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);\r
\r
/* we are basically trying to capture events where the mouse is\r
- hovering over one of the 'hotspots'. There are two kinds of\r
- hotspots one is the little widget thinggy that you click on to\r
- expand or collapse an outline. The other is a text cell that is\r
- partially concealed.\r
- */\r
+ hovering over one of the 'hotspots'. There are two kinds of\r
+ hotspots one is the little widget thinggy that you click on to\r
+ expand or collapse an outline. The other is a text cell that\r
+ is partially concealed. */\r
\r
x = GET_X_LPARAM(lParam);\r
y = GET_Y_LPARAM(lParam);\r
col = -1;\r
nm_state = CW_MOUSE_NONE;\r
nm_row = nm_col = -1;\r
+\r
for(i=0; i < (int) tbl->n_cols; i++) {\r
if(x >= tbl->cols[i].x &&\r
- x < tbl->cols[i].x + tbl->cols[i].width) \r
- {\r
+ x < tbl->cols[i].x + tbl->cols[i].width) {\r
col = i;\r
break;\r
}\r
/* are we on a widget then? */\r
x -= tbl->cols[tbl->rows[row].col].x;\r
if(x >= 0 && x < KHUI_SMICON_CX) /* hit */ {\r
- nm_state |= CW_MOUSE_OUTLINE;\r
+ nm_state |= CW_MOUSE_WOUTLINE | CW_MOUSE_WIDGET;\r
+ } else if (tbl->cols[tbl->rows[row].col].attr_id == \r
+ KCDB_ATTR_ID_NAME &&\r
+ col == tbl->rows[row].col &&\r
+ x >= KHUI_SMICON_CX * 3 / 2 &&\r
+ x < KHUI_SMICON_CX * 5 / 2){\r
+ nm_state |= CW_MOUSE_WSTICKY | CW_MOUSE_WIDGET;\r
}\r
}\r
}\r
\r
- if((tbl->mouse_state & CW_MOUSE_LDOWN) && \r
- (tbl->mouse_state & CW_MOUSE_OUTLINE) && \r
- (nm_row != tbl->mouse_row))\r
- {\r
- nm_state &= ~CW_MOUSE_OUTLINE;\r
+ /* did the user drag the cursor off the current row? */\r
+ if((tbl->mouse_state & CW_MOUSE_LDOWN) &&\r
+ (nm_row != tbl->mouse_row)) {\r
+ nm_state &= ~(CW_MOUSE_WIDGET | CW_MOUSE_WOUTLINE | CW_MOUSE_WSTICKY);\r
}\r
\r
if(!(nm_state & CW_MOUSE_LDOWN) && \r
- (tbl->mouse_state & CW_MOUSE_LDOWN)) {\r
+ (tbl->mouse_state & CW_MOUSE_LDOWN) &&\r
+ tbl->mouse_row == nm_row) {\r
\r
- if((nm_state & CW_MOUSE_OUTLINE) &&\r
- (tbl->mouse_state & CW_MOUSE_OUTLINE)) {\r
- /* click on a widget */\r
+ if((nm_state & CW_MOUSE_WOUTLINE) &&\r
+ (tbl->mouse_state & CW_MOUSE_WOUTLINE)) {\r
+ /* click on an outline widget */\r
khui_credwnd_outline * o;\r
\r
o = (khui_credwnd_outline *) tbl->rows[nm_row].data;\r
- tbl->mouse_state = CW_MOUSE_OUTLINE;\r
+ tbl->mouse_state = CW_MOUSE_WIDGET | CW_MOUSE_WOUTLINE;\r
\r
cw_toggle_outline_state(tbl, o);\r
\r
return 0;\r
- } else if(nm_row == tbl->mouse_row) {\r
+ } else if ((nm_state & CW_MOUSE_WSTICKY) &&\r
+ (tbl->mouse_state & CW_MOUSE_WSTICKY)) {\r
+\r
+ khui_credwnd_outline * o;\r
+ khm_handle ident;\r
+ khm_int32 idf = 0;\r
+\r
+ o = tbl->rows[nm_row].data;\r
+ ident = o->data;\r
+\r
+ kcdb_identity_get_flags(ident, &idf);\r
+ idf &= KCDB_IDENT_FLAG_STICKY;\r
+ kcdb_identity_set_flags(ident, (idf ^ KCDB_IDENT_FLAG_STICKY),\r
+ KCDB_IDENT_FLAG_STICKY);\r
+\r
+ tbl->mouse_state = CW_MOUSE_WIDGET | CW_MOUSE_WSTICKY;\r
+\r
+ return 0;\r
+ } else {\r
/* click on a row */\r
cw_select_row(tbl, nm_row, wParam);\r
}\r
-\r
}\r
\r
- /*TODO: if a user clicks somewhere and drags on to an exand widget, it activates the widet. should not */\r
-\r
/* ok, now if we are changing state, we need to invalidate a few\r
regions */\r
- if((tbl->mouse_state ^ nm_state) & CW_MOUSE_OUTLINE) {\r
- if(tbl->mouse_state & CW_MOUSE_OUTLINE) {\r
+ if (((tbl->mouse_state ^ nm_state) & (CW_MOUSE_WIDGET |\r
+ CW_MOUSE_WOUTLINE |\r
+ CW_MOUSE_WSTICKY)) ||\r
+ tbl->mouse_row != nm_row) {\r
+\r
+ if(tbl->mouse_state & CW_MOUSE_WOUTLINE) {\r
r.left = tbl->cols[tbl->mouse_col].x - tbl->scr_left;\r
- r.top = tbl->mouse_row * tbl->cell_height + tbl->header_height - tbl->scr_top;\r
+ r.top = tbl->mouse_row * tbl->cell_height + \r
+ tbl->header_height - tbl->scr_top;\r
+ r.right = r.left + KHUI_SMICON_CX;\r
+ r.bottom = r.top + tbl->cell_height;\r
+ InvalidateRect(tbl->hwnd, &r, TRUE);\r
+ }\r
+ if(tbl->mouse_state & CW_MOUSE_WSTICKY) {\r
+ r.left = KHUI_SMICON_CX * 3 / 2 + \r
+ tbl->cols[tbl->mouse_col].x - tbl->scr_left;\r
+ r.top = tbl->mouse_row * tbl->cell_height + \r
+ tbl->header_height - tbl->scr_top;\r
r.right = r.left + KHUI_SMICON_CX;\r
r.bottom = r.top + tbl->cell_height;\r
InvalidateRect(tbl->hwnd, &r, TRUE);\r
}\r
\r
- tbl->mouse_col = nm_col;\r
- tbl->mouse_row = nm_row;\r
+ if ((tbl->mouse_state & nm_state) & CW_MOUSE_LDOWN) {\r
+ if (tbl->mouse_row == nm_row)\r
+ tbl->mouse_col = nm_col;\r
+ } else {\r
+ tbl->mouse_col = nm_col;\r
+ tbl->mouse_row = nm_row;\r
+ }\r
tbl->mouse_state = nm_state;\r
\r
/* same code block as above */\r
- if(tbl->mouse_state & CW_MOUSE_OUTLINE) {\r
+ if(tbl->mouse_state & CW_MOUSE_WOUTLINE) {\r
r.left = tbl->cols[tbl->mouse_col].x - tbl->scr_left;\r
- r.top = tbl->mouse_row * tbl->cell_height + tbl->header_height - tbl->scr_top;\r
+ r.top = tbl->mouse_row * tbl->cell_height + \r
+ tbl->header_height - tbl->scr_top;\r
+ r.right = r.left + KHUI_SMICON_CX;\r
+ r.bottom = r.top + tbl->cell_height;\r
+ InvalidateRect(tbl->hwnd, &r, TRUE);\r
+ }\r
+ if(tbl->mouse_state & CW_MOUSE_WSTICKY) {\r
+ r.left = KHUI_SMICON_CX * 3 / 2 + \r
+ tbl->cols[tbl->mouse_col].x - tbl->scr_left;\r
+ r.top = tbl->mouse_row * tbl->cell_height + \r
+ tbl->header_height - tbl->scr_top;\r
r.right = r.left + KHUI_SMICON_CX;\r
r.bottom = r.top + tbl->cell_height;\r
InvalidateRect(tbl->hwnd, &r, TRUE);\r
}\r
} else if(tbl->mouse_state != nm_state) {\r
- tbl->mouse_col = nm_col;\r
- tbl->mouse_row = nm_row;\r
- tbl->mouse_state = nm_state;\r
+\r
+ if ((tbl->mouse_state & nm_state) & CW_MOUSE_LDOWN) {\r
+ if (tbl->mouse_row == nm_row) {\r
+ tbl->mouse_col = nm_col;\r
+ tbl->mouse_state = nm_state;\r
+ }\r
+ } else {\r
+ tbl->mouse_col = nm_col;\r
+ tbl->mouse_row = nm_row;\r
+ tbl->mouse_state = nm_state;\r
+ }\r
}\r
\r
/* if it was a double click, also show the property\r
cw_pp_ident_proc(HWND hwnd,\r
UINT uMsg,\r
WPARAM wParam,\r
- LPARAM lParam\r
- )\r
+ LPARAM lParam)\r
{\r
+ khui_property_sheet * s;\r
+\r
switch(uMsg) {\r
case WM_INITDIALOG:\r
{\r
- khui_property_sheet * s;\r
PROPSHEETPAGE * p;\r
khm_handle ident;\r
wchar_t idname[KCDB_IDENT_MAXCCH_NAME];\r
\r
kcdb_identity_get_flags(ident, &i);\r
\r
- SendDlgItemMessage(hwnd, \r
- IDC_PP_IDDEF, \r
- BM_SETCHECK, \r
- (WPARAM) ((i & KCDB_IDENT_FLAG_DEFAULT)?BST_CHECKED:BST_UNCHECKED),\r
- 0);\r
+ CheckDlgButton(hwnd, IDC_PP_IDDEF,\r
+ ((i & KCDB_IDENT_FLAG_DEFAULT)?BST_CHECKED:\r
+ BST_UNCHECKED));\r
+\r
+ /* if it's default, you can't change it further */\r
+ if (i & KCDB_IDENT_FLAG_DEFAULT) {\r
+ EnableWindow(GetDlgItem(hwnd, IDC_PP_IDDEF), FALSE);\r
+ }\r
+\r
+ CheckDlgButton(hwnd, IDC_PP_IDSEARCH,\r
+ ((i & KCDB_IDENT_FLAG_SEARCHABLE)?BST_CHECKED:\r
+ BST_UNCHECKED));\r
\r
- SendDlgItemMessage(\r
- hwnd,\r
- IDC_PP_IDSEARCH,\r
- BM_SETCHECK,\r
- (WPARAM) ((i & KCDB_IDENT_FLAG_SEARCHABLE)?BST_CHECKED:BST_UNCHECKED),\r
- 0);\r
+ CheckDlgButton(hwnd, IDC_PP_STICKY,\r
+ ((i & KCDB_IDENT_FLAG_STICKY)?BST_CHECKED:\r
+ BST_UNCHECKED));\r
\r
khui_property_wnd_set_record(GetDlgItem(hwnd, IDC_PP_PROPLIST),\r
ident);\r
}\r
return TRUE;\r
+\r
+ case WM_COMMAND:\r
+ s = (khui_property_sheet *) (LONG_PTR) \r
+ GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+ switch(wParam) {\r
+ case MAKEWPARAM(IDC_PP_IDDEF, BN_CLICKED):\r
+ /* fallthrough */\r
+ case MAKEWPARAM(IDC_PP_STICKY, BN_CLICKED):\r
+\r
+ if (s->status != KHUI_PS_STATUS_NONE)\r
+ PropSheet_Changed(s->hwnd, hwnd);\r
+ return TRUE;\r
+\r
+ case MAKEWPARAM(IDC_PP_CONFIG, BN_CLICKED):\r
+ {\r
+ khui_config_node cfg_ids = NULL;\r
+ khm_int32 rv;\r
+\r
+ khm_refresh_config();\r
+\r
+ rv = khui_cfg_open(NULL,\r
+ L"KhmIdentities",\r
+ &cfg_ids);\r
+\r
+ if (KHM_FAILED(rv))\r
+ return TRUE;\r
+\r
+ khm_show_config_pane(cfg_ids);\r
+\r
+ if (cfg_ids)\r
+ khui_cfg_release(cfg_ids);\r
+ }\r
+ return TRUE;\r
+ }\r
+ return FALSE;\r
+\r
+ case WM_NOTIFY:\r
+ {\r
+ LPPSHNOTIFY lpp;\r
+ khm_int32 flags;\r
+\r
+ lpp = (LPPSHNOTIFY) lParam;\r
+ s = (khui_property_sheet *) (LONG_PTR) \r
+ GetWindowLongPtr(hwnd, DWLP_USER);\r
+\r
+ switch(lpp->hdr.code) {\r
+ case PSN_APPLY:\r
+ flags = 0;\r
+ if (IsDlgButtonChecked(hwnd, IDC_PP_STICKY) == BST_CHECKED)\r
+ flags |= KCDB_IDENT_FLAG_STICKY;\r
+ if (IsDlgButtonChecked(hwnd, IDC_PP_IDDEF) == BST_CHECKED)\r
+ flags |= KCDB_IDENT_FLAG_DEFAULT;\r
+\r
+ kcdb_identity_set_flags(s->identity, flags,\r
+ KCDB_IDENT_FLAG_STICKY |\r
+ KCDB_IDENT_FLAG_DEFAULT);\r
+ return TRUE;\r
+\r
+ case PSN_RESET:\r
+ kcdb_identity_get_flags(s->identity, &flags);\r
+\r
+ CheckDlgButton(hwnd, \r
+ IDC_PP_IDDEF, \r
+ ((flags & KCDB_IDENT_FLAG_DEFAULT)?BST_CHECKED:\r
+ BST_UNCHECKED));\r
+\r
+ /* if it's default, you can't change it further */\r
+ if (flags & KCDB_IDENT_FLAG_DEFAULT) {\r
+ EnableWindow(GetDlgItem(hwnd, IDC_PP_IDDEF), FALSE);\r
+ }\r
+\r
+ CheckDlgButton(hwnd, IDC_PP_IDSEARCH,\r
+ ((flags & KCDB_IDENT_FLAG_SEARCHABLE)?BST_CHECKED:BST_UNCHECKED));\r
+\r
+ CheckDlgButton(hwnd, IDC_PP_STICKY,\r
+ ((flags & KCDB_IDENT_FLAG_STICKY)?BST_CHECKED:BST_UNCHECKED));\r
+ return TRUE;\r
+ }\r
+ }\r
+ break;\r
}\r
return FALSE;\r
}\r
PROPSHEETPAGE *p;\r
\r
if(s->identity) {\r
- p = malloc(sizeof(*p));\r
+ p = PMALLOC(sizeof(*p));\r
ZeroMemory(p, sizeof(*p));\r
\r
p->dwSize = sizeof(*p);\r
p->pszTemplate = MAKEINTRESOURCE(IDD_PP_IDENT);\r
p->pfnDlgProc = cw_pp_ident_proc;\r
p->lParam = (LPARAM) s;\r
- khui_ps_add_page(s, KHUI_PPCT_IDENTITY, 0, p, NULL);\r
+\r
+ khui_ps_add_page(s, KHUI_PPCT_IDENTITY, 129, p, NULL);\r
}\r
\r
if(s->cred) {\r
- p = malloc(sizeof(*p));\r
+ p = PMALLOC(sizeof(*p));\r
ZeroMemory(p, sizeof(*p));\r
\r
p->dwSize = sizeof(*p);\r
p->pszTemplate = MAKEINTRESOURCE(IDD_PP_CRED);\r
p->pfnDlgProc = cw_pp_cred_proc;\r
p->lParam = (LPARAM) s;\r
- khui_ps_add_page(s, KHUI_PPCT_CREDENTIAL, 0, p, NULL);\r
+\r
+ khui_ps_add_page(s, KHUI_PPCT_CREDENTIAL, 128, p, NULL);\r
}\r
}\r
\r
\r
khui_ps_find_page(s, KHUI_PPCT_IDENTITY, &p);\r
if(p) {\r
- free(p->p_page);\r
+ PFREE(p->p_page);\r
p->p_page = NULL;\r
}\r
\r
\r
khui_ps_find_page(s, KHUI_PPCT_CREDENTIAL, &p);\r
if(p) {\r
- free(p->p_page);\r
+ PFREE(p->p_page);\r
p->p_page = NULL;\r
}\r
}\r
{\r
if(ps->ctx.scope == KHUI_SCOPE_CRED) {\r
if(ps->header.pszCaption)\r
- free((LPWSTR) ps->header.pszCaption);\r
+ PFREE((LPWSTR) ps->header.pszCaption);\r
}\r
\r
+ khui_context_release(&ps->ctx);\r
+\r
khui_ps_destroy_sheet(ps);\r
\r
/* this is pretty weird because ps gets freed when\r
- khui_ps_destroy_sheet() is called. However, since destroying ps\r
- involves sending a WM_DESTROY message to the property sheet, we\r
- still need to keep it on the property sheet chain (or else the\r
- messages will not be delivered). This is only safe because we are\r
- not relinquishing the thread in-between destroying ps and removing\r
- it from the chain. */\r
-\r
- /*TODO: fix this */\r
+ khui_ps_destroy_sheet() is called. However, since destroying\r
+ ps involves sending a WM_DESTROY message to the property sheet,\r
+ we still need to keep it on the property sheet chain (or else\r
+ the messages will not be delivered). This is only safe because\r
+ we are not relinquishing the thread in-between destroying ps\r
+ and removing it from the chain. */\r
+\r
+ /* TODO: fix this */\r
khm_del_property_sheet(ps);\r
}\r
\r
-LRESULT \r
+LRESULT\r
cw_properties(HWND hwnd)\r
{\r
/* show a property sheet of some sort */\r
tbl = (khui_credwnd_tbl *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);\r
\r
if(ctx.scope == KHUI_SCOPE_NONE) {\r
-\r
+ khui_context_release(&ctx);\r
return FALSE;\r
\r
/* While it seems like a good idea, doing this is not */\r
\r
/* if still no context, then we can't show a property sheet */\r
if(ctx.scope == KHUI_SCOPE_NONE) {\r
+ khui_context_release(&ctx);\r
return FALSE;\r
}\r
\r
kcdb_identity_get_name(ident, NULL, &t);\r
\r
if(t > 0) {\r
- ps->header.pszCaption = malloc(t);\r
- kcdb_identity_get_name(ident, (wchar_t *) ps->header.pszCaption, &t);\r
+ ps->header.pszCaption = PMALLOC(t);\r
+ kcdb_identity_get_name(ident,\r
+ (wchar_t *) ps->header.pszCaption, &t);\r
} else {\r
ps->header.pszCaption = NULL;\r
}\r
something else */\r
kcdb_identity_get_name(ctx.identity, NULL, &t);\r
if (t > 0) {\r
- ps->header.pszCaption = malloc(t);\r
+ ps->header.pszCaption = PMALLOC(t);\r
kcdb_identity_get_name(ctx.identity, (wchar_t *) ps->header.pszCaption, &t);\r
} else {\r
ps->header.pszCaption = NULL;\r
} else {\r
kcdb_credtype_describe(cred_type, NULL, &t, KCDB_TS_LONG);\r
if(t > 0) {\r
- ps->header.pszCaption = malloc(t);\r
+ ps->header.pszCaption = PMALLOC(t);\r
kcdb_credtype_describe(cred_type, (wchar_t *) ps->header.pszCaption, &t, KCDB_TS_LONG);\r
} else {\r
ps->header.pszCaption = NULL;\r
ps->ctx = ctx;\r
\r
kcdb_cred_get_name(cred, NULL, &t);\r
- ps->header.pszCaption = malloc(t);\r
+ ps->header.pszCaption = PMALLOC(t);\r
kcdb_cred_get_name(cred, (LPWSTR) ps->header.pszCaption, &t);\r
\r
kcdb_cred_get_identity(cred, &ps->identity);\r
\r
kmq_post_message(KMSG_CRED, KMSG_CRED_PP_BEGIN, 0, (void *) ps);\r
} else {\r
+ khui_context_release(&ctx);\r
khui_ps_destroy_sheet(ps);\r
}\r
\r
- khui_context_reset();\r
+ /* by the way, if we are actually opening a property sheet, we\r
+ leave ctx held (which is now copied to ps->ctx). it will be\r
+ released when the property sheet is destroyed */\r
\r
return TRUE;\r
}\r
}\r
break;\r
\r
+ case KHUI_PACTION_SELALL:\r
+ {\r
+ cw_select_all(tbl);\r
+ }\r
+ break;\r
+\r
case KHUI_PACTION_LEFT:\r
{ /* collapse and up*/\r
khui_credwnd_outline * o;\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
HBRUSH hb_hdr_bg_warn; /* header background color (warn) */\r
HBRUSH hb_hdr_bg_crit; /* header background color (critical) */\r
HBRUSH hb_hdr_bg_sel; /* header background color (selected) */\r
+ HBRUSH hb_hdr_bg_def; /* header background color (default) */\r
HCURSOR hc_hand; /* the HAND cursor */\r
khui_ilist * ilist; /* image list */\r
\r
#define KHUI_CW_TBL_ACTIVE 0x00000100\r
\r
/* mouse_state constants */\r
-#define CW_MOUSE_NONE 0 /* nothing interesting */\r
-#define CW_MOUSE_OUTLINE 1 /* mouse is highlighting an outline widget */\r
-#define CW_MOUSE_LDOWN 2 /* left button is down */\r
-#define CW_MOUSE_ROW 4 /* mouse is acive over a valid row */\r
+#define CW_MOUSE_NONE 0x00000000 /* nothing interesting */\r
+#define CW_MOUSE_WIDGET 0x00000001 /* mouse is highlighting a\r
+ widget */\r
+#define CW_MOUSE_LDOWN 0x00000002 /* left button is down */\r
+#define CW_MOUSE_ROW 0x00000004 /* mouse is acive over a valid\r
+ row */\r
+#define CW_MOUSE_WOUTLINE 0x00000008 /* mouse is highlighting an\r
+ outline widget */\r
+#define CW_MOUSE_WSTICKY 0x00000010 /* mouse is highlighting a\r
+ sticky widget */\r
\r
void khm_unregister_credwnd_class(void);\r
\r
/*\r
-* Copyright (c) 2004 Massachusetts Institute of Technology\r
+* Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
khui_htwnd_link * l;\r
\r
if(!d->links) {\r
- d->links = malloc(sizeof(khui_htwnd_link *) * HTW_LINK_ALLOC);\r
+ d->links = PMALLOC(sizeof(khui_htwnd_link *) * HTW_LINK_ALLOC);\r
ZeroMemory(d->links, sizeof(khui_htwnd_link *) * HTW_LINK_ALLOC);\r
d->max_links = HTW_LINK_ALLOC;\r
d->n_links = 0;\r
\r
n_new = UBOUNDSS(d->n_links + 1, HTW_LINK_ALLOC, HTW_LINK_ALLOC);\r
\r
- ll = malloc(sizeof(khui_htwnd_link *) * n_new);\r
+ ll = PMALLOC(sizeof(khui_htwnd_link *) * n_new);\r
ZeroMemory(ll, sizeof(khui_htwnd_link *) * n_new);\r
memcpy(ll, d->links, sizeof(khui_htwnd_link *) * d->max_links);\r
- free(d->links);\r
+ PFREE(d->links);\r
d->links = ll;\r
d->max_links = n_new;\r
}\r
\r
l = d->links[d->n_links];\r
if(!l) {\r
- l = malloc(sizeof(khui_htwnd_link));\r
+ l = PMALLOC(sizeof(khui_htwnd_link));\r
d->links[d->n_links] = l;\r
}\r
\r
\r
cs = (CREATESTRUCT *) lParam;\r
\r
- d = malloc(sizeof(*d));\r
+ d = PMALLOC(sizeof(*d));\r
ZeroMemory(d, sizeof(*d));\r
\r
if(cs->dwExStyle & WS_EX_TRANSPARENT) {\r
\r
if(SUCCEEDED(StringCbLength(cs->lpszName, KHUI_HTWND_MAXCB_TEXT, &cbsize))) {\r
cbsize += sizeof(wchar_t);\r
- d->text = malloc(cbsize);\r
+ d->text = PMALLOC(cbsize);\r
StringCbCopy(d->text, cbsize, cs->lpszName);\r
}\r
\r
newtext = (wchar_t *) lParam;\r
\r
if(d->text) {\r
- free(d->text);\r
+ PFREE(d->text);\r
d->text = NULL;\r
}\r
\r
if(SUCCEEDED(StringCbLength(newtext, KHUI_HTWND_MAXCB_TEXT, &cbsize))) {\r
cbsize += sizeof(wchar_t);\r
- d->text = malloc(cbsize);\r
+ d->text = PMALLOC(cbsize);\r
StringCbCopy(d->text, cbsize, newtext);\r
rv = TRUE;\r
} else\r
\r
d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);\r
if(d->text)\r
- free(d->text);\r
+ PFREE(d->text);\r
d->text = 0;\r
\r
if(d->links) {\r
for(i=0;i<d->max_links;i++) {\r
if(d->links[i])\r
- free(d->links[i]);\r
+ PFREE(d->links[i]);\r
}\r
- free(d->links);\r
+ PFREE(d->links);\r
}\r
\r
clear_styles(d);\r
\r
- free(d);\r
+ PFREE(d);\r
}\r
break;\r
\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
#include<windowsx.h>\r
#include<strsafe.h>\r
#include<commctrl.h>\r
+#include<htmlhelp.h>\r
\r
#define KHERR_HMODULE khm_hInstance\r
#define KHERR_FACILITY khm_facility\r
#include<kmm.h>\r
#include<khhelp.h>\r
#include<khuidefs.h>\r
+#include<utils.h>\r
\r
#include<resource.h>\r
#include<credfuncs.h>\r
#include<reqdaemon.h>\r
#include<notifier.h>\r
#include<timer.h>\r
+#include<addrchange.h>\r
\r
#endif\r
// Generated from the TEXTINCLUDE 2 resource.\r
//\r
#include "afxres.h"\r
-#include <khimaira_version.h>\r
+\r
/////////////////////////////////////////////////////////////////////////////\r
#undef APSTUDIO_READONLY_SYMBOLS\r
\r
2 TEXTINCLUDE \r
BEGIN\r
"#include ""afxres.h""\r\n"\r
- "#include <khimaira_version.h>\0"\r
END\r
\r
3 TEXTINCLUDE \r
// Icon with lowest ID value placed first to ensure application icon\r
// remains consistent on all systems.\r
IDI_MAIN_APP ICON "..\\..\\images\\main_app.ico"\r
-IDI_WGT_COLLAPSE ICON "..\\..\\images\\wgt_arrow_collapse.ico"\r
-IDI_WGT_EXPAND ICON "..\\..\\images\\wgt_arrow_expand.ico"\r
IDI_ENABLED ICON "..\\..\\images\\enabled.ico"\r
IDI_DISABLED ICON "..\\..\\images\\disabled.ico"\r
IDI_NOTIFY_NONE ICON "..\\..\\images\\app_notify_none.ico"\r
IDI_CFG_DELETED ICON "..\\..\\images\\cfg_deleted.ico"\r
IDI_ID ICON "..\\..\\images\\id.ico"\r
\r
-/////////////////////////////////////////////////////////////////////////////\r
-//\r
-// Version\r
-//\r
-\r
-VS_VERSION_INFO VERSIONINFO\r
- FILEVERSION 0,1,1,0\r
- PRODUCTVERSION 0,1,1,0\r
- FILEFLAGSMASK 0x17L\r
-#ifdef _DEBUG\r
- FILEFLAGS 0x1L\r
-#else\r
- FILEFLAGS 0x0L\r
-#endif\r
- FILEOS 0x4L\r
- FILETYPE 0x0L\r
- FILESUBTYPE 0x0L\r
-BEGIN\r
- BLOCK "StringFileInfo"\r
- BEGIN\r
- BLOCK "040904b0"\r
- BEGIN\r
- VALUE "CompanyName", "Massachusetts Institute of Technology"\r
- VALUE "FileDescription", "Network Identity Manager"\r
- VALUE "FileVersion", "0.1.1.0"\r
- VALUE "InternalName", "NetIDMgr"\r
- VALUE "LegalCopyright", "Copyright (C) 2005 Massachusetts Institute of Technology"\r
- VALUE "OriginalFilename", "netidmgr.exe"\r
- VALUE "ProductName", "NetIDMgr"\r
- VALUE "ProductVersion", "0.1.1.0"\r
- END\r
- END\r
- BLOCK "VarFileInfo"\r
- BEGIN\r
- VALUE "Translation", 0x409, 1200\r
- END\r
-END\r
-\r
-\r
/////////////////////////////////////////////////////////////////////////////\r
//\r
// Bitmap\r
IDB_CHPW_DIS BITMAP "..\\..\\images\\chpw-dis.bmp"\r
IDB_CHPW_DIS_SM BITMAP "..\\..\\images\\chpw-dis-sm.bmp"\r
IDB_TB_SPACE BITMAP "..\\..\\images\\tb-space.bmp"\r
+IDB_WDG_STUCK_HI BITMAP "..\\..\\images\\wdg_stuck_hi.bmp"\r
+IDB_WDG_STICK BITMAP "..\\..\\images\\wdg_stick.bmp"\r
+IDB_WDG_STICK_HI BITMAP "..\\..\\images\\wdg_stick_hi.bmp"\r
+IDB_WDG_STUCK BITMAP "..\\..\\images\\wdg_stuck.bmp"\r
\r
/////////////////////////////////////////////////////////////////////////////\r
//\r
LTEXT "IdentityName",IDC_PP_IDNAME,34,7,194,12,NOT WS_GROUP,\r
WS_EX_CLIENTEDGE\r
CONTROL "Default identity",IDC_PP_IDDEF,"Button",BS_AUTOCHECKBOX | \r
- WS_TABSTOP,34,25,71,12\r
+ WS_TABSTOP,34,22,71,12\r
CONTROL "Searchable",IDC_PP_IDSEARCH,"Button",BS_AUTOCHECKBOX | \r
- WS_TABSTOP,34,43,74,12\r
+ WS_DISABLED | WS_TABSTOP,117,36,74,12\r
CONTROL "Custom1",IDC_PP_PROPLIST,"NetIDMgrPropertyWnd",\r
- WS_TABSTOP,7,61,221,88\r
+ WS_TABSTOP,7,51,221,80\r
CONTROL "Always visible (sticky)",IDC_PP_STICKY,"Button",\r
- BS_AUTOCHECKBOX | WS_TABSTOP,117,25,85,10\r
+ BS_AUTOCHECKBOX | WS_TABSTOP,117,22,85,12\r
+ PUSHBUTTON "Identity configuration ...",IDC_PP_CONFIG,117,135,111,\r
+ 14\r
END\r
\r
IDD_PP_CRED DIALOGEX 0, 0, 236, 158\r
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | \r
WS_SYSMENU\r
EXSTYLE WS_EX_CONTEXTHELP\r
-CAPTION "Khimaira Configuration"\r
+CAPTION "NetIDMgr Configuration"\r
FONT 8, "MS Shell Dlg", 400, 0, 0x1\r
BEGIN\r
LTEXT "Title",IDC_CFG_TITLE,0,0,357,20,SS_CENTERIMAGE\r
IDC_CFG_KEEPRUNNING,"Button",BS_AUTOCHECKBOX | \r
WS_TABSTOP,16,78,158,10\r
CONTROL "Detect network connectivity",IDC_CFG_NETDETECT,"Button",\r
- BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,16,96,106,10\r
+ BS_AUTOCHECKBOX | WS_TABSTOP,16,96,106,10\r
CONTROL "A&utomatically import credentials from Windows",\r
IDC_CFG_AUTOIMPORT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,\r
16,113,165,10\r
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU\r
FONT 8, "MS Shell Dlg", 400, 0, 0x1\r
BEGIN\r
- CONTROL "",IDC_CFG_PLUGINS,"SysListView32",LVS_ALIGNLEFT | \r
- WS_BORDER | WS_TABSTOP,7,7,75,168\r
+ CONTROL "",IDC_CFG_PLUGINS,"SysListView32",LVS_REPORT | \r
+ LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,7,75,168\r
GROUPBOX "Plugin",IDC_CFG_PLUGINGRP,86,7,162,103\r
LTEXT "Description",IDC_CFG_LBL_DESC,90,20,36,8\r
EDITTEXT IDC_CFG_DESC,134,17,109,14,ES_AUTOHSCROLL | ES_READONLY\r
EXSTYLE WS_EX_CONTROLPARENT\r
FONT 8, "MS Shell Dlg", 400, 0, 0x1\r
BEGIN\r
- CONTROL "",IDC_CFG_IDENTS,"SysListView32",LVS_SHAREIMAGELISTS | \r
- LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,7,7,221,72\r
+ CONTROL "",IDC_CFG_IDENTS,"SysListView32",LVS_REPORT | \r
+ LVS_SHAREIMAGELISTS | LVS_ALIGNLEFT | WS_BORDER | \r
+ WS_TABSTOP,7,7,221,72\r
GROUPBOX "Selected identity",IDC_CFG_IDENTITY,7,81,221,63\r
CONTROL "Monitor credential expiration",IDC_CFG_MONITOR,"Button",\r
- BS_3STATE | WS_TABSTOP,13,92,107,10\r
+ BS_3STATE | WS_DISABLED | WS_TABSTOP,13,92,107,10\r
CONTROL "Automatically renew",IDC_CFG_RENEW,"Button",BS_3STATE | \r
- WS_TABSTOP,13,106,81,10\r
+ WS_DISABLED | WS_TABSTOP,13,106,81,10\r
CONTROL "Always show in the credentials list (Sticky)",\r
- IDC_CFG_STICKY,"Button",BS_3STATE | WS_TABSTOP,13,120,\r
- 151,10\r
+ IDC_CFG_STICKY,"Button",BS_3STATE | WS_DISABLED | \r
+ WS_TABSTOP,13,120,151,10\r
PUSHBUTTON "&Remove",IDC_CFG_REMOVE,174,126,50,14,WS_DISABLED\r
END\r
\r
IDC_COPYRIGHT,41,23,220,18,NOT WS_GROUP\r
LTEXT "BuildInfo",IDC_BUILDINFO,41,41,220,17,NOT WS_GROUP\r
ICON IDI_MAIN_APP,IDC_STATIC,6,7,21,20\r
- CONTROL "",IDC_MODULES,"SysListView32",LVS_ALIGNLEFT | WS_BORDER | \r
- WS_TABSTOP,41,72,220,91\r
+ CONTROL "",IDC_MODULES,"SysListView32",LVS_REPORT | \r
+ LVS_ALIGNLEFT | WS_BORDER | WS_TABSTOP,41,72,220,91\r
LTEXT "Loaded modules",IDC_STATIC,41,60,52,8\r
END\r
\r
IDS_CTX_PROC_PASSWORD "Changing password for %1!s!"\r
IDS_NC_PWD_FAILED_TITLE "Failed to change password"\r
IDS_CMDLINE_HELP "Command line options for NetIDMgr are :\n\n-a or --autoinit: Auto initialize credentials\n-i or --kinit: Obtain new credentials\n-d or --destroy: Destroy default identity\n-r or --renew: Renew all credentials"\r
+ IDS_PACTION_NEXT "Next alert..."\r
+ IDS_ERR_TITLE_NO_IDENTPRO "Cannot proceed without identity provider"\r
+END\r
+\r
+STRINGTABLE \r
+BEGIN\r
+ IDS_ERR_MSG_NO_IDENTPRO "There is no identity provider currently loaded. The identity provider is the component of Network Identity Manager that verifies and performs operations on actual identities. Without this provider, many critical operations cannot be performed."\r
+ IDS_ERR_SUGG_NO_IDENTPRO \r
+ "This is quite possibly caused by the identity provider module failing to load properly."\r
+ IDS_NC_REN_FAILED_TITLE "Failed to renew credentials"\r
+ IDS_CW_DEFAULT "(Default)"\r
END\r
\r
#endif // English (U.S.) resources\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
khui_init_rescache();\r
khui_init_menu();\r
khui_init_toolbar();\r
- khui_init_notifier();\r
+ khm_init_notifier();\r
khm_init_config();\r
}\r
\r
void khm_exit_gui(void) {\r
khm_exit_config();\r
- khui_exit_notifier();\r
+ khm_exit_notifier();\r
khui_exit_toolbar();\r
khui_exit_menu();\r
khui_exit_rescache();\r
\r
for (i=1; i<wargc; i++) {\r
if (!wcscmp(wargs[i], L"-i") ||\r
- !wcscmp(wargs[i], L"--kinit")) {\r
+ !wcscmp(wargs[i], L"--kinit") ||\r
+ !wcscmp(wargs[i], L"-kinit")) {\r
khm_startup.init = TRUE;\r
khm_startup.exit = TRUE;\r
khm_startup.no_main_window = TRUE;\r
}\r
else if (!wcscmp(wargs[i], L"-m") ||\r
- !wcscmp(wargs[i], L"--import")) {\r
+ !wcscmp(wargs[i], L"--import") ||\r
+ !wcscmp(wargs[i], L"-import")) {\r
khm_startup.import = TRUE;\r
khm_startup.exit = TRUE;\r
khm_startup.no_main_window = TRUE;\r
}\r
else if (!wcscmp(wargs[i], L"-r") ||\r
- !wcscmp(wargs[i], L"--renew")) {\r
+ !wcscmp(wargs[i], L"--renew") ||\r
+ !wcscmp(wargs[i], L"-renew")) {\r
khm_startup.renew = TRUE;\r
khm_startup.exit = TRUE;\r
khm_startup.no_main_window = TRUE;\r
}\r
else if (!wcscmp(wargs[i], L"-d") ||\r
- !wcscmp(wargs[i], L"--destroy")) {\r
+ !wcscmp(wargs[i], L"--destroy") ||\r
+ !wcscmp(wargs[i], L"-destroy")) {\r
khm_startup.destroy = TRUE;\r
khm_startup.exit = TRUE;\r
khm_startup.no_main_window = TRUE;\r
}\r
else if (!wcscmp(wargs[i], L"-a") ||\r
- !wcscmp(wargs[i], L"--autoinit")) {\r
+ !wcscmp(wargs[i], L"--autoinit") ||\r
+ !wcscmp(wargs[i], L"-autoinit")) {\r
khm_startup.autoinit = TRUE;\r
}\r
else {\r
ICC_BAR_CLASSES |\r
ICC_DATE_CLASSES |\r
ICC_HOTKEY_CLASS |\r
+#if (_WIN32_WINNT >= 0x501)\r
ICC_LINK_CLASS |\r
- ICC_LISTVIEW_CLASSES |\r
ICC_STANDARD_CLASSES |\r
+#endif\r
+ ICC_LISTVIEW_CLASSES |\r
ICC_TAB_CLASSES;\r
InitCommonControlsEx(&ics);\r
\r
}\r
}\r
\r
- khui_main_window_active = IsWindowEnabled(khm_hwnd_main);\r
+ khui_main_window_active = khm_is_main_window_active();\r
EnableWindow(khm_hwnd_main, FALSE);\r
\r
khui_modal_dialog = hwnd;\r
}\r
}\r
\r
- EnableWindow(khm_hwnd_main, khui_main_window_active);\r
+ EnableWindow(khm_hwnd_main, TRUE);\r
+ if (khui_main_window_active)\r
+ SetForegroundWindow(khm_hwnd_main);\r
\r
khui_modal_dialog = NULL;\r
}\r
\r
BOOL khm_check_dlg_message(LPMSG pmsg) {\r
int i;\r
+ BOOL found = FALSE;\r
for(i=0;i<n_khui_dialogs;i++) {\r
- if(IsDialogMessage(khui_dialogs[i].hwnd, pmsg))\r
+ if(IsDialogMessage(khui_dialogs[i].hwnd, pmsg)) {\r
+ found = TRUE;\r
break;\r
+ }\r
}\r
\r
- if(i<n_khui_dialogs)\r
- return TRUE;\r
- else\r
- return FALSE;\r
+ return found;\r
}\r
\r
BOOL khm_is_dialog_active(void) {\r
return msg.wParam;\r
}\r
\r
+void KHMAPI\r
+khm_module_load_ctx_handler(enum kherr_ctx_event evt,\r
+ kherr_context * c) {\r
+ kherr_event * e;\r
+ khui_alert * a;\r
+\r
+ for(e = kherr_get_first_event(c);\r
+ e;\r
+ e = kherr_get_next_event(e)) {\r
+\r
+ kherr_evaluate_event(e);\r
+\r
+ if ((e->severity == KHERR_ERROR ||\r
+ e->severity == KHERR_WARNING) &&\r
+ e->short_desc &&\r
+ e->long_desc) {\r
+\r
+ khui_alert_create_empty(&a);\r
+\r
+ khui_alert_set_severity(a, e->severity);\r
+ khui_alert_set_title(a, e->short_desc);\r
+ khui_alert_set_message(a, e->long_desc);\r
+ if (e->suggestion)\r
+ khui_alert_set_suggestion(a, e->suggestion);\r
+\r
+ khui_alert_queue(a);\r
+\r
+ khui_alert_release(a);\r
+ }\r
+ }\r
+\r
+ kherr_remove_ctx_handler(khm_module_load_ctx_handler,\r
+ c->serial);\r
+}\r
+\r
+void khm_load_default_modules(void) {\r
+ kherr_context * c;\r
+\r
+ _begin_task(KHERR_CF_TRANSITIVE);\r
+\r
+ kmm_load_default_modules();\r
+\r
+ c = kherr_peek_context();\r
+ kherr_add_ctx_handler(khm_module_load_ctx_handler,\r
+ KHERR_CTX_END,\r
+ c->serial);\r
+ kherr_release_context(c);\r
+\r
+ _end_task();\r
+}\r
+\r
int WINAPI WinMain(HINSTANCE hInstance,\r
HINSTANCE hPrevInstance,\r
LPSTR lpCmdLine,\r
khc_load_schema(NULL, schema_uiconfig);\r
\r
if(!slave) {\r
+\r
+ /* set this so that we don't accidently invoke an API that\r
+ inadvertently puts up the new creds dialog at an\r
+ inopportune moment, like, say, during the new creds dialog\r
+ is open. This only affects this process, and any child\r
+ processes started by plugins. */\r
+ SetEnvironmentVariable(L"KERBEROSLOGIN_NEVER_PROMPT", L"1");\r
+\r
/* we only open a main window if this is the only instance \r
of the application that is running. */\r
kmq_init();\r
kmq_set_completion_handler(KMSG_CRED, kmsg_cred_completion);\r
\r
/* load the standard plugins */\r
- kmm_load_default_modules();\r
+ khm_load_default_modules();\r
\r
khm_register_window_classes();\r
\r
CloseHandle(hmap);\r
}\r
\r
+#if 0\r
+ /* writes a report of memory leaks to the specified file. Should\r
+ only be enabled on development versions. */\r
+ PDUMP("memleak.txt");\r
+#endif\r
+\r
return rv;\r
}\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
hm = CreatePopupMenu();\r
act = def->items;\r
i = 0;\r
- while(act->action != KHUI_MENU_END) {\r
+ while((def->n_items == -1 && act->action != KHUI_MENU_END) ||\r
+ (def->n_items >= 0 && i < (int) def->n_items)) {\r
add_action_to_menu(hm,khui_find_action(act->action),i,act->flags);\r
act++; i++;\r
}\r
TB_SETHOTITEM,\r
menu_id,\r
0);\r
- \r
\r
khm_menu_track_current();\r
\r
if((HIWORD(wParam) == 0xffff && lParam == 0) || \r
(HIWORD(wParam) & MF_POPUP)) {\r
/* the menu was closed */\r
- khui_statusbar_set_text(KHUI_SBPART_INFO, NULL);\r
+ khm_statusbar_set_part(KHUI_SBPART_INFO, NULL, NULL);\r
} else {\r
khui_action * act;\r
int id;\r
id = LOWORD(wParam);\r
act = khui_find_action(id);\r
if(act == NULL || act->is_tooltip == 0)\r
- khui_statusbar_set_text(KHUI_SBPART_INFO, NULL);\r
+ khm_statusbar_set_part(KHUI_SBPART_INFO, NULL, NULL);\r
else {\r
LoadString(khm_hInstance, \r
act->is_tooltip, \r
buf, ARRAYLENGTH(buf));\r
- khui_statusbar_set_text(KHUI_SBPART_INFO, buf);\r
+ khm_statusbar_set_part(KHUI_SBPART_INFO, NULL, buf);\r
}\r
}\r
return 0;\r
ret = TBDDRET_DEFAULT;\r
break;\r
\r
- case TBN_HOTITEMCHANGE: \r
+ case TBN_HOTITEMCHANGE:\r
{\r
LPNMTBHOTITEM nmhi;\r
int new_item = -1;\r
mm = mmdef->items;\r
nmm = (int) khui_action_list_length(mm);\r
\r
- hwtb = CreateWindowEx(\r
- TBSTYLE_EX_MIXEDBUTTONS,\r
- TOOLBARCLASSNAME,\r
- (LPWSTR) NULL,\r
- WS_CHILD | \r
- CCS_ADJUSTABLE | \r
- TBSTYLE_FLAT |\r
- TBSTYLE_AUTOSIZE |\r
- TBSTYLE_LIST |\r
- CCS_NORESIZE |\r
- CCS_NOPARENTALIGN |\r
- CCS_NODIVIDER,\r
- 0, 0, 0, 0, rebar,\r
- (HMENU) NULL, khm_hInstance,\r
- NULL);\r
+ hwtb = CreateWindowEx(0\r
+#if (_WIN32_IE >= 0x0501)\r
+ | TBSTYLE_EX_MIXEDBUTTONS\r
+#endif\r
+ ,\r
+ TOOLBARCLASSNAME,\r
+ (LPWSTR) NULL,\r
+ WS_CHILD | \r
+ CCS_ADJUSTABLE | \r
+ TBSTYLE_FLAT |\r
+ TBSTYLE_AUTOSIZE |\r
+ TBSTYLE_LIST |\r
+ CCS_NORESIZE |\r
+ CCS_NOPARENTALIGN |\r
+ CCS_NODIVIDER,\r
+ 0, 0, 0, 0, rebar,\r
+ (HMENU) NULL, khm_hInstance,\r
+ NULL);\r
\r
if(!hwtb) {\r
#ifdef DEBUG\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
case WM_DESTROY:\r
kmq_unsubscribe_hwnd(KMSG_ACT, hwnd);\r
kmq_unsubscribe_hwnd(KMSG_CRED, hwnd);\r
+ HtmlHelp(NULL, NULL, HH_CLOSE_ALL, 0);\r
PostQuitMessage(0);\r
break;\r
\r
return khm_toolbar_notify(lpnm);\r
} else if(lpnm->hwndFrom == khm_hwnd_rebar) {\r
return khm_rebar_notify(lpnm);\r
+ } else if(lpnm->hwndFrom == khm_hwnd_statusbar) {\r
+ return khm_statusbar_notify(lpnm);\r
}\r
break;\r
\r
+ case WM_HELP:\r
+ MessageBox(khm_hwnd_main, L"WM_HELP", L"Notice", MB_OK);\r
+ break;\r
+\r
case WM_COMMAND:\r
switch(LOWORD(wParam)) {\r
/* general actions */\r
case KHUI_ACTION_VIEW_REFRESH:\r
+ khm_cred_refresh();\r
InvalidateRect(khm_hwnd_main_cred, NULL, FALSE);\r
- kmq_post_message(KMSG_CRED, KMSG_CRED_REFRESH, 0, NULL);\r
return 0;\r
\r
case KHUI_ACTION_PASSWD_ID:\r
}\r
break;\r
\r
+ case KHUI_ACTION_HELP_CTX:\r
+ HtmlHelp(khm_hwnd_main, NIDM_HELPFILE,\r
+ HH_HELP_CONTEXT, IDH_WELCOME);\r
+ break;\r
+\r
+ case KHUI_ACTION_HELP_CONTENTS:\r
+ HtmlHelp(khm_hwnd_main, NIDM_HELPFILE,\r
+ HH_DISPLAY_TOC, 0);\r
+ break;\r
+\r
+ case KHUI_ACTION_HELP_INDEX:\r
+ HtmlHelp(khm_hwnd_main, NIDM_HELPFILE,\r
+ HH_DISPLAY_INDEX, (DWORD_PTR) L"");\r
+ break;\r
+\r
case KHUI_ACTION_HELP_ABOUT:\r
khm_create_about_window();\r
break;\r
\r
case KHUI_PACTION_DELETE:\r
\r
+ case KHUI_PACTION_SELALL:\r
case KHUI_ACTION_LAYOUT_ID:\r
case KHUI_ACTION_LAYOUT_TYPE:\r
case KHUI_ACTION_LAYOUT_LOC:\r
/* resize the rebar control */\r
SendMessage(khm_hwnd_rebar, WM_SIZE, 0, 0);\r
\r
- khui_update_statusbar(hwnd);\r
+ khm_update_statusbar(hwnd);\r
\r
GetWindowRect(khm_hwnd_rebar, &r_rebar);\r
- GetWindowRect(khui_hwnd_statusbar, &r_status);\r
+ GetWindowRect(khm_hwnd_statusbar, &r_status);\r
\r
/* the cred window fills the area between the rebar\r
and the status bar */\r
} else if (m->type == KMSG_CRED &&\r
m->subtype == KMSG_CRED_REFRESH) {\r
mw_restart_refresh_timer(hwnd);\r
+ } else if (m->type == KMSG_CRED &&\r
+ m->subtype == KMSG_CRED_ADDR_CHANGE) {\r
+ khm_cred_addr_change();\r
} else if (m->type == KMSG_KMM &&\r
m->subtype == KMSG_KMM_I_DONE) {\r
kmq_post_message(KMSG_ACT, KMSG_ACT_BEGIN_CMDLINE, 0, 0);\r
\r
LRESULT khm_rebar_notify(LPNMHDR lpnm) {\r
switch(lpnm->code) {\r
+#if (_WIN32_WINNT >= 0x0501)\r
case RBN_AUTOBREAK:\r
{\r
LPNMREBARAUTOBREAK lpra = (LPNMREBARAUTOBREAK) lpnm;\r
lpra->fAutoBreak = TRUE;\r
}\r
break;\r
-\r
+#endif\r
case RBN_BEGINDRAG:\r
{\r
LPNMREBAR lprb = (LPNMREBAR) lpnm;\r
/* self attach */\r
khm_menu_create_main(hwRebar);\r
khm_create_standard_toolbar(hwRebar);\r
- khui_create_statusbar(hwnd_main);\r
+ khm_create_statusbar(hwnd_main);\r
\r
/* manual attach */\r
khm_hwnd_main_cred = khm_create_credwnd(hwnd_main);\r
khm_handle csp_mw = NULL;\r
int x,y,width,height;\r
\r
- LoadString(khm_hInstance, IDS_MAIN_WINDOW_TITLE, buf, sizeof(buf)/sizeof(buf[0]));\r
+ LoadString(khm_hInstance, IDS_MAIN_WINDOW_TITLE, \r
+ buf, ARRAYLENGTH(buf));\r
\r
khm_hwnd_null =\r
CreateWindow(MAKEINTATOM(khm_null_window_class),\r
NULL,\r
NULL);\r
\r
- if (!khm_hwnd_main)\r
- return;\r
}\r
\r
void khm_show_main_window(void) {\r
SetForegroundWindow(khm_hwnd_main);\r
}\r
\r
- ShowWindow(khm_hwnd_main, khm_nCmdShow);\r
- UpdateWindow(khm_hwnd_main);\r
+ if (khm_nCmdShow == SW_SHOWMINIMIZED ||\r
+ khm_nCmdShow == SW_SHOWMINNOACTIVE ||\r
+ khm_nCmdShow == SW_MINIMIZE) {\r
+ khm_hide_main_window();\r
+ } else {\r
+ ShowWindow(khm_hwnd_main, khm_nCmdShow);\r
+ UpdateWindow(khm_hwnd_main);\r
+ }\r
\r
khm_nCmdShow = SW_RESTORE;\r
}\r
khm_handle csp_notices = NULL;\r
khm_int32 show_warning = FALSE;\r
\r
- if (KHM_SUCCEEDED(khc_open_space(NULL, L"CredWindow\\Notices",\r
+ if (khm_nCmdShow != SW_MINIMIZE &&\r
+ KHM_SUCCEEDED(khc_open_space(NULL, L"CredWindow\\Notices",\r
KHM_PERM_WRITE, &csp_notices)) &&\r
KHM_SUCCEEDED(khc_read_int32(csp_notices, L"MinimizeWarning",\r
&show_warning)) &&\r
show_warning != 0) {\r
+\r
khui_alert * alert;\r
wchar_t title[KHUI_MAXCCH_TITLE];\r
wchar_t msg[KHUI_MAXCCH_MESSAGE];\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
HWND hw = NULL;\r
size_t cch = 0;\r
\r
- ctbuf = malloc(NC_MAXCB_CREDTEXT);\r
+ ctbuf = PMALLOC(NC_MAXCB_CREDTEXT);\r
\r
assert(ctbuf != NULL);\r
\r
a comma separated string */\r
\r
/* d->nc->n_identities is at least 2 */\r
- ids_string = malloc((KCDB_IDENT_MAXCB_NAME + sizeof(id_fmt)) * \r
+ ids_string = PMALLOC((KCDB_IDENT_MAXCB_NAME + sizeof(id_fmt)) * \r
(d->nc->n_identities - 1));\r
cb_ids_string = \r
(KCDB_IDENT_MAXCB_NAME + sizeof(id_fmt)) * \r
StringCbPrintf(buf, NC_MAXCB_CREDTEXT - cch*sizeof(wchar_t), \r
main_fmt, id_string, ids_string);\r
\r
- free(ids_string);\r
+ PFREE(ids_string);\r
}\r
} else {\r
LoadString(khm_hInstance, IDS_NC_CREDTEXT_ID_NONE, \r
\r
SetDlgItemText(d->dlg_main, IDC_NC_CREDTEXT, ctbuf);\r
\r
- free(ctbuf);\r
+ PFREE(ctbuf);\r
\r
/* so depending on whether the primary identity was found to be\r
invalid, we need to disable the Ok button and set the title to\r
\r
lpc = (LPCREATESTRUCT) lParam;\r
\r
- ncd = malloc(sizeof(*ncd));\r
+ ncd = PMALLOC(sizeof(*ncd));\r
ZeroMemory(ncd, sizeof(*ncd));\r
\r
c = (khui_new_creds *) lpc->lpCreateParams;\r
d->dlg_main = NULL;\r
d->dlg_ts = NULL;\r
\r
- free(d);\r
+ PFREE(d);\r
\r
return TRUE;\r
}\r
&cbsize, \r
KCDB_TS_SHORT) == KHM_ERROR_TOO_LONG) {\r
\r
- name = malloc(cbsize);\r
+ name = PMALLOC(cbsize);\r
kcdb_credtype_describe(d->nc->types[i]->type, \r
name, \r
&cbsize, \r
x += width;\r
\r
if(!(d->nc->types[i]->name))\r
- free(name);\r
+ PFREE(name);\r
\r
/* Now set the position of the type panel */\r
ShowWindow(d->nc->types[i]->hwnd_panel, SW_HIDE);\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/* notifier message for notification icon */\r
#define KHUI_WM_NOTIFIER WM_COMMAND\r
\r
+#define KHUI_ALERT_QUEUE_MAX 64\r
+\r
/* window class registration atom for message only notifier window\r
class */\r
ATOM atom_notifier = 0;\r
\r
khui_alert * current_alert = NULL;\r
\r
+khui_alert * alert_queue[KHUI_ALERT_QUEUE_MAX];\r
+khm_int32 alert_queue_head = 0;\r
+khm_int32 alert_queue_tail = 0;\r
+\r
+#define is_alert_queue_empty() (alert_queue_head == alert_queue_tail)\r
+#define is_alert_queue_full() (((alert_queue_tail + 1) % KHUI_ALERT_QUEUE_MAX) == alert_queue_head)\r
+\r
+static void \r
+add_to_alert_queue(khui_alert * a) {\r
+ if (is_alert_queue_full()) return;\r
+ alert_queue[alert_queue_tail++] = a;\r
+ khui_alert_hold(a);\r
+ alert_queue_tail %= KHUI_ALERT_QUEUE_MAX;\r
+}\r
+\r
+static khui_alert * \r
+del_from_alert_queue(void) {\r
+ khui_alert * a;\r
+\r
+ if (is_alert_queue_empty()) return NULL;\r
+ a = alert_queue[alert_queue_head++];\r
+ alert_queue_head %= KHUI_ALERT_QUEUE_MAX;\r
+\r
+ return a; /* held */\r
+}\r
+\r
+static khui_alert * \r
+peek_alert_queue(void) {\r
+ if (is_alert_queue_empty()) return NULL;\r
+ return alert_queue[alert_queue_head];\r
+}\r
+\r
+static void\r
+check_for_queued_alerts(void) {\r
+ if (!is_alert_queue_empty()) {\r
+ khui_alert * a;\r
+\r
+ a = peek_alert_queue();\r
+\r
+ if (a->title) {\r
+ HICON hi;\r
+ int res;\r
+\r
+ if (a->severity == KHERR_ERROR)\r
+ res = OIC_ERROR;\r
+ else if (a->severity == KHERR_WARNING)\r
+ res = OIC_WARNING;\r
+ else\r
+ res = OIC_INFORMATION;\r
+\r
+ hi = LoadImage(0, MAKEINTRESOURCE(res),\r
+ IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON),\r
+ LR_SHARED);\r
+\r
+ khm_statusbar_set_part(KHUI_SBPART_NOTICE,\r
+ hi,\r
+ a->title);\r
+ }\r
+ } else {\r
+ khm_statusbar_set_part(KHUI_SBPART_NOTICE,\r
+ NULL, NULL);\r
+ }\r
+}\r
+\r
\r
/* forward dcls */\r
static khm_int32 \r
static khm_int32\r
alert_show_normal(khui_alert * a);\r
\r
+static khm_int32\r
+alert_enqueue(khui_alert * a);\r
+\r
/**********************************************************************\r
Notifier\r
***********************************************************************\r
if(m->type == KMSG_ALERT) {\r
/* handle notifier messages */\r
switch(m->subtype) {\r
- case KMSG_ALERT_SHOW:\r
- rv = alert_show((khui_alert *) m->vparam);\r
- khui_alert_release((khui_alert *) m->vparam);\r
- break;\r
+ case KMSG_ALERT_SHOW:\r
+ rv = alert_show((khui_alert *) m->vparam);\r
+ khui_alert_release((khui_alert *) m->vparam);\r
+ break;\r
+\r
+ case KMSG_ALERT_QUEUE:\r
+ rv = alert_enqueue((khui_alert *) m->vparam);\r
+ khui_alert_release((khui_alert *) m->vparam);\r
+ break;\r
+\r
+ case KMSG_ALERT_CHECK_QUEUE:\r
+ check_for_queued_alerts();\r
+ break;\r
+\r
+ case KMSG_ALERT_SHOW_QUEUED:\r
+ if (current_alert == NULL) {\r
+ khui_alert * a;\r
+\r
+ a = del_from_alert_queue();\r
+ if (a) {\r
+ rv = alert_show(a);\r
+ check_for_queued_alerts();\r
+ khui_alert_release(a);\r
+ }\r
+ }\r
+ break;\r
}\r
} else if (m->type == KMSG_CRED &&\r
m->subtype == KMSG_CRED_ROOTDELTA) {\r
+\r
KillTimer(hwnd, KHUI_REFRESH_TIMER_ID);\r
SetTimer(hwnd, KHUI_REFRESH_TIMER_ID,\r
KHUI_REFRESH_TIMEOUT,\r
NULL);\r
+\r
}\r
\r
return kmq_wm_end(m, rv);\r
khm_show_main_window();\r
break;\r
\r
+#if (_WIN32_IE >= 0x0501)\r
case NIN_BALLOONUSERCLICK:\r
if (current_alert) {\r
if ((current_alert->flags & KHUI_ALERT_FLAG_DEFACTION) &&\r
current_alert->n_alert_commands > 0) {\r
PostMessage(khm_hwnd_main, WM_COMMAND,\r
- MAKEWPARAM(current_alert->alert_commands[0], 0),\r
+ MAKEWPARAM(current_alert->alert_commands[0], \r
+ 0),\r
0);\r
- } else if (current_alert->flags & KHUI_ALERT_FLAG_REQUEST_WINDOW) {\r
+ } else if (current_alert->flags & \r
+ KHUI_ALERT_FLAG_REQUEST_WINDOW) {\r
khm_show_main_window();\r
alert_show_normal(current_alert);\r
}\r
}\r
/* fallthrough */\r
case NIN_BALLOONTIMEOUT:\r
- khui_notify_icon_change(KHERR_NONE);\r
+ khm_notify_icon_change(KHERR_NONE);\r
if (current_alert) {\r
khui_alert_release(current_alert);\r
current_alert = NULL;\r
}\r
break;\r
+#endif\r
}\r
} else if (uMsg == WM_TIMER) {\r
if (wParam == KHUI_TRIGGER_TIMER_ID) {\r
}\r
\r
ATOM \r
-khui_register_notifier_wnd_class(void)\r
+khm_register_notifier_wnd_class(void)\r
{\r
WNDCLASSEX wcx;\r
\r
\r
a->flags |= KHUI_ALERT_FLAG_DISPLAY_BALLOON;\r
\r
+#if (_WIN32_IE >= 0x0501)\r
current_alert = a;\r
khui_alert_hold(a);\r
+#endif\r
\r
- khui_notify_icon_balloon(a->severity,\r
+ khm_notify_icon_balloon(a->severity,\r
tbuf,\r
mbuf,\r
NTF_TIMEOUT);\r
title = a->title;\r
\r
/* if we don't have any commands, we just add a "close" button */\r
- if(a->n_alert_commands == 0) {\r
+ if (a->n_alert_commands == 0) {\r
khui_alert_add_command(a, KHUI_PACTION_CLOSE);\r
}\r
\r
+ if (!is_alert_queue_empty()) {\r
+ khui_alert_add_command(a, KHUI_PACTION_NEXT);\r
+ }\r
+\r
/* we don't need to keep track of the window handle\r
because the window procedure adds it to the dialog\r
list automatically */\r
\r
static khm_int32 \r
alert_show(khui_alert * a) {\r
+ /* is there an alert already? If so, we just enqueue the message\r
+ and let it sit. */\r
+ if (current_alert) {\r
+ return alert_enqueue(a);\r
+ }\r
+\r
/* the window has already been shown */\r
if((a->flags & KHUI_ALERT_FLAG_DISPLAY_WINDOW) ||\r
((a->flags & KHUI_ALERT_FLAG_DISPLAY_BALLOON) &&\r
return alert_show_minimized(a);\r
}\r
\r
+static khm_int32\r
+alert_enqueue(khui_alert * a) {\r
+ if (is_alert_queue_full())\r
+ return KHM_ERROR_NO_RESOURCES;\r
+\r
+ add_to_alert_queue(a);\r
+ check_for_queued_alerts();\r
+\r
+ return KHM_ERROR_SUCCESS;\r
+}\r
+\r
/* the alerter window is actually a dialog */\r
static LRESULT CALLBACK \r
alerter_wnd_proc(HWND hwnd,\r
a = (khui_alert *) lpcs->lpCreateParams;\r
khui_alert_hold(a);\r
\r
- d = malloc(sizeof(*d));\r
+ d = PMALLOC(sizeof(*d));\r
ZeroMemory(d, sizeof(*d));\r
\r
d->alert = a;\r
}\r
}\r
\r
- khui_notify_icon_change(a->severity);\r
+ khm_notify_icon_change(a->severity);\r
\r
khui_alert_unlock(a);\r
\r
\r
DeleteObject(d->hfont);\r
\r
- free(d);\r
+ PFREE(d);\r
\r
- khui_notify_icon_change(KHERR_NONE);\r
+ khm_notify_icon_change(KHERR_NONE);\r
\r
return TRUE;\r
}\r
hicon = LoadImage(NULL, \r
MAKEINTRESOURCE(iid), \r
IMAGE_ICON,\r
- SM_CXICON, SM_CYICON,\r
+ GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON),\r
LR_SHARED);\r
\r
DrawIcon(hdc, x, y, hicon);\r
CopyRect(&ro, &r);\r
\r
// adjust for icon and padding\r
- r.left += SM_CXICON + d->dx_suggest_pad * 2;\r
+ r.left += GetSystemMetrics(SM_CXSMICON) + d->dx_suggest_pad * 2;\r
r.top += d->dx_suggest_pad;\r
r.right -= d->dx_suggest_pad;\r
r.bottom -= d->dx_suggest_pad;\r
LoadImage(0,\r
MAKEINTRESOURCE(OIC_INFORMATION),\r
IMAGE_ICON,\r
- SM_CXICON, SM_CYICON,\r
+ GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON),\r
LR_SHARED);\r
\r
assert(h_sug_ico != NULL);\r
ro.left + d->dx_suggest_pad, \r
ro.top + d->dx_suggest_pad, \r
h_sug_ico,\r
- SM_CXICON, SM_CYICON,\r
+ GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON),\r
0, NULL,\r
DI_NORMAL);\r
\r
khm_leave_modal();\r
\r
DestroyWindow(hwnd);\r
+\r
+ if (LOWORD(wParam) == KHUI_PACTION_NEXT)\r
+ kmq_post_message(KMSG_ALERT, KMSG_ALERT_SHOW_QUEUED, 0, 0);\r
return 0;\r
}\r
}\r
//return DefWindowProc(hwnd, uMsg, wParam, lParam);\r
}\r
\r
-ATOM khui_register_alerter_wnd_class(void)\r
+ATOM khm_register_alerter_wnd_class(void)\r
{\r
WNDCLASSEX wcx;\r
\r
ZeroMemory(&wcx, sizeof(wcx));\r
\r
wcx.cbSize = sizeof(wcx);\r
- wcx.style = CS_DROPSHADOW | CS_OWNDC;\r
+ wcx.style =\r
+#if(_WIN32_WINNT >= 0x0501)\r
+ CS_DROPSHADOW |\r
+#endif\r
+ CS_OWNDC;\r
wcx.lpfnWndProc = alerter_wnd_proc;\r
wcx.cbClsExtra = 0;\r
wcx.cbWndExtra = DLGWINDOWEXTRA + sizeof(LONG_PTR);\r
\r
#define KHUI_NOTIFY_ICON_ID 0\r
\r
-void khui_notify_icon_add(void) {\r
+void khm_notify_icon_add(void) {\r
NOTIFYICONDATA ni;\r
wchar_t buf[256];\r
\r
}\r
\r
void \r
-khui_notify_icon_balloon(khm_int32 severity,\r
+khm_notify_icon_balloon(khm_int32 severity,\r
wchar_t * title,\r
wchar_t * msg,\r
khm_int32 timeout) {\r
DestroyIcon(ni.hIcon);\r
}\r
\r
-void khui_notify_icon_change(khm_int32 severity) {\r
+void khm_notify_icon_change(khm_int32 severity) {\r
NOTIFYICONDATA ni;\r
wchar_t buf[256];\r
int iid;\r
DestroyIcon(ni.hIcon);\r
}\r
\r
-void khui_notify_icon_remove(void) {\r
+void khm_notify_icon_remove(void) {\r
NOTIFYICONDATA ni;\r
\r
ZeroMemory(&ni, sizeof(ni));\r
Initialization\r
**********************************************************************/\r
\r
-void khui_init_notifier(void)\r
+void khm_init_notifier(void)\r
{\r
- if(!khui_register_notifier_wnd_class())\r
+ if(!khm_register_notifier_wnd_class())\r
return;\r
\r
- if(!khui_register_alerter_wnd_class())\r
+ if(!khm_register_alerter_wnd_class())\r
return;\r
\r
hwnd_notifier = CreateWindowEx(0,\r
kmq_subscribe_hwnd(KMSG_CRED, hwnd_notifier);\r
notifier_ready = TRUE;\r
\r
- khui_notify_icon_add();\r
+ khm_notify_icon_add();\r
}\r
#ifdef DEBUG\r
else {\r
}\r
#endif\r
khm_timer_init();\r
+\r
+ khm_addr_change_notifier_init();\r
}\r
\r
-void khui_exit_notifier(void)\r
+void khm_exit_notifier(void)\r
{\r
+ khm_addr_change_notifier_exit();\r
+\r
khm_timer_exit();\r
\r
if(hwnd_notifier != NULL) {\r
- khui_notify_icon_remove();\r
+ khm_notify_icon_remove();\r
kmq_unsubscribe_hwnd(KMSG_ALERT, hwnd_notifier);\r
kmq_unsubscribe_hwnd(KMSG_CRED, hwnd_notifier);\r
DestroyWindow(hwnd_notifier);\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
#define __KHIMAIRA_NOTIFIER_H\r
\r
void \r
-khui_init_notifier(void);\r
+khm_init_notifier(void);\r
\r
void \r
-khui_exit_notifier(void);\r
+khm_exit_notifier(void);\r
\r
void \r
-khui_notify_icon_change(khm_int32 severity);\r
+khm_notify_icon_change(khm_int32 severity);\r
\r
void \r
-khui_notify_icon_balloon(khm_int32 severity,\r
+khm_notify_icon_balloon(khm_int32 severity,\r
wchar_t * title,\r
wchar_t * msg,\r
khm_int32 timeout);\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
&attr_count)))\r
return;\r
\r
- attrs = malloc(sizeof(khm_int32) * attr_count);\r
+ attrs = PMALLOC(sizeof(khm_int32) * attr_count);\r
assert(attrs != NULL);\r
\r
kcdb_attrib_get_ids(\r
&attr_count);\r
\r
cb_buf = sizeof(wchar_t) * 2048;\r
- buffer = malloc(cb_buf);\r
+ buffer = PMALLOC(cb_buf);\r
assert(buffer != NULL);\r
\r
for(i=0; i<attr_count; i++) {\r
ListView_SetItem(hwnd_lv, &lvi);\r
}\r
\r
- free(attrs);\r
- free(buffer);\r
+ PFREE(attrs);\r
+ PFREE(buffer);\r
}\r
}\r
\r
\r
cs = (CREATESTRUCT *) lParam;\r
\r
- child = malloc(sizeof(*child));\r
+ child = PMALLOC(sizeof(*child));\r
ZeroMemory(child, sizeof(*child));\r
\r
#pragma warning(push)\r
{\r
child = (pw_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0);\r
kcdb_buf_release(child->record);\r
- free(child);\r
+ PFREE(child);\r
}\r
break;\r
\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
#ifdef DEBUG\r
assert(FALSE);\r
#endif\r
- rv = KHM_ERROR_INVALID_PARM;\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
goto _exit_tgt_with_lparam;\r
}\r
\r
#ifdef DEBUG\r
assert(FALSE);\r
#endif\r
- rv = KHM_ERROR_INVALID_PARM;\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
goto _exit_tgt_with_lparam;\r
}\r
\r
#ifdef DEBUG\r
assert(FALSE);\r
#endif\r
- rv = KHM_ERROR_INVALID_PARM;\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
goto _exit_tgt_with_lparam;\r
}\r
\r
\r
if (FAILED(StringCbPrintf(widname, sizeof(widname),\r
L"%hs@%hs", username, realm))) {\r
- rv = KHM_ERROR_INVALID_PARM;\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
goto _exit_tgt_with_lparam;\r
}\r
\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
//{{NO_DEPENDENCIES}}\r
// Microsoft Visual C++ generated include file.\r
-// Used by D:\work\khimaira\src\ui\lang\en_us\khapp.rc\r
+// Used by D:\work\pismere\athena\auth\krb5\src\windows\identity\ui\lang\en_us\khapp.rc\r
//\r
#define IDI_MAIN_APP 104\r
#define IDD_PROPPAGE_MEDIUM 106\r
#define IDS_NC_CREDTEXT_ID_MANY 148\r
#define IDB_LOGO_SHADE 149\r
#define IDS_NC_CREDTEXT_ID_INVALID 149\r
-#define IDI_WGT_COLLAPSE 150\r
#define IDS_WTPOST_INIT_CREDS 150\r
-#define IDI_WGT_EXPAND 151\r
#define IDS_WTPOST_NEW_CREDS 151\r
#define IDB_WDG_EXPAND 152\r
#define IDS_ACTION_RENEW_CRED 152\r
#define IDS_CFG_ID_TAB_SHORT 197\r
#define IDB_TB_SPACE 197\r
#define IDS_CFG_ID_TAB_LONG 198\r
+#define IDB_WDG_STUCK_HI 198\r
#define IDS_CFG_IDS_TAB_SHORT 199\r
+#define IDB_WDG_STICK 199\r
#define IDS_CFG_IDS_TAB_LONG 200\r
+#define IDB_WDG_STICK_HI 200\r
#define IDS_CFG_IDS_IDENTITY 201\r
+#define IDB_WDG_STUCK 201\r
#define IDS_ACTION_IMPORT 202\r
#define IDS_CTX_IMPORT 203\r
#define IDS_CFG_PI_COL_PLUGINS 204\r
#define IDS_CTX_PROC_PASSWORD 219\r
#define IDS_NC_PWD_FAILED_TITLE 220\r
#define IDS_CMDLINE_HELP 221\r
+#define IDS_PACTION_NEXT 222\r
+#define IDS_ERR_TITLE_NO_IDENTPRO 223\r
+#define IDS_ERR_MSG_NO_IDENTPRO 224\r
+#define IDS_ERR_SUGG_NO_IDENTPRO 225\r
+#define IDS_NC_REN_FAILED_TITLE 226\r
+#define IDS_CW_DEFAULT 227\r
#define IDC_NC_USERNAME 1007\r
#define IDC_NC_PASSWORD 1008\r
#define IDC_NC_CREDTEXT_LABEL 1009\r
#define IDC_BUILDINFO 1102\r
#define IDC_LIST1 1103\r
#define IDC_MODULES 1103\r
+#define IDC_PP_CONFIG 1104\r
#define IDA_ACTIVATE_MENU 40003\r
#define IDA_UP 40004\r
#define IDA_DOWN 40005\r
// \r
#ifdef APSTUDIO_INVOKED\r
#ifndef APSTUDIO_READONLY_SYMBOLS\r
-#define _APS_NEXT_RESOURCE_VALUE 198\r
+#define _APS_NEXT_RESOURCE_VALUE 202\r
#define _APS_NEXT_COMMAND_VALUE 40010\r
-#define _APS_NEXT_CONTROL_VALUE 1104\r
+#define _APS_NEXT_CONTROL_VALUE 1105\r
#define _APS_NEXT_SYMED_VALUE 101\r
#endif\r
#endif\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
\r
#include<khmapp.h>\r
\r
-khui_statusbar_part khui_statusbar_parts[] = {\r
+khm_statusbar_part khm_statusbar_parts[] = {\r
{KHUI_SBPART_INFO, 0, KHUI_SB_WTYPE_FILLER},\r
{KHUI_SBPART_NOTICE, 40, KHUI_SB_WTYPE_RELATIVE},\r
{KHUI_SBPART_LOC, 40, KHUI_SB_WTYPE_ABSOLUTE}\r
};\r
\r
-int khui_n_statusbar_parts = sizeof(khui_statusbar_parts) / sizeof(khui_statusbar_part);\r
+int khm_n_statusbar_parts = sizeof(khm_statusbar_parts) / sizeof(khm_statusbar_part);\r
\r
-HWND khui_hwnd_statusbar = NULL;\r
+HWND khm_hwnd_statusbar = NULL;\r
\r
-void khui_statusbar_set_parts(HWND parent) {\r
+LRESULT \r
+khm_statusbar_notify(LPNMHDR nmhdr) {\r
+ LPNMMOUSE pnmm;\r
+\r
+ switch(nmhdr->code) {\r
+ case NM_CLICK:\r
+ case NM_DBLCLK:\r
+ pnmm = (LPNMMOUSE) nmhdr;\r
+\r
+ if (pnmm->dwItemSpec >= (DWORD) khm_n_statusbar_parts)\r
+ return TRUE;\r
+\r
+ if (khm_statusbar_parts[pnmm->dwItemSpec].id == KHUI_SBPART_NOTICE) {\r
+ /* means, show next notification */\r
+ kmq_post_message(KMSG_ALERT, KMSG_ALERT_SHOW_QUEUED, 0, 0);\r
+ }\r
+\r
+ return TRUE;\r
+ }\r
+\r
+ return FALSE;\r
+}\r
+\r
+void \r
+khui_statusbar_set_parts(HWND parent) {\r
int i;\r
int fillerwidth;\r
int staticwidth;\r
\r
/* calculate fillerwidth and staticwidth */\r
staticwidth = 0;\r
- for(i=0;i<khui_n_statusbar_parts;i++) {\r
- if(khui_statusbar_parts[i].wtype == KHUI_SB_WTYPE_ABSOLUTE) {\r
- staticwidth += khui_statusbar_parts[i].width;\r
- } else if(khui_statusbar_parts[i].wtype == KHUI_SB_WTYPE_RELATIVE) {\r
- staticwidth += (khui_statusbar_parts[i].width * width) / 100;\r
+ for(i=0;i<khm_n_statusbar_parts;i++) {\r
+ if(khm_statusbar_parts[i].wtype == KHUI_SB_WTYPE_ABSOLUTE) {\r
+ staticwidth += khm_statusbar_parts[i].width;\r
+ } else if(khm_statusbar_parts[i].wtype == KHUI_SB_WTYPE_RELATIVE) {\r
+ staticwidth += (khm_statusbar_parts[i].width * width) / 100;\r
}\r
}\r
\r
fillerwidth = width - staticwidth;\r
\r
- parts = malloc(sizeof(INT) * khui_n_statusbar_parts);\r
+ parts = PMALLOC(sizeof(INT) * khm_n_statusbar_parts);\r
\r
lastx = 0;\r
- for(i=0;i<khui_n_statusbar_parts;i++) {\r
+ for(i=0;i<khm_n_statusbar_parts;i++) {\r
int w;\r
- switch(khui_statusbar_parts[i].wtype) {\r
+ switch(khm_statusbar_parts[i].wtype) {\r
case KHUI_SB_WTYPE_ABSOLUTE:\r
- w = khui_statusbar_parts[i].width;\r
+ w = khm_statusbar_parts[i].width;\r
break;\r
\r
case KHUI_SB_WTYPE_RELATIVE:\r
- w = (khui_statusbar_parts[i].width * width) / 100;\r
+ w = (khm_statusbar_parts[i].width * width) / 100;\r
break;\r
\r
case KHUI_SB_WTYPE_FILLER:\r
}\r
lastx += w;\r
\r
- if(i==khui_n_statusbar_parts - 1)\r
+ if(i==khm_n_statusbar_parts - 1)\r
parts[i] = -1;\r
else\r
parts[i] = lastx;\r
}\r
\r
SendMessage(\r
- khui_hwnd_statusbar,\r
+ khm_hwnd_statusbar,\r
SB_SETPARTS,\r
- khui_n_statusbar_parts,\r
+ khm_n_statusbar_parts,\r
(LPARAM) parts);\r
\r
- free(parts);\r
+ PFREE(parts);\r
}\r
\r
-void khui_create_statusbar(HWND parent) {\r
+void khm_create_statusbar(HWND parent) {\r
HWND hwsb;\r
\r
hwsb = CreateWindowEx(\r
if(!hwsb)\r
return;\r
\r
- khui_hwnd_statusbar = hwsb;\r
+ khm_hwnd_statusbar = hwsb;\r
\r
khui_statusbar_set_parts(parent);\r
+\r
+ kmq_post_message(KMSG_ALERT, KMSG_ALERT_CHECK_QUEUE, 0, 0);\r
}\r
\r
-void khui_update_statusbar(HWND parent) {\r
- MoveWindow(khui_hwnd_statusbar, 0, 0, 0, 0, TRUE);\r
+void khm_update_statusbar(HWND parent) {\r
+ MoveWindow(khm_hwnd_statusbar, 0, 0, 0, 0, TRUE);\r
khui_statusbar_set_parts(parent);\r
}\r
\r
int sb_find_index(int id) {\r
int i;\r
\r
- for(i=0;i<khui_n_statusbar_parts;i++) {\r
- if(khui_statusbar_parts[i].id == id)\r
+ for(i=0;i<khm_n_statusbar_parts;i++) {\r
+ if(khm_statusbar_parts[i].id == id)\r
return i;\r
}\r
\r
return -1;\r
}\r
\r
-void khui_statusbar_set_text(int id, wchar_t * text) {\r
+void khm_statusbar_set_part(int id, HICON icon, wchar_t * text) {\r
int idx;\r
\r
+ if (!khm_hwnd_statusbar)\r
+ return;\r
+\r
idx = sb_find_index(id);\r
if(idx < 0)\r
return;\r
\r
- SendMessage(\r
- khui_hwnd_statusbar,\r
- SB_SETTEXT,\r
- idx,\r
- (LPARAM) text);\r
+ SendMessage(khm_hwnd_statusbar,\r
+ SB_SETICON,\r
+ idx,\r
+ (LPARAM) icon);\r
+\r
+ SendMessage(khm_hwnd_statusbar,\r
+ SB_SETTEXT,\r
+ idx,\r
+ (LPARAM) text);\r
}\r
\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
#ifndef __KHIMAIRA_STATUSBAR_H\r
#define __KHIMAIRA_STATUSBAR_H\r
\r
-typedef struct khui_statusbar_part_t {\r
+typedef struct khm_statusbar_part_t {\r
int id;\r
int width;\r
int wtype; /* one of KHUI_SB_WTYPE_* */\r
-} khui_statusbar_part;\r
+} khm_statusbar_part;\r
\r
#define KHUI_SB_WTYPE_RELATIVE 1\r
#define KHUI_SB_WTYPE_ABSOLUTE 2\r
#define KHUI_SBPART_NOTICE 2\r
#define KHUI_SBPART_LOC 3\r
\r
-extern HWND khui_hwnd_statusbar;\r
-extern khui_statusbar_part khui_statusbar_parts[];\r
-extern int khui_n_statusbar_parts;\r
+extern HWND khm_hwnd_statusbar;\r
+extern khm_statusbar_part khm_statusbar_parts[];\r
+extern int khm_n_statusbar_parts;\r
\r
-void khui_create_statusbar(HWND p);\r
-void khui_update_statusbar(HWND parent);\r
-void khui_statusbar_set_text(int id, wchar_t * text);\r
+void khm_create_statusbar(HWND p);\r
+void khm_update_statusbar(HWND parent);\r
+void khm_statusbar_set_part(int id, HICON icon, wchar_t * text);\r
+LRESULT khm_statusbar_notify(LPNMHDR nmhdr);\r
\r
-#endif
\ No newline at end of file
+#endif\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
\r
khui_nc_timers = KHUI_TIMER_ALLOC_INCR;\r
khui_n_timers = 0;\r
- khui_timers = malloc(sizeof(*khui_timers) * khui_nc_timers);\r
+ khui_timers = PMALLOC(sizeof(*khui_timers) * khui_nc_timers);\r
\r
#ifdef DEBUG\r
assert(khui_timers != NULL);\r
InitializeCriticalSection(&cs_timers);\r
}\r
\r
-void \r
+void\r
khm_timer_exit(void) {\r
EnterCriticalSection(&cs_timers);\r
\r
if (khui_timers)\r
- free(khui_timers);\r
+ PFREE(khui_timers);\r
khui_timers = NULL;\r
khui_n_timers = 0;\r
khui_nc_timers = 0;\r
\r
static int\r
tmr_update(khm_handle key, khui_timer_type type, __int64 expire,\r
- __int64 offset, void * data) {\r
+ __int64 offset, void * data, khm_boolean reinstate) {\r
int i;\r
\r
for (i=0; i < (int) khui_n_timers; i++) {\r
#endif\r
khui_nc_timers = UBOUNDSS(i+1, KHUI_TIMER_ALLOC_INCR,\r
KHUI_TIMER_ALLOC_INCR);\r
- nt = malloc(sizeof(*nt) * khui_nc_timers);\r
+ nt = PMALLOC(sizeof(*nt) * khui_nc_timers);\r
#ifdef DEBUG\r
assert(nt);\r
#endif\r
memcpy(nt, khui_timers, sizeof(*nt) * khui_n_timers);\r
\r
- free(khui_timers);\r
+ PFREE(khui_timers);\r
khui_timers = nt;\r
}\r
\r
khui_timers[i].data = data;\r
\r
khui_timers[i].flags &= ~KHUI_TE_FLAG_STALE;\r
+ if (reinstate)\r
+ khui_timers[i].flags &= ~KHUI_TE_FLAG_EXPIRED;\r
\r
return i;\r
}\r
__int64 ft_cred_expiry;\r
__int64 ft;\r
__int64 fte;\r
+ __int64 ft_reinst;\r
khm_size cb;\r
\r
kcdb_cred_get_identity(cred, &ident);\r
/* and the current time */\r
GetSystemTimeAsFileTime((LPFILETIME) &ft_current);\r
\r
+ TimetToFileTimeInterval(KHUI_TIMEEQ_ERROR, (LPFILETIME) &ft_reinst);\r
+\r
mark_idx = tmr_find(ident, KHUI_TTYPE_ID_MARK, 0, 0);\r
\r
if (mark_idx < 0) {\r
- mark_idx = tmr_update(ident, KHUI_TTYPE_ID_MARK, 0, 0, 0);\r
+ mark_idx = tmr_update(ident, KHUI_TTYPE_ID_MARK, 0, 0, 0, FALSE);\r
kcdb_identity_hold(ident);\r
#ifdef DEBUG\r
assert(mark_idx >= 0);\r
khc_close_space(csp_id);\r
\r
if (monitor && do_renew) {\r
+ int prev;\r
+\r
TimetToFileTimeInterval(to_renew, (LPFILETIME) &ft);\r
fte = ft_expiry - ft;\r
\r
- if (fte > ft_current) {\r
- tmr_update(ident, KHUI_TTYPE_ID_RENEW, fte, ft, 0);\r
+ prev =\r
+ tmr_find(ident, KHUI_TTYPE_ID_RENEW, 0, 0);\r
+\r
+ /* we set off a renew notification immediately if the\r
+ renew threshold has passed but a renew was never sent.\r
+ This maybe because that NetIDMgr was started at the\r
+ last minute, or because for some reason the renew timer\r
+ could not be triggered earlier. */\r
+ if (fte > ft_current ||\r
+ prev == -1 ||\r
+ !(khui_timers[prev].flags & KHUI_TE_FLAG_EXPIRED)) {\r
+\r
+ if (fte <= ft_current)\r
+ fte = ft_current;\r
+\r
+ tmr_update(ident, KHUI_TTYPE_ID_RENEW, \r
+ fte, ft, 0, fte > ft_current + ft_reinst);\r
renew_done = TRUE;\r
+ } else {\r
+ /* special case. If the renew timer was in the past\r
+ and it was expired, then we retain the record as\r
+ long as the credentials are around. If the renewal\r
+ failed we don't want to automatically retry\r
+ everytime we check the timers. */\r
+ tmr_update(ident, KHUI_TTYPE_ID_RENEW,\r
+ fte, ft, 0, FALSE);\r
}\r
}\r
\r
fte = ft_expiry - ft;\r
\r
if (fte > ft_current)\r
- tmr_update(ident, KHUI_TTYPE_ID_WARN, fte, ft, 0);\r
+ tmr_update(ident, KHUI_TTYPE_ID_WARN,\r
+ fte, ft, 0, fte > ft_current + ft_reinst);\r
}\r
\r
if (monitor && do_crit && !renew_done) {\r
fte = ft_expiry - ft;\r
\r
if (fte > ft_current)\r
- tmr_update(ident, KHUI_TTYPE_ID_CRIT, fte, ft, 0);\r
+ tmr_update(ident, KHUI_TTYPE_ID_CRIT,\r
+ fte, ft, 0, fte > ft_current + ft_reinst);\r
}\r
\r
if (monitor && !renew_done) {\r
if (ft_expiry > ft_current)\r
- tmr_update(ident, KHUI_TTYPE_ID_EXP, ft_expiry, 0, 0);\r
+ tmr_update(ident, KHUI_TTYPE_ID_EXP, \r
+ ft_expiry, 0, 0, fte > ft_current + ft_reinst);\r
}\r
\r
_done_with_ident:\r
goto _cleanup;\r
\r
if ((idx = tmr_find(ident, KHUI_TTYPE_ID_WARN, 0, 0)) >= 0 &&\r
- !(khui_timers[idx].flags & KHUI_TE_FLAG_STALE)) {\r
+ !(khui_timers[idx].flags & KHUI_TE_FLAG_STALE)) {\r
\r
fte = ft_cred_expiry - khui_timers[idx].offset;\r
if (fte > ft_current) {\r
tmr_update(cred, KHUI_TTYPE_CRED_WARN, fte, \r
- khui_timers[idx].offset, 0);\r
+ khui_timers[idx].offset, 0,\r
+ fte > ft_current + ft_reinst);\r
kcdb_cred_hold(cred);\r
}\r
}\r
fte = ft_cred_expiry - khui_timers[idx].offset;\r
if (fte > ft_current) {\r
tmr_update(cred, KHUI_TTYPE_CRED_CRIT, fte,\r
- khui_timers[idx].offset, 0);\r
+ khui_timers[idx].offset, 0,\r
+ fte > ft_current + ft_reinst);\r
kcdb_cred_hold(cred);\r
}\r
}\r
fte = ft_cred_expiry - khui_timers[idx].offset;\r
if (fte > ft_current) {\r
tmr_update(cred, KHUI_TTYPE_CRED_RENEW, fte,\r
- khui_timers[idx].offset, 0);\r
+ khui_timers[idx].offset, 0,\r
+ fte > ft_current + ft_reinst);\r
kcdb_cred_hold(cred);\r
}\r
}\r
\r
if (ft_cred_expiry > ft_current) {\r
tmr_update(cred, KHUI_TTYPE_CRED_EXP, ft_cred_expiry,\r
- 0, 0);\r
+ 0, 0,\r
+ ft_cred_expiry > ft_current + ft_reinst);\r
}\r
}\r
\r
khui_n_timers = j;\r
}\r
\r
+/* go through all the credentials and set timers as appropriate. */\r
void \r
khm_timer_refresh(HWND hwnd) {\r
int i;\r
\r
next_event = 0;\r
for (i=0; i < (int) khui_n_timers; i++) {\r
- if (next_event == 0 ||\r
- (!(khui_timers[i].flags & KHUI_TE_FLAG_EXPIRED) &&\r
- khui_timers[i].type != KHUI_TTYPE_ID_MARK &&\r
+ if (!(khui_timers[i].flags & KHUI_TE_FLAG_EXPIRED) &&\r
+ khui_timers[i].type != KHUI_TTYPE_ID_MARK &&\r
+ (next_event == 0 ||\r
next_event > khui_timers[i].expire))\r
+\r
next_event = khui_timers[i].expire;\r
}\r
\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
bn.fsStyle = BTNS_SEP;\r
bn.iBitmap = 3;\r
\r
- lr = SendMessage(\r
- tb,\r
+ lr = SendMessage(tb,\r
TB_ADDBUTTONS,\r
1,\r
(LPARAM) &bn);\r
TB_ADDSTRING,\r
(WPARAM) NULL,\r
(LPARAM) buf);\r
+#if (_WIN32_IE >= 0x0501)\r
bn.fsStyle |= BTNS_SHOWTEXT;\r
+#endif\r
bn.iString = idx_caption;\r
}\r
}\r
if((opt & KHUI_TOOLBAR_ADD_BITMAP) && a->ib_normal) {\r
bn.fsStyle |= TBSTYLE_CUSTOMERASE;\r
bn.iBitmap = khui_tb_blank;\r
- } else\r
+ } else {\r
+#if (_WIN32_IE >= 0x0501)\r
bn.iBitmap = I_IMAGENONE;\r
+#endif\r
+ }\r
\r
bn.idCommand = a->cmd;\r
\r
\r
def = khui_find_menu(KHUI_TOOLBAR_STANDARD);\r
\r
- hwtb = CreateWindowEx(\r
- TBSTYLE_EX_MIXEDBUTTONS,\r
- TOOLBARCLASSNAME,\r
- (LPWSTR) NULL,\r
- WS_CHILD |\r
- TBSTYLE_FLAT |\r
- TBSTYLE_AUTOSIZE | \r
- TBSTYLE_LIST |\r
- CCS_NORESIZE | \r
- CCS_NOPARENTALIGN |\r
- CCS_ADJUSTABLE |\r
- CCS_NODIVIDER,\r
- 0, 0, 0, 0, rebar,\r
- (HMENU) NULL, khm_hInstance,\r
- NULL);\r
+ hwtb = CreateWindowEx(0\r
+#if (_WIN32_IE >= 0x0501)\r
+ | TBSTYLE_EX_MIXEDBUTTONS\r
+#endif\r
+ ,\r
+ TOOLBARCLASSNAME,\r
+ (LPWSTR) NULL,\r
+ WS_CHILD |\r
+ TBSTYLE_FLAT |\r
+ TBSTYLE_AUTOSIZE | \r
+ TBSTYLE_LIST |\r
+ CCS_NORESIZE | \r
+ CCS_NOPARENTALIGN |\r
+ CCS_ADJUSTABLE |\r
+ CCS_NODIVIDER,\r
+ 0, 0, 0, 0, rebar,\r
+ (HMENU) NULL, khm_hInstance,\r
+ NULL);\r
\r
if(!hwtb) {\r
#ifdef DEBUG\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
#define KHUI_TOOLBAR_BGCOLOR RGB(0xd7,0xd7,0xd7)\r
#define KHUI_TOOLBAR_MAX_BTNS 64\r
\r
-#endif
\ No newline at end of file
+#endif\r
KHUI_PACTION_ESC,FVIRTKEY,VK_ESCAPE,KHUI_ACCEL_SCOPE_GLOBAL\r
#KHUI_PACTION_DELETE,FVIRTKEY,VK_DELETE,KHUI_ACCEL_SCOPE_GLOBAL\r
KHUI_ACTION_DESTROY_CRED,FVIRTKEY,VK_DELETE,KHUI_ACCEL_SCOPE_GLOBAL\r
-KHUI_ACTION_EXIT,FCONTROL,\'X\',KHUI_ACCEL_SCOPE_GLOBAL\r
+KHUI_ACTION_EXIT,FCONTROL|FVIRTKEY,\'X\',KHUI_ACCEL_SCOPE_GLOBAL\r
KHUI_ACTION_VIEW_REFRESH,FVIRTKEY,VK_F5,KHUI_ACCEL_SCOPE_GLOBAL\r
-KHUI_ACTION_NEW_CRED,FCONTROL,\'N\',KHUI_ACCEL_SCOPE_GLOBAL\r
+KHUI_ACTION_NEW_CRED,FCONTROL|FVIRTKEY,\'N\',KHUI_ACCEL_SCOPE_GLOBAL\r
+KHUI_PACTION_SELALL,FCONTROL|FVIRTKEY,\'A\',KHUI_ACCEL_SCOPE_GLOBAL\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
\r
#define NOEXPORT\r
#include<khuidefs.h>\r
+#include<utils.h>\r
#include<assert.h>\r
\r
khui_action_ref khui_main_menu[] = {\r
khui_menu_create(int cmd)\r
{\r
khui_menu_def * d;\r
- d = malloc(sizeof(*d));\r
+\r
+ d = PMALLOC(sizeof(*d));\r
ZeroMemory(d, sizeof(*d));\r
\r
d->cmd = cmd;\r
d->nc_items = MENU_NC_ITEMS;\r
- d->items = malloc(sizeof(*(d->items)) * d->nc_items);\r
+ d->items = PMALLOC(sizeof(*(d->items)) * d->nc_items);\r
\r
d->state = KHUI_MENUSTATE_ALLOCD;\r
\r
\r
for(i=0; i< (int) d->n_items; i++) {\r
if(d->items[i].flags & KHUI_ACTIONREF_FREE_PACTION)\r
- free(d->items[i].p_action);\r
+ PFREE(d->items[i].p_action);\r
}\r
\r
if(d->items)\r
- free(d->items);\r
- free(d);\r
+ PFREE(d->items);\r
+ PFREE(d);\r
}\r
\r
static void khui_menu_assert_size(khui_menu_def * d, size_t n)\r
khui_action_ref * ni;\r
\r
d->nc_items = UBOUNDSS(n, MENU_NC_ITEMS, MENU_NC_ITEMS);\r
- ni = malloc(sizeof(*(d->items)) * d->nc_items);\r
+ ni = PMALLOC(sizeof(*(d->items)) * d->nc_items);\r
memcpy(ni, d->items, sizeof(*(d->items)) * d->n_items);\r
- free(d->items);\r
+ PFREE(d->items);\r
d->items = ni;\r
}\r
}\r
}\r
\r
if(delta) {\r
- kmq_send_message(KMSG_ACT, KMSG_ACT_ENABLE, 0, 0);\r
+ kmq_post_message(KMSG_ACT, KMSG_ACT_ENABLE, 0, 0);\r
}\r
}\r
\r
} else\r
return;\r
\r
- kmq_send_message(KMSG_ACT, KMSG_ACT_ENABLE, 0, 0);\r
+ kmq_post_message(KMSG_ACT, KMSG_ACT_ENABLE, 0, 0);\r
}\r
\r
KHMEXP HACCEL KHMAPI khui_create_global_accel_table(void) {\r
ACCEL * accels;\r
HACCEL ha;\r
\r
- accels = malloc(sizeof(ACCEL) * khui_n_accel_global);\r
+ accels = PMALLOC(sizeof(ACCEL) * khui_n_accel_global);\r
for(i=0;i<khui_n_accel_global;i++) {\r
accels[i].cmd = khui_accel_global[i].cmd;\r
accels[i].fVirt = khui_accel_global[i].mod;\r
\r
ha = CreateAcceleratorTable(accels, khui_n_accel_global);\r
\r
- free(accels);\r
+ PFREE(accels);\r
\r
return ha;\r
}\r
if (ctxdest->int_cb_buf < cb_total) {\r
\r
if (ctxdest->int_buf)\r
- free(ctxdest->int_buf);\r
+ PFREE(ctxdest->int_buf);\r
\r
ctxdest->int_cb_buf = cb_total;\r
- ctxdest->int_buf = malloc(cb_total);\r
+ ctxdest->int_buf = PMALLOC(cb_total);\r
}\r
\r
#ifdef DEBUG\r
khui_context_release() to free the allocated buffer */\r
#if 0\r
if (ctxsrc->vparam && ctxsrc->cb_vparam) {\r
- ctxdest->vparam = malloc(ctxsrc->cb_vparam);\r
+ ctxdest->vparam = PMALLOC(ctxsrc->cb_vparam);\r
#ifdef DEBUG\r
assert(ctxdest->vparam);\r
#endif\r
}\r
ctx->credset = NULL;\r
if (ctx->int_buf)\r
- free(ctx->int_buf);\r
+ PFREE(ctx->int_buf);\r
ctx->int_buf = NULL;\r
#if 0\r
if (ctx->vparam && ctx->cb_vparam > 0) {\r
- free(ctx->vparam);\r
+ PFREE(ctx->vparam);\r
ctx->vparam = NULL;\r
}\r
ctx->cb_vparam = 0;\r
KHUI_PACTION_CANCEL,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_PACTION_CANCEL,0,0,0\r
KHUI_PACTION_CLOSE,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_PACTION_CLOSE,0,0,0\r
KHUI_PACTION_BLANK,0,,IDB_TB_SPACE,0,IDB_TB_SPACE,IDB_TB_BLANK_SM,IDB_TB_BLANK_SM,0,0,0,KHUI_ACTIONSTATE_DISABLED\r
+KHUI_PACTION_NEXT,KHUI_ACTIONTYPE_TRIGGER,,0,0,0,0,0,IDS_PACTION_NEXT,0,0,0\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/* $Id$ */\r
\r
#include<khuidefs.h>\r
+#include<utils.h>\r
#include<assert.h>\r
\r
/***********************************************************************\r
{\r
khui_alert * a;\r
\r
- a = malloc(sizeof(*a));\r
+ a = PMALLOC(sizeof(*a));\r
ZeroMemory(a, sizeof(*a));\r
\r
a->magic = KHUI_ALERT_MAGIC;\r
\r
if(title) {\r
if(FAILED(StringCbLength(title, \r
- KHUI_MAXCB_TITLE - sizeof(wchar_t), \r
+ KHUI_MAXCB_TITLE, \r
&cb))) {\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
cb += sizeof(wchar_t);\r
}\r
\r
EnterCriticalSection(&cs_alerts);\r
if(alert->title && (alert->flags & KHUI_ALERT_FLAG_FREE_TITLE)) {\r
- free(alert->title);\r
+ PFREE(alert->title);\r
alert->title = NULL;\r
alert->flags &= ~KHUI_ALERT_FLAG_FREE_TITLE;\r
}\r
if(title) {\r
- alert->title = malloc(cb);\r
+ alert->title = PMALLOC(cb);\r
StringCbCopy(alert->title, cb, title);\r
alert->flags |= KHUI_ALERT_FLAG_FREE_TITLE;\r
}\r
assert(alert->magic == KHUI_ALERT_MAGIC);\r
\r
if (mask & ~KHUI_ALERT_FLAGMASK_RDWR)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_alerts);\r
alert->flags = \r
if(FAILED(StringCbLength(suggestion, \r
KHUI_MAXCB_MESSAGE - sizeof(wchar_t), \r
&cb))) {\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
cb += sizeof(wchar_t);\r
}\r
if(alert->suggestion && \r
(alert->flags & KHUI_ALERT_FLAG_FREE_SUGGEST)) {\r
\r
- free(alert->suggestion);\r
+ PFREE(alert->suggestion);\r
alert->suggestion = NULL;\r
alert->flags &= ~KHUI_ALERT_FLAG_FREE_SUGGEST;\r
\r
}\r
\r
if(suggestion) {\r
- alert->suggestion = malloc(cb);\r
+ alert->suggestion = PMALLOC(cb);\r
StringCbCopy(alert->suggestion, cb, suggestion);\r
alert->flags |= KHUI_ALERT_FLAG_FREE_SUGGEST;\r
}\r
if(FAILED(StringCbLength(message, \r
KHUI_MAXCB_MESSAGE - sizeof(wchar_t), \r
&cb))) {\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
cb += sizeof(wchar_t);\r
}\r
if(alert->message && \r
(alert->flags & KHUI_ALERT_FLAG_FREE_MESSAGE)) {\r
\r
- free(alert->message);\r
+ PFREE(alert->message);\r
alert->message = NULL;\r
alert->flags &= ~KHUI_ALERT_FLAG_FREE_MESSAGE;\r
\r
}\r
\r
if(message) {\r
- alert->message = malloc(cb);\r
+ alert->message = PMALLOC(cb);\r
StringCbCopy(alert->message, cb, message);\r
alert->flags |= KHUI_ALERT_FLAG_FREE_MESSAGE;\r
}\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
+KHMEXP khm_int32 KHMAPI\r
+khui_alert_queue(khui_alert * alert)\r
+{\r
+ assert(alert->magic == KHUI_ALERT_MAGIC);\r
+\r
+ khui_alert_hold(alert);\r
+ kmq_post_message(KMSG_ALERT, KMSG_ALERT_QUEUE, 0, (void *) alert);\r
+\r
+ return KHM_ERROR_SUCCESS;\r
+}\r
+\r
KHMEXP khm_int32 KHMAPI \r
khui_alert_show_simple(const wchar_t * title, \r
const wchar_t * message, \r
\r
if(alert->flags & KHUI_ALERT_FLAG_FREE_TITLE) {\r
assert(alert->title);\r
- free(alert->title);\r
+ PFREE(alert->title);\r
alert->title = NULL;\r
alert->flags &= ~KHUI_ALERT_FLAG_FREE_TITLE;\r
}\r
if(alert->flags & KHUI_ALERT_FLAG_FREE_MESSAGE) {\r
assert(alert->message);\r
- free(alert->message);\r
+ PFREE(alert->message);\r
alert->message = NULL;\r
alert->flags &= ~KHUI_ALERT_FLAG_FREE_MESSAGE;\r
}\r
if(alert->flags & KHUI_ALERT_FLAG_FREE_SUGGEST) {\r
assert(alert->suggestion);\r
- free(alert->suggestion);\r
+ PFREE(alert->suggestion);\r
alert->suggestion = NULL;\r
alert->flags &= ~KHUI_ALERT_FLAG_FREE_SUGGEST;\r
}\r
if(alert->flags & KHUI_ALERT_FLAG_FREE_STRUCT) {\r
alert->flags &= ~KHUI_ALERT_FLAG_FREE_STRUCT;\r
alert->magic = 0;\r
- free(alert);\r
+ PFREE(alert);\r
}\r
}\r
\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
#include<khuidefs.h>\r
#include<kmm.h>\r
#include<configui.h>\r
+#include<utils.h>\r
#include<assert.h>\r
\r
khm_int32 cfgui_node_serial;\r
cfgui_create_new_node(void) {\r
khui_config_node_i * node;\r
\r
- node = malloc(sizeof(*node));\r
+ node = PMALLOC(sizeof(*node));\r
#ifdef DEBUG\r
assert(node);\r
#endif\r
return;\r
\r
if (node->reg.name)\r
- free((void *) node->reg.name);\r
+ PFREE((void *) node->reg.name);\r
\r
if (node->reg.short_desc)\r
- free((void *) node->reg.short_desc);\r
+ PFREE((void *) node->reg.short_desc);\r
\r
if (node->reg.long_desc)\r
- free((void *) node->reg.long_desc);\r
+ PFREE((void *) node->reg.long_desc);\r
\r
node->magic = 0;\r
\r
\r
ZeroMemory(node, sizeof(*node));\r
\r
- free(node);\r
+ PFREE(node);\r
}\r
\r
\r
&cb_long_desc)) ||\r
(vparent &&\r
!cfgui_is_valid_node_handle(vparent)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if (KHM_SUCCEEDED(khui_cfg_open(vparent,\r
reg->name,\r
node->reg = *reg;\r
node->reg.flags &= KHUI_CNFLAGMASK_STATIC;\r
\r
- name = malloc(cb_name);\r
+ name = PMALLOC(cb_name);\r
StringCbCopy(name, cb_name, reg->name);\r
- short_desc = malloc(cb_short_desc);\r
+ short_desc = PMALLOC(cb_short_desc);\r
StringCbCopy(short_desc, cb_short_desc, reg->short_desc);\r
- long_desc = malloc(cb_long_desc);\r
+ long_desc = PMALLOC(cb_long_desc);\r
StringCbCopy(long_desc, cb_long_desc, reg->long_desc);\r
\r
node->reg.name = name;\r
!cfgui_is_valid_node_handle(vparent)) ||\r
FAILED(StringCbLength(name, KHUI_MAXCCH_NAME, &sz)) ||\r
!result)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_cfgui);\r
if (vparent)\r
khui_cfg_remove(khui_config_node vnode) {\r
khui_config_node_i * node;\r
if (!cfgui_is_valid_node_handle(vnode))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_cfgui);\r
node = cfgui_node_i_from_handle(vnode);\r
KHMEXP khm_int32 KHMAPI\r
khui_cfg_hold(khui_config_node vnode) {\r
if (!cfgui_is_valid_node_handle(vnode))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
cfgui_hold_node(cfgui_node_i_from_handle(vnode));\r
\r
KHMEXP khm_int32 KHMAPI\r
khui_cfg_release(khui_config_node vnode) {\r
if (!cfgui_is_valid_node_handle(vnode))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
cfgui_release_node(cfgui_node_i_from_handle(vnode));\r
\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
+KHMEXP khm_int32 KHMAPI\r
+khui_cfg_get_parent(khui_config_node vnode,\r
+ khui_config_node * result) {\r
+\r
+ khui_config_node_i * node;\r
+ khui_config_node_i * parent;\r
+\r
+ if(!cfgui_is_valid_node_handle(vnode) ||\r
+ !result)\r
+ return KHM_ERROR_INVALID_PARAM;\r
+\r
+ EnterCriticalSection(&cs_cfgui);\r
+ if (cfgui_is_valid_node_handle(vnode)) {\r
+ node = cfgui_node_i_from_handle(vnode);\r
+ parent = TPARENT(node);\r
+ if (parent == cfgui_root_config)\r
+ parent = NULL;\r
+ } else {\r
+ parent = NULL;\r
+ }\r
+ if (parent) {\r
+ cfgui_hold_node(parent);\r
+ }\r
+ LeaveCriticalSection(&cs_cfgui);\r
+\r
+ *result = parent;\r
+\r
+ if (parent)\r
+ return KHM_ERROR_SUCCESS;\r
+ else\r
+ return KHM_ERROR_NOT_FOUND;\r
+}\r
+\r
KHMEXP khm_int32 KHMAPI\r
khui_cfg_get_first_child(khui_config_node vparent,\r
khui_config_node * result) {\r
\r
if((vparent && !cfgui_is_valid_node_handle(vparent)) ||\r
!result)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_cfgui);\r
if (cfgui_is_valid_node_handle(vparent)) {\r
\r
if((vparent && !cfgui_is_valid_node_handle(vparent)) ||\r
!result)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_cfgui);\r
if (cfgui_is_valid_node_handle(vparent)) {\r
\r
if (!cfgui_is_valid_node_handle(vnode) ||\r
!result)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_cfgui);\r
if (cfgui_is_valid_node_handle(vnode)) {\r
\r
if (!pvnode || \r
!cfgui_is_valid_node_handle(*pvnode))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_cfgui);\r
if (cfgui_is_valid_node_handle(*pvnode)) {\r
\r
if ((vnode && !cfgui_is_valid_node_handle(vnode)) ||\r
!reg)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_cfgui);\r
if (cfgui_is_valid_node_handle(vnode)) {\r
if (node)\r
return KHM_ERROR_SUCCESS;\r
else\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
KHMEXP HWND KHMAPI\r
#ifdef DEBUG\r
assert(node->nc_data >= node->n_data + 1);\r
#endif\r
- newdata = malloc(sizeof(*newdata) * node->nc_data);\r
+ newdata = PMALLOC(sizeof(*newdata) * node->nc_data);\r
#ifdef DEBUG\r
assert(newdata);\r
#endif\r
\r
if (node->data && node->n_data > 0) {\r
memcpy(newdata, node->data, node->n_data * sizeof(*newdata));\r
- free(node->data);\r
+ PFREE(node->data);\r
}\r
node->data = newdata;\r
}\r
\r
/* called with cs_cfgui held */\r
static void\r
-recalc_node_flags(khui_config_node vnode) {\r
+recalc_node_flags(khui_config_node vnode, khm_boolean plural) {\r
khui_config_node_i * node;\r
khui_config_node_i * parent;\r
+ khui_config_node_i * subpanel;\r
+ cfg_node_data * data;\r
khm_int32 flags;\r
- khm_size i;\r
\r
#ifdef DEBUG\r
assert(cfgui_is_valid_node_handle(vnode));\r
\r
node = cfgui_node_i_from_handle(vnode);\r
\r
- parent = TPARENT(node);\r
+ if (plural)\r
+ parent = TPARENT(node);\r
+ else\r
+ parent = node;\r
#ifdef DEBUG\r
assert(parent);\r
#endif\r
\r
flags = 0;\r
\r
- /* this code is wrong. we need to go through all the subpanels in\r
- the parent and pick the data record corresponding to this node\r
- and then merge the flags from there. */\r
- /* TODO: fix this */\r
- for (i=0; i < parent->n_data; i++) {\r
- if (parent->data[i].key == vnode)\r
- flags |= parent->data[i].flags;\r
+ for(subpanel = TFIRSTCHILD(parent); subpanel;\r
+ subpanel = LNEXT(subpanel)) {\r
+ if (!(subpanel->reg.flags & KHUI_CNFLAG_SUBPANEL) ||\r
+ (plural && !(subpanel->reg.flags & KHUI_CNFLAG_PLURAL)) ||\r
+ (!plural && (subpanel->reg.flags & KHUI_CNFLAG_PLURAL)))\r
+ continue;\r
+\r
+ data = get_node_data(subpanel,\r
+ vnode,\r
+ FALSE);\r
+\r
+ if (data) {\r
+ flags |= data->flags;\r
+ }\r
}\r
\r
flags &= KHUI_CNFLAGMASK_DYNAMIC;\r
\r
- if ((node->flags & flags) != flags) {\r
- node->flags = flags |\r
- (node->flags & ~KHUI_CNFLAGMASK_DYNAMIC);\r
+ if ((node->flags & KHUI_CNFLAGMASK_DYNAMIC) == flags)\r
+ return;\r
+\r
+ node->flags = (node->flags & ~KHUI_CNFLAGMASK_DYNAMIC) | flags;\r
\r
- if (hwnd_cfgui)\r
- PostMessage(hwnd_cfgui, KHUI_WM_CFG_NOTIFY,\r
- MAKEWPARAM((WORD) node->flags, WMCFG_UPDATE_STATE),\r
- (LPARAM) vnode);\r
- }\r
+ if (hwnd_cfgui)\r
+ PostMessage(hwnd_cfgui, KHUI_WM_CFG_NOTIFY,\r
+ MAKEWPARAM((WORD) node->flags, WMCFG_UPDATE_STATE),\r
+ (LPARAM) vnode);\r
}\r
\r
KHMEXP void KHMAPI\r
data->flags = new_flags;\r
\r
if (d->ctx_node != d->ref_node)\r
- recalc_node_flags(d->ctx_node);\r
+ recalc_node_flags(d->ctx_node, TRUE);\r
+ else\r
+ recalc_node_flags(d->ctx_node, FALSE);\r
}\r
}\r
}\r
\r
if (!cb_buf ||\r
!cfgui_is_valid_node_handle(vnode))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
EnterCriticalSection(&cs_cfgui);\r
if (cfgui_is_valid_node_handle(vnode) &&\r
*cb_buf = cb;\r
}\r
} else {\r
- rv = KHM_ERROR_INVALID_PARM;\r
+ rv = KHM_ERROR_INVALID_PARAM;\r
}\r
LeaveCriticalSection(&cs_cfgui);\r
\r
khui_config_init_data * d;\r
\r
cb = sizeof(khui_config_init_data) + cb_extra;\r
- d = malloc(cb);\r
+ d = PMALLOC(cb);\r
#ifdef DEBUG\r
assert(d);\r
#endif\r
#endif\r
\r
if (d) {\r
- free(d);\r
+ PFREE(d);\r
}\r
\r
return (d)?KHM_ERROR_SUCCESS: KHM_ERROR_NOT_FOUND;\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/* $Id$ */\r
\r
#include<khuidefs.h>\r
+#include<utils.h>\r
#include<assert.h>\r
\r
#define CW_ALLOC_INCR 8\r
{\r
khui_new_creds * c;\r
\r
- c = malloc(sizeof(*c));\r
+ c = PMALLOC(sizeof(*c));\r
ZeroMemory(c, sizeof(*c));\r
\r
c->magic = KHUI_NC_MAGIC;\r
LeaveCriticalSection(&c->cs);\r
DeleteCriticalSection(&c->cs);\r
\r
- if(c->password) {\r
+ if (c->password) {\r
len = wcslen(c->password);\r
SecureZeroMemory(c->password, sizeof(wchar_t) * len);\r
- free(c->password);\r
+ PFREE(c->password);\r
}\r
\r
- if(c->identities)\r
- free(c->identities);\r
+ if (c->identities)\r
+ PFREE(c->identities);\r
\r
- if(c->types)\r
- free(c->types);\r
+ if (c->types)\r
+ PFREE(c->types);\r
+\r
+ if (c->type_subs)\r
+ PFREE(c->type_subs);\r
\r
if (c->window_title)\r
- free(c->window_title);\r
+ PFREE(c->window_title);\r
\r
- free(c);\r
+ PFREE(c);\r
\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
if(c->identities == NULL) {\r
c->nc_identities = NC_N_IDENTITIES;\r
- c->identities = malloc(sizeof(*(c->identities)) * \r
+ c->identities = PMALLOC(sizeof(*(c->identities)) * \r
c->nc_identities);\r
c->n_identities = 0;\r
} else if(c->n_identities + 1 > c->nc_identities) {\r
c->nc_identities = UBOUNDSS(c->n_identities + 1, \r
NC_N_IDENTITIES, \r
NC_N_IDENTITIES);\r
- ni = malloc(sizeof(*(c->identities)) * c->nc_identities);\r
+ ni = PMALLOC(sizeof(*(c->identities)) * c->nc_identities);\r
memcpy(ni, c->identities, \r
sizeof(*(c->identities)) * c->n_identities);\r
- free(c->identities);\r
+ PFREE(c->identities);\r
c->identities = ni;\r
}\r
\r
\r
if(c->types == NULL) {\r
c->nc_types = CW_ALLOC_INCR;\r
- c->types = malloc(sizeof(*(c->types)) * c->nc_types);\r
- c->type_subs = malloc(sizeof(*(c->type_subs)) * c->nc_types);\r
+ c->types = PMALLOC(sizeof(*(c->types)) * c->nc_types);\r
+ c->type_subs = PMALLOC(sizeof(*(c->type_subs)) * c->nc_types);\r
c->n_types = 0;\r
}\r
\r
\r
n = UBOUNDSS(c->n_types + 1, CW_ALLOC_INCR, CW_ALLOC_INCR);\r
\r
- t = malloc(sizeof(*(c->types)) * n);\r
+ t = PMALLOC(sizeof(*(c->types)) * n);\r
memcpy(t, (void *) c->types, sizeof(*(c->types)) * c->n_types);\r
- free(c->types);\r
+ PFREE(c->types);\r
c->types = t;\r
\r
- t = malloc(sizeof(*(c->type_subs)) * n);\r
+ t = PMALLOC(sizeof(*(c->type_subs)) * n);\r
memcpy(t, (void *) c->type_subs, sizeof(*(c->type_subs)) * c->n_types);\r
- free(c->type_subs);\r
+ PFREE(c->type_subs);\r
c->type_subs = t;\r
\r
c->nc_types = n;\r
if(def && FAILED(StringCbLength(def, KHUI_MAXCB_PROMPT_VALUE, &cb_def)))\r
return NULL;\r
\r
- p = malloc(sizeof(*p));\r
+ p = PMALLOC(sizeof(*p));\r
ZeroMemory(p, sizeof(*p));\r
\r
if(prompt) {\r
cb_prompt += sizeof(wchar_t);\r
- p->prompt = malloc(cb_prompt);\r
+ p->prompt = PMALLOC(cb_prompt);\r
StringCbCopy(p->prompt, cb_prompt, prompt);\r
}\r
\r
if(def) {\r
cb_def += sizeof(wchar_t);\r
- p->def = malloc(cb_def);\r
+ p->def = PMALLOC(cb_def);\r
StringCbCopy(p->def, cb_def, def);\r
}\r
\r
- p->value = malloc(KHUI_MAXCB_PROMPT_VALUE);\r
+ p->value = PMALLOC(KHUI_MAXCB_PROMPT_VALUE);\r
ZeroMemory(p->value, KHUI_MAXCB_PROMPT_VALUE);\r
\r
p->type = type;\r
if(p->prompt) {\r
if(SUCCEEDED(StringCbLength(p->prompt, KHUI_MAXCB_PROMPT, &cb)))\r
SecureZeroMemory(p->prompt, cb);\r
- free(p->prompt);\r
+ PFREE(p->prompt);\r
}\r
\r
if(p->def) {\r
if(SUCCEEDED(StringCbLength(p->def, KHUI_MAXCB_PROMPT, &cb)))\r
SecureZeroMemory(p->def, cb);\r
- free(p->def);\r
+ PFREE(p->def);\r
}\r
\r
if(p->value) {\r
if(SUCCEEDED(StringCbLength(p->value, KHUI_MAXCB_PROMPT_VALUE, &cb)))\r
SecureZeroMemory(p->value, cb);\r
- free(p->value);\r
+ PFREE(p->value);\r
}\r
\r
- free(p);\r
+ PFREE(p);\r
}\r
\r
static void \r
khm_size i;\r
\r
if(c->banner != NULL) {\r
- free(c->banner);\r
+ PFREE(c->banner);\r
c->banner = NULL;\r
}\r
\r
if(c->pname != NULL) {\r
- free(c->pname);\r
+ PFREE(c->pname);\r
c->pname = NULL;\r
}\r
\r
}\r
\r
if(c->prompts != NULL) {\r
- free(c->prompts);\r
+ PFREE(c->prompts);\r
c->prompts = NULL;\r
}\r
\r
if(SUCCEEDED(StringCbLength(banner, KHUI_MAXCB_BANNER, &cb)) && \r
cb > 0) {\r
cb += sizeof(wchar_t);\r
- c->banner = malloc(cb);\r
+ c->banner = PMALLOC(cb);\r
StringCbCopy(c->banner, cb, banner);\r
} else {\r
c->banner = NULL;\r
cb > 0) {\r
\r
cb += sizeof(wchar_t);\r
- c->pname = malloc(cb);\r
+ c->pname = PMALLOC(cb);\r
StringCbCopy(c->pname, cb, pname);\r
\r
} else {\r
}\r
\r
if(n_prompts > 0) {\r
-\r
- c->prompts = malloc(sizeof(*(c->prompts)) * n_prompts);\r
+ c->prompts = PMALLOC(sizeof(*(c->prompts)) * n_prompts);\r
ZeroMemory(c->prompts, sizeof(*(c->prompts)) * n_prompts);\r
c->nc_prompts = n_prompts;\r
c->n_prompts = 0;\r
p = cw_create_prompt(c->n_prompts, type, prompt, def, flags);\r
if(p == NULL) {\r
LeaveCriticalSection(&c->cs);\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
c->prompts[c->n_prompts++] = p;\r
LeaveCriticalSection(&c->cs);\r
if(t) {\r
t->flags &= ~KHUI_NCMASK_RESULT;\r
t->flags |= (response & KHUI_NCMASK_RESULT);\r
+\r
if (!(response & KHUI_NC_RESPONSE_NOEXIT) &&\r
!(response & KHUI_NC_RESPONSE_PENDING))\r
t->flags |= KHUI_NC_RESPONSE_COMPLETED;\r
\r
return KHM_ERROR_SUCCESS;\r
} else {\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
}\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
#define KHUI_PACTION_DOWN_EXTEND (KHUI_PACTION_BASE + 13)\r
#define KHUI_PACTION_DOWN_TOGGLE (KHUI_PACTION_BASE + 14)\r
#define KHUI_PACTION_BLANK (KHUI_PACTION_BASE + 15)\r
+#define KHUI_PACTION_NEXT (KHUI_PACTION_BASE + 16)\r
+#define KHUI_PACTION_SELALL (KHUI_PACTION_BASE + 17)\r
/*@}*/\r
\r
/*! \name Menus\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
KHMEXP khm_int32 KHMAPI \r
khui_alert_show(khui_alert * alert);\r
\r
+/*! \brief Queue an alert\r
+\r
+ Instead of displaying the alert immediately, the alert is queued\r
+ and the status bar updated to notify the user that there is a\r
+ pending alert. Once the user activates the pending alert, it will\r
+ be displayed as if khui_alert_show() was called.\r
+ */\r
+KHMEXP khm_int32 KHMAPI\r
+khui_alert_queue(khui_alert * alert);\r
+\r
/*! \brief Display a simple alert\r
\r
\see khui_alert_show()\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
required.\r
\r
\retval KHM_ERROR_SUCCESS Success\r
- \retval KHM_ERROR_INVALID_PARM One or more parameters, or fields\r
+ \retval KHM_ERROR_INVALID_PARAM One or more parameters, or fields\r
of reg were invalid\r
\retval KHM_ERROR_DUPLICATE A node with the same name exists as a\r
child of the specified parent node.\r
KHMEXP khm_int32 KHMAPI\r
khui_cfg_release(khui_config_node node);\r
\r
+/*! \brief Get the parent of a node\r
+\r
+ Returns a held handle to the parent of the node, or NULL if the\r
+ current node is a top level node. The returned handle must be\r
+ released with khui_cfg_release().\r
+\r
+ \retval KHM_ERROR_SUCCESS The handle to the parent node is in \a result\r
+ \retval KHM_ERROR_NOT_FOUND The node is a top level node\r
+ */\r
+KHMEXP khm_int32 KHMAPI\r
+khui_cfg_get_parent(khui_config_node vnode,\r
+ khui_config_node * result);\r
+\r
/*! \brief Get a handle to the first child node\r
\r
If the call is successful, \a result will receieve a handle to the\r
the function is released.\r
\r
\retval KHM_ERROR_SUCCESS The next node is now in \a node\r
- \retval KHM_ERROR_INVALID_PARM \a node was not a valid handle\r
+ \retval KHM_ERROR_INVALID_PARAM \a node was not a valid handle\r
\retval KHM_ERROR_NOT_FOUND There are no more siblings. \a node\r
is set to NULL.\r
\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
internal message. */\r
};\r
\r
+/*! \brief Plugins can use WMNC_NOTIFY message codes from here on up\r
+\r
+ \see ::KHUI_WM_NC_NOTIFY\r
+ */\r
+#define WMNC_USER 2048\r
+\r
/*! \brief Notifications to the identity provider\r
\r
These notifications are sent through to the identity provider's UI\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
used to order the pages in a property sheet. The pages are\r
ordered based on ordinal first and then alphabetically by\r
credentials type name. If the type is unavailable, then the\r
- ordering is undefined.\r
+ ordering is undefined. Ordinals for credential type property\r
+ pages can be in the range from 0 to 127. Ordinals 128 and\r
+ above are reserved. Passing in 0 will work for credentials\r
+ providers unless they provide more than one property page per\r
+ credential, in which case the ordinal should be used to\r
+ enforce an order.\r
\r
\param[in] ppage Pointer to structure that will be passed to\r
CreatePropertySheetPage() to create the property page. The\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
int lbl_y;\r
int lbl_lx;\r
int lbl_rx;\r
+ DWORD act_time;\r
\r
time_t current; /*!< Current selection */\r
time_t min; /*!< Minimum (inclusive) */\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/* $Id$ */\r
\r
#include<khuidefs.h>\r
+#include<utils.h>\r
#ifdef DEBUG\r
#include<assert.h>\r
#endif\r
\r
-KHMEXP khm_int32 KHMAPI khui_ps_create_sheet(khui_property_sheet ** sheet)\r
+CRITICAL_SECTION cs_props;\r
+\r
+void\r
+ps_init(void) {\r
+ InitializeCriticalSection(&cs_props);\r
+}\r
+\r
+void\r
+ps_exit(void) {\r
+ DeleteCriticalSection(&cs_props);\r
+}\r
+\r
+KHMEXP khm_int32 KHMAPI \r
+khui_ps_create_sheet(khui_property_sheet ** sheet)\r
{\r
khui_property_sheet * ps;\r
\r
- ps = malloc(sizeof(*ps));\r
+ ps = PMALLOC(sizeof(*ps));\r
ZeroMemory(ps, sizeof(*ps));\r
\r
ps->header.dwSize = sizeof(ps->header);\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI khui_ps_add_page(\r
- khui_property_sheet * sheet,\r
- khm_int32 credtype,\r
- khm_int32 ordinal,\r
- LPPROPSHEETPAGE ppage,\r
- khui_property_page ** page)\r
+KHMEXP khm_int32 KHMAPI \r
+khui_ps_add_page(khui_property_sheet * sheet,\r
+ khm_int32 credtype,\r
+ khm_int32 ordinal,\r
+ LPPROPSHEETPAGE ppage,\r
+ khui_property_page ** page)\r
{\r
khui_property_page * p;\r
\r
- p = malloc(sizeof(*p));\r
+ p = PMALLOC(sizeof(*p));\r
ZeroMemory(p, sizeof(*p));\r
\r
p->credtype = credtype;\r
p->ordinal = ordinal;\r
p->p_page = ppage;\r
- \r
+\r
+ EnterCriticalSection(&cs_props); \r
QPUT(sheet, p);\r
sheet->n_pages++;\r
+ LeaveCriticalSection(&cs_props);\r
\r
if(page)\r
*page = p;\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI khui_ps_find_page(\r
- khui_property_sheet * sheet,\r
- khm_int32 credtype,\r
- khui_property_page ** page)\r
+KHMEXP khm_int32 KHMAPI \r
+khui_ps_find_page(khui_property_sheet * sheet,\r
+ khm_int32 credtype,\r
+ khui_property_page ** page)\r
{\r
khui_property_page * p;\r
\r
+ EnterCriticalSection(&cs_props);\r
p = QTOP(sheet);\r
\r
while(p) {\r
break;\r
p = QNEXT(p);\r
}\r
+ LeaveCriticalSection(&cs_props);\r
\r
if(p) {\r
*page = p;\r
}\r
}\r
\r
-int __cdecl ps_order_func(const void *l, const void * r) {\r
- /* l is a ** */\r
- return 0;\r
+int __cdecl \r
+ps_order_func(const void *l, const void * r) {\r
+ khui_property_page * lp;\r
+ khui_property_page * rp;\r
+\r
+ lp = *(khui_property_page **)l;\r
+ rp = *(khui_property_page **)r;\r
+\r
+ if (lp->ordinal == rp->ordinal)\r
+ return lp->credtype - rp->credtype;\r
+ else\r
+ return lp->ordinal - rp->ordinal;\r
}\r
\r
-KHMEXP HWND KHMAPI khui_ps_show_sheet(HWND parent, khui_property_sheet * s)\r
+KHMEXP HWND KHMAPI \r
+khui_ps_show_sheet(HWND parent, khui_property_sheet * s)\r
{\r
khui_property_page * p;\r
HPROPSHEETPAGE phpsp[KHUI_PS_MAX_PSP];\r
INT_PTR prv;\r
HWND hw;\r
\r
+ EnterCriticalSection(&cs_props);\r
+\r
s->header.hwndParent = parent;\r
s->header.nPages = s->n_pages;\r
\r
#ifdef DEBUG\r
assert(p->h_page);\r
#endif\r
- ppgs[i] = p;\r
- phpsp[i++] = p->h_page;\r
+ ppgs[i++] = p;\r
p = QNEXT(p);\r
}\r
\r
- /*TODO: sort property sheets */\r
+#ifdef DEBUG\r
+ assert(i == s->n_pages);\r
+#endif\r
+\r
+ qsort(ppgs, s->n_pages, sizeof(ppgs[0]), ps_order_func);\r
+\r
+ for (i=0; i < s->n_pages; i++) {\r
+ phpsp[i] = ppgs[i]->h_page;\r
+ }\r
\r
s->header.phpage = phpsp;\r
\r
prv = PropertySheet(&s->header);\r
+\r
+ s->header.phpage = NULL;\r
+\r
if(prv <= 0) {\r
#ifdef DEBUG\r
assert(FALSE);\r
/*TODO: better handling for this */\r
hw = NULL;\r
} else {\r
- DWORD dw;\r
-\r
- dw = GetLastError();\r
s->status = KHUI_PS_STATUS_RUNNING;\r
\r
hw = (HWND) prv;\r
s->hwnd = hw;\r
s->hwnd_page = PropSheet_GetCurrentPageHwnd(hw);\r
}\r
+ LeaveCriticalSection(&cs_props);\r
\r
return hw;\r
}\r
\r
-KHMEXP LRESULT KHMAPI khui_ps_check_message(\r
- khui_property_sheet * sheet, \r
- PMSG pmsg)\r
+KHMEXP LRESULT KHMAPI \r
+khui_ps_check_message(khui_property_sheet * sheet, \r
+ PMSG pmsg)\r
{\r
LRESULT lr;\r
\r
return lr;\r
}\r
\r
-KHMEXP khm_int32 KHMAPI khui_ps_destroy_sheet(khui_property_sheet * sheet)\r
+KHMEXP khm_int32 KHMAPI \r
+khui_ps_destroy_sheet(khui_property_sheet * sheet)\r
{\r
khui_property_page * p;\r
\r
+ EnterCriticalSection(&cs_props);\r
+\r
DestroyWindow(sheet->hwnd);\r
sheet->hwnd = NULL;\r
\r
QGET(sheet, &p);\r
while(p) {\r
- free(p);\r
+ PFREE(p);\r
QGET(sheet, &p);\r
}\r
+ PFREE(sheet);\r
\r
- free(sheet);\r
+ LeaveCriticalSection(&cs_props);\r
\r
return KHM_ERROR_SUCCESS;\r
}\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/* $Id$ */\r
\r
#include<khuidefs.h>\r
-#include<hashtable.h>\r
+#include<utils.h>\r
\r
hashtable * h_bitmaps;\r
\r
BITMAPV5HEADER head;\r
HDC hdc;\r
\r
- khui_ilist * il = malloc(sizeof(khui_ilist));\r
+ khui_ilist * il = PMALLOC(sizeof(khui_ilist));\r
il->cx = cx;\r
il->cy = cy;\r
il->n = n;\r
head.bV5Reserved = 0;\r
il->img = CreateDIBitmap(hdc, (BITMAPINFOHEADER *) &head, 0, NULL, NULL, DIB_RGB_COLORS);\r
il->mask = CreateBitmap(cx * n, cy, 1, 1, NULL);\r
- il->idlist = malloc(sizeof(int) * n);\r
+ il->idlist = PMALLOC(sizeof(int) * n);\r
\r
return il;\r
}\r
khui_delete_ilist(khui_ilist * il) {\r
DeleteObject(il->img);\r
DeleteObject(il->mask);\r
- free(il->idlist);\r
- free(il);\r
+ PFREE(il->idlist);\r
+ PFREE(il);\r
\r
return TRUE;\r
}\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
TRACKBAR_CLASS,\r
L"NetIDMgrTimeTickerTrackbar",\r
WS_POPUP | TBS_AUTOTICKS | TBS_BOTTOM |\r
- TBS_DOWNISLEFT | TBS_HORZ | WS_CLIPCHILDREN,\r
+#if (_WIN32_IE >= 0x0501)\r
+ TBS_DOWNISLEFT | \r
+#endif\r
+ TBS_HORZ | WS_CLIPCHILDREN,\r
r.left,r.bottom,rs.right,rs.bottom,\r
hwnd,\r
NULL,\r
}\r
khui_tracker_reposition(tc);\r
ShowWindow(tc->hw_slider, SW_SHOWNOACTIVATE);\r
+\r
+ tc->act_time = GetTickCount();\r
//SetActiveWindow(p);\r
}\r
break;\r
}\r
return TRUE;\r
\r
+ case WM_LBUTTONUP:\r
+ if (IsWindowVisible(tc->hw_slider)) {\r
+ DWORD tm;\r
+\r
+ tm = GetTickCount();\r
+ if (tm - tc->act_time > 500)\r
+ ShowWindow(tc->hw_slider, SW_HIDE);\r
+ } else {\r
+ ShowWindow(tc->hw_slider, SW_SHOWNOACTIVATE);\r
+ }\r
+ break;\r
+\r
/* these messages can potentially change the text in the edit\r
control. We intercept them and see what changed. We may\r
need to grab and handle them */\r
case EM_UNDO:\r
case WM_UNDO:\r
case WM_CHAR:\r
+#if (_WIN32_WINNT >= 0x0501)\r
case WM_UNICHAR:\r
+#endif\r
{\r
wchar_t buf[256];\r
size_t nchars;\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
\r
extern void alert_init(void);\r
extern void alert_exit(void);\r
+extern void ps_init(void);\r
+extern void ps_exit(void);\r
\r
void\r
uilib_process_attach(void) {\r
alert_init();\r
+ ps_init();\r
}\r
\r
void\r
uilib_process_detach(void) {\r
+ ps_exit();\r
alert_exit();\r
}\r
-\r
!include <../config/Makefile.w32>\r
\r
INCFILES= \\r
- $(INCDIR)\utils.h \\r
- $(INCDIR)\hashtable.h \\r
- $(INCDIR)\mstring.h \\r
- $(INCDIR)\sync.h\r
+ $(INCDIR)\utils.h \\r
+ $(INCDIR)\hashtable.h \\r
+ $(INCDIR)\mstring.h \\r
+ $(INCDIR)\sync.h \\r
+ $(INCDIR)\perfstat.h\r
\r
OBJFILES= \\r
- $(OBJ)\hashtable.obj \\r
- $(OBJ)\mstring.obj \\r
- $(OBJ)\sync.obj\r
+ $(OBJ)\hashtable.obj \\r
+ $(OBJ)\mstring.obj \\r
+ $(OBJ)\sync.obj \\r
+ $(OBJ)\perfstat.obj\r
\r
LIBFILES=\r
\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
\r
/* $Id$ */\r
\r
+#include<perfstat.h>\r
#include<hashtable.h>\r
#include<stdlib.h>\r
\r
{\r
hashtable * h;\r
\r
- h = malloc(sizeof(hashtable));\r
+ h = PMALLOC(sizeof(hashtable));\r
\r
h->n = n;\r
h->addr = addr;\r
while(b) {\r
if(h->delr)\r
h->delr(b->key, b->data);\r
- free(b);\r
+ PFREE(b);\r
LPOP(&h->bins[i], &b);\r
}\r
}\r
\r
- free(h);\r
+ PFREE(h);\r
}\r
\r
KHMEXP void KHMAPI hash_add(hashtable * h, void * key, void * data) {\r
}\r
\r
if(!b) {\r
- b = malloc(sizeof(hash_bin));\r
+ b = PMALLOC(sizeof(hash_bin));\r
b->data = data;\r
b->key = key;\r
LINIT(b);\r
LDELETE(&h->bins[hv], b);\r
if(h->delr)\r
h->delr(b->key, b->data);\r
- free(b);\r
+ PFREE(b);\r
break;\r
}\r
b = LNEXT(b);\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
-* Copyright (c) 2004 Massachusetts Institute of Technology\r
+* Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
\r
KHMEXP khm_int32 KHMAPI\r
multi_string_init(wchar_t * ms,\r
- khm_size cb_ms) {\r
+ khm_size cb_ms) {\r
if (!ms || cb_ms < sizeof(wchar_t) * 2)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
memset(ms, 0, cb_ms);\r
\r
}\r
\r
KHMEXP khm_int32 KHMAPI \r
-multi_string_append(\r
- wchar_t * ms,\r
- khm_size * pcb_ms,\r
- const wchar_t * str)\r
+multi_string_append(wchar_t * ms,\r
+ khm_size * pcb_ms,\r
+ const wchar_t * str)\r
{\r
wchar_t * s;\r
size_t cch_s;\r
size_t cch_r;\r
\r
if(!ms || !pcb_ms || !str)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if(FAILED(StringCchLength(str, KHM_MAXCCH_STRING, &cch_s)) || cch_s == 0)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
cch_s++;\r
\r
s = ms;\r
\r
while(*s && ((s - ms) < KHM_MAXCCH_STRING)) {\r
if(FAILED(StringCchLength(s, KHM_MAXCB_STRING, &cch_t)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
s += cch_t + 1;\r
}\r
\r
if(*s || (s - ms) >= KHM_MAXCCH_STRING) {\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
}\r
\r
/* now s points to the second NULL of the terminating double NULL */\r
}\r
\r
KHMEXP khm_int32 KHMAPI \r
-multi_string_prepend(\r
- wchar_t * ms,\r
- khm_size * pcb_ms,\r
- const wchar_t * str)\r
+multi_string_prepend(wchar_t * ms,\r
+ khm_size * pcb_ms,\r
+ const wchar_t * str)\r
{\r
size_t cch_s;\r
size_t cch_t;\r
khm_size cb_r;\r
\r
if(!ms || !pcb_ms || !str)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if(FAILED(StringCchLength(str, KHM_MAXCCH_STRING, &cch_s)) || cch_s == 0)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
cch_s++;\r
\r
if(KHM_FAILED(multi_string_length_cch(ms,\r
KHM_MAXCCH_STRING,\r
&cch_r)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
cch_t = cch_s + cch_r;\r
cb_r = cch_t * sizeof(wchar_t);\r
}\r
\r
KHMEXP khm_int32 KHMAPI \r
-multi_string_delete(\r
- wchar_t * ms,\r
- const wchar_t * str,\r
- const khm_int32 flags)\r
+multi_string_delete(wchar_t * ms,\r
+ const wchar_t * str,\r
+ const khm_int32 flags)\r
{\r
wchar_t * s;\r
wchar_t * n;\r
size_t cch;\r
\r
if(!ms || !str)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
s = multi_string_find(ms, str, flags);\r
if(!s)\r
n = NULL;\r
while(*e && (e - s) < KHM_MAXCCH_STRING) {\r
if(FAILED(StringCchLength(e, KHM_MAXCCH_STRING, &cch)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
e += cch + 1;\r
\r
if(!n)\r
}\r
\r
if(*e || (e - s) >= KHM_MAXCCH_STRING)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
if(e == s)\r
return KHM_ERROR_SUCCESS;\r
}\r
\r
KHMEXP wchar_t * KHMAPI \r
-multi_string_find(\r
- const wchar_t * ms,\r
- const wchar_t * str,\r
- const khm_int32 flags)\r
+multi_string_find(const wchar_t * ms,\r
+ const wchar_t * str,\r
+ const khm_int32 flags)\r
{\r
const wchar_t *s;\r
size_t cch;\r
}\r
\r
KHMEXP khm_int32 KHMAPI \r
-multi_string_to_csv(\r
- wchar_t * csvbuf,\r
- khm_size * pcb_csvbuf,\r
- const wchar_t * ms)\r
+multi_string_to_csv(wchar_t * csvbuf,\r
+ khm_size * pcb_csvbuf,\r
+ const wchar_t * ms)\r
{\r
size_t cb;\r
size_t cbt;\r
wchar_t * d;\r
\r
if(!pcb_csvbuf || !ms)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
/* dry run */\r
cbt = 0;\r
khm_boolean quotes = FALSE;\r
\r
if(FAILED(StringCbLength(t, KHM_MAXCB_STRING, &cb)))\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
cb += sizeof(wchar_t);\r
\r
cbt += cb;\r
}\r
\r
if(cbt > KHM_MAXCB_STRING)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
/* happens if the multi string contained no strings */\r
if(cbt == 0)\r
}\r
\r
KHMEXP khm_int32 KHMAPI \r
-csv_to_multi_string(\r
- wchar_t * ms,\r
- khm_size * pcb_ms,\r
- const wchar_t * csv)\r
+csv_to_multi_string(wchar_t * ms,\r
+ khm_size * pcb_ms,\r
+ const wchar_t * csv)\r
{\r
const wchar_t * t;\r
wchar_t * p;\r
\r
\r
if(!pcb_ms || !csv)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
cchr = 0;\r
\r
}\r
\r
if((t - csv) >= KHM_MAXCCH_STRING)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
cchr++; /* last string ends */\r
cchr++; /* double NULL */\r
\r
KHMEXP khm_int32 KHMAPI \r
multi_string_length_cb(const wchar_t * str, \r
- khm_size max_cb, \r
- khm_size * len_cb)\r
+ khm_size max_cb, \r
+ khm_size * len_cb)\r
{\r
khm_size cch;\r
khm_int32 rv;\r
\r
KHMEXP khm_int32 KHMAPI \r
multi_string_length_cch(const wchar_t * str, \r
- khm_size max_cch, \r
- khm_size * len_cch)\r
+ khm_size max_cch, \r
+ khm_size * len_cch)\r
{\r
const wchar_t * s;\r
khm_size cch;\r
size_t tcch;\r
\r
if(!str)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
s = str;\r
cch = 0;\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
\r
if(!s_dest)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
rv = multi_string_length_cb(src, max_cb_dest, &cb_dest);\r
if(KHM_FAILED(rv))\r
\r
KHMEXP khm_int32 KHMAPI \r
multi_string_copy_cch(wchar_t * s_dest, \r
- khm_size max_cch_dest, \r
- const wchar_t * src)\r
+ khm_size max_cch_dest, \r
+ const wchar_t * src)\r
{\r
khm_size cch_dest;\r
khm_int32 rv = KHM_ERROR_SUCCESS;\r
\r
if(!s_dest)\r
- return KHM_ERROR_INVALID_PARM;\r
+ return KHM_ERROR_INVALID_PARAM;\r
\r
rv = multi_string_length_cch(src, max_cch_dest, &cch_dest);\r
if(KHM_FAILED(rv))\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
\retval KHM_ERROR_TOO_LONG The buffer pointed to by \a ms was\r
insufficient. The required size of the buffer is in \a pcb_ms\r
\r
- \retval KHM_ERROR_INVALID_PARM One of more of the parameters were invalid.\r
+ \retval KHM_ERROR_INVALID_PARAM One of more of the parameters were invalid.\r
*/\r
KHMEXP khm_int32 KHMAPI \r
multi_string_append(wchar_t * ms,\r
\r
\retval KHM_ERROR_NOT_FOUND No matches were found\r
\r
- \retval KHM_ERROR_INVALID_PARM One or more parameters were incorrect.\r
+ \retval KHM_ERROR_INVALID_PARAM One or more parameters were incorrect.\r
\r
\note The search for the existing string is done with\r
multi_string_find()\r
was NULL. The required number of bytes in the buffer is in \a\r
pcb_csvbuf.\r
\r
- \retval KHM_ERROR_INVALID_PARM One or more parameters were ivnalid.\r
+ \retval KHM_ERROR_INVALID_PARAM One or more parameters were ivnalid.\r
\r
\see csv_to_multi_string()\r
*/\r
ms was NULL. The required size of the buffer in bytes is in \a\r
pcb_ms.\r
\r
- \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid.\r
+ \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid.\r
\r
*/\r
KHMEXP khm_int32 KHMAPI \r
is successful.\r
\r
\retval KHM_ERROR_SUCCESS The length of the string is in \a len_cb\r
- \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid\r
+ \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid\r
\retval KHM_ERROR_TOO_LONG The multi string is longer than \a\r
max_cb bytes.\r
*/\r
is successful.\r
\r
\retval KHM_ERROR_SUCCESS The length of the string is in \a len_cch\r
- \retval KHM_ERROR_INVALID_PARM One or more parameters were invalid\r
+ \retval KHM_ERROR_INVALID_PARAM One or more parameters were invalid\r
\retval KHM_ERROR_TOO_LONG The multi string is longer than \a\r
max_cch characters.\r
*/\r
\param[in] src The source multi string\r
\r
\retval KHM_ERROR_SUCCESS The multi string was copied successfully\r
- \retval KHM_ERROR_INVALID_PARM One or more parameters were\r
+ \retval KHM_ERROR_INVALID_PARAM One or more parameters were\r
invalid.\r
\retval KHM_ERROR_TOO_LONG The size of the destination buffer was\r
insufficient.\r
\param[in] src The source multi string\r
\r
\retval KHM_ERROR_SUCCESS The multi string was copied successfully\r
- \retval KHM_ERROR_INVALID_PARM One or more parameters were\r
+ \retval KHM_ERROR_INVALID_PARAM One or more parameters were\r
invalid.\r
\retval KHM_ERROR_TOO_LONG The size of the destination buffer was\r
insufficient.\r
--- /dev/null
+/*\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#include<windows.h>\r
+#include<utils.h>\r
+#include<malloc.h>\r
+#include<stdio.h>\r
+#include<strsafe.h>\r
+#include<assert.h>\r
+\r
+#define HASHSIZE 1151\r
+#define ALLOCBLOCK 1024\r
+\r
+#define HASHPTR(p) (((size_t) (p)) % HASHSIZE)\r
+\r
+typedef struct tag_allocation {\r
+ char file[8];\r
+ int line;\r
+ size_t size;\r
+ void * ptr;\r
+\r
+ LDCL(struct tag_allocation);\r
+} allocation;\r
+\r
+static allocation * ht[HASHSIZE];\r
+\r
+static allocation * next_alloc = NULL;\r
+static size_t idx_next_alloc = 0;\r
+static allocation * free_alloc = NULL;\r
+\r
+static CRITICAL_SECTION cs_alloc;\r
+static LONG ctr = 0;\r
+static int perf_ready = 0;\r
+\r
+static void perf_once(void) {\r
+ if (InterlockedIncrement(&ctr) == 1) {\r
+ InitializeCriticalSection(&cs_alloc);\r
+ ZeroMemory(ht, sizeof(ht));\r
+\r
+ next_alloc = malloc(sizeof(allocation) * ALLOCBLOCK);\r
+ assert(next_alloc);\r
+ idx_next_alloc = 0;\r
+ free_alloc = NULL;\r
+\r
+ perf_ready = 1;\r
+ } else {\r
+ while(!perf_ready) {\r
+ Sleep(0); /* relinquish control to the thread\r
+ that is initializing the alloc\r
+ data. */\r
+ }\r
+ }\r
+}\r
+\r
+static allocation * get_allocation(void) {\r
+ allocation * a;\r
+\r
+ LPOP(&free_alloc, &a);\r
+ if (!a) {\r
+ if (idx_next_alloc == ALLOCBLOCK) {\r
+ next_alloc = malloc(sizeof(allocation) * ALLOCBLOCK);\r
+ assert(next_alloc);\r
+ idx_next_alloc = 0;\r
+ }\r
+\r
+ a = &next_alloc[idx_next_alloc];\r
+ idx_next_alloc++;\r
+ }\r
+\r
+ return a;\r
+}\r
+\r
+#define MAXCB_STR 32768\r
+\r
+KHMEXP wchar_t *\r
+perf_wcsdup(char * file, int line, const wchar_t * str) {\r
+ size_t cb;\r
+ wchar_t * dest;\r
+\r
+ if (FAILED(StringCbLength(str, MAXCB_STR, &cb)))\r
+ return NULL;\r
+ cb += sizeof(wchar_t);\r
+\r
+ dest = (wchar_t *) perf_malloc(file, line, cb);\r
+ StringCbCopy(dest, cb, str);\r
+\r
+ return dest;\r
+}\r
+\r
+KHMEXP char *\r
+perf_strdup(char * file, int line, const char * str) {\r
+ size_t cb;\r
+ char * dest;\r
+\r
+ if (FAILED(StringCbLengthA(str, MAXCB_STR, &cb)))\r
+ return NULL;\r
+ cb += sizeof(char);\r
+\r
+ dest = (char *) perf_malloc(file, line, cb);\r
+ StringCbCopyA(dest, cb, str);\r
+\r
+ return dest;\r
+}\r
+\r
+KHMEXP void * \r
+perf_malloc(char * file, int line, size_t s) {\r
+ allocation * a;\r
+ void * ptr;\r
+ size_t h;\r
+\r
+ perf_once();\r
+\r
+ assert(s > 0);\r
+\r
+ EnterCriticalSection(&cs_alloc);\r
+ a = get_allocation();\r
+\r
+ ptr = malloc(s);\r
+\r
+ assert(ptr); /* TODO: handle this gracefully */\r
+\r
+ if (file[0] == '.' && file[1] == '\\')\r
+ file += 2;\r
+\r
+ StringCbCopyA(a->file, sizeof(a->file), file);\r
+ a->line = line;\r
+ a->size = s;\r
+ a->ptr = ptr;\r
+\r
+ h = HASHPTR(ptr);\r
+\r
+ LPUSH(&ht[h], a);\r
+ LeaveCriticalSection(&cs_alloc);\r
+\r
+ return ptr;\r
+}\r
+\r
+KHMEXP void *\r
+perf_realloc(char * file, int line, void * data, size_t s) {\r
+ void * n_data;\r
+ allocation * a;\r
+ size_t h;\r
+\r
+ if (data == NULL)\r
+ return perf_malloc(file, line, s);\r
+\r
+ perf_once();\r
+ h = HASHPTR(data);\r
+\r
+ n_data = realloc(data, s);\r
+\r
+ assert(n_data);\r
+\r
+ EnterCriticalSection(&cs_alloc);\r
+ for (a = ht[h]; a; a = LNEXT(a)) {\r
+ if (a->ptr == data)\r
+ break;\r
+ }\r
+\r
+ assert(a);\r
+\r
+ LDELETE(&ht[h], a);\r
+\r
+ a->size = s;\r
+ a->ptr = n_data;\r
+\r
+ h = HASHPTR(n_data);\r
+ LPUSH(&ht[h], a);\r
+ LeaveCriticalSection(&cs_alloc);\r
+\r
+ return n_data;\r
+}\r
+\r
+KHMEXP void\r
+perf_free (void * b) {\r
+ size_t h;\r
+ allocation * a;\r
+\r
+ perf_once();\r
+ h = HASHPTR(b);\r
+\r
+ EnterCriticalSection(&cs_alloc);\r
+ for(a = ht[h]; a; a = LNEXT(a)) {\r
+ if (a->ptr == b)\r
+ break;\r
+ }\r
+\r
+ assert(a);\r
+\r
+ LDELETE(&ht[h], a);\r
+ LPUSH(&free_alloc, a);\r
+ LeaveCriticalSection(&cs_alloc);\r
+}\r
+\r
+KHMEXP void\r
+perf_dump(char * file) {\r
+ FILE * f;\r
+ size_t i;\r
+ allocation * a;\r
+ size_t total = 0;\r
+\r
+ perf_once();\r
+\r
+ EnterCriticalSection(&cs_alloc);\r
+ f = fopen(file, "w");\r
+ if (!f)\r
+ return;\r
+\r
+ fprintf(f, "Leaked allocations list ....\n");\r
+ fprintf(f, "File\tLine\tSize\n");\r
+\r
+ for (i=0; i < HASHSIZE; i++) {\r
+ for (a = ht[i]; a; a = LNEXT(a)) {\r
+ fprintf(f, "%s\t%6d\t%6d\n", a->file, a->line, a->size);\r
+ total += a->size;\r
+ }\r
+ }\r
+\r
+ fprintf(f, "----------------------------------------\n");\r
+ fprintf(f, "Total\t\t%d\n", total);\r
+ fprintf(f, "----------------- End ------------------\n");\r
+\r
+ fclose(f);\r
+\r
+ LeaveCriticalSection(&cs_alloc);\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person\r
+ * obtaining a copy of this software and associated documentation\r
+ * files (the "Software"), to deal in the Software without\r
+ * restriction, including without limitation the rights to use, copy,\r
+ * modify, merge, publish, distribute, sublicense, and/or sell copies\r
+ * of the Software, and to permit persons to whom the Software is\r
+ * furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be\r
+ * included in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS\r
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\r
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
+ * SOFTWARE.\r
+ */\r
+\r
+/* $Id$ */\r
+\r
+#ifndef __KHIMAIRA_PERFSTAT_H\r
+#define __KHIMAIRA_PERFSTAT_H\r
+\r
+#include<khdefs.h>\r
+\r
+#ifdef DEBUG\r
+#define PMALLOC(s) perf_malloc(__FILE__,__LINE__,s)\r
+#define PREALLOC(d,s) perf_realloc(__FILE__,__LINE__,d,s)\r
+#define PFREE(p) perf_free(p)\r
+#define PDUMP(f) perf_dump(f)\r
+#define PWCSDUP(s) perf_wcsdup(__FILE__,__LINE__,s)\r
+#define PSTRDUP(s) perf_strdup(__FILE__,__LINE__,s)\r
+#else\r
+#define PMALLOC(s) malloc(s)\r
+#define PREALLOC(d,s) realloc(d,s)\r
+#define PFREE(p) free(p)\r
+#define PDUMP(f) ((void) 0)\r
+#define PWCSDUP(s) wcsdup(s)\r
+#define PSTRDUP(s) strdup(s)\r
+#endif\r
+\r
+KHMEXP void *\r
+perf_malloc(char * file, int line, size_t s);\r
+\r
+KHMEXP void *\r
+perf_realloc(char * file, int line, void * data, size_t s);\r
+\r
+KHMEXP void\r
+perf_free (void * b);\r
+\r
+KHMEXP void\r
+perf_dump (char * filename);\r
+\r
+KHMEXP wchar_t *\r
+perf_wcsdup(char * file, int line, const wchar_t * str);\r
+\r
+KHMEXP char *\r
+perf_strdup(char * file, int line, const char * str);\r
+\r
+#endif\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
DeleteCriticalSection(&(pLock->cs));\r
CloseHandle(pLock->readwx);\r
CloseHandle(pLock->writewx);\r
+ pLock->readwx = NULL;\r
+ pLock->writewx = NULL;\r
}\r
\r
KHMEXP void KHMAPI LockObtainRead(PRWLOCK pLock)\r
pLock->writer == GetCurrentThreadId()) {\r
pLock->locks++;\r
LeaveCriticalSection(&(pLock->cs));\r
+ assert(FALSE);\r
return;\r
}\r
LeaveCriticalSection(&(pLock->cs));\r
}\r
pLock->status = LOCK_WRITING;\r
pLock->locks++;\r
+ pLock->writer = GetCurrentThreadId();\r
ResetEvent(pLock->readwx);\r
LeaveCriticalSection(&(pLock->cs));\r
}\r
pLock->locks--;\r
if(!pLock->locks) {\r
pLock->status = LOCK_OPEN;\r
+ pLock->writer = 0;\r
SetEvent(pLock->readwx);\r
SetEvent(pLock->writewx);\r
}\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
/*\r
- * Copyright (c) 2004 Massachusetts Institute of Technology\r
+ * Copyright (c) 2005 Massachusetts Institute of Technology\r
*\r
* Permission is hereby granted, free of charge, to any person\r
* obtaining a copy of this software and associated documentation\r
#include<hashtable.h>\r
#include<sync.h>\r
#include<mstring.h>\r
+#include<perfstat.h>\r
\r
#endif\r