From 9d5b91df2bc268c67cd3e6ec71d630b5422724a2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sven=20M=C3=A4der?= <maeder@phys.ethz.ch>
Date: Wed, 11 Apr 2018 13:49:54 +0200
Subject: [PATCH] Add modrdn, fix bugs

---
 bin/deltalogparse.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/bin/deltalogparse.py b/bin/deltalogparse.py
index df53552..7c52e2a 100755
--- a/bin/deltalogparse.py
+++ b/bin/deltalogparse.py
@@ -19,7 +19,7 @@ log_path = '/var/log/ldap/'
 log_file_log = log_path + 'deltalogparse.log'
 log_file_deltalog = log_path + 'delta.log'
 search_base = 'cn=deltalog'
-object_classes = '(|(objectClass=auditModify)(objectClass=auditAdd)(objectClass=auditDelete))'
+object_classes = '(|(objectClass=auditModify)(objectClass=auditAdd)(objectClass=auditDelete)(objectClass=auditModRDN))'
 
 log = logging.getLogger('log')
 log.setLevel(log_level)
@@ -73,10 +73,11 @@ def is_skipped(entry):
 
 def filtered(entry):
     """Filter out attributes not of interest"""
-    for attribute in entry['attributes']['reqMod']:
-        if rgx_filter.search(attribute):
-            log.info('filter attribute: {}'.format(attribute))
-            entry['attributes']['reqMod'].remove(attribute)
+    if 'reqMod' in  entry['attributes']:
+        for attribute in entry['attributes']['reqMod']:
+            if rgx_filter.search(attribute):
+                log.info('filter attribute: {}'.format(attribute))
+                entry['attributes']['reqMod'].remove(attribute)
 
     del entry['raw_dn']
     del entry['raw_attributes']
@@ -159,6 +160,7 @@ def main():
             log.exception('error: reading socket! trying to reconnect...')
             if slapd.reconnect():
                 log.error('socket reconnected.')
+                continue
 
         if response:
             for entry in slapd.response():
-- 
GitLab