Remove some additional instances of krbV from ipa-client

Make two krbV imports conditional. These aren't used during a client
install so should cause no problems.

Also fix the client installer to use the new env option in ipautil.run.
We weren't getting the krb5 configuration set in the environment because
we were overriding the environment to set the PATH.

ticket 136
This commit is contained in:
Rob Crittenden
2010-09-10 15:57:40 -04:00
parent a091be064d
commit 67a4549519
3 changed files with 16 additions and 9 deletions

View File

@@ -490,6 +490,7 @@ def main():
options = parse_options() options = parse_options()
logging_setup(options) logging_setup(options)
dnsok = True dnsok = True
env={"PATH":"/bin:/sbin:/usr/kerberos/bin:/usr/kerberos/sbin:/usr/bin:/usr/sbin"}
global fstore global fstore
fstore = sysrestore.FileStore('/var/lib/ipa-client/sysrestore') fstore = sysrestore.FileStore('/var/lib/ipa-client/sysrestore')
@@ -605,7 +606,7 @@ def main():
if configure_krb5_conf(fstore, cli_basedn, cli_realm, cli_domain, cli_server, dnsok, options, krb_name): if configure_krb5_conf(fstore, cli_basedn, cli_realm, cli_domain, cli_server, dnsok, options, krb_name):
print "Test kerberos configuration failed" print "Test kerberos configuration failed"
return 1 return 1
os.environ['KRB5_CONFIG'] = krb_name env['KRB5_CONFIG'] = krb_name
join_args = ["/usr/sbin/ipa-join", "-s", cli_server] join_args = ["/usr/sbin/ipa-join", "-s", cli_server]
if options.debug: if options.debug:
join_args.append("-d") join_args.append("-d")
@@ -627,7 +628,7 @@ def main():
else: else:
stdin = sys.stdin.readline() stdin = sys.stdin.readline()
(stderr, stdout, returncode) = run(["/usr/kerberos/bin/kinit", principal], raiseonerr=False, stdin=stdin) (stderr, stdout, returncode) = run(["kinit", principal], raiseonerr=False, stdin=stdin, env=env)
print "" print ""
if returncode != 0: if returncode != 0:
print stdout print stdout
@@ -644,7 +645,7 @@ def main():
join_args.append(password) join_args.append(password)
# Now join the domain # Now join the domain
(stdout, stderr, returncode) = run(join_args, raiseonerr=False) (stdout, stderr, returncode) = run(join_args, raiseonerr=False, env=env)
if returncode != 0: if returncode != 0:
print "Joining realm failed: %s" % stderr, print "Joining realm failed: %s" % stderr,
@@ -660,8 +661,7 @@ def main():
finally: finally:
if options.principal is not None: if options.principal is not None:
(stderr, stdout, returncode) = run(["/usr/kerberos/bin/kdestroy"], raiseonerr=False) (stderr, stdout, returncode) = run(["kdestroy"], raiseonerr=False, env=env)
del os.environ['KRB5_CONFIG']
os.remove(krb_name) os.remove(krb_name)
os.remove(krb_name + ".ipabkp") os.remove(krb_name + ".ipabkp")

View File

@@ -25,7 +25,6 @@ import os
import imp import imp
import logging import logging
import time import time
import krbV
import socket import socket
from types import NoneType from types import NoneType
@@ -49,7 +48,11 @@ def json_serialize(obj):
def get_current_principal(): def get_current_principal():
try: try:
# krbV isn't necessarily available on client machines, fail gracefully
import krbV
return unicode(krbV.default_context().default_ccache().principal().name) return unicode(krbV.default_context().default_ccache().principal().name)
except ImportError:
raise RuntimeError('python-krbV is not available.')
except krbV.Krb5Error: except krbV.Krb5Error:
#TODO: do a kinit? #TODO: do a kinit?
raise errors.CCacheError() raise errors.CCacheError()

View File

@@ -20,7 +20,6 @@
import ConfigParser import ConfigParser
from optparse import OptionParser, IndentedHelpFormatter from optparse import OptionParser, IndentedHelpFormatter
import krbV
import socket import socket
import ipapython.dnsclient import ipapython.dnsclient
import re import re
@@ -113,8 +112,13 @@ def __discover_config(discover_server = True):
rl = 0 rl = 0
try: try:
if not config.default_realm: if not config.default_realm:
krbctx = krbV.default_context() try:
config.default_realm = krbctx.default_realm # only import krbV when we need it
import krbV
krbctx = krbV.default_context()
config.default_realm = krbctx.default_realm
except ImportError:
pass
if not config.default_realm: if not config.default_realm:
return False return False