winsecur.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * winsecur.h: some miscellaneous security-related helper functions,
  3. * defined in winsecur.c, that use the advapi32 library. Also
  4. * centralises the machinery for dynamically loading that library.
  5. */
  6. #if !defined NO_SECURITY
  7. #include <aclapi.h>
  8. /*
  9. * Functions loaded from advapi32.dll.
  10. */
  11. DECL_WINDOWS_FUNCTION(extern, BOOL, OpenProcessToken,
  12. (HANDLE, DWORD, PHANDLE));
  13. DECL_WINDOWS_FUNCTION(extern, BOOL, GetTokenInformation,
  14. (HANDLE, TOKEN_INFORMATION_CLASS,
  15. LPVOID, DWORD, PDWORD));
  16. DECL_WINDOWS_FUNCTION(extern, BOOL, InitializeSecurityDescriptor,
  17. (PSECURITY_DESCRIPTOR, DWORD));
  18. DECL_WINDOWS_FUNCTION(extern, BOOL, SetSecurityDescriptorOwner,
  19. (PSECURITY_DESCRIPTOR, PSID, BOOL));
  20. DECL_WINDOWS_FUNCTION(extern, DWORD, GetSecurityInfo,
  21. (HANDLE, SE_OBJECT_TYPE, SECURITY_INFORMATION,
  22. PSID *, PSID *, PACL *, PACL *,
  23. PSECURITY_DESCRIPTOR *));
  24. DECL_WINDOWS_FUNCTION(extern, DWORD, SetSecurityInfo,
  25. (HANDLE, SE_OBJECT_TYPE, SECURITY_INFORMATION,
  26. PSID, PSID, PACL, PACL));
  27. DECL_WINDOWS_FUNCTION(extern, DWORD, SetEntriesInAclA,
  28. (ULONG, PEXPLICIT_ACCESS, PACL, PACL *));
  29. bool got_advapi(void);
  30. /*
  31. * Find the SID describing the current user. The return value (if not
  32. * NULL for some error-related reason) is smalloced.
  33. */
  34. PSID get_user_sid(void);
  35. /*
  36. * Construct a PSECURITY_DESCRIPTOR of the type used for named pipe
  37. * servers, i.e. allowing access only to the current user id and also
  38. * only local (i.e. not over SMB) connections.
  39. *
  40. * If this function returns true, then 'psd' and 'acl' will have been
  41. * filled in with memory allocated using LocalAlloc (and hence must be
  42. * freed later using LocalFree). If it returns false, then instead
  43. * 'error' has been filled with a dynamically allocated error message.
  44. */
  45. bool make_private_security_descriptor(
  46. DWORD permissions, PSECURITY_DESCRIPTOR *psd, PACL *acl, char **error);
  47. #endif