Author: akhaldi Date: Sun Mar 5 20:43:17 2017 New Revision: 74086
URL: http://svn.reactos.org/svn/reactos?rev=74086&view=rev Log: [RPCRT4_WINETEST] Sync with Wine Staging 2.2. CORE-12823
Removed: trunk/rostests/winetests/rpcrt4/rpc_protseq.c Modified: trunk/rostests/winetests/rpcrt4/CMakeLists.txt trunk/rostests/winetests/rpcrt4/rpc.c trunk/rostests/winetests/rpcrt4/server.c trunk/rostests/winetests/rpcrt4/testlist.c
Modified: trunk/rostests/winetests/rpcrt4/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/rpcrt4/CMakeList... ============================================================================== --- trunk/rostests/winetests/rpcrt4/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/winetests/rpcrt4/CMakeLists.txt [iso-8859-1] Sun Mar 5 20:43:17 2017 @@ -14,7 +14,6 @@ ndr_marshall.c rpc.c rpc_async.c - rpc_protseq.c server.c testlist.c ${CMAKE_CURRENT_BINARY_DIR}/server_c.c @@ -28,7 +27,7 @@ add_executable(rpcrt4_winetest ${SOURCE}) target_link_libraries(rpcrt4_winetest uuid wine ${PSEH_LIB}) set_module_type(rpcrt4_winetest win32cui) -add_importlibs(rpcrt4_winetest ole32 rpcrt4 secur32 msvcrt kernel32 ntdll) +add_importlibs(rpcrt4_winetest oleaut32 ole32 rpcrt4 secur32 advapi32 msvcrt kernel32 ntdll) add_rostests_file(TARGET rpcrt4_winetest)
if(NOT MSVC)
Modified: trunk/rostests/winetests/rpcrt4/rpc.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/rpcrt4/rpc.c?rev... ============================================================================== --- trunk/rostests/winetests/rpcrt4/rpc.c [iso-8859-1] (original) +++ trunk/rostests/winetests/rpcrt4/rpc.c [iso-8859-1] Sun Mar 5 20:43:17 2017 @@ -2,6 +2,7 @@ * Unit test suite for rpc functions * * Copyright 2002 Greg Turner + * Copyright 2008-2009 Robert Shearman * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -21,6 +22,7 @@ #include <stdarg.h> #include <stdio.h>
+#define COBJMACROS #include <ntstatus.h> #define WIN32_NO_STATUS #include "wine/test.h" @@ -28,6 +30,11 @@ #include <winbase.h> #include <winnt.h> #include <winerror.h> +#include <ole2.h> +#include <oleauto.h> +#include <ntsecapi.h> +#include <initguid.h> +#include <netfw.h>
#include "rpc.h" #include "rpcdce.h" @@ -907,11 +914,293 @@ ok(status == RPC_S_UNKNOWN_AUTHN_SERVICE, "status = %x\n", status); }
+static void test_RpcServerUseProtseq(void) +{ + RPC_STATUS status; + RPC_BINDING_VECTOR *bindings; + ULONG i; + ULONG binding_count_before; + ULONG binding_count_after1; + ULONG binding_count_after2; + ULONG endpoints_registered = 0; + static unsigned char iptcp[] = "ncacn_ip_tcp"; + static unsigned char np[] = "ncacn_np"; + static unsigned char ncalrpc[] = "ncalrpc"; + BOOL iptcp_registered = FALSE, np_registered = FALSE, ncalrpc_registered = FALSE; + + status = RpcServerInqBindings(&bindings); + if (status == RPC_S_NO_BINDINGS) + binding_count_before = 0; + else + { + binding_count_before = bindings->Count; + ok(status == RPC_S_OK, "RpcServerInqBindings failed with status %d\n", status); + for (i = 0; i < bindings->Count; i++) + { + RPC_CSTR str_bind; + status = RpcBindingToStringBindingA(bindings->BindingH[i], &str_bind); + ok(status == RPC_S_OK, "RpcBindingToStringBinding failed with status %d\n", status); + if (lstrlenA((const char *)str_bind) > 12 && !memcmp(str_bind, "ncacn_ip_tcp", 12)) + iptcp_registered = TRUE; + if (lstrlenA((const char *)str_bind) > 8 && !memcmp(str_bind, "ncacn_np", 8)) + np_registered = TRUE; + if (lstrlenA((const char *)str_bind) > 7 && !memcmp(str_bind, "ncalrpc", 7)) + ncalrpc_registered = TRUE; + RpcStringFreeA(&str_bind); + } + RpcBindingVectorFree(&bindings); + } + + /* show that RpcServerUseProtseqEp(..., NULL, ...) is the same as + * RpcServerUseProtseq(...) */ + status = RpcServerUseProtseqEpA(ncalrpc, 0, NULL, NULL); + ok(status == RPC_S_OK || broken(status == RPC_S_INVALID_ENDPOINT_FORMAT), + "RpcServerUseProtseqEp with NULL endpoint failed with status %d\n", + status); + + /* register protocol sequences without explicit endpoints */ + status = RpcServerUseProtseqA(np, 0, NULL); + if (status == RPC_S_PROTSEQ_NOT_SUPPORTED) + win_skip("ncacn_np not supported\n"); + else + ok(status == RPC_S_OK, "RpcServerUseProtseq(ncacn_np) failed with status %d\n", status); + if (status == RPC_S_OK && !np_registered) endpoints_registered++; + + status = RpcServerUseProtseqA(iptcp, 0, NULL); + ok(status == RPC_S_OK, "RpcServerUseProtseq(ncacn_ip_tcp) failed with status %d\n", status); + if (status == RPC_S_OK && !iptcp_registered) endpoints_registered++; + + status = RpcServerUseProtseqA(ncalrpc, 0, NULL); + ok(status == RPC_S_OK, "RpcServerUseProtseqEp(ncalrpc) failed with status %d\n", status); + if (status == RPC_S_OK && !ncalrpc_registered) endpoints_registered++; + + status = RpcServerInqBindings(&bindings); + ok(status == RPC_S_OK, "RpcServerInqBindings failed with status %d\n", status); + binding_count_after1 = bindings->Count; + ok(binding_count_after1 == binding_count_before + endpoints_registered, + "wrong binding count - before: %u, after %u, endpoints registered %u\n", + binding_count_before, binding_count_after1, endpoints_registered); + for (i = 0; i < bindings->Count; i++) + { + RPC_CSTR str_bind; + status = RpcBindingToStringBindingA(bindings->BindingH[i], &str_bind); + ok(status == RPC_S_OK, "RpcBindingToStringBinding failed with status %d\n", status); + trace("string binding: %s\n", str_bind); + RpcStringFreeA(&str_bind); + } + RpcBindingVectorFree(&bindings); + + /* re-register - endpoints should be reused */ + status = RpcServerUseProtseqA(np, 0, NULL); + if (status == RPC_S_PROTSEQ_NOT_SUPPORTED) + win_skip("ncacn_np not supported\n"); + else + ok(status == RPC_S_OK, "RpcServerUseProtseq(ncacn_np) failed with status %d\n", status); + + status = RpcServerUseProtseqA(iptcp, 0, NULL); + ok(status == RPC_S_OK, "RpcServerUseProtseq(ncacn_ip_tcp) failed with status %d\n", status); + + status = RpcServerUseProtseqA(ncalrpc, 0, NULL); + ok(status == RPC_S_OK, "RpcServerUseProtseqEp(ncalrpc) failed with status %d\n", status); + + status = RpcServerInqBindings(&bindings); + ok(status == RPC_S_OK, "RpcServerInqBindings failed with status %d\n", status); + binding_count_after2 = bindings->Count; + ok(binding_count_after2 == binding_count_after1, + "bindings should have been re-used - after1: %u after2: %u\n", + binding_count_after1, binding_count_after2); + RpcBindingVectorFree(&bindings); +} + +static void test_endpoint_mapper(RPC_CSTR protseq, RPC_CSTR address) +{ + static unsigned char annotation[] = "Test annotation string."; + RPC_STATUS status; + RPC_BINDING_VECTOR *binding_vector; + handle_t handle; + unsigned char *binding; + + status = RpcServerRegisterIf(IFoo_v0_0_s_ifspec, NULL, NULL); + ok(status == RPC_S_OK, "%s: RpcServerRegisterIf failed (%u)\n", protseq, status); + + status = RpcServerInqBindings(&binding_vector); + ok(status == RPC_S_OK, "%s: RpcServerInqBindings failed with error %u\n", protseq, status); + + /* register endpoints created in test_RpcServerUseProtseq */ + status = RpcEpRegisterA(IFoo_v0_0_s_ifspec, binding_vector, NULL, annotation); + ok(status == RPC_S_OK, "%s: RpcEpRegisterA failed with error %u\n", protseq, status); + /* reregister the same endpoint with no annotation */ + status = RpcEpRegisterA(IFoo_v0_0_s_ifspec, binding_vector, NULL, NULL); + ok(status == RPC_S_OK, "%s: RpcEpRegisterA failed with error %u\n", protseq, status); + + status = RpcStringBindingComposeA(NULL, protseq, address, + NULL, NULL, &binding); + ok(status == RPC_S_OK, "%s: RpcStringBindingCompose failed (%u)\n", protseq, status); + + status = RpcBindingFromStringBindingA(binding, &handle); + ok(status == RPC_S_OK, "%s: RpcBindingFromStringBinding failed (%u)\n", protseq, status); + + RpcStringFreeA(&binding); + + status = RpcBindingReset(handle); + ok(status == RPC_S_OK, "%s: RpcBindingReset failed with error %u\n", protseq, status); + + status = RpcEpResolveBinding(handle, IFoo_v0_0_s_ifspec); + ok(status == RPC_S_OK || broken(status == RPC_S_SERVER_UNAVAILABLE), /* win9x */ + "%s: RpcEpResolveBinding failed with error %u\n", protseq, status); + + status = RpcBindingReset(handle); + ok(status == RPC_S_OK, "%s: RpcBindingReset failed with error %u\n", protseq, status); + + status = RpcBindingFree(&handle); + ok(status == RPC_S_OK, "%s: RpcBindingFree failed with error %u\n", protseq, status); + + status = RpcServerUnregisterIf(NULL, NULL, FALSE); + ok(status == RPC_S_OK, "%s: RpcServerUnregisterIf failed (%u)\n", protseq, status); + + status = RpcEpUnregister(IFoo_v0_0_s_ifspec, binding_vector, NULL); + ok(status == RPC_S_OK, "%s: RpcEpUnregisterA failed with error %u\n", protseq, status); + + status = RpcBindingVectorFree(&binding_vector); + ok(status == RPC_S_OK, "%s: RpcBindingVectorFree failed with error %u\n", protseq, status); +} + +static BOOL is_process_elevated(void) +{ + HANDLE token; + if (OpenProcessToken( GetCurrentProcess(), TOKEN_QUERY, &token )) + { + TOKEN_ELEVATION_TYPE type; + DWORD size; + BOOL ret; + + ret = GetTokenInformation( token, TokenElevationType, &type, sizeof(type), &size ); + CloseHandle( token ); + return (ret && type == TokenElevationTypeFull); + } + return FALSE; +} + +static BOOL is_firewall_enabled(void) +{ + HRESULT hr, init; + INetFwMgr *mgr = NULL; + INetFwPolicy *policy = NULL; + INetFwProfile *profile = NULL; + VARIANT_BOOL enabled = VARIANT_FALSE; + + init = CoInitializeEx( 0, COINIT_APARTMENTTHREADED ); + + hr = CoCreateInstance( &CLSID_NetFwMgr, NULL, CLSCTX_INPROC_SERVER, &IID_INetFwMgr, + (void **)&mgr ); + ok( hr == S_OK, "got %08x\n", hr ); + if (hr != S_OK) goto done; + + hr = INetFwMgr_get_LocalPolicy( mgr, &policy ); + ok( hr == S_OK, "got %08x\n", hr ); + if (hr != S_OK) goto done; + + hr = INetFwPolicy_get_CurrentProfile( policy, &profile ); + if (hr != S_OK) goto done; + + hr = INetFwProfile_get_FirewallEnabled( profile, &enabled ); + ok( hr == S_OK, "got %08x\n", hr ); + +done: + if (policy) INetFwPolicy_Release( policy ); + if (profile) INetFwProfile_Release( profile ); + if (mgr) INetFwMgr_Release( mgr ); + if (SUCCEEDED( init )) CoUninitialize(); + return (enabled == VARIANT_TRUE); +} + +enum firewall_op +{ + APP_ADD, + APP_REMOVE +}; + +static HRESULT set_firewall( enum firewall_op op ) +{ + static const WCHAR testW[] = {'r','p','c','r','t','4','_','t','e','s','t',0}; + HRESULT hr, init; + INetFwMgr *mgr = NULL; + INetFwPolicy *policy = NULL; + INetFwProfile *profile = NULL; + INetFwAuthorizedApplication *app = NULL; + INetFwAuthorizedApplications *apps = NULL; + BSTR name, image = SysAllocStringLen( NULL, MAX_PATH ); + + if (!GetModuleFileNameW( NULL, image, MAX_PATH )) + { + SysFreeString( image ); + return E_FAIL; + } + init = CoInitializeEx( 0, COINIT_APARTMENTTHREADED ); + + hr = CoCreateInstance( &CLSID_NetFwMgr, NULL, CLSCTX_INPROC_SERVER, &IID_INetFwMgr, + (void **)&mgr ); + ok( hr == S_OK, "got %08x\n", hr ); + if (hr != S_OK) goto done; + + hr = INetFwMgr_get_LocalPolicy( mgr, &policy ); + ok( hr == S_OK, "got %08x\n", hr ); + if (hr != S_OK) goto done; + + hr = INetFwPolicy_get_CurrentProfile( policy, &profile ); + if (hr != S_OK) goto done; + + INetFwProfile_get_AuthorizedApplications( profile, &apps ); + ok( hr == S_OK, "got %08x\n", hr ); + if (hr != S_OK) goto done; + + hr = CoCreateInstance( &CLSID_NetFwAuthorizedApplication, NULL, CLSCTX_INPROC_SERVER, + &IID_INetFwAuthorizedApplication, (void **)&app ); + ok( hr == S_OK, "got %08x\n", hr ); + if (hr != S_OK) goto done; + + hr = INetFwAuthorizedApplication_put_ProcessImageFileName( app, image ); + if (hr != S_OK) goto done; + + name = SysAllocString( testW ); + hr = INetFwAuthorizedApplication_put_Name( app, name ); + SysFreeString( name ); + ok( hr == S_OK, "got %08x\n", hr ); + if (hr != S_OK) goto done; + + if (op == APP_ADD) + hr = INetFwAuthorizedApplications_Add( apps, app ); + else if (op == APP_REMOVE) + hr = INetFwAuthorizedApplications_Remove( apps, image ); + else + hr = E_INVALIDARG; + +done: + if (app) INetFwAuthorizedApplication_Release( app ); + if (apps) INetFwAuthorizedApplications_Release( apps ); + if (policy) INetFwPolicy_Release( policy ); + if (profile) INetFwProfile_Release( profile ); + if (mgr) INetFwMgr_Release( mgr ); + if (SUCCEEDED( init )) CoUninitialize(); + SysFreeString( image ); + return hr; +} + START_TEST( rpc ) { + static unsigned char ncacn_np[] = "ncacn_np"; + static unsigned char ncalrpc[] = "ncalrpc"; + static unsigned char np_address[] = "."; + BOOL firewall_enabled = is_firewall_enabled(); + + if (firewall_enabled && !is_process_elevated()) + { + skip("no privileges, skipping tests to avoid firewall dialog\n"); + return; + } + UuidConversionAndComparison(); TestDceErrorInqText(); - test_rpc_ncacn_ip_tcp(); test_towers(); test_I_RpcMapWin32Status(); test_RpcStringBindingParseA(); @@ -922,4 +1211,21 @@ test_RpcBindingFree(); test_RpcServerInqDefaultPrincName(); test_RpcServerRegisterAuthInfo(); -} + + if (firewall_enabled) + { + HRESULT hr = set_firewall(APP_ADD); + if (hr != S_OK) + { + skip("can't authorize app in firewall %08x\n", hr); + return; + } + } + + test_rpc_ncacn_ip_tcp(); + test_RpcServerUseProtseq(); + test_endpoint_mapper(ncacn_np, np_address); + test_endpoint_mapper(ncalrpc, NULL); + + if (firewall_enabled) set_firewall(APP_REMOVE); +}
Removed: trunk/rostests/winetests/rpcrt4/rpc_protseq.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/rpcrt4/rpc_prots... ============================================================================== --- trunk/rostests/winetests/rpcrt4/rpc_protseq.c [iso-8859-1] (original) +++ trunk/rostests/winetests/rpcrt4/rpc_protseq.c (removed) @@ -1,205 +0,0 @@ -/* - * RPC Protocol Sequence Server Tests - * - * Copyright 2008-2009 Robert Shearman - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include <stdarg.h> -#include <stdio.h> - -#include "wine/test.h" -#include <windef.h> -#include <winbase.h> -#include <winnt.h> -#include <winerror.h> - -#include "rpc.h" -#include "rpcdce.h" - -static void test_RpcServerUseProtseq(void) -{ - RPC_STATUS status; - RPC_BINDING_VECTOR *bindings; - ULONG i; - ULONG binding_count_before; - ULONG binding_count_after1; - ULONG binding_count_after2; - ULONG endpoints_registered = 0; - static unsigned char iptcp[] = "ncacn_ip_tcp"; - static unsigned char np[] = "ncacn_np"; - static unsigned char ncalrpc[] = "ncalrpc"; - - status = RpcServerInqBindings(&bindings); - if (status == RPC_S_NO_BINDINGS) - binding_count_before = 0; - else - { - binding_count_before = bindings->Count; - ok(status == RPC_S_OK, "RpcServerInqBindings failed with status %d\n", status); - RpcBindingVectorFree(&bindings); - } - - /* show that RpcServerUseProtseqEp(..., NULL, ...) is the same as - * RpcServerUseProtseq(...) */ - status = RpcServerUseProtseqEpA(ncalrpc, 0, NULL, NULL); - ok(status == RPC_S_OK || broken(status == RPC_S_INVALID_ENDPOINT_FORMAT), - "RpcServerUseProtseqEp with NULL endpoint failed with status %d\n", - status); - - /* register protocol sequences without explicit endpoints */ - status = RpcServerUseProtseqA(np, 0, NULL); - if (status == RPC_S_PROTSEQ_NOT_SUPPORTED) - win_skip("ncacn_np not supported\n"); - else - ok(status == RPC_S_OK, "RpcServerUseProtseq(ncacn_np) failed with status %d\n", status); - if (status == RPC_S_OK) endpoints_registered++; - - status = RpcServerUseProtseqA(iptcp, 0, NULL); - ok(status == RPC_S_OK, "RpcServerUseProtseq(ncacn_ip_tcp) failed with status %d\n", status); - if (status == RPC_S_OK) endpoints_registered++; - - status = RpcServerUseProtseqA(ncalrpc, 0, NULL); - ok(status == RPC_S_OK, "RpcServerUseProtseqEp(ncalrpc) failed with status %d\n", status); - if (status == RPC_S_OK) endpoints_registered++; - - status = RpcServerInqBindings(&bindings); - ok(status == RPC_S_OK, "RpcServerInqBindings failed with status %d\n", status); - binding_count_after1 = bindings->Count; - ok(binding_count_after1 == binding_count_before + endpoints_registered, - "wrong binding count - before: %u, after %u, endpoints registered %u\n", - binding_count_before, binding_count_after1, endpoints_registered); - for (i = 0; i < bindings->Count; i++) - { - RPC_CSTR str_bind; - status = RpcBindingToStringBindingA(bindings->BindingH[i], &str_bind); - ok(status == RPC_S_OK, "RpcBindingToStringBinding failed with status %d\n", status); - trace("string binding: %s\n", str_bind); - RpcStringFreeA(&str_bind); - } - RpcBindingVectorFree(&bindings); - - /* re-register - endpoints should be reused */ - status = RpcServerUseProtseqA(np, 0, NULL); - if (status == RPC_S_PROTSEQ_NOT_SUPPORTED) - win_skip("ncacn_np not supported\n"); - else - ok(status == RPC_S_OK, "RpcServerUseProtseq(ncacn_np) failed with status %d\n", status); - - status = RpcServerUseProtseqA(iptcp, 0, NULL); - ok(status == RPC_S_OK, "RpcServerUseProtseq(ncacn_ip_tcp) failed with status %d\n", status); - - status = RpcServerUseProtseqA(ncalrpc, 0, NULL); - ok(status == RPC_S_OK, "RpcServerUseProtseqEp(ncalrpc) failed with status %d\n", status); - - status = RpcServerInqBindings(&bindings); - ok(status == RPC_S_OK, "RpcServerInqBindings failed with status %d\n", status); - binding_count_after2 = bindings->Count; - ok(binding_count_after2 == binding_count_after1, - "bindings should have been re-used - after1: %u after2: %u\n", - binding_count_after1, binding_count_after2); - RpcBindingVectorFree(&bindings); -} - -static RPC_DISPATCH_FUNCTION IFoo_table[] = -{ - 0 -}; - -static RPC_DISPATCH_TABLE IFoo_v0_0_DispatchTable = -{ - 0, - IFoo_table -}; - -static const RPC_SERVER_INTERFACE IFoo___RpcServerInterface = -{ - sizeof(RPC_SERVER_INTERFACE), - {{0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x12,0x34}},{0,0}}, - {{0x8a885d04,0x1ceb,0x11c9,{0x9f,0xe8,0x08,0x00,0x2b,0x10,0x48,0x60}},{2,0}}, - &IFoo_v0_0_DispatchTable, - 0, - 0, - 0, - 0, - 0, -}; - -static RPC_IF_HANDLE IFoo_v0_0_s_ifspec = (RPC_IF_HANDLE)& IFoo___RpcServerInterface; - -static void test_endpoint_mapper(RPC_CSTR protseq, RPC_CSTR address) -{ - static unsigned char annotation[] = "Test annotation string."; - RPC_STATUS status; - RPC_BINDING_VECTOR *binding_vector; - handle_t handle; - unsigned char *binding; - - status = RpcServerRegisterIf(IFoo_v0_0_s_ifspec, NULL, NULL); - ok(status == RPC_S_OK, "%s: RpcServerRegisterIf failed (%u)\n", protseq, status); - - status = RpcServerInqBindings(&binding_vector); - ok(status == RPC_S_OK, "%s: RpcServerInqBindings failed with error %u\n", protseq, status); - - /* register endpoints created in test_RpcServerUseProtseq */ - status = RpcEpRegisterA(IFoo_v0_0_s_ifspec, binding_vector, NULL, annotation); - ok(status == RPC_S_OK, "%s: RpcEpRegisterA failed with error %u\n", protseq, status); - /* reregister the same endpoint with no annotation */ - status = RpcEpRegisterA(IFoo_v0_0_s_ifspec, binding_vector, NULL, NULL); - ok(status == RPC_S_OK, "%s: RpcEpRegisterA failed with error %u\n", protseq, status); - - status = RpcStringBindingComposeA(NULL, protseq, address, - NULL, NULL, &binding); - ok(status == RPC_S_OK, "%s: RpcStringBindingCompose failed (%u)\n", protseq, status); - - status = RpcBindingFromStringBindingA(binding, &handle); - ok(status == RPC_S_OK, "%s: RpcBindingFromStringBinding failed (%u)\n", protseq, status); - - RpcStringFreeA(&binding); - - status = RpcBindingReset(handle); - ok(status == RPC_S_OK, "%s: RpcBindingReset failed with error %u\n", protseq, status); - - status = RpcEpResolveBinding(handle, IFoo_v0_0_s_ifspec); - ok(status == RPC_S_OK || broken(status == RPC_S_SERVER_UNAVAILABLE), /* win9x */ - "%s: RpcEpResolveBinding failed with error %u\n", protseq, status); - - status = RpcBindingReset(handle); - ok(status == RPC_S_OK, "%s: RpcBindingReset failed with error %u\n", protseq, status); - - status = RpcBindingFree(&handle); - ok(status == RPC_S_OK, "%s: RpcBindingFree failed with error %u\n", protseq, status); - - status = RpcServerUnregisterIf(NULL, NULL, FALSE); - ok(status == RPC_S_OK, "%s: RpcServerUnregisterIf failed (%u)\n", protseq, status); - - status = RpcEpUnregister(IFoo_v0_0_s_ifspec, binding_vector, NULL); - ok(status == RPC_S_OK, "%s: RpcEpUnregisterA failed with error %u\n", protseq, status); - - status = RpcBindingVectorFree(&binding_vector); - ok(status == RPC_S_OK, "%s: RpcBindingVectorFree failed with error %u\n", protseq, status); -} - -START_TEST( rpc_protseq ) -{ - static unsigned char ncacn_np[] = "ncacn_np"; - static unsigned char ncalrpc[] = "ncalrpc"; - static unsigned char np_address[] = "."; - - test_RpcServerUseProtseq(); - test_endpoint_mapper(ncacn_np, np_address); - test_endpoint_mapper(ncalrpc, NULL); -}
Modified: trunk/rostests/winetests/rpcrt4/server.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/rpcrt4/server.c?... ============================================================================== --- trunk/rostests/winetests/rpcrt4/server.c [iso-8859-1] (original) +++ trunk/rostests/winetests/rpcrt4/server.c [iso-8859-1] Sun Mar 5 20:43:17 2017 @@ -18,9 +18,13 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#define COBJMACROS #include <windows.h> +#include <ole2.h> +#include <oleauto.h> #include <secext.h> #include <rpcdce.h> +#include <netfw.h> #include "wine/test.h" #include "server_s.h" #include "server_defines.h" @@ -1524,6 +1528,15 @@ } ok(level == RPC_C_AUTHN_LEVEL_PKT_PRIVACY, "level unchanged\n"); ok(authnsvc == RPC_C_AUTHN_WINNT, "authnsvc unchanged\n"); + RpcStringFreeA(&principal); + + status = RpcBindingInqAuthClientA(NULL, &privs, &principal, &level, &authnsvc, NULL); + ok(status == RPC_S_OK, "expected RPC_S_OK got %u\n", status); + RpcStringFreeA(&principal); + + status = RpcBindingInqAuthClientExA(NULL, &privs, &principal, &level, &authnsvc, NULL, 0); + ok(status == RPC_S_OK, "expected RPC_S_OK got %u\n", status); + RpcStringFreeA(&principal);
status = RpcImpersonateClient(NULL); ok(status == RPC_S_OK, "expected RPC_S_OK got %u\n", status); @@ -1745,13 +1758,141 @@ } }
+static BOOL is_process_elevated(void) +{ + HANDLE token; + if (OpenProcessToken( GetCurrentProcess(), TOKEN_QUERY, &token )) + { + TOKEN_ELEVATION_TYPE type; + DWORD size; + BOOL ret; + + ret = GetTokenInformation( token, TokenElevationType, &type, sizeof(type), &size ); + CloseHandle( token ); + return (ret && type == TokenElevationTypeFull); + } + return FALSE; +} + +static BOOL is_firewall_enabled(void) +{ + HRESULT hr, init; + INetFwMgr *mgr = NULL; + INetFwPolicy *policy = NULL; + INetFwProfile *profile = NULL; + VARIANT_BOOL enabled = VARIANT_FALSE; + + init = CoInitializeEx( 0, COINIT_APARTMENTTHREADED ); + + hr = CoCreateInstance( &CLSID_NetFwMgr, NULL, CLSCTX_INPROC_SERVER, &IID_INetFwMgr, + (void **)&mgr ); + ok( hr == S_OK, "got %08x\n", hr ); + if (hr != S_OK) goto done; + + hr = INetFwMgr_get_LocalPolicy( mgr, &policy ); + ok( hr == S_OK, "got %08x\n", hr ); + if (hr != S_OK) goto done; + + hr = INetFwPolicy_get_CurrentProfile( policy, &profile ); + if (hr != S_OK) goto done; + + hr = INetFwProfile_get_FirewallEnabled( profile, &enabled ); + ok( hr == S_OK, "got %08x\n", hr ); + +done: + if (policy) INetFwPolicy_Release( policy ); + if (profile) INetFwProfile_Release( profile ); + if (mgr) INetFwMgr_Release( mgr ); + if (SUCCEEDED( init )) CoUninitialize(); + return (enabled == VARIANT_TRUE); +} + +enum firewall_op +{ + APP_ADD, + APP_REMOVE +}; + +static HRESULT set_firewall( enum firewall_op op ) +{ + static const WCHAR testW[] = {'r','p','c','r','t','4','_','t','e','s','t',0}; + HRESULT hr, init; + INetFwMgr *mgr = NULL; + INetFwPolicy *policy = NULL; + INetFwProfile *profile = NULL; + INetFwAuthorizedApplication *app = NULL; + INetFwAuthorizedApplications *apps = NULL; + BSTR name, image = SysAllocStringLen( NULL, MAX_PATH ); + + if (!GetModuleFileNameW( NULL, image, MAX_PATH )) + { + SysFreeString( image ); + return E_FAIL; + } + init = CoInitializeEx( 0, COINIT_APARTMENTTHREADED ); + + hr = CoCreateInstance( &CLSID_NetFwMgr, NULL, CLSCTX_INPROC_SERVER, &IID_INetFwMgr, + (void **)&mgr ); + ok( hr == S_OK, "got %08x\n", hr ); + if (hr != S_OK) goto done; + + hr = INetFwMgr_get_LocalPolicy( mgr, &policy ); + ok( hr == S_OK, "got %08x\n", hr ); + if (hr != S_OK) goto done; + + hr = INetFwPolicy_get_CurrentProfile( policy, &profile ); + if (hr != S_OK) goto done; + + INetFwProfile_get_AuthorizedApplications( profile, &apps ); + ok( hr == S_OK, "got %08x\n", hr ); + if (hr != S_OK) goto done; + + hr = CoCreateInstance( &CLSID_NetFwAuthorizedApplication, NULL, CLSCTX_INPROC_SERVER, + &IID_INetFwAuthorizedApplication, (void **)&app ); + ok( hr == S_OK, "got %08x\n", hr ); + if (hr != S_OK) goto done; + + hr = INetFwAuthorizedApplication_put_ProcessImageFileName( app, image ); + if (hr != S_OK) goto done; + + name = SysAllocString( testW ); + hr = INetFwAuthorizedApplication_put_Name( app, name ); + SysFreeString( name ); + ok( hr == S_OK, "got %08x\n", hr ); + if (hr != S_OK) goto done; + + if (op == APP_ADD) + hr = INetFwAuthorizedApplications_Add( apps, app ); + else if (op == APP_REMOVE) + hr = INetFwAuthorizedApplications_Remove( apps, image ); + else + hr = E_INVALIDARG; + +done: + if (app) INetFwAuthorizedApplication_Release( app ); + if (apps) INetFwAuthorizedApplications_Release( apps ); + if (policy) INetFwPolicy_Release( policy ); + if (profile) INetFwProfile_Release( profile ); + if (mgr) INetFwMgr_Release( mgr ); + if (SUCCEEDED( init )) CoUninitialize(); + SysFreeString( image ); + return hr; +} + START_TEST(server) { ULONG size = 0; int argc; char **argv; + BOOL firewall_enabled = is_firewall_enabled();
InitFunctionPointers(); + + if (firewall_enabled && !is_process_elevated()) + { + trace("no privileges, skipping tests to avoid firewall dialog\n"); + return; + }
ok(!GetUserNameExA(NameSamCompatible, NULL, &size), "GetUserNameExA\n"); domain_and_user = HeapAlloc(GetProcessHeap(), 0, size); @@ -1773,7 +1914,20 @@ RpcEndExcept } else + { + if (firewall_enabled) + { + HRESULT hr = set_firewall(APP_ADD); + if (hr != S_OK) + { + skip("can't authorize app in firewall %08x\n", hr); + HeapFree(GetProcessHeap(), 0, domain_and_user); + return; + } + } server(); + if (firewall_enabled) set_firewall(APP_REMOVE); + }
HeapFree(GetProcessHeap(), 0, domain_and_user); }
Modified: trunk/rostests/winetests/rpcrt4/testlist.c URL: http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/rpcrt4/testlist.... ============================================================================== --- trunk/rostests/winetests/rpcrt4/testlist.c [iso-8859-1] (original) +++ trunk/rostests/winetests/rpcrt4/testlist.c [iso-8859-1] Sun Mar 5 20:43:17 2017 @@ -8,7 +8,6 @@ extern void func_ndr_marshall(void); extern void func_rpc(void); extern void func_rpc_async(void); -extern void func_rpc_protseq(void); extern void func_server(void);
const struct test winetest_testlist[] = @@ -18,7 +17,6 @@ { "ndr_marshall", func_ndr_marshall }, { "rpc", func_rpc }, { "rpc_async", func_rpc_async }, - { "rpc_protseq", func_rpc_protseq }, { "server", func_server }, { 0, 0 } };