Exemplo n.º 1
0
        private void RunBitlockerMaintenance(IMonitoringADConfig adConfig)
        {
            if (!adConfig.Dag.AutoDagBitlockerEnabled)
            {
                DiskReclaimerManager.Tracer.TraceDebug <string>((long)this.GetHashCode(), "DiskReclaimer: Skipping running RunBitlockerMaintenance because the local DAG '{0}' has AutoDagBitlockerEnabled set to disabled.", adConfig.Dag.Name);
                return;
            }
            Exception ex;
            bool      flag = BitlockerUtil.IsVolumeMountedOnVirtualDisk(string.Empty, out ex);

            if (ex != null)
            {
                DiskReclaimerManager.Tracer.TraceDebug <Exception>((long)this.GetHashCode(), "RunBitlockerMaintenance(): Exception finding whether Volumes are mounted on virtual disks or not. Reason {0}", ex);
                return;
            }
            if (flag)
            {
                DiskReclaimerManager.Tracer.TraceDebug((long)this.GetHashCode(), "RunBitlockerMaintenance(): Volumes are mounted on virtual disks. Virtul Disk Volumes cannot be encrypted.");
                return;
            }
            if (!BitlockerConfigHelper.IsBitlockerManagerEnabled())
            {
                DiskReclaimerManager.Tracer.TraceDebug <AmServerName>((long)this.GetHashCode(), "DiskReclaimer: Skipping running RunBitlockerMaintenance because the local Machine '{0}' has BitlockerManagerEnabled set to disabled.", adConfig.TargetServerName);
                ReplayCrimsonEvents.BitlockerFeatureDisabled.Log();
                return;
            }
            if (Util.IsOperatingSystemWin8OrHigher())
            {
                this.RunBitlockerMaintenanceforWin8EmptyVolumes(adConfig.Dag.AutoDagFIPSCompliant);
                return;
            }
            this.RunBitlockerMaintenanceforWin7EmptyVolumes(adConfig.Dag.AutoDagFIPSCompliant);
        }
Exemplo n.º 2
0
        public static void EncryptEmptyWin7Volumes(VolumeManager volumeManager, bool fipsCompliant)
        {
            if (Util.IsOperatingSystemWin8OrHigher())
            {
                ReplayCrimsonEvents.Win7EncryptionMethodCalledByWin8.Log();
                return;
            }
            List <ExchangeVolume>[] array = volumeManager.DetermineVolumeSpareStatuses();
            List <ExchangeVolume>   list  = array[1];

            if (list == null || list.Count == 0)
            {
                ReplayCrimsonEvents.NoEmptySpaceVolumesFoundToEncrypt.Log();
                return;
            }
            Exception     ex;
            List <string> encryptionPausedVolumes = BitlockerUtil.GetEncryptionPausedVolumes(out ex);

            if (ex != null || (encryptionPausedVolumes != null && encryptionPausedVolumes.Count > 0))
            {
                return;
            }
            List <string> encryptingVolumes = BitlockerUtil.GetEncryptingVolumes(out ex);

            if (ex != null || (encryptingVolumes != null && encryptingVolumes.Count > 0))
            {
                return;
            }
            ReplayCrimsonEvents.CandidatesForEncryption.Log <int>(list.Count);
            int num  = 0;
            int num2 = 0;

            foreach (ExchangeVolume exchangeVolume in list)
            {
                string           path = exchangeVolume.VolumeName.Path;
                Exception        ex2;
                ManagementObject encryptableVolume = BitlockerUtil.GetEncryptableVolume(path, out ex2);
                if (encryptableVolume == null)
                {
                    ReplayCrimsonEvents.BitlockerEncryptableVolumeGetFailed.Log <string, string>(path, ex2.Message);
                }
                else
                {
                    int num3;
                    ex = BitlockerUtil.ValidateAndEncryptEmptyWin7Volume(encryptableVolume, fipsCompliant, out num3);
                    if (ex == null)
                    {
                        ReplayCrimsonEvents.BitlockerFullVolumeEncryptionStartSucceeded.Log <string, string>(exchangeVolume.VolumeName.Path, exchangeVolume.ExchangeVolumeMountPoint.Path);
                        num++;
                        break;
                    }
                    ReplayCrimsonEvents.BitlockerFullVolumeEncryptionStartFailed.Log <string, string, string, int, string>(exchangeVolume.VolumeName.Path, exchangeVolume.ExchangeVolumeMountPoint.Path, ex.Message, num3, Util.WindowsErrorMessageLookup(num3));
                    num2++;
                }
            }
            ReplayCrimsonEvents.BitlockerFullVolumeEncryptionStartReport.Log <int, int>(num, num2);
        }
Exemplo n.º 3
0
        public static void LogEncryptionPercentagesForEncryptingVolumes()
        {
            List <string> list = new List <string>();
            Exception     ex;
            List <string> encryptionPausedVolumes = BitlockerUtil.GetEncryptionPausedVolumes(out ex);

            if (ex == null && encryptionPausedVolumes != null && encryptionPausedVolumes.Count > 0)
            {
                list.AddRange(encryptionPausedVolumes);
            }
            if (encryptionPausedVolumes != null)
            {
                foreach (string text in encryptionPausedVolumes)
                {
                    if (BitlockerUtil.GetEncryptableVolume(text, out ex) == null)
                    {
                        ReplayCrimsonEvents.BitlockerEncryptableVolumeGetFailed.Log <string, string>(text, ex.Message);
                    }
                    else
                    {
                        string text2;
                        string text3;
                        bool   flag = BitlockerUtil.IsEncryptionPausedDueToBadBlocks(text, out ex, out text2, out text3);
                        if (flag)
                        {
                            ReplayCrimsonEvents.EncryptionPausedDueToBadBlocks.Log <string, string, string, string>(text, ex.Message, text2, text3);
                        }
                    }
                }
            }
            List <string> encryptingVolumes = BitlockerUtil.GetEncryptingVolumes(out ex);

            if (ex == null && encryptingVolumes != null && encryptingVolumes.Count > 0)
            {
                list.AddRange(encryptingVolumes);
            }
            foreach (string text4 in list)
            {
                ManagementObject encryptableVolume = BitlockerUtil.GetEncryptableVolume(text4, out ex);
                if (encryptableVolume == null)
                {
                    ReplayCrimsonEvents.BitlockerEncryptableVolumeGetFailed.Log <string, string>(text4, ex.Message);
                }
                else
                {
                    int num;
                    int bitlockerEncryptionPercentage = BitlockerUtil.GetBitlockerEncryptionPercentage(encryptableVolume, out num, out ex);
                    if (ex == null)
                    {
                        ReplayCrimsonEvents.BitlockerEncryptionPercentage.Log <string, int>(text4, bitlockerEncryptionPercentage);
                    }
                }
            }
        }
Exemplo n.º 4
0
        // Token: 0x06000A1A RID: 2586 RVA: 0x0002EFBC File Offset: 0x0002D1BC
        public static bool IsPathOnLockedVolume(string directory)
        {
            Exception ex = null;

            if (BitlockerUtil.IsFilePathOnLockedVolume(directory, out ex))
            {
                return(true);
            }
            if (ex != null)
            {
                string text = string.Format("IsPathOnLockedVolume({0}) failed: {1}", directory, ex.Message);
                ReplayCrimsonEvents.BitlockerQueryFailed.LogPeriodic <string, Exception>(Environment.MachineName, DiagCore.DefaultEventSuppressionInterval, text, ex);
            }
            return(false);
        }
Exemplo n.º 5
0
        // Token: 0x060015A9 RID: 5545 RVA: 0x0005610C File Offset: 0x0005430C
        public VolumeSpareStatus GetSpareStatus(out Exception exception)
        {
            exception = null;
            ExchangeVolume.Tracer.TraceDebug <MountedFolderPath>((long)this.GetHashCode(), "ExchangeVolume.GetSpareStatus(): Computing status of volume '{0}'.", this.VolumeName);
            if (!this.IsValid)
            {
                ExchangeVolume.Tracer.TraceError <DatabaseVolumeInfoException>((long)this.GetHashCode(), "ExchangeVolume.GetSpareStatus(): Returning Error because the ExchangeVolume instance is invalid. Error: {0}", this.LastException);
                exception = this.LastException;
                return(VolumeSpareStatus.Error);
            }
            if (!this.IsExchangeVolume || !this.IsAvailableAsSpare || this.DatabaseMountPoints.Length != 0)
            {
                ExchangeVolume.Tracer.TraceDebug <MountedFolderPath>((long)this.GetHashCode(), "ExchangeVolume.GetSpareStatus(): Returning Volume '{0}' is NotUsableAsSpare.", this.VolumeName);
                return(VolumeSpareStatus.NotUsableAsSpare);
            }
            ExchangeVolume.Tracer.TraceDebug((long)this.GetHashCode(), "ExchangeVolume.GetSpareStatus(): Found a potential spare volume...");
            MountedFolderPath exchangeVolumeMountPoint = this.ExchangeVolumeMountPoint;

            if (MountPointUtil.IsDirectoryNonExistentOrEmpty(exchangeVolumeMountPoint.Path, out exception))
            {
                ExchangeVolume.Tracer.TraceDebug <MountedFolderPath>((long)this.GetHashCode(), "ExchangeVolume.GetSpareStatus(): Returning Volume '{0}' is EmptySpare.", this.VolumeName);
                bool flag = BitlockerUtil.IsVolumeMountedOnVirtualDisk(this.VolumeName.Path, out exception);
                if (exception != null)
                {
                    ExchangeVolume.Tracer.TraceDebug <MountedFolderPath, Exception>((long)this.GetHashCode(), "ExchangeVolume.GetSpareStatus(): Exception finding whether Volume '{0}' is mounted on a virtual disk or not. Reason {1}", this.VolumeName, exception);
                }
                if (!flag)
                {
                    bool flag2 = false;
                    bool flag3 = false;
                    exception = BitlockerUtil.IsVolumeEncryptedOrEncrypting(this.VolumeName.Path, out flag2, out flag3);
                    if (exception != null)
                    {
                        ExchangeVolume.Tracer.TraceDebug <MountedFolderPath, Exception>((long)this.GetHashCode(), "ExchangeVolume.GetSpareStatus(): Exception finding whether Volume '{0}' is encrypting or not. Reason {1}", this.VolumeName, exception);
                    }
                    else
                    {
                        if (flag2)
                        {
                            return(VolumeSpareStatus.EncryptingEmptySpare);
                        }
                        if (flag3)
                        {
                            return(VolumeSpareStatus.EncryptedEmptySpare);
                        }
                        string arg;
                        string arg2;
                        bool   flag4 = BitlockerUtil.IsEncryptionPausedDueToBadBlocks(this.VolumeName.Path, out exception, out arg, out arg2);
                        if (exception != null)
                        {
                            ExchangeVolume.Tracer.TraceDebug <MountedFolderPath, Exception>((long)this.GetHashCode(), "ExchangeVolume.GetSpareStatus(): Exception finding whether Volume '{0}' has encryption paused due to bad blocks. Reason {1}", this.VolumeName, exception);
                            return(VolumeSpareStatus.Error);
                        }
                        if (flag4)
                        {
                            ExchangeVolume.Tracer.TraceDebug <MountedFolderPath, string, string>((long)this.GetHashCode(), "ExchangeVolume.GetSpareStatus(): Returning Volume '{0}' is Qurantined due to encryption paused due to bad blocks. Mount point {1}. Event Xml {2}", this.VolumeName, arg, arg2);
                            return(VolumeSpareStatus.Quarantined);
                        }
                    }
                }
                else
                {
                    ExchangeVolume.Tracer.TraceDebug <MountedFolderPath>((long)this.GetHashCode(), "ExchangeVolume.GetSpareStatus(): Volume mounted on virtual disk. Not attempting to find bitlocker spare status", this.VolumeName);
                }
                return(VolumeSpareStatus.UnEncryptedEmptySpare);
            }
            int num = 0;

            if (exception == null || FileOperations.IsCorruptedIOException((IOException)exception, out num))
            {
                ExchangeVolume.Tracer.TraceDebug <MountedFolderPath, string>((long)this.GetHashCode(), "ExchangeVolume.GetSpareStatus(): Returning Volume '{0}' is Quarantined because it has some files/directories under mountPath '{1}'.", this.VolumeName, exchangeVolumeMountPoint.Path);
                return(VolumeSpareStatus.Quarantined);
            }
            ExchangeVolume.Tracer.TraceError <string, Exception>((long)this.GetHashCode(), "ExchangeVolume.GetSpareStatus(): Returning Error because IsDirectoryNonExistentOrEmpty() returned exception for mountPath '{0}'. Exception: {1}", exchangeVolumeMountPoint.Path, exception);
            return(VolumeSpareStatus.Error);
        }
Exemplo n.º 6
0
        internal NotificationAction NotifyLowDiskSpace(IADDatabase db, IMonitoringADConfig adConfig)
        {
            DatabaseRedundancyValidator databaseRedundancyValidator = new DatabaseRedundancyValidator(db, 1, this.m_statusLookup, adConfig, null, true);
            IHealthValidationResult     healthValidationResult      = databaseRedundancyValidator.Run();
            CopyStatusClientCachedEntry targetCopyStatus            = healthValidationResult.TargetCopyStatus;

            if (targetCopyStatus == null || targetCopyStatus.CopyStatus == null || targetCopyStatus.Result != CopyStatusRpcResult.Success || targetCopyStatus.CopyStatus.DiskTotalSpaceBytes == 0UL)
            {
                return(NotificationAction.None);
            }
            double num   = (double)RegistryParameters.SpaceMonitorLowSpaceThresholdInMB / 1024.0;
            double num2  = targetCopyStatus.CopyStatus.DiskFreeSpaceBytes / 1024.0 / 1024.0 / 1024.0;
            double num3  = 0.0;
            double num4  = 0.0;
            string text  = SpaceMonitor.FindVolume(new DirectoryInfo(db.EdbFilePath.PathName));
            string text2 = SpaceMonitor.FindVolume(new DirectoryInfo(db.LogFolderPath.PathName));

            if (!string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(text2) && !text.Equals(text2, StringComparison.OrdinalIgnoreCase) && db.EdbFilePath.IsLocalFull)
            {
                ulong num5 = 0UL;
                ulong num6 = 0UL;
                DiskHelper.GetFreeSpace(db.EdbFilePath.PathName, out num5, out num6);
                num3 = num5 / 1024UL / 1024UL / 1024UL;
                num4 = num6 / 1024UL / 1024UL / 1024UL;
            }
            bool   flag  = false;
            string text3 = string.Empty;

            if (num2 <= num)
            {
                text3 = string.Format("'{0}' is low on log volume space [{1}]. Current={2:0.##} GB, Threshold={3:0.##} GB", new object[]
                {
                    db.Name,
                    text2,
                    num2,
                    num
                });
                flag = true;
            }
            if (num3 != 0.0 && num4 <= num)
            {
                text3 += string.Format("{0}'{1}' is low on EDB volume space [{2}]. Current={3:0.##} GB, Threshold={4:0.##} GB", new object[]
                {
                    Environment.NewLine,
                    db.Name,
                    text,
                    num4,
                    num
                });
                flag = true;
            }
            if (flag)
            {
                if (SpaceMonitor.LastNotificationHistory.ContainsKey(db.Name) && DateTime.UtcNow - SpaceMonitor.LastNotificationHistory[db.Name] < SpaceMonitor.NotificationFrequency)
                {
                    SpaceMonitor.Tracer.TraceDebug((long)this.GetHashCode(), "SpaceMonitor.ProcessDatabase: Database '{0}' is low on space but notification throttling is hit. LastNotify={1}, Throttling={2}mins, Message={3}", new object[]
                    {
                        db.Name,
                        SpaceMonitor.LastNotificationHistory.ContainsKey(db.Name) ? "Never" : SpaceMonitor.LastNotificationHistory[db.Name].ToString(),
                        SpaceMonitor.NotificationFrequency.TotalMinutes,
                        text3
                    });
                    return(NotificationAction.None);
                }
                Exception ex;
                if (BitlockerUtil.IsFilePathOnEncryptingVolume(db.LogFolderPath.PathName, out ex))
                {
                    SpaceMonitor.Tracer.TraceDebug <string>((long)this.GetHashCode(), "SpaceMonitor.ProcessDatabase: Database '{0}' is currently encrypting. Do not raise alert.", db.Name);
                    return(NotificationAction.None);
                }
                if (ex != null)
                {
                    string text4 = string.Format("IsFilePathOnEncryptingVolume({0}) failed: {1}", db.LogFolderPath.PathName, ex.Message);
                    ReplayCrimsonEvents.BitlockerQueryFailed.LogPeriodic <string, Exception>(Environment.MachineName, DiagCore.DefaultEventSuppressionInterval, text4, ex);
                }
                EventNotificationItem eventNotificationItem = new EventNotificationItem("MSExchangeDagMgmt", "EdbAndLogVolSpace", db.Name.ToUpper(), text3, text3, ResultSeverityLevel.Critical);
                eventNotificationItem.Publish(false);
                if (SpaceMonitor.LastNotificationHistory.ContainsKey(db.Name))
                {
                    SpaceMonitor.LastNotificationHistory[db.Name] = DateTime.UtcNow;
                }
                else
                {
                    SpaceMonitor.LastNotificationHistory.Add(db.Name, DateTime.UtcNow);
                }
                return(NotificationAction.RedRaised);
            }
            else
            {
                text3 = string.Format("{0} Status is OK - EdbFreeSpace={1:0.##} GB [{2}], LogFreeSpace={3:0.##} GB [{4}], Threshold={5:0.##} GB", new object[]
                {
                    db.Name,
                    num4,
                    text,
                    num2,
                    text2,
                    num
                });
                if (SpaceMonitor.LastNotificationHistory.ContainsKey(db.Name) && SpaceMonitor.LastNotificationHistory[db.Name] != DateTime.MinValue)
                {
                    EventNotificationItem eventNotificationItem2 = new EventNotificationItem("MSExchangeDagMgmt", "EdbAndLogVolSpace", db.Name.ToUpper(), text3, text3, ResultSeverityLevel.Informational);
                    eventNotificationItem2.Publish(false);
                    SpaceMonitor.LastNotificationHistory[db.Name] = DateTime.MinValue;
                    return(NotificationAction.GreenRaised);
                }
                SpaceMonitor.Tracer.TraceDebug((long)this.GetHashCode(), "SpaceMonitor.ProcessDatabase: Database '{0}' has enough space but red notification was never raised. LastNotify={1}, Throttling={2}mins, Message={3}", new object[]
                {
                    db.Name,
                    SpaceMonitor.LastNotificationHistory.ContainsKey(db.Name) ? SpaceMonitor.LastNotificationHistory[db.Name].ToString() : "Never",
                    SpaceMonitor.NotificationFrequency.TotalMinutes,
                    text3
                });
                return(NotificationAction.None);
            }
        }