BDB_LOCKD,
BDB_SSTACK,
BDB_MODE,
- BDB_PGSIZE
+ BDB_PGSIZE,
+ BDB_CHECKSUM
};
static ConfigTable bdbcfg[] = {
bdb_cf_gen, "( OLcfgDbAt:1.2 NAME 'olcDbCheckpoint' "
"DESC 'Database checkpoint interval in kbytes and minutes' "
"SYNTAX OMsDirectoryString SINGLE-VALUE )",NULL, NULL },
+ { "checksum", NULL, 1, 2, 0, ARG_ON_OFF|ARG_MAGIC|BDB_CHECKSUM,
+ bdb_cf_gen, "( OLcfgDbAt:1.16 NAME 'olcDbChecksum' "
+ "DESC 'Enable database checksum validation' "
+ "SYNTAX OMsBoolean SINGLE-VALUE )", NULL, NULL },
{ "cryptfile", "file", 2, 2, 0, ARG_STRING|ARG_MAGIC|BDB_CRYPTFILE,
bdb_cf_gen, "( OLcfgDbAt:1.13 NAME 'olcDbCryptFile' "
"DESC 'Pathname of file containing the DB encryption key' "
c->value_int = 1;
break;
+ case BDB_CHECKSUM:
+ if ( bdb->bi_flags & BDB_CHKSUM )
+ c->value_int = 1;
+ break;
+
case BDB_INDEX:
bdb_attr_index_unparse( bdb, &c->rvalue_vals );
if ( !c->rvalue_vals ) rc = 1;
case BDB_NOSYNC:
bdb->bi_dbenv->set_flags( bdb->bi_dbenv, DB_TXN_NOSYNC, 0 );
break;
+ case BDB_CHECKSUM:
+ bdb->bi_flags &= ~BDB_CHKSUM;
+ break;
case BDB_INDEX:
if ( c->valx == -1 ) {
int i;
}
break;
+ case BDB_CHECKSUM:
+ if ( c->value_int )
+ bdb->bi_flags |= BDB_CHKSUM;
+ else
+ bdb->bi_flags &= ~BDB_CHKSUM;
+ break;
+
case BDB_INDEX:
rc = bdb_attr_index_config( bdb, c->fname, c->lineno,
c->argc - 1, &c->argv[1], &c->reply);
}
}
+ if( bdb->bi_flags & BDB_CHKSUM ) {
+ rc = db->bdi_db->set_flags( db->bdi_db, DB_CHKSUM );
+ if ( rc ) {
+ Debug( LDAP_DEBUG_ANY,
+ "bdb_db_cache: db set_flags(DB_CHKSUM)(%s) failed: %s (%d)\n",
+ bdb->bi_dbenv_home, db_strerror(rc), rc );
+ ldap_pvt_thread_mutex_unlock( &bdb->bi_database_mutex );
+ db->bdi_db->close( db->bdi_db, 0 );
+ ch_free( db );
+ return rc;
+ }
+ }
+
/* If no explicit size set, use the default */
flags = bdb_db_findsize( bdb, name );
if ( !flags ) flags = BDB_PAGESIZE;
}
}
+ if( bdb->bi_flags & BDB_CHKSUM ) {
+ rc = db->bdi_db->set_flags( db->bdi_db, DB_CHKSUM );
+ if ( rc ) {
+ snprintf(cr->msg, sizeof(cr->msg),
+ "database \"%s\": db set_flags(DB_CHKSUM)(%s) failed: %s (%d).",
+ be->be_suffix[0].bv_val,
+ bdb->bi_dbenv_home, db_strerror(rc), rc );
+ Debug( LDAP_DEBUG_ANY,
+ LDAP_XSTRING(bdb_db_open) ": %s\n",
+ cr->msg, 0, 0 );
+ goto fail;
+ }
+ }
+
rc = bdb_db_findsize( bdb, (struct berval *)&bdbi_databases[i].name );
if( i == BDB_ID2ENTRY ) {