Exemple #1
0
        protected override void OpenDirectoryInFileManagerEx(string path)
        {
            // TOFIX Don't work well on all distro
            string args = " - " + m_logname + " -c 'xdg-open \"" + SystemShell.EscapePath(path) + "\"'";             // IJTF2 // TOCHECK

            SystemShell.ShellX("su", args, false);
        }
Exemple #2
0
        public override bool RestartAsRoot()
        {
            string command   = "";
            string arguments = "";


            string command2       = "";
            string executablePath = Platform.Instance.GetExecutablePath();
            string cmdline        = CommandLine.SystemEnvironment.GetFull();

            if (executablePath.Substring(executablePath.Length - 4).ToLowerInvariant() == ".exe")
            {
                command2 += "mono ";
            }
            command2 += Platform.Instance.GetExecutablePath();
            command2 += " ";
            command2 += cmdline;
            command2 += " console.mode=none";       // 2.13.6, otherwise CancelKeyPress (mono bug?) and stdout fill the non-root non-blocked terminal.
            command2  = command2.Trim();            // 2.11.11
            bool waitEnd = false;

            if (LocateExecutable("kdesudo") != "")
            {
                command    = "kdesudo";
                arguments  = "";
                arguments += " -u root";            // Administrative privileges
                arguments += " -d";                 // Don't show commandline
                arguments += " --comment \"" + Messages.AdminRequiredPasswordPrompt + "\"";
                arguments += " -c ";                // The command
                //arguments += " \"" + command2 + "\"";
                arguments += " \"" + command2 + "\"";
            }
            else if (LocateExecutable("kdesu") != "")
            {
                command    = "kdesu";
                arguments  = "";
                arguments += " -u root";            // Administrative privileges
                arguments += " -d";                 // Don't show commandline
                //arguments += " --comment \"" + Messages.AdminRequiredPasswordPrompt + "\"";
                arguments += " -c ";                // The command
                //arguments += " \"" + command2 + "\"";
                arguments += " \"" + command2 + "\"";
            }

            /*
             * Under Debian, gksudo don't work, gksu work...
             * if (Platform.Instance.FileExists("/usr/bin/gksudo"))
             * {
             *      command = "gksudo";
             *      arguments = "";
             *      arguments += " -u root"; // Administrative privileges
             *      arguments += " -m \"" + Messages.AdminRequiredPasswordPrompt + "\"";
             *      arguments += " \"" + command2 + "\"";
             * }
             * else
             */
            else if (LocateExecutable("gksu") != "")
            {
                command    = "gksu";
                arguments  = "";
                arguments += " -u root";                 // Administrative privileges
                arguments += " -m \"" + Messages.AdminRequiredPasswordPrompt + "\"";
                arguments += " \"" + command2 + "\"";
            }
            else if (LocateExecutable("xdg-su") != "")             // OpenSUSE
            {
                command    = "xdg-su";
                arguments  = "";
                arguments += " -u root";             // Administrative privileges
                arguments += " -c ";                 // The command
                arguments += " \"" + command2 + "\"";
            }
            else if (LocateExecutable("beesu") != "")             // Fedora
            {
                command    = "beesu";
                arguments  = "";
                arguments += " " + command2 + "";
            }

            /*
             * else if (Platform.Instance.FileExists("/usr/bin/pkexec"))
             * {
             *      // Different behiavour on different platforms
             *      command = "pkexec";
             *      arguments = "";
             *      arguments = " env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY";
             *      arguments += " " + command2 + "";
             *
             *      // For this bug: https://lists.ubuntu.com/archives/foundations-bugs/2012-July/100103.html
             *      // We need to keep alive the current process, otherwise 'Refusing to render service to dead parents.'.
             *      waitEnd = true;
             *
             *      // Still don't work.
             * }
             */

            if (command != "")
            {
                Engine.Instance.Logs.Log(LogType.Verbose, Messages.AdminRequiredRestart);

                SystemShell.ShellX(command.Trim(), arguments.Trim(), waitEnd);                 // IJTF2
            }
            else
            {
                Engine.Instance.Logs.Log(LogType.Fatal, Messages.AdminRequiredRestartFailed);
            }

            return(true);
        }