Ejemplo n.º 1
0
    def testParseXinetd(self):
        """Xinetd entries return accurate LinuxServiceInformation values."""
        defaults = """
      defaults
      {
         instances      = 60
         log_type       = SYSLOG     authpriv
         log_on_success = HOST PID
         log_on_failure = HOST
         cps            = 25 30
      }
      includedir /etc/xinetd.d"""
        telnet = """
      service telnet
      {
         flags           = REUSE
         socket_type     = stream
         wait            = no
         user            = root
         server          = /sbin/telnetd
         log_on_failure  += USERID
         disable         = yes
      }

      service forwarder
      {
         disable        = no
         type           = UNLISTED
         socket_type    = stream
         protocol       = tcp
         wait           = no
         redirect       = 192.168.1.1 22
         bind           = 8.8.8.8
         port           = 443
         user           = nobody
      }"""
        paths = ["/etc/xinetd.conf", "/etc/xinetd.d/telnet"]
        vals = [defaults, telnet]
        stats, files = GenTestData(paths, vals)

        parser = linux_service_parser.LinuxXinetdParser()
        results = list(parser.ParseMultiple(stats, files, None))
        self.assertEqual(2, len(results))
        self.assertItemsEqual(["forwarder", "telnet"],
                              [r.name for r in results])
        for rslt in results:
            self.assertFalse(rslt.start_on)
            self.assertFalse(rslt.stop_on)
            self.assertFalse(rslt.stop_after)
            if rslt.name == "telnet":
                self.assertFalse(rslt.start_mode)
                self.assertFalse(rslt.start_after)
            else:
                self.assertEqual("XINETD", str(rslt.start_mode))
                self.assertItemsEqual(["xinetd"], list(rslt.start_after))
Ejemplo n.º 2
0
  def testParseXinetd(self):
    """Xinetd entries return accurate LinuxServiceInformation values."""
    configs = GenXinetd("telnet", "yes")
    configs.update(GenXinetd("forwarder", "no"))
    stats, files = GenTestData(configs, configs.values())

    parser = linux_service_parser.LinuxXinetdParser()
    results = list(parser.ParseMultiple(stats, files, None))
    self.assertEqual(2, len(results))
    self.assertItemsEqual(["forwarder", "telnet"], [r.name for r in results])
    for rslt in results:
      self.assertFalse(rslt.start_on)
      self.assertFalse(rslt.stop_on)
      self.assertFalse(rslt.stop_after)
      if rslt.name == "telnet":
        self.assertFalse(rslt.start_mode)
        self.assertFalse(rslt.start_after)
        self.assertFalse(rslt.starts)
      else:
        self.assertEqual("XINETD", str(rslt.start_mode))
        self.assertItemsEqual(["xinetd"], list(rslt.start_after))
        self.assertTrue(rslt.starts)
Ejemplo n.º 3
0
 def setUpClass(cls):
     cls.LoadCheck("services.yaml")
     cls.parser = linux_service_parser.LinuxXinetdParser().ParseMultiple
Ejemplo n.º 4
0
  def setUpClass(cls):
    super(XinetdServiceStateTests, cls).setUpClass()

    cls.LoadCheck("services.yaml")
    cls.parser = linux_service_parser.LinuxXinetdParser().ParseMultiple