public static void CheckAntiVirusExclusion(ITracer tracer, string path, out bool isExcluded, out string errorMessage) { errorMessage = string.Empty; if (AntiVirusExclusions.TryGetIsPathExcluded(path, out isExcluded, out errorMessage)) { if (!isExcluded) { if (AntiVirusExclusions.AddAntiVirusExclusion(path, out errorMessage)) { if (!AntiVirusExclusions.TryGetIsPathExcluded(path, out isExcluded, out errorMessage)) { errorMessage = string.Format("Unable to determine if this repo is excluded from antivirus after adding exclusion: {0}", errorMessage); tracer.RelatedWarning(errorMessage); } } else { errorMessage = string.Format("Could not add this repo to the antivirus exclusion list: {0}", errorMessage); tracer.RelatedWarning(errorMessage); } } } else { errorMessage = string.Format("Unable to determine if this repo is excluded from antivirus: {0}", errorMessage); tracer.RelatedWarning(errorMessage); } }
protected void CheckAntiVirusExclusion(GVFSEnlistment enlistment) { bool isExcluded; if (AntiVirusExclusions.TryGetIsPathExcluded(enlistment.EnlistmentRoot, out isExcluded)) { if (!isExcluded) { if (ProcessHelper.IsAdminElevated()) { this.Output.WriteLine(); this.Output.WriteLine("Adding {0} to your antivirus exclusion list", enlistment.EnlistmentRoot); this.Output.WriteLine(); AntiVirusExclusions.AddAntiVirusExclusion(enlistment.EnlistmentRoot); if (!AntiVirusExclusions.TryGetIsPathExcluded(enlistment.EnlistmentRoot, out isExcluded) || !isExcluded) { this.ReportErrorAndExit( "This repo is not excluded from antivirus and we were unable to add it. Add '{0}' to your exclusion list and then run {1} again.", enlistment.EnlistmentRoot, this.VerbName); } } else { this.ReportErrorAndExit( "This repo is not excluded from antivirus. Either re-run {1} with elevated privileges, or add '{0}' to your exclusion list and then run {1} again.", enlistment.EnlistmentRoot, this.VerbName); } } } else { this.Output.WriteLine(); this.Output.WriteLine( "WARNING: Unable to determine if this repo is excluded from antivirus. Please check to ensure that '{0}' is excluded.", enlistment.EnlistmentRoot); this.Output.WriteLine(); } }
protected void CheckAntiVirusExclusion(GVFSEnlistment enlistment) { bool isExcluded; string getError; if (AntiVirusExclusions.TryGetIsPathExcluded(enlistment.EnlistmentRoot, out isExcluded, out getError)) { if (!isExcluded) { string addError; if (!ProcessHelper.IsAdminElevated()) { addError = "Need elevated privileges to add exclusion."; } else if (AntiVirusExclusions.AddAntiVirusExclusion(enlistment.EnlistmentRoot, out addError)) { addError = string.Empty; AntiVirusExclusions.TryGetIsPathExcluded(enlistment.EnlistmentRoot, out isExcluded, out getError); } if (!isExcluded) { this.Output.WriteLine(); this.Output.WriteLine("WARNING: This repo is not excluded from antivirus and we were unable to add an exclusion for it."); if (!string.IsNullOrEmpty(addError)) { this.Output.WriteLine("Unable to add exclusion: " + addError); } this.Output.WriteLine("Please check to make sure that '{0}' is excluded.", enlistment.EnlistmentRoot); this.Output.WriteLine(); } } } else { this.Output.WriteLine(); this.Output.WriteLine("WARNING: Unable to ensure that this repo is excluded from antivirus."); this.Output.WriteLine("Please check to make sure that '{0}' is excluded.", enlistment.EnlistmentRoot); this.Output.WriteLine(); } }
private void CheckAntiVirusExclusion(ITracer tracer, string path) { string errorMessage; bool isExcluded; if (AntiVirusExclusions.TryGetIsPathExcluded(path, out isExcluded, out errorMessage)) { if (!isExcluded) { if (!AntiVirusExclusions.AddAntiVirusExclusion(path, out errorMessage)) { tracer.RelatedError("Could not add this repo to the antivirus exclusion list. Error: {0}", errorMessage); } } } else { tracer.RelatedError("Unable to determine if this repo is excluded from antivirus. Error: {0}", errorMessage); } }
private void CheckAntiVirusExclusion(ITracer tracer, string path) { bool isExcluded; string getError; if (AntiVirusExclusions.TryGetIsPathExcluded(path, out isExcluded, out getError)) { if (!isExcluded) { if (ProcessHelper.IsAdminElevated()) { string addError; if (AntiVirusExclusions.AddAntiVirusExclusion(path, out addError)) { addError = string.Empty; if (!AntiVirusExclusions.TryGetIsPathExcluded(path, out isExcluded, out getError)) { EventMetadata metadata = new EventMetadata(); metadata.Add("getError", getError); metadata.Add("path", path); tracer.RelatedWarning(metadata, "CheckAntiVirusExclusion: Failed to determine if path excluded after adding it"); } } else { EventMetadata metadata = new EventMetadata(); metadata.Add("addError", addError); metadata.Add("path", path); tracer.RelatedWarning(metadata, "CheckAntiVirusExclusion: AddAntiVirusExclusion failed"); } } else { EventMetadata metadata = new EventMetadata(); metadata.Add("path", path); metadata.Add(TracingConstants.MessageKey.InfoMessage, "CheckAntiVirusExclusion: Skipping call to AddAntiVirusExclusion, GVFS is not running with elevation"); tracer.RelatedEvent(EventLevel.Informational, "CheckAntiVirusExclusion_SkipLocalAdd", metadata); } } } else { EventMetadata metadata = new EventMetadata(); metadata.Add("getError", getError); metadata.Add("path", path); tracer.RelatedWarning(metadata, "CheckAntiVirusExclusion: Failed to determine if path excluded"); } string errorMessage = null; if (!isExcluded && !this.Unattended) { if (this.ShowStatusWhileRunning( () => { return(this.ExcludeFromAntiVirusThroughService(path, out errorMessage)); }, string.Format("Excluding '{0}' from antivirus", path))) { isExcluded = true; } else { EventMetadata metadata = new EventMetadata(); metadata.Add("errorMessage", errorMessage); metadata.Add("path", path); tracer.RelatedWarning(metadata, "CheckAntiVirusExclusion: Failed to exclude path through service"); } } if (!isExcluded) { this.Output.WriteLine(); this.Output.WriteLine("WARNING: Unable to ensure that '{0}' is excluded from antivirus", path); if (!string.IsNullOrEmpty(errorMessage)) { this.Output.WriteLine(errorMessage); } this.Output.WriteLine(); } }