Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

205 lines
6.0 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. AcChkSup.c
  5. Abstract:
  6. This module implements the RDBSS access checking routine
  7. Author:
  8. Gary Kimura [GaryKi] 12-Jun-1989
  9. Revision History:
  10. --*/
  11. // ----------------------joejoe-----------found-------------#include "RxProcs.h"
  12. #include "precomp.h"
  13. #pragma hdrstop
  14. //
  15. // The Bug check file id for this module
  16. //
  17. #define BugCheckFileId (RDBSS_BUG_CHECK_ACCHKSUP)
  18. //
  19. // Our debug trace level
  20. //
  21. #define Dbg (DEBUG_TRACE_ACCHKSUP)
  22. #ifdef ALLOC_PRAGMA
  23. #pragma alloc_text(PAGE, RxCheckFileAccess)
  24. #endif
  25. BOOLEAN
  26. RxCheckFileAccess (
  27. PRX_CONTEXT RxContext,
  28. IN UCHAR DirentAttributes,
  29. IN ULONG DesiredAccess
  30. )
  31. /*++
  32. Routine Description:
  33. This routine checks if a desired access is allowed to a file represented
  34. by the specified DirentAttriubutes.
  35. Arguments:
  36. DirentAttributes - Supplies the Dirent attributes to check access for
  37. DesiredAccess - Supplies the desired access mask that we are checking for
  38. Return Value:
  39. BOOLEAN - TRUE if access is allowed and FALSE otherwise
  40. --*/
  41. {
  42. BOOLEAN Result;
  43. RxDbgTrace(+1, Dbg, ("RxCheckFileAccess\n", 0));
  44. RxDbgTrace( 0, Dbg, ("DirentAttributes = %8lx\n", DirentAttributes));
  45. RxDbgTrace( 0, Dbg, ("DesiredAccess = %8lx\n", DesiredAccess));
  46. //
  47. // This procedures is programmed like a string of filters each
  48. // filter checks to see if some access is allowed, if it is not allowed
  49. // the filter return FALSE to the user without further checks otherwise
  50. // it moves on to the next filter. The filter check is to check for
  51. // desired access flags that are not allowed for a particular dirent
  52. //
  53. Result = TRUE;
  54. try {
  55. //
  56. // Check for Volume ID or Device Dirents, these are not allowed user
  57. // access at all
  58. //
  59. if (FlagOn(DirentAttributes, RDBSS_DIRENT_ATTR_VOLUME_ID) ||
  60. FlagOn(DirentAttributes, RDBSS_DIRENT_ATTR_DEVICE)) {
  61. RxDbgTrace(0, Dbg, ("Cannot access volume id or device\n", 0));
  62. try_return( Result = FALSE );
  63. }
  64. //
  65. // Check for a directory Dirent or non directory dirent
  66. //
  67. if (FlagOn(DirentAttributes, RDBSS_DIRENT_ATTR_DIRECTORY)) {
  68. //
  69. // check the desired access for directory dirent
  70. //
  71. if (FlagOn(DesiredAccess, ~(DELETE |
  72. READ_CONTROL |
  73. WRITE_OWNER |
  74. WRITE_DAC |
  75. SYNCHRONIZE |
  76. ACCESS_SYSTEM_SECURITY |
  77. FILE_WRITE_DATA |
  78. FILE_READ_EA |
  79. FILE_WRITE_EA |
  80. FILE_READ_ATTRIBUTES |
  81. FILE_WRITE_ATTRIBUTES |
  82. FILE_LIST_DIRECTORY |
  83. FILE_TRAVERSE |
  84. FILE_DELETE_CHILD |
  85. FILE_APPEND_DATA))) {
  86. RxDbgTrace(0, Dbg, ("Cannot open directory\n", 0));
  87. try_return( Result = FALSE );
  88. }
  89. } else {
  90. //
  91. // check the desired access for a non-directory dirent, we
  92. // blackball
  93. // FILE_LIST_DIRECTORY, FILE_ADD_FILE, FILE_TRAVERSE,
  94. // FILE_ADD_SUBDIRECTORY, and FILE_DELETE_CHILD
  95. //
  96. if (FlagOn(DesiredAccess, ~(DELETE |
  97. READ_CONTROL |
  98. WRITE_OWNER |
  99. WRITE_DAC |
  100. SYNCHRONIZE |
  101. ACCESS_SYSTEM_SECURITY |
  102. FILE_READ_DATA |
  103. FILE_WRITE_DATA |
  104. FILE_READ_EA |
  105. FILE_WRITE_EA |
  106. FILE_READ_ATTRIBUTES |
  107. FILE_WRITE_ATTRIBUTES |
  108. FILE_EXECUTE |
  109. FILE_APPEND_DATA))) {
  110. RxDbgTrace(0, Dbg, ("Cannot open file\n", 0));
  111. try_return( Result = FALSE );
  112. }
  113. }
  114. //
  115. // Check for a read-only Dirent
  116. //
  117. if (FlagOn(DirentAttributes, RDBSS_DIRENT_ATTR_READ_ONLY)) {
  118. //
  119. // Check the desired access for a read-only dirent, we blackball
  120. // WRITE, FILE_APPEND_DATA, FILE_ADD_FILE,
  121. // FILE_ADD_SUBDIRECTORY, and FILE_DELETE_CHILD
  122. //
  123. if (FlagOn(DesiredAccess, ~(DELETE |
  124. READ_CONTROL |
  125. WRITE_OWNER |
  126. WRITE_DAC |
  127. SYNCHRONIZE |
  128. ACCESS_SYSTEM_SECURITY |
  129. FILE_READ_DATA |
  130. FILE_READ_EA |
  131. FILE_WRITE_EA |
  132. FILE_READ_ATTRIBUTES |
  133. FILE_WRITE_ATTRIBUTES |
  134. FILE_EXECUTE |
  135. FILE_LIST_DIRECTORY |
  136. FILE_TRAVERSE))) {
  137. RxDbgTrace(0, Dbg, ("Cannot open readonly\n", 0));
  138. try_return( Result = FALSE );
  139. }
  140. }
  141. try_exit: NOTHING;
  142. } finally {
  143. DebugUnwind( RxCheckFileAccess );
  144. RxDbgTrace(-1, Dbg, ("RxCheckFileAccess -> %08lx\n", Result));
  145. }
  146. UNREFERENCED_PARAMETER( RxContext );
  147. return Result;
  148. }
  149.