[Fedora-directory-commits] ldapserver/ldap/servers/slapd/back-ldbm archive.c, 1.12, 1.13
by Doctor Conrad
Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv15561
Modified Files:
archive.c
Log Message:
Resolves: #316281
Summary: db2bak fails if the archive path exists and ends with '/'
Fix description:
1. Use path normalize API rel2abspath to remove the trailing '/'s.
2. db2bak renames the archive dir if the directory exists, checks the directory
is the db dir or not. If it is, the command line rename back the existing db
to the original and exits with the error: db2archive: Cannot archive to the db
directory. Then, the original dir is renamed back. If the db2bak runs as a
task (db2bak.pl or console), the server is up and running. Although the
backend is disabled, we don't want to rename the db path even for a short time.
That being said, changed the order to: check if the archive dir is the same as
db dir or not. It exits immediately.
Index: archive.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/archive.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- archive.c 26 Mar 2007 23:04:17 -0000 1.12
+++ archive.c 3 Oct 2007 19:14:58 -0000 1.13
@@ -110,7 +110,7 @@
slapi_task_log_notice(task,
"backup has old idl format; "
"to restore old formated backup onto the new server, "
- "please use command line utility \"bak2db\" .\n");
+ "please use command line utility \"bak2db\" .");
}
goto out;
}
@@ -128,7 +128,7 @@
if (task) {
slapi_task_log_notice(task,
"Backend '%s' is already in the middle of "
- "another task and cannot be disturbed.\n",
+ "another task and cannot be disturbed.",
inst->inst_name);
}
@@ -257,7 +257,8 @@
int ldbm_back_ldbm2archive( Slapi_PBlock *pb )
{
struct ldbminfo *li;
- char *directory = NULL; /* -a <directory> */
+ char *rawdirectory = NULL; /* -a <directory> */
+ char *directory = NULL; /* normalized */
char *dir_bak = NULL;
int return_value = -1;
int task_flags = 0;
@@ -266,25 +267,57 @@
struct stat sbuf;
slapi_pblock_get( pb, SLAPI_PLUGIN_PRIVATE, &li );
- slapi_pblock_get( pb, SLAPI_SEQ_VAL, &directory );
+ slapi_pblock_get( pb, SLAPI_SEQ_VAL, &rawdirectory );
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 ( !directory || !*directory ) {
+ if ( !rawdirectory || !*rawdirectory ) {
LDAPDebug( LDAP_DEBUG_ANY, "db2archive: no archive name\n",
0, 0, 0 );
- return( -1 );
+ return -1;
}
- if (stat(directory, &sbuf) == 0) {
- int baklen = strlen(directory) + 5; /* ".bak\0" */
+
+ /* start the database code up, do not attempt to perform recovery */
+ if (run_from_cmdline) {
+ /* No ldbm be's exist until we process the config information. */
+ mapping_tree_init();
+ ldbm_config_load_dse_info(li);
+ if (0 != (return_value =
+ dblayer_start(li,
+ DBLAYER_ARCHIVE_MODE|DBLAYER_NO_DBTHREADS_MODE))) {
+ LDAPDebug(LDAP_DEBUG_ANY, "db2archive: Failed to init database\n",
+ 0, 0, 0);
+ if (task) {
+ slapi_task_log_notice(task, "Failed to init database");
+ }
+ return -1;
+ }
+ }
+
+ if (stat(rawdirectory, &sbuf) == 0) {
+ int baklen = 0;
+ directory = rel2abspath(rawdirectory);
+
+ if (slapd_comp_path(directory, li->li_directory) == 0) {
+ LDAPDebug(LDAP_DEBUG_ANY,
+ "db2archive: Cannot archive to the db directory.\n", 0, 0, 0);
+ if (task) {
+ slapi_task_log_notice(task,
+ "Cannot archive to the db directory.");
+ }
+ return_value = -1;
+ goto out;
+ }
+
+ baklen = strlen(directory) + 5; /* ".bak\0" */
dir_bak = slapi_ch_malloc(baklen);
PR_snprintf(dir_bak, baklen, "%s.bak", directory);
LDAPDebug(LDAP_DEBUG_ANY, "db2archive: %s exists. Renaming to %s\n",
directory, dir_bak, 0);
if (task) {
- slapi_task_log_notice(task, "%s exists. Renaming to %s\n",
+ slapi_task_log_notice(task, "%s exists. Renaming to %s",
directory, dir_bak);
}
if (stat(dir_bak, &sbuf) == 0) {
@@ -295,7 +328,7 @@
dir_bak, 0, 0);
if (task) {
slapi_task_log_notice(task,
- "%s exists and failed to delete it.\n", dir_bak);
+ "%s exists and failed to delete it.", dir_bak);
}
return_value = -1;
goto out;
@@ -305,10 +338,10 @@
if (return_value != PR_SUCCESS) {
PRErrorCode prerr = PR_GetError();
LDAPDebug(LDAP_DEBUG_ANY,
- "db2archive: Failed to rename \"%s\" to \"%s\".",
+ "db2archive: Failed to rename \"%s\" to \"%s\".\n",
directory, dir_bak, 0);
LDAPDebug(LDAP_DEBUG_ANY,
- SLAPI_COMPONENT_NAME_NSPR " error %d (%s)",
+ SLAPI_COMPONENT_NAME_NSPR " error %d (%s)\n",
prerr, slapd_pr_strerror(prerr), 0);
if (task) {
slapi_task_log_notice(task,
@@ -336,11 +369,6 @@
goto err;
}
- /* No ldbm be's exist until we process the config information. */
- if (run_from_cmdline) {
- mapping_tree_init();
- ldbm_config_load_dse_info(li);
- }
/* to avoid conflict w/ import, do this check for commandline, as well */
{
Object *inst_obj, *inst_obj2;
@@ -360,7 +388,7 @@
if (task) {
slapi_task_log_notice(task,
"Backend '%s' is already in the middle of "
- "another task and cannot be disturbed.\n",
+ "another task and cannot be disturbed.",
inst->inst_name);
}
@@ -381,45 +409,9 @@
}
}
- /* start the database code up, do not attempt to perform recovery */
- if (run_from_cmdline &&
- 0 != (return_value = dblayer_start(li,DBLAYER_ARCHIVE_MODE|DBLAYER_NO_DBTHREADS_MODE))) {
- LDAPDebug(LDAP_DEBUG_ANY, "db2archive: Failed to init database\n",
- 0, 0, 0);
- if (task) {
- slapi_task_log_notice(task, "Failed to init database");
- }
- goto rel_err;
- }
-
- if (slapd_comp_path(directory, li->li_directory) == 0) {
- LDAPDebug(LDAP_DEBUG_ANY,
- "db2archive: Cannot archive to the db directory.\n", 0, 0, 0);
- if (task) {
- slapi_task_log_notice(task, "Cannot archive to the db directory.\n");
- }
- return_value = -1;
- goto rel_err;
- }
-
/* tell it to archive */
return_value = dblayer_backup(li, directory, task);
-rel_err:
- /* close the database down again */
- if (run_from_cmdline &&
- 0 != dblayer_close(li,DBLAYER_ARCHIVE_MODE|DBLAYER_NO_DBTHREADS_MODE)) {
- LDAPDebug(LDAP_DEBUG_ANY, "db2archive: Failed to close database\n",
- 0, 0, 0);
- if (task) {
- slapi_task_log_notice(task, "Failed to close database");
- }
-
- /* The backup succeeded, so a failed close is not really a
- total error... */
- /*return( -1 );*/
- }
-
if (! run_from_cmdline) {
ldbm_instance *inst;
Object *inst_obj;
@@ -436,13 +428,24 @@
LDAPDebug(LDAP_DEBUG_ANY, "db2archive: Rename %s back to %s\n",
dir_bak, directory, 0);
if (task) {
- slapi_task_log_notice(task, "Rename %s back to %s\n",
+ slapi_task_log_notice(task, "Rename %s back to %s",
dir_bak, directory);
}
ldbm_delete_dirs(directory);
PR_Rename(dir_bak, directory);
}
out:
+ /* close the database down again */
+ if (run_from_cmdline &&
+ 0 != dblayer_close(li,DBLAYER_ARCHIVE_MODE|DBLAYER_NO_DBTHREADS_MODE)) {
+ LDAPDebug(LDAP_DEBUG_ANY, "db2archive: Failed to close database\n",
+ 0, 0, 0);
+ if (task) {
+ slapi_task_log_notice(task, "Failed to close database");
+ }
+ }
+
slapi_ch_free_string(&dir_bak);
+ slapi_ch_free_string(&directory);
return return_value;
}
16 years, 6 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd opshared.c, 1.9, 1.10 result.c, 1.10, 1.11
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv488/ldapserver/ldap/servers/slapd
Modified Files:
opshared.c result.c
Log Message:
Resolves: bug 282911
Description: double err=32 result sent when suffix doesn't exist
Reviewed by: nkinder (Thanks!)
Fix Description: The backend does not send back a result if the op is search and the err is NO_SUCH_OBJECT (32). The frontend should handle this case so that it knows to defer sending the result until all of the backend candidates have been scanned. We also need to change send_nobackend_ldap_result() to use slapi_send_ldap_result instead of send_ldap_result so that it has the same semantics as the regular backend code.
Platforms tested: RHEL5 x86_64
Index: opshared.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/opshared.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- opshared.c 2 Oct 2007 19:21:32 -0000 1.9
+++ opshared.c 3 Oct 2007 17:44:50 -0000 1.10
@@ -546,10 +546,22 @@
rc = (*be->be_search)(pb);
switch (rc)
{
- int err;
- case 1: /* backend successfully sent result to the client */
+ int err = 0;
+ case 1: /* if the backend returned LDAP_NO_SUCH_OBJECT for a SEARCH request,
+ it will not have sent back a result - otherwise, it will have
+ sent a result */
rc = SLAPI_FAIL_GENERAL;
- /* Set a flag here so we don't return another result. */
+ slapi_pblock_get(pb, SLAPI_RESULT_CODE, &err);
+ if (err == LDAP_NO_SUCH_OBJECT)
+ {
+ /* may be the object exist somewhere else
+ * wait the end of the loop to send back this error
+ */
+ flag_no_such_object = 1;
+ break;
+ }
+ /* err something other than LDAP_NO_SUCH_OBJECT, so the backend will have sent the result -
+ Set a flag here so we don't return another result. */
sent_result = 1;
/* fall through */
Index: result.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/result.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- result.c 10 Nov 2006 23:45:40 -0000 1.10
+++ result.c 3 Oct 2007 17:44:50 -0000 1.11
@@ -573,7 +573,7 @@
err in the pblock, so this function needs to also */
slapi_pblock_set(pb, SLAPI_RESULT_CODE, &err);
- send_ldap_result( pb, err, NULL, NULL, 0, refurls );
+ slapi_send_ldap_result( pb, err, NULL, NULL, 0, refurls );
}
16 years, 6 months
[Fedora-directory-commits] ldapserver/ldap/servers/plugins/replication repl5_protocol_util.c, 1.10, 1.11
by Doctor Conrad
Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/replication
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv32219/plugins/replication
Modified Files:
repl5_protocol_util.c
Log Message:
Resolves: #196523
Summary: miscellaneous memory leaks
Description: 1) fixed memory leaks
2) cleaned up normalize_path code with fixing memory leaks
Index: repl5_protocol_util.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/replication/repl5_protocol_util.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- repl5_protocol_util.c 21 Nov 2006 19:14:10 -0000 1.10
+++ repl5_protocol_util.c 3 Oct 2007 00:55:34 -0000 1.11
@@ -117,6 +117,10 @@
int return_value;
ConnResult crc;
Repl_Connection *conn;
+ struct berval *retdata = NULL;
+ char *retoid = NULL;
+ Slapi_DN *replarea_sdn = NULL;
+ struct berval **ruv_bervals = NULL;
PR_ASSERT(prp && prot_oid);
@@ -200,9 +204,6 @@
} else
{
CSN *current_csn = NULL;
- struct berval *retdata = NULL;
- char *retoid = NULL;
- Slapi_DN *replarea_sdn;
/* Good to go. Start the protocol. */
@@ -243,7 +244,6 @@
* Extop was processed. Look at extop response to see if we're
* permitted to go ahead.
*/
- struct berval **ruv_bervals = NULL;
int extop_result;
int extop_rc = decode_repl_ext_response(retdata, &extop_result,
&ruv_bervals);
@@ -411,8 +411,6 @@
prp->last_acquire_response_code = NSDS50_REPL_INTERNAL_ERROR;
return_value = ACQUIRE_FATAL_ERROR;
}
- if (NULL != ruv_bervals)
- ber_bvecfree(ruv_bervals);
}
else
{
@@ -437,15 +435,18 @@
agmt_get_long_name(prp->agmt));
return_value = ACQUIRE_FATAL_ERROR;
}
- slapi_sdn_free(&replarea_sdn);
- if (NULL != retoid)
- ldap_memfree(retoid);
- if (NULL != retdata)
- ber_bvfree(retdata);
}
}
}
error:
+ if (NULL != ruv_bervals)
+ ber_bvecfree(ruv_bervals);
+ if (NULL != replarea_sdn)
+ slapi_sdn_free(&replarea_sdn);
+ if (NULL != retoid)
+ ldap_memfree(retoid);
+ if (NULL != retdata)
+ ber_bvfree(retdata);
if (ACQUIRE_SUCCESS != return_value)
{
16 years, 6 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd util.c, 1.14, 1.15 sasl_io.c, 1.11, 1.12
by Doctor Conrad
Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv32219/slapd
Modified Files:
util.c sasl_io.c
Log Message:
Resolves: #196523
Summary: miscellaneous memory leaks
Description: 1) fixed memory leaks
2) cleaned up normalize_path code with fixing memory leaks
Index: util.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/util.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- util.c 4 Dec 2006 18:36:56 -0000 1.14
+++ util.c 3 Oct 2007 00:55:35 -0000 1.15
@@ -402,61 +402,63 @@
static void
clean_path(char **norm_path)
{
- char **np;
+ char **np;
- for (np = norm_path; np && *np; np++)
- slapi_ch_free((void **)np);
- slapi_ch_free((void **)&norm_path);
+ for (np = norm_path; np && *np; np++)
+ slapi_ch_free_string(np);
+ slapi_ch_free((void **)&norm_path);
}
static char **
normalize_path(char *path)
{
- char *dname = slapi_ch_strdup(path);
- char *dnamep = dname;
- char *bnamep = NULL;
+ char *dname = NULL;
+ char *dnamep = NULL;
char **dirs = (char **)slapi_ch_calloc(strlen(path), sizeof(char *));
char **rdirs = (char **)slapi_ch_calloc(strlen(path), sizeof(char *));
char **dp = dirs;
char **rdp;
+ int elimdots = 0;
+
+ if (NULL == path || '\0' == *path) {
+ return NULL;
+ }
+
+ dname = slapi_ch_strdup(path);
do {
- bnamep = strrchr(dnamep, _CSEP);
- if (NULL == bnamep) {
- bnamep = dnamep;
+ dnamep = strrchr(dname, _CSEP);
+ if (NULL == dnamep) {
+ dnamep = dname;
} else {
- *bnamep = '\0';
- bnamep++;
+ *dnamep = '\0';
+ dnamep++;
}
- if (0 != strcmp(bnamep, ".")) {
- *dp++ = slapi_ch_strdup(bnamep); /* remove "/./" in the path */
+ if (0 != strcmp(dnamep, ".") && strlen(dnamep) > 0) {
+ *dp++ = slapi_ch_strdup(dnamep); /* rm "/./" and "//" in the path */
}
- } while (NULL != dnamep && '\0' != *dnamep && /* done or relative path */
- !(0 == strcmp(dnamep, ".") && 0 == strcmp(bnamep, ".")));
+ } while ( dnamep > dname /* == -> no more _CSEP */ );
+ slapi_ch_free_string(&dname);
/* remove "xxx/.." in the path */
for (dp = dirs, rdp = rdirs; dp && *dp; dp++) {
while (*dp && 0 == strcmp(*dp, "..")) {
dp++;
- if (rdp > rdirs)
- rdp--;
+ elimdots++;
}
- if (*dp)
+ if (elimdots > 0) {
+ elimdots--;
+ } else if (*dp) {
*rdp++ = slapi_ch_strdup(*dp);
- }
- for (--dp, rdp = rdirs; dp >= dirs; dp--) {
- while (*dp && 0 == strcmp(*dp, "..")) {
- dp--;
- if (rdp > rdirs)
- rdp--;
}
- if (*dp && strlen(*dp) > 0)
- *rdp++ = slapi_ch_strdup(*dp);
}
- *rdp = NULL;
+ /* reverse */
+ for (--rdp, dp = rdirs; rdp >= dp && rdp >= rdirs; --rdp, dp++) {
+ char *tmpp = *dp;
+ *dp = *rdp;
+ *rdp = tmpp;
+ }
clean_path(dirs);
- slapi_ch_free_string(&dname);
-
return rdirs;
}
Index: sasl_io.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/sasl_io.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- sasl_io.c 25 Apr 2007 20:24:31 -0000 1.11
+++ sasl_io.c 3 Oct 2007 00:55:35 -0000 1.12
@@ -139,6 +139,7 @@
sasl_io_cleanup(Connection *c)
{
int ret = 0;
+ struct lber_x_ext_io_fns *func_pointers = NULL;
sasl_io_private *sp = c->c_sasl_io_private;
if (sp) {
LDAPDebug( LDAP_DEBUG_CONNS,
@@ -147,6 +148,8 @@
slapi_ch_free((void**)&(sp->encrypted_buffer));
slapi_ch_free((void**)&(sp->decrypted_buffer));
/* Put the I/O functions back how they were */
+ ber_sockbuf_get_option( c->c_sb, LBER_SOCKBUF_OPT_EXT_IO_FNS, &func_pointers);
+ slapi_ch_free((void**)&func_pointers);
ber_sockbuf_set_option( c->c_sb, LBER_SOCKBUF_OPT_EXT_IO_FNS, sp->real_iofns);
slapi_ch_free((void**)&sp);
c->c_sasl_io_private = NULL;
16 years, 6 months
[Fedora-directory-commits] adminserver/admserv/newinst/src AdminUtil.pm.in, 1.15, 1.16
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/adminserver/admserv/newinst/src
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv21803/adminserver/admserv/newinst/src
Modified Files:
AdminUtil.pm.in
Log Message:
Resolves: bug 315731
Description: SNMP Show-stopper - Can't install DS80 on Rhel4-32 bit
Fix Description: If conn is NULL, we can't use it to get the error message, so just use a message of unknown in that case.
Index: AdminUtil.pm.in
===================================================================
RCS file: /cvs/dirsec/adminserver/admserv/newinst/src/AdminUtil.pm.in,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- AdminUtil.pm.in 20 Sep 2007 21:47:28 -0000 1.15
+++ AdminUtil.pm.in 2 Oct 2007 23:35:01 -0000 1.16
@@ -244,10 +244,17 @@
$inf->{slapd}->{RootDN},
$inf->{slapd}->{RootDNPwd},
$inf->{General}->{certdir});
- if (!$conn) {
+ my $errstr;
+ if ($conn) {
+ $errstr = $conn->getErrorString();
+ }
+ if (!$conn or ($errstr ne "Success")) {
@{$errs} = ('error_connection_failed', $inf->{General}->{FullMachineName},
$inf->{slapd}->{ServerPort}, $inf->{slapd}->{RootDN},
- $conn->getErrorString());
+ ($conn ? $errstr : "unknown"));
+ if ($conn) {
+ $conn->close();
+ }
return 0;
}
16 years, 6 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd/back-ldbm vlv.c, 1.14, 1.15
by Doctor Conrad
Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv21406
Modified Files:
vlv.c
Log Message:
Resolves: #314851
Summary: vlv: crash after repeated backend creation/deletion
Description: added a check code for the backend's existing.
Index: vlv.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/vlv.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- vlv.c 24 Sep 2007 18:27:15 -0000 1.14
+++ vlv.c 2 Oct 2007 23:21:31 -0000 1.15
@@ -76,6 +76,9 @@
struct vlvSearch* newVlvSearch= vlvSearch_new();
backend *be = inst->inst_be;
+ if (NULL == be) { /* backend is not associated */
+ return SLAPI_DSE_CALLBACK_ERROR;
+ }
vlvSearch_init(newVlvSearch, pb, entryBefore, inst);
/* vlvSearchList is modified; need Wlock */
PR_RWLock_Wlock(be->vlvSearchList_lock);
@@ -280,6 +283,9 @@
ldbm_instance *inst = (ldbm_instance*)arg;
backend *be= inst->inst_be;
+ if (NULL == be) { /* backend is not associated */
+ return SLAPI_DSE_CALLBACK_ERROR;
+ }
vlvSearch_init(newVlvSearch, pb, entryBefore, inst);
vlvSearch_addtolist(newVlvSearch, (struct vlvSearch **)&be->vlvSearchList);
return SLAPI_DSE_CALLBACK_OK;
16 years, 6 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd opshared.c, 1.8, 1.9
by Doctor Conrad
Author: nkinder
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv16047
Modified Files:
opshared.c
Log Message:
Resolves: 282911
Summary: Don't send result twice when searching against a non-existent suffix.
Index: opshared.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/opshared.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- opshared.c 10 Nov 2006 23:45:40 -0000 1.8
+++ opshared.c 2 Oct 2007 19:21:32 -0000 1.9
@@ -210,6 +210,7 @@
int iscritical = 0;
char * be_name = NULL;
int index = 0;
+ int sent_result = 0;
be_list[0] = NULL;
referral_list[0] = NULL;
@@ -548,6 +549,8 @@
int err;
case 1: /* backend successfully sent result to the client */
rc = SLAPI_FAIL_GENERAL;
+ /* Set a flag here so we don't return another result. */
+ sent_result = 1;
/* fall through */
case -1: /* an error occurred */
@@ -676,9 +679,12 @@
else if (flag_no_such_object)
{
/* there was at least 1 backend that was called to process
- * the operation and all backends returned NO SUCH OBJECTS
+ * the operation and all backends returned NO SUCH OBJECTS.
+ * Don't send the result if it's already been handled above.
*/
- slapi_send_ldap_result_from_pb(pb);
+ if (!sent_result) {
+ slapi_send_ldap_result_from_pb(pb);
+ }
}
else
{
16 years, 6 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd match.c, 1.5, 1.6 slap.h, 1.26, 1.27 slapi-plugin.h, 1.16, 1.17
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv8531/ldapserver/ldap/servers/slapd
Modified Files:
match.c slap.h slapi-plugin.h
Log Message:
Resolves: bug 249366
Bug Description: rhds71 - search filters returns too many entries on integer attributes value greater than 2 to the power of 31
Reviewed by: nkinder, nhosoi (Thanks!)
Fix Description: The way >= and <= searches are supposed to work in LDAP is that you are supposed to define an ORDERING matching rule for the attribute you want to use in the search filter. The way our code is written, most strings "just work" as a side effect of the way bdb sorts the keys by default - so you can do (uid>=jvedder) and get what you would expect, even though LDAP says this is illegal because the schema definition of the uid attribute does not have an ORDERING matching rule. And INTEGER worked with the old binary format for the same reason. The only attribute definitions we use with ORDERING are attributes that use Generalized Time syntax (e.g. createTimestamp, et. al.) and numSubordinates (which uses INTEGER, but this is a special case handled internally by the db code).
The way it works now is that the indexing code will honor the ORDERING matching rule specified in the schema definition. Or, if ORDERING is not specified, the user can use the nsMatchingRule index configuration. This will allow an existing customer that depends all integer syntax attributes (e.g. uidNumber) to allow range searches by default to enable range searches without editing the schema. The syntax definition for the attribute must also specify a compare function. This compare function will be used by the bdb bt_compare() function.
I also fixed a bug in the integer normalize code - a string of all zeros should normalize to a single "0". In all other cases, the leading zeros should be removed.
Platforms tested: RHEL5 x86_64
Flag Day: Yes. Integer indexes will need to be rebuilt (except for numsubordinates).
Doc impact: Yes - document slapi API additions
QA impact: Pay close attention to tests that use >= or <= search filters, both with and without index attributes. Also, pay close attention to greater/less than searches using i18n collations.
New Tests integrated into TET: Forthcoming
Index: match.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/match.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- match.c 10 Nov 2006 23:45:40 -0000 1.5
+++ match.c 2 Oct 2007 18:39:50 -0000 1.6
@@ -270,5 +270,26 @@
return(0);
}
+/*
+ See if a matching rule for this name or OID
+ is registered and is an ORDERING matching rule that applies
+ to the given syntax.
+*/
+int slapi_matchingrule_is_ordering(const char *oid_or_name, const char *syntax_oid)
+{
+ struct matchingRuleList *mrl=NULL;
+ for (mrl = g_get_global_mrl(); mrl != NULL; mrl = mrl->mrl_next) {
+ if (mrl->mr_entry->mr_name && !strcasecmp(oid_or_name, mrl->mr_entry->mr_name)) {
+ return (mrl->mr_entry->mr_name &&
+ PL_strcasestr(mrl->mr_entry->mr_name, "ordering") &&
+ !strcmp(mrl->mr_entry->mr_syntax, syntax_oid));
+ }
+ if (mrl->mr_entry->mr_oid && !strcmp(oid_or_name, mrl->mr_entry->mr_oid)) {
+ return (mrl->mr_entry->mr_name &&
+ PL_strcasestr(mrl->mr_entry->mr_name, "ordering") &&
+ !strcmp(mrl->mr_entry->mr_syntax, syntax_oid));
+ }
+ }
-
+ return 0;
+}
Index: slap.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/slap.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- slap.h 7 Sep 2007 19:08:45 -0000 1.26
+++ slap.h 2 Oct 2007 18:39:50 -0000 1.27
@@ -616,15 +616,6 @@
struct objclass *oc_next;
};
-typedef struct slapi_matchingRuleEntry {
- char *mr_oid;
- char *mr_oidalias;
- char *mr_name;
- char *mr_desc;
- char *mr_syntax;
- int mr_obsolete;
-} slapi_matchingRuleEntry;
-
struct matchingRuleList {
Slapi_MatchingRuleEntry *mr_entry;
struct matchingRuleList *mrl_next;
Index: slapi-plugin.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/slapi-plugin.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- slapi-plugin.h 30 Aug 2007 15:56:36 -0000 1.16
+++ slapi-plugin.h 2 Oct 2007 18:39:50 -0000 1.17
@@ -140,7 +140,6 @@
typedef struct slapi_value Slapi_Value;
typedef struct slapi_value_set Slapi_ValueSet;
typedef struct slapi_filter Slapi_Filter;
-typedef struct slapi_matchingRuleEntry Slapi_MatchingRuleEntry;
typedef struct backend Slapi_Backend;
typedef struct _guid_t Slapi_UniqueID;
typedef struct op Slapi_Operation;
@@ -645,6 +644,16 @@
#define SLAPI_BERVAL_EQ(L,R) ((L)->bv_len == (R)->bv_len && \
! memcmp ((L)->bv_val, (R)->bv_val, (L)->bv_len))
+typedef struct slapi_matchingRuleEntry {
+ char *mr_oid;
+ char *mr_oidalias;
+ char *mr_name;
+ char *mr_desc;
+ char *mr_syntax;
+ int mr_obsolete;
+} slapi_matchingRuleEntry;
+typedef struct slapi_matchingRuleEntry Slapi_MatchingRuleEntry;
+
Slapi_MatchingRuleEntry *slapi_matchingrule_new(void);
void slapi_matchingrule_free(Slapi_MatchingRuleEntry **mrEntry,
int freeMembers);
@@ -652,6 +661,7 @@
int slapi_matchingrule_set(Slapi_MatchingRuleEntry *mr, int arg, void *value);
int slapi_matchingrule_register(Slapi_MatchingRuleEntry *mrEntry);
int slapi_matchingrule_unregister(char *oid);
+int slapi_matchingrule_is_ordering(const char *oid_or_name, const char *syntax_oid);
/*
* access control
16 years, 6 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd/back-ldbm back-ldbm.h, 1.9, 1.10 dblayer.c, 1.21, 1.22 import-merge.c, 1.7, 1.8 ldbm_attr.c, 1.7, 1.8 proto-back-ldbm.h, 1.13, 1.14
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv8531/ldapserver/ldap/servers/slapd/back-ldbm
Modified Files:
back-ldbm.h dblayer.c import-merge.c ldbm_attr.c
proto-back-ldbm.h
Log Message:
Resolves: bug 249366
Bug Description: rhds71 - search filters returns too many entries on integer attributes value greater than 2 to the power of 31
Reviewed by: nkinder, nhosoi (Thanks!)
Fix Description: The way >= and <= searches are supposed to work in LDAP is that you are supposed to define an ORDERING matching rule for the attribute you want to use in the search filter. The way our code is written, most strings "just work" as a side effect of the way bdb sorts the keys by default - so you can do (uid>=jvedder) and get what you would expect, even though LDAP says this is illegal because the schema definition of the uid attribute does not have an ORDERING matching rule. And INTEGER worked with the old binary format for the same reason. The only attribute definitions we use with ORDERING are attributes that use Generalized Time syntax (e.g. createTimestamp, et. al.) and numSubordinates (which uses INTEGER, but this is a special case handled internally by the db code).
The way it works now is that the indexing code will honor the ORDERING matching rule specified in the schema definition. Or, if ORDERING is not specified, the user can use the nsMatchingRule index configuration. This will allow an existing customer that depends all integer syntax attributes (e.g. uidNumber) to allow range searches by default to enable range searches without editing the schema. The syntax definition for the attribute must also specify a compare function. This compare function will be used by the bdb bt_compare() function.
I also fixed a bug in the integer normalize code - a string of all zeros should normalize to a single "0". In all other cases, the leading zeros should be removed.
Platforms tested: RHEL5 x86_64
Flag Day: Yes. Integer indexes will need to be rebuilt (except for numsubordinates).
Doc impact: Yes - document slapi API additions
QA impact: Pay close attention to tests that use >= or <= search filters, both with and without index attributes. Also, pay close attention to greater/less than searches using i18n collations.
New Tests integrated into TET: Forthcoming
Index: back-ldbm.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/back-ldbm.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- back-ldbm.h 15 Mar 2007 21:34:32 -0000 1.9
+++ back-ldbm.h 2 Oct 2007 18:39:51 -0000 1.10
@@ -364,12 +364,22 @@
* yet. */
#define IS_INDEXED( a ) ( a & INDEX_ANY )
- void *ai_plugin;
+ void *ai_plugin; /* the syntax plugin for this attribute */
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 */
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) */
+ value_compare_fn_type ai_key_cmp_fn; /* function used to compare two index keys -
+ The function is the compare function provided by
+ ai_plugin - this function is used to order
+ the keys in the index so that we can use ORDERING
+ searches. In order for this function to be used,
+ the syntax plugin must define a compare function,
+ and either the attribute definition schema must
+ specify an ORDERING matching rule, or the index
+ configuration must define an ORDERING matching rule.
+ */
};
#define MAXDBCACHE 20
Index: dblayer.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/dblayer.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- dblayer.c 25 Sep 2007 22:03:19 -0000 1.21
+++ dblayer.c 2 Oct 2007 18:39:51 -0000 1.22
@@ -223,6 +223,33 @@
#define MEGABYTE (1024 * 1024)
#define GIGABYTE (1024 * MEGABYTE)
+
+/* This function compares two index keys. It is assumed
+ that the values are already normalized, since they should have
+ been when the index was created (by int_values2keys).
+
+ richm - actually, the current syntax compare functions
+ always normalize both arguments. We need to add an additional
+ syntax compare function that does not normalize or takes
+ an argument like value_cmp to specify to normalize or not.
+*/
+
+typedef int (*syntax_cmp_fn_type)(struct berval *, struct berval *);
+static int
+dblayer_bt_compare(DB *db, const DBT *dbt1, const DBT *dbt2)
+{
+ struct berval bv1, bv2;
+ value_compare_fn_type syntax_cmp_fn = (value_compare_fn_type)db->app_private;
+
+ bv1.bv_val = (char *)dbt1->data+1; /* remove leading '=' */
+ bv1.bv_len = (ber_len_t)dbt1->size-1;
+
+ bv2.bv_val = (char *)dbt2->data+1; /* remove leading '=' */
+ bv2.bv_len = (ber_len_t)dbt2->size-1;
+
+ return syntax_cmp_fn(&bv1, &bv2);
+}
+
/* this flag use if user remotely turned batching off */
#define FLUSH_REMOTEOFF -1
@@ -2594,7 +2621,7 @@
Success: 0
Failure: -1
*/
-int dblayer_open_file(backend *be, char* indexname, int open_flag, int index_flags, DB **ppDB)
+int dblayer_open_file(backend *be, char* indexname, int open_flag, struct attrinfo *ai, DB **ppDB)
{
struct ldbminfo *li = (struct ldbminfo *) be->be_database->plg_private;
ldbm_instance *inst = (ldbm_instance *) be->be_instance_info;
@@ -2682,7 +2709,7 @@
}
#endif
- if (idl_get_idl_new() && !(index_flags & INDEX_VLV)) {
+ if (idl_get_idl_new() && !(ai->ai_indexmask & INDEX_VLV)) {
return_value = dbp->set_flags(dbp, DB_DUP | DB_DUPSORT);
if (0 != return_value)
goto out;
@@ -2695,7 +2722,7 @@
goto out;
}
- if (index_flags & INDEX_VLV) {
+ if (ai->ai_indexmask & INDEX_VLV) {
/*
* Need index with record numbers for
* Virtual List View index
@@ -2703,6 +2730,24 @@
return_value = dbp->set_flags(dbp, DB_RECNUM);
if (0 != return_value)
goto out;
+ } else if (ai->ai_key_cmp_fn) { /* set in attr_index_config() */
+ /*
+ This is so that we can have ordered keys in the index, so that
+ greater than/less than searches work on indexed attrs. We had
+ to introduce this when we changed the integer key format from
+ a 32/64 bit value to a normalized string value. The default
+ bdb key cmp is based on length and lexicographic order, which
+ does not work with integer strings.
+
+ NOTE: If we ever need to use app_private for something else, we
+ will have to create some sort of data structure with different
+ fields for different uses. We will also need to have a new()
+ function that creates and allocates that structure, and a
+ destroy() function that destroys the structure, and make sure
+ to call it when the DB* is closed and/or freed.
+ */
+ dbp->app_private = (void *)ai->ai_key_cmp_fn;
+ dbp->set_bt_compare(dbp, dblayer_bt_compare);
}
/* The subname argument allows applications to have
@@ -2842,7 +2887,7 @@
* index file and stuff it in the attrinfo.
*/
return_value = dblayer_open_file(be, attribute_name, open_flags,
- a->ai_indexmask, &pDB);
+ a, &pDB);
if (0 == return_value) {
/* Opened it OK */
dblayer_handle *handle = (dblayer_handle *)
Index: import-merge.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/import-merge.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- import-merge.c 10 Nov 2006 23:45:39 -0000 1.7
+++ import-merge.c 2 Oct 2007 18:39:51 -0000 1.8
@@ -338,7 +338,7 @@
return 0;
}
-static int import_open_merge_input_files(backend *be, char *indexname,
+static int import_open_merge_input_files(backend *be, IndexInfo *index_info,
int passes, DB ***input_files, int *number_found, int *pass_number)
{
int i = 0;
@@ -354,16 +354,22 @@
}
for (i = 0; i < passes; i++) {
DB *pDB = NULL;
- char *filename = slapi_ch_smprintf("%s.%d", indexname, i+1);
+ char *filename = slapi_ch_smprintf("%s.%d", index_info->name, i+1);
if (NULL == filename) {
return -1;
}
if (vlv_isvlv(filename)) {
- ret = dblayer_open_file(be, filename, 0, INDEX_VLV, &pDB);
+ /* not sure why the file would be marked as a vlv index but
+ not the index configuration . . . but better make sure
+ the new code works with the old semantics */
+ int saved_mask = index_info->ai->ai_indexmask;
+ index_info->ai->ai_indexmask |= INDEX_VLV;
+ ret = dblayer_open_file(be, filename, 0, index_info->ai, &pDB);
+ index_info->ai->ai_indexmask = saved_mask;
} else {
- ret = dblayer_open_file(be, filename, 0, 0, &pDB);
+ ret = dblayer_open_file(be, filename, 0, index_info->ai, &pDB);
}
slapi_ch_free( (void**)&filename);
@@ -488,7 +494,7 @@
}
#endif
- ret = import_open_merge_input_files(be, worker->index_info->name,
+ ret = import_open_merge_input_files(be, worker->index_info,
passes, &input_files, &number_found, &pass_number);
if (0 != ret) {
import_log_notice(worker->job, "MERGE FAIL 10");
@@ -496,7 +502,7 @@
}
ret = dblayer_open_file(be, worker->index_info->name, 1,
- vlv_index ? INDEX_VLV : 0, &output_file);
+ worker->index_info->ai, &output_file);
if (0 != ret) {
import_log_notice(worker->job, "Failed to open output file for "
"index %s in merge", worker->index_info->name);
Index: ldbm_attr.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/ldbm_attr.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ldbm_attr.c 10 Nov 2006 23:45:39 -0000 1.7
+++ ldbm_attr.c 2 Oct 2007 18:39:51 -0000 1.8
@@ -57,6 +57,7 @@
p->ai_dblayer= NULL;
p->ai_dblayer_count = 0;
p->ai_idl= NULL;
+ p->ai_key_cmp_fn = NULL;
return p;
}
@@ -66,6 +67,7 @@
if(pp!=NULL && *pp!=NULL)
{
idl_release_private(*pp);
+ (*pp)->ai_key_cmp_fn = NULL;
slapi_ch_free((void**)&((*pp)->ai_type));
slapi_ch_free((void**)(*pp)->ai_index_rules);
slapi_ch_free((void**)pp);
@@ -179,9 +181,12 @@
}
}
for ( i = 0; attrs[i] != NULL; i++ ) {
+ int need_compare_fn = 0;
+ char *attrsyntax_oid = NULL;
a = attrinfo_new();
a->ai_type = slapi_attr_basetype( attrs[i], NULL, 0 );
slapi_attr_type2plugin( a->ai_type, &a->ai_plugin );
+ attrsyntax_oid = slapi_ch_strdup(plugin_syntax2oid(a->ai_plugin));
if ( argc == 1 ) {
a->ai_indexmask = (INDEX_PRESENCE | INDEX_EQUALITY |
INDEX_APPROX | INDEX_SUB);
@@ -245,10 +250,12 @@
preamble, officialOID, index_rules[j] );
slapi_ch_free((void**)&preamble);
}
- } else {
+ } else if (!slapi_matchingrule_is_ordering(index_rules[j], attrsyntax_oid)) {
LDAPDebug (LDAP_DEBUG_ANY, "%s: line %d: "
- "unknown index rule \"%s\" (ignored)\n",
+ "unknown or invalid matching rule \"%s\" in index configuration (ignored)\n",
fname, lineno, index_rules[j] );
+ } else { /* assume builtin and use compare fn provided by syntax plugin */
+ need_compare_fn = 1;
}
{/* It would improve speed to save the indexer, for future use.
But, for simplicity, we destroy it now: */
@@ -269,13 +276,8 @@
}
}
}
-#if 0 /* seems to not matter -- INDEX_FROMINIT is checked nowhere else */
- if ( init ) {
- a->ai_indexmask |= INDEX_FROMINIT;
- a->ai_indexmask &= ~INDEX_OFFLINE;
- }
-#endif
+ slapi_ch_free_string(&attrsyntax_oid);
/* initialize the IDL code's private data */
return_value = idl_init_private(be, a);
if (0 != return_value) {
@@ -285,6 +287,26 @@
exit( 1 );
}
+ /* if user didn't specify an ordering rule in the index config,
+ see if the schema def for the attr defines one */
+ if (!need_compare_fn) {
+ asyntaxinfo *asi = attr_syntax_get_by_name( a->ai_type );
+ if (asi && asi->asi_mr_ordering) {
+ need_compare_fn = 1;
+ }
+ attr_syntax_return( asi );
+ }
+
+ if (need_compare_fn) {
+ int rc = plugin_call_syntax_get_compare_fn( a->ai_plugin, &a->ai_key_cmp_fn );
+ if (rc != LDAP_SUCCESS) {
+ LDAPDebug(LDAP_DEBUG_ANY,
+ "The attribute [%s] does not have a valid ORDERING matching rule\n",
+ a->ai_type, 0, 0);
+ a->ai_key_cmp_fn = NULL;
+ }
+ }
+
if ( avl_insert( &inst->inst_attrs, a, ainfo_cmp, ainfo_dup ) != 0 ) {
/* duplicate - existing version updated */
attrinfo_delete(&a);
Index: proto-back-ldbm.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- proto-back-ldbm.h 25 Sep 2007 22:03:19 -0000 1.13
+++ proto-back-ldbm.h 2 Oct 2007 18:39:51 -0000 1.14
@@ -141,7 +141,7 @@
int dblayer_database_size(struct ldbminfo *li, unsigned int *size);
int dblayer_terminate(struct ldbminfo *li);
int dblayer_close_indexes(backend *be);
-int dblayer_open_file(backend *be, char* indexname, int create, int index_flags, DB **ppDB);
+int dblayer_open_file(backend *be, char* indexname, int create, struct attrinfo *ai, DB **ppDB);
int dblayer_close_file(DB *db);
void dblayer_sys_pages(size_t *pagesize, size_t *pages, size_t *procpages, size_t *availpages);
int dblayer_is_cachesize_sane(size_t *cachesize);
16 years, 6 months
[Fedora-directory-commits] ldapserver/ldap/servers/plugins/syntaxes cis.c, 1.5, 1.6 int.c, 1.6, 1.7 value.c, 1.7, 1.8
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/syntaxes
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv8531/ldapserver/ldap/servers/plugins/syntaxes
Modified Files:
cis.c int.c value.c
Log Message:
Resolves: bug 249366
Bug Description: rhds71 - search filters returns too many entries on integer attributes value greater than 2 to the power of 31
Reviewed by: nkinder, nhosoi (Thanks!)
Fix Description: The way >= and <= searches are supposed to work in LDAP is that you are supposed to define an ORDERING matching rule for the attribute you want to use in the search filter. The way our code is written, most strings "just work" as a side effect of the way bdb sorts the keys by default - so you can do (uid>=jvedder) and get what you would expect, even though LDAP says this is illegal because the schema definition of the uid attribute does not have an ORDERING matching rule. And INTEGER worked with the old binary format for the same reason. The only attribute definitions we use with ORDERING are attributes that use Generalized Time syntax (e.g. createTimestamp, et. al.) and numSubordinates (which uses INTEGER, but this is a special case handled internally by the db code).
The way it works now is that the indexing code will honor the ORDERING matching rule specified in the schema definition. Or, if ORDERING is not specified, the user can use the nsMatchingRule index configuration. This will allow an existing customer that depends all integer syntax attributes (e.g. uidNumber) to allow range searches by default to enable range searches without editing the schema. The syntax definition for the attribute must also specify a compare function. This compare function will be used by the bdb bt_compare() function.
I also fixed a bug in the integer normalize code - a string of all zeros should normalize to a single "0". In all other cases, the leading zeros should be removed.
Platforms tested: RHEL5 x86_64
Flag Day: Yes. Integer indexes will need to be rebuilt (except for numsubordinates).
Doc impact: Yes - document slapi API additions
QA impact: Pay close attention to tests that use >= or <= search filters, both with and without index attributes. Also, pay close attention to greater/less than searches using i18n collations.
New Tests integrated into TET: Forthcoming
Index: cis.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/syntaxes/cis.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- cis.c 10 Nov 2006 23:45:31 -0000 1.5
+++ cis.c 2 Oct 2007 18:39:50 -0000 1.6
@@ -84,6 +84,19 @@
static char *time_names[] = { "GeneralizedTime", "time",
GENERALIZEDTIME_SYNTAX_OID, 0 };
+#define GENERALIZEDTIMEMATCH_OID "2.5.13.27"
+#define GENERALIZEDTIMEORDERINGMATCH_OID "2.5.13.28"
+static Slapi_MatchingRuleEntry
+generalizedTimeMatch = { GENERALIZEDTIMEMATCH_OID, NULL /* no alias? */,
+ "generalizedTimeMatch", "The rule evaluates to TRUE if and only if the attribute value represents the same universal coordinated time as the assertion value.",
+ GENERALIZEDTIME_SYNTAX_OID, 0 /* not obsolete */ };
+
+static Slapi_MatchingRuleEntry
+generalizedTimeOrderingMatch = { GENERALIZEDTIMEORDERINGMATCH_OID, NULL /* no alias? */,
+ "generalizedTimeOrderingMatch", "The rule evaluates to TRUE if and only if the attribute value represents a universal coordinated time that is earlier than the universal coordinated time represented by the assertion value.",
+ GENERALIZEDTIME_SYNTAX_OID, 0 /* not obsolete */ };
+
+
static char *country_names[] = { "Country String",
COUNTRYSTRING_SYNTAX_OID, 0};
@@ -223,6 +236,9 @@
LDAPDebug( LDAP_DEBUG_PLUGIN, "=> time_init\n", 0, 0, 0 );
rc = register_cis_like_plugin( pb, &time_pdesc, time_names,
GENERALIZEDTIME_SYNTAX_OID );
+ /* also register this plugin for matching rules */
+ rc |= slapi_matchingrule_register(&generalizedTimeMatch);
+ rc |= slapi_matchingrule_register(&generalizedTimeOrderingMatch);
LDAPDebug( LDAP_DEBUG_PLUGIN, "<= time_init %d\n", rc, 0, 0 );
return( rc );
}
Index: int.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/syntaxes/int.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- int.c 19 Sep 2007 19:32:03 -0000 1.6
+++ int.c 2 Oct 2007 18:39:50 -0000 1.7
@@ -58,9 +58,23 @@
/* the first name is the official one from RFC 2252 */
static char *names[] = { "INTEGER", "int", INTEGER_SYNTAX_OID, 0 };
+#define INTEGERMATCH_OID "2.5.13.14"
+#define INTEGERORDERINGMATCH_OID "2.5.13.15"
+
static Slapi_PluginDesc pdesc = { "int-syntax", PLUGIN_MAGIC_VENDOR_STR,
PRODUCTTEXT, "integer attribute syntax plugin" };
+static Slapi_MatchingRuleEntry
+integerMatch = { INTEGERMATCH_OID, NULL /* no alias? */,
+ "integerMatch", "The rule evaluates to TRUE if and only if the attribute value and the assertion value are the same integer value.",
+ INTEGER_SYNTAX_OID, 0 /* not obsolete */ };
+
+static Slapi_MatchingRuleEntry
+integerOrderingMatch = { INTEGERORDERINGMATCH_OID, NULL /* no alias? */,
+ "integerOrderingMatch", "The rule evaluates to TRUE if and only if the integer value of the attribute value is less than the integer value of the assertion value.",
+ INTEGER_SYNTAX_OID, 0 /* not obsolete */ };
+
+
int
int_init( Slapi_PBlock *pb )
{
@@ -88,6 +102,10 @@
rc |= slapi_pblock_set( pb, SLAPI_PLUGIN_SYNTAX_COMPARE,
(void *) int_compare );
+ /* also register this plugin for matching rules */
+ rc |= slapi_matchingrule_register(&integerMatch);
+ rc |= slapi_matchingrule_register(&integerOrderingMatch);
+
LDAPDebug( LDAP_DEBUG_PLUGIN, "<= int_init %d\n", rc, 0, 0 );
return( rc );
}
Index: value.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/syntaxes/value.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- value.c 19 Sep 2007 19:32:03 -0000 1.7
+++ value.c 2 Oct 2007 18:39:50 -0000 1.8
@@ -117,21 +117,25 @@
/* have to do this after trimming spaces */
if (syntax & SYNTAX_INT) {
int foundsign = 0;
+ int foundzero = 0;
+
if (*s == '-') {
foundsign = 1;
LDAP_UTF8INC(s);
}
while (*s && (*s == '0')) {
+ foundzero = 1;
LDAP_UTF8INC(s);
}
- /* if there is a hyphen, make sure it is just to the left
- of the first significant (i.e. non-zero) digit e.g.
- convert -00000001 to -1 */
- if (foundsign && (s > d)) {
- *d = '-';
- d++;
+ if (foundzero && !*s) { /* value is all zeros */
+ *d++ = '0'; /* set value to a single zero */
+ } else if (foundsign && (s > d)) {
+ /* if there is a hyphen, make sure it is just to the left
+ of the first significant (i.e. non-zero) digit e.g.
+ convert -00000001 to -1 */
+ *d++ = '-';
}
/* s should now point at the first significant digit/char */
}
16 years, 6 months