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.

222 lines
5.6 KiB

  1. //*************************************************************
  2. //
  3. // Copyright (c) Microsoft Corporation 1998
  4. // All rights reserved
  5. //
  6. // filedb.hxx
  7. //
  8. //*************************************************************
  9. #ifndef _FILEDB_HXX_
  10. #define _FILEDB_HXX_
  11. #define GPT_SUBDIR L"\\Documents & Settings\\"
  12. #define INIFILE_NAME L"fdeploy.ini"
  13. //forward declaration
  14. class CCopyFailData;
  15. typedef struct _FOLDERINFO
  16. {
  17. int CSidl;
  18. DWORD FolderNameLength;
  19. WCHAR * FolderName;
  20. WCHAR * RegValue;
  21. } FOLDERINFO;
  22. class CSavedSettings
  23. {
  24. friend class CRedirectInfo;
  25. public:
  26. CSavedSettings();
  27. ~CSavedSettings();
  28. BOOL NeedsProcessing (void);
  29. DWORD HandleUserNameChange (CFileDB * pFileDB,
  30. CRedirectInfo * pRedir);
  31. DWORD Load (CFileDB * pFileDB);
  32. DWORD Save (const WCHAR * pwszPath, DWORD dwFlags, PSID pSid, const WCHAR * pszGPOName);
  33. static void ResetStaticMembers (void);
  34. void ResetMembers (void);
  35. private: //data
  36. static int m_idConstructor;
  37. static CFileDB * m_pFileDB;
  38. static WCHAR * m_szSavedSettingsPath;
  39. //object specific data
  40. REDIRECTABLE m_rID; //the id of the folder that it represents
  41. WCHAR * m_szLastRedirectedPath;
  42. WCHAR * m_szCurrentPath;
  43. WCHAR * m_szLastUserName; //the name of the user at the last logon
  44. BOOL m_bUserNameChanged; //if the user's logon name was different at last logon.
  45. WCHAR * m_szLastHomedir; // The value of Homedir at last redirection.
  46. BOOL m_bIsHomedirRedir; // Indicates if this is a homedir redirection.
  47. BOOL m_bHomedirChanged; // Indicates if the homedir value has changed.
  48. PSID m_psid;
  49. DWORD m_dwFlags;
  50. BOOL m_bValidGPO;
  51. WCHAR m_szGPOName[50]; //unique GPO name (if any) that was used for redirection
  52. //50 characters are more than enough to store the GPO name.
  53. private: //helper functions
  54. DWORD LoadDefaultLocal (void);
  55. DWORD LoadFromIniFile (void);
  56. DWORD GetCurrentPath (void);
  57. DWORD ResetLastUserName (void);
  58. DWORD UpdateUserNameInCache (void);
  59. };
  60. class CFileDB : public CRedirectionLog
  61. {
  62. friend class CSavedSettings;
  63. friend class CRedirectInfo;
  64. friend class CRedirectionPolicy;
  65. public:
  66. CFileDB();
  67. ~CFileDB();
  68. DWORD
  69. Initialize (
  70. HANDLE hUserToken,
  71. HKEY hkRoot,
  72. CRsopContext* pRsopContext
  73. );
  74. DWORD
  75. Process(
  76. PGROUP_POLICY_OBJECT pGPO,
  77. BOOL bRemove
  78. );
  79. const WCHAR *
  80. GetLocalStoragePath ();
  81. PVOID
  82. GetEnvBlock (void);
  83. CRsopContext*
  84. GetRsopContext();
  85. private:
  86. DWORD
  87. ProcessRedirects();
  88. BOOL
  89. ReadIniSection(
  90. WCHAR * pwszSectionName,
  91. WCHAR ** ppwszStrings,
  92. DWORD * pcchLen = NULL
  93. );
  94. DWORD
  95. GetLocalFilePath(
  96. WCHAR * pwszFolderPath,
  97. WCHAR wszFullPath[MAX_PATH]
  98. );
  99. DWORD
  100. GetPathFromFolderName(
  101. WCHAR * pwszFolderName,
  102. WCHAR wszFullPath[MAX_PATH]
  103. );
  104. DWORD
  105. CopyGPTFile(
  106. WCHAR * pwszLocalPath,
  107. WCHAR * pwszGPTPath
  108. );
  109. const FOLDERINFO*
  110. FolderInfoFromFolderName(
  111. WCHAR * pwszFolderName
  112. );
  113. int
  114. RegValueCSIDLFromFolderName(
  115. WCHAR * pwszFolderName
  116. );
  117. WCHAR *
  118. RegValueNameFromFolderName(
  119. WCHAR * pwszFolderName
  120. );
  121. DWORD
  122. CopyFileTree(
  123. WCHAR * pwszExistingPath,
  124. WCHAR * pwszNewPath,
  125. WCHAR * pwszIgnoredSubdir,
  126. SHARESTATUS StatusFrom,
  127. SHARESTATUS StatusTo,
  128. BOOL bAllowRdrTimeout,
  129. CCopyFailData * pCopyFailure
  130. );
  131. DWORD
  132. DeleteFileTree(
  133. WCHAR * pwszPath,
  134. WCHAR * pwszIgnoredSubdir
  135. );
  136. DWORD
  137. CreateRedirectedFolderPath(
  138. const WCHAR * pwszSource,
  139. const WCHAR * pwszDest,
  140. BOOL bSourceValid,
  141. BOOL bCheckOwner,
  142. BOOL bMoveContents
  143. );
  144. DWORD
  145. CreateFolderWithUserFileSecurity(
  146. WCHAR * pwszPath
  147. );
  148. DWORD
  149. SetUserAsOwner(
  150. WCHAR * pwszPath
  151. );
  152. DWORD IsUserOwner (const WCHAR * pwszPath);
  153. //data
  154. //same across all policies
  155. HANDLE _hUserToken;
  156. HKEY _hkRoot;
  157. PTOKEN_GROUPS _pGroups;
  158. WCHAR _pwszLocalPath[MAX_PATH]; //path to the Local Settings directory
  159. //created only if necessary but same across all policies
  160. WCHAR * _pwszProfilePath; // %userprofile%
  161. PVOID _pEnvBlock;
  162. //varies with each policy
  163. BOOL _bRemove;
  164. WCHAR * _pwszGPTPath; // Path to Documents & Settings dir on GPT
  165. DWORD _GPTPathLen; //number of characters allocated to _pwszGPTPath
  166. WCHAR * _pwszIniFilePath; // Full path to file deployment ini file on the GPT
  167. DWORD _IniFileLen; //# of characters allocated to _pwszIniFilePath
  168. WCHAR * _pwszGPOName; // From GPO_INFO struct, not alloced
  169. WCHAR * _pwszGPOUniqueName; // From GPO_INFO struct, not alloced
  170. WCHAR * _pwszGPOSOMPath; // From GPO_INFO struct, not alloced
  171. WCHAR * _pwszGPODSPath; // From GPO_INFO struct, not alloced
  172. CRsopContext* _pRsopContext; // unowned reference to rsop info
  173. };
  174. inline void
  175. RemoveEndingSlash(
  176. WCHAR * pwszPath
  177. )
  178. {
  179. DWORD Length = wcslen( pwszPath );
  180. if ( pwszPath[Length-1] == L'\\' )
  181. pwszPath[Length-1] = 0;
  182. }
  183. #endif