Leaked source code of windows server 2003
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.

416 lines
15 KiB

  1. //#pragma title ("SDStat.hpp -- Statistical information for SDResolve")
  2. /*
  3. Copyright (c) 1995-1998, Mission Critical Software, Inc. All rights reserved.
  4. ===============================================================================
  5. Module - sdstat.hpp
  6. System - SDResolve
  7. Author - Christy Boles
  8. Created - 97/06/27
  9. Description - Statistical information for SDResolve
  10. Updates -
  11. ===============================================================================
  12. */
  13. #include "stdafx.h"
  14. #include <stdio.h>
  15. #include "common.hpp"
  16. #include "ErrDct.hpp"
  17. #include "sidcache.hpp"
  18. #include "sd.hpp"
  19. #include "SecObj.hpp"
  20. #include "enumvols.hpp"
  21. #include "sdstat.hpp"
  22. #include "Mcs.h"
  23. extern TErrorDct err;
  24. TSDResolveStats::TSDResolveStats(
  25. TSDRidCache * cache, // in - cache containing mapping of accounts for the translation
  26. const TPathList * plist, // in - list of paths being translated
  27. IVarSet * pVarSet // in - varset to store stats in
  28. )
  29. {
  30. memset(&unit,0,sizeof TSDFileActions);
  31. memset(&part,0,sizeof TSDPartStats);
  32. pPList = plist;
  33. len = 0;
  34. frame_foreground =FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_GREEN ;
  35. background = BACKGROUND_BLUE ;
  36. data_foreground =frame_foreground | FOREGROUND_INTENSITY ;
  37. message_foreground = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY;
  38. pCache = cache;
  39. m_pVarSet = pVarSet;
  40. }
  41. TSDResolveStats::TSDResolveStats(
  42. TSDRidCache * cache // in - cache containing mapping of accounts for translation
  43. )
  44. {
  45. memset(&unit,0,sizeof TSDFileActions);
  46. memset(&part,0,sizeof TSDPartStats);
  47. pPList = NULL;
  48. len = 0;
  49. frame_foreground =FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_GREEN ;
  50. background = BACKGROUND_BLUE ;
  51. data_foreground =frame_foreground | FOREGROUND_INTENSITY ;
  52. message_foreground = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY;
  53. pCache = cache;
  54. //Added by Sham : Initialize m_pVarSet
  55. IVarSetPtr pVarSet(__uuidof(VarSet));
  56. m_pVarSet = pVarSet;
  57. // Need to add code to release this interface once we are done. In the destructor maybe
  58. m_pVarSet->AddRef();
  59. }
  60. void
  61. TSDResolveStats::IncrementOwnerChange(
  62. TAcctNode * acct, // in -account changed
  63. objectType type, // in -type of object
  64. TSecurableObject * file // in -file changed
  65. )
  66. {
  67. acct->AddOwnerChange(type);
  68. part.owner.changed++;
  69. if ( file )
  70. file->LogOwnerChange(acct);
  71. }
  72. void
  73. TSDResolveStats::IncrementGroupChange(
  74. TAcctNode * acct, // in -account changed
  75. objectType type, // in -type of object
  76. TSecurableObject * file // in -file changed
  77. )
  78. {
  79. acct->AddGroupChange(type);
  80. part.group.changed++;
  81. if ( file )
  82. file->LogGroupChange(acct);
  83. }
  84. void
  85. TSDResolveStats::IncrementDACEChange(
  86. TAcctNode * acct, // in -account changed
  87. objectType type, // in -type of object
  88. TSecurableObject * file // in -file changed
  89. )
  90. {
  91. acct->AddAceChange(type);
  92. part.dace.changed++;
  93. if ( file )
  94. file->LogDACEChange(acct);
  95. }
  96. void
  97. TSDResolveStats::IncrementSACEChange(
  98. TAcctNode * acct, // in -account changed
  99. objectType type, // in -type of object
  100. TSecurableObject * file // in -file changed
  101. )
  102. {
  103. acct->AddSaceChange(type);
  104. part.sace.changed++;
  105. if ( file )
  106. file->LogSACEChange(acct);
  107. }
  108. void
  109. TSDResolveStats::IncrementDACENotSelected(
  110. TSecurableObject *file // in - object to increment stats for
  111. )
  112. {
  113. file->daceNS++;
  114. part.dace.notselected++;
  115. }
  116. void
  117. TSDResolveStats::IncrementSACENotSelected(
  118. TSecurableObject *file // in - object to increment stats for
  119. )
  120. {
  121. if ( file )
  122. file->saceNS++;
  123. part.sace.notselected++;
  124. }
  125. void
  126. TSDResolveStats::IncrementDACEUnknown(
  127. TSecurableObject *file // in - object to increment stats for
  128. )
  129. {
  130. if ( file )
  131. file->daceU++;
  132. part.dace.unknown++;
  133. }
  134. void
  135. TSDResolveStats::IncrementSACEUnknown(
  136. TSecurableObject *file // in - object to increment stats for
  137. )
  138. {
  139. if ( file )
  140. file->saceU++;
  141. part.sace.unknown++;
  142. }
  143. void
  144. TSDResolveStats::IncrementDACENoTarget(
  145. TSecurableObject *file // in - object to increment stats for
  146. )
  147. {
  148. if ( file )
  149. file->daceNT++;
  150. part.dace.notarget++;
  151. }
  152. void
  153. TSDResolveStats::IncrementSACENoTarget(
  154. TSecurableObject *file // in - object to increment stats for
  155. )
  156. {
  157. if ( file )
  158. file->saceNT++;
  159. part.sace.notarget++;
  160. }
  161. /***************************************************************************************************/
  162. /* IncrementLastFileChanges: used in conjunction with last-seen heuristic. When a SD matches the
  163. last-seen SD, this routine repeats all the stat-updates
  164. that were done for the last-seen SD, so that we have accurate stats
  165. (especially ACE changes per account)
  166. /**************************************************************************************************/
  167. void
  168. TSDResolveStats::IncrementLastFileChanges(
  169. const TSecurableObject * lastfile, // in -file to repeat change stats from
  170. objectType objType // in -type of object
  171. )
  172. {
  173. TNodeListEnum tenum;
  174. TStatNode * snode;
  175. // make modifications except changes
  176. // owner
  177. IncrementOwnerExamined();
  178. IncrementGroupExamined();
  179. if ( lastfile->UnknownOwner() )
  180. part.owner.unknown++;
  181. // group
  182. if ( lastfile->UnknownGroup() )
  183. part.group.unknown++;
  184. // dacl
  185. if ( lastfile->HasDacl() )
  186. IncrementDACLExamined();
  187. // sacl
  188. if ( lastfile->HasSacl() )
  189. IncrementSACLExamined();
  190. // aces
  191. part.dace.notarget+=lastfile->daceNT;
  192. part.sace.notarget+=lastfile->saceNT;
  193. part.dace.unknown+=lastfile->daceU;
  194. part.sace.unknown+=lastfile->saceU;
  195. part.dace.notselected+=lastfile->daceNS;
  196. part.sace.notselected+=lastfile->saceNS;
  197. if ( lastfile->Changed() )
  198. {
  199. IncrementChanged(objType);
  200. }
  201. if ( lastfile->Changed() || (lastfile->GetChangeLog())->Count() )
  202. {
  203. if ( lastfile->IsDaclChanged() )
  204. {
  205. IncrementDACLChanged();
  206. }
  207. if ( lastfile->IsSaclChanged() )
  208. {
  209. IncrementSACLChanged();
  210. }
  211. for ( snode = (TStatNode *)tenum.OpenFirst(lastfile->GetChangeLog()) ;
  212. snode ;
  213. snode = (TStatNode *)tenum.Next()
  214. )
  215. {
  216. switch ( snode->changetype )
  217. {
  218. case TStatNode::owner:
  219. IncrementOwnerChange(snode->acctnode,objType,NULL);
  220. break;
  221. case TStatNode::group:
  222. IncrementGroupChange(snode->acctnode,objType,NULL);
  223. break;
  224. case TStatNode::dace:
  225. IncrementDACEChange(snode->acctnode,objType,NULL);
  226. break;
  227. case TStatNode::sace:
  228. IncrementSACEChange(snode->acctnode,objType,NULL);
  229. break;
  230. default:
  231. MCSASSERT( false );
  232. }
  233. }
  234. tenum.Close();
  235. }
  236. }
  237. void
  238. TSDResolveStats::ReportToVarSet(
  239. IVarSet * pVarSet, // in -varset to write data to
  240. DWORD verbnum // in -which info to log
  241. ) const
  242. {
  243. BOOL summary = verbnum & SUMMARYSTATS;
  244. BOOL accts = verbnum & ACCOUNTSTATS;
  245. // BOOL file = verbnum & FILESTATS;
  246. BOOL paths = verbnum & PATHSTATS;
  247. if ( summary )
  248. {
  249. if ( paths && pPList )
  250. {
  251. pVarSet->put(GET_BSTR(DCTVS_Stats_Paths),(LONG)pPList->GetNumPaths() );
  252. pVarSet->put(GET_BSTR(DCTVS_Stats_Servers),(LONG)pPList->GetNumServers() );
  253. }
  254. pVarSet->put(GET_BSTR(DCTVS_Stats_Files_Examined),(LONG)unit.examined.file);
  255. pVarSet->put(GET_BSTR(DCTVS_Stats_Directories_Examined),(LONG)unit.examined.dir);
  256. pVarSet->put(GET_BSTR(DCTVS_Stats_Shares_Examined),(LONG)unit.examined.share);
  257. pVarSet->put(GET_BSTR(DCTVS_Stats_Mailboxes_Examined),(LONG)unit.examined.mailbox);
  258. pVarSet->put(GET_BSTR(DCTVS_Stats_Containers_Examined),(LONG)unit.examined.container);
  259. pVarSet->put(GET_BSTR(DCTVS_Stats_Files_CacheHits),(LONG)unit.cachehit.file);
  260. pVarSet->put(GET_BSTR(DCTVS_Stats_Directories_CacheHits),(LONG)unit.cachehit.dir);
  261. pVarSet->put(GET_BSTR(DCTVS_Stats_Files_Skipped),(LONG)unit.skipped.file);
  262. pVarSet->put(GET_BSTR(DCTVS_Stats_Directories_Skipped),(LONG)unit.skipped.dir);
  263. pVarSet->put(GET_BSTR(DCTVS_Stats_Shares_Skipped),(LONG)unit.skipped.share);
  264. pVarSet->put(GET_BSTR(DCTVS_Stats_Mailboxes_Skipped),(LONG)unit.skipped.mailbox);
  265. pVarSet->put(GET_BSTR(DCTVS_Stats_Containers_Skipped),(LONG)unit.skipped.container);
  266. pVarSet->put(GET_BSTR(DCTVS_Stats_Files_Changed),(LONG)unit.changed.file);
  267. pVarSet->put(GET_BSTR(DCTVS_Stats_Directories_Changed),(LONG)unit.changed.dir);
  268. pVarSet->put(GET_BSTR(DCTVS_Stats_Shares_Changed),(LONG)unit.changed.share);
  269. pVarSet->put(GET_BSTR(DCTVS_Stats_Mailboxes_Changed),(LONG)unit.changed.mailbox);
  270. pVarSet->put(GET_BSTR(DCTVS_Stats_Containers_Changed),(LONG)unit.changed.container);
  271. pVarSet->put(GET_BSTR(DCTVS_Stats_Owners_Examined),(LONG)part.owner.examined);
  272. pVarSet->put(GET_BSTR(DCTVS_Stats_Groups_Examined),(LONG)part.group.examined);
  273. pVarSet->put(GET_BSTR(DCTVS_Stats_DACL_Examined),(LONG)part.dacl.examined);
  274. pVarSet->put(GET_BSTR(DCTVS_Stats_SACL_Examined),(LONG)part.sacl.examined);
  275. pVarSet->put(GET_BSTR(DCTVS_Stats_DACE_Examined),(LONG)part.dace.examined);
  276. pVarSet->put(GET_BSTR(DCTVS_Stats_SACE_Examined),(LONG)part.sace.examined);
  277. pVarSet->put(GET_BSTR(DCTVS_Stats_Owners_Changed),(LONG)part.owner.changed);
  278. pVarSet->put(GET_BSTR(DCTVS_Stats_Groups_Changed),(LONG)part.group.changed);
  279. pVarSet->put(GET_BSTR(DCTVS_Stats_DACL_Changed),(LONG)part.dacl.changed);
  280. pVarSet->put(GET_BSTR(DCTVS_Stats_SACL_Changed),(LONG)part.sacl.changed);
  281. pVarSet->put(GET_BSTR(DCTVS_Stats_DACE_Changed),(LONG)part.dace.changed);
  282. pVarSet->put(GET_BSTR(DCTVS_Stats_SACE_Changed),(LONG)part.sace.changed);
  283. pVarSet->put(GET_BSTR(DCTVS_Stats_Owners_NoTarget),(LONG)part.owner.notarget);
  284. pVarSet->put(GET_BSTR(DCTVS_Stats_Groups_NoTarget),(LONG)part.group.notarget);
  285. pVarSet->put(GET_BSTR(DCTVS_Stats_DACE_NoTarget),(LONG)part.dace.notarget);
  286. pVarSet->put(GET_BSTR(DCTVS_Stats_SACE_NoTarget),(LONG)part.sace.notarget);
  287. pVarSet->put(GET_BSTR(DCTVS_Stats_Owners_Unknown),(LONG)part.owner.unknown);
  288. pVarSet->put(GET_BSTR(DCTVS_Stats_Groups_Unknown),(LONG)part.group.unknown);
  289. pVarSet->put(GET_BSTR(DCTVS_Stats_DACE_Unknown),(LONG)part.dace.unknown);
  290. pVarSet->put(GET_BSTR(DCTVS_Stats_SACE_Unknown),(LONG)part.sace.unknown);
  291. }
  292. if ( accts )
  293. pCache->ReportToVarSet(pVarSet,false, true);
  294. }
  295. void
  296. TSDResolveStats::Report(
  297. BOOL summary, // in -flag, whether to report summary information
  298. BOOL accts, // in -flag, whether to report account detail information
  299. BOOL paths // in -flag, whether to report path detail information
  300. ) const
  301. {
  302. if ( accts )
  303. pCache->Display(summary!=0, accts!=0);
  304. #ifdef FST
  305. if ( paths & pPList )
  306. pPList->Display();
  307. #endif
  308. if ( summary )
  309. {
  310. err.MsgWrite(0,DCT_MSG_SUMMARY_REPORT_HEADER);
  311. err.MsgWrite(0,DCT_MSG_SUMMARY_REPORT_FILES_DDD,unit.examined.file, unit.changed.file, unit.examined.file - unit.changed.file);
  312. err.MsgWrite(0,DCT_MSG_SUMMARY_REPORT_DIRS_DDD,unit.examined.dir, unit.changed.dir, unit.examined.dir - unit.changed.dir);
  313. err.MsgWrite(0,DCT_MSG_SUMMARY_REPORT_SHARES_DDD,unit.examined.share, unit.changed.share, unit.examined.share - unit.changed.share);
  314. err.MsgWrite(0,DCT_MSG_SUMMARY_REPORT_MEMBERS_DDD,unit.examined.member, unit.changed.member, unit.examined.member - unit.changed.member);
  315. err.MsgWrite(0,DCT_MSG_SUMMARY_REPORT_RIGHTS_DDD,unit.examined.userright, unit.changed.userright, unit.examined.userright - unit.changed.userright);
  316. err.MsgWrite(0,DCT_MSG_SUMMARY_REPORT_MAILBOXES_DDD,unit.examined.mailbox, unit.changed.mailbox, unit.examined.mailbox - unit.changed.mailbox);
  317. err.MsgWrite(0,DCT_MSG_SUMMARY_REPORT_CONTAINERS_DDD,unit.examined.container, unit.changed.container, unit.examined.container - unit.changed.container);
  318. err.MsgWrite(0,DCT_MSG_SUMMARY_REPORT_DACLS_DDD,part.dacl.examined, part.dacl.changed, part.dacl.examined - part.dacl.changed);
  319. err.MsgWrite(0,DCT_MSG_SUMMARY_REPORT_SACLS_DDD,part.sacl.examined, part.sacl.changed, part.sacl.examined - part.sacl.changed);
  320. err.MsgWrite(0,DCT_MSG_SUMMARY_PARTS_REPORT_HEADER);
  321. err.MsgWrite(0,DCT_MSG_SUMMARY_PARTS_REPORT_OWNERS_DDDDD,part.owner.examined, part.owner.changed, part.owner.notarget, part.owner.examined - part.owner.changed - part.owner.notarget - part.owner.unknown, part.owner.unknown);
  322. err.MsgWrite(0,DCT_MSG_SUMMARY_PARTS_REPORT_GROUPS_DDDDD,part.group.examined, part.group.changed, part.group.notarget, part.group.examined - part.group.changed - part.group.notarget - part.group.unknown ,part.group.unknown);
  323. err.MsgWrite(0,DCT_MSG_SUMMARY_PARTS_REPORT_DACES_DDDDD,part.dace.examined, part.dace.changed, part.dace.notarget,part.dace.notselected,part.dace.unknown);
  324. err.MsgWrite(0,DCT_MSG_SUMMARY_PARTS_REPORT_SACES_DDDDD,part.sace.examined, part.sace.changed, part.sace.notarget,part.sace.notselected,part.sace.unknown);
  325. }
  326. }
  327. #define HDR1ITEMS 2
  328. #define HDRCOL1 8
  329. #define HDRROW1 4
  330. #define COLWIDTH 12
  331. #define HDRCOL2 ( HDRCOL1 + COLWIDTH )
  332. #define HDRROW2 ( HDRROW1 + ( 2 * HDR1ITEMS + 1) + 1)
  333. void
  334. TSDResolveStats::InitDisplay(
  335. BOOL nochange
  336. )
  337. {
  338. }
  339. // no longer used
  340. void
  341. TSDResolveStats::DisplayStatFrame(
  342. BOOL nochange
  343. )
  344. {
  345. }
  346. // no longer used
  347. void TSDResolveStats::DisplayStatItem(SHORT row, SHORT col, DWORD val, BOOL forceUpdate)
  348. {
  349. }
  350. DWORD dwLastUpdate = 0;
  351. void
  352. TSDResolveStats::DisplayPath(LPWSTR str,BOOL forceUpdate)
  353. {
  354. DWORD now = GetTickCount();
  355. if ( m_pVarSet )
  356. {
  357. m_pVarSet->put(GET_BSTR(DCTVS_CurrentPath),str);
  358. if ( now - dwLastUpdate > 1000 )
  359. {
  360. ReportToVarSet(m_pVarSet,SUMMARYSTATS);
  361. dwLastUpdate = GetTickCount();
  362. }
  363. }
  364. }
  365. void
  366. TSDResolveStats::DisplayBox(SHORT x1, SHORT y1, SHORT x2, SHORT y2)
  367. {
  368. }
  369. void
  370. TSDResolveStats::SetFrameText(WCHAR * msg)
  371. {
  372. }