ldap/servers/slapd/back-ldbm/dblayer.c | 60 ++++++++++++-------------
ldap/servers/slapd/back-ldbm/proto-back-ldbm.h | 4 -
3 files changed, 39 insertions(+), 31 deletions(-)
New commits:
commit 819cbfd6ee29cc485f516ff4829cf2ff10ce81de
Author: Noriko Hosoi <nhosoi@redhat.com>
Date: Thu May 15 18:57:21 2014 -0700
Ticket #47804 - db2bak.pl error with changelogdb
Bug description: Backup utility db2bak[.pl] copies not just backend
db files but also changelog db files, which is not associated with
the backend instance, but the backup code blindly expected it.
Fix description: If the copying directory is a changelog db dir,
skip retrieving the backend instance info and just copy the files
underneath.
https://fedorahosted.org/389/ticket/47804
Reviewed by rmeggins@redhat.com (Thank you, Rich!!)
diff --git a/ldap/servers/slapd/back-ldbm/dbhelp.c b/ldap/servers/slapd/back-ldbm/dbhelp.c
index 29c0247..40966ac 100644
--- a/ldap/servers/slapd/back-ldbm/dbhelp.c
+++ b/ldap/servers/slapd/back-ldbm/dbhelp.c
@@ -139,6 +139,12 @@ dblayer_copy_file_keybykey(DB_ENV *env,
(*(p + sizeof(LDBM_ENTRYRDN_STR) - 1) == '.')) {
/* entryrdn.db */
struct attrinfo *ai = NULL;
+ if (NULL == inst) {
+ LDAPDebug0Args(LDAP_DEBUG_ANY,
+ "dblayer_copy_file_keybykey(entryrdn), "
+ "dup_cmp_fn cannot be retrieved since inst is NULL.\n");
+ goto error;
+ }
ainfo_get(inst->inst_be, LDBM_ENTRYRDN_STR, &ai);
if (ai->ai_dup_cmp_fn) {
/* If set, use the special dup compare callback */
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index cb0509f..0fda6d3 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -5922,17 +5922,15 @@ dblayer_copy_directory(struct ldbminfo *li,
char *dest_dir,
int restore,
int *cnt,
- int instance_dir_flag,
int indexonly,
- int resetlsns)
+ int resetlsns,
+ int is_changelog)
{
dblayer_private *priv = NULL;
char *new_src_dir = NULL;
char *new_dest_dir = NULL;
PRDir *dirhandle = NULL;
PRDirEntry *direntry = NULL;
- size_t filename_length = 0;
- size_t offset = 0;
char *compare_piece = NULL;
char *filename1;
char *filename2;
@@ -5941,8 +5939,8 @@ dblayer_copy_directory(struct ldbminfo *li,
char *inst_dirp = NULL;
char inst_dir[MAXPATHLEN];
char sep;
- int suffix_len = 0;
- ldbm_instance *inst = NULL;
+ int src_is_fullpath = 0;
+ ldbm_instance *inst = NULL;
if (!src_dir || '\0' == *src_dir)
{
@@ -5966,20 +5964,28 @@ dblayer_copy_directory(struct ldbminfo *li,
else
relative_instance_name++;
- inst = ldbm_instance_find_by_name(li, relative_instance_name);
- if (NULL == inst) {
- LDAPDebug(LDAP_DEBUG_ANY, "Backend instance \"%s\" does not exist; "
- "Instance path %s could be invalid.\n",
- relative_instance_name, src_dir, 0);
- return return_value;
+ if (is_fullpath(src_dir)) {
+ src_is_fullpath = 1;
+ }
+ if (is_changelog) {
+ if (!src_is_fullpath) {
+ LDAPDebug1Arg(LDAP_DEBUG_ANY, "Changelogdir \"%s\" is not full path; "
+ "Skipping it.\n", src_dir);
+ return 0;
+ }
+ } else {
+ inst = ldbm_instance_find_by_name(li, relative_instance_name);
+ if (NULL == inst) {
+ LDAPDebug(LDAP_DEBUG_ANY, "Backend instance \"%s\" does not exist; "
+ "Instance path %s could be invalid.\n",
+ relative_instance_name, src_dir, 0);
+ return return_value;
+ }
}
- if (is_fullpath(src_dir))
- {
+ if (src_is_fullpath) {
new_src_dir = src_dir;
- }
- else
- {
+ } else {
int len;
inst_dirp = dblayer_get_full_inst_dir(inst->inst_li, inst,
@@ -6006,7 +6012,6 @@ dblayer_copy_directory(struct ldbminfo *li,
return return_value;
}
- suffix_len = sizeof(LDBM_SUFFIX) - 1;
while (NULL != (direntry =
PR_ReadDir(dirhandle, PR_SKIP_DOT | PR_SKIP_DOT_DOT)))
{
@@ -6020,15 +6025,10 @@ dblayer_copy_directory(struct ldbminfo *li,
continue;
}
- /* Look at the last three characters in the filename */
- filename_length = strlen(direntry->name);
- if (filename_length > suffix_len) {
- offset = filename_length - suffix_len;
- } else {
- offset = 0;
+ compare_piece = PL_strrchr((char *)direntry->name, '.');
+ if (NULL == compare_piece) {
+ compare_piece = (char *)direntry->name;
}
- compare_piece = (char *)direntry->name + offset;
-
/* rename .db3 -> .db4 or .db4 -> .db */
if (0 == strcmp(compare_piece, LDBM_FILENAME_SUFFIX) ||
0 == strcmp(compare_piece, LDBM_SUFFIX_OLD) ||
@@ -6128,6 +6128,7 @@ out:
/*
* Get changelogdir from cn=changelog5,cn=config
* The value does not have trailing spaces nor slashes.
+ * The changelogdir value must be a fullpath.
*/
static int
_dblayer_get_changelogdir(struct ldbminfo *li, char **changelogdir)
@@ -6343,7 +6344,7 @@ dblayer_backup(struct ldbminfo *li, char *dest_dir, Slapi_Task *task)
return_value = dblayer_copy_directory(li, task, changelogdir,
changelog_destdir,
0 /* backup */,
- &cnt, 0, 0, 0);
+ &cnt, 0, 0, 1);
if (return_value) {
LDAPDebug(LDAP_DEBUG_ANY,
"Backup: error in copying directory "
@@ -7016,7 +7017,8 @@ int dblayer_restore(struct ldbminfo *li, char *src_dir, Slapi_Task *task, char *
/* Get the parent dir of changelogdir */
*cldirname = '\0';
return_value = dblayer_copy_directory(li, task, filename1,
- changelogdir, 1 /* restore */, &cnt, 0, 0, 0);
+ changelogdir, 1 /* restore */,
+ &cnt, 0, 0, 1);
*cldirname = '/';
if (return_value) {
LDAPDebug1Arg(LDAP_DEBUG_ANY,
@@ -7048,7 +7050,7 @@ int dblayer_restore(struct ldbminfo *li, char *src_dir, Slapi_Task *task, char *
restore_dir = inst->inst_parent_dir_name;
/* If we're doing a partial restore, we need to reset the LSNs on the data files */
if (dblayer_copy_directory(li, task, filename1,
- restore_dir, 1 /* restore */, &cnt, 0, 0, (bename) ? 1 : 0) == 0)
+ restore_dir, 1 /* restore */, &cnt, 0, (bename) ? 1 : 0, 0) == 0)
continue;
else
{
diff --git a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
index 561a208..0de0632 100644
--- a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
+++ b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
@@ -144,8 +144,8 @@ int dblayer_backup(struct ldbminfo *li, char *destination_directory,
int dblayer_restore(struct ldbminfo *li, char* source_directory, Slapi_Task *task, char *bename);
int dblayer_copy_directory(struct ldbminfo *li, Slapi_Task *task,
char *instance_dir, char *destination_dir,
- int restore, int *cnt, int instance_dir_flag,
- int indexonly, int resetlsns);
+ int restore, int *cnt, int indexonly,
+ int resetlsns, int is_changelog);
int dblayer_copyfile(char* source, char * destination, int overwrite, int mode);
int dblayer_delete_instance_dir(backend *be);
int dblayer_delete_database(struct ldbminfo *li);
--
389 commits mailing list
389-commits@lists.fedoraproject.org
https://admin.fedoraproject.org/mailman/listinfo/389-commits
No comments:
Post a Comment