[Fedora-directory-commits] adminutil/lib/libadminutil resource.c, 1.3, 1.4
by Richard Allen Megginson
Author: rmeggins
Update of /cvs/dirsec/adminutil/lib/libadminutil
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv5277/adminutil/lib/libadminutil
Modified Files:
resource.c
Log Message:
Resolves: bug 466137
Bug Description: htmladmin gives 500 error
Reviewed by: nkinder (Thanks!)
Fix Description: If the locale string passed in to res_getstring is bogus, the CGI will just exit (no crash, no security problems) which causes the 500 error. ures_open returns U_ILLEGAL_ARGUMENT_ERROR if the locale string is bogus. In this case, just use NULL for the locale which will cause it to use the default one.
Platforms tested: RHEL5
Flag Day: no
Doc impact: no
Index: resource.c
===================================================================
RCS file: /cvs/dirsec/adminutil/lib/libadminutil/resource.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- resource.c 8 May 2007 19:13:25 -0000 1.3
+++ resource.c 4 Dec 2008 15:57:36 -0000 1.4
@@ -180,6 +180,12 @@
}
bundle = ures_open(resource->path, (const char*)locale, &status);
+ if (status == U_ILLEGAL_ARGUMENT_ERROR) {
+ /* the locale string is bogus - just use the default */
+ locale = NULL;
+ status = U_ZERO_ERROR;
+ bundle = ures_open(resource->path, (const char*)locale, &status);
+ }
if(U_SUCCESS(status) && bundle) {
int32_t umsglen=0;
14 years, 3 months
[Fedora-directory-commits] adminserver/admserv/cgi-src40 sec-activate.c, 1.11, 1.12
by Richard Allen Megginson
Author: rmeggins
Update of /cvs/dirsec/adminserver/admserv/cgi-src40
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv4922/adminserver/admserv/cgi-src40
Modified Files:
sec-activate.c
Log Message:
Resolves: bug 470946
Bug Description: admin console does not place quotes around the certificate name in console.conf
Reviewed by: nkinder (Thanks!)
Fix Description: Just put double quotes around the values we write out, including NSSNickname
Platforms tested: RHEL5
Flag Day: no
Doc impact: no
Index: sec-activate.c
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/cgi-src40/sec-activate.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- sec-activate.c 14 Jul 2008 20:00:02 -0000 1.11
+++ sec-activate.c 4 Dec 2008 15:55:39 -0000 1.12
@@ -703,7 +703,7 @@
while(fgets(inbuf, sizeof(inbuf), f) != NULL) {
if (strncasecmp(inbuf,name,strlen(name)) == 0) { /* Line starts with the attribute name */
if(val && *val != '\0') {
- PR_snprintf(buf, sizeof(buf), "%s %s\n", name, val);
+ PR_snprintf(buf, sizeof(buf), "%s \"%s\"\n", name, val);
lines[linecnt++] = strdup(buf);
modified=1;
}
@@ -718,7 +718,7 @@
fclose(f);
if (!modified && (val && *val != '\0')) { /* Add the attribute name/val pair*/
- PR_snprintf(buf, sizeof(buf), "%s %s\n", name, val);
+ PR_snprintf(buf, sizeof(buf), "%s \"%s\"\n", name, val);
lines[linecnt++] = strdup(buf);
}
14 years, 3 months
[Fedora-directory-commits] ldapserver/ldap/servers/plugins/replication repl5_connection.c, 1.13, 1.14
by Noriko Hosoi
Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/replication
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv19289
Modified Files:
repl5_connection.c
Log Message:
Resolves: #240512
Summary: schema replication op error logs wrong error
Description:
As suggested by Ulf in his original comment, put break in the case
CONN_OPERATION_FAILED and set the macro to return_value for the readability.
Index: repl5_connection.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/repl5_connection.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- repl5_connection.c 2 Dec 2008 15:29:30 -0000 1.13
+++ repl5_connection.c 4 Dec 2008 00:55:47 -0000 1.14
@@ -1458,6 +1458,8 @@
"%s: Schema replication update failed: %s\n",
agmt_get_long_name(conn->agmt),
ldaperr == -1 ? "Unknown Error" : ldap_err2string(ldaperr));
+ return_value = CONN_OPERATION_FAILED;
+ break;
}
case CONN_NOT_CONNECTED:
return_value = CONN_NOT_CONNECTED;
14 years, 3 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd/back-ldbm ldif2ldbm.c, 1.21, 1.22
by Noriko Hosoi
Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv18184/back-ldbm
Modified Files:
ldif2ldbm.c
Log Message:
Resolves: #474237
Summary: db2ldif -s "suffix" issues confusing warnings when sub suffix exists
[main.c]
* if -s <dn> is passed to db2ldif, the <dn> is used to look up the instance
name the <dn> belongs to with the base dn "cn=mapping tree,cn=config" and the
filter "(&(objectclass=nsmappingtree)(|(cn=*<dn>\")(cn=*<dn>)))". If the <dn>
is not the suffix, but the sub node, it fails to find out the instance which
contains the <dn>. To solve the problem, going upward the DIT until the
instance is found.
* If multiple backends are specified to export, all the names are printed.
[ldif2ldbm.c]
* ldbm_fetch_subtrees: when -s <dn> is passsed to db2ldif, added a logic to
avoid the further process if the <dn> does not belong to the backend.
* When multiple backends are exported, dse was loaded each time. Changed not
to do so.
* Export counter was not decremented when the entry was not to be exported.
Index: ldif2ldbm.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldif2ldbm.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- ldif2ldbm.c 5 Nov 2008 23:49:58 -0000 1.21
+++ ldif2ldbm.c 4 Dec 2008 00:50:18 -0000 1.22
@@ -675,9 +675,61 @@
back_txn *txn = NULL;
struct berval bv;
+ *err = 0;
/* for each subtree spec... */
for (i = 0; include[i]; i++) {
IDList *idl = NULL;
+ char *suffix = slapi_sdn_get_ndn(*be->be_suffix);
+ char *parentdn = slapi_ch_strdup(suffix);
+ char *nextdn = NULL;
+ int matched = 0;
+ int issubsuffix = 0;
+ /*
+ * avoid a case that an include suffix is applied to the backend of
+ * its sub suffix
+ * e.g., suffix: dc=example,dc=com (backend userRoot)
+ * sub suffix: ou=sub,dc=example,dc=com (backend subUserRoot)
+ * When this CLI db2ldif -s "dc=example,dc=com" is executed,
+ * skip checking "dc=example,dc=com" in entrydn of subUserRoot.
+ */
+ while (NULL != parentdn &&
+ NULL != (nextdn = slapi_dn_parent( parentdn ))) {
+ slapi_ch_free_string( &parentdn );
+ if (0 == slapi_utf8casecmp(nextdn, include[i])) {
+ issubsuffix = 1; /* suffix of be is a subsuffix of include[i] */
+ break;
+ }
+ parentdn = nextdn;
+ }
+ slapi_ch_free_string( &parentdn );
+ slapi_ch_free_string( &nextdn );
+ if (issubsuffix) {
+ continue;
+ }
+
+ /*
+ * avoid a case that an include suffix is applied to the unrelated
+ * backend.
+ * e.g., suffix: dc=example,dc=com (backend userRoot)
+ * suffix: dc=test,dc=com (backend testRoot))
+ * When this CLI db2ldif -s "dc=example,dc=com" is executed,
+ * skip checking "dc=example,dc=com" in entrydn of testRoot.
+ */
+ parentdn = slapi_ch_strdup(include[i]);
+ while (NULL != parentdn &&
+ NULL != (nextdn = slapi_dn_parent( parentdn ))) {
+ slapi_ch_free_string( &parentdn );
+ if (0 == slapi_utf8casecmp(nextdn, suffix)) {
+ matched = 1;
+ break;
+ }
+ parentdn = nextdn;
+ }
+ slapi_ch_free_string( &parentdn );
+ slapi_ch_free_string( &nextdn );
+ if (!matched) {
+ continue;
+ }
/*
* First map the suffix to its entry ID.
@@ -689,7 +741,7 @@
if (idl == NULL) {
if (DB_NOTFOUND == *err) {
LDAPDebug(LDAP_DEBUG_ANY,
- "warning: entrydn not indexed on '%s'; "
+ "info: entrydn not indexed on '%s'; "
"entry %s may not be added to the database yet.\n",
include[i], include[i], 0);
*err = 0; /* not a problem */
@@ -787,6 +839,7 @@
int str2entry_options= 0;
int retry;
int we_start_the_backends = 0;
+ static int load_dse = 1; /* We'd like to load dse just once. */
int server_running;
LDAPDebug( LDAP_DEBUG_TRACE, "=> ldbm_back_ldbm2ldif\n", 0, 0, 0 );
@@ -805,7 +858,7 @@
}
}
- if (we_start_the_backends) {
+ if (we_start_the_backends && load_dse) {
/* No ldbm be's exist until we process the config information. */
/*
@@ -815,6 +868,7 @@
* WARNING: ldbm instance userRoot already exists
*/
ldbm_config_load_dse_info(li);
+ load_dse = 0;
}
if (run_from_cmdline && li->li_dblayer_private->dblayer_private_mem
@@ -1004,17 +1058,19 @@
int err;
idl = ldbm_fetch_subtrees(be, include_suffix, &err);
- if (! idl) {
- /* most likely, indexes are bad. */
- LDAPDebug(LDAP_DEBUG_ANY,
- "Failed to fetch subtree lists (error %d) %s\n",
- err, dblayer_strerror(err), 0);
- LDAPDebug(LDAP_DEBUG_ANY,
- "Possibly the entrydn or ancestorid index is corrupted or "
- "does not exist.\n", 0, 0, 0);
- LDAPDebug(LDAP_DEBUG_ANY,
- "Attempting direct unindexed export instead.\n",
- 0, 0, 0);
+ if (NULL == idl) {
+ if (err) {
+ /* most likely, indexes are bad. */
+ LDAPDebug(LDAP_DEBUG_ANY,
+ "Failed to fetch subtree lists (error %d) %s\n",
+ err, dblayer_strerror(err), 0);
+ LDAPDebug(LDAP_DEBUG_ANY,
+ "Possibly the entrydn or ancestorid index is corrupted "
+ "or does not exist.\n", 0, 0, 0);
+ LDAPDebug(LDAP_DEBUG_ANY,
+ "Attempting direct unindexed export instead.\n",
+ 0, 0, 0);
+ }
ok_index = 0;
idl = NULL;
} else if (ALLIDS(idl)) {
@@ -1122,6 +1178,7 @@
if (!ldbm_back_ok_to_dump(backentry_get_ndn(ep), include_suffix,
exclude_suffix)) {
backentry_free( &ep );
+ cnt--;
continue;
}
if(!dump_replica && slapi_entry_flag_is_set(ep->ep_entry, SLAPI_ENTRY_FLAG_TOMBSTONE))
14 years, 3 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd main.c, 1.27, 1.28
by Noriko Hosoi
Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv18184
Modified Files:
main.c
Log Message:
Resolves: #474237
Summary: db2ldif -s "suffix" issues confusing warnings when sub suffix exists
[main.c]
* if -s <dn> is passed to db2ldif, the <dn> is used to look up the instance
name the <dn> belongs to with the base dn "cn=mapping tree,cn=config" and the
filter "(&(objectclass=nsmappingtree)(|(cn=*<dn>\")(cn=*<dn>)))". If the <dn>
is not the suffix, but the sub node, it fails to find out the instance which
contains the <dn>. To solve the problem, going upward the DIT until the
instance is found.
* If multiple backends are specified to export, all the names are printed.
[ldif2ldbm.c]
* ldbm_fetch_subtrees: when -s <dn> is passsed to db2ldif, added a logic to
avoid the further process if the <dn> does not belong to the backend.
* When multiple backends are exported, dse was loaded each time. Changed not
to do so.
* Export counter was not decremented when the entry was not to be exported.
Index: main.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/main.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- main.c 24 Oct 2008 22:36:58 -0000 1.27
+++ main.c 4 Dec 2008 00:50:18 -0000 1.28
@@ -1839,56 +1839,81 @@
static int
lookup_instance_name_by_suffix(char *suffix,
- char ***suffixes, char ***instances, int isexact)
+ char ***suffixes, char ***instances, int isexact)
{
Slapi_PBlock *pb = slapi_pblock_new();
Slapi_Entry **entries = NULL, **ep;
char *query;
- char *backend;
- char *fullsuffix;
- int rval = -1;
+ char *backend;
+ char *fullsuffix;
+ int rval = -1;
if (pb == NULL)
goto done;
- if (isexact)
- query = slapi_ch_smprintf("(&(objectclass=nsmappingtree)(|(cn=\"%s\")(cn=%s)))", suffix, suffix);
- else
- query = slapi_ch_smprintf("(&(objectclass=nsmappingtree)(|(cn=*%s\")(cn=*%s)))", suffix, suffix);
-
- if (query == NULL)
- goto done;
-
- slapi_search_internal_set_pb(pb, "cn=mapping tree,cn=config",
- LDAP_SCOPE_SUBTREE, query, NULL, 0, NULL, NULL,
- (void *)plugin_get_default_component_id(), 0);
- slapi_search_internal_pb(pb);
- slapi_ch_free((void **)&query);
-
- slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &rval);
- if (rval != LDAP_SUCCESS)
- goto done;
+ if (isexact) {
+ query = slapi_ch_smprintf("(&(objectclass=nsmappingtree)(|(cn=\"%s\")(cn=%s)))", suffix, suffix);
+ if (query == NULL)
+ goto done;
+
+ slapi_search_internal_set_pb(pb, "cn=mapping tree,cn=config",
+ LDAP_SCOPE_SUBTREE, query, NULL, 0, NULL, NULL,
+ (void *)plugin_get_default_component_id(), 0);
+ slapi_search_internal_pb(pb);
+ slapi_ch_free((void **)&query);
+
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &rval);
+ if (rval != LDAP_SUCCESS)
+ goto done;
+
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
+ if ((entries == NULL) || (entries[0] == NULL))
+ goto done;
- slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
- if ((entries == NULL) || (entries[0] == NULL))
- goto done;
+ } else {
+ char *suffixp = suffix;
+ while (NULL != suffixp && strlen(suffixp) > 0) {
+ query = slapi_ch_smprintf("(&(objectclass=nsmappingtree)(|(cn=*%s\")(cn=*%s)))", suffixp, suffixp);
+ if (query == NULL)
+ goto done;
+ slapi_search_internal_set_pb(pb, "cn=mapping tree,cn=config",
+ LDAP_SCOPE_SUBTREE, query, NULL, 0, NULL, NULL,
+ (void *)plugin_get_default_component_id(), 0);
+ slapi_search_internal_pb(pb);
+ slapi_ch_free((void **)&query);
+
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &rval);
+ if (rval != LDAP_SUCCESS)
+ goto done;
+
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
+ if ((entries == NULL) || (entries[0] == NULL)) {
+ suffixp = strchr(suffixp, ','); /* get a parent dn */
+ if (NULL != suffixp) {
+ suffixp++;
+ }
+ } else {
+ break; /* found backend entries */
+ }
+ }
+ }
- rval = 0;
- for (ep = entries; *ep; ep++) {
- backend = slapi_entry_attr_get_charptr(*ep, "nsslapd-backend");
- if (backend) {
- charray_add(instances, backend);
- if (suffixes) {
- fullsuffix = slapi_entry_attr_get_charptr(*ep, "cn");
- charray_add(suffixes, fullsuffix); /* NULL is ok */
- }
- }
- }
+ rval = 0;
+ for (ep = entries; *ep; ep++) {
+ backend = slapi_entry_attr_get_charptr(*ep, "nsslapd-backend");
+ if (backend) {
+ charray_add(instances, backend);
+ if (suffixes) {
+ fullsuffix = slapi_entry_attr_get_charptr(*ep, "cn");
+ charray_add(suffixes, fullsuffix); /* NULL is ok */
+ }
+ }
+ }
done:
- slapi_free_search_results_internal(pb);
- slapi_pblock_destroy(pb);
- return rval;
+ slapi_free_search_results_internal(pb);
+ slapi_pblock_destroy(pb);
+ return rval;
}
int
@@ -2167,8 +2192,10 @@
0, 0, 0);
exit(1);
} else {
- LDAPDebug(LDAP_DEBUG_ANY, "Backend Instance: %s\n",
- *instances, 0, 0);
+ LDAPDebug(LDAP_DEBUG_ANY, "Backend Instance(s): \n", 0, 0, 0);
+ for (ip = instances, counter = 0; ip && *ip; ip++, counter++) {
+ LDAPDebug(LDAP_DEBUG_ANY, "\t%s\n", *ip, 0, 0);
+ }
cmd_line_instance_names = instances;
}
} else {
14 years, 3 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd mapping_tree.c, 1.16, 1.17
by Noriko Hosoi
Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv16573/slapd
Modified Files:
mapping_tree.c
Log Message:
Resolves: #474248
Summary: Replica crashes in the consumer initialization if the backend to be
replicated does not exist
Description:
. mapping_tree.c: if NULL mapping tree state is passed, return an error.
. repl_extop.c: if mapping tree node state is NULL, don't reset the mapping
tree state.
. replutil.c: if NULL mapping tree state is passed, log it and return.
Index: mapping_tree.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/mapping_tree.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- mapping_tree.c 13 Nov 2008 23:08:18 -0000 1.16
+++ mapping_tree.c 4 Dec 2008 00:42:18 -0000 1.17
@@ -3043,6 +3043,10 @@
return LDAP_OPERATIONS_ERROR;
}
+ if (NULL == state) {
+ return LDAP_OPERATIONS_ERROR;
+ }
+
if ( (value = slapi_mtn_get_state(sdn)) != NULL )
{
if ( strcasecmp(value, state) == 0 )
14 years, 3 months
[Fedora-directory-commits] ldapserver/ldap/servers/plugins/replication repl_extop.c, 1.14, 1.15 replutil.c, 1.13, 1.14
by Noriko Hosoi
Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/replication
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv16573/plugins/replication
Modified Files:
repl_extop.c replutil.c
Log Message:
Resolves: #474248
Summary: Replica crashes in the consumer initialization if the backend to be
replicated does not exist
Description:
. mapping_tree.c: if NULL mapping tree state is passed, return an error.
. repl_extop.c: if mapping tree node state is NULL, don't reset the mapping
tree state.
. replutil.c: if NULL mapping tree state is passed, log it and return.
Index: repl_extop.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/repl_extop.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- repl_extop.c 17 Oct 2008 22:12:47 -0000 1.14
+++ repl_extop.c 4 Dec 2008 00:42:18 -0000 1.15
@@ -837,10 +837,12 @@
{
response = NSDS50_REPL_INTERNAL_ERROR;
/* reset the mapping tree state to what it was before
- we tried to do the bulk import */
- repl_set_mtn_state_and_referrals(repl_root_sdn, mtnstate,
+ we tried to do the bulk import if mtnstate exists */
+ if (mtnstate) {
+ repl_set_mtn_state_and_referrals(repl_root_sdn, mtnstate,
NULL, NULL, mtnreferral);
- slapi_ch_free_string(&mtnstate);
+ slapi_ch_free_string(&mtnstate);
+ }
charray_free(mtnreferral);
mtnreferral = NULL;
Index: replutil.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/replutil.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- replutil.c 17 Oct 2008 22:12:47 -0000 1.13
+++ replutil.c 4 Dec 2008 00:42:18 -0000 1.14
@@ -709,6 +709,11 @@
int ii = 0;
char **referrals_to_set = NULL;
PRBool chain_on_update = is_chain_on_update_setup(repl_root_sdn);
+ if (NULL == mtn_state) {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
+ "repl_set_mtn_referrals: cannot set NULL state.\n");
+ return;
+ }
/* Fix for blackflag bug 601440: We want the new behaviour of DS,
** going forward, to now be that if the nsds5replicareferral attrib
14 years, 3 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd/back-ldbm ancestorid.c, 1.6, 1.7
by Noriko Hosoi
Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv13558
Modified Files:
ancestorid.c
Log Message:
Resolves: #469800
Summary: Slow import post-processing with large number of non-leaf entries
Description:
Building the ancestorid index does not need to be so expensive, since the
information is available from the parentid index. The cost is associated with
general overhead in maintaining the IDLists in memory, and in particular to the
constant unions done on them to add children. When these lists may contain
millions of entries, the time spent copying the existing data when inserting
children is prohibitively expensive. This does not affect all layouts equally,
but does cause problems when large numbers of children are dispersed throughout
the tree.
BDB can usually handle inserts efficiently on its own, so it is not necessary
to maintain complete IDLists in memory for all the entries and write them out
in total. Updates can be performed directly to the DB instead.
Note: checking in the patch on behalf of Thomas Lackey
Index: ancestorid.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ancestorid.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ancestorid.c 15 Oct 2008 06:30:06 -0000 1.6
+++ ancestorid.c 3 Dec 2008 19:14:18 -0000 1.7
@@ -70,6 +70,8 @@
static int ldbm_parentid(backend *be, DB_TXN *txn, ID id, ID *ppid);
static int check_cache(id2idl_hash *ht);
static IDList *idl_union_allids(backend *be, struct attrinfo *ai, IDList *a, IDList *b);
+static int ldbm_ancestorid_default_create_index(backend *be);
+static int ldbm_ancestorid_new_idl_create_index(backend *be);
static int ldbm_get_nonleaf_ids(backend *be, DB_TXN *txn, IDList **idl)
{
@@ -158,6 +160,19 @@
*/
int ldbm_ancestorid_create_index(backend *be)
{
+ return (idl_get_idl_new()) ?
+ ldbm_ancestorid_new_idl_create_index(be) :
+ ldbm_ancestorid_default_create_index(be);
+}
+
+/*
+ * Create the ancestorid index. This version is safe to
+ * use whichever IDL mode is active. However, it may be
+ * quite a bit slower than ldbm_ancestorid_new_idl_create_index()
+ * when the new mode is used, particularly with large databases.
+ */
+static int ldbm_ancestorid_default_create_index(backend *be)
+{
int ret = 0;
DB *db_pid = NULL;
DB *db_aid = NULL;
@@ -330,6 +345,181 @@
}
/*
+ * Create the ancestorid index. This version expects to use
+ * idl_new_store_block() and should be used when idl_new != 0.
+ * It has lower overhead and can be faster than
+ * ldbm_ancestorid_default_create_index(), particularly on
+ * large databases. Cf. bug 469800.
+ */
+static int ldbm_ancestorid_new_idl_create_index(backend *be)
+{
+ int ret = 0;
+ DB *db_pid = NULL;
+ DB *db_aid = NULL;
+ DBT key = {0};
+ DB_TXN *txn = NULL;
+ struct attrinfo *ai_pid = NULL;
+ struct attrinfo *ai_aid = NULL;
+ char keybuf[24];
+ IDList *nodes = NULL;
+ IDList *children = NULL;
+ NIDS nids;
+ ID id, parentid;
+
+ /*
+ * We need to iterate depth-first through the non-leaf nodes
+ * in the tree amassing an idlist of descendant ids for each node.
+ * We would prefer to go through the parentid keys just once from
+ * highest id to lowest id but the btree ordering is by string
+ * rather than number. So we go through the parentid keys in btree
+ * order first of all to create an idlist of all the non-leaf nodes.
+ * Then we can use the idlist to iterate through parentid in the
+ * correct order.
+ */
+
+ LDAPDebug(LDAP_DEBUG_TRACE, "Creating ancestorid index\n", 0,0,0);
+
+ /* Bail now if we did not get here honestly. */
+ if (!idl_get_idl_new()) {
+ LDAPDebug(LDAP_DEBUG_ANY, "Cannot create ancestorid index. "
+ "New IDL version called but idl_new is false!\n", 0,0,0);
+ return 1;
+ }
+
+ /* Get the non-leaf node IDs */
+ ret = ldbm_get_nonleaf_ids(be, txn, &nodes);
+ if (ret != 0) return ret;
+
+ /* Get the ancestorid index */
+ ainfo_get(be, "ancestorid", &ai_aid);
+
+ /* Prevent any other use of the index */
+ ai_aid->ai_indexmask |= INDEX_OFFLINE;
+
+ /* Open the ancestorid index file */
+ ret = dblayer_get_index_file(be, ai_aid, &db_aid, DBOPEN_CREATE);
+ if (ret != 0) {
+ ldbm_nasty(sourcefile,13050,ret);
+ goto out;
+ }
+
+ /* Maybe nothing to do */
+ if (nodes == NULL || nodes->b_nids == 0) {
+ LDAPDebug(LDAP_DEBUG_ANY, "Nothing to do to build ancestorid index\n",
+ 0, 0, 0);
+ goto out;
+ }
+
+ /* Get the parentid index */
+ ainfo_get( be, "parentid", &ai_pid );
+
+ /* Open the parentid index file */
+ ret = dblayer_get_index_file(be, ai_pid, &db_pid, DBOPEN_CREATE);
+ if (ret != 0) {
+ ldbm_nasty(sourcefile,13060,ret);
+ goto out;
+ }
+
+ /* Initialize key DBT */
+ key.data = keybuf;
+ key.ulen = sizeof(keybuf);
+ key.flags = DB_DBT_USERMEM;
+
+ /* Iterate from highest to lowest ID */
+ nids = nodes->b_nids;
+ do {
+
+ nids--;
+ id = nodes->b_ids[nids];
+
+ /* Get immediate children from parentid index */
+ key.size = PR_snprintf(key.data, key.ulen, "%c%lu",
+ EQ_PREFIX, (u_long)id);
+ key.size++; /* include the null terminator */
+ ret = NEW_IDL_NO_ALLID;
+ children = idl_fetch(be, db_pid, &key, txn, ai_pid, &ret);
+ if (ret != 0) {
+ ldbm_nasty(sourcefile,13070,ret);
+ break;
+ }
+
+ /* Instead of maintaining a full accounting of IDs in a hashtable
+ * as is done with ldbm_ancestorid_default_create_index(), perform
+ * incremental updates straight to the DB with idl_new_store_block()
+ * (used by idl_store_block() when idl_get_idl_new() is true). This
+ * can be a significant performance improvement with large databases,
+ * where the overhead of maintaining and copying the lists is very
+ * expensive, particularly when the allids threshold is not being
+ * used to provide any cut off. Cf. bug 469800.
+ * TEL 20081029 */
+
+ /* Insert into ancestorid for this node */
+ ret = idl_store_block(be, db_aid, &key, children, txn, ai_aid);
+ if (ret != 0) {
+ idl_free(children);
+ break;
+ }
+
+ /* Get parentid for this entry */
+ ret = ldbm_parentid(be, txn, id, &parentid);
+ if (ret != 0) {
+ idl_free(children);
+ break;
+ }
+
+ /* A suffix entry does not have a parent */
+ if (parentid == NOID) {
+ idl_free(children);
+ continue;
+ }
+
+ /* Reset the key to the parent id */
+ key.size = PR_snprintf(key.data, key.ulen, "%c%lu",
+ EQ_PREFIX, (u_long)parentid);
+ key.size++;
+
+ /* Insert into ancestorid for this node's parent */
+ ret = idl_store_block(be, db_aid, &key, children, txn, ai_aid);
+ idl_free(children);
+ if (ret != 0) {
+ break;
+ }
+ } while (nids > 0);
+
+ if (ret != 0) {
+ goto out;
+ }
+
+ out:
+ if (ret == 0) {
+ LDAPDebug(LDAP_DEBUG_TRACE, "Created ancestorid index\n", 0,0,0);
+ } else {
+ LDAPDebug(LDAP_DEBUG_ANY, "Failed to create ancestorid index\n", 0,0,0);
+ }
+
+ /* Free any leftover idlists */
+ idl_free(nodes);
+
+ /* Release the parentid file */
+ if (db_pid != NULL) {
+ dblayer_release_index_file( be, ai_pid, db_pid );
+ }
+
+ /* Release the ancestorid file */
+ if (db_aid != NULL) {
+ dblayer_release_index_file( be, ai_aid, db_aid );
+ }
+
+ /* Enable the index */
+ if (ret == 0) {
+ ai_aid->ai_indexmask &= ~INDEX_OFFLINE;
+ }
+
+ return ret;
+}
+
+
+/*
* Get parentid of an id by reading the operational attr from id2entry.
*/
static int ldbm_parentid(backend *be, DB_TXN *txn, ID id, ID *ppid)
14 years, 3 months
[Fedora-directory-commits] adminutil/lib/libadminutil srvutil.c, 1.5, 1.6
by Richard Allen Megginson
Author: rmeggins
Update of /cvs/dirsec/adminutil/lib/libadminutil
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv10019/adminutil/lib/libadminutil
Modified Files:
srvutil.c
Log Message:
compiler warning clean up
Index: srvutil.c
===================================================================
RCS file: /cvs/dirsec/adminutil/lib/libadminutil/srvutil.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- srvutil.c 22 Jun 2007 21:06:44 -0000 1.5
+++ srvutil.c 3 Dec 2008 18:36:49 -0000 1.6
@@ -249,7 +249,7 @@
if (nl) {
size_t len = strlen(serverID);
AttrNameList nlptr = nl;
- while (retval = *nlptr++) {
+ while ((retval = *nlptr++)) {
/* nl is a list of DNs like this:
cn=slapd-foo, ...
cn=slapd-bar,...
14 years, 3 months
[Fedora-directory-commits] adminutil/lib/libadmsslutil admsslutil.c, 1.9, 1.10 srvutilssl.c, 1.6, 1.7
by Richard Allen Megginson
Author: rmeggins
Update of /cvs/dirsec/adminutil/lib/libadmsslutil
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv10019/adminutil/lib/libadmsslutil
Modified Files:
admsslutil.c srvutilssl.c
Log Message:
compiler warning clean up
Index: admsslutil.c
===================================================================
RCS file: /cvs/dirsec/adminutil/lib/libadmsslutil/admsslutil.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- admsslutil.c 22 Jun 2007 21:06:45 -0000 1.9
+++ admsslutil.c 3 Dec 2008 18:36:50 -0000 1.10
@@ -69,22 +69,6 @@
char custom_file[BIG_LINE] = "";
char retried_token[BIG_LINE] = "";
-/* returns true if the given path is a valid directory, false otherwise */
-static int
-is_dir_ok(const char *path)
-{
- PRFileInfo prinfo;
- int ret = 0;
-
- if (path && *path &&
- (PR_SUCCESS == PR_GetFileInfo(path, &prinfo)) &&
- prinfo.type == PR_FILE_DIRECTORY) {
- ret = 1;
- }
-
- return ret;
-}
-
PR_IMPLEMENT(int)
admldapBuildInfoSSL(AdmldapInfo info, int *errorcode)
{
Index: srvutilssl.c
===================================================================
RCS file: /cvs/dirsec/adminutil/lib/libadmsslutil/srvutilssl.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- srvutilssl.c 28 Jun 2007 20:47:56 -0000 1.6
+++ srvutilssl.c 3 Dec 2008 18:36:50 -0000 1.7
@@ -19,6 +19,7 @@
* END COPYRIGHT BLOCK **/
#include <string.h>
#include "libadminutil/admutil.h"
+#include "libadminutil/distadm.h"
#include "libadmsslutil/psetcssl.h"
#include "libadmsslutil/srvutilssl.h"
@@ -176,7 +177,7 @@
if (nl) {
size_t len = strlen(serverID);
AttrNameList nlptr = nl;
- while (retval = *nlptr++) {
+ while ((retval = *nlptr++)) {
/* nl is a list of DNs like this:
cn=slapd-foo, ...
cn=slapd-bar,...
14 years, 3 months