diff options
author | Noriko Hosoi <nhosoi@redhat.com> | 2007-12-04 17:52:56 +0000 |
---|---|---|
committer | Noriko Hosoi <nhosoi@redhat.com> | 2007-12-04 17:52:56 +0000 |
commit | 8736b7804edf65d9f996f753413566a90d91a472 (patch) | |
tree | a96991479dcd025715add88de12636cf7769c42e /ldap/servers/slapd | |
parent | 4b56e87e61399e6c7d5501e06ada3f22ffb4b728 (diff) | |
download | ds-8736b7804edf65d9f996f753413566a90d91a472.tar.gz ds-8736b7804edf65d9f996f753413566a90d91a472.tar.xz ds-8736b7804edf65d9f996f753413566a90d91a472.zip |
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.
Diffstat (limited to 'ldap/servers/slapd')
-rw-r--r-- | ldap/servers/slapd/back-ldbm/archive.c | 10 |
1 files changed, 7 insertions, 3 deletions
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 <directory> */ + char *rawdirectory = NULL; /* -a <directory> */ + 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; } |