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.

129 lines
2.6 KiB

  1. /*************************************************************************
  2. *
  3. * report.c
  4. *
  5. * Report module
  6. *
  7. * Copyright Microsoft, 1998
  8. *
  9. *
  10. * This module puts all reporting in one place to accommadate changes.
  11. *
  12. *
  13. *
  14. *************************************************************************/
  15. /*
  16. * Includes
  17. */
  18. #include <nt.h>
  19. #include <ntrtl.h>
  20. #include <nturtl.h>
  21. #include <windows.h>
  22. #include <stdio.h> // Make a bunch of default NT templates
  23. #include <process.h>
  24. #include <winsta.h>
  25. #include <syslib.h>
  26. #include "security.h"
  27. #if DBG
  28. ULONG
  29. DbgPrint(
  30. PCH Format,
  31. ...
  32. );
  33. #define DBGPRINT(x) DbgPrint x
  34. #if DBGTRACE
  35. #define TRACE0(x) DbgPrint x
  36. #define TRACE1(x) DbgPrint x
  37. #else
  38. #define TRACE0(x)
  39. #define TRACE1(x)
  40. #endif
  41. #else
  42. #define DBGPRINT(x)
  43. #define TRACE0(x)
  44. #define TRACE1(x)
  45. #endif
  46. //
  47. // Forward references
  48. //
  49. VOID
  50. PrintFileAccessMask(
  51. ACCESS_MASK Mask
  52. );
  53. /*****************************************************************************
  54. *
  55. * ReportFileResult
  56. *
  57. * Generates a report on a file access check
  58. *
  59. * ENTRY:
  60. * Param1 (input/output)
  61. * Comments
  62. *
  63. * EXIT:
  64. * STATUS_SUCCESS - no error
  65. *
  66. ****************************************************************************/
  67. BOOL
  68. ReportFileResult(
  69. FILE_RESULT Code,
  70. ACCESS_MASK Access,
  71. PWCHAR pFile,
  72. PWCHAR pAccountName,
  73. PWCHAR pDomainName,
  74. PCHAR UserFormat,
  75. ...
  76. )
  77. {
  78. va_list arglist;
  79. UCHAR Buffer[512];
  80. int cb;
  81. DWORD Len;
  82. va_start(arglist, UserFormat);
  83. //
  84. // New format:
  85. //
  86. // 6 28 xxx
  87. // ACCESS ACCOUNT FILE
  88. // ______ ____________________________ _______________________________________
  89. //
  90. if( Code == FileOk ) {
  91. ; // Do nothing, future options may report an OK list
  92. return (TRUE );
  93. }
  94. else if( Code == FileAccessError ) {
  95. DBGPRINT(("***WARNING*** Error accessing security information on file %ws\n",pFile));
  96. DBGPRINT(("The account in which the utility is run may not have access to the file\n"));
  97. DBGPRINT(("Use FileManager to take ownership of this file\n"));
  98. return (TRUE );
  99. }
  100. else if( Code == FileAccessErrorUserFormat ) {
  101. // Use the user supplied format string in the error report
  102. cb = _vsnprintf(Buffer, sizeof(Buffer), UserFormat, arglist);
  103. if (cb == -1) { // detect buffer overflow
  104. cb = sizeof(Buffer);
  105. Buffer[sizeof(Buffer) - 1] = '\n';
  106. }
  107. DBGPRINT(("***ERROR*** %s on file %ws\n",Buffer,pFile));
  108. return( TRUE );
  109. }
  110. return( FALSE );
  111. }