diff options
-rw-r--r-- | src/Makefile.in | 36 | ||||
-rw-r--r-- | src/ccapi/Makefile.in | 31 | ||||
-rw-r--r-- | src/ccapi/common/win/OldCC/ccutils.c | 2 | ||||
-rw-r--r-- | src/ccapi/common/win/OldCC/util.cxx | 7 | ||||
-rw-r--r-- | src/ccapi/common/win/tls.c | 47 | ||||
-rw-r--r-- | src/ccapi/common/win/tls.h | 7 | ||||
-rw-r--r-- | src/ccapi/common/win/win-utils.c | 3 | ||||
-rw-r--r-- | src/ccapi/lib/win/OldCC/client.cxx | 4 | ||||
-rw-r--r-- | src/ccapi/lib/win/ccapi_os_ipc.cxx | 23 | ||||
-rw-r--r-- | src/ccapi/lib/win/ccs_reply_proc.c | 3 | ||||
-rw-r--r-- | src/ccapi/lib/win/dllmain.cxx | 77 | ||||
-rw-r--r-- | src/ccapi/lib/win/dllmain.h | 7 | ||||
-rw-r--r-- | src/ccapi/server/win/ccs_os_server.cpp | 4 | ||||
-rw-r--r-- | src/ccapi/server/win/ccs_win_pipe.c | 2 | ||||
-rw-r--r-- | src/ccapi/test/Makefile.in | 145 | ||||
-rw-r--r-- | src/ccapi/test/Pingtest.sln | 20 | ||||
-rw-r--r-- | src/ccapi/test/pingtest.c | 10 | ||||
-rw-r--r-- | src/ccapi/test/setlib.pl | 10 | ||||
-rw-r--r-- | src/ccapi/test/test_ccapi.bat | 43 | ||||
-rw-r--r-- | src/ccapi/test/test_ccapi_util.c | 2 | ||||
-rw-r--r-- | src/config/win-pre.in | 2 | ||||
-rw-r--r-- | src/windows/build/bkw.pl | 25 |
22 files changed, 367 insertions, 143 deletions
diff --git a/src/Makefile.in b/src/Makefile.in index 055fb5d8b7..3fbc950263 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -15,6 +15,9 @@ LOCALINCLUDES = -I$(srcdir) SRCS = HDRS = +# Why aren't these flags showing up in Windows builds? +##DOS##CPPFLAGS=$(CPPFLAGS) -D_X86_=1 -DWIN32 -D_WIN32 -W3 -D_WINNT + DISTFILES = $(SRCS) $(HDRS) COPYING COPYING.LIB ChangeLog Makefile.in all-unix:: krb5-config @@ -36,6 +39,12 @@ all-windows:: maybe-awk Makefile-windows @echo Making autoconf.h in include cd include $(MAKE) -$(MFLAGS) autoconf.h + + @echo Making in ccapi + cd ..\ccapi + cd + $(MAKE) -$(MFLAGS) + @echo Making in util cd ..\util $(MAKE) -$(MFLAGS) @@ -171,6 +180,10 @@ config-windows:: Makefile-windows WINMAKEFILES=Makefile \ appl\gss-sample\Makefile \ appl\gssftp\ftp\Makefile \ + ccapi\Makefile \ + ccapi\lib\win\Makefile \ + ccapi\server\win\Makefile \ + ccapi\test\Makefile \ clients\Makefile clients\kdestroy\Makefile \ clients\kinit\Makefile clients\klist\Makefile \ clients\kpasswd\Makefile clients\kvno\Makefile \ @@ -215,6 +228,14 @@ WINMAKEFILES=Makefile \ ##DOS## $(WCONFIG) config < $@.in > $@ ##DOS##appl\gssftp\ftp\Makefile: appl\gssftp\ftp\Makefile.in $(MKFDEP) ##DOS## $(WCONFIG) config < $@.in > $@ +##DOS##ccapi\Makefile: ccapi\Makefile.in $(MKFDEP) +##DOS## $(WCONFIG) config < $@.in > $@ +##DOS##ccapi\lib\win\Makefile: ccapi\lib\win\Makefile.in $(MKFDEP) +##DOS## $(WCONFIG) config < $@.in > $@ +##DOS##ccapi\server\win\Makefile: ccapi\server\win\Makefile.in $(MKFDEP) +##DOS## $(WCONFIG) config < $@.in > $@ +##DOS##ccapi\test\Makefile: ccapi\test\Makefile.in $(MKFDEP) +##DOS## $(WCONFIG) config < $@.in > $@ ##DOS##clients\Makefile: clients\Makefile.in $(MKFDEP) ##DOS## $(WCONFIG) config < $@.in > $@ ##DOS##clients\kdestroy\Makefile: clients\kdestroy\Makefile.in $(MKFDEP) @@ -344,10 +365,10 @@ clean-windows:: Makefile-windows @echo Making clean in clients cd ..\clients $(MAKE) -$(MFLAGS) clean - @echo Making in appl\gss-sample + @echo Making clean in appl\gss-sample cd ..\appl\gss-sample $(MAKE) -$(MFLAGS) clean - @echo Making in appl\gssftp\ftp + @echo Making clean in appl\gssftp\ftp cd ..\..\appl\gssftp\ftp $(MAKE) -$(MFLAGS) clean cd ..\..\.. @@ -365,7 +386,7 @@ ren2long: # ZIP=zip FILES= ./* \ - clients/* clients/kdestroy/* clients/kinit/* clients/klist/* \ + clients/* clients/kdestroy/* clients/kinit/* clients/klist/* \ clients/kpasswd/* clients/kcpytkt/* clients/kdeltkt/* \ config/* include/* include/kerberosIV/* \ include/krb5/* include/krb5/stock/* include/sys/* krb524/* lib/* \ @@ -383,7 +404,12 @@ FILES= ./* \ lib/krb5/os/* lib/krb5/posix/* lib/krb5/rcache/* \ util/* util/et/* util/profile/* -WINFILES= util/windows/* windows/* windows/lib/* windows/cns/* \ +WINFILES= \ + ccapi/common/* ccapi/common/win/* ccapi/common/win/OldCC/* \ + ccapi/lib/* ccapi/lib/win/* ccapi/lib/win/OldCC/* \ + ccapi/server/* ccapi/server/win/* \ + ccapi\test\* \ + util/windows/* windows/* windows/lib/* windows/cns/* \ windows/wintel/* windows/gss/* windows/gina/* windows/ms2mit/* \ windows/kfwlogon/* @@ -575,6 +601,8 @@ install-windows:: $(CP) appl\gss-sample\$(OUTPRE)gss-client.exe "$(KRB_INSTALL_DIR)\bin\." $(CP) windows\ms2mit\$(OUTPRE)ms2mit.exe "$(KRB_INSTALL_DIR)\bin\." $(CP) appl\gssftp\ftp\$(OUTPRE)ftp.exe "$(KRB_INSTALL_DIR)\bin\." + $(CP) ccapi\lib\win\$(OUTPRE)ccapi.dll "$(KRB_INSTALL_DIR)\bin\." + $(CP) ccapi\server\win\$(OUTPRE)ccapiserver.exe "$(KRB_INSTALL_DIR)\bin\." $(CP) clients\kvno\$(OUTPRE)kvno.exe "$(KRB_INSTALL_DIR)\bin\." $(CP) clients\klist\$(OUTPRE)klist.exe "$(KRB_INSTALL_DIR)\bin\." $(CP) clients\kinit\$(OUTPRE)kinit.exe "$(KRB_INSTALL_DIR)\bin\." diff --git a/src/ccapi/Makefile.in b/src/ccapi/Makefile.in index ae4232917a..7cf8080552 100644 --- a/src/ccapi/Makefile.in +++ b/src/ccapi/Makefile.in @@ -3,8 +3,35 @@ myfulldir=ccapi mydir=ccapi BUILDTOP=$(REL).. -LOCAL_SUBDIRS= common lib server +LOCAL_SUBDIRS= lib server test -all-unix:: +all-windows:: + @echo Making in ccapi\lib\win + @echo buildtop: $(BUILDTOP) + cd lib\win + cd + $(MAKE) -$(MFLAGS) + @echo Making in ccapi\server\win + cd ..\..\server\win + cd + $(MAKE) -$(MFLAGS) + @echo Making in ccapi\test + cd ..\..\test + cd + $(MAKE) -$(MFLAGS) + +clean-windows:: + @echo Making clean in ccapi\lib\win + cd lib\win + cd + $(MAKE) -$(MFLAGS) clean + @echo Making clean in ccapi\server\win + cd ..\..\server\win + cd + $(MAKE) -$(MFLAGS) clean + @echo Making clean in ccapi\test + cd ..\..\test + cd + $(MAKE) -$(MFLAGS) clean # +++ Dependency line eater +++ diff --git a/src/ccapi/common/win/OldCC/ccutils.c b/src/ccapi/common/win/OldCC/ccutils.c index bfe1389978..d1b39cc383 100644 --- a/src/ccapi/common/win/OldCC/ccutils.c +++ b/src/ccapi/common/win/OldCC/ccutils.c @@ -25,6 +25,8 @@ */ #include <windows.h> +#include <stdlib.h> +#include <malloc.h> #include "cci_debugging.h" #include "util.h" diff --git a/src/ccapi/common/win/OldCC/util.cxx b/src/ccapi/common/win/OldCC/util.cxx index 8694c373ce..dd4a2694ac 100644 --- a/src/ccapi/common/win/OldCC/util.cxx +++ b/src/ccapi/common/win/OldCC/util.cxx @@ -26,15 +26,16 @@ #include <windows.h> #include <stdio.h> // for _snprintf - -#include "util.h" -#include "secure.hxx" +#include <malloc.h> +#include <stdlib.h> extern "C" { #include "cci_debugging.h" #include "ccutils.h" } +#include "util.h" +#include "secure.hxx" void* malloc_alloc_p(size_t size) { diff --git a/src/ccapi/common/win/tls.c b/src/ccapi/common/win/tls.c index cf8daa3b26..45020b5707 100644 --- a/src/ccapi/common/win/tls.c +++ b/src/ccapi/common/win/tls.c @@ -25,6 +25,8 @@ */ #include "string.h" +#include <stdlib.h> +#include <malloc.h> #include "tls.h" @@ -58,14 +60,47 @@ void tspdata_setSST (struct tspdata* p, time_t t) {p->_sst void tspdata_setStream (struct tspdata* p, cci_stream_t s) {p->_stream = s;} -BOOL tspdata_getConnected (struct tspdata* p) {return p->_CCAPI_Connected;} +BOOL tspdata_getConnected (const struct tspdata* p) {return p->_CCAPI_Connected;} -HANDLE tspdata_getReplyEvent(struct tspdata* p) {return p->_replyEvent;} +HANDLE tspdata_getReplyEvent(const struct tspdata* p) {return p->_replyEvent;} -time_t tspdata_getSST (const struct tspdata* p) {return p->_sst;} +time_t tspdata_getSST (const struct tspdata* p) {return p->_sst;} -cci_stream_t tspdata_getStream (const struct tspdata* p) {return p->_stream;} +cci_stream_t tspdata_getStream (const struct tspdata* p) {return p->_stream;} + +char* tspdata_getUUID (const struct tspdata* p) {return p->_uuid;} + +RPC_ASYNC_STATE* tspdata_getRpcAState (const struct tspdata* p) {return p->_rpcState;} + +BOOL WINAPI PutTspData(DWORD dwTlsIndex, struct tspdata* dw) { + LPVOID lpvData; + struct tspdata** pData; // The stored memory pointer + + // Retrieve a data pointer for the current thread: + lpvData = TlsGetValue(dwTlsIndex); + + // If NULL, allocate memory for the TLS slot for this thread: + if (lpvData == NULL) { + lpvData = (LPVOID) LocalAlloc(LPTR, sizeof(struct tspdata)); + if (lpvData == NULL) return FALSE; + if (!TlsSetValue(dwTlsIndex, lpvData)) return FALSE; + } + + pData = (struct tspdata**) lpvData; // Cast to my data type. + // In this example, it is only a pointer to a DWORD + // but it can be a structure pointer to contain more complicated data. + + (*pData) = dw; + return TRUE; + } + +BOOL WINAPI GetTspData(DWORD dwTlsIndex, struct tspdata** pdw) { + struct tspdata* pData; // The stored memory pointer + + pData = (struct tspdata*)TlsGetValue(dwTlsIndex); + if (pData == NULL) return FALSE; + (*pdw) = pData; + return TRUE; + } -char* tspdata_getUUID (const struct tspdata* p) {return p->_uuid;} -RPC_ASYNC_STATE* tspdata_getRpcAState (const struct tspdata* p) {return p->_rpcState;} diff --git a/src/ccapi/common/win/tls.h b/src/ccapi/common/win/tls.h index 3d988cd694..1a6086888b 100644 --- a/src/ccapi/common/win/tls.h +++ b/src/ccapi/common/win/tls.h @@ -31,13 +31,14 @@ #include "windows.h" #include "time.h" +#include "rpc.h" #include "cci_stream.h" #define UUID_SIZE 128 -/* The client code can be run in any client thread. The thread-specific data - is defined here. +/* The client code can be run in any client thread. + The thread-specific data is defined here. */ struct tspdata { @@ -66,5 +67,7 @@ time_t tspdata_getSST (const struct tspdata* p); cci_stream_t tspdata_getStream (const struct tspdata* p); char* tspdata_getUUID (const struct tspdata* p); +BOOL WINAPI PutTspData(DWORD tlsIndex, struct tspdata* dw); +BOOL WINAPI GetTspData(DWORD tlsIndex, struct tspdata** pdw); #endif _tls_h diff --git a/src/ccapi/common/win/win-utils.c b/src/ccapi/common/win/win-utils.c index 4cba153a9e..f60ee3b8f4 100644 --- a/src/ccapi/common/win/win-utils.c +++ b/src/ccapi/common/win/win-utils.c @@ -28,6 +28,9 @@ #include <string.h> #include <time.h> #include "windows.h" +#include <stdlib.h> +#include <malloc.h> + #include "win-utils.h" #include "cci_debugging.h" diff --git a/src/ccapi/lib/win/OldCC/client.cxx b/src/ccapi/lib/win/OldCC/client.cxx index 4928d4c536..ed8712339a 100644 --- a/src/ccapi/lib/win/OldCC/client.cxx +++ b/src/ccapi/lib/win/OldCC/client.cxx @@ -124,10 +124,10 @@ DWORD find_server(Init::InitInfo& info, LPSTR endpoint) { psa = isNT() ? &sa : 0; -// cci_debug_printf("%s Looking for server; ccs_request_IfHandle:0x%X", __FUNCTION__, ccs_request_IfHandle); + cci_debug_printf("%s Looking for server; ccs_request_IfHandle:0x%X", __FUNCTION__, ccs_request_IfHandle); status = cci_check_error(RpcMgmtIsServerListening(ccs_request_IfHandle)); if (status == RPC_S_NOT_LISTENING) { -// cci_debug_printf(" Server *NOT* found!"); + cci_debug_printf(" Server *NOT* found!"); si.cb = sizeof(si); status = alloc_module_dir_name(CCAPI_DLL, &szDir); diff --git a/src/ccapi/lib/win/ccapi_os_ipc.cxx b/src/ccapi/lib/win/ccapi_os_ipc.cxx index 770e75b6a8..7fc57b3925 100644 --- a/src/ccapi/lib/win/ccapi_os_ipc.cxx +++ b/src/ccapi/lib/win/ccapi_os_ipc.cxx @@ -27,21 +27,22 @@ extern "C" { #include "k5-thread.h" #include "ccapi_os_ipc.h" -#include "tls.h" -#include "dllmain.h" +#include "cci_debugging.h" #include "ccs_reply.h" #include "ccs_request.h" -#include "win-utils.h" #include "ccutils.h" +#include "tls.h" #include "util.h" +#include "win-utils.h" } +#include "autolock.hxx" #include "CredentialsCache.h" #include "secure.hxx" #include "opts.hxx" #include "client.h" -#include "autolock.hxx" -#include "cci_debugging.h" + +extern "C" DWORD GetTlsIndex(); #define SECONDS_TO_WAIT 10 #define CLIENT_REQUEST_RPC_HANDLE ccs_request_IfHandle @@ -81,7 +82,7 @@ extern "C" cc_int32 cci_os_ipc_thread_init (void) { UUID __RPC_FAR uuid; unsigned char __RPC_FAR* uuidString = NULL; - if (!GetTspData(&ptspdata)) return ccErrNoMem; + if (!GetTspData(GetTlsIndex(), &ptspdata)) return ccErrNoMem; opts.cMinCalls = 1; opts.cMaxCalls = 20; @@ -150,7 +151,7 @@ extern "C" cc_int32 cci_os_ipc_msg( cc_int32 in_launch_server, if (!in_request_stream) { err = cci_check_error (ccErrBadParam); } if (!out_reply_stream ) { err = cci_check_error (ccErrBadParam); } - if (!GetTspData(&ptspdata)) {return ccErrBadParam;} + if (!GetTspData(GetTlsIndex(), &ptspdata)) {return ccErrBadParam;} bCCAPI_Connected = tspdata_getConnected (ptspdata); replyEvent = tspdata_getReplyEvent (ptspdata); sst = tspdata_getSST (ptspdata); @@ -187,7 +188,7 @@ extern "C" cc_int32 cci_os_ipc_msg( cc_int32 in_launch_server, // New code using new RPC procedures for sending the data and receiving a reply: if (!err) { RpcTryExcept { - if (!GetTspData(&ptspdata)) {return ccErrBadParam;} + if (!GetTspData(GetTlsIndex(), &ptspdata)) {return ccErrBadParam;} uuid = tspdata_getUUID(ptspdata); lenUUID = 1 + strlen(uuid); /* 1+ includes terminating \0. */ cci_debug_printf("%s calling remote ccs_rpc_request tsp*:0x%X", __FUNCTION__, ptspdata); @@ -216,9 +217,9 @@ extern "C" cc_int32 cci_os_ipc_msg( cc_int32 in_launch_server, // Wait for reply handler to set event: if (!err) { - cci_debug_printf(" Waiting for request reply."); +// cci_debug_printf(" Waiting for request reply."); err = cci_check_error(WaitForSingleObject(replyEvent, INFINITE));//(SECONDS_TO_WAIT)*1000)); - cci_debug_printf(" Request reply received!"); +// cci_debug_printf(" Request reply received!"); } if (!err) { @@ -237,8 +238,6 @@ extern "C" cc_int32 cci_os_ipc_msg( cc_int32 in_launch_server, if (!err) { *out_reply_stream = tspdata_getStream(ptspdata); } - - cci_debug_printf(" payload:<%s>", cci_stream_data(*out_reply_stream)); return cci_check_error (err); } diff --git a/src/ccapi/lib/win/ccs_reply_proc.c b/src/ccapi/lib/win/ccs_reply_proc.c index f9eef87fff..8d17bfc053 100644 --- a/src/ccapi/lib/win/ccs_reply_proc.c +++ b/src/ccapi/lib/win/ccs_reply_proc.c @@ -51,8 +51,7 @@ void ccs_rpc_request_reply( long status = 0; cci_debug_printf("%s! msg#:%d SST:%ld uuid:%s", __FUNCTION__, rpcmsg, srvStartTime, uuid); - cci_debug_printf(" payload:<%s>", chIn); - cci_debug_printf(" uuid from handle:<%s>", tspdata_getUUID(tsp)); +// cci_debug_printf(" uuid from handle:<%s>", tspdata_getUUID(tsp)); if (!status) { status = cci_stream_new (&stream); /* Create a stream for the request data */ diff --git a/src/ccapi/lib/win/dllmain.cxx b/src/ccapi/lib/win/dllmain.cxx index dafbab28c1..e37a9ad6bf 100644 --- a/src/ccapi/lib/win/dllmain.cxx +++ b/src/ccapi/lib/win/dllmain.cxx @@ -24,19 +24,20 @@ * or implied warranty. */ +extern "C" { #include <windows.h> #include <LMCons.h> -extern "C" { #include "dllmain.h" #include "tls.h" #include "cci_debugging.h" #include "ccapi_context.h" #include "client.h" -//void cci_thread_init__auxinit(); +void cci_thread_init__auxinit(); } + #define CCAPI_V2_MUTEX_NAME TEXT("MIT_CCAPI_V4_MUTEX") // Process-specific data: @@ -52,6 +53,8 @@ DWORD firstThreadID = 0; static Init init; static Client client; +DWORD GetTlsIndex() {return dwTlsIndex;} + // DllMain() is the entry-point function for this DLL. BOOL WINAPI DllMain(HINSTANCE hinstDLL, // DLL module handle DWORD fdwReason, // reason called @@ -196,72 +199,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, // DLL module handle extern "C" { // we need to export the C interface #endif -__declspec(dllexport) -BOOL WINAPI PutTspData(struct tspdata* dw) { - LPVOID lpvData; - struct tspdata** pData; // The stored memory pointer - - // Retrieve a data pointer for the current thread: - lpvData = TlsGetValue(dwTlsIndex); - - // If NULL, allocate memory for the TLS slot for this thread: - if (lpvData == NULL) { - lpvData = (LPVOID) LocalAlloc(LPTR, sizeof(struct tspdata)); - if (lpvData == NULL) return FALSE; - if (!TlsSetValue(dwTlsIndex, lpvData)) return FALSE; - } - - pData = (struct tspdata**) lpvData; // Cast to my data type. - // In this example, it is only a pointer to a DWORD - // but it can be a structure pointer to contain more complicated data. - - (*pData) = dw; - return TRUE; - } - -__declspec(dllexport) -BOOL WINAPI GetTspData(struct tspdata** pdw) { - struct tspdata* pData; // The stored memory pointer - - pData = (struct tspdata*)TlsGetValue(dwTlsIndex); - if (pData == NULL) return FALSE; - (*pdw) = pData; - return TRUE; - } - -#if 0 // replaced by clientEndpoint / serverEndpoint. -__declspec(dllexport) -char* WINAPI getEndpoint(enum EndpointType ep) { - // The server endpoint is of the form CCS_<LSID> - // The client endpoint is of the form CCAPI_<uuid> - // Each client thread can have its own connection. - // - // NB: Caller must free the data the returned char* points to. - struct tspdata* pData; - char* s; - char* uuid; - unsigned int len; - - switch (ep) { - case EPT_SERVER: - s = (char*)malloc(32); // Length of CCS_<DWORD> - sprintf(s, "%s_%ld", ep_prefices[EPT_SERVER], sessionToken); - break; - case EPT_CLIENT: - GetTspData(&pData); - uuid = tspdata_getUUID(pData); - len = 4 + strlen(ep_prefices[ep]) + strlen(_user) + strlen(uuid); - s = (char*)malloc(len); - sprintf(s, "%s_%s_%s", ep_prefices[EPT_CLIENT], _user, uuid); - break; - default:; - } - cci_debug_printf("%s(%d) returning %s", __FUNCTION__, ep, s); - - return s; - } -#endif - #ifdef __cplusplus } #endif @@ -270,10 +207,10 @@ char* WINAPI getEndpoint(enum EndpointType ep) { /* MIDL allocate and free */ /*********************************************************************/ -void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len) { +extern "C" void __RPC_FAR * __RPC_USER MIDL_user_allocate(size_t len) { return(malloc(len)); } -void __RPC_USER midl_user_free(void __RPC_FAR * ptr) { +extern "C" void __RPC_USER MIDL_user_free(void __RPC_FAR * ptr) { free(ptr); } diff --git a/src/ccapi/lib/win/dllmain.h b/src/ccapi/lib/win/dllmain.h index 8c585721c0..abf6afd4ab 100644 --- a/src/ccapi/lib/win/dllmain.h +++ b/src/ccapi/lib/win/dllmain.h @@ -29,15 +29,12 @@ #include "windows.h" -enum EndpointType {EPT_SERVER=0, EPT_CLIENT}; - #ifdef __cplusplus // If used by C++ code, extern "C" { // we need to export the C interface #endif -__declspec(dllexport) BOOL WINAPI PutTspData(struct tspdata* p); -__declspec(dllexport) BOOL WINAPI GetTspData(struct tspdata** p); -//__declspec(dllexport) char* WINAPI getEndpoint(enum EndpointType); +DWORD GetTlsIndex(); + #ifdef __cplusplus } #endif diff --git a/src/ccapi/server/win/ccs_os_server.cpp b/src/ccapi/server/win/ccs_os_server.cpp index 0c3f7660ee..61392e9a34 100644 --- a/src/ccapi/server/win/ccs_os_server.cpp +++ b/src/ccapi/server/win/ccs_os_server.cpp @@ -941,10 +941,10 @@ RPC_STATUS RPC_ENTRY sec_callback( IN RPC_IF_ID *Interface, /* MIDL allocate and free */
/*********************************************************************/
-void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len) {
+extern "C" void __RPC_FAR * __RPC_USER midl_user_allocate(size_t len) {
return(malloc(len));
}
-void __RPC_USER midl_user_free(void __RPC_FAR * ptr) {
+extern "C" void __RPC_USER midl_user_free(void __RPC_FAR * ptr) {
free(ptr);
}
diff --git a/src/ccapi/server/win/ccs_win_pipe.c b/src/ccapi/server/win/ccs_win_pipe.c index a8fea2f384..7c61371272 100644 --- a/src/ccapi/server/win/ccs_win_pipe.c +++ b/src/ccapi/server/win/ccs_win_pipe.c @@ -25,6 +25,8 @@ */ #include "assert.h" +#include <stdlib.h> +#include <malloc.h> #include "ccs_win_pipe.h" #include "cci_debugging.h" diff --git a/src/ccapi/test/Makefile.in b/src/ccapi/test/Makefile.in index f0c10cb9ca..7e71dcf63e 100644 --- a/src/ccapi/test/Makefile.in +++ b/src/ccapi/test/Makefile.in @@ -1,34 +1,110 @@ -thisconfigdir=../.. -myfulldir=ccapi/test -mydir=ccapi/test +thisconfigdir=..$(S).. +myfulldir=ccapi$(S)test +mydir=ccapi$(S)test +BUILDTOP=..$(S).. + +!if defined(KRB5_KFW_COMPILE) +KFWINC= /I$(BUILDTOP)\..\..\krbcc\include +!endif + +# Because all the sources are in ., +# the only includes we need are to directories outside of ccapi. +LOCALINCLUDES = /I$(BUILDTOP) /I$(BUILDTOP)$(S)include /I$(BUILDTOP)$(S)include$(S)krb5 $(KFWINC) \ + -I$(BUILDTOP)$(S)util$(S)et /I. # run with "make all" to create CCAPI tests in "/tmp/ccapi_test" # run resulting tests with "sh test_ccapi.sh" -LIBS = -lkrb5 +##DOS##CPPFLAGS = $(CPPFLAGS) /EHsc -D_CRTAPI1=_cdecl -D_CRTAPI2=_cdecl -DWINVER=0x0501 \ +##DOS## -D_WIN32_WINNT=0x0501 -D_CRT_SECURE_NO_WARNINGS -SRCDIR = src -DSTROOT = /tmp -OBJDIR = $(DSTROOT)/ccapi_intermediates -DSTDIR = $(DSTROOT)/ccapi_test -TESTDIR = $(DSTDIR)/tests - -SCRIPT_NAME = test_ccapi.sh +##DOS##WINH = cci_debugging.h \ +##DOS## ccs_reply.h \ +##DOS## ccs_request.h \ +##DOS## ccs_request_c.c \ +##DOS## cci_stream.h \ +##DOS## cci_types.h \ +##DOS## win-utils.h -OBJECTS = test_ccapi_ccache.o test_ccapi_check.o test_ccapi_constants.o test_ccapi_context.o test_ccapi_globals.o test_ccapi_iterators.o test_ccapi_log.o test_ccapi_util.o -_OBJECTS = $(OBJECTS:.o=) +SRCDIR = . +DSTROOT = $(SRCDIR) +OBJDIR = $(DSTROOT)$(S)ccapi_intermediates +DSTDIR = $(DSTROOT)$(S)ccapi_test +TESTDIR = $(DSTDIR)$(S)tests -TEST_OBJECTS = test_constants.o test_cc_initialize.o test_cc_context_get_version.o test_cc_context_release.o test_cc_context_get_change_time.o test_cc_context_get_default_ccache_name.o test_cc_context_open_ccache.o test_cc_context_open_default_ccache.o test_cc_context_create_ccache.o test_cc_context_create_default_ccache.o test_cc_context_create_new_ccache.o test_cc_context_new_ccache_iterator.o test_cc_context_compare.o test_cc_ccache_release.o test_cc_ccache_destroy.o test_cc_ccache_set_default.o test_cc_ccache_get_credentials_version.o test_cc_ccache_get_name.o test_cc_ccache_get_principal.o test_cc_ccache_set_principal.o test_cc_ccache_store_credentials.o test_cc_ccache_remove_credentials.o test_cc_ccache_new_credentials_iterator.o test_cc_ccache_get_change_time.o test_cc_ccache_get_last_default_time.o test_cc_ccache_move.o test_cc_ccache_compare.o test_cc_ccache_get_kdc_time_offset.o test_cc_ccache_set_kdc_time_offset.o test_cc_ccache_clear_kdc_time_offset.o test_cc_ccache_iterator_next.o test_cc_credentials_iterator_next.o -TEST_NAMES = $(TEST_OBJECTS:.o=) +SCRIPT_NAME = test_ccapi.sh -all: setup-test-dir simple_lock_test build-base build-tests link-tests copy-script success-message +OBJECTS = $(OUTPRE)test_ccapi_ccache.$(OBJEXT) \ + $(OUTPRE)test_ccapi_check.$(OBJEXT) \ + $(OUTPRE)test_ccapi_constants.$(OBJEXT) \ + $(OUTPRE)test_ccapi_context.$(OBJEXT) \ + $(OUTPRE)test_ccapi_globals.$(OBJEXT) \ + $(OUTPRE)test_ccapi_iterators.$(OBJEXT) \ + $(OUTPRE)test_ccapi_log.$(OBJEXT) \ + $(OUTPRE)test_ccapi_util.$(OBJEXT) + +PINGOBJS = $(OUTPRE)ccs_request_c.$(OBJEXT) \ + $(OUTPRE)pingtest.$(OBJEXT) \ + $(OBJECTS) + +TEST_NAMES = test_constants \ + test_cc_initialize \ + test_cc_context_get_version + +MORE_TESTS = test_cc_context_release \ + test_cc_context_get_change_time \ + test_cc_context_get_default_ccache_name \ + test_cc_context_open_ccache \ + test_cc_context_open_default_ccache \ + test_cc_context_create_ccache \ + test_cc_context_create_default_ccache \ + test_cc_context_create_new_ccache \ + test_cc_context_new_ccache_iterator \ + test_cc_context_compare \ + test_cc_ccache_release \ + test_cc_ccache_destroy \ + test_cc_ccache_set_default \ + test_cc_ccache_get_credentials_version \ + test_cc_ccache_get_name \ + test_cc_ccache_get_principal \ + test_cc_ccache_set_principal \ + test_cc_ccache_store_credentials \ + test_cc_ccache_remove_credentials \ + test_cc_ccache_new_credentials_iterator \ + test_cc_ccache_get_change_time \ + test_cc_ccache_get_last_default_time \ + test_cc_ccache_move \ + test_cc_ccache_compare \ + test_cc_ccache_get_kdc_time_offset \ + test_cc_ccache_set_kdc_time_offset \ + test_cc_ccache_clear_kdc_time_offset \ + test_cc_ccache_iterator_next \ + test_cc_credentials_iterator_next + +##### Linker +LINK = link +LIBS = -lkrb5 +##DOS##LIBS = advapi32.lib rpcrt4.lib user32.lib ws2_32.lib ccapi.lib +LFLAGS = /nologo $(LOPTS) + +all-mac:: setup-test-dir pingtest stop_here simple_lock_test build-base build-tests link-tests copy-script success-message +all-windows:: setup-windows build-base $(OUTPRE)pingtest.exe build-tests copy-script stop_here success-message # compile base files used by all tests -build-base: $(OBJECTS) +build-base: $(PINGOBJS) +##++ These two rules build each element of the list: # compile each test -build-tests: $(TEST_OBJECTS) - +build-tests: $(TEST_NAMES) + @echo build-tests complete. + +$(TEST_NAMES): + @echo DBG: $@ + $(CC) $(ALL_CFLAGS) -Fe$(TESTDIR)$(S)$@.exe -Fd$(OBJDIR)$(S)$@.obj $@.c $(OBJECTS) $(LIBS) +# Clean .obj from .: + $(RM) $@.$(OBJEXT) +##-- These two rules build each element of the list. + # Make a build directory setup-test-dir: @echo "Removing old destination directory... $(DSTDIR)" @@ -36,12 +112,35 @@ setup-test-dir: mkdir -p "$(TESTDIR)" if [ -d "$(OBJDIR)" ]; then chmod -R u+w "$(OBJDIR)" && rm -rf "$(OBJDIR)"; fi mkdir -p "$(OBJDIR)" + +## The same trick as used in TEST_NAMES to run an action on each element ofthe list WINH: +setup-windows: $(WINH) + if NOT exist $(TESTDIR) mkdir $(TESTDIR) + if NOT exist $(OBJDIR) mkdir $(OBJDIR) + set LINK = link + +# This rule assumes that nmake in ..\lib\win has already run. +# That is how ..\Makefile.in is set up. +$(WINH): + copy ..\lib\win\srctmp\$@ . + +# This rule assumes that nmake in ..\lib\win\ has already run. +$(OUTPRE)pingtest.exe: $(OBJECTS) +# There doesn't appear to be any way to examine a variable and return a value +# indicating whether a string is present in it. We use a perl script to +# check the LIB variable. If the path to ccapi.lib isn't present, the script +# deletes a.tmp and the following nmake actions correct LIB. + echo %%PATH%% > a.tmp + perl setlib.pl + if not exist a.tmp ( + @echo Adding ..\lib\win\srctmp to LIB + set LIB=%%LIB%%;..\lib\win\srctmp + ) + $(LINK) $(linkdebug) /map:$(@B)1.map -out:$(*B)1.exe $(conflags) $(PINGOBJS) $(LIBS) + $(LINK) $(LFLAGS) /map:$(@B)2.map /out:$(*B)2.exe $(conflags) $(PINGOBJS) $(LIBS) $(conlibsdll) link-tests: $(TEST_NAMES) -$(TEST_NAMES): $(TEST_OBJECTS) - $(CC) -o $(TESTDIR)/$@ $(OBJDIR)/$@.o $(OBJECTS) $(LIBS) - simple_lock_test: $(CC) -o $(TESTDIR)/simple_lock_test simple_lock_test.c $(LIBS) @@ -54,5 +153,5 @@ success-message: .PHONY: clean -clean: +clean:: -rm -rf "$(OBJDIR)" diff --git a/src/ccapi/test/Pingtest.sln b/src/ccapi/test/Pingtest.sln new file mode 100644 index 0000000000..cf43a1e4f6 --- /dev/null +++ b/src/ccapi/test/Pingtest.sln @@ -0,0 +1,20 @@ +
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Pingtest", "Pingtest.vcproj", "{04017001-3222-43C4-A03C-8423B5349276}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {04017001-3222-43C4-A03C-8423B5349276}.Debug|Win32.ActiveCfg = Debug|Win32
+ {04017001-3222-43C4-A03C-8423B5349276}.Debug|Win32.Build.0 = Debug|Win32
+ {04017001-3222-43C4-A03C-8423B5349276}.Release|Win32.ActiveCfg = Release|Win32
+ {04017001-3222-43C4-A03C-8423B5349276}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/src/ccapi/test/pingtest.c b/src/ccapi/test/pingtest.c index a2499118f6..637f8ab183 100644 --- a/src/ccapi/test/pingtest.c +++ b/src/ccapi/test/pingtest.c @@ -4,6 +4,8 @@ #include <stdio.h> #include <stdarg.h> +#include <stdlib.h> +#include <malloc.h> #include "cci_debugging.h" #include "CredentialsCache.h" @@ -20,11 +22,15 @@ extern cc_int32 cci_os_ipc_msg( cc_int32 in_launch_server, cc_int32 in_msg, cci_stream_t* out_reply_stream); +static DWORD dwTlsIndex; + +DWORD GetTlsIndex() {return dwTlsIndex;} + RPC_STATUS send_test(char* endpoint) { unsigned char* pszNetworkAddress = NULL; unsigned char* pszOptions = NULL; unsigned char* pszStringBinding = NULL; - unsigned char* pszUuid = NULL; + unsigned char* pszUuid = NULL; RPC_STATUS status; status = RpcStringBindingCompose(pszUuid, @@ -67,6 +73,8 @@ int main( int argc, char *argv[]) { char* message = "Hello, RPC!"; + if ((dwTlsIndex = TlsAlloc()) == TLS_OUT_OF_INDEXES) return FALSE; + // send_test("krbcc.229026.0.ep"); #if 0 diff --git a/src/ccapi/test/setlib.pl b/src/ccapi/test/setlib.pl new file mode 100644 index 0000000000..bba2250668 --- /dev/null +++ b/src/ccapi/test/setlib.pl @@ -0,0 +1,10 @@ +#!perl -w
+
+$b = "lib\\win\\srctmp";
+$a = $ENV{LIB};
+if (! ($a =~ /$b/) ) {
+ print "$b Not in LIB!\n";
+ system("del a.tmp");
+ }
+else {print "$b in LIB.\n";}
+exit(0);
\ No newline at end of file diff --git a/src/ccapi/test/test_ccapi.bat b/src/ccapi/test/test_ccapi.bat new file mode 100644 index 0000000000..2d5bec53b7 --- /dev/null +++ b/src/ccapi/test/test_ccapi.bat @@ -0,0 +1,43 @@ +# test_ccapi.bat
+
+@echo "\nBeginning test of CCAPI...\n"
+@echo "\nThese tests are based on the CCAPI v3 revision 8 draft documentation.\n"
+
+#run_test simple_lock_test
+
+teststest_constants.exe
+tests\test_cc_initialize.exe
+tests\test_cc_context_get_version.exe
+exit 0
+
+tests\test_cc_context_release.exe
+tests\test_cc_context_get_change_time.exe
+tests\test_cc_context_get_default_ccache_name.exe
+tests\test_cc_context_open_ccache.exe
+tests\test_cc_context_open_default_ccache.exe
+tests\test_cc_context_create_ccache.exe
+tests\test_cc_context_create_default_ccache.exe
+tests\test_cc_context_create_new_ccache.exe
+tests\test_cc_context_new_ccache_iterator.exe
+tests\test_cc_context_compare.exe
+tests\test_cc_ccache_release.exe
+tests\test_cc_ccache_destroy.exe
+tests\test_cc_ccache_set_default.exe
+tests\test_cc_ccache_get_credentials_version.exe
+tests\test_cc_ccache_get_name.exe
+tests\test_cc_ccache_get_principal.exe
+tests\test_cc_ccache_set_principal.exe
+tests\test_cc_ccache_store_credentials.exe
+tests\test_cc_ccache_remove_credentials.exe
+tests\test_cc_ccache_new_credentials_iterator.exe
+tests\test_cc_ccache_get_change_time.exe
+tests\test_cc_ccache_get_last_default_time.exe
+tests\test_cc_ccache_move.exe
+tests\test_cc_ccache_compare.exe
+tests\test_cc_ccache_get_kdc_time_offset.exe
+tests\test_cc_ccache_set_kdc_time_offset.exe
+tests\test_cc_ccache_clear_kdc_time_offset.exe
+tests\test_cc_ccache_iterator_next.exe
+tests\test_cc_credentials_iterator_next.exe
+
+@echo "Finished testing CCAPI."
diff --git a/src/ccapi/test/test_ccapi_util.c b/src/ccapi/test/test_ccapi_util.c index fde6946fea..282ec74b56 100644 --- a/src/ccapi/test/test_ccapi_util.c +++ b/src/ccapi/test/test_ccapi_util.c @@ -3,6 +3,8 @@ #include <stdio.h> #include <stdarg.h> #include <stdlib.h> + +#include "k5-platform.h" #include "test_ccapi_util.h" diff --git a/src/config/win-pre.in b/src/config/win-pre.in index 7393526590..25dcaa9180 100644 --- a/src/config/win-pre.in +++ b/src/config/win-pre.in @@ -141,7 +141,7 @@ DEBUGOPT=/Zi !else CCLINKOPTION= SCLIB= -DEBUGOPT=/ZI +DEBUGOPT=/Zi !endif #if the compiler is vstudio 8, generate manifest diff --git a/src/windows/build/bkw.pl b/src/windows/build/bkw.pl index ee93203bfe..24c32a035d 100644 --- a/src/windows/build/bkw.pl +++ b/src/windows/build/bkw.pl @@ -164,9 +164,6 @@ sub main { ##++ Assemble configuration from config file and command line: my $bOutputCleaned = 0; - -#while ($v = each %$OPT) {print "$v: $OPT->{$v}\n";} - # Scan the configuration for switch definitions: while (($sw, $val) = each %$odr) { next if (! exists $val->{def}); ## ?? Should always exist. @@ -174,7 +171,10 @@ sub main { # Set/clear environment variables: if ($val->{env}) { if ($val->{def}) {$ENV{$sw} = (exists $val->{value}) ? $val->{value} : 1; } - else {delete $ENV{$sw}; } + else { + delete $ENV{$sw}; + undef $sw; + } } # If the switch is in the command line, override the stored value: @@ -184,14 +184,20 @@ sub main { $val->{def} = 1; } else { - $val->{def} = $OPT->{$sw}; ## If no<switch>, value will be zero. + $val->{def} = $OPT->{$sw}; ## If -NO<switch>, value will be zero. } } # If the switch can be negated, test that, too: if ( ! ($val->{def} =~ /A/)) { local $nosw = "no".$sw; - if (exists $OPT->{$nosw}) { - $val->{def} = 0; + if (exists $OPT->{$sw}) { ## -NO<environment variable> ? + if ($val->{env}) { + if (!$val->{def}) { + print "Deleting environment variable $sw\n"; + delete $ENV{$sw}; + undef $sw; + } + } } } @@ -315,6 +321,9 @@ sub main { $l->no_die_handler; ## Needed so XML::Simple won't throw exceptions. } + print "Command line options:\n"; + while ($v = each %$OPT) {print "$v: $OPT->{$v}\n";} + print "Executing $cmdline\n"; local $argvsize = @ARGV; local $nmakeargs = ""; @@ -687,4 +696,4 @@ sub main { $SIG{'INT'} = \&handler; $SIG{'QUIT'} = \&handler; -exit(main());
\ No newline at end of file +exit(main()); |