Port from python-krbV to python-gssapi

python-krbV library is deprecated and doesn't work with python 3. Replacing all
it's usages with python-gssapi.

- Removed Backend.krb and KRB5_CCache classes
  They were wrappers around krbV classes that cannot really work without them
- Added few utility functions for querying GSSAPI credentials
  in krb_utils module. They provide replacements for KRB5_CCache.
- Merged two kinit_keytab functions
- Changed ldap plugin connection defaults to match ipaldap
- Unified getting default realm
  Using api.env.realm instead of krbV call

Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Reviewed-By: Robbie Harwood <rharwood@redhat.com>
Reviewed-By: Simo Sorce <ssorce@redhat.com>
This commit is contained in:
Michael Simacek authored and Jan Cholasta committed 2015-08-26 09:41:36 +02:00
1 parent aebb72e1fb
commit aad73fad60
37 files changed
+249 -649

No files matched your search

+7 -9
View File
@@ -21,14 +21,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import gssapi
from ipaserver.install import adtrustinstance
from ipaserver.install.installutils import *
from ipaserver.install import service
from ipapython import version
from ipapython import ipautil, sysrestore, ipaldap
from ipalib import api, errors, util
from ipalib import api, errors, krb_utils
from ipapython.config import IPAOptionParser
import krbV
from ipaplatform.paths import paths
from ipapython.ipa_log_manager import *
from ipapython.dn import DN
@@ -302,21 +302,19 @@ def main():
print "Proceeding with credentials that existed before"
try:
ctx = krbV.default_context()
ccache = ctx.default_ccache()
principal = ccache.principal()
except krbV.Krb5Error as e:
sys.exit("Must have Kerberos credentials to setup AD trusts on server")
principal = krb_utils.get_principal()
except gssapi.exceptions.GSSError as e:
sys.exit("Must have Kerberos credentials to setup AD trusts on server: %s" % e.message)
try:
api.Backend.ldap2.connect(ccache)
api.Backend.ldap2.connect()
except errors.ACIError as e:
sys.exit("Outdated Kerberos credentials. Use kdestroy and kinit to update your ticket")
except errors.DatabaseError as e:
sys.exit("Cannot connect to the LDAP database. Please check if IPA is running")
try:
user = api.Command.user_show(unicode(principal[0]))['result']
user = api.Command.user_show(principal.partition('@')[0].partition('/')[0])['result']
group = api.Command.group_show(u'admins')['result']
if not (user['uid'][0] in group['member_user'] and
group['cn'][0] in user['memberof_group']):
+2 -3
View File
@@ -22,12 +22,11 @@
import sys
import os
import krbV
from ipapython.ipa_log_manager import *
from ipaserver.install import (replication, installutils, bindinstance,
cainstance, certs)
from ipalib import api, errors, util
from ipalib import api, errors
from ipalib.constants import CACERT
from ipapython import ipautil, ipaldap, version, dogtag
from ipapython.dn import DN
@@ -407,7 +406,7 @@ def main():
api.finalize()
dirman_passwd = None
realm = krbV.default_context().default_realm
realm = api.env.realm
if options.host:
host = options.host
+3 -4
View File
@@ -20,7 +20,7 @@
import sys
import os
import re, krbV
import re
import traceback
from urllib2 import urlparse
import ldap
@@ -1379,7 +1379,7 @@ def main():
api.finalize()
dirman_passwd = None
realm = krbV.default_context().default_realm
realm = api.env.realm
if options.host:
host = options.host
@@ -1404,8 +1404,7 @@ def main():
api.Backend.ldap2.connect(bind_dn=DN(('cn', 'Directory Manager')),
bind_pw=options.dirman_passwd)
else:
ccache = krbV.default_context().default_ccache()
api.Backend.ldap2.connect(ccache=ccache)
api.Backend.ldap2.connect()
if args[0] == "list":
replica = None