예제 #1
0
    def UnlockSubject(self, subject, transid, token):
        """Unlocks subject using transaction id."""
        request = rdfvalue.DataStoreRequest(subject=[subject])
        if token:
            request.token = token
        blob = rdfvalue.DataBlob(string=transid)
        value = rdfvalue.DataStoreValue(value=blob)
        request.values.Append(value)

        # We do not care about the server response.
        typ = rdfvalue.DataStoreCommand.Command.UNLOCK_SUBJECT
        self._MakeSyncRequest(request, typ)

        return transid
예제 #2
0
  def ExtendSubjectLock(self, subject, transid, lease_time, token):
    """Extends lock of subject."""
    request = rdfvalue.DataStoreRequest(subject=[subject])
    specific = rdfvalue.TimestampSpec.Type.SPECIFIC_TIME
    request.timestamp = rdfvalue.TimestampSpec(start=lease_time, type=specific)
    if token:
      request.token = token
    blob = rdfvalue.DataBlob(string=transid)
    value = rdfvalue.DataStoreValue(value=blob)
    request.values.Append(value)

    typ = rdfvalue.DataStoreCommand.Command.EXTEND_SUBJECT
    response = self._MakeSyncRequest(request, typ)

    if not response.results:
      return None
    result = response.results[0]
    if not result.values:
      return None
    value = result.values[0].value.string
    return transid if transid == value else None
예제 #3
0
파일: store.py 프로젝트: zzzzpaul/grr
 def _AddTransactionId(self, response, subject, transid):
     blob = rdfvalue.DataBlob(string=transid)
     value = rdfvalue.DataStoreValue(value=blob)
     response.results.Append(subject=subject, values=[value])