Ejemplo n.º 1
0
        public override bool OnCheckEnvironmentSession()
        {
            if (Engine.Instance.Storage.GetLower("ipv6.mode") == "disable")
            {
                string keyname    = "net.ipv6.conf.all.disable_ipv6";
                string ipV6       = "";
                string sysctlPath = LocateExecutable("sysctl");
                if (sysctlPath != "")
                {
                    ipV6 = SystemShell.Shell1(sysctlPath, keyname).Replace(keyname, "").Trim().Trim(new char[] { '=', ' ', '\n', '\r' });                     // 2.10.1
                }
                if (ipV6 == "0")
                {
                    if (Engine.Instance.OnAskYesNo(Messages.IpV6Warning))
                    {
                        Engine.Instance.Storage.Set("ipv6.mode", "none");
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (ipV6 == "1")
                {
                    // Already disabled
                }
                else
                {
                    Engine.Instance.Logs.Log(LogType.Verbose, Messages.IpV6WarningUnableToDetect);
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        public override bool OnInit()
        {
            base.OnInit();

            m_version      = SystemShell.Shell1(LocateExecutable("uname"), "-a");
            m_architecture = NormalizeArchitecture(SystemShell.Shell1(LocateExecutable("uname"), "-m").Trim());

            try
            {
                bool result = (NativeMethods.Init() == 0);
                if (result == false)
                {
                    throw new Exception("fail");
                }

                NativeMethods.Signal((int)NativeMethods.Signum.SIGHUP, SignalCallback);
                NativeMethods.Signal((int)NativeMethods.Signum.SIGINT, SignalCallback);
                NativeMethods.Signal((int)NativeMethods.Signum.SIGTERM, SignalCallback);
                NativeMethods.Signal((int)NativeMethods.Signum.SIGUSR1, SignalCallback);
                NativeMethods.Signal((int)NativeMethods.Signum.SIGUSR2, SignalCallback);
            }
            catch
            {
                Console.WriteLine("Unable to initialize native library. Maybe a CPU architecture issue.");
                return(false);
            }

            return(true);
        }
Ejemplo n.º 3
0
        public override string GetExecutablePathEx()
        {
            // We use this because querying .Net Assembly (what the base class do) doesn't work within Mkbundle.

            // TOFIX: Linux and OS X version are different, merge. Probably OS X it's more a clean approach.

            // Removed in 2.11 to avoid dependencies with libMonoPosixHelper.so
            // Useless, still required, but at least it's an external requirement.

            /*
             * string output = "";
             * StringBuilder builder = new StringBuilder(8192);
             * if (Syscall.readlink("/proc/self/exe", builder) >= 0)
             *      output = builder.ToString();
             */
            int    pid    = Process.GetCurrentProcess().Id;
            string output = SystemShell.Shell1(LocateExecutable("readlink"), "/proc/" + pid.ToString() + "/exe");

            if ((output != "") && (new FileInfo(output).Name.ToLowerInvariant().StartsWith("mono", StringComparison.InvariantCulture)))
            {
                // Exception: Assembly directly load by Mono
                output = base.GetExecutablePathEx();
            }

            return(output);
        }
Ejemplo n.º 4
0
        public override void Init()
        {
            base.Init();

            m_iptablesVersion = SystemShell.Shell1(Platform.Instance.LocateExecutable("iptables"), "--version");
            m_iptablesVersion = m_iptablesVersion.Replace("iptables v", "");
        }
Ejemplo n.º 5
0
        public override void OnReport(Report report)
        {
            base.OnReport(report);

            report.Add("ifconfig", (LocateExecutable("ifconfig") != "") ? SystemShell.Shell0(LocateExecutable("ifconfig")) : "'ifconfig' " + Messages.NotFound);
            report.Add("netstat /rnl", (LocateExecutable("netstat") != "") ? SystemShell.Shell1(LocateExecutable("netstat"), "/rnl") : "'netstat' " + Messages.NotFound);
        }
Ejemplo n.º 6
0
        public override void Deactivation()
        {
            base.Deactivation();

            // Restore system rules
            SystemShell s = new SystemShell();

            s.Path = m_pfctlPath;
            s.Arguments.Add("-v");
            s.Arguments.Add("-f");
            s.Arguments.Add(SystemShell.EscapePath("/etc/pf.conf"));
            s.Run();

            if (m_filePfConf != null)
            {
                m_filePfConf.Close();
                m_filePfConf = null;
            }

            if (m_prevActive)
            {
            }
            else
            {
                SystemShell.Shell1(m_pfctlPath, "-d");
            }
        }
Ejemplo n.º 7
0
        public override void FlushDNS()
        {
            base.FlushDNS();

            // 10.5 - 10.6
            string dscacheutilPath = LocateExecutable("dscacheutil");

            if (dscacheutilPath != "")
            {
                SystemShell.Shell1(dscacheutilPath, "-flushcache");
            }

            // 10.7 - 10.8 - 10.9 - 10.10.4 - 10.11 - Sierra 10.12.0
            string killallPath = LocateExecutable("killall");

            if (killallPath != "")
            {
                SystemShell.Shell2(killallPath, "-HUP", "mDNSResponder");
            }

            // 10.10.0 - 10.10.3
            string discoveryutilPath = LocateExecutable("discoveryutil");

            if (discoveryutilPath != "")
            {
                SystemShell.Shell1(discoveryutilPath, "udnsflushcaches");
                SystemShell.Shell1(discoveryutilPath, "mdnsflushcache");
            }
        }
Ejemplo n.º 8
0
        public override IpAddresses DetectDNS()
        {
            IpAddresses list = new IpAddresses();

            // Method1: Don't return DHCP DNS
            string networksetupPath = LocateExecutable("networksetup");

            if (networksetupPath != "")
            {
                string[] interfaces = GetInterfaces();
                foreach (string i in interfaces)
                {
                    string i2 = i.Trim();

                    string current = SystemShell.Shell(networksetupPath, new string[] { "-getdnsservers", SystemShell.EscapeInsideQuote(i2) });

                    foreach (string line in current.Split('\n'))
                    {
                        string field = line.Trim();
                        list.Add(field);
                    }
                }
            }

            // Method2 - More info about DHCP DNS
            string scutilPath = LocateExecutable("scutil");

            if (scutilPath != "")
            {
                string scutilOut             = SystemShell.Shell1(scutilPath, "--dns");
                List <List <string> > result = UtilsString.RegExMatchMulti(scutilOut.Replace(" ", ""), "nameserver\\[[0-9]+\\]:([0-9:\\.]+)");
                foreach (List <string> match in result)
                {
                    foreach (string field in match)
                    {
                        list.Add(field);
                    }
                }
            }

            // Method3 - Compatibility
            if (FileExists("/etc/resolv.conf"))
            {
                string o = FileContentsReadText("/etc/resolv.conf");
                foreach (string line in o.Split('\n'))
                {
                    if (line.Trim().StartsWith("#"))
                    {
                        continue;
                    }
                    if (line.Trim().StartsWith("nameserver"))
                    {
                        string field = line.Substring(11).Trim();
                        list.Add(field);
                    }
                }
            }

            return(list);
        }
Ejemplo n.º 9
0
        public override void OnJsonNetworkInfo(Json jNetworkInfo)
        {
            // Step1: Set IPv6 support to true by default.
            // From base virtual, always 'false'. Missing Mono implementation?
            // After for interfaces listed by 'networksetup -listallhardwareports' we detect specific support.
            foreach (Json jNetworkInterface in jNetworkInfo["interfaces"].Json.GetArray())
            {
                jNetworkInterface["support_ipv6"].Value = true;
            }

            // Step2: Query 'networksetup -listallhardwareports' to obtain a more accurate device friendly names.
            string networksetupPath = LocateExecutable("networksetup");

            if (networksetupPath != "")
            {
                string nsOutput = SystemShell.Shell1(networksetupPath, "-listallhardwareports");
                string lastName = "";
                foreach (string line in nsOutput.Split('\n'))
                {
                    if (line.StartsWith("Hardware Port: ", StringComparison.InvariantCulture))
                    {
                        lastName = line.Substring(15).Trim();
                    }
                    if (line.StartsWith("Device:", StringComparison.InvariantCulture))
                    {
                        string deviceId = line.Substring(7).Trim();
                        foreach (Json jNetworkInterface in jNetworkInfo["interfaces"].Json.GetArray())
                        {
                            if (jNetworkInterface["id"].Value as string == deviceId)
                            {
                                // Set friendly name
                                jNetworkInterface["friendly"].Value = lastName;

                                // Detect IPv6 support
                                string getInfo = SystemShell.Shell(LocateExecutable("networksetup"), new string[] { "-getinfo", SystemShell.EscapeInsideQuote(lastName) });

                                string mode = getInfo.RegExMatchOne("^IPv6: (.*?)$").Trim();

                                if (mode == "Off")
                                {
                                    jNetworkInterface["support_ipv6"].Value = false;
                                }
                                else
                                {
                                    jNetworkInterface["support_ipv6"].Value = true;
                                }

                                break;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 10
0
        public override void Activation()
        {
            base.Activation();

            try
            {
                if (m_pfctlPath == "")
                {
                    throw new Exception("pfctl " + Messages.NotFound);
                }

                m_prevActive = false;
                string report = SystemShell.Shell1(m_pfctlPath, "-si").ToLowerInvariant();
                if (report.IndexOf("denied") != -1)
                {
                    throw new Exception("Permission denied.");
                }
                else if (report.IndexOf("status: enabled") != -1)
                {
                    m_prevActive = true;
                }
                else if (report.IndexOf("status: disabled") != -1)
                {
                    m_prevActive = false;
                }
                else
                {
                    throw new Exception("Unexpected PF Firewall status");
                }

                if (m_prevActive == false)
                {
                    string reportActivation = SystemShell.Shell1(m_pfctlPath, "-e").ToLowerInvariant();
                    if (reportActivation.IndexOf("pf enabled") == -1)
                    {
                        throw new Exception("Unexpected PF Firewall activation failure");
                    }
                }
                m_filePfConf = new TemporaryFile("pf.conf");

                OnUpdateIps();

                if (m_prevActive == false)
                {
                    SystemShell.Shell1(m_pfctlPath, "-e");
                }
            }
            catch (Exception ex)
            {
                Deactivation();
                throw new Exception(ex.Message);
            }
        }
Ejemplo n.º 11
0
        public override string GetName()
        {
            string swversPath = LocateExecutable("sw_vers");

            if (swversPath != "")
            {
                return(SystemShell.Shell1(swversPath, "-productVersion"));
            }
            else
            {
                return("Unknown (no sw_vers)");
            }
        }
Ejemplo n.º 12
0
        public override void OnInit()
        {
            base.OnInit();

            m_version      = SystemShell.Shell1(LocateExecutable("uname"), "-a");
            m_architecture = NormalizeArchitecture(SystemShell.Shell1(LocateExecutable("uname"), "-m").Trim());

            NativeMethods.Signal((int)NativeMethods.Signum.SIGHUP, SignalCallback);
            NativeMethods.Signal((int)NativeMethods.Signum.SIGINT, SignalCallback);
            NativeMethods.Signal((int)NativeMethods.Signum.SIGTERM, SignalCallback);
            NativeMethods.Signal((int)NativeMethods.Signum.SIGUSR1, SignalCallback);
            NativeMethods.Signal((int)NativeMethods.Signum.SIGUSR2, SignalCallback);
        }
Ejemplo n.º 13
0
        public override string GetExecutableReport(string path)
        {
            string lddPath = LocateExecutable("ldd");

            if (lddPath != "")
            {
                return(SystemShell.Shell1(lddPath, SystemShell.EscapePath(path)));
            }
            else
            {
                return("'ldd' " + LanguageManager.GetText("NotFound"));
            }
        }
Ejemplo n.º 14
0
        public override string GetExecutableReport(string path)
        {
            string lddPath = LocateExecutable("ldd");

            if (lddPath != "")
            {
                return(SystemShell.Shell1(lddPath, SystemShell.EscapePath(path)));
            }
            else
            {
                return("'ldd' " + Messages.NotFound);
            }
        }
Ejemplo n.º 15
0
        public static void Init()
        {
            StringFormatLeftTop            = BuildStringFormat(StringAlignment.Near, StringAlignment.Near);
            StringFormatCenterTop          = BuildStringFormat(StringAlignment.Center, StringAlignment.Near);
            StringFormatRightTop           = BuildStringFormat(StringAlignment.Far, StringAlignment.Near);
            StringFormatLeftMiddle         = BuildStringFormat(StringAlignment.Near, StringAlignment.Center);
            StringFormatCenterMiddle       = BuildStringFormat(StringAlignment.Center, StringAlignment.Center);
            StringFormatRightMiddle        = BuildStringFormat(StringAlignment.Far, StringAlignment.Center);
            StringFormatLeftBottom         = BuildStringFormat(StringAlignment.Near, StringAlignment.Far);
            StringFormatCenterBottom       = BuildStringFormat(StringAlignment.Center, StringAlignment.Far);
            StringFormatRightBottom        = BuildStringFormat(StringAlignment.Far, StringAlignment.Far);
            StringFormatLeftMiddleNoWrap   = BuildStringFormat(StringAlignment.Near, StringAlignment.Center, StringFormatFlags.NoWrap);
            StringFormatCenterMiddleNoWrap = BuildStringFormat(StringAlignment.Center, StringAlignment.Center, StringFormatFlags.NoWrap);
            StringFormatRightMiddleNoWrap  = BuildStringFormat(StringAlignment.Far, StringAlignment.Center, StringFormatFlags.NoWrap);

            if (IsUnix())
            {
                m_unixFontSystem = "";
                string gsettingsPath = Eddie.Core.Platform.Instance.LocateExecutable("gsettings");                 // gnome
                if (gsettingsPath != "")
                {
                    m_unixFontSystem = SystemShell.Shell1(gsettingsPath, "get org.gnome.desktop.interface font-name").Trim('\'');
                    int posSize = m_unixFontSystem.LastIndexOf(" ");
                    if (posSize != -1)
                    {
                        m_unixFontSystem = m_unixFontSystem.Substring(0, posSize) + "," + m_unixFontSystem.Substring(posSize + 1);
                    }
                }

                m_unixFontMonoSpace = "";
                if (gsettingsPath != "")
                {
                    m_unixFontMonoSpace = SystemShell.Shell1(gsettingsPath, "get org.gnome.desktop.interface monospace-font-name").Trim('\'');
                    int posSize = m_unixFontMonoSpace.LastIndexOf(" ");
                    if (posSize != -1)
                    {
                        m_unixFontMonoSpace = m_unixFontMonoSpace.Substring(0, posSize) + "," + m_unixFontMonoSpace.Substring(posSize + 1);
                    }
                }
            }
        }
Ejemplo n.º 16
0
        public static void Init()
        {
            StringFormatLeftTop            = BuildStringFormat(StringAlignment.Near, StringAlignment.Near);
            StringFormatCenterTop          = BuildStringFormat(StringAlignment.Center, StringAlignment.Near);
            StringFormatRightTop           = BuildStringFormat(StringAlignment.Far, StringAlignment.Near);
            StringFormatLeftMiddle         = BuildStringFormat(StringAlignment.Near, StringAlignment.Center);
            StringFormatCenterMiddle       = BuildStringFormat(StringAlignment.Center, StringAlignment.Center);
            StringFormatRightMiddle        = BuildStringFormat(StringAlignment.Far, StringAlignment.Center);
            StringFormatLeftBottom         = BuildStringFormat(StringAlignment.Near, StringAlignment.Far);
            StringFormatCenterBottom       = BuildStringFormat(StringAlignment.Center, StringAlignment.Far);
            StringFormatRightBottom        = BuildStringFormat(StringAlignment.Far, StringAlignment.Far);
            StringFormatLeftMiddleNoWrap   = BuildStringFormat(StringAlignment.Near, StringAlignment.Center, StringFormatFlags.NoWrap);
            StringFormatCenterMiddleNoWrap = BuildStringFormat(StringAlignment.Center, StringAlignment.Center, StringFormatFlags.NoWrap);
            StringFormatRightMiddleNoWrap  = BuildStringFormat(StringAlignment.Far, StringAlignment.Center, StringFormatFlags.NoWrap);

            if (IsUnix())
            {
                m_unixFontSystemName    = SystemFonts.MenuFont.Name;
                m_unixFontSystemSize    = SystemFonts.MenuFont.Size;
                m_unixFontMonoSpaceName = "Monospace";
                m_unixFontMonoSpaceSize = SystemFonts.MenuFont.Size;

                string gsettingsPath = Eddie.Core.Platform.Instance.LocateExecutable("gsettings");                 // gnome
                if (gsettingsPath != "")
                {
                    string uFontSystem    = SystemShell.Shell1(gsettingsPath, "get org.gnome.desktop.interface font-name").Trim('\'');
                    int    uFontSystemSep = uFontSystem.LastIndexOf(" ");
                    if (uFontSystemSep != -1)
                    {
                        m_unixFontSystemName = uFontSystem.Substring(0, uFontSystemSep).TrimChars(",; \n\r");
                        m_unixFontSystemSize = Conversions.ToInt32(uFontSystem.Substring(uFontSystemSep + 1).TrimChars(",; \n\r"));
                    }

                    string uFontMono    = SystemShell.Shell1(gsettingsPath, "get org.gnome.desktop.interface monospace-font-name").Trim('\'');
                    int    uFontMonoSep = uFontMono.LastIndexOf(" ");
                    if (uFontMonoSep != -1)
                    {
                        m_unixFontMonoSpaceName = uFontMono.Substring(0, uFontMonoSep).TrimChars(",; \n\r");
                        m_unixFontMonoSpaceSize = Conversions.ToInt32(uFontMono.Substring(uFontMonoSep + 1).TrimChars(",; \n\r"));
                    }
                }

                if (m_unixFontSystemName == "")
                {
                    m_unixFontSystemName = "Cantarell";
                }
                if (m_unixFontSystemSize < 6)
                {
                    m_unixFontSystemSize = 6;
                }

                if (m_unixFontMonoSpaceName == "")
                {
                    m_unixFontMonoSpaceName = "Monospace";
                }
                if (m_unixFontMonoSpaceSize < 6)
                {
                    m_unixFontMonoSpaceSize = 6;
                }
            }
        }
Ejemplo n.º 17
0
        public override List <RouteEntry> RouteList()
        {
            List <RouteEntry> entryList = new List <RouteEntry>();

            string netstatPath = LocateExecutable("netstat");

            if (netstatPath != "")
            {
                string result = SystemShell.Shell1(netstatPath, "-rnl");

                string[] lines = result.Split('\n');
                foreach (string line in lines)
                {
                    if (line == "Routing tables")
                    {
                        continue;
                    }
                    if (line == "Internet:")
                    {
                        continue;
                    }
                    if (line == "Internet6:")
                    {
                        continue;
                    }

                    string[] fields = Utils.StringCleanSpace(line).Split(' ');

                    if (fields.Length == 8)
                    {
                        if (fields[0] == "Destination")
                        {
                            continue;
                        }

                        RouteEntry e = new RouteEntry();
                        e.Address = fields[0];
                        e.Gateway = fields[1];
                        e.Flags   = fields[2];
                        // Refs
                        // Use
                        // Mtu
                        e.Interface = fields[6];
                        // Expire

                        if (e.Address.Valid == false)
                        {
                            continue;
                        }
                        if (e.Gateway.Valid == false)
                        {
                            continue;
                        }

                        entryList.Add(e);
                    }
                }
            }

            return(entryList);
        }
Ejemplo n.º 18
0
        public override void OnJsonRouteList(Json jRoutesList)
        {
            base.OnJsonRouteList(jRoutesList);

            string netstatPath = LocateExecutable("netstat");

            if (netstatPath != "")
            {
                string result = SystemShell.Shell1(netstatPath, "-rnl");

                string[] lines = result.Split('\n');
                foreach (string line in lines)
                {
                    if (line == "Routing tables")
                    {
                        continue;
                    }
                    if (line == "Internet:")
                    {
                        continue;
                    }
                    if (line == "Internet6:")
                    {
                        continue;
                    }

                    string[] fields = line.CleanSpace().Split(' ');

                    if ((fields.Length > 0) && (fields[0].ToLowerInvariant().Trim() == "destination"))
                    {
                        continue;
                    }

                    if (fields.Length >= 7)
                    {
                        Json      jRoute  = new Json();
                        IpAddress address = new IpAddress();
                        if (fields[0].ToLowerInvariant().Trim() == "default")
                        {
                            IpAddress gateway = new IpAddress(fields[1]);
                            if (gateway.Valid == false)
                            {
                                continue;
                            }
                            if (gateway.IsV4)
                            {
                                address = IpAddress.DefaultIPv4;
                            }
                            else if (gateway.IsV6)
                            {
                                address = IpAddress.DefaultIPv6;
                            }
                        }
                        else
                        {
                            address.Parse(fields[0]);
                        }
                        if (address.Valid == false)
                        {
                            continue;
                        }
                        jRoute["address"].Value   = address.ToCIDR();
                        jRoute["gateway"].Value   = fields[1];
                        jRoute["flags"].Value     = fields[2];
                        jRoute["refs"].Value      = fields[3];
                        jRoute["use"].Value       = fields[4];
                        jRoute["mtu"].Value       = fields[5];
                        jRoute["interface"].Value = fields[6];
                        if (fields.Length > 7)
                        {
                            jRoute["expire"].Value = fields[7];
                        }
                        jRoutesList.Append(jRoute);
                    }
                }
            }
        }
Ejemplo n.º 19
0
        public override void OnInit(bool cli)
        {
            base.OnInit(cli);

            m_version      = SystemShell.Shell1(LocateExecutable("uname"), "-a");
            m_architecture = NormalizeArchitecture(SystemShell.Shell1(LocateExecutable("uname"), "-m").Trim());
            m_uid          = 9999;
            UInt32.TryParse(SystemShell.Shell1(LocateExecutable("id"), "-u"), out m_uid);

            // Debian, Environment.UserName == 'root', $SUDO_USER == '', $LOGNAME == 'root', whoami == 'root', logname == 'myuser'
            // Ubuntu, Environment.UserName == 'root', $SUDO_USER == 'myuser', $LOGNAME == 'root', whoami == 'root', logname == 'no login name'
            // Manjaro, same as Ubuntu
            m_logname = Environment.GetEnvironmentVariable("SUDO_USER");
            if (m_logname == null)
            {
                m_logname = "";
            }
            else
            {
                m_logname = m_logname.Trim();
            }
            if (m_logname == "")
            {
                m_logname = SystemShell.Shell0(LocateExecutable("logname"));
            }
            if (m_logname.Contains("no login name"))
            {
                m_logname = Environment.UserName;
            }
            if (m_logname == null)
            {
                m_logname = "";
            }

            m_fontSystem = "";
            string gsettingsPath = LocateExecutable("gsettings");             // gnome

            if (gsettingsPath != "")
            {
                m_fontSystem = SystemShell.Shell1(gsettingsPath, "get org.gnome.desktop.interface font-name").Trim('\'');
                int posSize = m_fontSystem.LastIndexOf(" ");
                if (posSize != -1)
                {
                    m_fontSystem = m_fontSystem.Substring(0, posSize) + "," + m_fontSystem.Substring(posSize + 1);
                }
            }

            m_fontMonoSpace = "";
            if (gsettingsPath != "")
            {
                m_fontMonoSpace = SystemShell.Shell1(gsettingsPath, "get org.gnome.desktop.interface monospace-font-name").Trim('\'');
                int posSize = m_fontMonoSpace.LastIndexOf(" ");
                if (posSize != -1)
                {
                    m_fontMonoSpace = m_fontMonoSpace.Substring(0, posSize) + "," + m_fontMonoSpace.Substring(posSize + 1);
                }
            }

            Native.eddie_signal((int)Native.Signum.SIGINT, SignalCallback);
            Native.eddie_signal((int)Native.Signum.SIGTERM, SignalCallback);
            Native.eddie_signal((int)Native.Signum.SIGUSR1, SignalCallback);
            Native.eddie_signal((int)Native.Signum.SIGUSR2, SignalCallback);
        }
Ejemplo n.º 20
0
        public override void FlushDNS()
        {
            base.FlushDNS();

            string servicePath = LocateExecutable("service");

            if (servicePath != "")
            {
                Dictionary <string, string> services = new Dictionary <string, string>();
                string list = SystemShell.Shell1(servicePath, "--status-all");
                list = Utils.StringCleanSpace(list);
                foreach (string line in list.Split('\n'))
                {
                    if (line.Contains(" running "))
                    {
                        int pos = line.IndexOf(".service");
                        if (pos != -1)
                        {
                            string name = line.Substring(0, pos).Trim();
                            services[name] = name;
                        }
                    }
                }

                if (services.ContainsKey("nscd"))
                {
                    SystemShell.Shell2(servicePath, "nscd", "restart");
                }
                if (services.ContainsKey("dnsmasq"))
                {
                    SystemShell.Shell2(servicePath, "dnsmasq", "restart");
                }
                if (services.ContainsKey("named"))
                {
                    SystemShell.Shell2(servicePath, "named", "restart");
                }
                if (services.ContainsKey("bind9"))
                {
                    SystemShell.Shell2(servicePath, "bind9", "restart");
                }
            }
            else
            {
                if (FileExists("/etc/init.d/nscd"))
                {
                    SystemShell.Shell1("/etc/init.d/nscd", "restart");
                }
                if (FileExists("/etc/init.d/dnsmasq"))
                {
                    SystemShell.Shell1("/etc/init.d/dnsmasq", "restart");
                }
                if (FileExists("/etc/init.d/named"))
                {
                    SystemShell.Shell1("/etc/init.d/named", "restart");
                }
                if (FileExists("/etc/init.d/bind9"))
                {
                    SystemShell.Shell1("/etc/init.d/bind9", "restart");
                }
            }

            // On some system, for example Fedora, nscd caches are saved to disk,
            // located in /var/db/nscd, and not flushed with a simple restart.
            string nscdPath = LocateExecutable("nscd");

            if (nscdPath != "")
            {
                SystemShell.Shell1(nscdPath, "--invalidate=hosts");
            }
        }