Esempio n. 1
0
def recv(rfile):
    # Compute the size of an unsigned int
    n = struct.calcsize("L")
    # Read the first bytes to figure out the size
    buff = readSocket(rfile, n)
    if len(buff) != n:
        # Incomplete read
        raise CommunicationError(0,
            "Expected %d bytes; got only %d" % (n, len(buff)))

    n,  = struct.unpack("!L", buff)

    if n > 65536:
        # The buffer to be read is too big
        raise CommunicationError(1, "Block too big: %s" % len(buff))

    buff = readSocket(rfile, n)
    if len(buff) != n:
        # Incomplete read
        raise CommunicationError(0,
            "Expected %d bytes; got only %d" % (n, len(buff)))

    return loads(buff)
Esempio n. 2
0
        if self.__systemid_mtime == mtime \
        and self.__systemid and self.__serverid:
            # nothing to do
            return 0

        # get systemid
        try:
            ProxyAuth.__systemid = open(ProxyAuth.__systemid_filename, 'r').read()
        except IOError, e:
            log_error("unable to read %s" % ProxyAuth.__systemid_filename)
            raise rhnFault(1000,
                      _("RHN Proxy error (RHN Proxy systemid has wrong permissions?). "
                        "Please contact your system administrator."))

        # get serverid
        sysid, cruft = loads(ProxyAuth.__systemid)
        ProxyAuth.__serverid = sysid[0]['system_id'][3:]

        log_debug(7, 'SystemId: "%s[...snip  snip...]%s"' \
          % (ProxyAuth.__systemid[:20], ProxyAuth.__systemid[-20:]))
        log_debug(7, 'ServerId: %s' % ProxyAuth.__serverid)

        # ids were updated
        return 1

    def check_cached_token(self, forceRefresh=0):
        """ check cache, login if need be, and cache.
        """
        log_debug(3)
        oldToken = self.get_cached_token()
        token = oldToken