[Fedora-directory-commits] ldapserver/ldap/servers/slapd main.c, 1.20, 1.21 pblock.c, 1.9, 1.10 slap.h, 1.25, 1.26 slapi-private.h, 1.15, 1.16 task.c, 1.11, 1.12

Noriko Hosoi (nhosoi) fedora-directory-commits at redhat.com
Fri Sep 7 19:08:47 UTC 2007


Author: nhosoi

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

Modified Files:
	main.c pblock.c slap.h slapi-private.h task.c 
Log Message:
Resolves: #236256
Summary: verify-db.pl (db_verify) does not work on a little endian machine
(comment #1-#4)
Description: 1) introducing dbverify mode to ns-slapd.
2) providing new script dbverify to call "ns-slapd dbverify"
3) fixing verify-db.pl to call dbverify instead of db_verify from BDB



Index: main.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/main.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- main.c	17 Aug 2007 02:12:37 -0000	1.20
+++ main.c	7 Sep 2007 19:08:45 -0000	1.21
@@ -112,6 +112,7 @@
 static int slapd_exemode_archive2db();
 static int slapd_exemode_db2archive();
 static int slapd_exemode_upgradedb();
+static int slapd_exemode_dbverify();
 static int slapd_exemode_dbtest();
 static int slapd_exemode_suffix2instance();
 static int slapd_debug_level_string2level( const char *s );
@@ -374,16 +375,16 @@
 		exemode = SLAPD_EXEMODE_REFERRAL;
 	} else if ( strcmp( s, "suffix2instance" ) == 0 ) {
 		exemode = SLAPD_EXEMODE_SUFFIX2INSTANCE;
-	}
-	else if ( strcmp( s, "upgradedb" ) == 0 )
-	{
+	} else if ( strcmp( s, "upgradedb" ) == 0 ) {
 		exemode = SLAPD_EXEMODE_UPGRADEDB;
+	} else if ( strcmp( s, "dbverify" ) == 0 ) {
+		exemode = SLAPD_EXEMODE_DBVERIFY;
 	}
 	else if ( exit_if_unknown ) {
 		fprintf( stderr, "usage: %s -D configdir "
 				 "[ldif2db | db2ldif | archive2db "
 				 "| db2archive | db2index | refer | suffix2instance"
-				 " | upgradedb] "
+				 " | upgradedb | dbverify] "
 				 "[options]\n", progname );
 		exit( 1 );
 	} else {
@@ -443,6 +444,9 @@
     case SLAPD_EXEMODE_UPGRADEDB:
 	usagestr = "usage: %s %s%s-D configdir [-d debuglevel] [-f] -a archivedir\n";
 	break;
+    case SLAPD_EXEMODE_DBVERIFY:
+	usagestr = "usage: %s %s%s-D configdir [-d debuglevel] [-n backend-instance-name]\n";
+	break;
 
     default:	/* SLAPD_EXEMODE_SLAPD */
 	usagestr = "usage: %s %s%s-D configdir [-d debuglevel] "
@@ -480,7 +484,8 @@
 static int db2ldif_dump_replica = 0;
 static int db2ldif_dump_uniqueid = 1;
 static int ldif2db_generate_uniqueid = SLAPI_UNIQUEID_GENERATE_TIME_BASED;	
-static int ldif2db_load_state= 1;
+static int ldif2db_load_state = 1;
+static int dbverify_verbose = 0;
 static char *ldif2db_namespaceid = NULL;
 int importexport_encrypt = 0;
 static int upgradedb_force = 0;
@@ -983,6 +988,13 @@
 	case SLAPD_EXEMODE_UPGRADEDB:
 		return slapd_exemode_upgradedb();
 
+	case SLAPD_EXEMODE_DBVERIFY:
+		return_value = slapd_exemode_dbverify();
+		if (return_value == 0)
+			return return_value;
+		else
+			return 1;
+
 	case SLAPD_EXEMODE_PRINTVERSION:
 		slapd_print_version(1);
 		exit(1);
@@ -1368,6 +1380,15 @@
 		{"configDir",ArgRequired,'D'},
 		{0,0,0}};
 
+	char *opts_dbverify = "vVfd:n:D:"; 
+	struct opt_ext long_options_dbverify[] = {
+		{"version",ArgNone,'v'},
+		{"debug",ArgRequired,'d'},
+		{"backend",ArgRequired,'n'},
+		{"configDir",ArgRequired,'D'},
+		{"verbose",ArgNone,'V'},
+		{0,0,0}};
+
 	char *opts_referral = "vd:p:r:SD:"; 
 	struct opt_ext long_options_referral[] = {
 		{"version",ArgNone,'v'},
@@ -1464,6 +1485,10 @@
 		opts = opts_upgradedb;
 		long_opts = long_options_upgradedb;
 		break;
+	case SLAPD_EXEMODE_DBVERIFY:
+		opts = opts_dbverify;
+		long_opts = long_options_dbverify;
+		break;
 	default:	/* SLAPD_EXEMODE_SLAPD */
 		opts = opts_slapd;
 		long_opts = long_options_slapd;
@@ -1567,7 +1592,8 @@
 				slapd_exemode == SLAPD_EXEMODE_ARCHIVE2DB) {
 				/* The -n argument will give the name of a backend instance. */
 				cmd_line_instance_name = optarg_ext;
-			} else if (slapd_exemode == SLAPD_EXEMODE_DB2LDIF) {
+			} else if (slapd_exemode == SLAPD_EXEMODE_DB2LDIF ||
+			 	slapd_exemode == SLAPD_EXEMODE_DBVERIFY) {
 			    char *s = slapi_ch_strdup(optarg_ext);
 			    charray_add(&cmd_line_instance_names, s);
 			} else { 
@@ -1726,7 +1752,11 @@
 			break;
 
 		case 'V':
-		  	slapd_exemode = SLAPD_EXEMODE_PRINTVERSION;
+			if ( slapd_exemode == SLAPD_EXEMODE_DBVERIFY ) {
+				dbverify_verbose = 1;
+			} else {
+		  		slapd_exemode = SLAPD_EXEMODE_PRINTVERSION;
+			}
 			break;
 
 		case 'a':	/* archive pathname for db */
@@ -2004,7 +2034,7 @@
         exit( 1 );
     }
 
-    /* this should be the first time this are called!  if the init order
+    /* this should be the first time to be called!  if the init order
      * is ever changed, these lines should be changed (or erased)!
      */
     mapping_tree_init();
@@ -2546,7 +2576,7 @@
         exit( 1 );
     }
 
-    /* this should be the first time this are called!  if the init order
+    /* this should be the first time to be called!  if the init order
      * is ever changed, these lines should be changed (or erased)!
      */
     mapping_tree_init();
@@ -2601,10 +2631,58 @@
     return( return_value );
 }
 
+/*
+ * function to perform DB verify
+ */
+static int
+slapd_exemode_dbverify()
+{
+    int return_value = 0;
+    Slapi_PBlock pb;
+    struct slapdplugin *backend_plugin;
+    slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
+
+    /* this should be the first time to be called!  if the init order
+     * is ever changed, these lines should be changed (or erased)!
+     */
+    mapping_tree_init();
+    if ((backend_plugin = plugin_get_by_name("ldbm database")) == NULL) {
+        LDAPDebug(LDAP_DEBUG_ANY, 
+            "ERROR: Could not find the ldbm backend plugin.\n",
+            0, 0, 0);
+        exit(1);
+    }
+
+    /* check for slapi v2 support */
+    if (! SLAPI_PLUGIN_IS_V2(backend_plugin)) {
+        LDAPDebug(LDAP_DEBUG_ANY, "ERROR: %s is too old to do dbverify.\n",
+                  backend_plugin->plg_name, 0, 0);
+        exit(1);
+    }
+
+    memset( &pb, '\0', sizeof(pb) );
+    pb.pb_backend = NULL;
+    pb.pb_seq_val = dbverify_verbose;
+    pb.pb_plugin = backend_plugin;
+    pb.pb_instance_name = (char *)cmd_line_instance_names;
+    pb.pb_task_flags = TASK_RUNNING_FROM_COMMANDLINE;
+    
+    if ( backend_plugin->plg_dbverify != NULL ) {
+        return_value = (*backend_plugin->plg_dbverify)( &pb );
+    } else {
+        LDAPDebug( LDAP_DEBUG_ANY,
+                   "ERROR: no db verify function defined for "
+                   "%s\n", backend_plugin->plg_name, 0, 0 );
+        return_value = -1;
+    }
+
+    return( return_value );
+}
+
 
 static int
 slapd_exemode_dbtest()
-{	
+{
     int return_value= 0;
     Slapi_PBlock pb;
     struct slapdplugin *plugin;


Index: pblock.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/pblock.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- pblock.c	27 Feb 2007 02:57:30 -0000	1.9
+++ pblock.c	7 Sep 2007 19:08:45 -0000	1.10
@@ -617,6 +617,12 @@
         }
         (*(IFP *)value) = pblock->pb_plugin->plg_upgradedb;
         break;
+    case SLAPI_PLUGIN_DB_DBVERIFY_FN:
+        if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
+                return( -1 );
+        }
+        (*(IFP *)value) = pblock->pb_plugin->plg_dbverify;
+        break;
     case SLAPI_PLUGIN_DB_BEGIN_FN:
         if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
                 return( -1 );
@@ -1886,6 +1892,12 @@
 		}
 		pblock->pb_plugin->plg_upgradedb = (IFP) value;
 		break;
+	case SLAPI_PLUGIN_DB_DBVERIFY_FN:
+		if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
+			return( -1 );
+		}
+		pblock->pb_plugin->plg_dbverify = (IFP) value;
+		break;
 	case SLAPI_PLUGIN_DB_BEGIN_FN:
 		if ( pblock->pb_plugin->plg_type != SLAPI_PLUGIN_DATABASE ) {
 			return( -1 );


Index: slap.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/slap.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- slap.h	17 Aug 2007 02:12:37 -0000	1.25
+++ slap.h	7 Sep 2007 19:08:45 -0000	1.26
@@ -65,8 +65,9 @@
 #define SLAPD_EXEMODE_DB2INDEX		7
 #define SLAPD_EXEMODE_REFERRAL		8
 #define SLAPD_EXEMODE_SUFFIX2INSTANCE	9
-#define SLAPD_EXEMODE_PRINTVERSION     10
+#define SLAPD_EXEMODE_PRINTVERSION  10
 #define SLAPD_EXEMODE_UPGRADEDB     11
+#define SLAPD_EXEMODE_DBVERIFY      12
 
 #ifdef _WIN32
 #ifndef DONT_DECLARE_SLAPD_LDAP_DEBUG
@@ -766,14 +767,14 @@
 			IFP	plg_un_db_flush;	  /* close */
 			IFP	plg_un_db_seq;	  	  /* sequence */
 			IFP	plg_un_db_entry;	  /* entry send */
-			IFP	plg_un_db_referral;       /* referral send */
+			IFP	plg_un_db_referral;   /* referral send */
 			IFP	plg_un_db_result;	  /* result send */
 			IFP	plg_un_db_ldif2db;	  /* ldif 2 database */
 			IFP	plg_un_db_db2ldif;	  /* database 2 ldif */
 			IFP	plg_un_db_db2index;	  /* database 2 index */
-			IFP	plg_un_db_archive2db;	  /* ldif 2 database */
-			IFP	plg_un_db_db2archive;	  /* database 2 ldif */
-			IFP	plg_un_db_upgradedb;	  /* convert old idl to new */
+			IFP	plg_un_db_archive2db; /* ldif 2 database */
+			IFP	plg_un_db_db2archive; /* database 2 ldif */
+			IFP	plg_un_db_upgradedb;  /* convert old idl to new */
 			IFP	plg_un_db_begin;	  /* dbase txn begin */
 			IFP	plg_un_db_commit;	  /* dbase txn commit */
 			IFP	plg_un_db_abort;	  /* dbase txn abort */
@@ -784,6 +785,7 @@
 			IFP	plg_un_db_register_oc_callback; /* Register a function to call when a operation is applied to a given ObjectClass */
 			IFP	plg_un_db_init_instance;  /* initializes new db instance */
 			IFP	plg_un_db_wire_import;    /* fast replica update */
+			IFP	plg_un_db_verify;	  /* verify db files */
 		} plg_un_db;
 #define plg_bind		plg_un.plg_un_db.plg_un_db_bind
 #define plg_unbind		plg_un.plg_un_db.plg_un_db_unbind
@@ -809,6 +811,7 @@
 #define plg_archive2db		plg_un.plg_un_db.plg_un_db_archive2db
 #define plg_db2archive		plg_un.plg_un_db.plg_un_db_db2archive
 #define plg_upgradedb		plg_un.plg_un_db.plg_un_db_upgradedb
+#define plg_dbverify		plg_un.plg_un_db.plg_un_db_verify
 #define plg_dbsize		plg_un.plg_un_db.plg_un_db_dbsize
 #define plg_dbtest		plg_un.plg_un_db.plg_un_db_dbtest
 #define plg_rmdb		plg_un.plg_un_db.plg_un_db_rmdb


Index: slapi-private.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/slapi-private.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- slapi-private.h	14 Dec 2006 23:16:54 -0000	1.15
+++ slapi-private.h	7 Sep 2007 19:08:45 -0000	1.16
@@ -829,9 +829,10 @@
 #define SLAPI_PLUGIN_DB_DB2INDEX_FN		228
 #define SLAPI_PLUGIN_DB_NEXT_SEARCH_ENTRY_EXT_FN	229
 #define SLAPI_PLUGIN_DB_ENTRY_RELEASE_FN	230
-#define SLAPI_PLUGIN_DB_INIT_INSTANCE_FN        231
-#define SLAPI_PLUGIN_DB_WIRE_IMPORT_FN          234
+#define SLAPI_PLUGIN_DB_INIT_INSTANCE_FN	231
+#define SLAPI_PLUGIN_DB_WIRE_IMPORT_FN		234
 #define SLAPI_PLUGIN_DB_UPGRADEDB_FN		235
+#define SLAPI_PLUGIN_DB_DBVERIFY_FN			236
 /* database plugin-specific parameters */
 #define SLAPI_PLUGIN_DB_NO_ACL        		250
 #define SLAPI_PLUGIN_DB_RMDB_FN         	280


Index: task.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/task.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- task.c	9 Apr 2007 23:02:41 -0000	1.11
+++ task.c	7 Sep 2007 19:08:45 -0000	1.12
@@ -55,13 +55,13 @@
 static int shutting_down = 0;
 
 
-#define TASK_BASE_DN    "cn=tasks, cn=config"
-#define TASK_IMPORT_DN  "cn=import, cn=tasks, cn=config"
-#define TASK_EXPORT_DN  "cn=export, cn=tasks, cn=config"
-#define TASK_BACKUP_DN  "cn=backup, cn=tasks, cn=config"
-#define TASK_RESTORE_DN "cn=restore, cn=tasks, cn=config"
-#define TASK_INDEX_DN   "cn=index, cn=tasks, cn=config"
-#define TASK_UPGRADEDB_DN   "cn=upgradedb, cn=tasks, cn=config"
+#define TASK_BASE_DN      "cn=tasks, cn=config"
+#define TASK_IMPORT_DN    "cn=import, cn=tasks, cn=config"
+#define TASK_EXPORT_DN    "cn=export, cn=tasks, cn=config"
+#define TASK_BACKUP_DN    "cn=backup, cn=tasks, cn=config"
+#define TASK_RESTORE_DN   "cn=restore, cn=tasks, cn=config"
+#define TASK_INDEX_DN     "cn=index, cn=tasks, cn=config"
+#define TASK_UPGRADEDB_DN "cn=upgradedb, cn=tasks, cn=config"
 
 #define TASK_LOG_NAME           "nsTaskLog"
 #define TASK_STATUS_NAME        "nsTaskStatus"
@@ -1486,6 +1486,7 @@
     }
 
 out:
+    slapi_ch_free((void **)&mypb.pb_seq_val);
     if (rv != 0) {
         if (task)
             destroy_task(1, task);




More information about the Fedora-directory-commits mailing list