From 2fa04088931450237ad6580fd5fc5903878bdbb0 Mon Sep 17 00:00:00 2001 From: Simon Pichugin Date: Jul 10 2018 15:18:00 +0000 Subject: 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!) --- diff --git a/ldap/servers/slapd/config.c b/ldap/servers/slapd/config.c index 9b3b5a6..7e1618e 100644 --- a/ldap/servers/slapd/config.c +++ b/ldap/servers/slapd/config.c @@ -526,10 +526,18 @@ slapd_bootstrap_config(const char *configdir) if (e == NULL) { continue; } - if (plugin_setup(e, 0, 0, 1, returntext) != 0) { - slapi_log_err(SLAPI_LOG_TRACE, "slapd_bootstrap_config", "Application of plugin failed, maybe already there?\n"); - } else { + rc = plugin_setup(e, 0, 0, 1, returntext); + if (rc == 0) { slapi_log_err(SLAPI_LOG_TRACE, "slapd_bootstrap_config", "Application of plugin SUCCESS\n"); + } else if (rc == 1) { + /* It means that the plugin entry already exists */ + slapi_log_err(SLAPI_LOG_TRACE, "slapd_bootstrap_config", + "The plugin entry [%s] in the configfile %s was invalid. %s\n", + slapi_entry_get_dn(e), configfile, returntext); + } else { + slapi_log_err(SLAPI_LOG_ERR, "slapd_bootstrap_config", + "The plugin entry [%s] in the configfile %s was invalid. %s\n", + slapi_entry_get_dn(e), configfile, returntext); } slapi_entry_free(e); } diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c index 2db3c7f..9e1c1b4 100644 --- a/ldap/servers/slapd/plugin.c +++ b/ldap/servers/slapd/plugin.c @@ -2786,12 +2786,12 @@ plugin_setup(Slapi_Entry *plugin_entry, struct slapi_componentid *group, slapi_p } if ((existname = plugin_exists(slapi_entry_get_sdn_const(plugin_entry))) != NULL) { - slapi_log_err(SLAPI_LOG_ERR, "plugin_setup", "The plugin named %s already exists, " - "or is already setup.\n", + slapi_log_err(SLAPI_LOG_TRACE, "plugin_setup", "The plugin named %s already exists, " + "or is already setup.\n", existname); PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE, "the plugin named %s already exists, or is already setup.", existname); - return -1; + return 1; } /* @@ -3016,7 +3016,9 @@ plugin_setup(Slapi_Entry *plugin_entry, struct slapi_componentid *group, slapi_p } if (!status) { - status = plugin_add_descriptive_attributes(plugin_entry, plugin); + if (plugin_add_descriptive_attributes(plugin_entry, plugin) != 0) { + status = -1; + } } slapi_ch_free((void **)&value);