diff options
author | Noriko Hosoi <nhosoi@redhat.com> | 2006-10-13 01:06:29 +0000 |
---|---|---|
committer | Noriko Hosoi <nhosoi@redhat.com> | 2006-10-13 01:06:29 +0000 |
commit | 57e9577e0e96da39c62cc0b2c3ae3c053ff9232f (patch) | |
tree | 9c276cb9c3f35cec42e4c63c24fcba21f25b929e /ldap/servers/slapd/back-ldbm | |
parent | 65dd96fe4a1effd42dfecaebd58c384ba7624518 (diff) | |
download | ds-57e9577e0e96da39c62cc0b2c3ae3c053ff9232f.tar.gz ds-57e9577e0e96da39c62cc0b2c3ae3c053ff9232f.tar.xz ds-57e9577e0e96da39c62cc0b2c3ae3c053ff9232f.zip |
[208672] parameterizing the hardcoded paths (phase 2. db, log, lock, pid, cert, and instance dir)
1) introduced these 3 new config attributes:
nsslapd-lockdir, nsslapd-tmpdir, nsslapd-certdir,
and eliminated: nsslapd-instancedir.
2) replaced the hardcoded paths with the corresponding attribute value in the
server as well as in the create/remove instance codes.
3) moved snmp stats file to the nsslapd-tmpdir
4) moved the server instance dir to <prefix>/lib/<brand>-ds/slapd-<id>
Diffstat (limited to 'ldap/servers/slapd/back-ldbm')
-rw-r--r-- | ldap/servers/slapd/back-ldbm/archive.c | 22 | ||||
-rw-r--r-- | ldap/servers/slapd/back-ldbm/ldbm_config.c | 313 | ||||
-rw-r--r-- | ldap/servers/slapd/back-ldbm/ldbm_config.h | 2 |
3 files changed, 164 insertions, 173 deletions
diff --git a/ldap/servers/slapd/back-ldbm/archive.c b/ldap/servers/slapd/back-ldbm/archive.c index cb317b52..46b7a5b4 100644 --- a/ldap/servers/slapd/back-ldbm/archive.c +++ b/ldap/servers/slapd/back-ldbm/archive.c @@ -42,9 +42,7 @@ int ldbm_back_archive2ldbm( Slapi_PBlock *pb ) { struct ldbminfo *li; - char *instancedir = NULL; - char *orig_dir = NULL; - char *directory = NULL; + char *directory = NULL; /* -a <directory> */ char *backendname = NULL; int return_value = -1; int task_flags = 0; @@ -53,19 +51,17 @@ 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, &orig_dir ); + slapi_pblock_get( pb, SLAPI_SEQ_VAL, &directory ); 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 ( !orig_dir || !*orig_dir ) { + if ( !directory || !*directory ) { LDAPDebug( LDAP_DEBUG_ANY, "archive2db: no archive name\n", 0, 0, 0 ); return( -1 ); } - instancedir = config_get_instancedir(); - directory = rel2abspath_ext(orig_dir, instancedir); /* check the current idl format vs backup DB version */ if (idl_get_idl_new()) @@ -248,17 +244,14 @@ int ldbm_back_archive2ldbm( Slapi_PBlock *pb ) } } out: - slapi_ch_free_string(&directory); return return_value; } int ldbm_back_ldbm2archive( Slapi_PBlock *pb ) { struct ldbminfo *li; - char *orig_dir = NULL; - char *directory = NULL; + char *directory = NULL; /* -a <directory> */ char *dir_bak = NULL; - char *instancedir = NULL; int return_value = -1; int task_flags = 0; int run_from_cmdline = 0; @@ -266,19 +259,17 @@ int ldbm_back_ldbm2archive( Slapi_PBlock *pb ) struct stat sbuf; slapi_pblock_get( pb, SLAPI_PLUGIN_PRIVATE, &li ); - slapi_pblock_get( pb, SLAPI_SEQ_VAL, &orig_dir ); + slapi_pblock_get( pb, SLAPI_SEQ_VAL, &directory ); slapi_pblock_get( pb, SLAPI_TASK_FLAGS, &task_flags ); li->li_flags = run_from_cmdline = (task_flags & TASK_RUNNING_FROM_COMMANDLINE); slapi_pblock_get( pb, SLAPI_BACKEND_TASK, &task ); - if ( !orig_dir || !*orig_dir ) { + if ( !directory || !*directory ) { LDAPDebug( LDAP_DEBUG_ANY, "db2archive: no archive name\n", 0, 0, 0 ); return( -1 ); } - instancedir = config_get_instancedir(); - directory = rel2abspath_ext(orig_dir, instancedir); if (stat(directory, &sbuf) == 0) { int baklen = strlen(directory) + 5; /* ".bak\0" */ dir_bak = slapi_ch_malloc(baklen); @@ -446,6 +437,5 @@ err: } out: slapi_ch_free_string(&dir_bak); - slapi_ch_free_string(&directory); return return_value; } diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.c b/ldap/servers/slapd/back-ldbm/ldbm_config.c index 9021dd7f..08fb22ef 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_config.c +++ b/ldap/servers/slapd/back-ldbm/ldbm_config.c @@ -226,13 +226,10 @@ static int ldbm_config_directory_set(void *arg, void *value, char *errorbuf, int LDAPDebug(LDAP_DEBUG_ANY, "New db directory location will not take affect until the server is restarted\n", 0, 0, 0); } else { if (!strcmp(val, "get default")) { - /* Generate the default db directory name. The default db directory - * should be the instance directory with a '/db' thrown on the end. - * We need to read cn=config to get the instance dir. */ /* We use this funky "get default" string for the caller to * tell us that it has no idea what the db directory should - * be. This code figures it out be reading cn=config. */ - + * be. This code figures it out be reading "cn=config,cn=ldbm + * database,cn=plugins,cn=config" entry. */ Slapi_PBlock *search_pb; Slapi_Entry **entries = NULL; Slapi_Attr *attr = NULL; @@ -241,30 +238,33 @@ static int ldbm_config_directory_set(void *arg, void *value, char *errorbuf, int int res; search_pb = slapi_pblock_new(); - slapi_search_internal_set_pb(search_pb, "cn=config", LDAP_SCOPE_BASE, - "objectclass=*", NULL, 0, NULL, NULL, li->li_identity, 0); + slapi_search_internal_set_pb(search_pb, CONFIG_LDBM_DN, + LDAP_SCOPE_BASE, "objectclass=*", NULL, 0, NULL, NULL, + li->li_identity, 0); slapi_search_internal_pb(search_pb); slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_RESULT, &res); if (res != LDAP_SUCCESS) { - LDAPDebug(LDAP_DEBUG_ANY, "ERROR: ldbm plugin unable to read cn=config\n", - 0, 0, 0); + LDAPDebug(LDAP_DEBUG_ANY, + "ERROR: ldbm plugin unable to read %s\n", + CONFIG_LDBM_DN, 0, 0); goto done; } slapi_pblock_get(search_pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries); if (NULL == entries) { - LDAPDebug(LDAP_DEBUG_ANY, "ERROR: ldbm plugin unable to read cn=config\n", - 0, 0, 0); + LDAPDebug(LDAP_DEBUG_ANY, + "ERROR: ldbm plugin unable to read %s\n", + CONFIG_LDBM_DN, 0, 0); res = LDAP_OPERATIONS_ERROR; goto done; } - res = slapi_entry_attr_find(entries[0], "nsslapd-instancedir", &attr); + res = slapi_entry_attr_find(entries[0], "nsslapd-directory", &attr); if (res != 0 || attr == NULL) { LDAPDebug(LDAP_DEBUG_ANY, - "ERROR: ldbm plugin unable to read attribute nsslapd-instancedir from cn=config\n", - 0, 0, 0); + "ERROR: ldbm plugin unable to read attribute nsslapd-directory from %s\n", + CONFIG_LDBM_DN, 0, 0); res = LDAP_OPERATIONS_ERROR; goto done; } @@ -273,8 +273,8 @@ static int ldbm_config_directory_set(void *arg, void *value, char *errorbuf, int || ( NULL == v ) || ( NULL == ( s = slapi_value_get_string( v )))) { LDAPDebug(LDAP_DEBUG_ANY, - "ERROR: ldbm plugin unable to read attribute nsslapd-instancedir from cn=config\n", - 0, 0, 0); + "ERROR: ldbm plugin unable to read attribute nsslapd-directory from %s\n", + CONFIG_LDBM_DN, 0, 0); res = LDAP_OPERATIONS_ERROR; goto done; } @@ -284,7 +284,7 @@ done: if (res != LDAP_SUCCESS) { return res; } - PR_snprintf(tmpbuf, BUFSIZ, "%s/db", s ); + PR_snprintf(tmpbuf, BUFSIZ, "%s", s); val = tmpbuf; } slapi_ch_free((void **) &(li->li_new_directory)); @@ -350,7 +350,7 @@ static int ldbm_config_maxpassbeforemerge_set(void *arg, void *value, char *erro val = 100; } - li->li_maxpassbeforemerge = val; + li->li_maxpassbeforemerge = val; } return retval; @@ -661,7 +661,7 @@ static int ldbm_config_db_trickle_percentage_set(void *arg, void *value, char *e if (val < 0 || val > 100) { PR_snprintf(errorbuf, SLAPI_DSE_RETURNTEXT_SIZE, - "Error: Invalid value for %s (%d). Must be between 0 and 100\n", CONFIG_DB_TRICKLE_PERCENTAGE, val); + "Error: Invalid value for %s (%d). Must be between 0 and 100\n", CONFIG_DB_TRICKLE_PERCENTAGE, val); LDAPDebug(LDAP_DEBUG_ANY, "%s", errorbuf, 0, 0); return LDAP_UNWILLING_TO_PERFORM; } @@ -896,12 +896,12 @@ static void *ldbm_config_import_cache_autosize_get(void *arg) } static int ldbm_config_import_cache_autosize_set(void *arg, void *value, char *errorbuf, - int phase, int apply) + int phase, int apply) { struct ldbminfo *li = (struct ldbminfo *)arg; if (apply) - li->li_import_cache_autosize = (int)value; + li->li_import_cache_autosize = (int)value; return LDAP_SUCCESS; } @@ -913,12 +913,12 @@ static void *ldbm_config_cache_autosize_get(void *arg) } static int ldbm_config_cache_autosize_set(void *arg, void *value, char *errorbuf, - int phase, int apply) + int phase, int apply) { struct ldbminfo *li = (struct ldbminfo *)arg; if (apply) - li->li_cache_autosize = (int)value; + li->li_cache_autosize = (int)value; return LDAP_SUCCESS; } @@ -930,12 +930,12 @@ static void *ldbm_config_cache_autosize_split_get(void *arg) } static int ldbm_config_cache_autosize_split_set(void *arg, void *value, char *errorbuf, - int phase, int apply) + int phase, int apply) { struct ldbminfo *li = (struct ldbminfo *)arg; if (apply) - li->li_cache_autosize_split = (int)value; + li->li_cache_autosize_split = (int)value; return LDAP_SUCCESS; } @@ -1090,7 +1090,7 @@ static void *ldbm_config_get_use_vlv_index(void *arg) static int ldbm_config_exclude_from_export_set( void *arg, void *value, char *errorbuf, - int phase, int apply) + int phase, int apply) { struct ldbminfo *li = (struct ldbminfo *)arg; @@ -1114,12 +1114,12 @@ static void * ldbm_config_exclude_from_export_get( void *arg ) { struct ldbminfo *li = (struct ldbminfo *)arg; - char *p, *retstr = NULL; - size_t len = 0; + char *p, *retstr = NULL; + size_t len = 0; if ( NULL != li->li_attrs_to_exclude_from_export && NULL != li->li_attrs_to_exclude_from_export[0] ) { - int i; + int i; for ( i = 0; li->li_attrs_to_exclude_from_export[i] != NULL; ++i ) { len += strlen( li->li_attrs_to_exclude_from_export[i] ) + 1; @@ -1171,59 +1171,59 @@ static int ldbm_config_db_tx_max_set( * Configuration array for ldbm and dblayer variables *----------------------------------------------------------------------*/ static config_info ldbm_config[] = { - {CONFIG_LOOKTHROUGHLIMIT, CONFIG_TYPE_INT, "5000", &ldbm_config_lookthroughlimit_get, &ldbm_config_lookthroughlimit_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, - {CONFIG_MODE, CONFIG_TYPE_INT_OCTAL, "0600", &ldbm_config_mode_get, &ldbm_config_mode_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, - {CONFIG_IDLISTSCANLIMIT, CONFIG_TYPE_INT, "4000", &ldbm_config_allidsthreshold_get, &ldbm_config_allidsthreshold_set, CONFIG_FLAG_ALWAYS_SHOW}, - {CONFIG_DIRECTORY, CONFIG_TYPE_STRING, "", &ldbm_config_directory_get, &ldbm_config_directory_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, - {CONFIG_DBCACHESIZE, CONFIG_TYPE_SIZE_T, "10000000", &ldbm_config_dbcachesize_get, &ldbm_config_dbcachesize_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, - {CONFIG_DBNCACHE, CONFIG_TYPE_INT, "0", &ldbm_config_dbncache_get, &ldbm_config_dbncache_set, CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, - {CONFIG_MAXPASSBEFOREMERGE, CONFIG_TYPE_INT, "100", &ldbm_config_maxpassbeforemerge_get, &ldbm_config_maxpassbeforemerge_set, 0}, - - /* dblayer config attributes */ - {CONFIG_DB_LOGDIRECTORY, CONFIG_TYPE_STRING, "", &ldbm_config_db_logdirectory_get, &ldbm_config_db_logdirectory_set, CONFIG_FLAG_ALWAYS_SHOW}, - {CONFIG_DB_DURABLE_TRANSACTIONS, CONFIG_TYPE_ONOFF, "on", &ldbm_config_db_durable_transactions_get, &ldbm_config_db_durable_transactions_set, CONFIG_FLAG_ALWAYS_SHOW}, - {CONFIG_DB_CIRCULAR_LOGGING, CONFIG_TYPE_ONOFF, "on", &ldbm_config_db_circular_logging_get, &ldbm_config_db_circular_logging_set, 0}, - {CONFIG_DB_TRANSACTION_LOGGING, CONFIG_TYPE_ONOFF, "on", &ldbm_config_db_transaction_logging_get, &ldbm_config_db_transaction_logging_set, CONFIG_FLAG_ALWAYS_SHOW}, - {CONFIG_DB_CHECKPOINT_INTERVAL, CONFIG_TYPE_INT, "60", &ldbm_config_db_checkpoint_interval_get, &ldbm_config_db_checkpoint_interval_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, - {CONFIG_DB_TRANSACTION_BATCH, CONFIG_TYPE_INT, "0", &dblayer_get_batch_transactions, &dblayer_set_batch_transactions, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, - {CONFIG_DB_LOGBUF_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_logbuf_size_get, &ldbm_config_db_logbuf_size_set, CONFIG_FLAG_ALWAYS_SHOW}, - {CONFIG_DB_PAGE_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_page_size_get, &ldbm_config_db_page_size_set, 0}, - {CONFIG_DB_INDEX_PAGE_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_index_page_size_get, &ldbm_config_db_index_page_size_set, 0}, - {CONFIG_DB_IDL_DIVISOR, CONFIG_TYPE_INT, "0", &ldbm_config_db_idl_divisor_get, &ldbm_config_db_idl_divisor_set, 0}, - {CONFIG_DB_LOGFILE_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_logfile_size_get, &ldbm_config_db_logfile_size_set, 0}, - {CONFIG_DB_TRICKLE_PERCENTAGE, CONFIG_TYPE_INT, "5", &ldbm_config_db_trickle_percentage_get, &ldbm_config_db_trickle_percentage_set, 0}, - {CONFIG_DB_SPIN_COUNT, CONFIG_TYPE_INT, "0", &ldbm_config_db_spin_count_get, &ldbm_config_db_spin_count_set, 0}, - {CONFIG_DB_VERBOSE, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_verbose_get, &ldbm_config_db_verbose_set, 0}, - {CONFIG_DB_DEBUG, CONFIG_TYPE_ONOFF, "on", &ldbm_config_db_debug_get, &ldbm_config_db_debug_set, 0}, - {CONFIG_DB_NAMED_REGIONS, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_named_regions_get, &ldbm_config_db_named_regions_set, 0}, - {CONFIG_DB_LOCK, CONFIG_TYPE_INT, "10000", &ldbm_config_db_lock_get, &ldbm_config_db_lock_set, 0}, - {CONFIG_DB_PRIVATE_MEM, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_private_mem_get, &ldbm_config_db_private_mem_set, 0}, - {CONFIG_DB_PRIVATE_IMPORT_MEM, CONFIG_TYPE_ONOFF, "on", &ldbm_config_db_private_import_mem_get, &ldbm_config_db_private_import_mem_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, - {CONFIG_DB_SHM_KEY, CONFIG_TYPE_LONG, "389389", &ldbm_config_db_shm_key_get, &ldbm_config_db_shm_key_set, 0}, - {CONFIG_DB_CACHE, CONFIG_TYPE_INT, "0", &ldbm_config_db_cache_get, &ldbm_config_db_cache_set, 0}, - {CONFIG_DB_DEBUG_CHECKPOINTING, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_debug_checkpointing_get, &ldbm_config_db_debug_checkpointing_set, 0}, - {CONFIG_DB_HOME_DIRECTORY, CONFIG_TYPE_STRING, "", &ldbm_config_db_home_directory_get, &ldbm_config_db_home_directory_set, 0}, - {CONFIG_IMPORT_CACHE_AUTOSIZE, CONFIG_TYPE_INT, "-1", &ldbm_config_import_cache_autosize_get, &ldbm_config_import_cache_autosize_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, - {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}, + {CONFIG_LOOKTHROUGHLIMIT, CONFIG_TYPE_INT, "5000", &ldbm_config_lookthroughlimit_get, &ldbm_config_lookthroughlimit_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, + {CONFIG_MODE, CONFIG_TYPE_INT_OCTAL, "0600", &ldbm_config_mode_get, &ldbm_config_mode_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, + {CONFIG_IDLISTSCANLIMIT, CONFIG_TYPE_INT, "4000", &ldbm_config_allidsthreshold_get, &ldbm_config_allidsthreshold_set, CONFIG_FLAG_ALWAYS_SHOW}, + {CONFIG_DIRECTORY, CONFIG_TYPE_STRING, "", &ldbm_config_directory_get, &ldbm_config_directory_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, + {CONFIG_DBCACHESIZE, CONFIG_TYPE_SIZE_T, "10000000", &ldbm_config_dbcachesize_get, &ldbm_config_dbcachesize_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, + {CONFIG_DBNCACHE, CONFIG_TYPE_INT, "0", &ldbm_config_dbncache_get, &ldbm_config_dbncache_set, CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, + {CONFIG_MAXPASSBEFOREMERGE, CONFIG_TYPE_INT, "100", &ldbm_config_maxpassbeforemerge_get, &ldbm_config_maxpassbeforemerge_set, 0}, + + /* dblayer config attributes */ + {CONFIG_DB_LOGDIRECTORY, CONFIG_TYPE_STRING, "", &ldbm_config_db_logdirectory_get, &ldbm_config_db_logdirectory_set, CONFIG_FLAG_ALWAYS_SHOW}, + {CONFIG_DB_DURABLE_TRANSACTIONS, CONFIG_TYPE_ONOFF, "on", &ldbm_config_db_durable_transactions_get, &ldbm_config_db_durable_transactions_set, CONFIG_FLAG_ALWAYS_SHOW}, + {CONFIG_DB_CIRCULAR_LOGGING, CONFIG_TYPE_ONOFF, "on", &ldbm_config_db_circular_logging_get, &ldbm_config_db_circular_logging_set, 0}, + {CONFIG_DB_TRANSACTION_LOGGING, CONFIG_TYPE_ONOFF, "on", &ldbm_config_db_transaction_logging_get, &ldbm_config_db_transaction_logging_set, CONFIG_FLAG_ALWAYS_SHOW}, + {CONFIG_DB_CHECKPOINT_INTERVAL, CONFIG_TYPE_INT, "60", &ldbm_config_db_checkpoint_interval_get, &ldbm_config_db_checkpoint_interval_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, + {CONFIG_DB_TRANSACTION_BATCH, CONFIG_TYPE_INT, "0", &dblayer_get_batch_transactions, &dblayer_set_batch_transactions, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, + {CONFIG_DB_LOGBUF_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_logbuf_size_get, &ldbm_config_db_logbuf_size_set, CONFIG_FLAG_ALWAYS_SHOW}, + {CONFIG_DB_PAGE_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_page_size_get, &ldbm_config_db_page_size_set, 0}, + {CONFIG_DB_INDEX_PAGE_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_index_page_size_get, &ldbm_config_db_index_page_size_set, 0}, + {CONFIG_DB_IDL_DIVISOR, CONFIG_TYPE_INT, "0", &ldbm_config_db_idl_divisor_get, &ldbm_config_db_idl_divisor_set, 0}, + {CONFIG_DB_LOGFILE_SIZE, CONFIG_TYPE_SIZE_T, "0", &ldbm_config_db_logfile_size_get, &ldbm_config_db_logfile_size_set, 0}, + {CONFIG_DB_TRICKLE_PERCENTAGE, CONFIG_TYPE_INT, "5", &ldbm_config_db_trickle_percentage_get, &ldbm_config_db_trickle_percentage_set, 0}, + {CONFIG_DB_SPIN_COUNT, CONFIG_TYPE_INT, "0", &ldbm_config_db_spin_count_get, &ldbm_config_db_spin_count_set, 0}, + {CONFIG_DB_VERBOSE, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_verbose_get, &ldbm_config_db_verbose_set, 0}, + {CONFIG_DB_DEBUG, CONFIG_TYPE_ONOFF, "on", &ldbm_config_db_debug_get, &ldbm_config_db_debug_set, 0}, + {CONFIG_DB_NAMED_REGIONS, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_named_regions_get, &ldbm_config_db_named_regions_set, 0}, + {CONFIG_DB_LOCK, CONFIG_TYPE_INT, "10000", &ldbm_config_db_lock_get, &ldbm_config_db_lock_set, 0}, + {CONFIG_DB_PRIVATE_MEM, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_private_mem_get, &ldbm_config_db_private_mem_set, 0}, + {CONFIG_DB_PRIVATE_IMPORT_MEM, CONFIG_TYPE_ONOFF, "on", &ldbm_config_db_private_import_mem_get, &ldbm_config_db_private_import_mem_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, + {CONFIG_DB_SHM_KEY, CONFIG_TYPE_LONG, "389389", &ldbm_config_db_shm_key_get, &ldbm_config_db_shm_key_set, 0}, + {CONFIG_DB_CACHE, CONFIG_TYPE_INT, "0", &ldbm_config_db_cache_get, &ldbm_config_db_cache_set, 0}, + {CONFIG_DB_DEBUG_CHECKPOINTING, CONFIG_TYPE_ONOFF, "off", &ldbm_config_db_debug_checkpointing_get, &ldbm_config_db_debug_checkpointing_set, 0}, + {CONFIG_DB_HOME_DIRECTORY, CONFIG_TYPE_STRING, "", &ldbm_config_db_home_directory_get, &ldbm_config_db_home_directory_set, 0}, + {CONFIG_IMPORT_CACHE_AUTOSIZE, CONFIG_TYPE_INT, "-1", &ldbm_config_import_cache_autosize_get, &ldbm_config_import_cache_autosize_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, + {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}, + {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}, + {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}, - {CONFIG_INDEX_BUFFER_SIZE, CONFIG_TYPE_INT, "0", &ldbm_config_index_buffer_size_get, &ldbm_config_index_buffer_size_set, 0}, - {CONFIG_EXCLUDE_FROM_EXPORT, CONFIG_TYPE_STRING, - CONFIG_EXCLUDE_FROM_EXPORT_DEFAULT_VALUE, - &ldbm_config_exclude_from_export_get, - &ldbm_config_exclude_from_export_set, CONFIG_FLAG_ALWAYS_SHOW}, - {CONFIG_DB_TX_MAX, CONFIG_TYPE_INT, "200", &ldbm_config_db_tx_max_get, &ldbm_config_db_tx_max_set, 0}, - {CONFIG_SERIAL_LOCK, CONFIG_TYPE_ONOFF, "on", &ldbm_config_serial_lock_get, &ldbm_config_serial_lock_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, - {CONFIG_USE_LEGACY_ERRORCODE, CONFIG_TYPE_ONOFF, "off", &ldbm_config_legacy_errcode_get, &ldbm_config_legacy_errcode_set, 0}, - {NULL, 0, NULL, NULL, NULL, 0} + {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}, + {CONFIG_INDEX_BUFFER_SIZE, CONFIG_TYPE_INT, "0", &ldbm_config_index_buffer_size_get, &ldbm_config_index_buffer_size_set, 0}, + {CONFIG_EXCLUDE_FROM_EXPORT, CONFIG_TYPE_STRING, + CONFIG_EXCLUDE_FROM_EXPORT_DEFAULT_VALUE, + &ldbm_config_exclude_from_export_get, + &ldbm_config_exclude_from_export_set, CONFIG_FLAG_ALWAYS_SHOW}, + {CONFIG_DB_TX_MAX, CONFIG_TYPE_INT, "200", &ldbm_config_db_tx_max_get, &ldbm_config_db_tx_max_set, 0}, + {CONFIG_SERIAL_LOCK, CONFIG_TYPE_ONOFF, "on", &ldbm_config_serial_lock_get, &ldbm_config_serial_lock_set, CONFIG_FLAG_ALWAYS_SHOW|CONFIG_FLAG_ALLOW_RUNNING_CHANGE}, + {CONFIG_USE_LEGACY_ERRORCODE, CONFIG_TYPE_ONOFF, "off", &ldbm_config_legacy_errcode_get, &ldbm_config_legacy_errcode_set, 0}, + {NULL, 0, NULL, NULL, NULL, 0} }; void ldbm_config_setup_default(struct ldbminfo *li) @@ -1279,7 +1279,7 @@ int ldbm_config_load_dse_info(struct ldbminfo *li) * there, then we process the config information it stores. */ PR_snprintf(dn, BUFSIZ, "cn=config, cn=%s, cn=plugins, cn=config", - li->li_plugin->plg_name); + li->li_plugin->plg_name); search_pb = slapi_pblock_new(); slapi_search_internal_set_pb(search_pb, dn, LDAP_SCOPE_BASE, "objectclass=*", NULL, 0, NULL, NULL, li->li_identity, 0); @@ -1304,14 +1304,14 @@ int ldbm_config_load_dse_info(struct ldbminfo *li) 0, 0, 0); return 1; } - parse_ldbm_config_entry(li, entries[0], ldbm_config); + parse_ldbm_config_entry(li, entries[0], ldbm_config); } if (search_pb) { slapi_free_search_results_internal(search_pb); slapi_pblock_destroy(search_pb); } - + /* Find all the instance entries and create a Slapi_Backend and an * ldbm_instance for each */ ldbm_config_read_instance_entries(li, li->li_plugin->plg_name); @@ -1371,14 +1371,14 @@ int ldbm_config_load_dse_info(struct ldbminfo *li) void ldbm_config_get(void *arg, config_info *config, char *buf) { char *tmp_string; - size_t val = 0; + size_t val = 0; if (config == NULL) { buf[0] = '\0'; } switch(config->config_type) { - case CONFIG_TYPE_INT: + case CONFIG_TYPE_INT: sprintf(buf, "%d", (int) config->config_get_fn(arg)); break; case CONFIG_TYPE_INT_OCTAL: @@ -1388,7 +1388,7 @@ void ldbm_config_get(void *arg, config_info *config, char *buf) sprintf(buf, "%ld", (long) config->config_get_fn(arg)); break; case CONFIG_TYPE_SIZE_T: - val = (size_t) config->config_get_fn(arg); + val = (size_t) config->config_get_fn(arg); sprintf(buf, "%lu", val); break; case CONFIG_TYPE_STRING: @@ -1475,17 +1475,17 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc int int_val; long long_val; size_t sz_val; - PRInt64 llval; - int maxint = (int)(((unsigned int)~0)>>1); - int minint = ~maxint; - PRInt64 llmaxint; - PRInt64 llminint; - int err = 0; - char *str_val; + PRInt64 llval; + int maxint = (int)(((unsigned int)~0)>>1); + int minint = ~maxint; + PRInt64 llmaxint; + PRInt64 llminint; + int err = 0; + char *str_val; int retval = 0; - LL_I2L(llmaxint, maxint); - LL_I2L(llminint, minint); + LL_I2L(llmaxint, maxint); + LL_I2L(llminint, minint); config = get_config_info(config_array, attr_name); if (NULL == config) { @@ -1505,7 +1505,7 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc /* If the config phase is initialization or if bval is NULL, we will use * the default value for the attribute. */ if (CONFIG_PHASE_INITIALIZATION == phase || NULL == bval) { - use_default = 1; + use_default = 1; } else { use_default = 0; @@ -1518,33 +1518,33 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc switch(config->config_type) { case CONFIG_TYPE_INT: if (use_default) { - str_val = config->config_default_value; + str_val = config->config_default_value; } else { - str_val = bval->bv_val; + str_val = bval->bv_val; + } + /* get the value as a 64 bit value */ + llval = db_atoi(str_val, &err); + /* check for parsing error (e.g. not a number) */ + if (err) { + PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is not a number\n", + str_val, attr_name); + LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0); + return LDAP_UNWILLING_TO_PERFORM; + /* check for overflow */ + } else if (LL_CMP(llval, >, llmaxint)) { + PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is greater than the maximum %d\n", + str_val, attr_name, maxint); + LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0); + return LDAP_UNWILLING_TO_PERFORM; + /* check for underflow */ + } else if (LL_CMP(llval, <, llminint)) { + PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is less than the minimum %d\n", + str_val, attr_name, minint); + LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0); + return LDAP_UNWILLING_TO_PERFORM; } - /* get the value as a 64 bit value */ - llval = db_atoi(str_val, &err); - /* check for parsing error (e.g. not a number) */ - if (err) { - PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is not a number\n", - str_val, attr_name); - LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0); - return LDAP_UNWILLING_TO_PERFORM; - /* check for overflow */ - } else if (LL_CMP(llval, >, llmaxint)) { - PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is greater than the maximum %d\n", - str_val, attr_name, maxint); - LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0); - return LDAP_UNWILLING_TO_PERFORM; - /* check for underflow */ - } else if (LL_CMP(llval, <, llminint)) { - PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is less than the minimum %d\n", - str_val, attr_name, minint); - LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0); - return LDAP_UNWILLING_TO_PERFORM; - } - /* convert 64 bit value to 32 bit value */ - LL_L2I(int_val, llval); + /* convert 64 bit value to 32 bit value */ + LL_L2I(int_val, llval); retval = config->config_set_fn(arg, (void *) int_val, err_buf, phase, apply_mod); break; case CONFIG_TYPE_INT_OCTAL: @@ -1553,37 +1553,37 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc } else { int_val = (int) strtol((char *)bval->bv_val, NULL, 8); } - retval = config->config_set_fn(arg, (void *) int_val, err_buf, phase, apply_mod); - break; + retval = config->config_set_fn(arg, (void *) int_val, err_buf, phase, apply_mod); + break; case CONFIG_TYPE_LONG: if (use_default) { - str_val = config->config_default_value; + str_val = config->config_default_value; } else { - str_val = bval->bv_val; + str_val = bval->bv_val; } - /* get the value as a 64 bit value */ - llval = db_atoi(str_val, &err); - /* check for parsing error (e.g. not a number) */ - if (err) { - PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is not a number\n", - str_val, attr_name); - LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0); - return LDAP_UNWILLING_TO_PERFORM; - /* check for overflow */ - } else if (LL_CMP(llval, >, llmaxint)) { - PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is greater than the maximum %d\n", - str_val, attr_name, maxint); - LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0); - return LDAP_UNWILLING_TO_PERFORM; - /* check for underflow */ - } else if (LL_CMP(llval, <, llminint)) { - PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is less than the minimum %d\n", - str_val, attr_name, minint); - LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0); - return LDAP_UNWILLING_TO_PERFORM; - } - /* convert 64 bit value to 32 bit value */ - LL_L2I(long_val, llval); + /* get the value as a 64 bit value */ + llval = db_atoi(str_val, &err); + /* check for parsing error (e.g. not a number) */ + if (err) { + PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is not a number\n", + str_val, attr_name); + LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0); + return LDAP_UNWILLING_TO_PERFORM; + /* check for overflow */ + } else if (LL_CMP(llval, >, llmaxint)) { + PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is greater than the maximum %d\n", + str_val, attr_name, maxint); + LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0); + return LDAP_UNWILLING_TO_PERFORM; + /* check for underflow */ + } else if (LL_CMP(llval, <, llminint)) { + PR_snprintf(err_buf, SLAPI_DSE_RETURNTEXT_SIZE, "Error: value %s for attr %s is less than the minimum %d\n", + str_val, attr_name, minint); + LDAPDebug(LDAP_DEBUG_ANY, "%s", err_buf, 0, 0); + return LDAP_UNWILLING_TO_PERFORM; + } + /* convert 64 bit value to 32 bit value */ + LL_L2I(long_val, llval); retval = config->config_set_fn(arg, (void *) long_val, err_buf, phase, apply_mod); break; case CONFIG_TYPE_SIZE_T: @@ -1615,7 +1615,7 @@ int ldbm_config_set(void *arg, char *attr_name, config_info *config_array, struc if (use_default) { retval = config->config_set_fn(arg, config->config_default_value, err_buf, phase, apply_mod); } else { - retval = config->config_set_fn(arg, bval->bv_val, err_buf, phase, apply_mod); + retval = config->config_set_fn(arg, bval->bv_val, err_buf, phase, apply_mod); } break; case CONFIG_TYPE_ONOFF: @@ -1663,7 +1663,7 @@ static int parse_ldbm_config_entry(struct ldbminfo *li, Slapi_Entry *e, config_i * Returns: * SLAPI_DSE_CALLBACK_ERROR on failure * SLAPI_DSE_CALLBACK_OK on success - */ + */ int ldbm_config_modify_entry_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry* e, int *returncode, char *returntext, void *arg) { int i; @@ -1678,7 +1678,7 @@ int ldbm_config_modify_entry_callback(Slapi_PBlock *pb, Slapi_Entry* entryBefore PR_Lock(li->li_config_mutex); slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods ); - + returntext[0] = '\0'; /* @@ -1750,15 +1750,14 @@ void ldbm_config_internal_set(struct ldbminfo *li, char *attrname, char *value) void replace_ldbm_config_value(char *conftype, char *val, struct ldbminfo *li) { Slapi_PBlock pb; - Slapi_Mods smods; + Slapi_Mods smods; pblock_init(&pb); - slapi_mods_init(&smods, 1); - slapi_mods_add(&smods, LDAP_MOD_REPLACE, conftype, strlen(val), val); - slapi_modify_internal_set_pb(&pb, - "cn=config,cn=ldbm database,cn=plugins,cn=config", - slapi_mods_get_ldapmods_byref(&smods), - NULL, NULL, li->li_identity, 0); + slapi_mods_init(&smods, 1); + slapi_mods_add(&smods, LDAP_MOD_REPLACE, conftype, strlen(val), val); + slapi_modify_internal_set_pb(&pb, CONFIG_LDBM_DN, + slapi_mods_get_ldapmods_byref(&smods), + NULL, NULL, li->li_identity, 0); slapi_modify_internal_pb(&pb); slapi_mods_done(&smods); pblock_done(&pb); diff --git a/ldap/servers/slapd/back-ldbm/ldbm_config.h b/ldap/servers/slapd/back-ldbm/ldbm_config.h index 1eb56a49..6dd11e7d 100644 --- a/ldap/servers/slapd/back-ldbm/ldbm_config.h +++ b/ldap/servers/slapd/back-ldbm/ldbm_config.h @@ -144,6 +144,8 @@ struct config_info { #define CONFIG_USE_LEGACY_ERRORCODE "nsslapd-do-not-use-vlv-error" +#define CONFIG_LDBM_DN "cn=config,cn=ldbm database,cn=plugins,cn=config" + #define LDBM_INSTANCE_CONFIG_DONT_WRITE 1 /* Some fuctions in ldbm_config.c used by ldbm_instance_config.c */ |