Skip to content

Commit 6a1cf52

Browse files
committed
Fix issues #39 and #40
- Add support for multiple domains with non-unique shortnames - Fix Netgroups check
1 parent 7f8b076 commit 6a1cf52

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

checkipaconsistency/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
along with this program. If not, see <http://www.gnu.org/licenses/>.
2323
"""
2424

25-
VERSION = '2.7.0'
25+
VERSION = '2.7.1'

checkipaconsistency/freeipaserver.py

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import logging
2727
import ldap
2828
import dns.resolver
29-
import re
3029

3130

3231
class FreeIPAServer(object):
@@ -57,25 +56,14 @@ def __init__(self, host, domain, binddn, bindpw):
5756
self._bindpw = bindpw
5857
self._domain = domain
5958
self._url = 'ldaps://' + host
60-
self.hostname_short = host
61-
59+
self.hostname_short = host.replace('.%s' % domain, '')
6260
self._conn = self._get_conn()
6361

6462
if not self._conn:
6563
return
6664

67-
if re.match('^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$', host):
68-
self._log.debug("IP %s supplied as host's address" % host)
69-
self._fqdn = self._get_fqdn()
70-
self.hostname_short = self._fqdn.partition('.')[0]
71-
elif '.' not in host:
72-
self._log.debug("Short hostname %s supplied as host's address" % host)
73-
self._fqdn = self._get_fqdn()
74-
self.hostname_short = host
75-
else:
76-
self._log.debug("FQDN supplied as host's address")
77-
self._fqdn = host
78-
self.hostname_short = host.partition('.')[0]
65+
self._fqdn = self._get_fqdn()
66+
self.hostname_short = self._fqdn.replace('.%s' % domain, '')
7967

8068
self._log.debug('FQDN: %s, short hostname: %s' % (self._fqdn, self.hostname_short))
8169

@@ -256,8 +244,8 @@ def _count_services(self):
256244
def _count_netgroups(self):
257245
self._log.debug('Counting netgroups...')
258246
results = self._search(
259-
'cn=ng,cn=compat,%s' % self._base_dn,
260-
'(cn=*)',
247+
'cn=ng,cn=alt,%s' % self._base_dn,
248+
'(ipaUniqueID=*)',
261249
['dn'],
262250
scope=ldap.SCOPE_ONELEVEL
263251
)
@@ -423,10 +411,10 @@ def _replication_agreements(self):
423411
for result in results:
424412
dn, attrs = result
425413
host = attrs['nsDS5ReplicaHost'][0].decode('utf-8')
426-
host = host.partition('.')[0]
414+
host = host.replace('.%s' % self._domain, '')
427415
status = attrs['nsds5replicaLastUpdateStatus'][0].decode('utf-8')
428416
status = status.replace('Error ', '').partition(' ')[0].strip('()')
429-
if status != '0':
417+
if status not in ['0']:
430418
healthy = False
431419
msg.append('%s %s' % (host, status))
432420

0 commit comments

Comments
 (0)