예제 #1
0
        public virtual SolarisSmfInfo GetSmfInfo(string frmi)
        {
            SolarisSmfInfo retVal = null;

            string[] svcComps = frmi.Split(new char[] { ':' }, 3);
            if (svcComps.Length < 2)
            {
                return(null);
            }
            string[] nameComps = svcComps[1].Split(new char[] { '/' });
            if (nameComps.Length < 1)
            {
                return(null);
            }
            retVal             = new SolarisSmfInfo();
            retVal.frmi        = frmi;
            retVal.ServiceName = nameComps[nameComps.Length - 1];

            SolarisSvcPropInfo thisProp = null;
            Dictionary <string, SolarisSvcPropInfo> props = getAllProps(frmi);

            if (props.TryGetValue("restarter/state", out thisProp))
            {
                retVal.ServiceState = thisProp.Value.ToUpper();
            }

            if (props.TryGetValue("inetd/proto", out thisProp))
            {
                retVal.Protocol = thisProp.Value;
            }

            if (props.TryGetValue("inetd_start/exec", out thisProp) || props.TryGetValue("start/exec", out thisProp))
            {
                int slashSpacePos = thisProp.Value.IndexOf("\\ ");
                if (slashSpacePos < 0)
                {
                    retVal.ServerExecutable = thisProp.Value;
                }
                else
                {
                    retVal.ServerExecutable = thisProp.Value.Substring(0, slashSpacePos);
                    retVal.ServerArgs       = thisProp.Value.Substring(slashSpacePos + 2);
                }
            }

            if (props.TryGetValue("inetd_start/user", out thisProp))
            {
                retVal.ExecAsUser = thisProp.Value;
            }

            return(retVal);
        }
예제 #2
0
        public virtual SolarisSmfInfo GetSmfInfo(string frmi)
        {
            SolarisSmfInfo retVal = null;
            string[] svcComps = frmi.Split(new char[] { ':' }, 3);
            if (svcComps.Length < 2)
                return null;
            string[] nameComps = svcComps[1].Split(new char[] { '/' });
            if (nameComps.Length < 1)
                return null;
            retVal = new SolarisSmfInfo();
            retVal.frmi = frmi;
            retVal.ServiceName = nameComps[nameComps.Length - 1];

            SolarisSvcPropInfo thisProp = null;
            Dictionary<string, SolarisSvcPropInfo> props = getAllProps(frmi);

            if (props.TryGetValue("restarter/state", out thisProp))
                retVal.ServiceState = thisProp.Value.ToUpper();

            if (props.TryGetValue("inetd/proto", out thisProp))
                retVal.Protocol = thisProp.Value;

            if (props.TryGetValue("inetd_start/exec", out thisProp) || props.TryGetValue("start/exec", out thisProp))
            {
                int slashSpacePos = thisProp.Value.IndexOf("\\ ");
                if (slashSpacePos < 0)
                    retVal.ServerExecutable = thisProp.Value;
                else
                {
                    retVal.ServerExecutable = thisProp.Value.Substring(0, slashSpacePos);
                    retVal.ServerArgs = thisProp.Value.Substring(slashSpacePos + 2);
                }
            }

            if (props.TryGetValue("inetd_start/user", out thisProp))
                retVal.ExecAsUser = thisProp.Value;

            return retVal;
        }
예제 #3
0
        private BaseObjectCollector CreateSmfObjectCollector(
            SolarisSmfInfo fakeSmfInfoToReturn)
        {
            var mocks = new MockRepository();
            var fakeSmfCollector = mocks.DynamicMock<SolarisSmfCollector>();
            Expect.Call(fakeSmfCollector.GetSmfInfo(null))
                .IgnoreArguments()
                    .Return(fakeSmfInfoToReturn);

            mocks.ReplayAll();

            return new SMFObjectCollector()
            {
                SMFCollector = fakeSmfCollector
            };
        }