mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-12 09:11:55 -06:00
Fix ipa command running in server_context=True
Make the LDAP host and port environment variables More changes so that commands have a shell return value lite-xmlrpc no longer hardcodes the kerberos credentials cache location
This commit is contained in:
parent
f8e8ac8503
commit
06a82bf4b6
@ -311,9 +311,25 @@ class CLI(object):
|
||||
break
|
||||
except errors.ValidationError, e:
|
||||
error = e.error
|
||||
if self.api.env.server_context:
|
||||
try:
|
||||
import krbV
|
||||
import ldap
|
||||
from ipa_server import conn
|
||||
from ipa_server.servercore import context
|
||||
krbccache = krbV.default_context().default_ccache().name
|
||||
context.conn = conn.IPAConn(self.api.env.ldaphost, self.api.env.ldapport, krbccache)
|
||||
except ImportError:
|
||||
print >> sys.stderr, "There was a problem importing a Python module: %s" % sys.exc_value
|
||||
return 2
|
||||
except ldap.LDAPError, e:
|
||||
print >> sys.stderr, "There was a problem connecting to the LDAP server: %s" % e[0].get('desc')
|
||||
return 2
|
||||
ret = cmd(**kw)
|
||||
if callable(cmd.output_for_cli):
|
||||
cmd.output_for_cli(ret)
|
||||
return cmd.output_for_cli(ret)
|
||||
else:
|
||||
return 0
|
||||
|
||||
def parse(self, cmd, argv):
|
||||
parser = self.build_parser(cmd)
|
||||
|
@ -146,6 +146,8 @@ def set_default_env(env):
|
||||
server_context = EnvProp(bool, True),
|
||||
server = LazyIter(basestring, get_servers),
|
||||
verbose = EnvProp(bool, False),
|
||||
ldaphost = EnvProp(basestring, 'localhost'),
|
||||
ldapport = EnvProp(int, 389),
|
||||
)
|
||||
|
||||
env.update(default)
|
||||
|
@ -37,6 +37,7 @@ from ipa_server.servercore import context
|
||||
import ipalib.load_plugins
|
||||
from ipalib.util import xmlrpc_unmarshal
|
||||
import traceback
|
||||
import krbV
|
||||
|
||||
|
||||
PORT=8888
|
||||
@ -70,10 +71,7 @@ class LoggingSimpleXMLRPCRequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHa
|
||||
not be called.
|
||||
"""
|
||||
|
||||
# this is fine for our test server
|
||||
# uid = commands.getoutput('/usr/bin/id -u')
|
||||
uid = "500"
|
||||
krbccache = "FILE:/tmp/krb5cc_" + uid
|
||||
krbccache = krbV.default_context().default_ccache().name
|
||||
|
||||
func = None
|
||||
try:
|
||||
@ -84,7 +82,7 @@ class LoggingSimpleXMLRPCRequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHa
|
||||
raise Exception('method "%s" is not supported' % method)
|
||||
(args, kw) = xmlrpc_unmarshal(*params)
|
||||
# FIXME: don't hardcode host and port
|
||||
context.conn = conn.IPAConn("localhost", 389, krbccache)
|
||||
context.conn = conn.IPAConn(api.env.ldaphost, api.env.ldapport, krbccache)
|
||||
logger.info("calling %s" % method)
|
||||
return func(*args, **kw)
|
||||
finally:
|
||||
|
Loading…
Reference in New Issue
Block a user