This is an automated email from the git hooks/post-receive script.
mreynolds pushed a commit to branch 389-ds-base-1.3.6
in repository 389-ds-base.
commit 8dd1c60e3662c2d91c0b19618e13f6bcaafe428a
Author: William Brown <firstyear(a)redhat.com>
Date: Wed Nov 15 13:44:02 2017 +1000
Ticket 49298 - Correct error codes with config restore.
Bug Description: The piece of code uses 0 as an error - not 1,
and in some cases did not even check the codes or use the
correct logic.
Fix Description: Cleanup dse_check_file to better check the
content of files and communicate issues to the admin. Correct
slapd_bootstrap_config to correctly handle the cases of removal
and restore.
https://pagure.io/389-ds-base/issue/49298
Author: wibrown
Review by: mreynoolds & spichugi
Signed-off-by: Mark Reynolds <mreynolds(a)redhat.com>
(cherry picked from commit 75e55e26579955adf058e8adcba9a28779583b7b)
---
.../suites/config/removed_config_49298_test.py | 81 +++++
ldap/servers/slapd/config.c | 369 ++++++++++-----------
ldap/servers/slapd/dse.c | 49 ++-
3 files changed, 287 insertions(+), 212 deletions(-)
diff --git a/dirsrvtests/tests/suites/config/removed_config_49298_test.py
b/dirsrvtests/tests/suites/config/removed_config_49298_test.py
new file mode 100644
index 0000000..e652369
--- /dev/null
+++ b/dirsrvtests/tests/suites/config/removed_config_49298_test.py
@@ -0,0 +1,81 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2017 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+#
+import pytest
+import os
+import logging
+import subprocess
+
+from lib389.topologies import topology_st as topo
+
+DEBUGGING = os.getenv("DEBUGGING", default=False)
+if DEBUGGING:
+ logging.getLogger(__name__).setLevel(logging.DEBUG)
+else:
+ logging.getLogger(__name__).setLevel(logging.INFO)
+log = logging.getLogger(__name__)
+
+def test_restore_config(topo):
+ """
+ Check that if a dse.ldif and backup are removed, that the server still starts.
+
+ :id: e1c38fa7-30bc-46f2-a934-f8336f387581
+ :setup: Standalone instance
+ :steps:
+ 1. Stop the instance
+ 2. Delete 'dse.ldif'
+ 3. Start the instance
+ :expectedresults:
+ 1. Steps 1 and 2 succeed.
+ 2. Server will succeed to start with restored cfg.
+ """
+ topo.standalone.stop()
+
+ dse_path = topo.standalone.get_config_dir()
+
+ log.info(dse_path)
+
+ for i in ('dse.ldif', 'dse.ldif.startOK'):
+ p = os.path.join(dse_path, i)
+ os.remove(p)
+
+ # This will pass.
+ topo.standalone.start()
+
+def test_removed_config(topo):
+ """
+ Check that if a dse.ldif and backup are removed, that the server
+ exits better than "segfault".
+
+ :id: b45272d1-c197-473e-872f-07257fcb2ec0
+ :setup: Standalone instance
+ :steps:
+ 1. Stop the instance
+ 2. Delete 'dse.ldif', 'dse.ldif.bak', 'dse.ldif.startOK'
+ 3. Start the instance
+ :expectedresults:
+ 1. Steps 1 and 2 succeed.
+ 2. Server will fail to start, but will not crash.
+ """
+ topo.standalone.stop()
+
+ dse_path = topo.standalone.get_config_dir()
+
+ log.info(dse_path)
+
+ for i in ('dse.ldif', 'dse.ldif.bak', 'dse.ldif.startOK'):
+ p = os.path.join(dse_path, i)
+ os.remove(p)
+
+ # We actually can't check the log output, because it can't read dse.ldif,
+ # don't know where to write it yet! All we want is the server fail to
+ # start here, rather than infinite run + segfault.
+ with pytest.raises(subprocess.CalledProcessError):
+ topo.standalone.start()
+
+
diff --git a/ldap/servers/slapd/config.c b/ldap/servers/slapd/config.c
index e37179d..40c067b 100644
--- a/ldap/servers/slapd/config.c
+++ b/ldap/servers/slapd/config.c
@@ -116,206 +116,181 @@ entry_has_attr_and_value(Slapi_Entry *e, const char *attrname,
int
slapd_bootstrap_config(const char *configdir)
{
- char configfile[MAXPATHLEN+1];
- PRFileInfo64 prfinfo;
- int rc = 0; /* Fail */
- int done = 0;
- PRInt32 nr = 0;
- PRFileDesc *prfd = 0;
- char returntext[SLAPI_DSE_RETURNTEXT_SIZE] = {0};
- char *buf = 0;
- char *lastp = 0;
- char *entrystr = 0;
- char tmpfile[MAXPATHLEN+1];
-
- if (NULL == configdir) {
- slapi_log_err(SLAPI_LOG_ERR, "slapd_bootstrap_config",
- "Passed null config directory\n");
- return rc; /* Fail */
- }
- PR_snprintf(configfile, sizeof(configfile), "%s/%s", configdir,
- CONFIG_FILENAME);
- PR_snprintf(tmpfile, sizeof(tmpfile), "%s/%s.tmp", configdir,
- CONFIG_FILENAME);
- if ( (rc = dse_check_file(configfile, tmpfile)) == 0 ) {
- PR_snprintf(tmpfile, sizeof(tmpfile), "%s/%s.bak", configdir,
- CONFIG_FILENAME);
- rc = dse_check_file(configfile, tmpfile);
- }
-
- if ( (rc = PR_GetFileInfo64( configfile, &prfinfo )) != PR_SUCCESS )
- {
- PRErrorCode prerr = PR_GetError();
- slapi_log_err(SLAPI_LOG_ERR, "slapd_bootstrap_config",
- "The given config file %s could not be accessed, " SLAPI_COMPONENT_NAME_NSPR
" error %d (%s)\n",
- configfile, prerr, slapd_pr_strerror(prerr));
- return rc;
- }
- else if (( prfd = PR_Open( configfile, PR_RDONLY,
- SLAPD_DEFAULT_FILE_MODE )) == NULL )
- {
- PRErrorCode prerr = PR_GetError();
- slapi_log_err(SLAPI_LOG_ERR, "slapd_bootstrap_config",
- "The given config file %s could not be opened for reading, "
SLAPI_COMPONENT_NAME_NSPR " error %d (%s)\n",
- configfile, prerr, slapd_pr_strerror(prerr));
- return rc; /* Fail */
- }
- else
- {
- /* read the entire file into core */
- buf = slapi_ch_malloc( prfinfo.size + 1 );
- if (( nr = slapi_read_buffer( prfd, buf, prfinfo.size )) < 0 )
- {
- slapi_log_err(SLAPI_LOG_ERR, "slapd_bootstrap_config",
- "Could only read %d of %ld bytes from config file %s\n",
- nr, (long int)prfinfo.size, configfile);
- rc = 0; /* Fail */
- done= 1;
- }
-
- (void)PR_Close(prfd);
- buf[ nr ] = '\0';
-
- if(!done)
- {
- char workpath[MAXPATHLEN+1];
- char loglevel[BUFSIZ];
- char maxdescriptors[BUFSIZ];
- char val[BUFSIZ];
- char _localuser[BUFSIZ];
- char logenabled[BUFSIZ];
- char schemacheck[BUFSIZ];
- char syntaxcheck[BUFSIZ];
- char syntaxlogging[BUFSIZ];
- char plugintracking[BUFSIZ];
- char dn_validate_strict[BUFSIZ];
- char moddn_aci[BUFSIZ];
- Slapi_DN plug_dn;
-
- workpath[0] = loglevel[0] = maxdescriptors[0] = '\0';
- val[0] = logenabled[0] = schemacheck[0] = syntaxcheck[0] = '\0';
- syntaxlogging[0] = _localuser[0] = '\0';
- plugintracking [0] = dn_validate_strict[0] = moddn_aci[0] ='\0';
-
- /* Convert LDIF to entry structures */
- slapi_sdn_init_ndn_byref(&plug_dn, PLUGIN_BASE_DN);
- while ((entrystr = dse_read_next_entry(buf, &lastp)) != NULL)
- {
- char errorbuf[SLAPI_DSE_RETURNTEXT_SIZE];
- /*
- * XXXmcs: it would be better to also pass
- * SLAPI_STR2ENTRY_REMOVEDUPVALS in the flags, but
- * duplicate value checking requires that the syntax
- * and schema subsystems be initialized... and they
- * are not yet.
- */
- Slapi_Entry *e = slapi_str2entry(entrystr,
- SLAPI_STR2ENTRY_NOT_WELL_FORMED_LDIF);
- if (e == NULL)
- {
- slapi_log_err(SLAPI_LOG_ERR, "slapd_bootstrap_config - "
- "The entry [%s] in the configfile %s was empty or could not be
parsed\n",
- entrystr, configfile, 0);
- continue;
- }
- /* increase file descriptors */
- if (!maxdescriptors[0] &&
- entry_has_attr_and_value(e, CONFIG_MAXDESCRIPTORS_ATTRIBUTE,
- maxdescriptors, sizeof(maxdescriptors)))
- {
- if (config_set_maxdescriptors(
- CONFIG_MAXDESCRIPTORS_ATTRIBUTE,
- maxdescriptors, errorbuf, CONFIG_APPLY)
- != LDAP_SUCCESS)
- {
- slapi_log_err(SLAPI_LOG_ERR, "slapd_bootstrap_config - "
- "%s: %s: %s\n", configfile, CONFIG_MAXDESCRIPTORS_ATTRIBUTE, errorbuf);
- }
- }
-
- /* see if we need to enable error logging */
- if (!logenabled[0] &&
- entry_has_attr_and_value(e,
- CONFIG_ERRORLOG_LOGGING_ENABLED_ATTRIBUTE,
- logenabled, sizeof(logenabled)))
- {
- if (log_set_logging(
- CONFIG_ERRORLOG_LOGGING_ENABLED_ATTRIBUTE,
- logenabled, SLAPD_ERROR_LOG, errorbuf, CONFIG_APPLY)
- != LDAP_SUCCESS)
- {
- slapi_log_err(SLAPI_LOG_ERR, "slapd_bootstrap_config - %s: %s: %s\n",
- configfile, CONFIG_ERRORLOG_LOGGING_ENABLED_ATTRIBUTE, errorbuf);
- }
- }
+ char configfile[MAXPATHLEN + 1];
+ PRFileInfo64 prfinfo;
+ int rc = 0; /* Fail */
+ int done = 0;
+ PRInt32 nr = 0;
+ PRFileDesc *prfd = 0;
+ char returntext[SLAPI_DSE_RETURNTEXT_SIZE] = {0};
+ char *buf = 0;
+ char *lastp = 0;
+ char *entrystr = 0;
+ char tmpfile[MAXPATHLEN + 1];
+
+ if (NULL == configdir) {
+ slapi_log_err(SLAPI_LOG_ERR, "slapd_bootstrap_config",
+ "Passed null config directory\n");
+ return rc; /* Fail */
+ }
+ PR_snprintf(configfile, sizeof(configfile), "%s/%s", configdir,
CONFIG_FILENAME);
+ PR_snprintf(tmpfile, sizeof(tmpfile), "%s/%s.bak", configdir,
CONFIG_FILENAME);
+ rc = dse_check_file(configfile, tmpfile);
+ if (rc == 0) {
+ /* EVERYTHING IS GOING WRONG, ARRGHHHHHH */
+ slapi_log_err(SLAPI_LOG_ERR, "slapd_bootstrap_config", "No valid
configurations can be accessed! You must restore %s from backup!\n", configfile);
+ return 0;
+ }
- /* set the local user name; needed to set up error log */
- if (!_localuser[0] &&
- entry_has_attr_and_value(e, CONFIG_LOCALUSER_ATTRIBUTE,
- _localuser, sizeof(_localuser)))
- {
- if (config_set_localuser(CONFIG_LOCALUSER_ATTRIBUTE,
- _localuser, errorbuf, CONFIG_APPLY) != LDAP_SUCCESS)
- {
- slapi_log_err(SLAPI_LOG_ERR, "slapd_bootstrap_config - %s: %s: %s. \n",
- configfile, CONFIG_LOCALUSER_ATTRIBUTE, errorbuf);
- }
- }
-
- /* set the log file name */
- workpath[0] = '\0';
- if (!workpath[0] &&
- entry_has_attr_and_value(e, CONFIG_ERRORLOG_ATTRIBUTE,
- workpath, sizeof(workpath)))
- {
- if (config_set_errorlog(CONFIG_ERRORLOG_ATTRIBUTE,
- workpath, errorbuf, CONFIG_APPLY) != LDAP_SUCCESS)
- {
- slapi_log_err(SLAPI_LOG_ERR, "slapd_bootstrap_config - %s: %s: %s. \n",
- configfile, CONFIG_ERRORLOG_ATTRIBUTE, errorbuf);
- }
- }
- /* set the error log level */
- if (!loglevel[0] &&
- entry_has_attr_and_value(e, CONFIG_LOGLEVEL_ATTRIBUTE,
- loglevel, sizeof(loglevel)))
- {
- if (should_detach || !config_get_errorlog_level())
- { /* -d wasn't on command line */
- if (config_set_errorlog_level(CONFIG_LOGLEVEL_ATTRIBUTE,
- loglevel, errorbuf, CONFIG_APPLY) != LDAP_SUCCESS)
- {
- slapi_log_err(SLAPI_LOG_ERR, "%s: %s: %s. \n", configfile,
- CONFIG_LOGLEVEL_ATTRIBUTE, errorbuf);
- }
- }
- }
+ if ((rc = PR_GetFileInfo64(configfile, &prfinfo)) != PR_SUCCESS) {
+ PRErrorCode prerr = PR_GetError();
+ slapi_log_err(SLAPI_LOG_ERR, "slapd_bootstrap_config",
+ "The given config file %s could not be accessed, "
SLAPI_COMPONENT_NAME_NSPR " error %d (%s)\n",
+ configfile, prerr, slapd_pr_strerror(prerr));
+ return rc;
+ } else if ((prfd = PR_Open(configfile, PR_RDONLY,
+ SLAPD_DEFAULT_FILE_MODE)) == NULL) {
+ PRErrorCode prerr = PR_GetError();
+ slapi_log_err(SLAPI_LOG_ERR, "slapd_bootstrap_config",
+ "The given config file %s could not be opened for reading,
" SLAPI_COMPONENT_NAME_NSPR " error %d (%s)\n",
+ configfile, prerr, slapd_pr_strerror(prerr));
+ return rc; /* Fail */
+ } else {
+ /* read the entire file into core */
+ buf = slapi_ch_malloc(prfinfo.size + 1);
+ if ((nr = slapi_read_buffer(prfd, buf, prfinfo.size)) < 0) {
+ slapi_log_err(SLAPI_LOG_ERR, "slapd_bootstrap_config",
+ "Could only read %d of %ld bytes from config file
%s\n",
+ nr, (long int)prfinfo.size, configfile);
+ rc = 0; /* Fail */
+ done = 1;
+ }
- /* set the cert dir; needed in slapd_nss_init */
- workpath[0] = '\0';
- if (entry_has_attr_and_value(e, CONFIG_CERTDIR_ATTRIBUTE,
- workpath, sizeof(workpath)))
- {
- if (config_set_certdir(CONFIG_CERTDIR_ATTRIBUTE,
- workpath, errorbuf, CONFIG_APPLY) != LDAP_SUCCESS)
- {
- slapi_log_err(SLAPI_LOG_ERR, "slapd_bootstrap_config", "%s: %s: %s.
\n",
- configfile, CONFIG_CERTDIR_ATTRIBUTE, errorbuf);
- }
- }
+ (void)PR_Close(prfd);
+ buf[nr] = '\0';
+
+ if (!done) {
+ char workpath[MAXPATHLEN + 1];
+ char loglevel[BUFSIZ];
+ char maxdescriptors[BUFSIZ];
+ char val[BUFSIZ];
+ char _localuser[BUFSIZ];
+ char logenabled[BUFSIZ];
+ char schemacheck[BUFSIZ];
+ char syntaxcheck[BUFSIZ];
+ char syntaxlogging[BUFSIZ];
+ char plugintracking[BUFSIZ];
+ char dn_validate_strict[BUFSIZ];
+ char moddn_aci[BUFSIZ];
+ Slapi_DN plug_dn;
+
+ workpath[0] = loglevel[0] = maxdescriptors[0] = '\0';
+ val[0] = logenabled[0] = schemacheck[0] = syntaxcheck[0] = '\0';
+ syntaxlogging[0] = _localuser[0] = '\0';
+ plugintracking[0] = dn_validate_strict[0] = moddn_aci[0] = '\0';
+
+ /* Convert LDIF to entry structures */
+ slapi_sdn_init_ndn_byref(&plug_dn, PLUGIN_BASE_DN);
+ while ((entrystr = dse_read_next_entry(buf, &lastp)) != NULL) {
+ char errorbuf[SLAPI_DSE_RETURNTEXT_SIZE];
+ /*
+ * XXXmcs: it would be better to also pass
+ * SLAPI_STR2ENTRY_REMOVEDUPVALS in the flags, but
+ * duplicate value checking requires that the syntax
+ * and schema subsystems be initialized... and they
+ * are not yet.
+ */
+ Slapi_Entry *e = slapi_str2entry(entrystr,
+ SLAPI_STR2ENTRY_NOT_WELL_FORMED_LDIF);
+ if (e == NULL) {
+ slapi_log_err(SLAPI_LOG_ERR, "slapd_bootstrap_config - "
+ "The entry [%s] in the configfile
%s was empty or could not be parsed\n",
+ entrystr, configfile, 0);
+ continue;
+ }
+ /* increase file descriptors */
+ if (!maxdescriptors[0] &&
+ entry_has_attr_and_value(e, CONFIG_MAXDESCRIPTORS_ATTRIBUTE,
+ maxdescriptors, sizeof(maxdescriptors))) {
+ if (config_set_maxdescriptors(
+ CONFIG_MAXDESCRIPTORS_ATTRIBUTE,
+ maxdescriptors, errorbuf, CONFIG_APPLY) != LDAP_SUCCESS) {
+ slapi_log_err(SLAPI_LOG_ERR, "slapd_bootstrap_config -
"
+ "%s: %s: %s\n",
+ configfile, CONFIG_MAXDESCRIPTORS_ATTRIBUTE,
errorbuf);
+ }
+ }
+
+ /* see if we need to enable error logging */
+ if (!logenabled[0] &&
+ entry_has_attr_and_value(e,
+ CONFIG_ERRORLOG_LOGGING_ENABLED_ATTRIBUTE,
+ logenabled, sizeof(logenabled))) {
+ if (log_set_logging(
+ CONFIG_ERRORLOG_LOGGING_ENABLED_ATTRIBUTE,
+ logenabled, SLAPD_ERROR_LOG, errorbuf, CONFIG_APPLY) !=
LDAP_SUCCESS) {
+ slapi_log_err(SLAPI_LOG_ERR, "slapd_bootstrap_config - %s:
%s: %s\n",
+ configfile,
CONFIG_ERRORLOG_LOGGING_ENABLED_ATTRIBUTE, errorbuf);
+ }
+ }
+
+ /* set the local user name; needed to set up error log */
+ if (!_localuser[0] &&
+ entry_has_attr_and_value(e, CONFIG_LOCALUSER_ATTRIBUTE,
+ _localuser, sizeof(_localuser))) {
+ if (config_set_localuser(CONFIG_LOCALUSER_ATTRIBUTE,
+ _localuser, errorbuf, CONFIG_APPLY) !=
LDAP_SUCCESS) {
+ slapi_log_err(SLAPI_LOG_ERR, "slapd_bootstrap_config - %s:
%s: %s. \n",
+ configfile, CONFIG_LOCALUSER_ATTRIBUTE, errorbuf);
+ }
+ }
+
+ /* set the log file name */
+ workpath[0] = '\0';
+ if (!workpath[0] &&
+ entry_has_attr_and_value(e, CONFIG_ERRORLOG_ATTRIBUTE,
+ workpath, sizeof(workpath))) {
+ if (config_set_errorlog(CONFIG_ERRORLOG_ATTRIBUTE,
+ workpath, errorbuf, CONFIG_APPLY) !=
LDAP_SUCCESS) {
+ slapi_log_err(SLAPI_LOG_ERR, "slapd_bootstrap_config - %s:
%s: %s. \n",
+ configfile, CONFIG_ERRORLOG_ATTRIBUTE, errorbuf);
+ }
+ }
+ /* set the error log level */
+ if (!loglevel[0] &&
+ entry_has_attr_and_value(e, CONFIG_LOGLEVEL_ATTRIBUTE,
+ loglevel, sizeof(loglevel))) {
+ if (should_detach || !config_get_errorlog_level()) { /* -d wasn't
on command line */
+ if (config_set_errorlog_level(CONFIG_LOGLEVEL_ATTRIBUTE,
+ loglevel, errorbuf, CONFIG_APPLY)
!= LDAP_SUCCESS) {
+ slapi_log_err(SLAPI_LOG_ERR, "%s: %s: %s. \n",
configfile,
+ CONFIG_LOGLEVEL_ATTRIBUTE, errorbuf);
+ }
+ }
+ }
+
+ /* set the cert dir; needed in slapd_nss_init */
+ workpath[0] = '\0';
+ if (entry_has_attr_and_value(e, CONFIG_CERTDIR_ATTRIBUTE,
+ workpath, sizeof(workpath))) {
+ if (config_set_certdir(CONFIG_CERTDIR_ATTRIBUTE,
+ workpath, errorbuf, CONFIG_APPLY) !=
LDAP_SUCCESS) {
+ slapi_log_err(SLAPI_LOG_ERR, "slapd_bootstrap_config",
"%s: %s: %s. \n",
+ configfile, CONFIG_CERTDIR_ATTRIBUTE, errorbuf);
+ }
+ }
+
+ /* set the sasl path; needed in main */
+ workpath[0] = '\0';
+ if (entry_has_attr_and_value(e, CONFIG_SASLPATH_ATTRIBUTE,
+ workpath, sizeof(workpath))) {
+ if (config_set_saslpath(CONFIG_SASLPATH_ATTRIBUTE,
+ workpath, errorbuf, CONFIG_APPLY) !=
LDAP_SUCCESS) {
+ slapi_log_err(SLAPI_LOG_ERR, "slapd_bootstrap_config",
"%s: %s: %s. \n",
+ configfile, CONFIG_SASLPATH_ATTRIBUTE, errorbuf);
+ }
+ }
- /* set the sasl path; needed in main */
- workpath[0] = '\0';
- if (entry_has_attr_and_value(e, CONFIG_SASLPATH_ATTRIBUTE,
- workpath, sizeof(workpath)))
- {
- if (config_set_saslpath(CONFIG_SASLPATH_ATTRIBUTE,
- workpath, errorbuf, CONFIG_APPLY) != LDAP_SUCCESS)
- {
- slapi_log_err(SLAPI_LOG_ERR, "slapd_bootstrap_config", "%s: %s: %s.
\n",
- configfile, CONFIG_SASLPATH_ATTRIBUTE, errorbuf);
- }
- }
#if defined(ENABLE_LDAPI)
/* set the ldapi file path; needed in main */
workpath[0] = '\0';
diff --git a/ldap/servers/slapd/dse.c b/ldap/servers/slapd/dse.c
index fa1aacc..f237df8 100644
--- a/ldap/servers/slapd/dse.c
+++ b/ldap/servers/slapd/dse.c
@@ -649,31 +649,50 @@ dse_check_file(char *filename, char *backupname)
int rc= 0; /* Fail */
PRFileInfo64 prfinfo;
- if (PR_GetFileInfo64( filename, &prfinfo ) == PR_SUCCESS) {
- if ( prfinfo.size > 0) {
- return (1);
+ if (PR_GetFileInfo64(filename, &prfinfo) == PR_SUCCESS) {
+ if (prfinfo.size > 0) {
+ /* File exists and has content. */
+ return 1;
} else {
- rc = PR_Delete (filename);
+ slapi_log_err(SLAPI_LOG_INFO, "dse_check_file",
+ "The config %s has zero length. Attempting restore ...
\n", filename, rc);
+ rc = PR_Delete(filename);
}
+ } else {
+ slapi_log_err(SLAPI_LOG_INFO, "dse_check_file",
+ "The config %s can not be accessed. Attempting restore ...
(reason: %d)\n", filename, rc);
}
if (backupname) {
- rc = PR_Rename (backupname, filename);
- } else {
- return (0);
- }
+ if (PR_GetFileInfo64(backupname, &prfinfo) != PR_SUCCESS) {
+ slapi_log_err(SLAPI_LOG_INFO, "dse_check_file",
+ "The backup %s can not be accessed. Check it exists and
permissions.\n", backupname);
+ return 0;
+ }
+
+ if (prfinfo.size <= 0) {
+ slapi_log_err(SLAPI_LOG_ERR, "dse_check_file",
+ "The backup file %s has zero length, refusing to restore
it.\n", backupname);
+ return 0;
+ }
+
+ rc = PR_Rename(backupname, filename);
+ if (rc != PR_SUCCESS) {
+ slapi_log_err(SLAPI_LOG_INFO, "dse_check_file",
+ "The configuration file %s was NOT able to be restored from
%s, error %d\n", filename, backupname, rc);
+ return 0;
+ }
- if ( PR_GetFileInfo64( filename, &prfinfo ) == PR_SUCCESS && prfinfo.size
> 0 ) {
slapi_log_err(SLAPI_LOG_INFO, "dse_check_file",
- "The configuration file %s was restored from backup %s\n",
filename, backupname);
- return (1);
+ "The configuration file %s was restored from backup %s\n",
filename, backupname);
+ return 1;
+
} else {
- slapi_log_err(SLAPI_LOG_ERR, "dse_check_file",
- "The configuration file %s was not restored from backup %s, error
%d\n",
- filename, backupname, rc);
- return (0);
+ slapi_log_err(SLAPI_LOG_INFO, "dse_check_file", "No backup
filename provided.\n");
+ return 0;
}
}
+
static int
dse_read_one_file(struct dse *pdse, const char *filename, Slapi_PBlock *pb,
int primary_file )
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.