From 5f766a75dcd7ba90f106a3f573be5cbab23c4491 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Fri, 19 Aug 2016 09:40:25 +0000 Subject: [PATCH] [RPCRT4] Sync with Wine Staging 1.9.16. CORE-11866 svn path=/trunk/; revision=72350 --- reactos/dll/win32/rpcrt4/ndr_stubless.c | 5 + reactos/dll/win32/rpcrt4/rpc_server.c | 166 +++++++++++------------- reactos/dll/win32/rpcrt4/rpcrt4.spec | 2 +- reactos/media/doc/README.WINE | 2 +- 4 files changed, 84 insertions(+), 91 deletions(-) diff --git a/reactos/dll/win32/rpcrt4/ndr_stubless.c b/reactos/dll/win32/rpcrt4/ndr_stubless.c index d2f16f59f7c..6197c9debd4 100644 --- a/reactos/dll/win32/rpcrt4/ndr_stubless.c +++ b/reactos/dll/win32/rpcrt4/ndr_stubless.c @@ -1829,3 +1829,8 @@ RPCRTAPI LONG RPC_ENTRY NdrAsyncStubCall(struct IRpcStubBuffer* pThis, FIXME("unimplemented, expect crash!\n"); return 0; } + +void RPC_ENTRY NdrAsyncServerCall(PRPC_MESSAGE pRpcMsg) +{ + FIXME("unimplemented, %p\n", pRpcMsg); +} diff --git a/reactos/dll/win32/rpcrt4/rpc_server.c b/reactos/dll/win32/rpcrt4/rpc_server.c index aed5a5833b9..f4b22393ee2 100644 --- a/reactos/dll/win32/rpcrt4/rpc_server.c +++ b/reactos/dll/win32/rpcrt4/rpc_server.c @@ -1288,11 +1288,44 @@ struct rpc_server_registered_auth_info { struct list entry; TimeStamp exp; + BOOL cred_acquired; CredHandle cred; ULONG max_token; USHORT auth_type; + WCHAR *principal; }; +static RPC_STATUS find_security_package(ULONG auth_type, SecPkgInfoW **packages_buf, SecPkgInfoW **ret) +{ + SECURITY_STATUS sec_status; + SecPkgInfoW *packages; + ULONG package_count; + ULONG i; + + sec_status = EnumerateSecurityPackagesW(&package_count, &packages); + if (sec_status != SEC_E_OK) + { + ERR("EnumerateSecurityPackagesW failed with error 0x%08x\n", sec_status); + return RPC_S_SEC_PKG_ERROR; + } + + for (i = 0; i < package_count; i++) + if (packages[i].wRPCID == auth_type) + break; + + if (i == package_count) + { + WARN("unsupported AuthnSvc %u\n", auth_type); + FreeContextBuffer(packages); + return RPC_S_UNKNOWN_AUTHN_SERVICE; + } + + TRACE("found package %s for service %u\n", debugstr_w(packages[i].Name), auth_type); + *packages_buf = packages; + *ret = packages + i; + return RPC_S_OK; +} + RPC_STATUS RPCRT4_ServerGetRegisteredAuthInfo( USHORT auth_type, CredHandle *cred, TimeStamp *exp, ULONG *max_token) { @@ -1304,6 +1337,28 @@ RPC_STATUS RPCRT4_ServerGetRegisteredAuthInfo( { if (auth_info->auth_type == auth_type) { + if (!auth_info->cred_acquired) + { + SecPkgInfoW *packages, *package; + SECURITY_STATUS sec_status; + + status = find_security_package(auth_info->auth_type, &packages, &package); + if (status != RPC_S_OK) + break; + + sec_status = AcquireCredentialsHandleW((SEC_WCHAR *)auth_info->principal, package->Name, + SECPKG_CRED_INBOUND, NULL, NULL, NULL, NULL, + &auth_info->cred, &auth_info->exp); + FreeContextBuffer(packages); + if (sec_status != SEC_E_OK) + { + status = RPC_S_SEC_PKG_ERROR; + break; + } + + auth_info->cred_acquired = TRUE; + } + *cred = auth_info->cred; *exp = auth_info->exp; *max_token = auth_info->max_token; @@ -1323,7 +1378,9 @@ void RPCRT4_ServerFreeAllRegisteredAuthInfo(void) EnterCriticalSection(&server_auth_info_cs); LIST_FOR_EACH_ENTRY_SAFE(auth_info, cursor2, &server_registered_auth_info, struct rpc_server_registered_auth_info, entry) { - FreeCredentialsHandle(&auth_info->cred); + if (auth_info->cred_acquired) + FreeCredentialsHandle(&auth_info->cred); + HeapFree(GetProcessHeap(), 0, auth_info->principal); HeapFree(GetProcessHeap(), 0, auth_info); } LeaveCriticalSection(&server_auth_info_cs); @@ -1336,63 +1393,18 @@ void RPCRT4_ServerFreeAllRegisteredAuthInfo(void) RPC_STATUS WINAPI RpcServerRegisterAuthInfoA( RPC_CSTR ServerPrincName, ULONG AuthnSvc, RPC_AUTH_KEY_RETRIEVAL_FN GetKeyFn, LPVOID Arg ) { - SECURITY_STATUS sec_status; - CredHandle cred; - TimeStamp exp; - ULONG package_count; - ULONG i; - PSecPkgInfoA packages; - ULONG max_token; - struct rpc_server_registered_auth_info *auth_info; + WCHAR *principal_name = NULL; + RPC_STATUS status; TRACE("(%s,%u,%p,%p)\n", ServerPrincName, AuthnSvc, GetKeyFn, Arg); - sec_status = EnumerateSecurityPackagesA(&package_count, &packages); - if (sec_status != SEC_E_OK) - { - ERR("EnumerateSecurityPackagesA failed with error 0x%08x\n", - sec_status); - return RPC_S_SEC_PKG_ERROR; - } - - for (i = 0; i < package_count; i++) - if (packages[i].wRPCID == AuthnSvc) - break; - - if (i == package_count) - { - WARN("unsupported AuthnSvc %u\n", AuthnSvc); - FreeContextBuffer(packages); - return RPC_S_UNKNOWN_AUTHN_SERVICE; - } - TRACE("found package %s for service %u\n", packages[i].Name, - AuthnSvc); - sec_status = AcquireCredentialsHandleA((SEC_CHAR *)ServerPrincName, - packages[i].Name, - SECPKG_CRED_INBOUND, NULL, NULL, - NULL, NULL, &cred, &exp); - max_token = packages[i].cbMaxToken; - FreeContextBuffer(packages); - if (sec_status != SEC_E_OK) - return RPC_S_SEC_PKG_ERROR; - - auth_info = HeapAlloc(GetProcessHeap(), 0, sizeof(*auth_info)); - if (!auth_info) - { - FreeCredentialsHandle(&cred); + if(ServerPrincName && !(principal_name = RPCRT4_strdupAtoW((const char*)ServerPrincName))) return RPC_S_OUT_OF_RESOURCES; - } - auth_info->exp = exp; - auth_info->cred = cred; - auth_info->max_token = max_token; - auth_info->auth_type = AuthnSvc; + status = RpcServerRegisterAuthInfoW(principal_name, AuthnSvc, GetKeyFn, Arg); - EnterCriticalSection(&server_auth_info_cs); - list_add_tail(&server_registered_auth_info, &auth_info->entry); - LeaveCriticalSection(&server_auth_info_cs); - - return RPC_S_OK; + HeapFree(GetProcessHeap(), 0, principal_name); + return status; } /*********************************************************************** @@ -1401,55 +1413,31 @@ RPC_STATUS WINAPI RpcServerRegisterAuthInfoA( RPC_CSTR ServerPrincName, ULONG Au RPC_STATUS WINAPI RpcServerRegisterAuthInfoW( RPC_WSTR ServerPrincName, ULONG AuthnSvc, RPC_AUTH_KEY_RETRIEVAL_FN GetKeyFn, LPVOID Arg ) { - SECURITY_STATUS sec_status; - CredHandle cred; - TimeStamp exp; - ULONG package_count; - ULONG i; - PSecPkgInfoW packages; - ULONG max_token; struct rpc_server_registered_auth_info *auth_info; + SecPkgInfoW *packages, *package; + ULONG max_token; + RPC_STATUS status; TRACE("(%s,%u,%p,%p)\n", debugstr_w(ServerPrincName), AuthnSvc, GetKeyFn, Arg); - sec_status = EnumerateSecurityPackagesW(&package_count, &packages); - if (sec_status != SEC_E_OK) - { - ERR("EnumerateSecurityPackagesW failed with error 0x%08x\n", - sec_status); - return RPC_S_SEC_PKG_ERROR; - } + status = find_security_package(AuthnSvc, &packages, &package); + if (status != RPC_S_OK) + return status; - for (i = 0; i < package_count; i++) - if (packages[i].wRPCID == AuthnSvc) - break; - - if (i == package_count) - { - WARN("unsupported AuthnSvc %u\n", AuthnSvc); - FreeContextBuffer(packages); - return RPC_S_UNKNOWN_AUTHN_SERVICE; - } - TRACE("found package %s for service %u\n", debugstr_w(packages[i].Name), - AuthnSvc); - sec_status = AcquireCredentialsHandleW((SEC_WCHAR *)ServerPrincName, - packages[i].Name, - SECPKG_CRED_INBOUND, NULL, NULL, - NULL, NULL, &cred, &exp); - max_token = packages[i].cbMaxToken; + max_token = package->cbMaxToken; FreeContextBuffer(packages); - if (sec_status != SEC_E_OK) - return RPC_S_SEC_PKG_ERROR; auth_info = HeapAlloc(GetProcessHeap(), 0, sizeof(*auth_info)); if (!auth_info) - { - FreeCredentialsHandle(&cred); + return RPC_S_OUT_OF_RESOURCES; + + if (!ServerPrincName) { + auth_info->principal = NULL; + }else if (!(auth_info->principal = RPCRT4_strdupW(ServerPrincName))) { + HeapFree(GetProcessHeap(), 0, auth_info); return RPC_S_OUT_OF_RESOURCES; } - auth_info->exp = exp; - auth_info->cred = cred; auth_info->max_token = max_token; auth_info->auth_type = AuthnSvc; diff --git a/reactos/dll/win32/rpcrt4/rpcrt4.spec b/reactos/dll/win32/rpcrt4/rpcrt4.spec index 2957c3c0b84..3e5a445d4b2 100644 --- a/reactos/dll/win32/rpcrt4/rpcrt4.spec +++ b/reactos/dll/win32/rpcrt4/rpcrt4.spec @@ -124,7 +124,7 @@ 124 stub NDRcopy 125 stdcall NdrAllocate(ptr long) 126 varargs NdrAsyncClientCall(ptr ptr) -127 stub NdrAsyncServerCall +127 stdcall NdrAsyncServerCall(ptr) 128 stdcall NdrByteCountPointerBufferSize(ptr ptr ptr) 129 stdcall NdrByteCountPointerFree(ptr ptr ptr) 130 stdcall NdrByteCountPointerMarshall(ptr ptr ptr) diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index fe1e0a274b6..e31187a3b33 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -163,7 +163,7 @@ reactos/dll/win32/rasapi32 # Synced to WineStaging-1.9.11 reactos/dll/win32/resutils # Synced to WineStaging-1.9.11 reactos/dll/win32/riched20 # Synced to WineStaging-1.9.16 reactos/dll/win32/riched32 # Synced to WineStaging-1.9.11 -reactos/dll/win32/rpcrt4 # Synced to WineStaging-1.9.11 +reactos/dll/win32/rpcrt4 # Synced to WineStaging-1.9.16 reactos/dll/win32/rsabase # Synced to WineStaging-1.9.11 reactos/dll/win32/rsaenh # Synced to WineStaging-1.9.11 reactos/dll/win32/sccbase # Synced to WineStaging-1.9.11