diff --git a/builder/kojid b/builder/kojid index 726d5354..5149ce5b 100755 --- a/builder/kojid +++ b/builder/kojid @@ -24,7 +24,7 @@ try: import krbV except ImportError: # pragma: no cover - pass + krbV = None import koji import koji.plugin import koji.util @@ -5782,7 +5782,7 @@ if __name__ == "__main__": quit("Error: Unable to log in. Bad credentials?") except xmlrpclib.ProtocolError: quit("Error: Unable to connect to server %s" % (options.server)) - elif 'krbV' in sys.modules: + elif krbV and 'krbV' in sys.modules: krb_principal = options.krb_principal if krb_principal is None: krb_principal = options.host_principal_format % socket.getfqdn() diff --git a/plugins/hub/messagebus.py b/plugins/hub/messagebus.py index 1e208c4c..a45561c8 100644 --- a/plugins/hub/messagebus.py +++ b/plugins/hub/messagebus.py @@ -14,7 +14,10 @@ import qpid.messaging.transports from ssl import wrap_socket import socket import os -import krbV +try: + import krbV +except ImportError: # pragma: no cover + krbV = None MAX_KEY_LENGTH = 255 CONFIG_FILE = '/etc/koji-hub/plugins/messagebus.conf' @@ -105,6 +108,9 @@ def get_sender(): url += config.get('broker', 'username') + '/' url += config.get('broker', 'password') + '@' elif auth == 'GSSAPI': + if krbV is None: + # TODO: port this to python-gssapi + raise PluginError('krbV module not installed') ccname = 'MEMORY:messagebus' os.environ['KRB5CCNAME'] = ccname ctx = krbV.default_context() diff --git a/util/koji-gc b/util/koji-gc index 89cc4925..ae48648b 100755 --- a/util/koji-gc +++ b/util/koji-gc @@ -9,7 +9,7 @@ try: import krbV except ImportError: # pragma: no cover - pass + krbV = None import koji from koji.util import LazyDict, LazyValue import koji.policy @@ -345,7 +345,7 @@ def ensure_connection(session): warn(_("WARNING: The server is at API version %d and the client is at %d" % (ret, koji.API_VERSION))) def has_krb_creds(): - if 'krbV' not in sys.modules: + if krbV is None or 'krbV' not in sys.modules: return False try: ctx = krbV.default_context() diff --git a/util/koji-shadow b/util/koji-shadow index a958c9cb..d53f19d6 100755 --- a/util/koji-shadow +++ b/util/koji-shadow @@ -25,7 +25,7 @@ try: import krbV except ImportError: # pragma: no cover - pass + krbV = None import koji import ConfigParser import fnmatch @@ -320,7 +320,7 @@ def activate_session(session): elif options.user: #authenticate using user/password session.login() - elif 'krbV' in sys.modules: + elif krbV and 'krbV' in sys.modules: try: if options.keytab and options.principal: session.krb_login(principal=options.principal, keytab=options.keytab, proxyuser=options.runas) diff --git a/vm/kojivmd b/vm/kojivmd index 41789ec4..d2c1d9db 100755 --- a/vm/kojivmd +++ b/vm/kojivmd @@ -48,7 +48,7 @@ from optparse import OptionParser try: import krbV except ImportError: # pragma: no cover - pass + krbV = None # Register libvirt handler @@ -1099,7 +1099,7 @@ if __name__ == "__main__": quit("Error: Unable to log in. Bad credentials?") except xmlrpclib.ProtocolError: quit("Error: Unable to connect to server %s" % (options.server)) - elif 'krbV' in sys.modules: + elif krbV and 'krbV' in sys.modules: krb_principal = options.krb_principal if krb_principal is None: krb_principal = options.host_principal_format % socket.getfqdn()