mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Clean up some problems discovered with pylint and pychecker
Much of this is formatting to make pylint happy but it also fixes some real bugs.
This commit is contained in:
parent
c781e8a57d
commit
8780751330
@ -992,6 +992,22 @@ class RemoteRetrieveError(ExecutionError):
|
|||||||
errno = 4016
|
errno = 4016
|
||||||
format = _('%(reason)s')
|
format = _('%(reason)s')
|
||||||
|
|
||||||
|
class SameGroupError(ExecutionError):
|
||||||
|
"""
|
||||||
|
**4017** Raised when adding a group as a member of itself
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
>>> raise SameGroupError()
|
||||||
|
Traceback (most recent call last):
|
||||||
|
...
|
||||||
|
SameGroupError: A group may not be added as a member of itself
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
errno = 4017
|
||||||
|
format = _('A group may not be added as a member of itself')
|
||||||
|
|
||||||
class BuiltinError(ExecutionError):
|
class BuiltinError(ExecutionError):
|
||||||
"""
|
"""
|
||||||
**4100** Base class for builtin execution errors (*4100 - 4199*).
|
**4100** Base class for builtin execution errors (*4100 - 4199*).
|
||||||
|
@ -15,10 +15,6 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
|
||||||
import ldap
|
|
||||||
import ldif
|
|
||||||
import re
|
|
||||||
import cStringIO
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
import ipapython.ipautil
|
import ipapython.ipautil
|
||||||
|
@ -15,6 +15,10 @@
|
|||||||
# the reference counting and SharedSocketClient provides an constructor
|
# the reference counting and SharedSocketClient provides an constructor
|
||||||
# and close() method that call incref() and decref() correctly.
|
# and close() method that call incref() and decref() correctly.
|
||||||
|
|
||||||
|
import socket
|
||||||
|
import errno
|
||||||
|
from httplib import UnimplementedFileMode
|
||||||
|
|
||||||
class SharedSocket:
|
class SharedSocket:
|
||||||
def __init__(self, sock):
|
def __init__(self, sock):
|
||||||
self.sock = sock
|
self.sock = sock
|
||||||
@ -91,13 +95,13 @@ class SSLFile(SharedSocketClient):
|
|||||||
break
|
break
|
||||||
L.append(s)
|
L.append(s)
|
||||||
avail += len(s)
|
avail += len(s)
|
||||||
all = "".join(L)
|
alldata = "".join(L)
|
||||||
if size is None:
|
if size is None:
|
||||||
self._buf = ''
|
self._buf = ''
|
||||||
return all
|
return alldata
|
||||||
else:
|
else:
|
||||||
self._buf = all[size:]
|
self._buf = alldata[size:]
|
||||||
return all[:size]
|
return alldata[:size]
|
||||||
|
|
||||||
def readline(self):
|
def readline(self):
|
||||||
L = [self._buf]
|
L = [self._buf]
|
||||||
@ -114,25 +118,25 @@ class SSLFile(SharedSocketClient):
|
|||||||
# loop exited because there is no more data
|
# loop exited because there is no more data
|
||||||
return "".join(L)
|
return "".join(L)
|
||||||
else:
|
else:
|
||||||
all = "".join(L)
|
alldata = "".join(L)
|
||||||
# XXX could do enough bookkeeping not to do a 2nd search
|
# XXX could do enough bookkeeping not to do a 2nd search
|
||||||
i = all.find("\n") + 1
|
i = alldata.find("\n") + 1
|
||||||
line = all[:i]
|
line = alldata[:i]
|
||||||
self._buf = all[i:]
|
self._buf = alldata[i:]
|
||||||
return line
|
return line
|
||||||
|
|
||||||
def readlines(self, sizehint=0):
|
def readlines(self, sizehint=0):
|
||||||
total = 0
|
total = 0
|
||||||
list = []
|
inlist = []
|
||||||
while True:
|
while True:
|
||||||
line = self.readline()
|
line = self.readline()
|
||||||
if not line:
|
if not line:
|
||||||
break
|
break
|
||||||
list.append(line)
|
inlist.append(line)
|
||||||
total += len(line)
|
total += len(line)
|
||||||
if sizehint and total >= sizehint:
|
if sizehint and total >= sizehint:
|
||||||
break
|
break
|
||||||
return list
|
return inlist
|
||||||
|
|
||||||
def fileno(self):
|
def fileno(self):
|
||||||
return self._sock.fileno()
|
return self._sock.fileno()
|
||||||
|
@ -57,7 +57,7 @@ def get_domain_name():
|
|||||||
try:
|
try:
|
||||||
config.init_config()
|
config.init_config()
|
||||||
domain_name = config.config.get_domain()
|
domain_name = config.config.get_domain()
|
||||||
except Exception, e:
|
except Exception:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return domain_name
|
return domain_name
|
||||||
@ -362,13 +362,13 @@ class GeneralizedTimeZone(datetime.tzinfo):
|
|||||||
if self.houroffset < 0:
|
if self.houroffset < 0:
|
||||||
self.minoffset *= -1
|
self.minoffset *= -1
|
||||||
|
|
||||||
def utcoffset(self, dt):
|
def utcoffset(self):
|
||||||
return datetime.timedelta(hours=self.houroffset, minutes=self.minoffset)
|
return datetime.timedelta(hours=self.houroffset, minutes=self.minoffset)
|
||||||
|
|
||||||
def dst(self, dt):
|
def dst(self):
|
||||||
return datetime.timedelta(0)
|
return datetime.timedelta(0)
|
||||||
|
|
||||||
def tzname(self, dt):
|
def tzname(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
@ -748,7 +748,7 @@ class AttributeValueCompleter:
|
|||||||
return self.default_value.get(self.lhs, None)
|
return self.default_value.get(self.lhs, None)
|
||||||
elif default_value_type is FunctionType:
|
elif default_value_type is FunctionType:
|
||||||
return self.default_value(self.lhs)
|
return self.default_value(self.lhs)
|
||||||
elif default_value_type is StringsType:
|
elif default_value_type is StringType:
|
||||||
return self.default_value
|
return self.default_value
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
@ -759,7 +759,7 @@ class AttributeValueCompleter:
|
|||||||
else:
|
else:
|
||||||
self.completions = self.lhs_names
|
self.completions = self.lhs_names
|
||||||
|
|
||||||
def complete(self, text, state):
|
def complete(self, state):
|
||||||
self.line_buffer= readline.get_line_buffer()
|
self.line_buffer= readline.get_line_buffer()
|
||||||
self.parse_input()
|
self.parse_input()
|
||||||
if not self.lhs_complete:
|
if not self.lhs_complete:
|
||||||
@ -905,7 +905,7 @@ class ItemCompleter:
|
|||||||
else:
|
else:
|
||||||
self.completions = self.items
|
self.completions = self.items
|
||||||
|
|
||||||
def complete(self, text, state):
|
def complete(self, state):
|
||||||
self.line_buffer= readline.get_line_buffer()
|
self.line_buffer= readline.get_line_buffer()
|
||||||
if state == 0:
|
if state == 0:
|
||||||
beg = readline.get_begidx()
|
beg = readline.get_begidx()
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
import httplib
|
import httplib
|
||||||
import getpass
|
import getpass
|
||||||
import socket
|
import socket
|
||||||
import errno
|
|
||||||
|
|
||||||
from nss.error import NSPRError
|
from nss.error import NSPRError
|
||||||
import nss.io as io
|
import nss.io as io
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import errno
|
|
||||||
import shutil
|
import shutil
|
||||||
import logging
|
import logging
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
@ -110,13 +109,13 @@ class FileStore:
|
|||||||
logging.debug(" -> Not backing up - '%s' doesn't exist", path)
|
logging.debug(" -> Not backing up - '%s' doesn't exist", path)
|
||||||
return
|
return
|
||||||
|
|
||||||
(reldir, file) = os.path.split(path)
|
(reldir, backupfile) = os.path.split(path)
|
||||||
|
|
||||||
filename = ""
|
filename = ""
|
||||||
for i in range(8):
|
for i in range(8):
|
||||||
h = "%02x" % self.random.randint(0,255)
|
h = "%02x" % self.random.randint(0,255)
|
||||||
filename += h
|
filename += h
|
||||||
filename += "-"+file
|
filename += "-"+backupfile
|
||||||
|
|
||||||
backup_path = os.path.join(self._path, filename)
|
backup_path = os.path.join(self._path, filename)
|
||||||
if os.path.exists(backup_path):
|
if os.path.exists(backup_path):
|
||||||
|
@ -17,12 +17,9 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
|
||||||
import string
|
|
||||||
import tempfile
|
import tempfile
|
||||||
import shutil
|
|
||||||
import os
|
import os
|
||||||
import pwd
|
import pwd
|
||||||
import socket
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import installutils
|
import installutils
|
||||||
@ -232,7 +229,6 @@ class BindInstance(service.Service):
|
|||||||
def uninstall(self):
|
def uninstall(self):
|
||||||
running = self.restore_state("running")
|
running = self.restore_state("running")
|
||||||
enabled = self.restore_state("enabled")
|
enabled = self.restore_state("enabled")
|
||||||
domain = self.restore_state("domain")
|
|
||||||
|
|
||||||
if not running is None:
|
if not running is None:
|
||||||
self.stop()
|
self.stop()
|
||||||
|
@ -575,7 +575,7 @@ class CAInstance(service.Service):
|
|||||||
def __restart_instance(self):
|
def __restart_instance(self):
|
||||||
try:
|
try:
|
||||||
self.restart()
|
self.restart()
|
||||||
except Exception, e:
|
except Exception:
|
||||||
# TODO: roll back here?
|
# TODO: roll back here?
|
||||||
logging.critical("Failed to restart the certificate server. See the installation log for details.")
|
logging.critical("Failed to restart the certificate server. See the installation log for details.")
|
||||||
|
|
||||||
@ -625,8 +625,6 @@ class CAInstance(service.Service):
|
|||||||
params['submit'] = 'submit'
|
params['submit'] = 'submit'
|
||||||
params['requestNotes'] = ''
|
params['requestNotes'] = ''
|
||||||
params = urllib.urlencode(params)
|
params = urllib.urlencode(params)
|
||||||
headers = {"Content-type": "application/x-www-form-urlencoded",
|
|
||||||
"Accept": "text/plain"}
|
|
||||||
|
|
||||||
# Now issue the RA certificate.
|
# Now issue the RA certificate.
|
||||||
args = [
|
args = [
|
||||||
@ -826,8 +824,6 @@ class CAInstance(service.Service):
|
|||||||
os.chown(self.ra_agent_pwd, pent.pw_uid, pent.pw_gid)
|
os.chown(self.ra_agent_pwd, pent.pw_uid, pent.pw_gid)
|
||||||
|
|
||||||
def __setup_sign_profile(self):
|
def __setup_sign_profile(self):
|
||||||
caconfig = "/var/lib/pki-ca/conf/CS.cfg"
|
|
||||||
|
|
||||||
# Tell the profile to automatically issue certs for RAs
|
# Tell the profile to automatically issue certs for RAs
|
||||||
installutils.set_directive('/var/lib/pki-ca/profiles/ca/caJarSigningCert.cfg', 'auth.instance_id', 'raCertAuth', quotes=False, separator='=')
|
installutils.set_directive('/var/lib/pki-ca/profiles/ca/caJarSigningCert.cfg', 'auth.instance_id', 'raCertAuth', quotes=False, separator='=')
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
import stat
|
|
||||||
|
|
||||||
from ipapython import ipautil
|
from ipapython import ipautil
|
||||||
|
|
||||||
@ -36,7 +35,7 @@ import certs
|
|||||||
import ldap
|
import ldap
|
||||||
from ipaserver import ipaldap
|
from ipaserver import ipaldap
|
||||||
from ipaserver.install import ldapupdate
|
from ipaserver.install import ldapupdate
|
||||||
from ipalib import util
|
from ipalib import util, errors
|
||||||
|
|
||||||
SERVER_ROOT_64 = "/usr/lib64/dirsrv"
|
SERVER_ROOT_64 = "/usr/lib64/dirsrv"
|
||||||
SERVER_ROOT_32 = "/usr/lib/dirsrv"
|
SERVER_ROOT_32 = "/usr/lib/dirsrv"
|
||||||
@ -319,7 +318,7 @@ class DsInstance(service.Service):
|
|||||||
dsdb.create_from_pkcs12(self.pkcs12_info[0], self.pkcs12_info[1])
|
dsdb.create_from_pkcs12(self.pkcs12_info[0], self.pkcs12_info[1])
|
||||||
server_certs = dsdb.find_server_certs()
|
server_certs = dsdb.find_server_certs()
|
||||||
if len(server_certs) == 0:
|
if len(server_certs) == 0:
|
||||||
raise RuntimeError("Could not find a suitable server cert in import in %s" % pkcs12_info[0])
|
raise RuntimeError("Could not find a suitable server cert in import in %s" % self.pkcs12_info[0])
|
||||||
|
|
||||||
# We only handle one server cert
|
# We only handle one server cert
|
||||||
nickname = server_certs[0][0]
|
nickname = server_certs[0][0]
|
||||||
@ -453,7 +452,7 @@ class DsInstance(service.Service):
|
|||||||
status = True
|
status = True
|
||||||
try:
|
try:
|
||||||
certdb.load_cacert(cacert_fname)
|
certdb.load_cacert(cacert_fname)
|
||||||
except ipalib.CalledProcessError, e:
|
except errors.CalledProcessError, e:
|
||||||
logging.critical("Error importing CA cert file named [%s]: %s" %
|
logging.critical("Error importing CA cert file named [%s]: %s" %
|
||||||
(cacert_fname, str(e)))
|
(cacert_fname, str(e)))
|
||||||
status = False
|
status = False
|
||||||
|
@ -19,13 +19,9 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import subprocess
|
|
||||||
import string
|
|
||||||
import tempfile
|
import tempfile
|
||||||
import logging
|
import logging
|
||||||
import pwd
|
import pwd
|
||||||
import fileinput
|
|
||||||
import sys
|
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
import service
|
import service
|
||||||
@ -105,7 +101,7 @@ class HTTPInstance(service.Service):
|
|||||||
if selinux:
|
if selinux:
|
||||||
try:
|
try:
|
||||||
# returns e.g. "httpd_can_network_connect --> off"
|
# returns e.g. "httpd_can_network_connect --> off"
|
||||||
(stdout, stderr) = ipautils.run(["/usr/sbin/getsebool",
|
(stdout, stderr) = ipautil.run(["/usr/sbin/getsebool",
|
||||||
"httpd_can_network_connect"])
|
"httpd_can_network_connect"])
|
||||||
self.backup_state("httpd_can_network_connect", stdout.split()[2])
|
self.backup_state("httpd_can_network_connect", stdout.split()[2])
|
||||||
except:
|
except:
|
||||||
@ -170,7 +166,7 @@ class HTTPInstance(service.Service):
|
|||||||
db.create_from_pkcs12(self.pkcs12_info[0], self.pkcs12_info[1], passwd="")
|
db.create_from_pkcs12(self.pkcs12_info[0], self.pkcs12_info[1], passwd="")
|
||||||
server_certs = db.find_server_certs()
|
server_certs = db.find_server_certs()
|
||||||
if len(server_certs) == 0:
|
if len(server_certs) == 0:
|
||||||
raise RuntimeError("Could not find a suitable server cert in import in %s" % pkcs12_info[0])
|
raise RuntimeError("Could not find a suitable server cert in import in %s" % self.pkcs12_info[0])
|
||||||
|
|
||||||
db.create_password_conf()
|
db.create_password_conf()
|
||||||
# We only handle one server cert
|
# We only handle one server cert
|
||||||
|
@ -25,7 +25,6 @@ import os
|
|||||||
import re
|
import re
|
||||||
import fileinput
|
import fileinput
|
||||||
import sys
|
import sys
|
||||||
import time
|
|
||||||
import struct
|
import struct
|
||||||
import fcntl
|
import fcntl
|
||||||
|
|
||||||
@ -217,28 +216,28 @@ def set_directive(filename, directive, value, quotes=True, separator=' '):
|
|||||||
"""
|
"""
|
||||||
valueset = False
|
valueset = False
|
||||||
fd = open(filename)
|
fd = open(filename)
|
||||||
file = []
|
newfile = []
|
||||||
for line in fd:
|
for line in fd:
|
||||||
if directive in line:
|
if directive in line:
|
||||||
valueset = True
|
valueset = True
|
||||||
if quotes:
|
if quotes:
|
||||||
file.append('%s%s"%s"\n' % (directive, separator, value))
|
newfile.append('%s%s"%s"\n' % (directive, separator, value))
|
||||||
else:
|
else:
|
||||||
file.append('%s%s%s\n' % (directive, separator, value))
|
newfile.append('%s%s%s\n' % (directive, separator, value))
|
||||||
else:
|
else:
|
||||||
file.append(line)
|
newfile.append(line)
|
||||||
fd.close()
|
fd.close()
|
||||||
if not valueset:
|
if not valueset:
|
||||||
if quotes:
|
if quotes:
|
||||||
file.append('%s%s"%s"\n' % (directive, separator, value))
|
newfile.append('%s%s"%s"\n' % (directive, separator, value))
|
||||||
else:
|
else:
|
||||||
file.append('%s%s%s\n' % (directive, separator, value))
|
newfile.append('%s%s%s\n' % (directive, separator, value))
|
||||||
|
|
||||||
fd = open(filename, "w")
|
fd = open(filename, "w")
|
||||||
fd.write("".join(file))
|
fd.write("".join(newfile))
|
||||||
fd.close()
|
fd.close()
|
||||||
|
|
||||||
def get_directive(filename, directive, strip_quotes=True, separator=' '):
|
def get_directive(filename, directive, separator=' '):
|
||||||
"""
|
"""
|
||||||
A rather inefficient way to get a configuration directive.
|
A rather inefficient way to get a configuration directive.
|
||||||
"""
|
"""
|
||||||
|
@ -17,8 +17,6 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
|
||||||
import subprocess
|
|
||||||
import string
|
|
||||||
import shutil
|
import shutil
|
||||||
import logging
|
import logging
|
||||||
import fileinput
|
import fileinput
|
||||||
@ -27,7 +25,6 @@ import sys
|
|||||||
import os
|
import os
|
||||||
import pwd
|
import pwd
|
||||||
import socket
|
import socket
|
||||||
import shutil
|
|
||||||
|
|
||||||
import service
|
import service
|
||||||
import installutils
|
import installutils
|
||||||
@ -46,7 +43,6 @@ from pyasn1.type import univ, namedtype
|
|||||||
import pyasn1.codec.ber.encoder
|
import pyasn1.codec.ber.encoder
|
||||||
import pyasn1.codec.ber.decoder
|
import pyasn1.codec.ber.decoder
|
||||||
import struct
|
import struct
|
||||||
import base64
|
|
||||||
|
|
||||||
KRBMKEY_DENY_ACI = """
|
KRBMKEY_DENY_ACI = """
|
||||||
(targetattr = "krbMKey")(version 3.0; acl "No external access"; deny (all) userdn != "ldap:///uid=kdc,cn=sysaccounts,cn=etc,$SUFFIX";)
|
(targetattr = "krbMKey")(version 3.0; acl "No external access"; deny (all) userdn != "ldap:///uid=kdc,cn=sysaccounts,cn=etc,$SUFFIX";)
|
||||||
@ -225,7 +221,7 @@ class KrbInstance(service.Service):
|
|||||||
msgid = self.conn.search("cn=mapping,cn=sasl,cn=config", ldap.SCOPE_ONELEVEL, "(objectclass=nsSaslMapping)")
|
msgid = self.conn.search("cn=mapping,cn=sasl,cn=config", ldap.SCOPE_ONELEVEL, "(objectclass=nsSaslMapping)")
|
||||||
res = self.conn.result(msgid)
|
res = self.conn.result(msgid)
|
||||||
for r in res[1]:
|
for r in res[1]:
|
||||||
mid = self.conn.delete_s(r[0])
|
self.conn.delete_s(r[0])
|
||||||
#except LDAPError, e:
|
#except LDAPError, e:
|
||||||
# logging.critical("Error during SASL mapping removal: %s" % str(e))
|
# logging.critical("Error during SASL mapping removal: %s" % str(e))
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
@ -301,7 +297,7 @@ class KrbInstance(service.Service):
|
|||||||
def __write_stash_from_ds(self):
|
def __write_stash_from_ds(self):
|
||||||
try:
|
try:
|
||||||
entry = self.conn.getEntry("cn=%s, cn=kerberos, %s" % (self.realm, self.suffix), ldap.SCOPE_SUBTREE)
|
entry = self.conn.getEntry("cn=%s, cn=kerberos, %s" % (self.realm, self.suffix), ldap.SCOPE_SUBTREE)
|
||||||
except errors.NotFound:
|
except errors.NotFound, e:
|
||||||
logging.critical("Could not find master key in DS")
|
logging.critical("Could not find master key in DS")
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
|
||||||
import shutil
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import service
|
import service
|
||||||
|
@ -27,11 +27,11 @@ from ipalib import util
|
|||||||
from ipalib import errors
|
from ipalib import errors
|
||||||
|
|
||||||
DIRMAN_CN = "cn=directory manager"
|
DIRMAN_CN = "cn=directory manager"
|
||||||
CACERT="/usr/share/ipa/html/ca.crt"
|
CACERT = "/usr/share/ipa/html/ca.crt"
|
||||||
# the default container used by AD for user entries
|
# the default container used by AD for user entries
|
||||||
WIN_USER_CONTAINER="cn=Users"
|
WIN_USER_CONTAINER = "cn=Users"
|
||||||
# the default container used by IPA for user entries
|
# the default container used by IPA for user entries
|
||||||
IPA_USER_CONTAINER="cn=users,cn=accounts"
|
IPA_USER_CONTAINER = "cn=users,cn=accounts"
|
||||||
PORT = 636
|
PORT = 636
|
||||||
TIMEOUT = 120
|
TIMEOUT = 120
|
||||||
|
|
||||||
@ -351,8 +351,10 @@ class ReplicationManager:
|
|||||||
def check_repl_init(self, conn, agmtdn):
|
def check_repl_init(self, conn, agmtdn):
|
||||||
done = False
|
done = False
|
||||||
hasError = 0
|
hasError = 0
|
||||||
attrlist = ['cn', 'nsds5BeginReplicaRefresh', 'nsds5replicaUpdateInProgress',
|
attrlist = ['cn', 'nsds5BeginReplicaRefresh',
|
||||||
'nsds5ReplicaLastInitStatus', 'nsds5ReplicaLastInitStart',
|
'nsds5replicaUpdateInProgress',
|
||||||
|
'nsds5ReplicaLastInitStatus',
|
||||||
|
'nsds5ReplicaLastInitStart',
|
||||||
'nsds5ReplicaLastInitEnd']
|
'nsds5ReplicaLastInitEnd']
|
||||||
entry = conn.getEntry(agmtdn, ldap.SCOPE_BASE, "(objectclass=*)", attrlist)
|
entry = conn.getEntry(agmtdn, ldap.SCOPE_BASE, "(objectclass=*)", attrlist)
|
||||||
if not entry:
|
if not entry:
|
||||||
|
@ -17,11 +17,13 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
|
||||||
import string
|
|
||||||
import xmlrpclib
|
import xmlrpclib
|
||||||
import re
|
import re
|
||||||
|
|
||||||
def realm_to_suffix(realm_name):
|
def realm_to_suffix(realm_name):
|
||||||
|
"""
|
||||||
|
Convert a kerberos realm into the IPA suffix.
|
||||||
|
"""
|
||||||
s = realm_name.split(".")
|
s = realm_name.split(".")
|
||||||
terms = ["dc=" + x.lower() for x in s]
|
terms = ["dc=" + x.lower() for x in s]
|
||||||
return ",".join(terms)
|
return ",".join(terms)
|
||||||
@ -37,32 +39,32 @@ class CIDict(dict):
|
|||||||
If you extend UserDict, isinstance(foo, dict) returns false.
|
If you extend UserDict, isinstance(foo, dict) returns false.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,default=None):
|
def __init__(self, default=None):
|
||||||
super(CIDict, self).__init__()
|
super(CIDict, self).__init__()
|
||||||
self._keys = {}
|
self._keys = {}
|
||||||
self.update(default or {})
|
self.update(default or {})
|
||||||
|
|
||||||
def __getitem__(self,key):
|
def __getitem__(self, key):
|
||||||
return super(CIDict,self).__getitem__(string.lower(key))
|
return super(CIDict, self).__getitem__(key.lower())
|
||||||
|
|
||||||
def __setitem__(self,key,value):
|
def __setitem__(self, key, value):
|
||||||
lower_key = string.lower(key)
|
lower_key = key.lower()
|
||||||
self._keys[lower_key] = key
|
self._keys[lower_key] = key
|
||||||
return super(CIDict,self).__setitem__(string.lower(key),value)
|
return super(CIDict, self).__setitem__(lower_key, value)
|
||||||
|
|
||||||
def __delitem__(self,key):
|
def __delitem__(self, key):
|
||||||
lower_key = string.lower(key)
|
lower_key = key.lower()
|
||||||
del self._keys[lower_key]
|
del self._keys[lower_key]
|
||||||
return super(CIDict,self).__delitem__(string.lower(key))
|
return super(CIDict, self).__delitem__(key.lower())
|
||||||
|
|
||||||
def update(self,dict):
|
def update(self, dict):
|
||||||
for key in dict.keys():
|
for key in dict.keys():
|
||||||
self[key] = dict[key]
|
self[key] = dict[key]
|
||||||
|
|
||||||
def has_key(self,key):
|
def has_key(self, key):
|
||||||
return super(CIDict, self).has_key(string.lower(key))
|
return super(CIDict, self).has_key(key.lower())
|
||||||
|
|
||||||
def get(self,key,failobj=None):
|
def get(self, key, failobj=None):
|
||||||
try:
|
try:
|
||||||
return self[key]
|
return self[key]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@ -74,7 +76,7 @@ class CIDict(dict):
|
|||||||
def items(self):
|
def items(self):
|
||||||
result = []
|
result = []
|
||||||
for k in self._keys.values():
|
for k in self._keys.values():
|
||||||
result.append((k,self[k]))
|
result.append((k, self[k]))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def copy(self):
|
def copy(self):
|
||||||
@ -89,7 +91,7 @@ class CIDict(dict):
|
|||||||
def iterkeys(self):
|
def iterkeys(self):
|
||||||
return self.copy().iterkeys()
|
return self.copy().iterkeys()
|
||||||
|
|
||||||
def setdefault(self,key,value=None):
|
def setdefault(self, key, value=None):
|
||||||
try:
|
try:
|
||||||
return self[key]
|
return self[key]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
@ -107,11 +109,11 @@ class CIDict(dict):
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
def popitem(self):
|
def popitem(self):
|
||||||
(lower_key,value) = super(CIDict,self).popitem()
|
(lower_key, value) = super(CIDict, self).popitem()
|
||||||
key = self._keys[lower_key]
|
key = self._keys[lower_key]
|
||||||
del self._keys[lower_key]
|
del self._keys[lower_key]
|
||||||
|
|
||||||
return (key,value)
|
return (key, value)
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -148,7 +150,7 @@ def wrap_binary_data(data):
|
|||||||
return retval
|
return retval
|
||||||
elif isinstance(data, dict):
|
elif isinstance(data, dict):
|
||||||
retval = {}
|
retval = {}
|
||||||
for (k,v) in data.iteritems():
|
for (k, v) in data.iteritems():
|
||||||
retval[k] = wrap_binary_data(v)
|
retval[k] = wrap_binary_data(v)
|
||||||
return retval
|
return retval
|
||||||
else:
|
else:
|
||||||
@ -170,7 +172,7 @@ def unwrap_binary_data(data):
|
|||||||
return retval
|
return retval
|
||||||
elif isinstance(data, dict):
|
elif isinstance(data, dict):
|
||||||
retval = {}
|
retval = {}
|
||||||
for (k,v) in data.iteritems():
|
for (k, v) in data.iteritems():
|
||||||
retval[k] = unwrap_binary_data(v)
|
retval[k] = unwrap_binary_data(v)
|
||||||
return retval
|
return retval
|
||||||
else:
|
else:
|
||||||
@ -183,19 +185,19 @@ def get_gsserror(e):
|
|||||||
try:
|
try:
|
||||||
primary = e[0]
|
primary = e[0]
|
||||||
secondary = e[1]
|
secondary = e[1]
|
||||||
except:
|
except Exception:
|
||||||
primary = e[0][0]
|
primary = e[0][0]
|
||||||
secondary = e[0][1]
|
secondary = e[0][1]
|
||||||
|
|
||||||
return (primary[0], secondary[0])
|
return (primary[0], secondary[0])
|
||||||
|
|
||||||
def utf8_encode_value(value):
|
def utf8_encode_value(value):
|
||||||
if isinstance(value,unicode):
|
if isinstance(value, unicode):
|
||||||
return value.encode('utf-8')
|
return value.encode('utf-8')
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def utf8_encode_values(values):
|
def utf8_encode_values(values):
|
||||||
if isinstance(values,list) or isinstance(values,tuple):
|
if isinstance(values, list) or isinstance(values, tuple):
|
||||||
return map(utf8_encode_value, values)
|
return map(utf8_encode_value, values)
|
||||||
else:
|
else:
|
||||||
return utf8_encode_value(values)
|
return utf8_encode_value(values)
|
||||||
|
@ -28,16 +28,12 @@ Backend plugin for LDAP.
|
|||||||
|
|
||||||
import copy
|
import copy
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
import socket
|
import socket
|
||||||
import string
|
import string
|
||||||
|
|
||||||
import krbV
|
|
||||||
import ldap as _ldap
|
import ldap as _ldap
|
||||||
import ldap.filter as _ldap_filter
|
import ldap.filter as _ldap_filter
|
||||||
import ldap.sasl as _ldap_sasl
|
import ldap.sasl as _ldap_sasl
|
||||||
from ldap.controls import LDAPControl
|
|
||||||
from ldap.ldapobject import SimpleLDAPObject
|
|
||||||
# for backward compatibility
|
# for backward compatibility
|
||||||
from ldap.functions import explode_dn
|
from ldap.functions import explode_dn
|
||||||
|
|
||||||
|
@ -18,11 +18,8 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
import ldap
|
import ldap
|
||||||
import string
|
|
||||||
import re
|
|
||||||
from ipalib.request import context
|
from ipalib.request import context
|
||||||
from ipaserver import ipaldap
|
from ipaserver import ipaldap
|
||||||
import ipautil
|
|
||||||
from ipalib import errors
|
from ipalib import errors
|
||||||
from ipalib import api
|
from ipalib import api
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user