protected TerminalLauncher(string title, string initScript, ReadOnlyCollection <EnvironmentEntry> environment) { _title = title; _initScript = initScript; _environment = environment; _isRoot = UnixNativeMethods.GetEUid() == 0; }
internal static string GetDebuggerCommand(LocalLaunchOptions localOptions) { string quotedDebuggerPath = String.Format(CultureInfo.InvariantCulture, "\"{0}\"", localOptions.MIDebuggerPath); if (PlatformUtilities.IsLinux()) { string debuggerPathCorrectElevation = quotedDebuggerPath; string prompt = string.Empty; // If running as root, make sure the new console is also root. bool isRoot = UnixNativeMethods.GetEUid() == 0; // If the system doesn't allow a non-root process to attach to another process, try to run GDB as root if (localOptions.ProcessId.HasValue && !isRoot && UnixUtilities.GetRequiresRootAttach(localOptions.DebuggerMIMode)) { prompt = String.Format(CultureInfo.CurrentCulture, "echo -n '{0}'; read yn; if [ \"$yn\" != 'y' ] && [ \"$yn\" != 'Y' ] ; then exit 1; fi; ", MICoreResources.Warn_AttachAsRootProcess); // Prefer pkexec for a nice graphical prompt, but fall back to sudo if it's not available if (File.Exists(UnixUtilities.PKExecPath)) { debuggerPathCorrectElevation = String.Concat(UnixUtilities.PKExecPath, " ", debuggerPathCorrectElevation); } else if (File.Exists(UnixUtilities.SudoPath)) { debuggerPathCorrectElevation = String.Concat(UnixUtilities.SudoPath, " ", debuggerPathCorrectElevation); } else { Debug.Fail("Root required to attach, but no means of elevating available!"); } } return(String.Concat(prompt, debuggerPathCorrectElevation)); } else { return(quotedDebuggerPath); } }