From 4b2ab4975121a51150cf4db64e49f2a6c96d779b Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Tue, 5 Feb 2008 18:33:20 +0000 Subject: more eol-style git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20218 dc483132-0cff-0310-8789-dd5450dbe970 --- src/ccapi/common/win/OldCC/autolock.hxx | 106 ++-- src/ccapi/common/win/OldCC/ccutil.cxx | 374 +++++------ src/ccapi/common/win/OldCC/ccutil.def | 8 +- src/ccapi/common/win/OldCC/init.cxx | 374 +++++------ src/ccapi/common/win/OldCC/init.hxx | 204 +++--- src/ccapi/common/win/OldCC/opts.cxx | 376 +++++------ src/ccapi/common/win/OldCC/opts.hxx | 112 ++-- src/ccapi/common/win/OldCC/secure.cxx | 320 +++++----- src/ccapi/common/win/OldCC/secure.hxx | 120 ++-- src/ccapi/common/win/OldCC/util.cxx | 1038 +++++++++++++++---------------- src/ccapi/common/win/ccs_reply.Acf | 62 +- src/ccapi/common/win/ccs_reply.Idl | 120 ++-- src/ccapi/common/win/ccs_request.Acf | 62 +- src/ccapi/common/win/ccs_request.idl | 116 ++-- 14 files changed, 1696 insertions(+), 1696 deletions(-) (limited to 'src/ccapi/common') diff --git a/src/ccapi/common/win/OldCC/autolock.hxx b/src/ccapi/common/win/OldCC/autolock.hxx index 9fc759514..bbd773488 100644 --- a/src/ccapi/common/win/OldCC/autolock.hxx +++ b/src/ccapi/common/win/OldCC/autolock.hxx @@ -1,53 +1,53 @@ -/* - - Copyright (C) 1998 Danilo Almeida. All rights reserved. - - automatic stack-based locking object - - This file is part of FIFS (Framework for Implementing File Systems). - - This software is distributed with NO WARRANTY OF ANY KIND. No - author or distributor accepts any responsibility for the - consequences of using it, or for whether it serves any particular - purpose or works at all, unless he or she says so in writing. - Refer to the included modified Alladin Free Public License (the - "License") for full details. - - Every copy of this software must include a copy of the License, in - a plain ASCII text file named COPYING. The License grants you the - right to copy, modify and redistribute this software, but only - under certain conditions described in the License. Among other - things, the License requires that the copyright notice and this - notice be preserved on all copies. - -*/ - -#ifndef __AUTOLOCK_HXX__ -#define __AUTOLOCK_HXX__ - -#include - -class CcOsLock { - CRITICAL_SECTION cs; - bool valid; -public: - CcOsLock() {InitializeCriticalSection(&cs); valid = true; } - ~CcOsLock() {DeleteCriticalSection(&cs); valid = false;} - void lock() {if (valid) EnterCriticalSection(&cs);} - void unlock() {if (valid) LeaveCriticalSection(&cs);} -#if 0 - bool trylock() {return valid ? (TryEnterCriticalSection(&cs) ? true : false) - : false; } -#endif -}; - -class CcAutoLock { - CcOsLock& m_lock; -public: - static void Start(CcAutoLock*& a, CcOsLock& lock) { a = new CcAutoLock(lock); }; - static void Stop (CcAutoLock*& a) { delete a; a = 0; }; - CcAutoLock(CcOsLock& lock):m_lock(lock) { m_lock.lock(); } - ~CcAutoLock() { m_lock.unlock(); } -}; - -#endif /* __AUTOLOCK_HXX */ +/* + + Copyright (C) 1998 Danilo Almeida. All rights reserved. + + automatic stack-based locking object + + This file is part of FIFS (Framework for Implementing File Systems). + + This software is distributed with NO WARRANTY OF ANY KIND. No + author or distributor accepts any responsibility for the + consequences of using it, or for whether it serves any particular + purpose or works at all, unless he or she says so in writing. + Refer to the included modified Alladin Free Public License (the + "License") for full details. + + Every copy of this software must include a copy of the License, in + a plain ASCII text file named COPYING. The License grants you the + right to copy, modify and redistribute this software, but only + under certain conditions described in the License. Among other + things, the License requires that the copyright notice and this + notice be preserved on all copies. + +*/ + +#ifndef __AUTOLOCK_HXX__ +#define __AUTOLOCK_HXX__ + +#include + +class CcOsLock { + CRITICAL_SECTION cs; + bool valid; +public: + CcOsLock() {InitializeCriticalSection(&cs); valid = true; } + ~CcOsLock() {DeleteCriticalSection(&cs); valid = false;} + void lock() {if (valid) EnterCriticalSection(&cs);} + void unlock() {if (valid) LeaveCriticalSection(&cs);} +#if 0 + bool trylock() {return valid ? (TryEnterCriticalSection(&cs) ? true : false) + : false; } +#endif +}; + +class CcAutoLock { + CcOsLock& m_lock; +public: + static void Start(CcAutoLock*& a, CcOsLock& lock) { a = new CcAutoLock(lock); }; + static void Stop (CcAutoLock*& a) { delete a; a = 0; }; + CcAutoLock(CcOsLock& lock):m_lock(lock) { m_lock.lock(); } + ~CcAutoLock() { m_lock.unlock(); } +}; + +#endif /* __AUTOLOCK_HXX */ diff --git a/src/ccapi/common/win/OldCC/ccutil.cxx b/src/ccapi/common/win/OldCC/ccutil.cxx index e5e5baef5..729104de7 100644 --- a/src/ccapi/common/win/OldCC/ccutil.cxx +++ b/src/ccapi/common/win/OldCC/ccutil.cxx @@ -1,187 +1,187 @@ -/* - * $Header$ - * - * Copyright 2008 Massachusetts Institute of Technology. - * All Rights Reserved. - * - * Export of this software from the United States of America may - * require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. Furthermore if you modify this software you must label - * your software as modified software and not distribute it in such a - * fashion that it might be confused with the original M.I.T. software. - * M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - */ - -#include -#include "init.hxx" -#include "secure.hxx" - -extern "C" { -#include "cci_debugging.h" - } - - -CcOsLock Init::s_lock; -DWORD Init::s_refcount = 0; -DWORD Init::s_error = ERROR_INVALID_HANDLE; -bool Init::s_init = false; -Init::InitInfo Init::s_info = { 0 }; -HINSTANCE Init::s_hRpcDll = 0; - -#define INIT "INIT: " - -static -void -ShowInfo( - Init::InitInfo& info - ); - -DWORD -Init::Info( - InitInfo& info - ) -{ - // This funciton will not do automatic initialization. - CcAutoLock AL(s_lock); - if (!s_init) { - memset(&info, 0, sizeof(info)); - return s_error ? s_error : ERROR_INVALID_HANDLE; - } else { - info = s_info; - return 0; - } -} - -DWORD -Init::Initialize() { - CcAutoLock AL(s_lock); - cci_debug_printf("%s s_init:%d", __FUNCTION__, s_init); - if (s_init) { - s_refcount++; - return 0; - } - SecureClient s; - DWORD status = 0; - OSVERSIONINFO osvi; - BOOL isSupportedVersion = FALSE; - memset(&s_info, 0, sizeof(s_info)); - memset(&osvi, 0, sizeof(osvi)); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - - status = !GetVersionEx(&osvi); // Returns a boolean. Invert to 0 is OK. - - if (!status) { - switch(osvi.dwPlatformId) { - case VER_PLATFORM_WIN32_WINDOWS: - s_info.isNT = FALSE; - isSupportedVersion = TRUE; - break; - case VER_PLATFORM_WIN32_NT: - s_info.isNT = TRUE; - isSupportedVersion = TRUE; - break; - case VER_PLATFORM_WIN32s: - default: - s_info.isNT = FALSE; - break; - } - - if (!isSupportedVersion) { - cci_debug_printf("%s Trying to run on an unsupported version of Windows", __FUNCTION__); - status = 1; - } - } - - if (!status) {status = !s_info.isNT;} - - if (!status) {status = !(s_hRpcDll = LoadLibrary(TEXT("rpcrt4.dll")));} - - if (!status) { - s_info.fRpcBindingSetAuthInfoEx = (FP_RpcBindingSetAuthInfoEx) - GetProcAddress(s_hRpcDll, TEXT(FN_RpcBindingSetAuthInfoEx)); - if (!s_info.fRpcBindingSetAuthInfoEx) { - cci_debug_printf(" Running on NT but could not find RpcBindinSetAuthInfoEx"); - status = 1; - } - } - - if (!status) { - s_info.fRpcServerRegisterIfEx = (FP_RpcServerRegisterIfEx) - GetProcAddress(s_hRpcDll, TEXT(FN_RpcServerRegisterIfEx)); - if (!s_info.fRpcServerRegisterIfEx) { - cci_debug_printf(" Running on NT but could not find RpcServerRegisterIfEx"); - status = 1; - } - } - - if (!status) { - status = SecureClient::Attach(); - if (status) { - cci_debug_printf(" SecureClient::Attach() failed (%u)", status); - } - } - - if (status) { - memset(&s_info, 0, sizeof(s_info)); - if (s_hRpcDll) { - FreeLibrary(s_hRpcDll); - s_hRpcDll = 0; - } - cci_debug_printf(" Init::Attach() failed (%u)", status); - } else { - s_refcount++; - s_init = true; - ShowInfo(s_info); - } - s_error = status; - return status; -} - -DWORD -Init::Cleanup( - ) -{ - CcAutoLock AL(s_lock); - s_refcount--; - if (s_refcount) return 0; - if (!s_init) return 0; - DWORD error = 0; - if (s_hRpcDll) { - FreeLibrary(s_hRpcDll); - s_hRpcDll = 0; - } - error = SecureClient::Detach(); - memset(&s_info, 0, sizeof(s_info)); - s_init = false; - s_error = 0; - if (error) { - cci_debug_printf(" Init::Detach() had an error (%u)", error); - } - return error; -} - -static -void -ShowInfo( - Init::InitInfo& info - ) -{ - if (info.isNT) { - cci_debug_printf(" Running on Windows NT using secure mode"); - } else { - cci_debug_printf(" Running insecurely on non-NT Windows"); - } - return; -} +/* + * $Header$ + * + * Copyright 2008 Massachusetts Institute of Technology. + * All Rights Reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Furthermore if you modify this software you must label + * your software as modified software and not distribute it in such a + * fashion that it might be confused with the original M.I.T. software. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + */ + +#include +#include "init.hxx" +#include "secure.hxx" + +extern "C" { +#include "cci_debugging.h" + } + + +CcOsLock Init::s_lock; +DWORD Init::s_refcount = 0; +DWORD Init::s_error = ERROR_INVALID_HANDLE; +bool Init::s_init = false; +Init::InitInfo Init::s_info = { 0 }; +HINSTANCE Init::s_hRpcDll = 0; + +#define INIT "INIT: " + +static +void +ShowInfo( + Init::InitInfo& info + ); + +DWORD +Init::Info( + InitInfo& info + ) +{ + // This funciton will not do automatic initialization. + CcAutoLock AL(s_lock); + if (!s_init) { + memset(&info, 0, sizeof(info)); + return s_error ? s_error : ERROR_INVALID_HANDLE; + } else { + info = s_info; + return 0; + } +} + +DWORD +Init::Initialize() { + CcAutoLock AL(s_lock); + cci_debug_printf("%s s_init:%d", __FUNCTION__, s_init); + if (s_init) { + s_refcount++; + return 0; + } + SecureClient s; + DWORD status = 0; + OSVERSIONINFO osvi; + BOOL isSupportedVersion = FALSE; + memset(&s_info, 0, sizeof(s_info)); + memset(&osvi, 0, sizeof(osvi)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + + status = !GetVersionEx(&osvi); // Returns a boolean. Invert to 0 is OK. + + if (!status) { + switch(osvi.dwPlatformId) { + case VER_PLATFORM_WIN32_WINDOWS: + s_info.isNT = FALSE; + isSupportedVersion = TRUE; + break; + case VER_PLATFORM_WIN32_NT: + s_info.isNT = TRUE; + isSupportedVersion = TRUE; + break; + case VER_PLATFORM_WIN32s: + default: + s_info.isNT = FALSE; + break; + } + + if (!isSupportedVersion) { + cci_debug_printf("%s Trying to run on an unsupported version of Windows", __FUNCTION__); + status = 1; + } + } + + if (!status) {status = !s_info.isNT;} + + if (!status) {status = !(s_hRpcDll = LoadLibrary(TEXT("rpcrt4.dll")));} + + if (!status) { + s_info.fRpcBindingSetAuthInfoEx = (FP_RpcBindingSetAuthInfoEx) + GetProcAddress(s_hRpcDll, TEXT(FN_RpcBindingSetAuthInfoEx)); + if (!s_info.fRpcBindingSetAuthInfoEx) { + cci_debug_printf(" Running on NT but could not find RpcBindinSetAuthInfoEx"); + status = 1; + } + } + + if (!status) { + s_info.fRpcServerRegisterIfEx = (FP_RpcServerRegisterIfEx) + GetProcAddress(s_hRpcDll, TEXT(FN_RpcServerRegisterIfEx)); + if (!s_info.fRpcServerRegisterIfEx) { + cci_debug_printf(" Running on NT but could not find RpcServerRegisterIfEx"); + status = 1; + } + } + + if (!status) { + status = SecureClient::Attach(); + if (status) { + cci_debug_printf(" SecureClient::Attach() failed (%u)", status); + } + } + + if (status) { + memset(&s_info, 0, sizeof(s_info)); + if (s_hRpcDll) { + FreeLibrary(s_hRpcDll); + s_hRpcDll = 0; + } + cci_debug_printf(" Init::Attach() failed (%u)", status); + } else { + s_refcount++; + s_init = true; + ShowInfo(s_info); + } + s_error = status; + return status; +} + +DWORD +Init::Cleanup( + ) +{ + CcAutoLock AL(s_lock); + s_refcount--; + if (s_refcount) return 0; + if (!s_init) return 0; + DWORD error = 0; + if (s_hRpcDll) { + FreeLibrary(s_hRpcDll); + s_hRpcDll = 0; + } + error = SecureClient::Detach(); + memset(&s_info, 0, sizeof(s_info)); + s_init = false; + s_error = 0; + if (error) { + cci_debug_printf(" Init::Detach() had an error (%u)", error); + } + return error; +} + +static +void +ShowInfo( + Init::InitInfo& info + ) +{ + if (info.isNT) { + cci_debug_printf(" Running on Windows NT using secure mode"); + } else { + cci_debug_printf(" Running insecurely on non-NT Windows"); + } + return; +} diff --git a/src/ccapi/common/win/OldCC/ccutil.def b/src/ccapi/common/win/OldCC/ccutil.def index a187c805d..57113f094 100644 --- a/src/ccapi/common/win/OldCC/ccutil.def +++ b/src/ccapi/common/win/OldCC/ccutil.def @@ -1,5 +1,5 @@ -;LIBRARY COMERR32 -HEAPSIZE 8192 - -EXPORTS +;LIBRARY COMERR32 +HEAPSIZE 8192 + +EXPORTS \ No newline at end of file diff --git a/src/ccapi/common/win/OldCC/init.cxx b/src/ccapi/common/win/OldCC/init.cxx index af93722fe..feb7ad3ad 100644 --- a/src/ccapi/common/win/OldCC/init.cxx +++ b/src/ccapi/common/win/OldCC/init.cxx @@ -1,187 +1,187 @@ -/* - * $Header$ - * - * Copyright 2008 Massachusetts Institute of Technology. - * All Rights Reserved. - * - * Export of this software from the United States of America may - * require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. Furthermore if you modify this software you must label - * your software as modified software and not distribute it in such a - * fashion that it might be confused with the original M.I.T. software. - * M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - */ - -#include -#include "init.hxx" -#include "secure.hxx" - -extern "C" { -#include "cci_debugging.h" - } - - -CcOsLock Init::s_lock; -DWORD Init::s_refcount = 0; -DWORD Init::s_error = ERROR_INVALID_HANDLE; -bool Init::s_init = false; -Init::InitInfo Init::s_info = { 0 }; -HINSTANCE Init::s_hRpcDll = 0; - -#define INIT "INIT: " - -static -void -ShowInfo( - Init::InitInfo& info - ); - -DWORD -Init::Info( - InitInfo& info - ) -{ - // This funciton will not do automatic initialization. - CcAutoLock AL(s_lock); - if (!s_init) { - memset(&info, 0, sizeof(info)); - return s_error ? s_error : ERROR_INVALID_HANDLE; - } else { - info = s_info; - return 0; - } -} - -DWORD -Init::Initialize() { - CcAutoLock AL(s_lock); -// cci_debug_printf("%s s_init:%d", __FUNCTION__, s_init); - if (s_init) { - s_refcount++; - return 0; - } - SecureClient s; - DWORD status = 0; - OSVERSIONINFO osvi; - BOOL isSupportedVersion = FALSE; - memset(&s_info, 0, sizeof(s_info)); - memset(&osvi, 0, sizeof(osvi)); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - - status = !GetVersionEx(&osvi); // Returns a boolean. Invert to 0 is OK. - - if (!status) { - switch(osvi.dwPlatformId) { - case VER_PLATFORM_WIN32_WINDOWS: - s_info.isNT = FALSE; - isSupportedVersion = TRUE; - break; - case VER_PLATFORM_WIN32_NT: - s_info.isNT = TRUE; - isSupportedVersion = TRUE; - break; - case VER_PLATFORM_WIN32s: - default: - s_info.isNT = FALSE; - break; - } - - if (!isSupportedVersion) { - cci_debug_printf("%s Trying to run on an unsupported version of Windows", __FUNCTION__); - status = 1; - } - } - - if (!status) {status = !s_info.isNT;} - - if (!status) {status = !(s_hRpcDll = LoadLibrary(TEXT("rpcrt4.dll")));} - - if (!status) { - s_info.fRpcBindingSetAuthInfoEx = (FP_RpcBindingSetAuthInfoEx) - GetProcAddress(s_hRpcDll, TEXT(FN_RpcBindingSetAuthInfoEx)); - if (!s_info.fRpcBindingSetAuthInfoEx) { - cci_debug_printf(" Running on NT but could not find RpcBindinSetAuthInfoEx"); - status = 1; - } - } - - if (!status) { - s_info.fRpcServerRegisterIfEx = (FP_RpcServerRegisterIfEx) - GetProcAddress(s_hRpcDll, TEXT(FN_RpcServerRegisterIfEx)); - if (!s_info.fRpcServerRegisterIfEx) { - cci_debug_printf(" Running on NT but could not find RpcServerRegisterIfEx"); - status = 1; - } - } - - if (!status) { - status = SecureClient::Attach(); - if (status) { - cci_debug_printf(" SecureClient::Attach() failed (%u)", status); - } - } - - if (status) { - memset(&s_info, 0, sizeof(s_info)); - if (s_hRpcDll) { - FreeLibrary(s_hRpcDll); - s_hRpcDll = 0; - } - cci_debug_printf(" Init::Attach() failed (%u)", status); - } else { - s_refcount++; - s_init = true; - ShowInfo(s_info); - } - s_error = status; - return status; -} - -DWORD -Init::Cleanup( - ) -{ - CcAutoLock AL(s_lock); - s_refcount--; - if (s_refcount) return 0; - if (!s_init) return 0; - DWORD error = 0; - if (s_hRpcDll) { - FreeLibrary(s_hRpcDll); - s_hRpcDll = 0; - } - error = SecureClient::Detach(); - memset(&s_info, 0, sizeof(s_info)); - s_init = false; - s_error = 0; - if (error) { - cci_debug_printf(" Init::Detach() had an error (%u)", error); - } - return error; -} - -static -void -ShowInfo( - Init::InitInfo& info - ) -{ - if (info.isNT) { - cci_debug_printf(" Running on Windows NT using secure mode"); - } else { - cci_debug_printf(" Running insecurely on non-NT Windows"); - } - return; -} +/* + * $Header$ + * + * Copyright 2008 Massachusetts Institute of Technology. + * All Rights Reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Furthermore if you modify this software you must label + * your software as modified software and not distribute it in such a + * fashion that it might be confused with the original M.I.T. software. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + */ + +#include +#include "init.hxx" +#include "secure.hxx" + +extern "C" { +#include "cci_debugging.h" + } + + +CcOsLock Init::s_lock; +DWORD Init::s_refcount = 0; +DWORD Init::s_error = ERROR_INVALID_HANDLE; +bool Init::s_init = false; +Init::InitInfo Init::s_info = { 0 }; +HINSTANCE Init::s_hRpcDll = 0; + +#define INIT "INIT: " + +static +void +ShowInfo( + Init::InitInfo& info + ); + +DWORD +Init::Info( + InitInfo& info + ) +{ + // This funciton will not do automatic initialization. + CcAutoLock AL(s_lock); + if (!s_init) { + memset(&info, 0, sizeof(info)); + return s_error ? s_error : ERROR_INVALID_HANDLE; + } else { + info = s_info; + return 0; + } +} + +DWORD +Init::Initialize() { + CcAutoLock AL(s_lock); +// cci_debug_printf("%s s_init:%d", __FUNCTION__, s_init); + if (s_init) { + s_refcount++; + return 0; + } + SecureClient s; + DWORD status = 0; + OSVERSIONINFO osvi; + BOOL isSupportedVersion = FALSE; + memset(&s_info, 0, sizeof(s_info)); + memset(&osvi, 0, sizeof(osvi)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + + status = !GetVersionEx(&osvi); // Returns a boolean. Invert to 0 is OK. + + if (!status) { + switch(osvi.dwPlatformId) { + case VER_PLATFORM_WIN32_WINDOWS: + s_info.isNT = FALSE; + isSupportedVersion = TRUE; + break; + case VER_PLATFORM_WIN32_NT: + s_info.isNT = TRUE; + isSupportedVersion = TRUE; + break; + case VER_PLATFORM_WIN32s: + default: + s_info.isNT = FALSE; + break; + } + + if (!isSupportedVersion) { + cci_debug_printf("%s Trying to run on an unsupported version of Windows", __FUNCTION__); + status = 1; + } + } + + if (!status) {status = !s_info.isNT;} + + if (!status) {status = !(s_hRpcDll = LoadLibrary(TEXT("rpcrt4.dll")));} + + if (!status) { + s_info.fRpcBindingSetAuthInfoEx = (FP_RpcBindingSetAuthInfoEx) + GetProcAddress(s_hRpcDll, TEXT(FN_RpcBindingSetAuthInfoEx)); + if (!s_info.fRpcBindingSetAuthInfoEx) { + cci_debug_printf(" Running on NT but could not find RpcBindinSetAuthInfoEx"); + status = 1; + } + } + + if (!status) { + s_info.fRpcServerRegisterIfEx = (FP_RpcServerRegisterIfEx) + GetProcAddress(s_hRpcDll, TEXT(FN_RpcServerRegisterIfEx)); + if (!s_info.fRpcServerRegisterIfEx) { + cci_debug_printf(" Running on NT but could not find RpcServerRegisterIfEx"); + status = 1; + } + } + + if (!status) { + status = SecureClient::Attach(); + if (status) { + cci_debug_printf(" SecureClient::Attach() failed (%u)", status); + } + } + + if (status) { + memset(&s_info, 0, sizeof(s_info)); + if (s_hRpcDll) { + FreeLibrary(s_hRpcDll); + s_hRpcDll = 0; + } + cci_debug_printf(" Init::Attach() failed (%u)", status); + } else { + s_refcount++; + s_init = true; + ShowInfo(s_info); + } + s_error = status; + return status; +} + +DWORD +Init::Cleanup( + ) +{ + CcAutoLock AL(s_lock); + s_refcount--; + if (s_refcount) return 0; + if (!s_init) return 0; + DWORD error = 0; + if (s_hRpcDll) { + FreeLibrary(s_hRpcDll); + s_hRpcDll = 0; + } + error = SecureClient::Detach(); + memset(&s_info, 0, sizeof(s_info)); + s_init = false; + s_error = 0; + if (error) { + cci_debug_printf(" Init::Detach() had an error (%u)", error); + } + return error; +} + +static +void +ShowInfo( + Init::InitInfo& info + ) +{ + if (info.isNT) { + cci_debug_printf(" Running on Windows NT using secure mode"); + } else { + cci_debug_printf(" Running insecurely on non-NT Windows"); + } + return; +} diff --git a/src/ccapi/common/win/OldCC/init.hxx b/src/ccapi/common/win/OldCC/init.hxx index f50db776a..9bac7f8f9 100644 --- a/src/ccapi/common/win/OldCC/init.hxx +++ b/src/ccapi/common/win/OldCC/init.hxx @@ -1,102 +1,102 @@ -/* - * $Header$ - * - * Copyright 2008 Massachusetts Institute of Technology. - * All Rights Reserved. - * - * Export of this software from the United States of America may - * require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. Furthermore if you modify this software you must label - * your software as modified software and not distribute it in such a - * fashion that it might be confused with the original M.I.T. software. - * M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - */ - -#pragma once -#include "autolock.hxx" -#include - -typedef RPC_STATUS (RPC_ENTRY *FP_RpcBindingSetAuthInfoExA)( - IN RPC_BINDING_HANDLE Binding, - IN unsigned char __RPC_FAR * ServerPrincName, - IN unsigned long AuthnLevel, - IN unsigned long AuthnSvc, - IN RPC_AUTH_IDENTITY_HANDLE AuthIdentity, OPTIONAL - IN unsigned long AuthzSvc, - IN RPC_SECURITY_QOS *SecurityQos OPTIONAL - ); - -typedef RPC_STATUS (RPC_ENTRY *FP_RpcBindingSetAuthInfoExW)( - IN RPC_BINDING_HANDLE Binding, - IN unsigned short __RPC_FAR * ServerPrincName, - IN unsigned long AuthnLevel, - IN unsigned long AuthnSvc, - IN RPC_AUTH_IDENTITY_HANDLE AuthIdentity, OPTIONAL - IN unsigned long AuthzSvc, OPTIONAL - IN RPC_SECURITY_QOS *SecurityQOS - ); - -typedef RPC_STATUS (RPC_ENTRY *FP_RpcServerRegisterIfEx)( - IN RPC_IF_HANDLE IfSpec, - IN UUID __RPC_FAR * MgrTypeUuid, - IN RPC_MGR_EPV __RPC_FAR * MgrEpv, - IN unsigned int Flags, - IN unsigned int MaxCalls, - IN RPC_IF_CALLBACK_FN __RPC_FAR *IfCallback - ); - -#ifdef UNICODE -#define FP_RpcBindingSetAuthInfoEx FP_RpcBindingSetAuthInfoExW -#define FN_RpcBindingSetAuthInfoEx "RpcBindingSetAuthInfoExW" -#else -#define FP_RpcBindingSetAuthInfoEx FP_RpcBindingSetAuthInfoExA -#define FN_RpcBindingSetAuthInfoEx "RpcBindingSetAuthInfoExA" -#endif - -#define FN_RpcServerRegisterIfEx "RpcServerRegisterIfEx" - -class Init -{ -public: - struct InitInfo { - BOOL isNT; - FP_RpcBindingSetAuthInfoEx fRpcBindingSetAuthInfoEx; - FP_RpcServerRegisterIfEx fRpcServerRegisterIfEx; - }; - - static DWORD Initialize(); - static DWORD Cleanup(); - static DWORD Info(InitInfo& info); - - static bool Initialized() { return s_init; } - -private: - static CcOsLock s_lock; - static DWORD s_refcount; - static DWORD s_error; - static bool s_init; - static InitInfo s_info; - static HINSTANCE s_hRpcDll; -}; - -#define INIT_INIT_EX(trap, error) \ -do \ -{ \ - if (!Init::Initialized()) \ - { \ - DWORD rc = Init::Initialize(); \ - if (rc) return (trap) ? (error) : rc; \ - } \ -} while(0) +/* + * $Header$ + * + * Copyright 2008 Massachusetts Institute of Technology. + * All Rights Reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Furthermore if you modify this software you must label + * your software as modified software and not distribute it in such a + * fashion that it might be confused with the original M.I.T. software. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + */ + +#pragma once +#include "autolock.hxx" +#include + +typedef RPC_STATUS (RPC_ENTRY *FP_RpcBindingSetAuthInfoExA)( + IN RPC_BINDING_HANDLE Binding, + IN unsigned char __RPC_FAR * ServerPrincName, + IN unsigned long AuthnLevel, + IN unsigned long AuthnSvc, + IN RPC_AUTH_IDENTITY_HANDLE AuthIdentity, OPTIONAL + IN unsigned long AuthzSvc, + IN RPC_SECURITY_QOS *SecurityQos OPTIONAL + ); + +typedef RPC_STATUS (RPC_ENTRY *FP_RpcBindingSetAuthInfoExW)( + IN RPC_BINDING_HANDLE Binding, + IN unsigned short __RPC_FAR * ServerPrincName, + IN unsigned long AuthnLevel, + IN unsigned long AuthnSvc, + IN RPC_AUTH_IDENTITY_HANDLE AuthIdentity, OPTIONAL + IN unsigned long AuthzSvc, OPTIONAL + IN RPC_SECURITY_QOS *SecurityQOS + ); + +typedef RPC_STATUS (RPC_ENTRY *FP_RpcServerRegisterIfEx)( + IN RPC_IF_HANDLE IfSpec, + IN UUID __RPC_FAR * MgrTypeUuid, + IN RPC_MGR_EPV __RPC_FAR * MgrEpv, + IN unsigned int Flags, + IN unsigned int MaxCalls, + IN RPC_IF_CALLBACK_FN __RPC_FAR *IfCallback + ); + +#ifdef UNICODE +#define FP_RpcBindingSetAuthInfoEx FP_RpcBindingSetAuthInfoExW +#define FN_RpcBindingSetAuthInfoEx "RpcBindingSetAuthInfoExW" +#else +#define FP_RpcBindingSetAuthInfoEx FP_RpcBindingSetAuthInfoExA +#define FN_RpcBindingSetAuthInfoEx "RpcBindingSetAuthInfoExA" +#endif + +#define FN_RpcServerRegisterIfEx "RpcServerRegisterIfEx" + +class Init +{ +public: + struct InitInfo { + BOOL isNT; + FP_RpcBindingSetAuthInfoEx fRpcBindingSetAuthInfoEx; + FP_RpcServerRegisterIfEx fRpcServerRegisterIfEx; + }; + + static DWORD Initialize(); + static DWORD Cleanup(); + static DWORD Info(InitInfo& info); + + static bool Initialized() { return s_init; } + +private: + static CcOsLock s_lock; + static DWORD s_refcount; + static DWORD s_error; + static bool s_init; + static InitInfo s_info; + static HINSTANCE s_hRpcDll; +}; + +#define INIT_INIT_EX(trap, error) \ +do \ +{ \ + if (!Init::Initialized()) \ + { \ + DWORD rc = Init::Initialize(); \ + if (rc) return (trap) ? (error) : rc; \ + } \ +} while(0) diff --git a/src/ccapi/common/win/OldCC/opts.cxx b/src/ccapi/common/win/OldCC/opts.cxx index c6a40d64d..bd5f503ea 100644 --- a/src/ccapi/common/win/OldCC/opts.cxx +++ b/src/ccapi/common/win/OldCC/opts.cxx @@ -1,188 +1,188 @@ -/* - * $Header$ - * - * Copyright 2008 Massachusetts Institute of Technology. - * All Rights Reserved. - * - * Export of this software from the United States of America may - * require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. Furthermore if you modify this software you must label - * your software as modified software and not distribute it in such a - * fashion that it might be confused with the original M.I.T. software. - * M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - */ - -#include -#include -#include -#include - -#if 0 -const struct Opts* -GetOpts( - ) -{ - bool done = false; - struct Opts* o; - if (!(o = new Opts)) - goto cleanup; - if (!(o->pszString = new char[lstrlenA(opts.pszString) + 1])) - goto cleanup; - if (!(o->pszEndpoint = new char[lstrlenA(opts.pszEndpoint) + 1])) - goto cleanup; - strcpy(o->pszString, opts.pszString); - strcpy(o->pszEndpoint, opts.pszEndpoint); - done = true; - cleanup: - if (!done) { - FreeOpts(o); - o = 0; - } - return o; -} - -void -FreeOpts( - struct Opts* o - ) -{ - if (o) { - if (o->pszString) - delete [] o->pszString; - if (o->pszEndpoint) - delete [] o->pszEndpoint; - delete o; - } -} -#endif - -bool -ParseOpts::IsValidOpt( - char ch - ) -{ - return (m_ValidOpts[ch % 256] != 0); -} - -void -ParseOpts::PrintOpt( - char ch, - char* text - ) -{ - if (IsValidOpt(ch)) - fprintf(stderr, " -%c %s\n", ch, text); -} - -void -ParseOpts::UsageOpts( - char * program, - int code - ) -{ - fprintf(stderr, "Usage: %s [options]\n", program); - PrintOpt('k', "stop server"); -#ifdef CCAPI_TEST_OPTIONS - PrintOpt('s', "string"); - PrintOpt('e', "endpoint"); - PrintOpt('m', "maxcalls"); - PrintOpt('n', "mincalls"); - PrintOpt('f', "flag_wait_op"); - PrintOpt('u', "unprotected"); - PrintOpt('b', "use security callback"); -#endif - PrintOpt('c', "output debug info to console"); - exit(code); -} - -void -ParseOpts::SetValidOpts( - char* valid_opts - ) -{ - memset(m_ValidOpts, 0, sizeof(m_ValidOpts)); - char *p = valid_opts; - for (p = valid_opts; *p; p++) { - m_ValidOpts[*p % sizeof(m_ValidOpts)] = 1; - } -} - -void -ParseOpts::Parse( - Opts& opts, - int argc, - char **argv - ) -{ - int i; - for (i = 1; i < argc; i++) { - if ((*argv[i] == '-') || (*argv[i] == '/')) { - char ch = tolower(*(argv[i]+1)); - if (!IsValidOpt(ch)) - UsageOpts(argv[0]); - switch (ch) { - case 'k': - opts.bShutdown = TRUE; - break; -#ifdef CCAPI_TEST_OPTIONS - case 's': - opts.pszString = argv[++i]; - break; - case 'e': - opts.pszEndpoint = argv[++i]; - break; - case 'm': - opts.cMaxCalls = (unsigned int) atoi(argv[++i]); - break; - case 'n': - opts.cMinCalls = (unsigned int) atoi(argv[++i]); - break; - case 'f': - opts.fDontWait = (unsigned int) atoi(argv[++i]); - break; - case 'u': - opts.bDontProtect = TRUE; - break; - case 'b': - opts.bSecCallback = TRUE; - break; -#endif - case 'c': - opts.bConsole = TRUE; - break; - case 'h': - case '?': - default: - UsageOpts(argv[0]); - } - } - else - UsageOpts(argv[0]); - } - -} - -ParseOpts::ParseOpts(char* valid_opts) -{ - SetValidOpts(valid_opts); -} - -ParseOpts::ParseOpts() -{ -} - -ParseOpts::~ParseOpts() -{ -} +/* + * $Header$ + * + * Copyright 2008 Massachusetts Institute of Technology. + * All Rights Reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Furthermore if you modify this software you must label + * your software as modified software and not distribute it in such a + * fashion that it might be confused with the original M.I.T. software. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + */ + +#include +#include +#include +#include + +#if 0 +const struct Opts* +GetOpts( + ) +{ + bool done = false; + struct Opts* o; + if (!(o = new Opts)) + goto cleanup; + if (!(o->pszString = new char[lstrlenA(opts.pszString) + 1])) + goto cleanup; + if (!(o->pszEndpoint = new char[lstrlenA(opts.pszEndpoint) + 1])) + goto cleanup; + strcpy(o->pszString, opts.pszString); + strcpy(o->pszEndpoint, opts.pszEndpoint); + done = true; + cleanup: + if (!done) { + FreeOpts(o); + o = 0; + } + return o; +} + +void +FreeOpts( + struct Opts* o + ) +{ + if (o) { + if (o->pszString) + delete [] o->pszString; + if (o->pszEndpoint) + delete [] o->pszEndpoint; + delete o; + } +} +#endif + +bool +ParseOpts::IsValidOpt( + char ch + ) +{ + return (m_ValidOpts[ch % 256] != 0); +} + +void +ParseOpts::PrintOpt( + char ch, + char* text + ) +{ + if (IsValidOpt(ch)) + fprintf(stderr, " -%c %s\n", ch, text); +} + +void +ParseOpts::UsageOpts( + char * program, + int code + ) +{ + fprintf(stderr, "Usage: %s [options]\n", program); + PrintOpt('k', "stop server"); +#ifdef CCAPI_TEST_OPTIONS + PrintOpt('s', "string"); + PrintOpt('e', "endpoint"); + PrintOpt('m', "maxcalls"); + PrintOpt('n', "mincalls"); + PrintOpt('f', "flag_wait_op"); + PrintOpt('u', "unprotected"); + PrintOpt('b', "use security callback"); +#endif + PrintOpt('c', "output debug info to console"); + exit(code); +} + +void +ParseOpts::SetValidOpts( + char* valid_opts + ) +{ + memset(m_ValidOpts, 0, sizeof(m_ValidOpts)); + char *p = valid_opts; + for (p = valid_opts; *p; p++) { + m_ValidOpts[*p % sizeof(m_ValidOpts)] = 1; + } +} + +void +ParseOpts::Parse( + Opts& opts, + int argc, + char **argv + ) +{ + int i; + for (i = 1; i < argc; i++) { + if ((*argv[i] == '-') || (*argv[i] == '/')) { + char ch = tolower(*(argv[i]+1)); + if (!IsValidOpt(ch)) + UsageOpts(argv[0]); + switch (ch) { + case 'k': + opts.bShutdown = TRUE; + break; +#ifdef CCAPI_TEST_OPTIONS + case 's': + opts.pszString = argv[++i]; + break; + case 'e': + opts.pszEndpoint = argv[++i]; + break; + case 'm': + opts.cMaxCalls = (unsigned int) atoi(argv[++i]); + break; + case 'n': + opts.cMinCalls = (unsigned int) atoi(argv[++i]); + break; + case 'f': + opts.fDontWait = (unsigned int) atoi(argv[++i]); + break; + case 'u': + opts.bDontProtect = TRUE; + break; + case 'b': + opts.bSecCallback = TRUE; + break; +#endif + case 'c': + opts.bConsole = TRUE; + break; + case 'h': + case '?': + default: + UsageOpts(argv[0]); + } + } + else + UsageOpts(argv[0]); + } + +} + +ParseOpts::ParseOpts(char* valid_opts) +{ + SetValidOpts(valid_opts); +} + +ParseOpts::ParseOpts() +{ +} + +ParseOpts::~ParseOpts() +{ +} diff --git a/src/ccapi/common/win/OldCC/opts.hxx b/src/ccapi/common/win/OldCC/opts.hxx index 1732ceb25..755ce4ae6 100644 --- a/src/ccapi/common/win/OldCC/opts.hxx +++ b/src/ccapi/common/win/OldCC/opts.hxx @@ -1,56 +1,56 @@ -/* - * $Header$ - * - * Copyright 2008 Massachusetts Institute of Technology. - * All Rights Reserved. - * - * Export of this software from the United States of America may - * require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. Furthermore if you modify this software you must label - * your software as modified software and not distribute it in such a - * fashion that it might be confused with the original M.I.T. software. - * M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - */ - -#pragma once - -class ParseOpts -{ -public: - struct Opts { - char* pszString; - char* pszEndpoint; - unsigned int cMinCalls; - unsigned int cMaxCalls; - unsigned int fDontWait; - bool bDontProtect; - bool bShutdown; - bool bSecCallback; - bool bConsole; - }; - - ParseOpts(char* valid_opts); - ParseOpts(); - ~ParseOpts(); - void SetValidOpts(char* valid_opts); - void Parse(Opts& opts, int argc, char **argv); - -private: - bool IsValidOpt(char ch); - void PrintOpt(char ch, char* text); - void UsageOpts(char* program, int code = 0); - - char m_ValidOpts[256]; -}; +/* + * $Header$ + * + * Copyright 2008 Massachusetts Institute of Technology. + * All Rights Reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Furthermore if you modify this software you must label + * your software as modified software and not distribute it in such a + * fashion that it might be confused with the original M.I.T. software. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + */ + +#pragma once + +class ParseOpts +{ +public: + struct Opts { + char* pszString; + char* pszEndpoint; + unsigned int cMinCalls; + unsigned int cMaxCalls; + unsigned int fDontWait; + bool bDontProtect; + bool bShutdown; + bool bSecCallback; + bool bConsole; + }; + + ParseOpts(char* valid_opts); + ParseOpts(); + ~ParseOpts(); + void SetValidOpts(char* valid_opts); + void Parse(Opts& opts, int argc, char **argv); + +private: + bool IsValidOpt(char ch); + void PrintOpt(char ch, char* text); + void UsageOpts(char* program, int code = 0); + + char m_ValidOpts[256]; +}; diff --git a/src/ccapi/common/win/OldCC/secure.cxx b/src/ccapi/common/win/OldCC/secure.cxx index a32235fd6..99ba08a25 100644 --- a/src/ccapi/common/win/OldCC/secure.cxx +++ b/src/ccapi/common/win/OldCC/secure.cxx @@ -1,161 +1,161 @@ -/* - * $Header$ - * - * Copyright 2008 Massachusetts Institute of Technology. - * All Rights Reserved. - * - * Export of this software from the United States of America may - * require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. Furthermore if you modify this software you must label - * your software as modified software and not distribute it in such a - * fashion that it might be confused with the original M.I.T. software. - * M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - */ - -#include -#include "secure.hxx" - -extern "C" { -#include "cci_debugging.h" - } - -CcOsLock SecureClient::s_lock; -DWORD SecureClient::s_refcount = 0; -DWORD SecureClient::s_error = 0; -HANDLE SecureClient::s_hToken = 0; - -#include "util.h" - -#define SC "SecureClient::" - -DWORD -SecureClient::Attach( - ) -{ - CcAutoLock AL(s_lock); - if (s_hToken) { - s_refcount++; - return 0; - } - if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, - &s_hToken)) { - s_refcount++; - s_error = 0; - } else { - s_hToken = 0; - s_error = GetLastError(); - } - return s_error; -} - -DWORD -SecureClient::Detach( - ) -{ - CcAutoLock AL(s_lock); - s_refcount--; - if (s_refcount) return 0; - if (!s_hToken) return 0; - DWORD error = 0; - if (!CloseHandle(s_hToken)) - error = GetLastError(); - s_hToken = 0; - s_error = 0; - return error; -} - -DWORD SecureClient::Token(HANDLE& hToken) { - // This function will not do automatic initialization. - CcAutoLock AL(s_lock); - hToken = 0; - if (!s_hToken) { - cci_debug_printf("%s no process token initialized (%u)", __FUNCTION__, s_error); - return s_error ? s_error : ERROR_INVALID_HANDLE; - } - else { - DWORD status = 0; - if (!DuplicateHandle(GetCurrentProcess(), s_hToken, - GetCurrentProcess(), &hToken, 0, FALSE, - DUPLICATE_SAME_ACCESS)) { - status = GetLastError(); - cci_debug_printf(" Could not duplicate handle (%u)", status); - } - return status; - } - } - -void -SecureClient::Start(SecureClient*& s) { - s = new SecureClient; -} - -void -SecureClient::Stop(SecureClient*& s) { - delete s; - s = 0; -} - -/////////////////////////////////////////////////////////////////////////////// - -/* This constructor turns off impersonation. - * It is OK for OpenThreadToken to return an error -- that just means impersonation - * is off. - */ -SecureClient::SecureClient(): - m_Error(0), - m_hToken(0), - m_NeedRestore(false) { - - HANDLE hThread = GetCurrentThread(); - HANDLE hThDuplicate; - - int status = DuplicateHandle( GetCurrentProcess(), - hThread, - GetCurrentProcess(), - &hThDuplicate, - TOKEN_ALL_ACCESS, - FALSE, - 0); - if (!status) return; - - if (!OpenThreadToken(hThDuplicate, TOKEN_ALL_ACCESS, FALSE, &m_hToken)) { - m_Error = GetLastError(); - return; - } - if (SetThreadToken(&hThDuplicate, NULL)) { - m_NeedRestore = true; - } else { - m_Error = GetLastError(); - } - CloseHandle(hThDuplicate); - } - -SecureClient::~SecureClient() { - if (m_NeedRestore) { - HANDLE hThread = GetCurrentThread(); - if (!SetThreadToken(&hThread, m_hToken)) { - m_Error = cci_check_error(GetLastError()); - } - } - if (m_hToken) { - if (!CloseHandle(m_hToken)) { - m_Error = cci_check_error(GetLastError()); - } - } - } - -DWORD SecureClient::Error() { - return m_Error; +/* + * $Header$ + * + * Copyright 2008 Massachusetts Institute of Technology. + * All Rights Reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Furthermore if you modify this software you must label + * your software as modified software and not distribute it in such a + * fashion that it might be confused with the original M.I.T. software. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + */ + +#include +#include "secure.hxx" + +extern "C" { +#include "cci_debugging.h" + } + +CcOsLock SecureClient::s_lock; +DWORD SecureClient::s_refcount = 0; +DWORD SecureClient::s_error = 0; +HANDLE SecureClient::s_hToken = 0; + +#include "util.h" + +#define SC "SecureClient::" + +DWORD +SecureClient::Attach( + ) +{ + CcAutoLock AL(s_lock); + if (s_hToken) { + s_refcount++; + return 0; + } + if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, + &s_hToken)) { + s_refcount++; + s_error = 0; + } else { + s_hToken = 0; + s_error = GetLastError(); + } + return s_error; +} + +DWORD +SecureClient::Detach( + ) +{ + CcAutoLock AL(s_lock); + s_refcount--; + if (s_refcount) return 0; + if (!s_hToken) return 0; + DWORD error = 0; + if (!CloseHandle(s_hToken)) + error = GetLastError(); + s_hToken = 0; + s_error = 0; + return error; +} + +DWORD SecureClient::Token(HANDLE& hToken) { + // This function will not do automatic initialization. + CcAutoLock AL(s_lock); + hToken = 0; + if (!s_hToken) { + cci_debug_printf("%s no process token initialized (%u)", __FUNCTION__, s_error); + return s_error ? s_error : ERROR_INVALID_HANDLE; + } + else { + DWORD status = 0; + if (!DuplicateHandle(GetCurrentProcess(), s_hToken, + GetCurrentProcess(), &hToken, 0, FALSE, + DUPLICATE_SAME_ACCESS)) { + status = GetLastError(); + cci_debug_printf(" Could not duplicate handle (%u)", status); + } + return status; + } + } + +void +SecureClient::Start(SecureClient*& s) { + s = new SecureClient; +} + +void +SecureClient::Stop(SecureClient*& s) { + delete s; + s = 0; +} + +/////////////////////////////////////////////////////////////////////////////// + +/* This constructor turns off impersonation. + * It is OK for OpenThreadToken to return an error -- that just means impersonation + * is off. + */ +SecureClient::SecureClient(): + m_Error(0), + m_hToken(0), + m_NeedRestore(false) { + + HANDLE hThread = GetCurrentThread(); + HANDLE hThDuplicate; + + int status = DuplicateHandle( GetCurrentProcess(), + hThread, + GetCurrentProcess(), + &hThDuplicate, + TOKEN_ALL_ACCESS, + FALSE, + 0); + if (!status) return; + + if (!OpenThreadToken(hThDuplicate, TOKEN_ALL_ACCESS, FALSE, &m_hToken)) { + m_Error = GetLastError(); + return; + } + if (SetThreadToken(&hThDuplicate, NULL)) { + m_NeedRestore = true; + } else { + m_Error = GetLastError(); + } + CloseHandle(hThDuplicate); + } + +SecureClient::~SecureClient() { + if (m_NeedRestore) { + HANDLE hThread = GetCurrentThread(); + if (!SetThreadToken(&hThread, m_hToken)) { + m_Error = cci_check_error(GetLastError()); + } + } + if (m_hToken) { + if (!CloseHandle(m_hToken)) { + m_Error = cci_check_error(GetLastError()); + } + } + } + +DWORD SecureClient::Error() { + return m_Error; } \ No newline at end of file diff --git a/src/ccapi/common/win/OldCC/secure.hxx b/src/ccapi/common/win/OldCC/secure.hxx index 009e36c74..3714c6f84 100644 --- a/src/ccapi/common/win/OldCC/secure.hxx +++ b/src/ccapi/common/win/OldCC/secure.hxx @@ -1,60 +1,60 @@ -/* - * $Header$ - * - * Copyright 2008 Massachusetts Institute of Technology. - * All Rights Reserved. - * - * Export of this software from the United States of America may - * require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. Furthermore if you modify this software you must label - * your software as modified software and not distribute it in such a - * fashion that it might be confused with the original M.I.T. software. - * M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - */ - -#pragma once - -#include -#include "autolock.hxx" - -class SecureClient -{ -public: - static DWORD Attach(); - static DWORD Detach(); - static DWORD Token(HANDLE& hToken); - static void Start(SecureClient*& s); - static void Stop(SecureClient*& s); - -#if 0 - static DWORD CheckImpersonation(); - static bool IsImp(); - static DWORD DuplicateImpAsPrimary(HANDLE& hPrimary); -#endif - - SecureClient(); - ~SecureClient(); - DWORD Error(); - -private: - static CcOsLock s_lock; - static DWORD s_refcount; - static DWORD s_error; - static HANDLE s_hToken; - - DWORD m_Error; - HANDLE m_hToken; - bool m_NeedRestore; -}; +/* + * $Header$ + * + * Copyright 2008 Massachusetts Institute of Technology. + * All Rights Reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Furthermore if you modify this software you must label + * your software as modified software and not distribute it in such a + * fashion that it might be confused with the original M.I.T. software. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + */ + +#pragma once + +#include +#include "autolock.hxx" + +class SecureClient +{ +public: + static DWORD Attach(); + static DWORD Detach(); + static DWORD Token(HANDLE& hToken); + static void Start(SecureClient*& s); + static void Stop(SecureClient*& s); + +#if 0 + static DWORD CheckImpersonation(); + static bool IsImp(); + static DWORD DuplicateImpAsPrimary(HANDLE& hPrimary); +#endif + + SecureClient(); + ~SecureClient(); + DWORD Error(); + +private: + static CcOsLock s_lock; + static DWORD s_refcount; + static DWORD s_error; + static HANDLE s_hToken; + + DWORD m_Error; + HANDLE m_hToken; + bool m_NeedRestore; +}; diff --git a/src/ccapi/common/win/OldCC/util.cxx b/src/ccapi/common/win/OldCC/util.cxx index 62b204b92..8694c373c 100644 --- a/src/ccapi/common/win/OldCC/util.cxx +++ b/src/ccapi/common/win/OldCC/util.cxx @@ -1,519 +1,519 @@ -/* - * $Header$ - * - * Copyright 2008 Massachusetts Institute of Technology. - * All Rights Reserved. - * - * Export of this software from the United States of America may - * require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. Furthermore if you modify this software you must label - * your software as modified software and not distribute it in such a - * fashion that it might be confused with the original M.I.T. software. - * M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - */ - -#include -#include // for _snprintf - -#include "util.h" -#include "secure.hxx" - -extern "C" { -#include "cci_debugging.h" -#include "ccutils.h" - } - - - -void* malloc_alloc_p(size_t size) { - return malloc(size); - } - -void free_alloc_p(void *pptr) { - void **real_pptr = (void**)pptr; - if (*real_pptr) { - free(*real_pptr); - *real_pptr = 0; - } - } - -extern "C" DWORD alloc_textual_sid( - PSID pSid, // binary Sid - LPSTR *pTextualSid // buffer for Textual representaion of Sid - ) { - PSID_IDENTIFIER_AUTHORITY psia; - DWORD dwSubAuthorities; - DWORD dwSidRev = SID_REVISION; - DWORD dwCounter; - DWORD dwSidSize; - - *pTextualSid = 0; - - // - // test if Sid passed in is valid - // - if(!IsValidSid(pSid)) return ERROR_INVALID_PARAMETER; - - // obtain SidIdentifierAuthority - psia = GetSidIdentifierAuthority(pSid); - - // obtain sidsubauthority count - dwSubAuthorities =* GetSidSubAuthorityCount(pSid); - - // - // compute buffer length - // S-SID_REVISION- + identifierauthority- + subauthorities- + NULL - // - dwSidSize = (15 + 12 + (12 * dwSubAuthorities) + 1) * sizeof(TCHAR); - *pTextualSid = (LPSTR)malloc_alloc_p(dwSidSize); - if (!*pTextualSid) - return GetLastError(); - - LPSTR TextualSid = *pTextualSid; - - // - // prepare S-SID_REVISION- - // - wsprintf(TextualSid, TEXT("S-%lu-"), dwSidRev ); - - // - // prepare SidIdentifierAuthority - // - if ( (psia->Value[0] != 0) || (psia->Value[1] != 0) ) - { - wsprintf(TextualSid + lstrlen(TextualSid), - TEXT("0x%02hx%02hx%02hx%02hx%02hx%02hx"), - (USHORT)psia->Value[0], - (USHORT)psia->Value[1], - (USHORT)psia->Value[2], - (USHORT)psia->Value[3], - (USHORT)psia->Value[4], - (USHORT)psia->Value[5]); - } - else - { - wsprintf(TextualSid + lstrlen(TextualSid), TEXT("%lu"), - (ULONG)(psia->Value[5] ) + - (ULONG)(psia->Value[4] << 8) + - (ULONG)(psia->Value[3] << 16) + - (ULONG)(psia->Value[2] << 24) ); - } - - // - // loop through SidSubAuthorities - // - for (dwCounter=0 ; dwCounter < dwSubAuthorities ; dwCounter++) - { - wsprintf(TextualSid + lstrlen(TextualSid), TEXT("-%lu"), - *GetSidSubAuthority(pSid, dwCounter) ); - } - return 0; -} - -DWORD alloc_token_user(HANDLE hToken, PTOKEN_USER *pptu) { - DWORD status = 0; - DWORD size = 0; - *pptu = 0; - - GetTokenInformation(hToken, TokenUser, *pptu, 0, &size); - if (size == 0) status = GetLastError(); - - if (!status) { - if (!(*pptu = (PTOKEN_USER)malloc_alloc_p(size))) - status = GetLastError(); - } - - if (!status) { - if (!GetTokenInformation(hToken, TokenUser, *pptu, size, &size)) - status = GetLastError(); - } - - if (status && *pptu) { - free_alloc_p(pptu); - } - return status; - } - -DWORD -alloc_username( - PSID Sid, - LPSTR* pname, - LPSTR* pdomain = 0 - ) -{ - DWORD status = 0; - DWORD name_len = 0; - DWORD domain_len = 0; - SID_NAME_USE snu; - LPSTR name = 0; - LPSTR domain = 0; - - *pname = 0; - if (pdomain) *pdomain = 0; - - LookupAccountSidA(NULL, Sid, 0, &name_len, 0, &domain_len, &snu); - if ((name_len == 0) || (domain_len == 0)) status = GetLastError(); - - if (!status) { - if (!(name = (LPSTR)malloc_alloc_p(name_len))) status = GetLastError(); - } - - if (!status) { - if (!(domain = (LPSTR)malloc_alloc_p(domain_len))) status = GetLastError(); - } - - if (!status) { - if (!LookupAccountSidA(NULL, Sid, name, &name_len, domain, &domain_len, &snu)) status = GetLastError(); - } - - if (status) { - if (name) free_alloc_p(&name); - if (domain) free_alloc_p(&domain); - } - else { - if (pdomain) { - *pname = name; - *pdomain = domain; - } - else { - DWORD size = name_len + domain_len + 1; - *pname = (LPSTR)malloc_alloc_p(size); - if (!*pname) status = GetLastError(); - else _snprintf(*pname, size, "%s\\%s", name, domain); - } - } - return status; - } - -DWORD get_authentication_id(HANDLE hToken, LUID* pAuthId) { - TOKEN_STATISTICS ts; - DWORD len; - - if (!GetTokenInformation(hToken, TokenStatistics, &ts, sizeof(ts), &len)) - return GetLastError(); - *pAuthId = ts.AuthenticationId; - return 0; - } - -DWORD -alloc_name_9x( - LPSTR* pname, - LPSTR postfix - ) -{ - char prefix[] = "krbcc"; - DWORD len = (sizeof(prefix) - 1) + 1 + strlen(postfix) + 1; - - *pname = (LPSTR)malloc_alloc_p(len); - if (!*pname) return GetLastError(); - _snprintf(*pname, len, "%s.%s", prefix, postfix); - return 0; -} - -DWORD alloc_name_NT(LPSTR* pname, LPSTR postfix) { - DWORD status = 0; - HANDLE hToken = 0; - LUID auth_id; -#ifdef _DEBUG - PTOKEN_USER ptu = 0; - LPSTR name = 0; - LPSTR domain = 0; - LPSTR sid = 0; -#endif - char prefix[] = "krbcc"; - // Play it safe and say 3 characters are needed per 8 bits (byte). - // Note that 20 characters are needed for a 64-bit number in - // decimal (plus one for the string termination. - // and include room for sessionId. - char lid[3*sizeof(LUID)+1+5]; - DWORD sessionId; - DWORD len = 0; - - *pname = 0; - - status = SecureClient::Token(hToken); - - if (!status) { - status = get_authentication_id(hToken, &auth_id); - } - - if (!status) { - if (!ProcessIdToSessionId(GetCurrentProcessId(), &sessionId)) - sessionId = 0; - } - -#ifdef _DEBUG - if (!status) {status = alloc_token_user(hToken, &ptu);} - if (!status) {status = alloc_username(ptu->User.Sid, &name, &domain);} - if (!status) {status = alloc_textual_sid(ptu->User.Sid, &sid);} -#endif - - if (!status) { - _snprintf(lid, sizeof(lid), "%I64u.%u", auth_id, sessionId); - lid[sizeof(lid)-1] = 0; // be safe - - len = (sizeof(prefix) - 1) + 1 + strlen(lid) + 1 + strlen(postfix) + 1; - *pname = (LPSTR)malloc_alloc_p(len); - if (!*pname) status = GetLastError(); - } - - // - // We used to allocate a name of the form: - // "prefix.domain.name.sid.lid.postfix" (usually under 80 - // characters, depending on username). However, XP thought this - // was "invalid" (too long?) for some reason. - // - // Therefore, we now use "prefix.lid.postfix" - // and for Terminal server we use "prefix.lid.sessionId.postfix" - // - - if (!status) { - _snprintf(*pname, len, "%s.%s.%s", prefix, lid, postfix); - } - -#ifdef _DEBUG - if (sid) - free_alloc_p(&sid); - if (name) - free_alloc_p(&name); - if (domain) - free_alloc_p(&domain); - if (ptu) - free_alloc_p(&ptu); -#endif - if (hToken && hToken != INVALID_HANDLE_VALUE) - CloseHandle(hToken); - if (status && *pname) - free_alloc_p(pname); - return status; -} - -extern "C" DWORD alloc_name(LPSTR* pname, LPSTR postfix, BOOL isNT) { - return isNT ? alloc_name_NT(pname, postfix) : - alloc_name_9x(pname, postfix); - } - -extern "C" DWORD alloc_own_security_descriptor_NT(PSECURITY_DESCRIPTOR* ppsd) { - DWORD status = 0; - HANDLE hToken = 0; - PTOKEN_USER ptu = 0; - PSID pSid = 0; - PACL pAcl = 0; - DWORD size = 0; - SECURITY_DESCRIPTOR sd; - - *ppsd = 0; - - if (!status) {status = SecureClient::Token(hToken);} - - // Get SID: - if (!status) {status = alloc_token_user(hToken, &ptu);} - - if (!status) { - size = GetLengthSid(ptu->User.Sid); - pSid = (PSID) malloc_alloc_p(size); - if (!pSid) status = GetLastError(); - } - if (!status) { - if (!CopySid(size, pSid, ptu->User.Sid)) status = GetLastError(); - } - - if (!status) { - // Prepare ACL: - size = sizeof(ACL); - // Add an ACE: - size += sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(pSid); - pAcl = (PACL) malloc_alloc_p(size); - if (!pAcl) status = GetLastError(); - } - - if (!status) { - if (!InitializeAcl(pAcl, size, ACL_REVISION)) status = GetLastError(); - } - - if (!status) { - if (!AddAccessAllowedAce(pAcl, ACL_REVISION, GENERIC_ALL, pSid)) status = GetLastError(); - } - - if (!status) { - // Prepare SD itself: - if (!InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION)) status = GetLastError(); - } - - if (!status) { - if (!SetSecurityDescriptorDacl(&sd, TRUE, pAcl, FALSE)) status = GetLastError(); - } - - if (!status) { - if (!SetSecurityDescriptorOwner(&sd, pSid, FALSE)) status = GetLastError(); - } - - if (!status) { - if (!IsValidSecurityDescriptor(&sd)) status = ERROR_INVALID_PARAMETER; - } - - if (!status) { - // We now have a SD. Let's copy it. - { - // This should not succeed. Instead it should give us the size. - BOOL ok = MakeSelfRelativeSD(&sd, 0, &size); - } - if (size == 0) status = GetLastError(); - } - - if (!status) { - *ppsd = (PSECURITY_DESCRIPTOR) malloc_alloc_p(size); - if (!*ppsd) status = GetLastError(); - } - - if (!status) { - if (!MakeSelfRelativeSD(&sd, *ppsd, &size)) status = GetLastError(); - } - - if (ptu) free_alloc_p(&ptu); - if (pSid) free_alloc_p(&pSid); - if (pAcl) free_alloc_p(&pAcl); - if (hToken && hToken != INVALID_HANDLE_VALUE) CloseHandle(hToken); - if (status && *ppsd) free_alloc_p(ppsd); - return status; -} - -DWORD -alloc_module_file_name( - char* module, - char** pname - ) -{ - const DWORD max = 8192; - DWORD status = 0; - DWORD got = 0; - DWORD size = 512; // use low number to test... - HMODULE h = 0; - BOOL ok = FALSE; - char* name = 0; - - if (!pname) - return ERROR_INVALID_PARAMETER; - *pname = 0; - - h = GetModuleHandle(module); - - if (!h) return GetLastError(); - - // We assume size < max and size > 0 - while (!status && !ok) { - if (size > max) { - // XXX - Assert? - status = ERROR_INVALID_DATA; - continue; - } - if (name) free_alloc_p(&name); - name = (char*)malloc_alloc_p(size + 1); - if (!name) { - status = ERROR_NOT_ENOUGH_MEMORY; - continue; - } - name[size] = 0; - got = GetModuleFileName(h, name, size); - if (!got) { - status = GetLastError(); - // sanity check: - if (!status) { - // XXX - print nasty message...assert? - status = ERROR_INVALID_DATA; - } - continue; - } - // To know we're ok, we need to verify that what we got - // was bigger than GetModuleSize thought it got. - ok = got && (got < size) && !name[got]; - size *= 2; - } - if (status && name) - free_alloc_p(&name); - else - *pname = name; - return status; -} - -DWORD -alloc_module_dir_name( - char* module, - char** pname - ) -{ - DWORD status = alloc_module_file_name(module, pname); - if (!status) { - char* name = *pname; - char* p = name + strlen(name); - while ((p >= name) && (*p != '\\') && (*p != '/')) p--; - if (p < name) { - free_alloc_p(pname); - status = ERROR_INVALID_DATA; - } else { - *p = 0; - } - } - return status; -} - -DWORD -alloc_module_dir_name_with_file( - char* module, - char* file, - char** pname - ) -{ - DWORD status = alloc_module_dir_name(module, pname); - if (!status) { - char* name = *pname; - size_t name_size = strlen(name); - size_t size = name_size + 1 + strlen(file) + 1; - char* result = (char*)malloc_alloc_p(size); - if (!result) { - status = ERROR_NOT_ENOUGH_MEMORY; - free_alloc_p(pname); - } else { - strcpy(result, name); - result[name_size] = '\\'; - strcpy(result + name_size + 1, file); - free_alloc_p(pname); - *pname = result; - } - } - return status; -} - -DWORD alloc_cmdline_2_args(char* prog, - char* arg1, - char* arg2, - char** pname) { - DWORD status = 0; - size_t size = strlen(prog) + strlen(arg1) + strlen(arg2) + 4; - char* result = (char*)malloc_alloc_p(size); - if (!result) { - status = ERROR_NOT_ENOUGH_MEMORY; - } - else { - strcpy(result, prog); - strcat(result, " "); - strcat(result, arg1); - strcat(result, " "); - strcat(result, arg2); - *pname = result; - } - cci_debug_printf("%s made <%s>", __FUNCTION__, result); - return status; - } +/* + * $Header$ + * + * Copyright 2008 Massachusetts Institute of Technology. + * All Rights Reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Furthermore if you modify this software you must label + * your software as modified software and not distribute it in such a + * fashion that it might be confused with the original M.I.T. software. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + */ + +#include +#include // for _snprintf + +#include "util.h" +#include "secure.hxx" + +extern "C" { +#include "cci_debugging.h" +#include "ccutils.h" + } + + + +void* malloc_alloc_p(size_t size) { + return malloc(size); + } + +void free_alloc_p(void *pptr) { + void **real_pptr = (void**)pptr; + if (*real_pptr) { + free(*real_pptr); + *real_pptr = 0; + } + } + +extern "C" DWORD alloc_textual_sid( + PSID pSid, // binary Sid + LPSTR *pTextualSid // buffer for Textual representaion of Sid + ) { + PSID_IDENTIFIER_AUTHORITY psia; + DWORD dwSubAuthorities; + DWORD dwSidRev = SID_REVISION; + DWORD dwCounter; + DWORD dwSidSize; + + *pTextualSid = 0; + + // + // test if Sid passed in is valid + // + if(!IsValidSid(pSid)) return ERROR_INVALID_PARAMETER; + + // obtain SidIdentifierAuthority + psia = GetSidIdentifierAuthority(pSid); + + // obtain sidsubauthority count + dwSubAuthorities =* GetSidSubAuthorityCount(pSid); + + // + // compute buffer length + // S-SID_REVISION- + identifierauthority- + subauthorities- + NULL + // + dwSidSize = (15 + 12 + (12 * dwSubAuthorities) + 1) * sizeof(TCHAR); + *pTextualSid = (LPSTR)malloc_alloc_p(dwSidSize); + if (!*pTextualSid) + return GetLastError(); + + LPSTR TextualSid = *pTextualSid; + + // + // prepare S-SID_REVISION- + // + wsprintf(TextualSid, TEXT("S-%lu-"), dwSidRev ); + + // + // prepare SidIdentifierAuthority + // + if ( (psia->Value[0] != 0) || (psia->Value[1] != 0) ) + { + wsprintf(TextualSid + lstrlen(TextualSid), + TEXT("0x%02hx%02hx%02hx%02hx%02hx%02hx"), + (USHORT)psia->Value[0], + (USHORT)psia->Value[1], + (USHORT)psia->Value[2], + (USHORT)psia->Value[3], + (USHORT)psia->Value[4], + (USHORT)psia->Value[5]); + } + else + { + wsprintf(TextualSid + lstrlen(TextualSid), TEXT("%lu"), + (ULONG)(psia->Value[5] ) + + (ULONG)(psia->Value[4] << 8) + + (ULONG)(psia->Value[3] << 16) + + (ULONG)(psia->Value[2] << 24) ); + } + + // + // loop through SidSubAuthorities + // + for (dwCounter=0 ; dwCounter < dwSubAuthorities ; dwCounter++) + { + wsprintf(TextualSid + lstrlen(TextualSid), TEXT("-%lu"), + *GetSidSubAuthority(pSid, dwCounter) ); + } + return 0; +} + +DWORD alloc_token_user(HANDLE hToken, PTOKEN_USER *pptu) { + DWORD status = 0; + DWORD size = 0; + *pptu = 0; + + GetTokenInformation(hToken, TokenUser, *pptu, 0, &size); + if (size == 0) status = GetLastError(); + + if (!status) { + if (!(*pptu = (PTOKEN_USER)malloc_alloc_p(size))) + status = GetLastError(); + } + + if (!status) { + if (!GetTokenInformation(hToken, TokenUser, *pptu, size, &size)) + status = GetLastError(); + } + + if (status && *pptu) { + free_alloc_p(pptu); + } + return status; + } + +DWORD +alloc_username( + PSID Sid, + LPSTR* pname, + LPSTR* pdomain = 0 + ) +{ + DWORD status = 0; + DWORD name_len = 0; + DWORD domain_len = 0; + SID_NAME_USE snu; + LPSTR name = 0; + LPSTR domain = 0; + + *pname = 0; + if (pdomain) *pdomain = 0; + + LookupAccountSidA(NULL, Sid, 0, &name_len, 0, &domain_len, &snu); + if ((name_len == 0) || (domain_len == 0)) status = GetLastError(); + + if (!status) { + if (!(name = (LPSTR)malloc_alloc_p(name_len))) status = GetLastError(); + } + + if (!status) { + if (!(domain = (LPSTR)malloc_alloc_p(domain_len))) status = GetLastError(); + } + + if (!status) { + if (!LookupAccountSidA(NULL, Sid, name, &name_len, domain, &domain_len, &snu)) status = GetLastError(); + } + + if (status) { + if (name) free_alloc_p(&name); + if (domain) free_alloc_p(&domain); + } + else { + if (pdomain) { + *pname = name; + *pdomain = domain; + } + else { + DWORD size = name_len + domain_len + 1; + *pname = (LPSTR)malloc_alloc_p(size); + if (!*pname) status = GetLastError(); + else _snprintf(*pname, size, "%s\\%s", name, domain); + } + } + return status; + } + +DWORD get_authentication_id(HANDLE hToken, LUID* pAuthId) { + TOKEN_STATISTICS ts; + DWORD len; + + if (!GetTokenInformation(hToken, TokenStatistics, &ts, sizeof(ts), &len)) + return GetLastError(); + *pAuthId = ts.AuthenticationId; + return 0; + } + +DWORD +alloc_name_9x( + LPSTR* pname, + LPSTR postfix + ) +{ + char prefix[] = "krbcc"; + DWORD len = (sizeof(prefix) - 1) + 1 + strlen(postfix) + 1; + + *pname = (LPSTR)malloc_alloc_p(len); + if (!*pname) return GetLastError(); + _snprintf(*pname, len, "%s.%s", prefix, postfix); + return 0; +} + +DWORD alloc_name_NT(LPSTR* pname, LPSTR postfix) { + DWORD status = 0; + HANDLE hToken = 0; + LUID auth_id; +#ifdef _DEBUG + PTOKEN_USER ptu = 0; + LPSTR name = 0; + LPSTR domain = 0; + LPSTR sid = 0; +#endif + char prefix[] = "krbcc"; + // Play it safe and say 3 characters are needed per 8 bits (byte). + // Note that 20 characters are needed for a 64-bit number in + // decimal (plus one for the string termination. + // and include room for sessionId. + char lid[3*sizeof(LUID)+1+5]; + DWORD sessionId; + DWORD len = 0; + + *pname = 0; + + status = SecureClient::Token(hToken); + + if (!status) { + status = get_authentication_id(hToken, &auth_id); + } + + if (!status) { + if (!ProcessIdToSessionId(GetCurrentProcessId(), &sessionId)) + sessionId = 0; + } + +#ifdef _DEBUG + if (!status) {status = alloc_token_user(hToken, &ptu);} + if (!status) {status = alloc_username(ptu->User.Sid, &name, &domain);} + if (!status) {status = alloc_textual_sid(ptu->User.Sid, &sid);} +#endif + + if (!status) { + _snprintf(lid, sizeof(lid), "%I64u.%u", auth_id, sessionId); + lid[sizeof(lid)-1] = 0; // be safe + + len = (sizeof(prefix) - 1) + 1 + strlen(lid) + 1 + strlen(postfix) + 1; + *pname = (LPSTR)malloc_alloc_p(len); + if (!*pname) status = GetLastError(); + } + + // + // We used to allocate a name of the form: + // "prefix.domain.name.sid.lid.postfix" (usually under 80 + // characters, depending on username). However, XP thought this + // was "invalid" (too long?) for some reason. + // + // Therefore, we now use "prefix.lid.postfix" + // and for Terminal server we use "prefix.lid.sessionId.postfix" + // + + if (!status) { + _snprintf(*pname, len, "%s.%s.%s", prefix, lid, postfix); + } + +#ifdef _DEBUG + if (sid) + free_alloc_p(&sid); + if (name) + free_alloc_p(&name); + if (domain) + free_alloc_p(&domain); + if (ptu) + free_alloc_p(&ptu); +#endif + if (hToken && hToken != INVALID_HANDLE_VALUE) + CloseHandle(hToken); + if (status && *pname) + free_alloc_p(pname); + return status; +} + +extern "C" DWORD alloc_name(LPSTR* pname, LPSTR postfix, BOOL isNT) { + return isNT ? alloc_name_NT(pname, postfix) : + alloc_name_9x(pname, postfix); + } + +extern "C" DWORD alloc_own_security_descriptor_NT(PSECURITY_DESCRIPTOR* ppsd) { + DWORD status = 0; + HANDLE hToken = 0; + PTOKEN_USER ptu = 0; + PSID pSid = 0; + PACL pAcl = 0; + DWORD size = 0; + SECURITY_DESCRIPTOR sd; + + *ppsd = 0; + + if (!status) {status = SecureClient::Token(hToken);} + + // Get SID: + if (!status) {status = alloc_token_user(hToken, &ptu);} + + if (!status) { + size = GetLengthSid(ptu->User.Sid); + pSid = (PSID) malloc_alloc_p(size); + if (!pSid) status = GetLastError(); + } + if (!status) { + if (!CopySid(size, pSid, ptu->User.Sid)) status = GetLastError(); + } + + if (!status) { + // Prepare ACL: + size = sizeof(ACL); + // Add an ACE: + size += sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + GetLengthSid(pSid); + pAcl = (PACL) malloc_alloc_p(size); + if (!pAcl) status = GetLastError(); + } + + if (!status) { + if (!InitializeAcl(pAcl, size, ACL_REVISION)) status = GetLastError(); + } + + if (!status) { + if (!AddAccessAllowedAce(pAcl, ACL_REVISION, GENERIC_ALL, pSid)) status = GetLastError(); + } + + if (!status) { + // Prepare SD itself: + if (!InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION)) status = GetLastError(); + } + + if (!status) { + if (!SetSecurityDescriptorDacl(&sd, TRUE, pAcl, FALSE)) status = GetLastError(); + } + + if (!status) { + if (!SetSecurityDescriptorOwner(&sd, pSid, FALSE)) status = GetLastError(); + } + + if (!status) { + if (!IsValidSecurityDescriptor(&sd)) status = ERROR_INVALID_PARAMETER; + } + + if (!status) { + // We now have a SD. Let's copy it. + { + // This should not succeed. Instead it should give us the size. + BOOL ok = MakeSelfRelativeSD(&sd, 0, &size); + } + if (size == 0) status = GetLastError(); + } + + if (!status) { + *ppsd = (PSECURITY_DESCRIPTOR) malloc_alloc_p(size); + if (!*ppsd) status = GetLastError(); + } + + if (!status) { + if (!MakeSelfRelativeSD(&sd, *ppsd, &size)) status = GetLastError(); + } + + if (ptu) free_alloc_p(&ptu); + if (pSid) free_alloc_p(&pSid); + if (pAcl) free_alloc_p(&pAcl); + if (hToken && hToken != INVALID_HANDLE_VALUE) CloseHandle(hToken); + if (status && *ppsd) free_alloc_p(ppsd); + return status; +} + +DWORD +alloc_module_file_name( + char* module, + char** pname + ) +{ + const DWORD max = 8192; + DWORD status = 0; + DWORD got = 0; + DWORD size = 512; // use low number to test... + HMODULE h = 0; + BOOL ok = FALSE; + char* name = 0; + + if (!pname) + return ERROR_INVALID_PARAMETER; + *pname = 0; + + h = GetModuleHandle(module); + + if (!h) return GetLastError(); + + // We assume size < max and size > 0 + while (!status && !ok) { + if (size > max) { + // XXX - Assert? + status = ERROR_INVALID_DATA; + continue; + } + if (name) free_alloc_p(&name); + name = (char*)malloc_alloc_p(size + 1); + if (!name) { + status = ERROR_NOT_ENOUGH_MEMORY; + continue; + } + name[size] = 0; + got = GetModuleFileName(h, name, size); + if (!got) { + status = GetLastError(); + // sanity check: + if (!status) { + // XXX - print nasty message...assert? + status = ERROR_INVALID_DATA; + } + continue; + } + // To know we're ok, we need to verify that what we got + // was bigger than GetModuleSize thought it got. + ok = got && (got < size) && !name[got]; + size *= 2; + } + if (status && name) + free_alloc_p(&name); + else + *pname = name; + return status; +} + +DWORD +alloc_module_dir_name( + char* module, + char** pname + ) +{ + DWORD status = alloc_module_file_name(module, pname); + if (!status) { + char* name = *pname; + char* p = name + strlen(name); + while ((p >= name) && (*p != '\\') && (*p != '/')) p--; + if (p < name) { + free_alloc_p(pname); + status = ERROR_INVALID_DATA; + } else { + *p = 0; + } + } + return status; +} + +DWORD +alloc_module_dir_name_with_file( + char* module, + char* file, + char** pname + ) +{ + DWORD status = alloc_module_dir_name(module, pname); + if (!status) { + char* name = *pname; + size_t name_size = strlen(name); + size_t size = name_size + 1 + strlen(file) + 1; + char* result = (char*)malloc_alloc_p(size); + if (!result) { + status = ERROR_NOT_ENOUGH_MEMORY; + free_alloc_p(pname); + } else { + strcpy(result, name); + result[name_size] = '\\'; + strcpy(result + name_size + 1, file); + free_alloc_p(pname); + *pname = result; + } + } + return status; +} + +DWORD alloc_cmdline_2_args(char* prog, + char* arg1, + char* arg2, + char** pname) { + DWORD status = 0; + size_t size = strlen(prog) + strlen(arg1) + strlen(arg2) + 4; + char* result = (char*)malloc_alloc_p(size); + if (!result) { + status = ERROR_NOT_ENOUGH_MEMORY; + } + else { + strcpy(result, prog); + strcat(result, " "); + strcat(result, arg1); + strcat(result, " "); + strcat(result, arg2); + *pname = result; + } + cci_debug_printf("%s made <%s>", __FUNCTION__, result); + return status; + } diff --git a/src/ccapi/common/win/ccs_reply.Acf b/src/ccapi/common/win/ccs_reply.Acf index 89e8abe7a..aea44d74c 100644 --- a/src/ccapi/common/win/ccs_reply.Acf +++ b/src/ccapi/common/win/ccs_reply.Acf @@ -1,31 +1,31 @@ -/* - * $Header$ - * - * Copyright 2008 Massachusetts Institute of Technology. - * All Rights Reserved. - * - * Export of this software from the United States of America may - * require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. Furthermore if you modify this software you must label - * your software as modified software and not distribute it in such a - * fashion that it might be confused with the original M.I.T. software. - * M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - */ - -[implicit_handle(handle_t ccs_reply_IfHandle)] - -interface ccs_reply { - [async] ccapi_listen(); - } +/* + * $Header$ + * + * Copyright 2008 Massachusetts Institute of Technology. + * All Rights Reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Furthermore if you modify this software you must label + * your software as modified software and not distribute it in such a + * fashion that it might be confused with the original M.I.T. software. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + */ + +[implicit_handle(handle_t ccs_reply_IfHandle)] + +interface ccs_reply { + [async] ccapi_listen(); + } diff --git a/src/ccapi/common/win/ccs_reply.Idl b/src/ccapi/common/win/ccs_reply.Idl index 4c6f6f304..9035a4d00 100644 --- a/src/ccapi/common/win/ccs_reply.Idl +++ b/src/ccapi/common/win/ccs_reply.Idl @@ -1,60 +1,60 @@ -/* - * $Header$ - * - * Copyright 2008 Massachusetts Institute of Technology. - * All Rights Reserved. - * - * Export of this software from the United States of America may - * require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. Furthermore if you modify this software you must label - * your software as modified software and not distribute it in such a - * fashion that it might be confused with the original M.I.T. software. - * M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - */ - -[ uuid (6E3B5060-CA46-1067-B31A-00DD010662DA), - version(1.0), - pointer_default(unique) -] - -/* This interface sends a cci_stream via rpc. - */ - -interface ccs_reply { - const long HSIZE = sizeof(void*); - -/* The reply from the server to a request from the client: */ -void ccs_rpc_request_reply( - [in] const long rpcmsg, /* Message type */ - [in, size_is(HSIZE)] const char tsphandle[], - [in, string] const char* uuid, - [in] const long srvStartTime, /* Server Start Time */ - [in] const long cbIn, /* Length of buffer */ - [in, size_is(cbIn)] const unsigned char chIn[], /* Data buffer */ - [out] long* status ); /* Return code */ - -void ccs_rpc_connect_reply( - [in] const long rpcmsg, /* Message type */ - [in, size_is(HSIZE)] const char tsphandle[], - [in, string] const char* uuid, - [in] const long srvStartTime, /* Server Start Time */ - [out] long* status ); /* Return code */ - -void ccapi_listen( - handle_t hBinding, - [in] const long rpcmsg, /* Message type */ - [out] long* status ); /* Return code */ - - } +/* + * $Header$ + * + * Copyright 2008 Massachusetts Institute of Technology. + * All Rights Reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Furthermore if you modify this software you must label + * your software as modified software and not distribute it in such a + * fashion that it might be confused with the original M.I.T. software. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + */ + +[ uuid (6E3B5060-CA46-1067-B31A-00DD010662DA), + version(1.0), + pointer_default(unique) +] + +/* This interface sends a cci_stream via rpc. + */ + +interface ccs_reply { + const long HSIZE = sizeof(void*); + +/* The reply from the server to a request from the client: */ +void ccs_rpc_request_reply( + [in] const long rpcmsg, /* Message type */ + [in, size_is(HSIZE)] const char tsphandle[], + [in, string] const char* uuid, + [in] const long srvStartTime, /* Server Start Time */ + [in] const long cbIn, /* Length of buffer */ + [in, size_is(cbIn)] const unsigned char chIn[], /* Data buffer */ + [out] long* status ); /* Return code */ + +void ccs_rpc_connect_reply( + [in] const long rpcmsg, /* Message type */ + [in, size_is(HSIZE)] const char tsphandle[], + [in, string] const char* uuid, + [in] const long srvStartTime, /* Server Start Time */ + [out] long* status ); /* Return code */ + +void ccapi_listen( + handle_t hBinding, + [in] const long rpcmsg, /* Message type */ + [out] long* status ); /* Return code */ + + } diff --git a/src/ccapi/common/win/ccs_request.Acf b/src/ccapi/common/win/ccs_request.Acf index 853a15252..625bcce65 100644 --- a/src/ccapi/common/win/ccs_request.Acf +++ b/src/ccapi/common/win/ccs_request.Acf @@ -1,31 +1,31 @@ -/* - * $Header$ - * - * Copyright 2008 Massachusetts Institute of Technology. - * All Rights Reserved. - * - * Export of this software from the United States of America may - * require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. Furthermore if you modify this software you must label - * your software as modified software and not distribute it in such a - * fashion that it might be confused with the original M.I.T. software. - * M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - */ - -[implicit_handle(handle_t ccs_request_IfHandle)] -interface ccs_request -{ - -} +/* + * $Header$ + * + * Copyright 2008 Massachusetts Institute of Technology. + * All Rights Reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Furthermore if you modify this software you must label + * your software as modified software and not distribute it in such a + * fashion that it might be confused with the original M.I.T. software. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + */ + +[implicit_handle(handle_t ccs_request_IfHandle)] +interface ccs_request +{ + +} diff --git a/src/ccapi/common/win/ccs_request.idl b/src/ccapi/common/win/ccs_request.idl index bd693142c..8c68fd8f3 100644 --- a/src/ccapi/common/win/ccs_request.idl +++ b/src/ccapi/common/win/ccs_request.idl @@ -1,58 +1,58 @@ -/* - * $Header$ - * - * Copyright 2008 Massachusetts Institute of Technology. - * All Rights Reserved. - * - * Export of this software from the United States of America may - * require a specific license from the United States Government. - * It is the responsibility of any person or organization contemplating - * export to obtain such a license before exporting. - * - * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and - * distribute this software and its documentation for any purpose and - * without fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright notice and - * this permission notice appear in supporting documentation, and that - * the name of M.I.T. not be used in advertising or publicity pertaining - * to distribution of the software without specific, written prior - * permission. Furthermore if you modify this software you must label - * your software as modified software and not distribute it in such a - * fashion that it might be confused with the original M.I.T. software. - * M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" without express - * or implied warranty. - */ - -[ uuid (906B0CE0-C70B-1067-B317-00DD010662DA), - version(1.0), - pointer_default(unique) -] - -interface ccs_request { - -typedef char CC_CHAR; -typedef unsigned char CC_UCHAR; -typedef int CC_INT32; -typedef unsigned int CC_UINT32; - -const long HSIZE = sizeof(void*); - -void ccs_rpc_request( - [in] const long rpcmsg, /* Message type */ - [in, size_is(HSIZE)] const char tsphandle[], - [in, string] const char* pszUUID, /* Requestor's UUID */ - [in] const long lenRequest, /* Length of buffer */ - [in, size_is(lenRequest)] const char* pszRequest, /* Data buffer */ - [in] const long serverStartTime,/* Which server session we're talking to */ - [out] long* status ); /* Return code */ - -void ccs_rpc_connect( - [in] const long rpcmsg, /* Message type */ - [in, size_is(HSIZE)] const char tsphandle[], - [in, string] const char* pszUUID, /* Requestor's UUID */ - [out] long* status ); /* Return code */ - -CC_UINT32 ccs_authenticate( - [in, string] const CC_CHAR* name ); -} +/* + * $Header$ + * + * Copyright 2008 Massachusetts Institute of Technology. + * All Rights Reserved. + * + * Export of this software from the United States of America may + * require a specific license from the United States Government. + * It is the responsibility of any person or organization contemplating + * export to obtain such a license before exporting. + * + * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and + * distribute this software and its documentation for any purpose and + * without fee is hereby granted, provided that the above copyright + * notice appear in all copies and that both that copyright notice and + * this permission notice appear in supporting documentation, and that + * the name of M.I.T. not be used in advertising or publicity pertaining + * to distribution of the software without specific, written prior + * permission. Furthermore if you modify this software you must label + * your software as modified software and not distribute it in such a + * fashion that it might be confused with the original M.I.T. software. + * M.I.T. makes no representations about the suitability of + * this software for any purpose. It is provided "as is" without express + * or implied warranty. + */ + +[ uuid (906B0CE0-C70B-1067-B317-00DD010662DA), + version(1.0), + pointer_default(unique) +] + +interface ccs_request { + +typedef char CC_CHAR; +typedef unsigned char CC_UCHAR; +typedef int CC_INT32; +typedef unsigned int CC_UINT32; + +const long HSIZE = sizeof(void*); + +void ccs_rpc_request( + [in] const long rpcmsg, /* Message type */ + [in, size_is(HSIZE)] const char tsphandle[], + [in, string] const char* pszUUID, /* Requestor's UUID */ + [in] const long lenRequest, /* Length of buffer */ + [in, size_is(lenRequest)] const char* pszRequest, /* Data buffer */ + [in] const long serverStartTime,/* Which server session we're talking to */ + [out] long* status ); /* Return code */ + +void ccs_rpc_connect( + [in] const long rpcmsg, /* Message type */ + [in, size_is(HSIZE)] const char tsphandle[], + [in, string] const char* pszUUID, /* Requestor's UUID */ + [out] long* status ); /* Return code */ + +CC_UINT32 ccs_authenticate( + [in, string] const CC_CHAR* name ); +} -- cgit