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.

177 lines
3.7 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1996.
  5. //
  6. // File: UNC.C
  7. //
  8. // Contents: Unit test for file propagation, issues
  9. //
  10. // History: 05-Mar-98 MacM Created
  11. //
  12. // Notes:
  13. //
  14. //----------------------------------------------------------------------------
  15. #include <windows.h>
  16. #include <stdlib.h>
  17. #include <stdio.h>
  18. #include <aclapi.h>
  19. #define UTEST_DOUBLE_UNC 0x00000001
  20. #define FLAG_ON(flags,bit) ((flags) & (bit))
  21. VOID
  22. Usage (
  23. IN PSTR pszExe
  24. )
  25. /*++
  26. Routine Description:
  27. Displays the usage
  28. Arguments:
  29. pszExe - Name of the exe
  30. Return Value:
  31. VOID
  32. --*/
  33. {
  34. printf("%s path [/test]\n", pszExe);
  35. printf(" where path is the UNC path to use\n");
  36. printf(" /test indicates which test to run:\n");
  37. printf(" /DOUBLE (Double Read from UNC path)\n");
  38. return;
  39. }
  40. DWORD
  41. DoubleUncTest(
  42. IN PWSTR pwszUNCPath
  43. )
  44. {
  45. DWORD dwErr = ERROR_SUCCESS;
  46. PACTRL_ACCESS pAccess;
  47. dwErr = GetNamedSecurityInfoExW(pwszUNCPath,
  48. SE_FILE_OBJECT,
  49. DACL_SECURITY_INFORMATION,
  50. NULL,
  51. NULL,
  52. &pAccess,
  53. NULL,
  54. NULL,
  55. NULL);
  56. if ( dwErr != ERROR_SUCCESS ) {
  57. printf("Initial GetNamedSecurityInfoExW on %ws failed with %lu\n",
  58. pwszUNCPath, dwErr );
  59. } else {
  60. LocalFree( pAccess );
  61. dwErr = GetNamedSecurityInfoExW(pwszUNCPath,
  62. SE_FILE_OBJECT,
  63. DACL_SECURITY_INFORMATION,
  64. NULL,
  65. NULL,
  66. &pAccess,
  67. NULL,
  68. NULL,
  69. NULL);
  70. if ( dwErr != ERROR_SUCCESS ) {
  71. printf( "Second GetNamedSecurityInfoExW on %ws failed with %lu\n",
  72. pwszUNCPath, dwErr );
  73. } else {
  74. LocalFree( pAccess );
  75. }
  76. }
  77. return( dwErr );
  78. }
  79. __cdecl main (
  80. IN INT argc,
  81. IN CHAR *argv[])
  82. /*++
  83. Routine Description:
  84. The main
  85. Arguments:
  86. argc -- Count of arguments
  87. argv -- List of arguments
  88. Return Value:
  89. 0 -- Success
  90. non-0 -- Failure
  91. --*/
  92. {
  93. DWORD dwErr = ERROR_SUCCESS, dwErr2;
  94. WCHAR wszPath[MAX_PATH + 1];
  95. WCHAR wszUser[MAX_PATH + 1];
  96. INHERIT_FLAGS Inherit = 0;
  97. ULONG Tests = 0;
  98. INT i;
  99. BOOL fHandle = FALSE;
  100. srand((ULONG)(GetTickCount() * GetCurrentThreadId()));
  101. if(argc < 2)
  102. {
  103. Usage(argv[0]);
  104. exit(1);
  105. }
  106. mbstowcs(wszPath, argv[1], strlen(argv[1]) + 1);
  107. //
  108. // process the command line
  109. //
  110. for(i = 3; i < argc; i++)
  111. {
  112. if(_stricmp(argv[i],"/DOUBLE") == 0)
  113. {
  114. Tests |= UTEST_DOUBLE_UNC;
  115. }
  116. else
  117. {
  118. Usage(argv[0]);
  119. exit(1);
  120. break;
  121. }
  122. }
  123. if(Tests == 0)
  124. {
  125. Tests = UTEST_DOUBLE_UNC;
  126. }
  127. if(dwErr == ERROR_SUCCESS && FLAG_ON(Tests, UTEST_DOUBLE_UNC))
  128. {
  129. dwErr = DoubleUncTest(wszPath);
  130. }
  131. printf("%s\n", dwErr == ERROR_SUCCESS ?
  132. "success" :
  133. "failed");
  134. return(dwErr);
  135. }