Bug 2014768

Summary: Log the Auto Member invalid regex rules in the LDAP errors log. [rhel-7.9.z]
Product: Red Hat Enterprise Linux 7 Reporter: Têko Mihinto <tmihinto>
Component: 389-ds-baseAssignee: mreynolds
Status: CLOSED ERRATA QA Contact: RHDS QE <ds-qe-bugs>
Severity: low Docs Contact:
Priority: unspecified    
Version: 7.9CC: aadhikar, kpfleming, ldap-maint, mreynolds, pcech, rcritten, sgouvern, tbordaz, tscherf
Target Milestone: rcKeywords: Triaged, ZStream
Target Release: 7.9   
Hardware: x86_64   
OS: Linux   
Whiteboard: sync-to-jira
Fixed In Version: 389-ds-base-1.3.10.2-16.el7_9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2015996 (view as bug list) Environment:
Last Closed: 2022-06-28 09:54:23 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2015996, 2015998    

Description Têko Mihinto 2021-10-16 14:24:38 UTC
Description of problem:
When logging an error message about invalid Auto Member rules, it would be useful to add also the name of the rule and the invalid regular expression.

Version-Release number of selected component (if applicable):
# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.9 (Maipo)
#
# rpm -qa | grep ipa-server
ipa-server-common-4.6.8-5.el7.noarch
ipa-server-4.6.8-5.el7.x86_64
#

How reproducible:
Always.

Steps to Reproduce:
1. Add an invalid regex to a rule.
2. Check in the LDAP errors log. The related message doesn't contain the actual invalid regex:
# grep automember_parse_regex_rule /var/log/dirsrv/slapd-<INSTANCE>/errors
[15/Oct/2021:21:44:12.657912921 +0200] - ERR - auto-membership-plugin - automember_parse_regex_rule - Unable to parse regex rule (invalid regex).  Error "nothing to repeat".
#

It would be helpful to get such information to quickly find the invalid expression(s).
Especially when there are many of them:
$ grep -c  automember_parse_regex_rule <SOS_REPORT>/var/log/dirsrv/slapd-<INSTANCE_NAME>/errors
72
$

Actual results:
Not enough additional information.

Expected results:
Log the invalid regexes.

Additional info:

Comment 3 Florence Blanc-Renaud 2021-10-19 09:15:19 UTC
I am moving this BZ to 389ds component, as the automember plugin belongs there.

Comment 4 mreynolds 2021-10-20 11:51:21 UTC
The reason that we do not log with rule and regex is invalid is becuase oif a bug where we do not return a error code when things go wrong.

diff --git a/ldap/servers/plugins/automember/automember.c b/ldap/servers/plugins/automember/automember.c
index 39350ad53..b92b89bd5 100644
--- a/ldap/servers/plugins/automember/automember.c
+++ b/ldap/servers/plugins/automember/automember.c
@@ -1217,6 +1217,7 @@ automember_parse_regex_rule(char *rule_string)
                       "automember_parse_regex_rule - Unable to parse "
                       "regex rule (invalid regex).  Error \"%s\".\n",
                       recomp_result ? recomp_result : "unknown");
+        goto bail;
     }
 
     /* Validation has passed, so create the regex rule struct and fill it in.

Comment 5 thierry bordaz 2021-11-03 14:48:34 UTC
Fix pushed upstream -> POST

Comment 6 thierry bordaz 2021-12-08 17:00:50 UTC
I was wrong, it is not pushed in 1.3.10 => NEW

Comment 15 Akshay Adhikari 2022-06-17 16:58:31 UTC
============================================================================ test session starts ============================================================================
platform linux -- Python 3.6.8, pytest-7.0.1, pluggy-1.0.0 -- /usr/bin/python3
cachedir: .pytest_cache
metadata: {'Python': '3.6.8', 'Platform': 'Linux-3.10.0-1160.68.1.el7.x86_64-x86_64-with-redhat-7.9-Maipo', 'Packages': {'pytest': '7.0.1', 'py': '1.11.0', 'pluggy': '1.0.0'}, 'Plugins': {'metadata': '1.11.0', 'html': '3.1.1', 'libfaketime': '0.1.2', 'flaky': '3.7.0'}}
389-ds-base: 1.3.10.2-16.el7_9
nss: 3.67.0-4.el7_9
nspr: 4.32.0-1.el7_9
openldap: 2.4.44-25.el7_9
cyrus-sasl: 2.1.26-24.el7_9
FIPS: 0

rootdir: /mnt/tests/rhds/tests/upstream/ds
plugins: metadata-1.11.0, html-3.1.1, libfaketime-0.1.2, flaky-3.7.0
collected 1 item                                                                                                                                                            

dirsrvtests/tests/suites/automember_plugin/configuration_test.py::test_invalid_regex PASSED                                                                           [100%]

====================================================================== 1 passed, 3 warnings in 20.12s =======================================================================

Marking as VERIFIED.

Comment 23 errata-xmlrpc 2022-06-28 09:54:23 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: 389-ds-base security, bug fix, and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2022:5239