private static void DoNtfsSecurityComparison(int partition, NtfsFileSystem leftFileSystem, DiscFileInfo left, NtfsFileSystem rightFileSystem, DiscFileInfo right) { var leftEntry = leftFileSystem.GetDirectoryEntry(left.FullName); var leftRef = leftFileSystem.GetFile(leftEntry.Reference); var rightEntry = rightFileSystem.GetDirectoryEntry(right.FullName); var rightRef = rightFileSystem.GetFile(rightEntry.Reference); Info("Partition{0}:{1}: Comparing NTFS meta data", partition, left.FullName); // Disable these checks there are problems with the short names DiscUtils assigns /* // hard links * DoingCheck(); * var leftRefHardLinkCount = leftRef.HardLinkCount; * if (leftRef.HasWin32OrDosName) * leftRefHardLinkCount--; // remove the legacy short name * * var rightRefHardLinkCount = rightRef.HardLinkCount; * if (rightRef.HasWin32OrDosName) * rightRefHardLinkCount--; // remove the legacy short name * * if (leftRefHardLinkCount != rightRefHardLinkCount) * { * Error("Partition{0}:{1}: Non-matching hard link count" + * "(Left: {2}, Right: {3})", * partition, left.FullName, leftRefHardLinkCount, rightRefHardLinkCount); * } * * // file names * DoingCheck(); * var leftRefNamesCount = leftRef.Names.Count; * if (leftRef.HasWin32OrDosName) * leftRefNamesCount--; // remove the legacy short name * * var rightRefNamesCount = rightRef.Names.Count; * if (rightRef.HasWin32OrDosName) * rightRefNamesCount--; // remove the legacy short name * * if (leftRefNamesCount != rightRefNamesCount) * { * Error("Partition{0}:{1}: Non-matching file names count" + * "(Left: {2}, Right: {3})", * partition, left.FullName, leftRefNamesCount, rightRefNamesCount); * } */ // security var leftSecurity = leftFileSystem.GetSecurity(left.FullName); var rightSecurity = rightFileSystem.GetSecurity(right.FullName); DoingCheck(); if (leftSecurity.BinaryLength != rightSecurity.BinaryLength) { Error("Partition{0}:{1}: Non-matching security binary length" + "(Left: 0x{2:X}, Right: 0x{3:X})", partition, left.FullName, leftSecurity.BinaryLength, rightSecurity.BinaryLength); } DoingCheck(); if (leftSecurity.ControlFlags != rightSecurity.ControlFlags) { Error("Partition{0}:{1}: Non-matching security control flags" + "(Left: 0x{2:X}, Right: 0x{3:X})", partition, left.FullName, leftSecurity.ControlFlags, rightSecurity.ControlFlags); } DoingCheck(); if (leftSecurity.Group != null && rightSecurity.Group != null) { if (leftSecurity.Group.Value != rightSecurity.Group.Value) { Error("Partition{0}:{1}: Non-matching security group name" + "(Left: {2}, Right: {3})", partition, left.FullName, leftSecurity.Group.Value, rightSecurity.Group.Value); } } else if ((leftSecurity.Group == null && rightSecurity.Group != null) || (leftSecurity.Group != null && rightSecurity.Owner == null)) { Warning("Partition{0}:{1}: No valid NTFS security group found", partition, left.FullName); } DoingCheck(); if (leftSecurity.Owner != null && rightSecurity.Owner != null) { if (leftSecurity.Owner.Value != rightSecurity.Owner.Value) { Error("Partition{0}:{1}: Non-matching security owner name" + "(Left: {2}, Right: {3})", partition, left.FullName, leftSecurity.Group.Value, rightSecurity.Group.Value); } } else if ((leftSecurity.Owner == null && rightSecurity.Owner != null) || (leftSecurity.Owner != null && rightSecurity.Owner == null)) { Warning("Partition{0}:{1}: No valid NTFS security owner found", partition, left.FullName); } DoingCheck(); if (leftSecurity.DiscretionaryAcl != null && rightSecurity.DiscretionaryAcl != null) { if (leftSecurity.DiscretionaryAcl.Count != rightSecurity.DiscretionaryAcl.Count) { Error("Partition{0}:{1}: Non-matching count of Discretionary ACL entries" + "(Left: {2}, Right: {3})", partition, left.FullName, leftSecurity.DiscretionaryAcl.Count, rightSecurity.DiscretionaryAcl.Count); } } else if ((leftSecurity.DiscretionaryAcl == null && rightSecurity.DiscretionaryAcl != null) || (leftSecurity.DiscretionaryAcl != null && rightSecurity.DiscretionaryAcl == null)) { Warning("Partition{0}:{1}: No valid NTFS security Discretionary ACL found", partition, left.FullName); } DoingCheck(); if (leftSecurity.SystemAcl != null && rightSecurity.SystemAcl != null) { if (leftSecurity.SystemAcl.Count != rightSecurity.SystemAcl.Count) { Error("Partition{0}:{1}: Non-matching count of System ACL entries" + "(Left: {2}, Right: {3})", partition, left.FullName, leftSecurity.DiscretionaryAcl.Count, rightSecurity.DiscretionaryAcl.Count); } } else if ((leftSecurity.SystemAcl == null && rightSecurity.SystemAcl != null) || (leftSecurity.SystemAcl != null && rightSecurity.SystemAcl == null)) { Warning("Partition{0}:{1}: No valid NTFS security System ACL found", partition, left.FullName); } }