public ConsoleUiMediator() { FileSystemView = new FileSystemView(); MainView = new MainView(); CurrentView = MainView; ClientLock = new ReaderWriterLock(); RevShellLock = new ReaderWriterLock(); }
// // GET: /Admin/FileView/ public ActionResult Index() { FileSystemView model = new FileSystemView() { TempltesImageFiles = GetImageList() }; return(View(model)); }
public ConsoleUiMediator(AppUiDoubleQueueThreadChannel channel) { FileSystemView = new FileSystemView(); MainView = new MainView(); CurrentView = MainView; ClientLock = new ReaderWriterLock(); AppUiChannel = channel; ShellView = new ShellView(); }
public PipQueueTestExecutionEnvironment(BuildXLContext context, IConfiguration configuration, PipTable pipTable, string tempDirectory, ISandboxConnection SandboxConnection = null) { Contract.Requires(context != null); Contract.Requires(configuration != null); Context = context; LoggingContext = CreateLoggingContextForTest(); Configuration = configuration; FileContentTable = FileContentTable.CreateNew(); ContentFingerprinter = new PipContentFingerprinter( context.PathTable, artifact => State.FileContentManager.GetInputContent(artifact).FileContentInfo, ExtraFingerprintSalts.Default(), pathExpander: PathExpander); PipTable = pipTable; PipFragmentRenderer = this.CreatePipFragmentRenderer(); IpcProvider = IpcFactory.GetProvider(); var tracker = FileChangeTracker.CreateDisabledTracker(LoggingContext); Cache = InMemoryCacheFactory.Create(); LocalDiskContentStore = new LocalDiskContentStore(LoggingContext, context.PathTable, FileContentTable, tracker); m_sandboxConnectionKext = SandboxConnection; m_expectedWrittenContent = new ConcurrentDictionary <FileArtifact, ContentHash>(); m_wellKnownFiles = new ConcurrentDictionary <FileArtifact, ContentHash>(); m_producers = new ConcurrentDictionary <FileArtifact, Pip>(); m_filesystemView = new TestPipGraphFilesystemView(Context.PathTable); var fileSystemView = new FileSystemView(Context.PathTable, m_filesystemView, LocalDiskContentStore); TempCleaner = new TestMoveDeleteCleaner(tempDirectory); State = new PipExecutionState( configuration, cache: new PipTwoPhaseCache(LoggingContext, Cache, context, PathExpander), unsafeConfiguration: configuration.Sandbox.UnsafeSandboxConfiguration, preserveOutputsSalt: ContentHashingUtilities.CreateRandom(), fileAccessWhitelist: FileAccessWhitelist, directoryMembershipFingerprinter: this, pathExpander: PathExpander, executionLog: null, fileSystemView: fileSystemView, fileContentManager: new FileContentManager(this, new NullOperationTracker()), directoryMembershipFinterprinterRuleSet: null); m_sealContentsById = new ConcurrentBigMap <DirectoryArtifact, int[]>(); ProcessInContainerManager = new ProcessInContainerManager(LoggingContext, context.PathTable); }
/// <summary> /// Class constructor /// </summary> public PipExecutionState( IConfiguration configuration, LoggingContext loggingContext, PipTwoPhaseCache cache, FileAccessWhitelist fileAccessWhitelist, IDirectoryMembershipFingerprinter directoryMembershipFingerprinter, SemanticPathExpander pathExpander, IExecutionLogTarget executionLog, DirectoryMembershipFingerprinterRuleSet directoryMembershipFinterprinterRuleSet, FileContentManager fileContentManager, IUnsafeSandboxConfiguration unsafeConfiguration, PreserveOutputsInfo preserveOutputsSalt, FileSystemView fileSystemView, bool lazyDeletionOfSharedOpaqueOutputsEnabled, ServiceManager serviceManager = null) { Contract.Requires(fileContentManager != null); Contract.Requires(directoryMembershipFingerprinter != null); Contract.Requires(pathExpander != null); Cache = cache; m_fileAccessWhitelist = fileAccessWhitelist; DirectoryMembershipFingerprinter = directoryMembershipFingerprinter; ResourceManager = new ProcessResourceManager(loggingContext); m_pathExpander = new FileContentManagerSemanticPathExpander(fileContentManager, pathExpander); ExecutionLog = executionLog; m_rootModuleConfiguration = configuration; m_directoryMembershipFingerprinterRuleSet = directoryMembershipFinterprinterRuleSet; PathExistenceCache = new ConcurrentBigMap <AbsolutePath, PathExistence>(); FileContentManager = fileContentManager; ServiceManager = serviceManager ?? ServiceManager.Default; PipEnvironment = new PipEnvironment(loggingContext); FileSystemView = fileSystemView; m_unsafeConfiguration = unsafeConfiguration; m_preserveOutputsSalt = preserveOutputsSalt; LazyDeletionOfSharedOpaqueOutputsEnabled = lazyDeletionOfSharedOpaqueOutputsEnabled; if (fileSystemView != null) { fileContentManager.SetLocalDiskFileSystemExistenceView(fileSystemView); } }
public ActionResult <FileSystemView> GetById(int id) { var item = _context.FileSystem.Find(id); FileSystemView item2 = new FileSystemView() { ID = item.ID, Name = item.Name, Size = item.Size, UploadedBy = item.UploadedBy, UploadedAt = item.UploadedAt, Url = item.Url }; if (item == null) { return(NotFound()); } return(item2); }
public Harness(PathTable pathTable) { m_pathTable = pathTable; FileSystemView = new FileSystemView(pathTable, this, this); }
public void ShowFsDirEntries(Client client, string basePath, List <FileInfo> dirEntries) { FileSystemView.PrintFsDirEntries(client, basePath, dirEntries); CurrentView.PrintBanner(); }
//===================================================================================== // Triggered From Application class //===================================================================================== public void ShowFsRoots(Client client, List <DiskDriveInfo> drives) { FileSystemView.PrintRoots(client, drives); CurrentView.PrintBanner(); }
private bool ProcessInstructionInteracting(string instruction, string[] parts) { try { ClientLock.AcquireReaderLock(15 * 1000); try { RevShellLock.AcquireReaderLock(15 * 1000); if (IsRevShellActive) { Application.ExecInShell(Client, instruction); return(true); } } catch (ApplicationException) { C.WriteLine("DeadLock ? ProcessInstructionInteracting"); } finally { RevShellLock.ReleaseReaderLock(); } if (parts[0] == "ls") { if (CurrentView == FileSystemView) { string basePath = FileSystemView.CurrentBasePath; if (basePath == null) { Application.FetchFileSystemDrives(Client); } else { Application.FetchDirEntries(Client, basePath); } } else { if (parts.Length == 1 || (parts.Length > 1 && parts[1].Trim().Equals("/"))) { Application.FetchFileSystemDrives(Client); } else { string basePath = Path.GetFullPath(parts[1]); Application.FetchDirEntries(Client, basePath); } } return(true); } if (parts[0].Equals("sysinfo", StringComparison.OrdinalIgnoreCase)) { Application.FetchSystemInfo(Client); return(true); } if (parts[0] == "fs") { if (parts.Length == 1 || (parts.Length > 1 && parts[1].Equals("start", StringComparison.OrdinalIgnoreCase))) { CurrentView = FileSystemView; FileSystemView.SetActiveClient(Application.GetClient(Client.Id)); } } else if (parts[0] == "ps") { Application.FetchProcessList(Client); return(true); } else if (instruction.Equals("desktop start", StringComparison.OrdinalIgnoreCase)) { bool shouldStart; lock (IsDesktopActiveLock) { shouldStart = !IsDesktopActive; } if (shouldStart) { Application.StartDesktop(Client); } return(true); } else if (instruction.Equals("desktop stop", StringComparison.OrdinalIgnoreCase)) { lock (IsDesktopActiveLock) { if (IsDesktopActive) { IsDesktopActive = false; Application.StopDesktop(Client); } } return(true); } else if (parts[0] == "cd") { if (parts.Length > 1) { if (CurrentView != FileSystemView) { CurrentView = FileSystemView; FileSystemView.ChangeDirectory(parts[1]); FileSystemView.Client = Client; } } } else if (parts[0] == "shell") { try { RevShellLock.AcquireWriterLock(15 * 1000); IsRevShellActive = true; } catch (ApplicationException) { C.WriteLine("DeadLock? RevShellLock.AcquireWriterLock"); } finally { RevShellLock.ReleaseWriterLock(); } Application.StartShell(Client); return(true); } } catch (ApplicationException exception) { C.WriteLine("============================================================================"); C.WriteLine("DeadLock? ConsoleUiMediator::ProcessInstructionInteracting AcquireReaderLock"); C.WriteLine("============================================================================"); return(false); } finally { ClientLock.ReleaseReaderLock(); } return(false); }
/// <summary> /// Creates an execution environment for a single pip. To run pips incrementally, the <paramref name="fileContentTable"/> and <paramref name="pipCache"/> should be specified. /// </summary> public DummyPipExecutionEnvironment( LoggingContext loggingContext, PipExecutionContext context, IConfiguration config, FileContentTable fileContentTable = null, EngineCache pipCache = null, SemanticPathExpander semanticPathExpander = null, PipContentFingerprinter.PipDataLookup pipDataLookup = null, FileAccessWhitelist fileAccessWhitelist = null, bool allowUnspecifiedSealedDirectories = false, PipTable pipTable = null, IIpcProvider ipcProvider = null, IKextConnection sandboxedKextConnection = null) { Contract.Requires(context != null); Contract.Requires(config != null); LoggingContext = loggingContext; Context = context; // Ensure paths visible when debugging PathTable.DebugPathTable = Context.PathTable; Configuration = config; PipTable = pipTable; PathExpander = semanticPathExpander ?? SemanticPathExpander.Default; ContentFingerprinter = new PipContentFingerprinter( Context.PathTable, artifact => State.FileContentManager.GetInputContent(artifact).FileContentInfo, new ExtraFingerprintSalts(config, PipFingerprintingVersion.TwoPhaseV2, fingerprintSalt: null, searchPathToolsHash: null), pathExpander: PathExpander, pipDataLookup: pipDataLookup); PipFragmentRenderer = this.CreatePipFragmentRenderer(); IpcProvider = ipcProvider ?? IpcFactory.GetProvider(); FileContentTable = fileContentTable ?? FileContentTable.CreateNew(); Cache = pipCache; FileAccessWhitelist = fileAccessWhitelist; m_allowUnspecifiedSealedDirectories = allowUnspecifiedSealedDirectories; m_sandboxedKextConnection = sandboxedKextConnection; if (Cache == null) { Cache = InMemoryCacheFactory.Create(context); } var tracker = FileChangeTracker.CreateDisabledTracker(LoggingContext); LocalDiskContentStore = new LocalDiskContentStore(loggingContext, context.PathTable, FileContentTable, tracker); PipGraphView = new TestPipGraphFilesystemView(Context.PathTable); m_operationTracker = new OperationTracker(loggingContext); var fileSystemView = new FileSystemView(Context.PathTable, PipGraphView, LocalDiskContentStore); var preserveOutputsSalt = UnsafeOptions.PreserveOutputsNotUsed; if (config.Sandbox.UnsafeSandboxConfiguration.PreserveOutputs != PreserveOutputsMode.Disabled) { preserveOutputsSalt = ContentHashingUtilities.HashString(Guid.NewGuid().ToString()); } State = new PipExecutionState( config, cache: new PipTwoPhaseCache(loggingContext, Cache, context, PathExpander), fileAccessWhitelist: FileAccessWhitelist, directoryMembershipFingerprinter: this, pathExpander: PathExpander, executionLog: ExecutionLogRecorder, fileSystemView: fileSystemView, fileContentManager: GetFileContentManager(), directoryMembershipFinterprinterRuleSet: null, unsafeConfiguration: config.Sandbox.UnsafeSandboxConfiguration, preserveOutputsSalt: preserveOutputsSalt, serviceManager: new DummyServiceManager()); m_sealContentsById = new ConcurrentBigMap <DirectoryArtifact, int[]>(); ProcessInContainerManager = new ProcessInContainerManager(LoggingContext, context.PathTable); }
private bool ProcessInstructionInteracting(string instruction, string[] parts) { try { ClientLock.AcquireReaderLock(15 * 1000); if (CurrentView == ShellView) { AppUiChannel.SubmitToApp(new ClientAppEvent(Client) { Subject = Subject.Shell, Action = Action.Push, Data = string.Join(" ", parts) }); return(true); } else if (parts[0] == "ls") { if (CurrentView == FileSystemView) { string basePath = FileSystemView.CurrentBasePath; if (basePath == null) { AppUiChannel.SubmitToApp(new ClientAppEvent(Client) { Subject = Subject.FileSystem, Action = Action.Start }); } else { AppUiChannel.SubmitToApp(new ClientAppEvent(Client) { Subject = Subject.FileSystem, Action = Action.Start, Data = basePath }); } } else { if (parts.Length == 1 || (parts.Length > 1 && parts[1].Trim().Equals("/"))) { AppUiChannel.SubmitToApp(new ClientAppEvent(Client) { Subject = Subject.FileSystem, Action = Action.Start }); } else { string basePath = Path.GetFullPath(parts[1]); AppUiChannel.SubmitToApp(new ClientAppEvent(Client) { Subject = Subject.FileSystem, Action = Action.Start, Data = basePath }); } } return(true); } else if (parts[0].Equals("sysinfo", StringComparison.OrdinalIgnoreCase)) { AppUiChannel.SubmitToApp(new ClientAppEvent(Client) { Subject = Subject.Information, Action = Action.Start }); return(true); } else if (parts[0] == "fs") { if (parts.Length == 1 || (parts.Length > 1 && parts[1].Equals("start", StringComparison.OrdinalIgnoreCase))) { CurrentView = FileSystemView; FileSystemView.SetActiveClient(Client); } } else if (parts[0] == "ps") { AppUiChannel.SubmitToApp(new ClientAppEvent(Client) { Subject = Subject.Process, Action = Action.Start }); return(true); } else if (parts[0] == "exec") { AppUiChannel.SubmitToApp(new ClientAppEvent(Client) { Subject = Subject.Shell, Action = Action.Push }); return(true); } else if (parts[0] == "shell") { CurrentView = ShellView; ShellView.SetActiveClient(Client); AppUiChannel.SubmitToApp(new ClientAppEvent(Client) { Subject = Subject.Shell, Action = Action.Start }); return(true); } else if (instruction.Equals("desktop start", StringComparison.OrdinalIgnoreCase)) { bool shouldStart; lock (IsDesktopActiveLock) { shouldStart = !IsDesktopActive; } if (shouldStart) { AppUiChannel.SubmitToApp(new ClientAppEvent(Client) { Subject = Subject.Desktop, Action = Action.Start }); return(true); } return(true); } else if (instruction.Equals("desktop stop", StringComparison.OrdinalIgnoreCase)) { lock (IsDesktopActiveLock) { if (IsDesktopActive) { IsDesktopActive = false; AppUiChannel.SubmitToApp(new ClientAppEvent(Client) { Subject = Subject.Desktop, Action = Action.Stop }); } } return(true); } else if (parts[0] == "cd") { if (parts.Length > 1) { if (CurrentView != FileSystemView) { CurrentView = FileSystemView; FileSystemView.ChangeDirectory(parts[1]); FileSystemView.Client = Client; } } } } catch (ApplicationException exception) { C.WriteLine("============================================================================"); C.WriteLine("DeadLock? ConsoleUiMediator::ProcessInstructionInteracting AcquireReaderLock"); C.WriteLine("============================================================================"); return(false); } finally { ClientLock.ReleaseReaderLock(); } return(false); }