Beispiel #1
0
    def CreateServiceProto(self, job):
        """Create the Service protobuf.

    Args:
      job: Launchdjobdict from servicemanagement framework.
    Returns:
      sysinfo_pb2.OSXServiceInformation proto
    """
        service = rdf_client.OSXServiceInformation(
            label=job.get("Label"),
            program=job.get("Program"),
            sessiontype=job.get("LimitLoadToSessionType"),
            lastexitstatus=int(job["LastExitStatus"]),
            timeout=int(job["TimeOut"]),
            ondemand=bool(job["OnDemand"]))

        for arg in job.get("ProgramArguments", "", stringify=False):
            # Returns CFArray of CFStrings
            service.args.Append(unicode(arg))

        mach_dict = job.get("MachServices", {}, stringify=False)
        for key, value in mach_dict.iteritems():
            service.machservice.Append("%s:%s" % (key, value))

        job_mach_dict = job.get("PerJobMachServices", {}, stringify=False)
        for key, value in job_mach_dict.iteritems():
            service.perjobmachservice.Append("%s:%s" % (key, value))

        if "PID" in job:
            service.pid = job["PID"].value

        return service
Beispiel #2
0
 def testParse(self):
     parser = osx_launchd.DarwinPersistenceMechanismsParser()
     serv_info = rdf_client.OSXServiceInformation(label="blah",
                                                  args=["/blah/test", "-v"])
     results = list(
         parser.Parse(serv_info, None, rdf_paths.PathSpec.PathType.OS))
     self.assertEqual(results[0].pathspec.path, "/blah/test")