winsecur.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. #ifndef WINSECUR_GLOBAL
  9. #define WINSECUR_GLOBAL extern
  10. #endif
  11. /*
  12. * Functions loaded from advapi32.dll.
  13. */
  14. DECL_WINDOWS_FUNCTION(WINSECUR_GLOBAL, BOOL, OpenProcessToken,
  15. (HANDLE, DWORD, PHANDLE));
  16. DECL_WINDOWS_FUNCTION(WINSECUR_GLOBAL, BOOL, GetTokenInformation,
  17. (HANDLE, TOKEN_INFORMATION_CLASS,
  18. LPVOID, DWORD, PDWORD));
  19. DECL_WINDOWS_FUNCTION(WINSECUR_GLOBAL, BOOL, InitializeSecurityDescriptor,
  20. (PSECURITY_DESCRIPTOR, DWORD));
  21. DECL_WINDOWS_FUNCTION(WINSECUR_GLOBAL, BOOL, SetSecurityDescriptorOwner,
  22. (PSECURITY_DESCRIPTOR, PSID, BOOL));
  23. DECL_WINDOWS_FUNCTION(WINSECUR_GLOBAL, DWORD, GetSecurityInfo,
  24. (HANDLE, SE_OBJECT_TYPE, SECURITY_INFORMATION,
  25. PSID *, PSID *, PACL *, PACL *,
  26. PSECURITY_DESCRIPTOR *));
  27. DECL_WINDOWS_FUNCTION(WINSECUR_GLOBAL, DWORD, SetSecurityInfo,
  28. (HANDLE, SE_OBJECT_TYPE, SECURITY_INFORMATION,
  29. PSID, PSID, PACL, PACL));
  30. DECL_WINDOWS_FUNCTION(WINSECUR_GLOBAL, DWORD, SetEntriesInAclA,
  31. (ULONG, PEXPLICIT_ACCESS, PACL, PACL *));
  32. int got_advapi(void);
  33. /*
  34. * Find the SID describing the current user. The return value (if not
  35. * NULL for some error-related reason) is smalloced.
  36. */
  37. PSID get_user_sid(void);
  38. /*
  39. * Construct a PSECURITY_DESCRIPTOR of the type used for named pipe
  40. * servers, i.e. allowing access only to the current user id and also
  41. * only local (i.e. not over SMB) connections.
  42. *
  43. * If this function returns TRUE, then 'psd' and 'acl' will have been
  44. * filled in with memory allocated using LocalAlloc (and hence must be
  45. * freed later using LocalFree). If it returns FALSE, then instead
  46. * 'error' has been filled with a dynamically allocated error message.
  47. */
  48. int make_private_security_descriptor(DWORD permissions,
  49. PSECURITY_DESCRIPTOR *psd,
  50. PACL *acl,
  51. char **error);
  52. #endif