security-api.h 2.0 KB

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