From 8736b7804edf65d9f996f753413566a90d91a472 Mon Sep 17 00:00:00 2001 From: Noriko Hosoi Date: Tue, 4 Dec 2007 17:52:56 +0000 Subject: Resolves: #174776 Summary: Multiple restores from a non-existant directory could wipe out database Description: The given archive path was not normalized. Due to the trailing slash '/', comparing with the db dir failed and wiped out the db dirs. Applying the path normalization to the archive path. --- ldap/servers/slapd/back-ldbm/archive.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'ldap') diff --git a/ldap/servers/slapd/back-ldbm/archive.c b/ldap/servers/slapd/back-ldbm/archive.c index 0c0fc0f3..be2c4c63 100644 --- a/ldap/servers/slapd/back-ldbm/archive.c +++ b/ldap/servers/slapd/back-ldbm/archive.c @@ -47,7 +47,8 @@ int ldbm_back_archive2ldbm( Slapi_PBlock *pb ) { struct ldbminfo *li; - char *directory = NULL; /* -a */ + char *rawdirectory = NULL; /* -a */ + char *directory = NULL; /* normalized */ char *backendname = NULL; int return_value = -1; int task_flags = 0; @@ -56,18 +57,20 @@ int ldbm_back_archive2ldbm( Slapi_PBlock *pb ) int is_old_to_new = 0; slapi_pblock_get( pb, SLAPI_PLUGIN_PRIVATE, &li ); - slapi_pblock_get( pb, SLAPI_SEQ_VAL, &directory ); + slapi_pblock_get( pb, SLAPI_SEQ_VAL, &rawdirectory ); slapi_pblock_get( pb, SLAPI_BACKEND_INSTANCE_NAME, &backendname); slapi_pblock_get( pb, SLAPI_BACKEND_TASK, &task ); slapi_pblock_get( pb, SLAPI_TASK_FLAGS, &task_flags ); li->li_flags = run_from_cmdline = (task_flags & TASK_RUNNING_FROM_COMMANDLINE); - if ( !directory || !*directory ) { + if ( !rawdirectory || !*rawdirectory ) { LDAPDebug( LDAP_DEBUG_ANY, "archive2db: no archive name\n", 0, 0, 0 ); return( -1 ); } + directory = rel2abspath(rawdirectory); + /* check the current idl format vs backup DB version */ if (idl_get_idl_new()) { @@ -251,6 +254,7 @@ int ldbm_back_archive2ldbm( Slapi_PBlock *pb ) } } out: + slapi_ch_free_string(&directory); return return_value; } -- cgit