def login(systemId=None): server = rpcServer.getServer() log = rhnLog.initLog() # send up the capabality info headerlist = clientCaps.caps.headerFormat() for (headerName, value) in headerlist: server.add_header(headerName, value) if systemId == None: systemId = getSystemId() if not systemId: return None maybeUpdateVersion() log.log_me("logging into up2date server") # the list of caps the client needs caps = capabilities.Capabilities() global loginInfo, loginTime, loginOffset try: loginInfo = rpcServer.doCall(server.up2date.login, systemId) loginTime = time.time() loginOffset = float(loginInfo['X-RHN-Auth-Expire-Offset']) - 60.0 except xmlrpclib.Fault, f: if abs(f.faultCode) == 49: # print f.faultString raise rhnErrors.AbuseError(f.faultString) else: raise f
def doCall(method, *args, **kwargs): log = rhnLog.initLog() cfg = config.initUp2dateConfig() ret = None attempt_count = 1 attempts = cfg["networkRetries"] or 5 while 1: failure = 0 ret = None try: ret = apply(method, args, kwargs) except KeyboardInterrupt: raise rhnErrors.CommunicationError(_( "Connection aborted by the user")) # if we get a socket error, keep tryingx2 except (socket.error, socket.sslerror), e: log.log_me("A socket error occurred: %s, attempt #%s" % ( e, attempt_count)) if attempt_count >= attempts: if len(e.args) > 1: raise rhnErrors.CommunicationError(e.args[1]) else: raise rhnErrors.CommunicationError(e.args[0]) else: failure = 1 except httplib.IncompleteRead: print "httplib.IncompleteRead" raise rhnErrors.CommunicationError("httplib.IncompleteRead")
def updateLoginInfo(): log = rhnLog.initLog() log.log_me("updating login info") global loginInfo loginInfo = None try: login() except: pass if loginInfo is None: raise rhnErrors.AuthenticationError("Unable to authenticate") return loginInfo
def __repr__(self): msg = _("GPG is not installed properly.") log = rhnLog.initLog() log.log_me(msg) return msg
def __repr__(self): msg = _("Delay error from server. The message was:\n") + self.errmsg log = rhnLog.initLog() log.log_me(msg) return msg
def __repr__(self): msg = _("Error communicating with server. "\ "The message was:\n") + self.errmsg log = rhnLog.initLog() log.log_me(msg) return msg
def __init__(self, errmsg): self.errmsg = errmsg self.log = rhnLog.initLog()
def __repr__(self): log = rhnLog.initLog() log.log_me(self.errmsg) return self.errmsg
def __repr__(self): msg = _("File Skip List or config file overwrite error. "\ "The message was:\n") + self.errmsg log = rhnLog.initLog() log.log_me(msg) return msg
def __repr__(self): msg = _("Package Skip List error. The message was:\n") + self.errmsg log = rhnLog.initLog() log.log_me(msg) return msg
def __repr__(self): msg = _("The package %s failed its gpg signature verification. "\ "This means the package is corrupt." % self.errmsg) log = rhnLog.initLog() log.log_me(msg) return msg
def __repr__(self): msg = _("Disk error. The message was:\n") + self.errmsg log = rhnLog.initLog() log.log_me(msg) return msg
def __repr__(self): msg = _("File Not Found: \n") + self.errmsg log = rhnLog.initLog() log.log_me(msg) return msg
def __repr__(self): log = rhnLog.initLog() msg = _("Password error. The message was:\n") + self.errmsg log.log_me(msg) return msg
def __repr__(self): msg = _("RPM dependency error. The message was:\n") + self.errmsg log = rhnLog.initLog() log.log_me(msg) return msg
def __repr__(self): msg = _("Could not remove package \"%s\". "\ "It was on the RemoveSkipList") % self.errmsg log = rhnLog.initLog() log.log_me(msg) return msg
def getServer(refreshCallback=None): log = rhnLog.initLog() cfg = config.initUp2dateConfig() # Where do we keep the CA certificate for RHNS? # The servers we're talking to need to have their certs # signed by one of these CA. ca = cfg["sslCACert"] if type(ca) == type(""): ca = [ca] rhns_ca_certs = ca or ["%s/usr/share/rhn/RHNS-CA-CERT" % config.PREFIX] if cfg["enableProxy"]: proxyHost = rhnUtils.getProxySetting() else: proxyHost = None if hasSSL(): serverUrl = cfg["serverURL"] else: serverUrl = cfg["noSSLServerURL"] proxyUser = None proxyPassword = None if cfg["enableProxyAuth"]: proxyUser = cfg["proxyUser"] or None proxyPassword = cfg["proxyPassword"] or None lang = None for env in 'LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG': if os.environ.has_key(env): if not os.environ[env]: # sometimes unset continue lang = string.split(os.environ[env], ':')[0] lang = string.split(lang, '.')[0] break s = rpclib.Server(serverUrl, refreshCallback=refreshCallback, proxy=proxyHost, username=proxyUser, password=proxyPassword) s.add_header("X-Up2date-Version", rhnUtils.version()) if lang: s.setlang(lang) # require RHNS-CA-CERT file to be able to authenticate the SSL connections for rhns_ca_cert in rhns_ca_certs: if not os.access(rhns_ca_cert, os.R_OK): log.log_me("ERROR: can not find RHNS CA file: %s" % rhns_ca_cert) sys.exit(-1) # force the validation of the SSL cert s.add_trusted_cert(rhns_ca_cert) clientCaps.loadLocalCaps() # send up the capabality info headerlist = clientCaps.caps.headerFormat() for (headerName, value) in headerlist: s.add_header(headerName, value) return s
def __repr__(self): msg = _("GPG keyring does not include the Red Hat, Inc. "\ "public package-signing key") log = rhnLog.initLog() log.log_me(msg) return msg
def __repr__(self): msg = _("Package %s does not have a GPG signature.\n") % self.errmsg log = rhnLog.initLog() log.log_me(msg) return msg
def __repr__(self): msg = _("Package %s has a unknown GPG signature.\n") % self.errmsg log = rhnLog.initLog() log.log_me(msg) return msg
def __repr__(self): msg = _("There was a fatal error installing the package:\n") msg = msg + self.errmsg log = rhnLog.initLog() log.log_me(msg) return msg
def __repr__(self): msg = _("RPM file conflict error. The message was:\n") + self.errmsg log = rhnLog.initLog() log.log_me(msg) return msg