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.

173 lines
5.4 KiB

  1. //depot/Lab01_N/Base/cluster/service/api/fixup.cpp#2 - edit change 450 (text)
  2. /*++
  3. Copyright (c) 1998 Microsoft Corporation
  4. Module Name:
  5. FixUp.cpp
  6. Abstract:
  7. Fix up Routines for Rolling Upgrades
  8. Author:
  9. Sunita Shrivastava(sunitas) 18-Mar-1998
  10. Galen Barbee (galenb) 31-Mar-1998
  11. Revision History:
  12. --*/
  13. #include "apip.h"
  14. //extern "C"
  15. //{
  16. //extern ULONG CsLogLevel;
  17. //extern ULONG CsLogModule;
  18. //}
  19. //static WCHAR wszPropertyName [] = { CLUSREG_NAME_CLUS_SD };
  20. //typedef struct stSecurityDescriptorProp
  21. //{
  22. // DWORD dwPropCount;
  23. // CLUSPROP_PROPERTY_NAME pnPropName;
  24. // WCHAR wszPropName [( sizeof( wszPropertyName ) / sizeof( WCHAR ) )];
  25. // CLUSPROP_BINARY biValueHeader;
  26. // BYTE rgbValueData[1];
  27. //} SECURITYPROPERTY;
  28. /****
  29. @func DWORD | ApiFixNotifyCb | If a cluster component wants to make
  30. a fixup to the cluster registry as a part of form/join it
  31. must register with the NM via this API.
  32. @parm IN PVOID| pContext | A pointer to the context information passed
  33. to NmRegisterFixupCb().
  34. @parm IN PVOID *ppPropertyList |
  35. @parm IN PVOID pdwProperyListSize | A pointer to DWORD where the size
  36. of the property list structure is returned.
  37. @comm For NT 5.0, the api layer performs the fixup for the security
  38. descriptor. If the new security descriptor entry for the cluster
  39. is not present in the registry , convert the old format to the new
  40. one and write it to the cluster registry.
  41. @rdesc Returns a result code. ERROR_SUCCESS on success.
  42. @xref <f NmJoinFixup> <f NmFormFixup>
  43. *****/
  44. extern "C" DWORD
  45. ApiFixupNotifyCb(
  46. IN DWORD dwFixupType,
  47. OUT PVOID *ppPropertyList,
  48. OUT LPDWORD pdwPropertyListSize,
  49. OUT LPWSTR *pszKeyName
  50. )
  51. {
  52. // CL_ASSERT( ppPropertyList != NULL );
  53. // CL_ASSERT( pdwPropertyListSize != NULL );
  54. PSECURITY_DESCRIPTOR psd = NULL;
  55. DWORD dwBufferSize = 0;
  56. DWORD dwSize = 0;
  57. DWORD dwStatus = E_FAIL;
  58. // ClRtlLogPrint( LOG_INFORMATION, "[API] ApiFixupNotifyCb: entering.\n" );
  59. if ( pdwPropertyListSize && ppPropertyList )
  60. {
  61. *ppPropertyList = NULL;
  62. *pdwPropertyListSize = 0;
  63. dwStatus = DmQueryString( DmClusterParametersKey, //try to get the NT5 SD
  64. CLUSREG_NAME_CLUS_SD,
  65. REG_BINARY,
  66. (LPWSTR *) &psd,
  67. &dwBufferSize,
  68. &dwSize );
  69. if ( dwStatus != ERROR_SUCCESS )
  70. {
  71. dwStatus = DmQueryString( DmClusterParametersKey, // try to get the NT4 SD
  72. CLUSREG_NAME_CLUS_SECURITY,
  73. REG_BINARY,
  74. (LPWSTR *) &psd,
  75. &dwBufferSize,
  76. &dwSize );
  77. if ( dwStatus == ERROR_SUCCESS )
  78. {
  79. PSECURITY_DESCRIPTOR psd5 = ClRtlConvertClusterSDToNT5Format( psd ); // convert SD to NT5 format
  80. *pdwPropertyListSize = sizeof( DWORD )
  81. + sizeof( CLUSPROP_PROPERTY_NAME )
  82. + ( ALIGN_CLUSPROP( ( lstrlenW( CLUSREG_NAME_CLUS_SD ) + 1 ) * sizeof( WCHAR ) ) )
  83. + sizeof( CLUSPROP_BINARY )
  84. + ALIGN_CLUSPROP( GetSecurityDescriptorLength( psd5 ) )
  85. + sizeof( CLUSPROP_SYNTAX );
  86. *ppPropertyList = LocalAlloc( LMEM_ZEROINIT, *pdwPropertyListSize );
  87. if ( *ppPropertyList != NULL )
  88. {
  89. CLUSPROP_BUFFER_HELPER props;
  90. props.pb = (BYTE *) *ppPropertyList;
  91. // set the number of properties
  92. props.pList->nPropertyCount = 1;
  93. props.pb += sizeof( props.pList->nPropertyCount ); // DWORD
  94. // set the property name
  95. props.pName->Syntax.dw = CLUSPROP_SYNTAX_NAME;
  96. props.pName->cbLength = ( lstrlenW( CLUSREG_NAME_CLUS_SD ) + 1 ) * sizeof( WCHAR );
  97. lstrcpyW( props.pName->sz, CLUSREG_NAME_CLUS_SD );
  98. props.pb += ( sizeof( CLUSPROP_PROPERTY_NAME )
  99. + ( ALIGN_CLUSPROP( ( lstrlenW( CLUSREG_NAME_CLUS_SD ) + 1 ) * sizeof( WCHAR ) ) ) );
  100. // set the binary part of the property the SD...
  101. props.pBinaryValue->Syntax.dw = CLUSPROP_SYNTAX_LIST_VALUE_BINARY;
  102. props.pBinaryValue->cbLength = GetSecurityDescriptorLength( psd5 );
  103. CopyMemory( props.pBinaryValue->rgb, psd5, GetSecurityDescriptorLength( psd5 ) );
  104. props.pb += sizeof(*props.pBinaryValue) + ALIGN_CLUSPROP( GetSecurityDescriptorLength( psd5 ) );
  105. // Set an endmark.
  106. props.pSyntax->dw = CLUSPROP_SYNTAX_ENDMARK;
  107. }
  108. else
  109. {
  110. dwStatus = GetLastError();
  111. // ClRtlLogPrint( LOG_CRITICAL, "[API] ApiFixupNotifyCb: Security key not found. Error = %1!0x.8!.\n", dwStatus );
  112. }
  113. // specify the registry key
  114. *pszKeyName=(LPWSTR)LocalAlloc(LMEM_FIXED, (lstrlenW(L"Cluster") + 1) *sizeof(WCHAR));
  115. if(*pszKeyName==NULL)
  116. dwStatus =GetLastError();
  117. else
  118. lstrcpyW(*pszKeyName,L"Cluster");
  119. LocalFree( psd5 );
  120. LocalFree( psd );
  121. }
  122. }
  123. else
  124. {
  125. // ClRtlLogPrint( LOG_INFORMATION, "[API] ApiFixupNotifyCb: No fixup neccessary.\n" );
  126. LocalFree( psd );
  127. }
  128. }
  129. else
  130. {
  131. // ClRtlLogPrint( LOG_CRITICAL, "[API] ApiFixupNotifyCb: Invalid parameters.\n" );
  132. }
  133. return dwStatus;
  134. }