private bool TryPrepareSandboxedProcess(SandboxedProcessInfo info) { Contract.Requires(info != null); if (!string.IsNullOrEmpty(info.DetoursFailureFile) && FileUtilities.FileExistsNoFollow(info.DetoursFailureFile)) { Analysis.IgnoreResult(FileUtilities.TryDeleteFile(info.DetoursFailureFile)); } if (!string.IsNullOrEmpty(info.FileAccessManifest.InternalDetoursErrorNotificationFile) && FileUtilities.FileExistsNoFollow(info.FileAccessManifest.InternalDetoursErrorNotificationFile)) { Analysis.IgnoreResult(FileUtilities.TryDeleteFile(info.FileAccessManifest.InternalDetoursErrorNotificationFile)); } if (info.GetCommandLine().Length > SandboxedProcessInfo.MaxCommandLineLength) { m_logger.LogError($"Process command line is longer than {SandboxedProcessInfo.MaxCommandLineLength} characters: {info.GetCommandLine()}"); return(false); } m_outputErrorObserver = OutputErrorObserver.Create(m_logger, info); info.StandardOutputObserver = m_outputErrorObserver.ObserveStandardOutputForWarning; info.StandardErrorObserver = m_outputErrorObserver.ObserveStandardErrorForWarning; if (!TryPrepareWorkingDirectory(info) || !TryPrepareTemporaryFolders(info)) { return(false); } SetSandboxConnectionIfNeeded(info); return(true); }
private bool TryPrepareSandboxedProcess(SandboxedProcessInfo info) { Contract.Requires(info != null); FileAccessManifest fam = info.FileAccessManifest; if (!string.IsNullOrEmpty(fam.InternalDetoursErrorNotificationFile)) { Analysis.IgnoreResult(FileUtilities.TryDeleteFile(fam.InternalDetoursErrorNotificationFile)); } if (fam.CheckDetoursMessageCount && !OperatingSystemHelper.IsUnixOS) { string semaphoreName = fam.InternalDetoursErrorNotificationFile.Replace('\\', '_'); if (!fam.SetMessageCountSemaphore(semaphoreName)) { m_logger.LogError($"Semaphore '{semaphoreName}' for counting Detours messages is already opened"); return(false); } } if (info.GetCommandLine().Length > SandboxedProcessInfo.MaxCommandLineLength) { m_logger.LogError($"Process command line is longer than {SandboxedProcessInfo.MaxCommandLineLength} characters: {info.GetCommandLine().Length}"); return(false); } m_outputErrorObserver = OutputErrorObserver.Create(m_logger, info); info.StandardOutputObserver = m_outputErrorObserver.ObserveStandardOutputForWarning; info.StandardErrorObserver = m_outputErrorObserver.ObserveStandardErrorForWarning; return(true); }