ReactOS 0.4.15-dev-8235-gcd88a97
resman.c File Reference
#include "precomp.h"
#include <debug.h>
Include dependency graph for resman.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static BOOL AuthzpQueryToken (IN OUT PAUTHZ_RESMAN ResMan, IN HANDLE hToken)
 
static BOOL AuthzpInitUnderImpersonation (IN OUT PAUTHZ_RESMAN ResMan)
 
static BOOL AuthzpInitSelf (IN OUT PAUTHZ_RESMAN ResMan)
 
AUTHZAPI BOOL WINAPI AuthzInitializeResourceManager (IN DWORD flags, IN PFN_AUTHZ_DYNAMIC_ACCESS_CHECK pfnAccessCheck OPTIONAL, IN PFN_AUTHZ_COMPUTE_DYNAMIC_GROUPS pfnComputeDynamicGroups OPTIONAL, IN PFN_AUTHZ_FREE_DYNAMIC_GROUPS pfnFreeDynamicGroups OPTIONAL, IN PCWSTR ResourceManagerName OPTIONAL, IN PAUTHZ_RESOURCE_MANAGER_HANDLE pAuthzResourceManager)
 
AUTHZAPI BOOL WINAPI AuthzFreeResourceManager (IN AUTHZ_RESOURCE_MANAGER_HANDLE AuthzResourceManager)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 31 of file resman.c.

Function Documentation

◆ AuthzFreeResourceManager()

AUTHZAPI BOOL WINAPI AuthzFreeResourceManager ( IN AUTHZ_RESOURCE_MANAGER_HANDLE  AuthzResourceManager)

Definition at line 229 of file resman.c.

230{
231 BOOL Ret = FALSE;
232
233 if (AuthzResourceManager != NULL)
234 {
235 PAUTHZ_RESMAN ResMan = (PAUTHZ_RESMAN)AuthzResourceManager;
236
237 VALIDATE_RESMAN_HANDLE(AuthzResourceManager);
238
239 if (!(ResMan->flags & AUTHZ_RM_FLAG_NO_AUDIT))
240 {
241 /* FIXME - cleanup auditing */
242 }
243
244 if (ResMan->UserSid != NULL)
245 {
246 LocalFree((HLOCAL)ResMan->UserSid);
247 }
248
249 LocalFree((HLOCAL)AuthzResourceManager);
250 Ret = TRUE;
251 }
252 else
254
255 return Ret;
256}
#define AUTHZ_RM_FLAG_NO_AUDIT
Definition: authz.h:42
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define VALIDATE_RESMAN_HANDLE(handle)
Definition: precomp.h:26
struct _AUTHZ_RESMAN * PAUTHZ_RESMAN
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
unsigned int BOOL
Definition: ntddk_ex.h:94
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1594
DWORD flags
Definition: precomp.h:41
PSID UserSid
Definition: precomp.h:42

◆ AuthzInitializeResourceManager()

AUTHZAPI BOOL WINAPI AuthzInitializeResourceManager ( IN DWORD  flags,
IN PFN_AUTHZ_DYNAMIC_ACCESS_CHECK pfnAccessCheck  OPTIONAL,
IN PFN_AUTHZ_COMPUTE_DYNAMIC_GROUPS pfnComputeDynamicGroups  OPTIONAL,
IN PFN_AUTHZ_FREE_DYNAMIC_GROUPS pfnFreeDynamicGroups  OPTIONAL,
IN PCWSTR ResourceManagerName  OPTIONAL,
IN PAUTHZ_RESOURCE_MANAGER_HANDLE  pAuthzResourceManager 
)

Definition at line 145 of file resman.c.

151{
152 BOOL Ret = FALSE;
153
154 if (pAuthzResourceManager != NULL &&
156 {
157 PAUTHZ_RESMAN ResMan;
159
160 if (ResourceManagerName != NULL)
161 {
162 RequiredSize += wcslen(ResourceManagerName) * sizeof(WCHAR);
163 }
164
167 if (ResMan != NULL)
168 {
169 /* initialize the resource manager structure */
170#if DBG
171 ResMan->Tag = RESMAN_TAG;
172#endif
173
174 ResMan->flags = flags;
175 ResMan->UserSid = NULL;
176
177 if (ResourceManagerName != NULL)
178 {
180 ResourceManagerName);
181 }
182 else
184
185 ResMan->pfnAccessCheck = pfnAccessCheck;
186 ResMan->pfnComputeDynamicGroups = pfnComputeDynamicGroups;
187 ResMan->pfnFreeDynamicGroups = pfnFreeDynamicGroups;
188
190 {
191 /* FIXME - initialize auditing */
192 DPRINT1("Auditing not implemented!\n");
193 }
194
196 {
197 Ret = AuthzpInitUnderImpersonation(ResMan);
198 }
199 else
200 {
201 Ret = AuthzpInitSelf(ResMan);
202 }
203
204 if (Ret)
205 {
206 /* finally return the handle */
207 *pAuthzResourceManager = (AUTHZ_RESOURCE_MANAGER_HANDLE)ResMan;
208 }
209 else
210 {
211 DPRINT1("Querying the token failed!\n");
212 LocalFree((HLOCAL)ResMan);
213 }
214 }
215 }
216 else
218
219 return Ret;
220}
HANDLE AUTHZ_RESOURCE_MANAGER_HANDLE
Definition: authz.h:50
#define AUTHZ_RM_FLAG_INITIALIZE_UNDER_IMPERSONATION
Definition: authz.h:43
#define DPRINT1
Definition: precomp.h:8
struct _AUTHZ_RESMAN AUTHZ_RESMAN
GLbitfield flags
Definition: glext.h:7161
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1390
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define UNICODE_NULL
static BOOL AuthzpInitSelf(IN OUT PAUTHZ_RESMAN ResMan)
Definition: resman.c:120
static BOOL AuthzpInitUnderImpersonation(IN OUT PAUTHZ_RESMAN ResMan)
Definition: resman.c:100
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
WCHAR ResourceManagerName[1]
Definition: precomp.h:45
PFN_AUTHZ_COMPUTE_DYNAMIC_GROUPS pfnComputeDynamicGroups
Definition: precomp.h:38
PFN_AUTHZ_DYNAMIC_ACCESS_CHECK pfnAccessCheck
Definition: precomp.h:37
PFN_AUTHZ_FREE_DYNAMIC_GROUPS pfnFreeDynamicGroups
Definition: precomp.h:39
ULONG_PTR SIZE_T
Definition: typedefs.h:80
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4439
#define LMEM_FIXED
Definition: winbase.h:368
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ AuthzpInitSelf()

static BOOL AuthzpInitSelf ( IN OUT PAUTHZ_RESMAN  ResMan)
static

Definition at line 120 of file resman.c.

121{
122 HANDLE hToken;
123 BOOL Ret;
124
127 &hToken);
128 if (Ret)
129 {
130 Ret = AuthzpQueryToken(ResMan,
131 hToken);
132 CloseHandle(hToken);
133 }
134
135 return Ret;
136}
BOOL WINAPI OpenProcessToken(HANDLE ProcessHandle, DWORD DesiredAccess, PHANDLE TokenHandle)
Definition: security.c:294
#define CloseHandle
Definition: compat.h:739
#define GetCurrentProcess()
Definition: compat.h:759
static BOOL AuthzpQueryToken(IN OUT PAUTHZ_RESMAN ResMan, IN HANDLE hToken)
Definition: resman.c:35
#define TOKEN_QUERY
Definition: setypes.h:928

Referenced by AuthzInitializeResourceManager().

◆ AuthzpInitUnderImpersonation()

static BOOL AuthzpInitUnderImpersonation ( IN OUT PAUTHZ_RESMAN  ResMan)
static

Definition at line 100 of file resman.c.

101{
102 HANDLE hToken;
103 BOOL Ret;
104
107 TRUE,
108 &hToken);
109 if (Ret)
110 {
111 Ret = AuthzpQueryToken(ResMan,
112 hToken);
113 CloseHandle(hToken);
114 }
115
116 return Ret;
117}
BOOL WINAPI OpenThreadToken(HANDLE ThreadHandle, DWORD DesiredAccess, BOOL OpenAsSelf, HANDLE *TokenHandle)
Definition: security.c:336
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1148

Referenced by AuthzInitializeResourceManager().

◆ AuthzpQueryToken()

static BOOL AuthzpQueryToken ( IN OUT PAUTHZ_RESMAN  ResMan,
IN HANDLE  hToken 
)
static

Definition at line 35 of file resman.c.

37{
38 TOKEN_USER User;
39 TOKEN_STATISTICS Statistics;
41 PSID UserSid = NULL;
42 BOOL Ret = FALSE;
43
44 /* query information about the user */
45 BufLen = sizeof(User);
46 Ret = GetTokenInformation(hToken,
48 &User,
49 BufLen,
50 &BufLen);
51 if (Ret)
52 {
54 if (BufLen != 0)
55 {
56 UserSid = (PSID)LocalAlloc(LMEM_FIXED,
57 BufLen);
58 if (UserSid != NULL)
59 {
60 CopyMemory(UserSid,
61 User.User.Sid,
62 BufLen);
63 }
64 else
65 Ret = FALSE;
66 }
67 else
68 Ret = FALSE;
69 }
70
71 if (Ret)
72 {
73 /* query general information */
74 BufLen = sizeof(Statistics);
75 Ret = GetTokenInformation(hToken,
77 &Statistics,
78 BufLen,
79 &BufLen);
80 }
81
82 if (Ret)
83 {
84 ResMan->UserSid = UserSid;
85 ResMan->AuthenticationId = Statistics.AuthenticationId;
86 Ret = TRUE;
87 }
88 else
89 {
90 if (UserSid != NULL)
91 {
92 LocalFree((HLOCAL)UserSid);
93 }
94 }
95
96 return Ret;
97}
BOOL WINAPI GetTokenInformation(HANDLE TokenHandle, TOKEN_INFORMATION_CLASS TokenInformationClass, LPVOID TokenInformation, DWORD TokenInformationLength, PDWORD ReturnLength)
Definition: security.c:411
DWORD WINAPI GetLengthSid(PSID pSid)
Definition: security.c:919
#define BufLen
Definition: fatfs.h:167
unsigned long DWORD
Definition: ntddk_ex.h:95
struct _SID * PSID
Definition: eventlog.c:35
LUID AuthenticationId
Definition: setypes.h:1087
SID_AND_ATTRIBUTES User
Definition: setypes.h:1010
#define CopyMemory
Definition: winbase.h:1710
@ TokenUser
Definition: setypes.h:966

Referenced by AuthzpInitSelf(), and AuthzpInitUnderImpersonation().