Commit 2fa0408 Issue 49640 - Cleanup plugin bootstrap logging

2 files Authored and Committed by Simon Pichugin 6 days ago
Issue 49640 - Cleanup plugin bootstrap logging

Bug Description: We add PBKDF2_SHA256 password storage schema two times. During:
1. the dse.ldif parsing;
2. the bootstrap plugin operation.
It causes the error to appear during the startup.

Fix Description: Make plugin_setup() function report the error to TRACE log level
if the plugin already exists. We will report the error in ERR log level during
the config bootstrap anyway (code path for the 1st option from bug description).
For 2nd option, report the error to TRACE if it is 'already exist' issue
and to ERR if it is any other case.

Make the plugin_setup returns more consistent.

https://pagure.io/389-ds-base/issue/49640

Reviewed by: mreynolds, mhonek (Thanks!)

    
 1 @@ -526,10 +526,18 @@
 2                   if (e == NULL) {
 3                       continue;
 4                   }
 5 -                 if (plugin_setup(e, 0, 0, 1, returntext) != 0) {
 6 -                     slapi_log_err(SLAPI_LOG_TRACE, "slapd_bootstrap_config", "Application of plugin failed, maybe already there?\n");
 7 -                 } else {
 8 +                 rc = plugin_setup(e, 0, 0, 1, returntext);
 9 +                 if (rc == 0) {
10                       slapi_log_err(SLAPI_LOG_TRACE, "slapd_bootstrap_config", "Application of plugin SUCCESS\n");
11 +                 } else if (rc == 1) {
12 +                     /* It means that the plugin entry already exists */
13 +                     slapi_log_err(SLAPI_LOG_TRACE, "slapd_bootstrap_config",
14 +                                   "The plugin entry [%s] in the configfile %s was invalid. %s\n",
15 +                                   slapi_entry_get_dn(e), configfile, returntext);
16 +                 } else {
17 +                     slapi_log_err(SLAPI_LOG_ERR, "slapd_bootstrap_config",
18 +                                   "The plugin entry [%s] in the configfile %s was invalid. %s\n",
19 +                                   slapi_entry_get_dn(e), configfile, returntext);
20                   }
21                   slapi_entry_free(e);
22               }
 1 @@ -2786,12 +2786,12 @@
 2       }
 3   
 4       if ((existname = plugin_exists(slapi_entry_get_sdn_const(plugin_entry))) != NULL) {
 5 -         slapi_log_err(SLAPI_LOG_ERR, "plugin_setup", "The plugin named %s already exists, "
 6 -                                                      "or is already setup.\n",
 7 +         slapi_log_err(SLAPI_LOG_TRACE, "plugin_setup", "The plugin named %s already exists, "
 8 +                                                        "or is already setup.\n",
 9                         existname);
10           PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
11                       "the plugin named %s already exists, or is already setup.", existname);
12 -         return -1;
13 +         return 1;
14       }
15   
16       /*
17 @@ -3016,7 +3016,9 @@
18       }
19   
20       if (!status) {
21 -         status = plugin_add_descriptive_attributes(plugin_entry, plugin);
22 +         if (plugin_add_descriptive_attributes(plugin_entry, plugin) != 0) {
23 +             status = -1;
24 +         }
25       }
26   
27       slapi_ch_free((void **)&value);