/usr/lib/x86_64-linux-gnu/dirsrv/python/logregex.py is in 389-ds-base 1.3.7.10-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | import sys
import re
import __main__ # to use globals
# supports more than one regex - multiple regex are combined using AND logic
# OR logic is easily supported with the '|' regex modifier
regex_regex_ary = []
def pre(plgargs):
global regex_regex_ary
regexary = plgargs.get('regex', None)
if not regexary:
print("Error: missing required argument logregex.regex")
return False
if isinstance(regexary,list):
regex_regex_ary = [re.compile(xx) for xx in regexary]
else:
regex_regex_ary.append(re.compile(regexary))
return True
def plugin(line):
__main__.totallines = __main__.totallines + 1
for rx in regex_regex_ary:
if not rx.search(line):
return True # regex did not match - get next line
else: # all regexes matched
__main__.totallines = __main__.totallines - 1
return __main__.defaultplugin(line)
|