public IProcess StartHost(Interpreter interpreter, string profilePath, string userName, ClaimsPrincipal principal, string commandLine) { IProcess process; if (principal.HasClaim((c) => c.Type == UnixClaims.RPassword)) { var args = ParseArgumentsIntoList(commandLine); var environment = GetHostEnvironment(interpreter, profilePath, userName); var password = principal.FindFirst(UnixClaims.RPassword).Value; process = Utility.AuthenticateAndRunAsUser(_sessionLogger, _ps, userName, password, profilePath, args, environment); } else { process = Utility.RunAsCurrentUser(_sessionLogger, _ps, commandLine, GetRHomePath(interpreter), GetLoadLibraryPath(interpreter)); } process.WaitForExit(250); if (process.HasExited && process.ExitCode != 0) { var message = _ps.MessageFromExitCode(process.ExitCode); if (!string.IsNullOrEmpty(message)) { throw new Win32Exception(message); } throw new Win32Exception(process.ExitCode); } return(process); }
public IProcess StartHost(Interpreter interpreter, string profilePath, string userName, ClaimsPrincipal principal, string commandLine) { var exeLocator = BrokerExecutableLocator.Create(_fs); var hostBinPath = exeLocator.GetHostExecutablePath(); if (!_fs.FileExists(hostBinPath) && RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { hostBinPath = PathConstants.RunHostBinPath; } var process = Utility.RunAsCurrentUser(_sessionLogger, _ps, hostBinPath, commandLine, GetRHomePath(interpreter), GetLoadLibraryPath(interpreter)); process.WaitForExit(250); if (process.HasExited && process.ExitCode != 0) { var message = _ps.MessageFromExitCode(process.ExitCode); if (!string.IsNullOrEmpty(message)) { throw new Win32Exception(message); } throw new Win32Exception(process.ExitCode); } return(process); }
private IProcess StartBroker(ProcessStartInfo psi) { var process = _processServices.Start(psi); process.WaitForExit(250); if (process.HasExited && process.ExitCode < 0) { var message = _processServices.MessageFromExitCode(process.ExitCode); if (!string.IsNullOrEmpty(message)) { throw new RHostDisconnectedException(Resources.Error_UnableToStartBrokerException.FormatInvariant(_name, message), new Win32Exception(message)); } throw new RHostDisconnectedException(Resources.Error_UnableToStartBrokerException.FormatInvariant(_name, process.ExitCode), new Win32Exception(process.ExitCode)); } return(process); }