diff options
author | Noriko Hosoi <nhosoi@redhat.com> | 2007-03-15 21:34:32 +0000 |
---|---|---|
committer | Noriko Hosoi <nhosoi@redhat.com> | 2007-03-15 21:34:32 +0000 |
commit | d155d05b4648a4803dab0306b6249f2d4cdf9610 (patch) | |
tree | 82c9f26d35cd15bec3ff6aab2e00e1005fcbf08e /ldap/servers/slapd | |
parent | 4f079fb8eb74f636aeb8ac64ebfb88b714fe1909 (diff) | |
download | ds-d155d05b4648a4803dab0306b6249f2d4cdf9610.tar.gz ds-d155d05b4648a4803dab0306b6249f2d4cdf9610.tar.xz ds-d155d05b4648a4803dab0306b6249f2d4cdf9610.zip |
Resolves: 232050
Summary: Change format of DBVERSION and guardian files (Comment #4)
1) introduced new strings for DBVERSION
2) added the logic to compare the new DBVERSION strings
note: we don't store the current db version string in the backend source
code any more. Instead, we get it from Berkeley DB header file db.h.
Diffstat (limited to 'ldap/servers/slapd')
-rw-r--r-- | ldap/servers/slapd/back-ldbm/back-ldbm.h | 44 | ||||
-rw-r--r-- | ldap/servers/slapd/back-ldbm/dblayer.c | 351 | ||||
-rw-r--r-- | ldap/servers/slapd/back-ldbm/dbversion.c | 38 | ||||
-rw-r--r-- | ldap/servers/slapd/back-ldbm/ldbm_config.c | 4 | ||||
-rw-r--r-- | ldap/servers/slapd/back-ldbm/proto-back-ldbm.h | 2 | ||||
-rw-r--r-- | ldap/servers/slapd/back-ldbm/start.c | 2 | ||||
-rw-r--r-- | ldap/servers/slapd/back-ldbm/upgrade.c | 125 |
7 files changed, 360 insertions, 206 deletions
diff --git a/ldap/servers/slapd/back-ldbm/back-ldbm.h b/ldap/servers/slapd/back-ldbm/back-ldbm.h index cafaf60a..6463fbeb 100644 --- a/ldap/servers/slapd/back-ldbm/back-ldbm.h +++ b/ldap/servers/slapd/back-ldbm/back-ldbm.h @@ -134,26 +134,29 @@ typedef unsigned short u_int16_t; #define LDBM_VERSION_MAXBUF 64 #define LDBM_DATABASE_TYPE_NAME "ldbm database" /* + * 232050: Change format of DBVERSION and guardian files + * new format: + * implementation/version/server backend plugin name[/other tag][/other tag].... + * For example: + * bdb/4.2/libback-ldbm/newidl + * This indicates that the files use Berkeley DB version 4.2, they are used + * by the server libback-ldbm database plugin, and the index files use the + * newidl format. + * Starting from DS7.2 + */ +#define BDB_IMPL "bdb" +#define BDB_BACKEND "libback-ldbm" /* This backend plugin */ + +/* * While we support both new and old idl index, * we distinguish them by the following 2 macros. * When we drop the old idl code, we eliminate LDBM_VERSION_OLD. * bug #604922 */ -/* To set new idl default, uncomment it. */ -#define USE_NEW_IDL 1 - #define LDBM_VERSION_BASE "Netscape-ldbm/" #define LDBM_VERSION "Netscape-ldbm/7.0" /* db42: new idl -> old */ #define LDBM_VERSION_NEW "Netscape-ldbm/7.0_NEW" /* db42: new idl */ - /* used only when - * USE_NEW_IDL is - * NOT defined - */ #define LDBM_VERSION_OLD "Netscape-ldbm/7.0_CLASSIC" /* db42: old idl */ - /* used only when - * USE_NEW_IDL is - * defined - */ #define LDBM_VERSION_62 "Netscape-ldbm/6.2" /* db33: new idl */ #define LDBM_VERSION_61 "Netscape-ldbm/6.1" /* db33: new idl */ #define LDBM_VERSION_60 "Netscape-ldbm/6.0" /* db33: old idl */ @@ -364,7 +367,7 @@ struct attrinfo { void *ai_plugin; char **ai_index_rules; /* matching rule OIDs */ void *ai_dblayer; /* private data used by the dblayer code */ - PRInt32 ai_dblayer_count; /* used by the dblayer code */ + PRInt32 ai_dblayer_count; /* used by the dblayer code */ idl_private *ai_idl; /* private data used by the IDL code (eg locking the IDLs) */ attrcrypt_private *ai_attrcrypt; /* private data used by the attribute encryption code (eg is it enabled or not) */ }; @@ -380,7 +383,9 @@ struct id_array { typedef struct id_array Id_Array; struct _db_upgrade_info { - char* old_version_string; + char *old_version_string; + int old_dbversion_major; + int old_dbversion_minor; int type; int action; }; @@ -396,8 +401,17 @@ typedef struct _db_upgrade_info db_upgrade_info; #define DBVERSION_NO_UPGRADE 0x0 #define DBVERSION_NEED_IDL_OLD2NEW 0x100 #define DBVERSION_NEED_IDL_NEW2OLD 0x200 -#define DBVERSION_UPGRADE_3_4 0x400 -#define DBVERSION_NOT_SUPPORTED 0x800 +#define DBVERSION_UPGRADE_3_4 0x400 /* bdb 3.3 -> 4.2 */ + /* The log file format changed; + * No database formats changed; + * db extention: .db3 -> .db4 + */ +#define DBVERSION_UPGRADE_4_4 0x800 /* bdb 4.2 -> 4.3 -> 4.4 -> 4.5 */ + /* The log file format changed; + * No database formats changed; + * no db extention change + */ +#define DBVERSION_NOT_SUPPORTED 0x10000000 #define DBVERSION_TYPE 0x1 #define DBVERSION_ACTION 0x2 diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c index 8c066d9b..a7320d4e 100644 --- a/ldap/servers/slapd/back-ldbm/dblayer.c +++ b/ldap/servers/slapd/back-ldbm/dblayer.c @@ -346,7 +346,7 @@ static void dblayer_reset_env(struct ldbminfo *li) dblayer_private *priv = (dblayer_private*)li->li_dblayer_private; DB_ENV *pEnv = priv->dblayer_env->dblayer_DB_ENV; char *home_dir = dblayer_get_home_dir(li, NULL); - if (home_dir) + if (home_dir && *home_dir) pEnv->remove(pEnv, home_dir, DB_FORCE); } @@ -815,18 +815,18 @@ void dblayer_sys_pages(size_t *pagesize, size_t *pages, size_t *procpages, size_ #ifdef LINUX { struct sysinfo si; - size_t pages_per_mem_unit = 0; - size_t mem_units_per_page = 0; /* We don't know if these units are really pages */ + size_t pages_per_mem_unit = 0; + size_t mem_units_per_page = 0; /* We don't know if these units are really pages */ sysinfo(&si); *pagesize = getpagesize(); - if (si.mem_unit > *pagesize) { - pages_per_mem_unit = si.mem_unit / *pagesize; - *pages = si.totalram * pages_per_mem_unit; - } else { - mem_units_per_page = *pagesize / si.mem_unit; - *pages = si.totalram / mem_units_per_page; - } + if (si.mem_unit > *pagesize) { + pages_per_mem_unit = si.mem_unit / *pagesize; + *pages = si.totalram * pages_per_mem_unit; + } else { + mem_units_per_page = *pagesize / si.mem_unit; + *pages = si.totalram / mem_units_per_page; + } *availpages = dblayer_getvirtualmemsize() / *pagesize; /* okay i take that back, linux's method is more retarded here. * hopefully linux doesn't have the FILE* problem that solaris does @@ -861,7 +861,7 @@ void dblayer_sys_pages(size_t *pagesize, size_t *pages, size_t *procpages, size_ if (rval < 0) /* pstat_getstatic failed */ return; *pagesize = pst.page_size; - *pages = pst.physical_memory; + *pages = pst.physical_memory; *availpages = dblayer_getvirtualmemsize() / *pagesize; if (procpages) { @@ -894,21 +894,21 @@ void dblayer_sys_pages(size_t *pagesize, size_t *pages, size_t *procpages, size_ } } #endif - /* If this is a 32-bit build, it might be running on a 64-bit machine, - * in which case, if the box has tons of ram, we can end up telling - * the auto cache code to use more memory than the process can address. - * so we cap the number returned here. - */ + /* If this is a 32-bit build, it might be running on a 64-bit machine, + * in which case, if the box has tons of ram, we can end up telling + * the auto cache code to use more memory than the process can address. + * so we cap the number returned here. + */ #if defined(__LP64__) || defined (_LP64) #else - { - size_t one_gig_pages = GIGABYTE / *pagesize; - if (*pages > (2 * one_gig_pages) ) { - LDAPDebug(LDAP_DEBUG_TRACE,"More than 2Gbytes physical memory detected. Since this is a 32-bit process, truncating memory size used for auto cache calculations to 2Gbytes\n", - 0, 0, 0); - *pages = (2 * one_gig_pages); - } - } + { + size_t one_gig_pages = GIGABYTE / *pagesize; + if (*pages > (2 * one_gig_pages) ) { + LDAPDebug(LDAP_DEBUG_TRACE,"More than 2Gbytes physical memory detected. Since this is a 32-bit process, truncating memory size used for auto cache calculations to 2Gbytes\n", + 0, 0, 0); + *pages = (2 * one_gig_pages); + } + } #endif } @@ -921,21 +921,21 @@ int dblayer_is_cachesize_sane(size_t *cachesize) dblayer_sys_pages(&pagesize, &pages, &procpages, &availpages); if (!pagesize || !pages) return 1; /* do nothing when we can't get the avail mem */ - /* If the requested cache size is larger than the remaining pysical memory - * after the current working set size for this process has been subtracted, - * then we say that's insane and try to correct. - */ + /* If the requested cache size is larger than the remaining pysical memory + * after the current working set size for this process has been subtracted, + * then we say that's insane and try to correct. + */ issane = (int)(*cachesize / pagesize) <= (pages - procpages); if (!issane) { - *cachesize = (size_t)((pages - procpages) * pagesize); - } - /* We now compensate for DB's own compensation for metadata size - * They increase the actual cache size by 25%, but only for sizes - * less than 500Meg. - */ - if (*cachesize < 500*MEGABYTE) { - *cachesize = (size_t)((double)*cachesize * (double)0.8); - } + *cachesize = (size_t)((pages - procpages) * pagesize); + } + /* We now compensate for DB's own compensation for metadata size + * They increase the actual cache size by 25%, but only for sizes + * less than 500Meg. + */ + if (*cachesize < 500*MEGABYTE) { + *cachesize = (size_t)((double)*cachesize * (double)0.8); + } return issane; } @@ -1153,7 +1153,8 @@ dblayer_make_env(struct dblayer_private_env **env, struct ldbminfo *li) } home_dir = dblayer_get_home_dir(li, NULL); /* user specified db home */ - if (!charray_utf8_inlist(priv->dblayer_data_directories, home_dir)) + if (home_dir && *home_dir && + !charray_utf8_inlist(priv->dblayer_data_directories, home_dir)) { charray_add(&(priv->dblayer_data_directories), home_dir); } @@ -1206,6 +1207,10 @@ dblayer_get_full_inst_dir(struct ldbminfo *li, ldbm_instance *inst, else { parent_dir = dblayer_get_home_dir(li, NULL); + if (!parent_dir || !*parent_dir) { + buf = NULL; + return buf; + } mylen = strlen(parent_dir); inst->inst_parent_dir_name = slapi_ch_strdup(parent_dir); } @@ -1382,6 +1387,7 @@ int dblayer_start(struct ldbminfo *li, int dbmode) log_dir = priv->dblayer_log_directory; /* nsslapd-db-logdirectory */ if (log_dir && *log_dir) { + /* checking the user defined log dir's accessability */ return_value = dblayer_grok_directory(log_dir, DBLAYER_DIRECTORY_READWRITE_ACCESS); if (0 != return_value) { @@ -1391,6 +1397,11 @@ int dblayer_start(struct ldbminfo *li, int dbmode) return return_value; } } + else + { + /* using the home dir for the log dir, which is already checked */ + log_dir = dblayer_get_home_dir(li, NULL); + } /* Sanity check on cache size on platforms which allow us to figure out * the available phys mem */ @@ -1525,6 +1536,15 @@ int dblayer_start(struct ldbminfo *li, int dbmode) dblayer_strerror(return_value), 0); return return_value; } + /* remove transaction logs */ + return_value = dblayer_delete_transaction_logs(log_dir); + if (return_value) + { + LDAPDebug(LDAP_DEBUG_ANY, + "dblayer_start: failed to remove old transaction logs (%d)\n", + return_value, 0, 0); + return return_value; + } dbmode = DBLAYER_NORMAL_MODE; if ((return_value = dblayer_make_env(&pEnv, li)) != 0) @@ -1687,22 +1707,22 @@ autosize_import_cache(struct ldbminfo *li) if (pagesize) { char s[32]; /* big enough to hold %ld */ int import_pages; - int pages_limit = (200 * 1024) / (pagesize/1024); + int pages_limit = (200 * 1024) / (pagesize/1024); import_pages = (li->li_import_cache_autosize * pages) / 125; - /* We don't want to go wild with memory when auto-sizing, cap the - * cache size at 200 Megs to try to avoid situations where we - * attempt to allocate more memory than there is free page pool for, or - * where there's some system limit on the size of process memory - */ - if (import_pages > pages_limit) { - import_pages = pages_limit; - } + /* We don't want to go wild with memory when auto-sizing, cap the + * cache size at 200 Megs to try to avoid situations where we + * attempt to allocate more memory than there is free page pool for, or + * where there's some system limit on the size of process memory + */ + if (import_pages > pages_limit) { + import_pages = pages_limit; + } LDAPDebug(LDAP_DEBUG_ANY, "cache autosizing: import cache: %dk \n", import_pages*(pagesize/1024), NULL, NULL); LDAPDebug(LDAP_DEBUG_ANY, "li_import_cache_autosize: %d, import_pages: %d, pagesize: %d\n", li->li_import_cache_autosize, import_pages, - pagesize); + pagesize); sprintf(s, "%lu", (unsigned long)(import_pages * pagesize)); ldbm_config_internal_set(li, CONFIG_IMPORT_CACHESIZE, s); @@ -1742,7 +1762,7 @@ int dblayer_instance_start(backend *be, int mode) return 0; } - attrcrypt_init(inst); + attrcrypt_init(inst); /* Get the name of the directory that holds index files * for this instance. */ @@ -1753,8 +1773,14 @@ int dblayer_instance_start(backend *be, int mode) } inst_dirp = dblayer_get_full_inst_dir(li, inst, inst_dir, MAXPATHLEN); - return_value = dblayer_grok_directory(inst_dirp, + if (inst_dirp && *inst_dirp) { + return_value = dblayer_grok_directory(inst_dirp, DBLAYER_DIRECTORY_READWRITE_ACCESS); + } else { + LDAPDebug(LDAP_DEBUG_ANY,"Can't start because the database instance " + "directory is NULL\n", 0, 0, 0); + goto errout; + } if (0 != return_value) { LDAPDebug(LDAP_DEBUG_ANY,"Can't start because the database instance " "directory \"%s\" either doesn't exist, " @@ -1770,18 +1796,20 @@ int dblayer_instance_start(backend *be, int mode) /* Read the dbversion file if there is one, and create it * if it doesn't exist. */ if (dbversion_exists(li, inst_dirp)) { - char ldbmversion[LDBM_VERSION_MAXBUF]; - char dataversion[LDBM_VERSION_MAXBUF]; + char *ldbmversion = NULL; + char *dataversion = NULL; - if (dbversion_read(li, inst_dirp, ldbmversion, dataversion) != 0) { + if (dbversion_read(li, inst_dirp, &ldbmversion, &dataversion) != 0) { LDAPDebug(LDAP_DEBUG_ANY, "Warning: Unable to read dbversion " "file in %s\n", inst->inst_dir_name, 0, 0); } else { int rval = 0; /* check the DBVERSION and reset idl-switch if needed (DS6.2) */ /* from the next major rel, we won't do this and just upgrade */ - if (!(li->li_flags & LI_FORCE_MOD_CONFIG)) + if (!(li->li_flags & LI_FORCE_MOD_CONFIG)) { adjust_idl_switch(ldbmversion, li); + } + slapi_ch_free_string(&ldbmversion); /* check to make sure these instance was made with the correct * version. */ @@ -1810,8 +1838,10 @@ int dblayer_instance_start(backend *be, int mode) } /* record the dataversion */ - if (dataversion[0] != '\0') { - inst->inst_dataversion = slapi_ch_strdup(dataversion); + if (dataversion != NULL && *dataversion != '\0') { + inst->inst_dataversion = dataversion; + } else { + slapi_ch_free_string(&dataversion); } rval = ldbm_upgrade(inst, rval); @@ -1888,8 +1918,8 @@ int dblayer_instance_start(backend *be, int mode) cachesize = 1048576; } priv->dblayer_cachesize = cachesize; - /* We always auto-calculate ncache for the import region */ - priv->dblayer_ncache = 0; + /* We always auto-calculate ncache for the import region */ + priv->dblayer_ncache = 0; /* use our own env */ return_value = dblayer_make_env(&mypEnv, li); @@ -2026,10 +2056,10 @@ out: if (mode & DBLAYER_NORMAL_MODE) { dbversion_write(li, inst_dirp, NULL); - /* richm - not sure if need to acquire the be lock first? */ - /* need to set state back to started - set to stopped in - dblayer_instance_close */ - be->be_state = BE_STATE_STARTED; + /* richm - not sure if need to acquire the be lock first? */ + /* need to set state back to started - set to stopped in + dblayer_instance_close */ + be->be_state = BE_STATE_STARTED; } /* @@ -2136,8 +2166,17 @@ int dblayer_get_aux_id2entry(backend *be, DB **ppDB, DB_ENV **ppEnv) priv->dblayer_spin_count = 0; inst_dirp = dblayer_get_full_inst_dir(li, inst, inst_dir, MAXPATHLEN); - priv->dblayer_home_directory = - slapi_ch_smprintf("%s/dbenv", inst_dirp); + if (inst_dirp && *inst_dirp) + { + priv->dblayer_home_directory = slapi_ch_smprintf("%s/dbenv", inst_dirp); + } + else + { + LDAPDebug(LDAP_DEBUG_ANY, + "Instance dir is NULL: persistent id2entry is not available\n", + 0, 0, 0); + goto done; + } priv->dblayer_log_directory = slapi_ch_strdup(priv->dblayer_home_directory); prst = PR_GetFileInfo(inst_dirp, &prfinfo); @@ -2263,7 +2302,10 @@ int dblayer_release_aux_id2entry(backend *be, DB *pDB, DB_ENV *pEnv) inst_dirp = dblayer_get_full_inst_dir(inst->inst_li, inst, inst_dir, MAXPATHLEN); - envdir = slapi_ch_smprintf("%s/dbenv", inst_dirp); + if (inst_dirp && *inst_dirp) + { + envdir = slapi_ch_smprintf("%s/dbenv", inst_dirp); + } done: if (pDB) @@ -2272,8 +2314,8 @@ done: pEnv->close(pEnv, 0); if (envdir) { ldbm_delete_dirs(envdir); - slapi_ch_free_string(&envdir); - } + slapi_ch_free_string(&envdir); + } if (inst_dirp != inst_dir) slapi_ch_free_string(&inst_dirp); return 0; @@ -2336,7 +2378,13 @@ int dblayer_instance_close(backend *be) char inst_dir[MAXPATHLEN]; char *inst_dirp = dblayer_get_full_inst_dir(inst->inst_li, inst, inst_dir, MAXPATHLEN); - return_value = env->remove(env, inst_dirp, 0); + if (inst_dirp && *inst_dir) { + return_value = env->remove(env, inst_dirp, 0); + } + else + { + return_value = -1; + } if (return_value == EBUSY) { return_value = 0; /* something else is using the env so ignore */ } @@ -2457,7 +2505,7 @@ int dblayer_post_close(struct ldbminfo *li, int dbmode) if (return_value == 0) { char *home_dir = dblayer_get_home_dir(li, NULL); if (home_dir) - return_value = env->remove(env, home_dir, 0); + return_value = env->remove(env, home_dir, 0); if (0 == return_value && !((DBLAYER_ARCHIVE_MODE|DBLAYER_EXPORT_MODE) & dbmode) && !priv->dblayer_bad_stuff_happened) { @@ -2670,6 +2718,11 @@ int dblayer_open_file(backend *be, char* indexname, int open_flag, int index_fla /* create a file with abs path, then try again */ inst_dirp = dblayer_get_full_inst_dir(li, inst, inst_dir, MAXPATHLEN); + if (!inst_dirp || !*inst_dirp) + { + return_value = -1; + goto out; + } abs_file_name = slapi_ch_smprintf("%s%c%s", inst_dirp, get_sep(inst_dirp), file_name); DB_OPEN(pENV->dblayer_openflags, @@ -2678,7 +2731,9 @@ int dblayer_open_file(backend *be, char* indexname, int open_flag, int index_fla dbp->close(dbp, 0); return_value = db_create(ppDB, pENV->dblayer_DB_ENV, 0); if (0 != return_value) + { goto out; + } dbp = *ppDB; slapi_ch_free_string(&abs_file_name); @@ -2895,7 +2950,7 @@ int dblayer_erase_index_file_ex(backend *be, struct attrinfo *a, dblayer_private *priv = (dblayer_private*) li->li_dblayer_private; struct dblayer_private_env *pEnv = priv->dblayer_env; ldbm_instance *inst = (ldbm_instance *) be->be_instance_info; - dblayer_handle *handle; + dblayer_handle *handle = NULL; char dbName[MAXPATHLEN]; char *dbNamep; char *p; @@ -2961,19 +3016,26 @@ int dblayer_erase_index_file_ex(backend *be, struct attrinfo *a, } } dbNamep = dblayer_get_full_inst_dir(li, inst, dbName, MAXPATHLEN); - dbbasenamelen = strlen(dbNamep); - dbnamelen = dbbasenamelen + strlen(a->ai_type) + 6; - if (dbnamelen > MAXPATHLEN) + if (dbNamep && *dbNamep) { + dbbasenamelen = strlen(dbNamep); + dbnamelen = dbbasenamelen + strlen(a->ai_type) + 6; + if (dbnamelen > MAXPATHLEN) + { + dbNamep = (char *)slapi_ch_realloc(dbNamep, dbnamelen); + } + p = dbNamep + dbbasenamelen; + sprintf(p, "%c%s%s", + get_sep(dbNamep), a->ai_type, LDBM_FILENAME_SUFFIX); + rc = dblayer_db_remove_ex(pEnv, dbNamep, 0, use_lock); + a->ai_dblayer = NULL; + if (dbNamep != dbName) + slapi_ch_free_string(&dbNamep); + } + else { - dbNamep = (char *)slapi_ch_realloc(dbNamep, dbnamelen); + rc = -1; } - p = dbNamep + dbbasenamelen; - sprintf(p, "%c%s%s", get_sep(dbNamep), a->ai_type, LDBM_FILENAME_SUFFIX); - rc = dblayer_db_remove_ex(pEnv, dbNamep, 0, use_lock); - a->ai_dblayer = NULL; slapi_ch_free((void **)&handle); - if (dbNamep != dbName) - slapi_ch_free_string(&dbNamep); } else { /* no handle to close */ } @@ -3262,7 +3324,7 @@ static int perf_threadmain(void *param) /* sleep for a while, updating perf counters if we need to */ perfctrs_wait(1000,priv->perf_private,priv->dblayer_env->dblayer_DB_ENV); } - + DECR_THREAD_COUNT(priv); LDAPDebug(LDAP_DEBUG_TRACE, "Leaving perf_threadmain\n", 0, 0, 0); return 0; @@ -3448,7 +3510,7 @@ static int checkpoint_threadmain(void *param) interval = PR_MillisecondsToInterval(DBLAYER_SLEEP_INTERVAL); home_dir = dblayer_get_home_dir(li, NULL); - if (NULL == home_dir) + if (NULL == home_dir || '\0' == *home_dir) { LDAPDebug(LDAP_DEBUG_ANY, "Checkpoint thread failed due to missing db home directory info\n", @@ -3869,7 +3931,7 @@ static int commit_good_database(dblayer_private *priv) return -1; } PR_snprintf(line,sizeof(line),"cachesize:%lu\nncache:%d\nversion:%d\n", - priv->dblayer_cachesize, priv->dblayer_ncache, 3); + priv->dblayer_cachesize, priv->dblayer_ncache, DB_VERSION_MAJOR); num_bytes = strlen(line); return_value = slapi_write_buffer(prfd, line, num_bytes); if (return_value != num_bytes) @@ -4079,17 +4141,17 @@ static int _dblayer_delete_instance_dir(ldbm_instance *inst, int startdb) if (NULL != li) { - if (startdb) - { - /* close immediately; no need to run db threads */ - rval = dblayer_start(li, DBLAYER_NORMAL_MODE|DBLAYER_NO_DBTHREADS_MODE); - if (rval) - { - LDAPDebug(LDAP_DEBUG_ANY, "_dblayer_delete_instance_dir: dblayer_start failed! %s (%d)\n", - dblayer_strerror(rval), rval, 0); - goto done; - } - } + if (startdb) + { + /* close immediately; no need to run db threads */ + rval = dblayer_start(li, DBLAYER_NORMAL_MODE|DBLAYER_NO_DBTHREADS_MODE); + if (rval) + { + LDAPDebug(LDAP_DEBUG_ANY, "_dblayer_delete_instance_dir: dblayer_start failed! %s (%d)\n", + dblayer_strerror(rval), rval, 0); + goto done; + } + } priv = (dblayer_private*)li->li_dblayer_private; if (NULL != priv) { @@ -4101,16 +4163,23 @@ static int _dblayer_delete_instance_dir(ldbm_instance *inst, int startdb) dblayer_get_instance_data_dir(inst->inst_be); inst_dirp = dblayer_get_full_inst_dir(li, inst, inst_dir, MAXPATHLEN); - dirhandle = PR_OpenDir(inst_dirp); + if (inst_dirp && *inst_dirp) { + dirhandle = PR_OpenDir(inst_dirp); + } if (! dirhandle) { if ( PR_GetError() == PR_FILE_NOT_FOUND_ERROR ) { /* the directory does not exist... that's not an error */ rval = 0; goto done; } - LDAPDebug(LDAP_DEBUG_ANY, - "_dblayer_delete_instance_dir: PR_OpenDir(%s) failed (%d): %s\n", - inst_dirp, PR_GetError(),slapd_pr_strerror(PR_GetError())); + if (inst_dirp && *inst_dirp) { + LDAPDebug(LDAP_DEBUG_ANY, + "_dblayer_delete_instance_dir: inst_dir is NULL\n", 0, 0, 0); + } else { + LDAPDebug(LDAP_DEBUG_ANY, + "_dblayer_delete_instance_dir: PR_OpenDir(%s) failed (%d): %s\n", + inst_dirp, PR_GetError(),slapd_pr_strerror(PR_GetError())); + } rval = -1; goto done; } @@ -4148,15 +4217,15 @@ static int _dblayer_delete_instance_dir(ldbm_instance *inst, int startdb) } } PR_CloseDir(dirhandle); - if (pEnv && startdb) - { - rval = dblayer_close(li, DBLAYER_NORMAL_MODE); - if (rval) - { - LDAPDebug(LDAP_DEBUG_ANY, "_dblayer_delete_instance_dir: dblayer_close failed! %s (%d)\n", - dblayer_strerror(rval), rval, 0); - } - } + if (pEnv && startdb) + { + rval = dblayer_close(li, DBLAYER_NORMAL_MODE); + if (rval) + { + LDAPDebug(LDAP_DEBUG_ANY, "_dblayer_delete_instance_dir: dblayer_close failed! %s (%d)\n", + dblayer_strerror(rval), rval, 0); + } + } done: /* remove the directory itself too */ if (0 == rval) @@ -4276,7 +4345,7 @@ int dblayer_delete_database_ex(struct ldbminfo *li, char *instance) { log_dir = dblayer_get_home_dir(li, NULL); } - if (instance == NULL) + if (instance == NULL && log_dir && *log_dir) { ret = dblayer_delete_transaction_logs(log_dir); if(ret) { @@ -4565,17 +4634,25 @@ int dblayer_copy_directory(struct ldbminfo *li, return return_value; } - inst_dirp = dblayer_get_full_inst_dir(inst->inst_li, inst, - inst_dir, MAXPATHLEN); if (is_fullpath(src_dir)) new_src_dir = src_dir; else { - int len = strlen(inst_dirp); + int len; + inst_dirp = dblayer_get_full_inst_dir(inst->inst_li, inst, + inst_dir, MAXPATHLEN); + if (!inst_dirp || !*inst_dirp) + { + LDAPDebug(LDAP_DEBUG_ANY, "Instance dir is NULL.\n", 0, 0, 0); + return return_value; + } + len = strlen(inst_dirp); sep = get_sep(inst_dirp); if (*(inst_dirp+len-1) == sep) sep = '\0'; new_src_dir = slapi_ch_smprintf("%s%c%s", inst_dirp, sep, src_dir); + if (inst_dirp != inst_dir) + slapi_ch_free_string(&inst_dirp); } dirhandle = PR_OpenDir(new_src_dir); @@ -4619,6 +4696,10 @@ int dblayer_copy_directory(struct ldbminfo *li, if (!is_fullpath(dest_dir)) { prefix = dblayer_get_home_dir(li, NULL); + if (!prefix || !*prefix) + { + continue; + } mysep = get_sep(prefix); } @@ -4711,7 +4792,7 @@ int dblayer_backup(struct ldbminfo *li, char *dest_dir, Slapi_Task *task) priv = (dblayer_private*)li->li_dblayer_private; PR_ASSERT(NULL != priv); home_dir = dblayer_get_home_dir(li, NULL); - if (NULL == home_dir) + if (NULL == home_dir || '\0' == *home_dir) { LDAPDebug(LDAP_DEBUG_ANY, "Backup failed due to missing db home directory info\n", 0, 0, 0); @@ -4789,8 +4870,25 @@ int dblayer_backup(struct ldbminfo *li, char *dest_dir, Slapi_Task *task) inst = (ldbm_instance *)object_get_data(inst_obj); inst_dirp = dblayer_get_full_inst_dir(inst->inst_li, inst, inst_dir, MAXPATHLEN); - return_value = dblayer_copy_directory(li, task, inst_dirp, - dest_dir, 0 /* backup */, &cnt, 0, 0, 0); + if (inst_dirp && *inst_dirp) + { + return_value = dblayer_copy_directory(li, task, inst_dirp, + dest_dir, 0 /* backup */, &cnt, 0, 0, 0); + } + else + { + LDAPDebug(LDAP_DEBUG_ANY, + "ERROR: Instance dir is empty\n", 0, 0, 0); + if (task) { + slapi_task_log_notice(task, + "ERROR: Instance dir is empty\n"); + } + if (listA) { + free(listA); + } + dblayer_txn_abort(li,&txn); + return -1; + } if (return_value != 0) { LDAPDebug(LDAP_DEBUG_ANY, "ERROR: error copying directory (%s -> %s): err=%d\n", @@ -5266,7 +5364,7 @@ int dblayer_restore(struct ldbminfo *li, char *src_dir, Slapi_Task *task, char * home_dir = dblayer_get_home_dir(li, NULL); - if (NULL == home_dir) + if (NULL == home_dir || '\0' == *home_dir) { LDAPDebug(LDAP_DEBUG_ANY, "Restore failed due to missing db home directory info\n", 0, 0, 0); @@ -5470,10 +5568,10 @@ int dblayer_restore(struct ldbminfo *li, char *src_dir, Slapi_Task *task, char * /* [605024] check the DBVERSION and reset idl-switch if needed */ if (dbversion_exists(li, home_dir)) { - char ldbmversion[LDBM_VERSION_MAXBUF]; - char dataversion[LDBM_VERSION_MAXBUF]; + char *ldbmversion = NULL; + char *dataversion = NULL; - if (dbversion_read(li, home_dir, ldbmversion, dataversion) != 0) + if (dbversion_read(li, home_dir, &ldbmversion, &dataversion) != 0) { LDAPDebug(LDAP_DEBUG_ANY, "Warning: Unable to read dbversion " "file in %s\n", home_dir, 0, 0); @@ -5481,11 +5579,13 @@ int dblayer_restore(struct ldbminfo *li, char *src_dir, Slapi_Task *task, char * else { adjust_idl_switch(ldbmversion, li); + slapi_ch_free_string(&ldbmversion); + slapi_ch_free_string(&ldbmversion); } } return_value = check_db_version(li, &action); - if (action & DBVERSION_UPGRADE_3_4) + if (action & (DBVERSION_UPGRADE_3_4|DBVERSION_UPGRADE_4_4)) { dbmode = DBLAYER_CLEAN_RECOVER_MODE;/* upgrade: remove logs & recover */ } @@ -5586,6 +5686,9 @@ int dblayer_get_instance_data_dir(backend *be) */ full_namep = dblayer_get_full_inst_dir(inst->inst_li, inst, full_name, MAXPATHLEN); + if (!full_namep || !*full_namep) { + return ret; + } /* Does this directory already exist? */ if ((db_dir = PR_OpenDir(full_namep)) != NULL) { /* yep. */ @@ -5622,6 +5725,11 @@ dblayer_in_import(ldbm_instance *inst) inst_dirp = dblayer_get_full_inst_dir(inst->inst_li, inst, inst_dir, MAXPATHLEN); + if (!inst_dirp || !*inst_dirp) + { + rval = -1; + goto done; + } dirhandle = PR_OpenDir(inst_dirp); if (NULL == dirhandle) @@ -5672,6 +5780,11 @@ int dblayer_update_db_ext(ldbm_instance *inst, char *oldext, char *newext) li = inst->inst_li; priv = (dblayer_private*)li->li_dblayer_private; inst_dirp = dblayer_get_full_inst_dir(li, inst, inst_dir, MAXPATHLEN); + if (!inst_dirp || *inst_dirp) { + LDAPDebug(LDAP_DEBUG_ANY, + "update_db_ext: instance dir is NULL\n", 0, 0, 0); + return -1; /* non zero */ + } for (a = (struct attrinfo *)avl_getfirst(inst->inst_attrs); NULL != a; a = (struct attrinfo *)avl_getnext()) diff --git a/ldap/servers/slapd/back-ldbm/dbversion.c b/ldap/servers/slapd/back-ldbm/dbversion.c index ba2dd9e8..78780df8 100644 --- a/ldap/servers/slapd/back-ldbm/dbversion.c +++ b/ldap/servers/slapd/back-ldbm/dbversion.c @@ -105,19 +105,13 @@ dbversion_write(struct ldbminfo *li, const char *directory, * (406922) */ if (idl_get_idl_new()) { -#if defined(USE_NEW_IDL) - sprintf( buf, "%s\n", LDBM_VERSION ); -#else - sprintf( buf, "%s\n", LDBM_VERSION_NEW ); -#endif + sprintf(buf, "%s/%d.%d/%s\n", + BDB_IMPL, DB_VERSION_MAJOR, DB_VERSION_MINOR, BDB_BACKEND); } else { -#if defined(USE_NEW_IDL) - sprintf( buf, "%s\n", LDBM_VERSION_OLD ); -#else - sprintf( buf, "%s\n", LDBM_VERSION ); -#endif + sprintf(buf, "%s/%d.%d/%s\n", + BDB_IMPL, DB_VERSION_MAJOR, DB_VERSION_MINOR, BDB_BACKEND); } len = strlen( buf ); if ( slapi_write_buffer( prfd, buf, len ) != len ) @@ -149,7 +143,7 @@ dbversion_write(struct ldbminfo *li, const char *directory, */ int dbversion_read(struct ldbminfo *li, const char *directory, - char *ldbmversion, char *dataversion) + char **ldbmversion, char **dataversion) { char filename[ MAXPATHLEN*2 ]; PRFileDesc *prfd; @@ -157,15 +151,15 @@ dbversion_read(struct ldbminfo *li, const char *directory, char * iter = NULL; if (!is_fullpath((char *)directory)) { - rc = -1; + return rc; + } + + if (NULL == ldbmversion) { return rc; } mk_dbversion_fullpath(li, directory, filename); - ldbmversion[0]= '\0'; - dataversion[0]= '\0'; - /* Open the file */ if (( prfd = PR_Open( filename, PR_RDONLY, SLAPD_DEFAULT_FILE_MODE )) == NULL ) @@ -180,15 +174,15 @@ dbversion_read(struct ldbminfo *li, const char *directory, if ( nr > 0 && nr != (PRInt32)LDBM_VERSION_MAXBUF-1 ) { char *t; - buf[nr]= '\0'; - t= ldap_utf8strtok_r(buf,"\n", &iter); - if(t!=NULL) + buf[nr] = '\0'; + t = ldap_utf8strtok_r(buf,"\n", &iter); + if(NULL != t) { - strcpy(ldbmversion,t); - t= ldap_utf8strtok_r(NULL,"\n", &iter); - if(t!=NULL && t[0]!='\0') + *ldbmversion = slapi_ch_strdup(t); + t = ldap_utf8strtok_r(NULL,"\n", &iter); + if(NULL != dataversion && t != NULL && t[0] != '\0') { - strcpy(dataversion,t); + *dataversion = slapi_ch_strdup(t); } } } diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.c b/ldap/servers/slapd/back-ldbm/ldbm_config.c index 32403a68..624d343d 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_config.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_config.c @@ -1214,11 +1214,7 @@ static config_info ldbm_config[] = { {CONFIG_CACHE_AUTOSIZE, CONFIG_TYPE_INT, "0", &ldbm_config_cache_autosize_get, &ldbm_config_cache_autosize_set, 0}, {CONFIG_CACHE_AUTOSIZE_SPLIT, CONFIG_TYPE_INT, "50", &ldbm_config_cache_autosize_split_get, &ldbm_config_cache_autosize_split_set, 0}, {CONFIG_IMPORT_CACHESIZE, CONFIG_TYPE_SIZE_T, "20000000", &ldbm_config_import_cachesize_get, &ldbm_config_import_cachesize_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, -#if defined(USE_NEW_IDL) {CONFIG_IDL_SWITCH, CONFIG_TYPE_STRING, "new", &ldbm_config_idl_get_idl_new, &ldbm_config_idl_set_tune, CONFIG_FLAG_ALWAYS_SHOW}, -#else - {CONFIG_IDL_SWITCH, CONFIG_TYPE_STRING, "old", &ldbm_config_idl_get_idl_new, &ldbm_config_idl_set_tune, CONFIG_FLAG_ALWAYS_SHOW}, -#endif {CONFIG_BYPASS_FILTER_TEST, CONFIG_TYPE_STRING, "on", &ldbm_config_get_bypass_filter_test, &ldbm_config_set_bypass_filter_test, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, {CONFIG_USE_VLV_INDEX, CONFIG_TYPE_ONOFF, "on", &ldbm_config_get_use_vlv_index, &ldbm_config_set_use_vlv_index, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, {CONFIG_DB_LOCKDOWN, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_lockdown_get, &ldbm_config_db_lockdown_set, 0}, diff --git a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h index 2fddc4c2..e0c89536 100644 --- a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h +++ b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h @@ -563,7 +563,7 @@ int ldbm_attribute_always_indexed(const char *attrtype); */ int dbversion_write(struct ldbminfo *li, const char *dir, const char *dversion); int dbversion_read(struct ldbminfo *li, const char *directory, - char *ldbmversion, char *dataversion); + char **ldbmversion, char **dataversion); int dbversion_exists(struct ldbminfo *li, const char *directory); /* diff --git a/ldap/servers/slapd/back-ldbm/start.c b/ldap/servers/slapd/back-ldbm/start.c index aedd1a12..e5c4299f 100644 --- a/ldap/servers/slapd/back-ldbm/start.c +++ b/ldap/servers/slapd/back-ldbm/start.c @@ -163,7 +163,7 @@ ldbm_back_start( Slapi_PBlock *pb ) return SLAPI_FAIL_GENERAL; } - if (action & DBVERSION_UPGRADE_3_4) + if (action & (DBVERSION_UPGRADE_3_4|DBVERSION_UPGRADE_4_4)) { retval = dblayer_start(li,DBLAYER_CLEAN_RECOVER_MODE); } diff --git a/ldap/servers/slapd/back-ldbm/upgrade.c b/ldap/servers/slapd/back-ldbm/upgrade.c index c291b661..a64f2578 100644 --- a/ldap/servers/slapd/back-ldbm/upgrade.c +++ b/ldap/servers/slapd/back-ldbm/upgrade.c @@ -45,9 +45,6 @@ #include "back-ldbm.h" -#if 0 -static char* filename = "upgrade.c"; -#endif /* * ldbm_compat_versions holds DBVERSION strings for all versions of the * database with which we are (upwards) compatible. If check_db_version @@ -56,16 +53,13 @@ static char* filename = "upgrade.c"; */ db_upgrade_info ldbm_version_suss[] = { -#if defined(USE_NEW_IDL) - {LDBM_VERSION,DBVERSION_NEW_IDL,DBVERSION_NO_UPGRADE}, - {LDBM_VERSION_OLD,DBVERSION_OLD_IDL,DBVERSION_NO_UPGRADE}, -#else - /* default: old idl (DS6.2) */ - {LDBM_VERSION_NEW,DBVERSION_NEW_IDL,DBVERSION_NO_UPGRADE}, - {LDBM_VERSION,DBVERSION_OLD_IDL,DBVERSION_NO_UPGRADE}, -#endif - {LDBM_VERSION_61,DBVERSION_NEW_IDL,DBVERSION_UPGRADE_3_4}, - {LDBM_VERSION_60,DBVERSION_OLD_IDL,DBVERSION_UPGRADE_3_4}, + /* for bdb/#.#/..., we don't have to put the version number in the 2nd col + since DBVERSION keeps it */ + {BDB_IMPL, 0, 0, DBVERSION_NEW_IDL, DBVERSION_NO_UPGRADE}, + {LDBM_VERSION, 4, 2, DBVERSION_NEW_IDL, DBVERSION_NO_UPGRADE}, + {LDBM_VERSION_OLD, 4, 2, DBVERSION_OLD_IDL, DBVERSION_NO_UPGRADE}, + {LDBM_VERSION_61, 3, 3, DBVERSION_NEW_IDL, DBVERSION_UPGRADE_3_4}, + {LDBM_VERSION_60, 3, 3, DBVERSION_OLD_IDL, DBVERSION_UPGRADE_3_4}, {NULL,0,0} }; @@ -79,11 +73,12 @@ int lookup_dbversion(char *dbversion, int flag) { int i, matched = 0; - int rval = 0; + int rval = DBVERSION_NO_UPGRADE; for ( i = 0; ldbm_version_suss[i].old_version_string != NULL; ++i ) { - if ( strcmp( dbversion, ldbm_version_suss[i].old_version_string ) == 0 ) + if (PL_strncasecmp(dbversion, ldbm_version_suss[i].old_version_string, + strlen(ldbm_version_suss[i].old_version_string)) == 0) { matched = 1; break; @@ -97,7 +92,42 @@ lookup_dbversion(char *dbversion, int flag) } if ( flag & DBVERSION_ACTION ) { - rval |= ldbm_version_suss[i].action; + int dbmajor = 0, dbminor = 0; + if (0 == ldbm_version_suss[i].old_dbversion_major) + { + /* case of bdb/#.#/... */ + char *p = strchr(dbversion, '/'); + char *endp = dbversion + strlen(dbversion); + if (NULL != p && p < endp) + { + char *dotp = strchr(++p, '.'); + if (NULL != dotp) + { + *dotp = '\0'; + dbmajor = strtol(p, (char **)NULL, 10); + dbminor = strtol(++dotp, (char **)NULL, 10); + } + else + { + dbmajor = strtol(p, (char **)NULL, 10); + } + } + } + else + { + dbmajor = ldbm_version_suss[i].old_dbversion_major; + dbminor = ldbm_version_suss[i].old_dbversion_minor; + } + if (dbmajor < DB_VERSION_MAJOR) + { + /* 3.3 -> 4.x */ + rval |= ldbm_version_suss[i].action; + } + else if (dbminor < DB_VERSION_MINOR) + { + /* 4.low -> 4.high */ + rval |= DBVERSION_UPGRADE_4_4; + } } } return rval; @@ -113,20 +143,23 @@ lookup_dbversion(char *dbversion, int flag) * * action: 0: nothing is needed * DBVERSION_UPGRADE_3_4: db3->db4 uprev is needed + * DBVERSION_UPGRADE_4_4: db4->db4 uprev is needed */ int check_db_version( struct ldbminfo *li, int *action ) { int value = 0; - char ldbmversion[BUFSIZ]; - char dataversion[BUFSIZ]; + char *ldbmversion = NULL; + char *dataversion = NULL; *action = 0; - dbversion_read(li, li->li_directory,ldbmversion,dataversion); - if (0 == strlen(ldbmversion)) + dbversion_read(li, li->li_directory, &ldbmversion, &dataversion); + if (NULL == ldbmversion || '\0' == *ldbmversion) { + slapi_ch_free_string(&dataversion); return 0; + } - value = lookup_dbversion( ldbmversion, DBVERSION_TYPE | DBVERSION_ACTION); + value = lookup_dbversion( ldbmversion, DBVERSION_TYPE | DBVERSION_ACTION ); if ( !value ) { LDAPDebug( LDAP_DEBUG_ANY, @@ -136,6 +169,8 @@ check_db_version( struct ldbminfo *li, int *action ) /* * A non-zero return here will cause slapd to exit during startup. */ + slapi_ch_free_string(&ldbmversion); + slapi_ch_free_string(&dataversion); return DBVERSION_NOT_SUPPORTED; } if ( value & DBVERSION_UPGRADE_3_4 ) @@ -143,6 +178,13 @@ check_db_version( struct ldbminfo *li, int *action ) dblayer_set_recovery_required(li); *action = DBVERSION_UPGRADE_3_4; } + else if ( value & DBVERSION_UPGRADE_4_4 ) + { + dblayer_set_recovery_required(li); + *action = DBVERSION_UPGRADE_4_4; + } + slapi_ch_free_string(&ldbmversion); + slapi_ch_free_string(&dataversion); return 0; } @@ -160,13 +202,14 @@ check_db_version( struct ldbminfo *li, int *action ) * DBVERSION_NOT_SUPPORTED: not supported * * DBVERSION_UPGRADE_3_4: db3->db4 uprev is needed + * DBVERSION_UPGRADE_4_4: db4->db4 uprev is needed */ int check_db_inst_version( ldbm_instance *inst ) { int value = 0; - char ldbmversion[BUFSIZ]; - char dataversion[BUFSIZ]; + char *ldbmversion = NULL; + char *dataversion = NULL; int rval = 0; char inst_dir[MAXPATHLEN*2]; char *inst_dirp = NULL; @@ -174,11 +217,12 @@ check_db_inst_version( ldbm_instance *inst ) inst_dirp = dblayer_get_full_inst_dir(inst->inst_li, inst, inst_dir, MAXPATHLEN*2); - dbversion_read(inst->inst_li, inst_dirp,ldbmversion,dataversion); - if (0 == strlen(ldbmversion)) + dbversion_read(inst->inst_li, inst_dirp, &ldbmversion, &dataversion); + if (NULL == ldbmversion || '\0' == *ldbmversion) { return rval; + } - value = lookup_dbversion( ldbmversion, DBVERSION_TYPE | DBVERSION_ACTION); + value = lookup_dbversion( ldbmversion, DBVERSION_TYPE | DBVERSION_ACTION ); if ( !value ) { LDAPDebug( LDAP_DEBUG_ANY, @@ -188,6 +232,8 @@ check_db_inst_version( ldbm_instance *inst ) /* * A non-zero return here will cause slapd to exit during startup. */ + slapi_ch_free_string(&ldbmversion); + slapi_ch_free_string(&dataversion); return DBVERSION_NOT_SUPPORTED; } @@ -205,8 +251,14 @@ check_db_inst_version( ldbm_instance *inst ) { rval |= DBVERSION_UPGRADE_3_4; } + else if ( value & DBVERSION_UPGRADE_4_4 ) + { + rval |= DBVERSION_UPGRADE_4_4; + } if (inst_dirp != inst_dir) slapi_ch_free_string(&inst_dirp); + slapi_ch_free_string(&ldbmversion); + slapi_ch_free_string(&dataversion); return rval; } @@ -221,13 +273,9 @@ adjust_idl_switch(char *ldbmversion, struct ldbminfo *li) int rval = 0; li->li_flags |= LI_FORCE_MOD_CONFIG; -#if defined(USE_NEW_IDL) - if ((0 == strcmp(ldbmversion, LDBM_VERSION)) || - (0 == strcmp(ldbmversion, LDBM_VERSION_61))) /* db: new idl */ -#else - if ((0 == strcmp(ldbmversion, LDBM_VERSION_NEW)) || - (0 == strcmp(ldbmversion, LDBM_VERSION_61))) /* db: new idl */ -#endif + if ((0 == PL_strncasecmp(ldbmversion, BDB_IMPL, strlen(BDB_IMPL))) || + (0 == PL_strcmp(ldbmversion, LDBM_VERSION)) || + (0 == PL_strcmp(ldbmversion, LDBM_VERSION_61))) /* db: new idl */ { if (!idl_get_idl_new()) /* config: old idl */ { @@ -239,13 +287,8 @@ adjust_idl_switch(char *ldbmversion, struct ldbminfo *li) ldbmversion, 0, 0); } } -#if defined(USE_NEW_IDL) else if ((0 == strcmp(ldbmversion, LDBM_VERSION_OLD)) || (0 == strcmp(ldbmversion, LDBM_VERSION_60))) /* db: old */ -#else - else if ((0 == strcmp(ldbmversion, LDBM_VERSION)) || /* ds6.2: old */ - (0 == strcmp(ldbmversion, LDBM_VERSION_60))) /* db: old */ -#endif { if (idl_get_idl_new()) /* config: new */ { @@ -289,7 +332,6 @@ int ldbm_upgrade(ldbm_instance *inst, int action) int rval = dblayer_update_db_ext(inst, LDBM_SUFFIX_OLD, LDBM_SUFFIX); if (0 == rval) { -#if defined(USE_NEW_IDL) if (idl_get_idl_new()) { LDAPDebug(LDAP_DEBUG_ANY, @@ -302,11 +344,6 @@ int ldbm_upgrade(ldbm_instance *inst, int action) "ldbm_upgrade: Upgrading instance %s to %s%s is successfully done.\n", inst->inst_name, LDBM_VERSION_OLD, 0); } -#else - LDAPDebug(LDAP_DEBUG_ANY, - "ldbm_upgrade: Upgrading instance %s to %s%s is successfully done.\n", - inst->inst_name, LDBM_VERSION_BASE, PRODUCTTEXT); -#endif } else { |