libfreerdp-core: add proper SPN for HTTP authentication in TSG
This commit is contained in:
parent
744c60b66d
commit
78908fb857
@ -114,7 +114,7 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
|
||||
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
|
||||
MONOLITHIC ${MONOLITHIC_BUILD}
|
||||
MODULE winpr
|
||||
MODULES winpr-registry winpr-utils winpr-sspi winpr-crt)
|
||||
MODULES winpr-registry winpr-utils winpr-dsparse winpr-sspi winpr-crt)
|
||||
|
||||
if(MONOLITHIC_BUILD)
|
||||
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/dsparse.h>
|
||||
|
||||
#include <openssl/rand.h>
|
||||
|
||||
#include "http.h"
|
||||
@ -65,6 +67,25 @@ BOOL ntlm_client_init(rdpNtlm* ntlm, BOOL http, char* user, char* domain, char*
|
||||
|
||||
sspi_SetAuthIdentity(&(ntlm->identity), user, domain, password);
|
||||
|
||||
if (http)
|
||||
{
|
||||
DWORD status;
|
||||
DWORD SpnLength;
|
||||
|
||||
SpnLength = 0;
|
||||
status = DsMakeSpn(_T("HTTP"), _T("LAB1-W2K8R2-GW.lab1.awake.local"), NULL, 0, NULL, &SpnLength, NULL);
|
||||
|
||||
if (status != ERROR_BUFFER_OVERFLOW)
|
||||
{
|
||||
_tprintf(_T("DsMakeSpn: expected ERROR_BUFFER_OVERFLOW\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
ntlm->ServicePrincipalName = (LPTSTR) malloc(SpnLength * sizeof(TCHAR));
|
||||
|
||||
status = DsMakeSpn(_T("HTTP"), _T("LAB1-W2K8R2-GW.lab1.awake.local"), NULL, 0, NULL, &SpnLength, ntlm->ServicePrincipalName);
|
||||
}
|
||||
|
||||
status = ntlm->table->QuerySecurityPackageInfo(NTLMSP_NAME, &ntlm->pPackageInfo);
|
||||
|
||||
if (status != SEC_E_OK)
|
||||
@ -114,6 +135,38 @@ BOOL ntlm_client_init(rdpNtlm* ntlm, BOOL http, char* user, char* domain, char*
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL ntlm_client_make_spn(rdpNtlm* ntlm, LPCTSTR ServiceClass, char* hostname)
|
||||
{
|
||||
int length;
|
||||
DWORD status;
|
||||
DWORD SpnLength;
|
||||
LPTSTR hostnameX;
|
||||
|
||||
#ifdef UNICODE
|
||||
length = strlen(hostname);
|
||||
hostnameX = (LPWSTR) malloc(length * sizeof(TCHAR));
|
||||
MultiByteToWideChar(CP_ACP, 0, hostname, length, hostnameX, length);
|
||||
hostnameX[length] = 0;
|
||||
#else
|
||||
hostnameX = hostname;
|
||||
#endif
|
||||
|
||||
SpnLength = 0;
|
||||
status = DsMakeSpn(ServiceClass, hostnameX, NULL, 0, NULL, &SpnLength, NULL);
|
||||
|
||||
if (status != ERROR_BUFFER_OVERFLOW)
|
||||
return FALSE;
|
||||
|
||||
ntlm->ServicePrincipalName = (LPTSTR) malloc(SpnLength * sizeof(TCHAR));
|
||||
|
||||
status = DsMakeSpn(ServiceClass, hostnameX, NULL, 0, NULL, &SpnLength, ntlm->ServicePrincipalName);
|
||||
|
||||
if (status != ERROR_SUCCESS)
|
||||
return -1;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL ntlm_authenticate(rdpNtlm* ntlm)
|
||||
{
|
||||
SECURITY_STATUS status;
|
||||
@ -135,7 +188,8 @@ BOOL ntlm_authenticate(rdpNtlm* ntlm)
|
||||
|
||||
status = ntlm->table->InitializeSecurityContext(&ntlm->credentials,
|
||||
(ntlm->haveContext) ? &ntlm->context : NULL,
|
||||
NULL, ntlm->fContextReq, 0, SECURITY_NATIVE_DREP,
|
||||
(ntlm->ServicePrincipalName) ? ntlm->ServicePrincipalName : NULL,
|
||||
ntlm->fContextReq, 0, SECURITY_NATIVE_DREP,
|
||||
(ntlm->haveInputBuffer) ? &ntlm->inputBufferDesc : NULL,
|
||||
0, &ntlm->context, &ntlm->outputBufferDesc,
|
||||
&ntlm->pfContextAttr, &ntlm->expiration);
|
||||
@ -243,11 +297,13 @@ BOOL rpc_ntlm_http_out_connect(rdpRpc* rpc)
|
||||
{
|
||||
ntlm_client_init(ntlm, TRUE, settings->username,
|
||||
settings->domain, settings->password);
|
||||
ntlm_client_make_spn(ntlm, _T("HTTP"), settings->tsg_hostname);
|
||||
}
|
||||
else
|
||||
{
|
||||
ntlm_client_init(ntlm, TRUE, settings->tsg_username,
|
||||
settings->tsg_domain, settings->tsg_password);
|
||||
ntlm_client_make_spn(ntlm, _T("HTTP"), settings->tsg_hostname);
|
||||
}
|
||||
|
||||
ntlm_authenticate(ntlm);
|
||||
@ -292,13 +348,26 @@ BOOL rpc_ntlm_http_out_connect(rdpRpc* rpc)
|
||||
BOOL rpc_ntlm_http_in_connect(rdpRpc* rpc)
|
||||
{
|
||||
STREAM* s;
|
||||
rdpSettings* settings;
|
||||
int ntlm_token_length;
|
||||
BYTE* ntlm_token_data;
|
||||
HttpResponse* http_response;
|
||||
rdpNtlm* ntlm = rpc->ntlm_http_in->ntlm;
|
||||
|
||||
ntlm_client_init(ntlm, TRUE, rpc->settings->username,
|
||||
rpc->settings->domain, rpc->settings->password);
|
||||
settings = rpc->settings;
|
||||
|
||||
if (settings->tsg_same_credentials)
|
||||
{
|
||||
ntlm_client_init(ntlm, TRUE, settings->username,
|
||||
settings->domain, settings->password);
|
||||
ntlm_client_make_spn(ntlm, _T("HTTP"), settings->tsg_hostname);
|
||||
}
|
||||
else
|
||||
{
|
||||
ntlm_client_init(ntlm, TRUE, settings->tsg_username,
|
||||
settings->tsg_domain, settings->tsg_password);
|
||||
ntlm_client_make_spn(ntlm, _T("HTTP"), settings->tsg_hostname);
|
||||
}
|
||||
|
||||
ntlm_authenticate(ntlm);
|
||||
|
||||
|
@ -540,6 +540,7 @@ struct rdp_ntlm
|
||||
SecBuffer outputBuffer;
|
||||
BOOL haveContext;
|
||||
BOOL haveInputBuffer;
|
||||
LPTSTR ServicePrincipalName;
|
||||
SecBufferDesc inputBufferDesc;
|
||||
SecBufferDesc outputBufferDesc;
|
||||
CredHandle credentials;
|
||||
|
@ -22,14 +22,76 @@
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <winpr/rpc.h>
|
||||
#include <winpr/windows.h>
|
||||
|
||||
#include <ntdsapi.h>
|
||||
|
||||
#else
|
||||
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/winpr.h>
|
||||
#include <winpr/wtypes.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DS_NAME_NO_FLAGS = 0x0,
|
||||
DS_NAME_FLAG_SYNTACTICAL_ONLY = 0x1,
|
||||
DS_NAME_FLAG_EVAL_AT_DC = 0x2,
|
||||
DS_NAME_FLAG_GCVERIFY = 0x4,
|
||||
DS_NAME_FLAG_TRUST_REFERRAL = 0x8
|
||||
} DS_NAME_FLAGS;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DS_UNKNOWN_NAME = 0,
|
||||
DS_FQDN_1779_NAME = 1,
|
||||
DS_NT4_ACCOUNT_NAME = 2,
|
||||
DS_DISPLAY_NAME = 3,
|
||||
DS_UNIQUE_ID_NAME = 6,
|
||||
DS_CANONICAL_NAME = 7,
|
||||
DS_USER_PRINCIPAL_NAME = 8,
|
||||
DS_CANONICAL_NAME_EX = 9,
|
||||
DS_SERVICE_PRINCIPAL_NAME = 10,
|
||||
DS_SID_OR_SID_HISTORY_NAME = 11,
|
||||
DS_DNS_DOMAIN_NAME = 12
|
||||
} DS_NAME_FORMAT;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DS_NAME_NO_ERROR = 0,
|
||||
DS_NAME_ERROR_RESOLVING = 1,
|
||||
DS_NAME_ERROR_NOT_FOUND = 2,
|
||||
DS_NAME_ERROR_NOT_UNIQUE = 3,
|
||||
DS_NAME_ERROR_NO_MAPPING = 4,
|
||||
DS_NAME_ERROR_DOMAIN_ONLY = 5,
|
||||
DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING = 6,
|
||||
DS_NAME_ERROR_TRUST_REFERRAL = 7
|
||||
} DS_NAME_ERROR;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DS_SPN_DNS_HOST = 0,
|
||||
DS_SPN_DN_HOST = 1,
|
||||
DS_SPN_NB_HOST = 2,
|
||||
DS_SPN_DOMAIN = 3,
|
||||
DS_SPN_NB_DOMAIN = 4,
|
||||
DS_SPN_SERVICE = 5
|
||||
} DS_SPN_NAME_TYPE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD status;
|
||||
LPTSTR pDomain;
|
||||
LPTSTR pName;
|
||||
} DS_NAME_RESULT_ITEM, *PDS_NAME_RESULT_ITEM;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD cItems;
|
||||
PDS_NAME_RESULT_ITEM rItems;
|
||||
} DS_NAME_RESULT, *PDS_NAME_RESULT;
|
||||
|
||||
WINPR_API DWORD DsCrackSpnW(LPCWSTR pszSpn, DWORD* pcServiceClass, LPWSTR ServiceClass, DWORD* pcServiceName,
|
||||
LPWSTR ServiceName, DWORD* pcInstanceName, LPWSTR InstanceName, USHORT* pInstancePort);
|
||||
|
||||
|
@ -22,7 +22,11 @@
|
||||
|
||||
#include <winpr/rpc.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
WINPR_API void* MIDL_user_allocate(size_t cBytes);
|
||||
WINPR_API void MIDL_user_free(void* p);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* WINPR_RPC_MIDL_H */
|
||||
|
@ -23,6 +23,8 @@
|
||||
#include <winpr/rpc.h>
|
||||
#include <winpr/wtypes.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
#define __RPC_WIN32__ 1
|
||||
#define TARGET_IS_NT50_OR_LATER 1
|
||||
|
||||
@ -525,4 +527,6 @@ typedef void (*NDR_TYPE_FREE_ROUTINE)(PMIDL_STUB_MESSAGE pStubMsg, unsigned char
|
||||
|
||||
WINPR_API CLIENT_CALL_RETURN NdrClientCall2(PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRING pFormat, ...);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* WINPR_RPC_NDR_H */
|
||||
|
@ -20,6 +20,12 @@
|
||||
#ifndef WINPR_RPC_H
|
||||
#define WINPR_RPC_H
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <rpc.h>
|
||||
|
||||
#else
|
||||
|
||||
#include <winpr/winpr.h>
|
||||
#include <winpr/wtypes.h>
|
||||
|
||||
@ -42,4 +48,6 @@ typedef PCONTEXT_HANDLE PCHANNEL_CONTEXT_HANDLE_SERIALIZE;
|
||||
|
||||
void RpcRaiseException(RPC_STATUS exception);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* WINPR_RPC_H */
|
||||
|
@ -21,16 +21,29 @@ set(MODULE_PREFIX "WINPR_DSPARSE")
|
||||
set(${MODULE_PREFIX}_SRCS
|
||||
dsparse.c)
|
||||
|
||||
if(MSVC AND (NOT MONOLITHIC_BUILD))
|
||||
set(${MODULE_PREFIX}_SRCS ${${MODULE_PREFIX}_SRCS} module.def)
|
||||
endif()
|
||||
|
||||
add_complex_library(MODULE ${MODULE_NAME} TYPE "OBJECT"
|
||||
MONOLITHIC ${MONOLITHIC_BUILD}
|
||||
SOURCES ${${MODULE_PREFIX}_SRCS})
|
||||
|
||||
set_target_properties(${MODULE_NAME} PROPERTIES VERSION ${WINPR_VERSION_FULL} SOVERSION ${WINPR_VERSION} PREFIX "lib")
|
||||
|
||||
if(MONOLITHIC_BUILD)
|
||||
if(WIN32)
|
||||
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ntdsapi)
|
||||
endif()
|
||||
|
||||
if(MONOLITHIC_BUILD)
|
||||
set(WINPR_LIBS ${WINPR_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
|
||||
else()
|
||||
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
|
||||
install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
|
||||
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR")
|
||||
|
||||
if(BUILD_TESTING)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
3
winpr/libwinpr/dsparse/module.def
Normal file
3
winpr/libwinpr/dsparse/module.def
Normal file
@ -0,0 +1,3 @@
|
||||
LIBRARY "libwinpr-dsparse"
|
||||
EXPORTS
|
||||
|
2
winpr/libwinpr/dsparse/test/.gitignore
vendored
Normal file
2
winpr/libwinpr/dsparse/test/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
TestDs
|
||||
TestDs.c
|
31
winpr/libwinpr/dsparse/test/CMakeLists.txt
Normal file
31
winpr/libwinpr/dsparse/test/CMakeLists.txt
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
set(MODULE_NAME "TestDsParse")
|
||||
set(MODULE_PREFIX "TEST_DSPARSE")
|
||||
|
||||
set(${MODULE_PREFIX}_DRIVER ${MODULE_NAME}.c)
|
||||
|
||||
set(${MODULE_PREFIX}_TESTS
|
||||
TestDsMakeSpn.c
|
||||
TestDsCrackNames.c)
|
||||
|
||||
create_test_sourcelist(${MODULE_PREFIX}_SRCS
|
||||
${${MODULE_PREFIX}_DRIVER}
|
||||
${${MODULE_PREFIX}_TESTS})
|
||||
|
||||
add_executable(${MODULE_NAME} ${${MODULE_PREFIX}_SRCS})
|
||||
|
||||
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
|
||||
MONOLITHIC ${MONOLITHIC_BUILD}
|
||||
MODULE winpr
|
||||
MODULES winpr-dsparse)
|
||||
|
||||
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
|
||||
|
||||
set_target_properties(${MODULE_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${TESTING_OUTPUT_DIRECTORY}")
|
||||
|
||||
foreach(test ${${MODULE_PREFIX}_TESTS})
|
||||
get_filename_component(TestName ${test} NAME_WE)
|
||||
add_test(${TestName} ${TESTING_OUTPUT_DIRECTORY}/${MODULE_NAME} ${TestName})
|
||||
endforeach()
|
||||
|
||||
set_property(TARGET ${MODULE_NAME} PROPERTY FOLDER "WinPR/Test")
|
50
winpr/libwinpr/dsparse/test/TestDsCrackNames.c
Normal file
50
winpr/libwinpr/dsparse/test/TestDsCrackNames.c
Normal file
@ -0,0 +1,50 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/winpr.h>
|
||||
#include <winpr/tchar.h>
|
||||
#include <winpr/dsparse.h>
|
||||
|
||||
//LPCTSTR testName = _T("LAB1\\JohnDoe");
|
||||
|
||||
int TestDsCrackNames(int argc, char* argv[])
|
||||
{
|
||||
#if 0
|
||||
HANDLE ds;
|
||||
DWORD status;
|
||||
PDS_NAME_RESULT pResult;
|
||||
|
||||
status = DsBind(NULL, NULL, &ds);
|
||||
|
||||
if (status != ERROR_SUCCESS)
|
||||
{
|
||||
_tprintf(_T("DsBind: expected ERROR_SUCCESS: 0x%08X\n"), status);
|
||||
return -1;
|
||||
}
|
||||
|
||||
status = DsCrackNames(ds, DS_NAME_FLAG_SYNTACTICAL_ONLY, DS_NT4_ACCOUNT_NAME,
|
||||
DS_USER_PRINCIPAL_NAME, 1, &testName, &pResult);
|
||||
|
||||
if (status != ERROR_SUCCESS)
|
||||
{
|
||||
_tprintf(_T("DsCrackNames: expected ERROR_SUCCESS\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
_tprintf(_T("DsCrackNames: pResult->cItems: %d\n"), pResult->cItems);
|
||||
|
||||
_tprintf(_T("DsCrackNames: pResult->rItems[0]: Domain: %s Name: %s Status: 0x%08X\n"),
|
||||
pResult->rItems[0].pDomain, pResult->rItems[0].pName, pResult->rItems[0].status);
|
||||
|
||||
status = DsUnBind(&ds);
|
||||
|
||||
if (status != ERROR_SUCCESS)
|
||||
{
|
||||
_tprintf(_T("DsUnBind: expected ERROR_SUCCESS\n"));
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
56
winpr/libwinpr/dsparse/test/TestDsMakeSpn.c
Normal file
56
winpr/libwinpr/dsparse/test/TestDsMakeSpn.c
Normal file
@ -0,0 +1,56 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/winpr.h>
|
||||
#include <winpr/tchar.h>
|
||||
#include <winpr/dsparse.h>
|
||||
|
||||
LPCTSTR testServiceClass = _T("HTTP");
|
||||
LPCTSTR testServiceName = _T("LAB1-W2K8R2-GW.lab1.awake.local");
|
||||
|
||||
int TestDsMakeSpn(int argc, char* argv[])
|
||||
{
|
||||
LPTSTR Spn;
|
||||
DWORD status;
|
||||
DWORD SpnLength;
|
||||
|
||||
SpnLength = -1;
|
||||
status = DsMakeSpn(testServiceClass, testServiceName, NULL, 0, NULL, &SpnLength, NULL);
|
||||
|
||||
if (status != ERROR_INVALID_PARAMETER)
|
||||
{
|
||||
_tprintf(_T("DsMakeSpn: expected ERROR_INVALID_PARAMETER\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
SpnLength = 0;
|
||||
status = DsMakeSpn(testServiceClass, testServiceName, NULL, 0, NULL, &SpnLength, NULL);
|
||||
|
||||
if (status != ERROR_BUFFER_OVERFLOW)
|
||||
{
|
||||
_tprintf(_T("DsMakeSpn: expected ERROR_BUFFER_OVERFLOW\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (SpnLength != 37)
|
||||
{
|
||||
_tprintf(_T("DsMakeSpn: SpnLength mismatch: Actual: %d, Expected: %d\n"), SpnLength, 37);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* SpnLength includes null terminator */
|
||||
Spn = (LPTSTR) malloc(SpnLength * sizeof(TCHAR));
|
||||
|
||||
status = DsMakeSpn(testServiceClass, testServiceName, NULL, 0, NULL, &SpnLength, Spn);
|
||||
|
||||
if (status != ERROR_SUCCESS)
|
||||
{
|
||||
_tprintf(_T("DsMakeSpn: expected ERROR_SUCCESS\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
_tprintf(_T("DsMakeSpn: %s\n"), Spn);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
165
winpr/libwinpr/dsparse/test/TestDsParse.c
Normal file
165
winpr/libwinpr/dsparse/test/TestDsParse.c
Normal file
@ -0,0 +1,165 @@
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
|
||||
|
||||
/* Forward declare test functions. */
|
||||
int TestDsMakeSpn(int, char*[]);
|
||||
int TestDsCrackNames(int, char*[]);
|
||||
|
||||
|
||||
/* Create map. */
|
||||
|
||||
typedef int (*MainFuncPointer)(int , char*[]);
|
||||
typedef struct
|
||||
{
|
||||
const char* name;
|
||||
MainFuncPointer func;
|
||||
} functionMapEntry;
|
||||
|
||||
functionMapEntry cmakeGeneratedFunctionMapEntries[] = {
|
||||
{
|
||||
"TestDsMakeSpn",
|
||||
TestDsMakeSpn
|
||||
},
|
||||
{
|
||||
"TestDsCrackNames",
|
||||
TestDsCrackNames
|
||||
},
|
||||
|
||||
{0,0}
|
||||
};
|
||||
|
||||
/* Allocate and create a lowercased copy of string
|
||||
(note that it has to be free'd manually) */
|
||||
|
||||
char* lowercase(const char *string)
|
||||
{
|
||||
char *new_string, *p;
|
||||
|
||||
#ifdef __cplusplus
|
||||
new_string = static_cast<char *>(malloc(sizeof(char) *
|
||||
static_cast<size_t>(strlen(string) + 1)));
|
||||
#else
|
||||
new_string = (char *)(malloc(sizeof(char) * (size_t)(strlen(string) + 1)));
|
||||
#endif
|
||||
|
||||
if (!new_string)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
strcpy(new_string, string);
|
||||
p = new_string;
|
||||
while (*p != 0)
|
||||
{
|
||||
#ifdef __cplusplus
|
||||
*p = static_cast<char>(tolower(*p));
|
||||
#else
|
||||
*p = (char)(tolower(*p));
|
||||
#endif
|
||||
|
||||
++p;
|
||||
}
|
||||
return new_string;
|
||||
}
|
||||
|
||||
int main(int ac, char *av[])
|
||||
{
|
||||
int i, NumTests, testNum, partial_match;
|
||||
char *arg, *test_name;
|
||||
int count;
|
||||
int testToRun = -1;
|
||||
|
||||
|
||||
|
||||
for(count =0; cmakeGeneratedFunctionMapEntries[count].name != 0; count++)
|
||||
{
|
||||
}
|
||||
NumTests = count;
|
||||
/* If no test name was given */
|
||||
/* process command line with user function. */
|
||||
if (ac < 2)
|
||||
{
|
||||
/* Ask for a test. */
|
||||
printf("Available tests:\n");
|
||||
for (i =0; i < NumTests; ++i)
|
||||
{
|
||||
printf("%3d. %s\n", i, cmakeGeneratedFunctionMapEntries[i].name);
|
||||
}
|
||||
printf("To run a test, enter the test number: ");
|
||||
fflush(stdout);
|
||||
testNum = 0;
|
||||
if( scanf("%d", &testNum) != 1 )
|
||||
{
|
||||
printf("Couldn't parse that input as a number\n");
|
||||
return -1;
|
||||
}
|
||||
if (testNum >= NumTests)
|
||||
{
|
||||
printf("%3d is an invalid test number.\n", testNum);
|
||||
return -1;
|
||||
}
|
||||
testToRun = testNum;
|
||||
ac--;
|
||||
av++;
|
||||
}
|
||||
partial_match = 0;
|
||||
arg = 0;
|
||||
/* If partial match is requested. */
|
||||
if(testToRun == -1 && ac > 1)
|
||||
{
|
||||
partial_match = (strcmp(av[1], "-R") == 0) ? 1 : 0;
|
||||
}
|
||||
if (partial_match && ac < 3)
|
||||
{
|
||||
printf("-R needs an additional parameter.\n");
|
||||
return -1;
|
||||
}
|
||||
if(testToRun == -1)
|
||||
{
|
||||
arg = lowercase(av[1 + partial_match]);
|
||||
}
|
||||
for (i =0; i < NumTests && testToRun == -1; ++i)
|
||||
{
|
||||
test_name = lowercase(cmakeGeneratedFunctionMapEntries[i].name);
|
||||
if (partial_match && strstr(test_name, arg) != NULL)
|
||||
{
|
||||
testToRun = i;
|
||||
ac -=2;
|
||||
av += 2;
|
||||
}
|
||||
else if (!partial_match && strcmp(test_name, arg) == 0)
|
||||
{
|
||||
testToRun = i;
|
||||
ac--;
|
||||
av++;
|
||||
}
|
||||
free(test_name);
|
||||
}
|
||||
if(arg)
|
||||
{
|
||||
free(arg);
|
||||
}
|
||||
if(testToRun != -1)
|
||||
{
|
||||
int result;
|
||||
|
||||
result = (*cmakeGeneratedFunctionMapEntries[testToRun].func)(ac, av);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* Nothing was run, display the test names. */
|
||||
printf("Available tests:\n");
|
||||
for (i =0; i < NumTests; ++i)
|
||||
{
|
||||
printf("%3d. %s\n", i, cmakeGeneratedFunctionMapEntries[i].name);
|
||||
}
|
||||
printf("Failed: %s is an invalid test name.\n", av[1]);
|
||||
|
||||
return -1;
|
||||
}
|
@ -27,6 +27,8 @@
|
||||
|
||||
#include <winpr/ndr.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
#include "ndr_array.h"
|
||||
#include "ndr_context.h"
|
||||
#include "ndr_pointer.h"
|
||||
@ -344,3 +346,5 @@ CLIENT_CALL_RETURN NdrClientCall2(PMIDL_STUB_DESC pStubDescriptor, PFORMAT_STRIN
|
||||
|
||||
return client_call_return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -28,6 +28,8 @@
|
||||
|
||||
#include "ndr_array.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
void NdrConformantArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat)
|
||||
{
|
||||
/**
|
||||
@ -139,3 +141,5 @@ void NdrComplexArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemo
|
||||
|
||||
printf("warning: NdrComplexArrayBufferSize unimplemented\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -22,10 +22,14 @@
|
||||
|
||||
#include <winpr/rpc.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
void NdrConformantArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat);
|
||||
void NdrConformantVaryingArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat);
|
||||
void NdrFixedArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat);
|
||||
void NdrVaryingArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat);
|
||||
void NdrComplexArrayBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* WINPR_RPC_NDR_ARRAY_H */
|
||||
|
@ -25,6 +25,9 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <winpr/rpc.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
#include "ndr_context.h"
|
||||
#include "ndr_private.h"
|
||||
|
||||
@ -68,3 +71,5 @@ void NdrContextHandleBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMem
|
||||
NdrpIncrementLength(&(pStubMsg->BufferLength), 20);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -22,6 +22,10 @@
|
||||
|
||||
#include <winpr/rpc.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
void NdrContextHandleBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* WINPR_RPC_NDR_CONTEXT_H */
|
||||
|
@ -25,6 +25,9 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <winpr/rpc.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
#include "ndr_correlation.h"
|
||||
#include "ndr_private.h"
|
||||
|
||||
@ -189,3 +192,5 @@ PFORMAT_STRING NdrpComputeVariance(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* p
|
||||
|
||||
return pFormat;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -22,8 +22,12 @@
|
||||
|
||||
#include <winpr/rpc.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
PFORMAT_STRING NdrpComputeCount(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat, ULONG_PTR* pCount);
|
||||
PFORMAT_STRING NdrpComputeConformance(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat);
|
||||
PFORMAT_STRING NdrpComputeVariance(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* WINPR_RPC_NDR_CORRELATION_H */
|
||||
|
@ -25,6 +25,9 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <winpr/rpc.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
#include "ndr_pointer.h"
|
||||
#include "ndr_private.h"
|
||||
|
||||
@ -324,3 +327,5 @@ void NdrByteCountPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* p
|
||||
{
|
||||
printf("warning: NdrByteCountPointerBufferSize unimplemented\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
#include <winpr/rpc.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
PFORMAT_STRING NdrpSkipPointerLayout(PFORMAT_STRING pFormat);
|
||||
|
||||
void NdrpPointerBufferSize(unsigned char* pMemory, PFORMAT_STRING pFormat, PMIDL_STUB_MESSAGE pStubMsg);
|
||||
@ -34,4 +36,6 @@ PFORMAT_STRING NdrpEmbeddedPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsign
|
||||
void NdrPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat);
|
||||
void NdrByteCountPointerBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* WINPR_RPC_NDR_POINTER_H */
|
||||
|
@ -26,6 +26,8 @@
|
||||
|
||||
#include <winpr/rpc.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
#include "ndr_array.h"
|
||||
#include "ndr_context.h"
|
||||
#include "ndr_pointer.h"
|
||||
@ -554,3 +556,5 @@ const NDR_TYPE_FREE_ROUTINE pfnFreeRoutines[] =
|
||||
NULL, /* FC_END */
|
||||
NULL, /* FC_PAD */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
#include <winpr/rpc.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
void NdrpAlignLength(unsigned long* length, unsigned int alignment);
|
||||
void NdrpIncrementLength(unsigned long* length, unsigned int size);
|
||||
|
||||
@ -39,4 +41,6 @@ extern const char* FC_TYPE_STRINGS[];
|
||||
|
||||
#include "ndr_correlation.h"
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* WINPR_RPC_NDR_PRIVATE_H */
|
||||
|
@ -25,6 +25,9 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <winpr/rpc.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
#include "ndr_simple.h"
|
||||
#include "ndr_private.h"
|
||||
|
||||
@ -195,3 +198,5 @@ void NdrSimpleTypeFree(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFOR
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
#include <winpr/rpc.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
void NdrSimpleTypeBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat);
|
||||
void NdrSimpleTypeMarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, unsigned char FormatChar);
|
||||
void NdrSimpleTypeUnmarshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, unsigned char FormatChar);
|
||||
@ -32,4 +34,6 @@ char NdrGetSimpleTypeBufferSize(unsigned char FormatChar);
|
||||
char NdrGetSimpleTypeMemorySize(unsigned char FormatChar);
|
||||
int NdrGetTypeFlags(unsigned char FormatChar);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* WINPR_RPC_NDR_SIMPLE_H */
|
||||
|
@ -26,6 +26,8 @@
|
||||
|
||||
#include <winpr/rpc.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
#include "ndr_string.h"
|
||||
|
||||
void NdrConformantStringBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat)
|
||||
@ -37,3 +39,6 @@ void NdrNonConformantStringBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char
|
||||
{
|
||||
printf("warning: NdrNonConformantStringBufferSize unimplemented\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -22,7 +22,11 @@
|
||||
|
||||
#include <winpr/rpc.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
void NdrConformantStringBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat);
|
||||
void NdrNonConformantStringBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* WINPR_RPC_NDR_STRING_H */
|
||||
|
@ -25,6 +25,9 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <winpr/rpc.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
#include "ndr_private.h"
|
||||
#include "ndr_pointer.h"
|
||||
#include "ndr_structure.h"
|
||||
@ -315,3 +318,5 @@ void NdrComplexStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMem
|
||||
pStubMsg->PointerLength = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -22,9 +22,13 @@
|
||||
|
||||
#include <winpr/rpc.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
void NdrSimpleStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat);
|
||||
void NdrConformantStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat);
|
||||
void NdrConformantVaryingStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat);
|
||||
void NdrComplexStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* WINPR_RPC_NDR_STRUCTURE_H */
|
||||
|
@ -26,6 +26,8 @@
|
||||
|
||||
#include <winpr/rpc.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
#include "ndr_union.h"
|
||||
|
||||
void NdrEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat)
|
||||
@ -37,3 +39,5 @@ void NdrNonEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned cha
|
||||
{
|
||||
printf("warning: NdrNonEncapsulatedUnionBufferSize unimplemented\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -22,7 +22,11 @@
|
||||
|
||||
#include <winpr/rpc.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
void NdrEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat);
|
||||
void NdrNonEncapsulatedUnionBufferSize(PMIDL_STUB_MESSAGE pStubMsg, unsigned char* pMemory, PFORMAT_STRING pFormat);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* WINPR_RPC_NDR_UNION_H */
|
||||
|
@ -25,7 +25,11 @@
|
||||
|
||||
#include <winpr/rpc.h>
|
||||
|
||||
#ifndef _WIN32
|
||||
|
||||
void RpcRaiseException(RPC_STATUS exception)
|
||||
{
|
||||
printf("RpcRaiseException: 0x%08luX\n", exception);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user