mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Fix assorted bugs found by pylint
This commit is contained in:
parent
27da394c44
commit
ab2ca8022e
@ -439,8 +439,8 @@ def main():
|
|||||||
|
|
||||||
# We ned to ldap_enable the CA now that DS is up and running
|
# We ned to ldap_enable the CA now that DS is up and running
|
||||||
if CA:
|
if CA:
|
||||||
CA.ldap_enable('CA', host_name, dm_password,
|
CA.ldap_enable('CA', config.host_name, config.dirman_password,
|
||||||
util.realm_to_suffix(self.realm_name))
|
util.realm_to_suffix(config.realm_name))
|
||||||
|
|
||||||
install_krb(config, setup_pkinit=options.setup_pkinit)
|
install_krb(config, setup_pkinit=options.setup_pkinit)
|
||||||
install_http(config)
|
install_http(config)
|
||||||
|
@ -141,7 +141,7 @@ def main():
|
|||||||
set_ds_cert_name(server_cert[0], dm_password)
|
set_ds_cert_name(server_cert[0], dm_password)
|
||||||
|
|
||||||
if options.http:
|
if options.http:
|
||||||
dirname = httpinstance.NSS_DIR
|
dirname = certs.NSS_DIR
|
||||||
server_cert = import_cert(dirname, pkcs12_fname, options.http_pin, "")
|
server_cert = import_cert(dirname, pkcs12_fname, options.http_pin, "")
|
||||||
installutils.set_directive(httpinstance.NSS_CONF, 'NSSNickname', server_cert[0])
|
installutils.set_directive(httpinstance.NSS_CONF, 'NSSNickname', server_cert[0])
|
||||||
|
|
||||||
|
@ -620,17 +620,6 @@ class help(frontend.Local):
|
|||||||
if module == __name__:
|
if module == __name__:
|
||||||
return
|
return
|
||||||
return module.split('.')[-1]
|
return module.split('.')[-1]
|
||||||
# get representation in the form of 'base_module.bare_module.command()'
|
|
||||||
r = repr(cmd_plugin_proxy)
|
|
||||||
# skip base module part and the following dot
|
|
||||||
start = r.find(self._PLUGIN_BASE_MODULE)
|
|
||||||
if start == -1:
|
|
||||||
# command module isn't a plugin module, it's a builtin
|
|
||||||
return None
|
|
||||||
start += len(self._PLUGIN_BASE_MODULE) + 1
|
|
||||||
# parse bare module name
|
|
||||||
end = r.find('.', start)
|
|
||||||
return r[start:end]
|
|
||||||
|
|
||||||
def _get_module_topic(self, module_name):
|
def _get_module_topic(self, module_name):
|
||||||
if not sys.modules[module_name]:
|
if not sys.modules[module_name]:
|
||||||
|
@ -693,13 +693,13 @@ class Command(HasParam):
|
|||||||
If the client minor version is less than or equal to the server
|
If the client minor version is less than or equal to the server
|
||||||
then let the request proceed.
|
then let the request proceed.
|
||||||
"""
|
"""
|
||||||
|
server_ver = version.LooseVersion(API_VERSION)
|
||||||
ver = version.LooseVersion(client_version)
|
ver = version.LooseVersion(client_version)
|
||||||
if len(ver.version) < 2:
|
if len(ver.version) < 2:
|
||||||
raise VersionError(cver=ver.version, sver=server_ver.version, server= self.env.xmlrpc_uri)
|
raise VersionError(cver=ver.version, sver=server_ver.version, server= self.env.xmlrpc_uri)
|
||||||
client_major = ver.version[0]
|
client_major = ver.version[0]
|
||||||
client_minor = ver.version[1]
|
client_minor = ver.version[1]
|
||||||
|
|
||||||
server_ver = version.LooseVersion(API_VERSION)
|
|
||||||
server_major = server_ver.version[0]
|
server_major = server_ver.version[0]
|
||||||
server_minor = server_ver.version[1]
|
server_minor = server_ver.version[1]
|
||||||
|
|
||||||
|
@ -1532,6 +1532,13 @@ class AccessTime(Str):
|
|||||||
if value < 1 or value > 52:
|
if value < 1 or value > 52:
|
||||||
raise ValueError('week of the year out of range')
|
raise ValueError('week of the year out of range')
|
||||||
|
|
||||||
|
def _check_doty(self, t):
|
||||||
|
if not t.isnumeric():
|
||||||
|
raise ValueError('day of the year non-numeric')
|
||||||
|
value = int(t)
|
||||||
|
if value < 1 or value > 365:
|
||||||
|
raise ValueError('day of the year out of range')
|
||||||
|
|
||||||
def _check_month_num(self, t):
|
def _check_month_num(self, t):
|
||||||
if not t.isnumeric():
|
if not t.isnumeric():
|
||||||
raise ValueError('month number non-numeric')
|
raise ValueError('month number non-numeric')
|
||||||
|
@ -83,8 +83,6 @@ if __name__ == '__main__':
|
|||||||
# Read PEM request from stdin and print out its components
|
# Read PEM request from stdin and print out its components
|
||||||
|
|
||||||
csrlines = sys.stdin.readlines()
|
csrlines = sys.stdin.readlines()
|
||||||
csrlines = fp.readlines()
|
|
||||||
fp.close()
|
|
||||||
csr = ''.join(csrlines)
|
csr = ''.join(csrlines)
|
||||||
|
|
||||||
csr = load_certificate_request(csr)
|
csr = load_certificate_request(csr)
|
||||||
|
@ -369,7 +369,7 @@ class dnsrecord(LDAPObject):
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
def is_pkey_zone_record(*keys):
|
def is_pkey_zone_record(self, *keys):
|
||||||
idnsname = keys[-1]
|
idnsname = keys[-1]
|
||||||
if idnsname == '@' or idnsname == ('%s.' % keys[-2]):
|
if idnsname == '@' or idnsname == ('%s.' % keys[-2]):
|
||||||
return True
|
return True
|
||||||
|
@ -160,7 +160,7 @@ class group_del(LDAPDelete):
|
|||||||
def_primary_group = config.get('ipadefaultprimarygroup', '')
|
def_primary_group = config.get('ipadefaultprimarygroup', '')
|
||||||
def_primary_group_dn = group_dn = self.obj.get_dn(def_primary_group)
|
def_primary_group_dn = group_dn = self.obj.get_dn(def_primary_group)
|
||||||
if dn == def_primary_group_dn:
|
if dn == def_primary_group_dn:
|
||||||
raise errors.DefaultGroup()
|
raise errors.DefaultGroupError()
|
||||||
group_attrs = self.obj.methods.show(
|
group_attrs = self.obj.methods.show(
|
||||||
self.obj.get_primary_key_from_dn(dn), all=True
|
self.obj.get_primary_key_from_dn(dn), all=True
|
||||||
)['result']
|
)['result']
|
||||||
|
@ -437,7 +437,6 @@ class host_del(LDAPDelete):
|
|||||||
break
|
break
|
||||||
if not match:
|
if not match:
|
||||||
raise errors.NotFound(reason=_('DNS zone %(zone)s not found' % dict(zone=domain)))
|
raise errors.NotFound(reason=_('DNS zone %(zone)s not found' % dict(zone=domain)))
|
||||||
raise e
|
|
||||||
# Get all forward resources for this host
|
# Get all forward resources for this host
|
||||||
records = api.Command['dnsrecord_find'](domain, idnsname=parts[0])['result']
|
records = api.Command['dnsrecord_find'](domain, idnsname=parts[0])['result']
|
||||||
for record in records:
|
for record in records:
|
||||||
|
@ -41,9 +41,6 @@ import datetime
|
|||||||
from ipapython import config
|
from ipapython import config
|
||||||
try:
|
try:
|
||||||
from subprocess import CalledProcessError
|
from subprocess import CalledProcessError
|
||||||
class CalledProcessError(subprocess.CalledProcessError):
|
|
||||||
def __init__(self, returncode, cmd):
|
|
||||||
super(CalledProcessError, self).__init__(returncode, cmd)
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# Python 2.4 doesn't implement CalledProcessError
|
# Python 2.4 doesn't implement CalledProcessError
|
||||||
class CalledProcessError(Exception):
|
class CalledProcessError(Exception):
|
||||||
@ -876,6 +873,7 @@ class ItemCompleter:
|
|||||||
self.items = items
|
self.items = items
|
||||||
self.initial_input = None
|
self.initial_input = None
|
||||||
self.item_delims = ' \t,'
|
self.item_delims = ' \t,'
|
||||||
|
self.operator = '='
|
||||||
self.split_re = re.compile('[%s]+' % self.item_delims)
|
self.split_re = re.compile('[%s]+' % self.item_delims)
|
||||||
|
|
||||||
def open(self):
|
def open(self):
|
||||||
|
@ -602,7 +602,7 @@ class CertDB(object):
|
|||||||
dogtag.https_request(self.host_name, api.env.ca_ee_port, "/ca/ee/ca/profileSubmitSSLClient", self.secdir, password, "ipaCert", **params)
|
dogtag.https_request(self.host_name, api.env.ca_ee_port, "/ca/ee/ca/profileSubmitSSLClient", self.secdir, password, "ipaCert", **params)
|
||||||
|
|
||||||
if http_status != 200:
|
if http_status != 200:
|
||||||
raise CertificateOperationError(error=_('Unable to communicate with CMS (%s)') % \
|
raise CertificateOperationError(error='Unable to communicate with CMS (%s)' % \
|
||||||
http_reason_phrase)
|
http_reason_phrase)
|
||||||
|
|
||||||
# The result is an XML blob. Pull the certificate out of that
|
# The result is an XML blob. Pull the certificate out of that
|
||||||
|
@ -82,7 +82,7 @@ def verify_dns_records(host_name, responses, resaddr, family):
|
|||||||
|
|
||||||
rs = dnsclient.query(dns_addr.reverse_dns, dnsclient.DNS_C_IN, dnsclient.DNS_T_PTR)
|
rs = dnsclient.query(dns_addr.reverse_dns, dnsclient.DNS_C_IN, dnsclient.DNS_T_PTR)
|
||||||
if len(rs) == 0:
|
if len(rs) == 0:
|
||||||
raise RuntimeError("Cannot find Reverse Address for %s (%s)" % (host_name, addr))
|
raise RuntimeError("Cannot find Reverse Address for %s (%s)" % (host_name, dns_addr.format()))
|
||||||
|
|
||||||
rev = None
|
rev = None
|
||||||
for rsn in rs:
|
for rsn in rs:
|
||||||
@ -91,7 +91,7 @@ def verify_dns_records(host_name, responses, resaddr, family):
|
|||||||
break
|
break
|
||||||
|
|
||||||
if rev == None:
|
if rev == None:
|
||||||
raise RuntimeError("Cannot find Reverse Address for %s (%s)" % (host_name, addr))
|
raise RuntimeError("Cannot find Reverse Address for %s (%s)" % (host_name, dns_addr.format()))
|
||||||
|
|
||||||
if rec.dns_name != rev.rdata.ptrdname:
|
if rec.dns_name != rev.rdata.ptrdname:
|
||||||
raise RuntimeError("The DNS forward record %s does not match the reverse address %s" % (rec.dns_name, rev.rdata.ptrdname))
|
raise RuntimeError("The DNS forward record %s does not match the reverse address %s" % (rec.dns_name, rev.rdata.ptrdname))
|
||||||
|
@ -611,8 +611,6 @@ class IPAdmin(SimpleLDAPObject):
|
|||||||
while not entry and int(time.time()) < timeout:
|
while not entry and int(time.time()) < timeout:
|
||||||
try:
|
try:
|
||||||
entry = self.getEntry(dn, scope, filter, attrlist)
|
entry = self.getEntry(dn, scope, filter, attrlist)
|
||||||
except ipaerror.exception_for(ipaerror.LDAP_NOT_FOUND):
|
|
||||||
pass # found entry, but no attr
|
|
||||||
except ldap.NO_SUCH_OBJECT:
|
except ldap.NO_SUCH_OBJECT:
|
||||||
pass # no entry yet
|
pass # no entry yet
|
||||||
except ldap.LDAPError, e: # badness
|
except ldap.LDAPError, e: # badness
|
||||||
|
@ -1519,9 +1519,7 @@ class ra(rabase.rabase):
|
|||||||
"""
|
"""
|
||||||
self.debug('%s.revoke_certificate()', self.fullname)
|
self.debug('%s.revoke_certificate()', self.fullname)
|
||||||
if type(revocation_reason) is not int:
|
if type(revocation_reason) is not int:
|
||||||
raise TYPE_ERROR('revocation_reason', int, revocation_reason,
|
raise TypeError(TYPE_ERROR % ('revocation_reason', int, revocation_reason, type(revocation_reason)))
|
||||||
type(revocation_reason)
|
|
||||||
)
|
|
||||||
|
|
||||||
# Convert serial number to integral type from string to properly handle
|
# Convert serial number to integral type from string to properly handle
|
||||||
# radix issues. Note: the int object constructor will properly handle large
|
# radix issues. Note: the int object constructor will properly handle large
|
||||||
|
@ -308,7 +308,7 @@ class ldap2(CrudBackend, Encoder):
|
|||||||
_ldap.set_option(_ldap.OPT_X_TLS_KEYFILE, tls_keyfile)
|
_ldap.set_option(_ldap.OPT_X_TLS_KEYFILE, tls_keyfile)
|
||||||
|
|
||||||
if debug_level:
|
if debug_level:
|
||||||
_ldap.set_option(_ldap.OPT_X_DEBUG_LEVEL, debug_level)
|
_ldap.set_option(_ldap.OPT_DEBUG_LEVEL, debug_level)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
conn = _ldap.initialize(self.ldap_uri)
|
conn = _ldap.initialize(self.ldap_uri)
|
||||||
|
@ -25,7 +25,6 @@ This wraps the python-ldap bindings.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import ldap as _ldap
|
import ldap as _ldap
|
||||||
import ldap.dn
|
|
||||||
from ipalib import api
|
from ipalib import api
|
||||||
from ipalib import errors
|
from ipalib import errors
|
||||||
from ipalib.crud import CrudBackend
|
from ipalib.crud import CrudBackend
|
||||||
@ -443,9 +442,4 @@ class ldap(CrudBackend):
|
|||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def get_effective_rights(self, dn, attrs=None):
|
|
||||||
binddn = self.find_entry_dn("krbprincipalname", self.conn.principal, "posixAccount")
|
|
||||||
|
|
||||||
return servercore.get_effective_rights(binddn, dn, attrs)
|
|
||||||
|
|
||||||
api.register(ldap)
|
api.register(ldap)
|
||||||
|
@ -168,14 +168,6 @@ def get_entry_by_cn (cn, sattrs):
|
|||||||
searchfilter = "(cn=%s)" % cn
|
searchfilter = "(cn=%s)" % cn
|
||||||
return get_sub_entry("cn=accounts," + api.env.basedn, searchfilter, sattrs)
|
return get_sub_entry("cn=accounts," + api.env.basedn, searchfilter, sattrs)
|
||||||
|
|
||||||
def get_user_by_uid(uid, sattrs):
|
|
||||||
"""Get a specific user's entry."""
|
|
||||||
# FIXME: should accept a container to look in
|
|
||||||
# uid = self.__safe_filter(uid)
|
|
||||||
searchfilter = "(&(uid=%s)(objectclass=posixAccount))" % uid
|
|
||||||
|
|
||||||
return get_sub_entry("cn=accounts," + api.env.basedn, searchfilter, sattrs)
|
|
||||||
|
|
||||||
# User support
|
# User support
|
||||||
|
|
||||||
def entry_exists(dn):
|
def entry_exists(dn):
|
||||||
|
Loading…
Reference in New Issue
Block a user