[Fedora-directory-commits] ldapserver/ldap/servers/slapd/back-ldbm archive.c, 1.14, 1.15

Noriko Hosoi (nhosoi) fedora-directory-commits at redhat.com
Tue Dec 4 17:53:05 UTC 2007


Author: nhosoi

Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv22611

Modified Files:
	archive.c 
Log Message:
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.



Index: archive.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/archive.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- archive.c	8 Oct 2007 18:45:00 -0000	1.14
+++ archive.c	4 Dec 2007 17:52:56 -0000	1.15
@@ -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 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 @@
         }
     }
 out:
+    slapi_ch_free_string(&directory);
     return return_value;
 }
 




More information about the Fedora-directory-commits mailing list