[Fedora-directory-commits] ldapserver/ldap/servers/slapd libslapd.def, 1.11, 1.11.2.1 slapi-private.h, 1.8, 1.8.2.1
by Doctor Conrad
Author: nkinder
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv15039
Modified Files:
Tag: Directory71RtmBranch
libslapd.def slapi-private.h
Log Message:
164843, 166012, 165827 - Indexing code now deals with attribute subtypes correctly.
Index: libslapd.def
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/libslapd.def,v
retrieving revision 1.11
retrieving revision 1.11.2.1
diff -u -r1.11 -r1.11.2.1
--- libslapd.def 19 Apr 2005 22:07:36 -0000 1.11
+++ libslapd.def 26 Aug 2005 15:44:35 -0000 1.11.2.1
@@ -1056,6 +1056,7 @@
slapi_entry_delete_values_sv @1058
slapi_entry_attr_replace_sv @1059
+ valuearray_find @1060
valuearray_free @1061
slapd_Client_auth @1062
slapi_rand_r @1063
Index: slapi-private.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/slapi-private.h,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -u -r1.8 -r1.8.2.1
--- slapi-private.h 19 Apr 2005 22:07:37 -0000 1.8
+++ slapi-private.h 26 Aug 2005 15:44:35 -0000 1.8.2.1
@@ -778,6 +778,7 @@
void valuearray_add_value_fast(Slapi_Value ***vals, Slapi_Value *addval, int nvals, int *maxvals, int exact, int passin);
void valuearray_add_valuearray( Slapi_Value ***vals, Slapi_Value **addvals, PRUint32 flags );
void valuearray_add_valuearray_fast( Slapi_Value ***vals, Slapi_Value **addvals, int nvals, int naddvals, int *maxvals, int exact, int passin );
+int valuearray_find(const Slapi_Attr *a, Slapi_Value **va, const Slapi_Value *v);
/******************************************************************************
18 years, 7 months
[Fedora-directory-commits] ldapserver/ldap/servers/plugins/uiduniq uid.c, 1.6, 1.6.2.1
by Doctor Conrad
Author: nkinder
Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/uiduniq
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv11833
Modified Files:
Tag: Directory71RtmBranch
uid.c
Log Message:
164836 - Attribute uniqueness needs to check if the target DN for the incoming operation applies to a subtree before searchnig for a conflict within it.
Index: uid.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/uiduniq/uid.c,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -u -r1.6 -r1.6.2.1
--- uid.c 19 Apr 2005 22:07:35 -0000 1.6
+++ uid.c 25 Aug 2005 23:05:20 -0000 1.6.2.1
@@ -383,8 +383,14 @@
*/
for(;argc > 0;argc--,argv++)
{
- result = search(*argv, attrName, attr, values, dn);
- if (result) break;
+ /*
+ * The DN should already be normalized, so we don't have to
+ * worry about that here.
+ */
+ if (slapi_dn_issuffix(dn, *argv)) {
+ result = search(*argv, attrName, attr, values, dn);
+ if (result) break;
+ }
}
return result;
}
18 years, 7 months
[Fedora-directory-commits] ldapserver/ldap/servers/plugins/views views.c, 1.5, 1.5.2.1
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/views
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv10467
Modified Files:
Tag: Directory71RtmBranch
views.c
Log Message:
Bug(s) fixed: 165640
Bug Description: Directory Server crashes when deleting a view
Branch: Directory71RtmBranch
Reviewed by: Nathan (Thanks!)
Fix Description: Needed to pass in the _address_ of theCache.pCacheViews to views_cache_add_ll_entry. Yet another lesson in using the compiler to catch type errors rather than casting to void*.
Platforms tested: RHEL3
Flag Day: no
Doc impact: no
QA impact: should be covered by regular nightly and manual testing
New Tests integrated into TET: none
Index: views.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/views/views.c,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- views.c 19 Apr 2005 22:07:36 -0000 1.5
+++ views.c 25 Aug 2005 22:38:40 -0000 1.5.2.1
@@ -1529,7 +1529,7 @@
theView->parentid = 0;
/* add view to the cache */
- views_cache_add_ll_entry((void**)theCache.pCacheViews, (void *)theView);
+ views_cache_add_ll_entry((void**)&theCache.pCacheViews, (void *)theView);
views_cache_discover_parent(theView);
if(theView->pParent)
18 years, 7 months
[Fedora-directory-commits] ldapserver/ldap/servers/plugins/uiduniq 7bit.c, 1.5, 1.5.2.1
by Doctor Conrad
Author: rmeggins
Update of /cvs/dirsec/ldapserver/ldap/servers/plugins/uiduniq
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv9201
Modified Files:
Tag: Directory71RtmBranch
7bit.c
Log Message:
Bug(s) fixed: 165600
Bug Description: Adding multiple attributes using a single ldapmodify crashes ns-slapd
Branch: Directory71RtmBranch
Reviewed by: Nathan (Thanks!)
Fix Description: In C, the array '[]' dereference operator takes precedence over the '*' deref operator. In this case, I needed to put parentheses around the pointer dereference to avoid having array dereferenced first. modary is a pointer to an array, not an array, so I can't dereference it with the array operator until I first dereference the pointer.
Platforms tested: RHEL3
Flag Day: no
Doc impact: no
QA impact: should be covered by regular nightly and manual testing
New Tests integrated into TET: none
Index: 7bit.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/plugins/uiduniq/7bit.c,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- 7bit.c 19 Apr 2005 22:07:35 -0000 1.5
+++ 7bit.c 25 Aug 2005 21:49:47 -0000 1.5.2.1
@@ -344,7 +344,7 @@
*modary = (LDAPMod **)slapi_ch_malloc(*capacity * sizeof(LDAPMod *));
}
}
- *modary[*nmods] = toadd;
+ (*modary)[*nmods] = toadd;
(*nmods)++;
}
18 years, 7 months
[Fedora-directory-commits] ldapserver/ldap/admin/src/scripts template-db2index.pl, 1.4, 1.4.2.1
by Doctor Conrad
Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/admin/src/scripts
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv8521
Modified Files:
Tag: Directory71RtmBranch
template-db2index.pl
Log Message:
[160003] db2index.pl cannot find libldap50.so if only certain parameters are used
In the perl script db2index.pl, before executing any ldap client command line
tools, should have chdir to the <dsroot>/shared/bin, where the rpath is set
from.
Index: template-db2index.pl
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/template-db2index.pl,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- template-db2index.pl 19 Apr 2005 22:07:00 -0000 1.4
+++ template-db2index.pl 25 Aug 2005 21:20:03 -0000 1.4.2.1
@@ -40,21 +40,21 @@
#
sub usage {
- print(STDERR "Usage: $0 [-v] -D rootdn { -w password | -w - | -j filename } \n");
- print(STDERR " -n instance [-t attributeName[:indextypes[:matchingrules]]]\n");
- print(STDERR " Opts: -D rootdn - Directory Manager\n");
- print(STDERR " : -w password - Directory Manager's password\n");
- print(STDERR " : -w - - Prompt for Directory Manager's password\n");
- print(STDERR " : -j filename - Read Directory Manager's password from file\n");
- print(STDERR " : -n instance - instance to be indexed\n");
- print(STDERR " : -t attributeName[:indextypes[:matchingrules]]\n");
- print(STDERR " - attribute: name of the attribute to be indexed\n");
- print(STDERR " If omitted, all the indexes defined \n");
- print(STDERR " for that instance are generated.\n");
- print(STDERR " - indextypes: comma separated index types\n");
- print(STDERR " - matchingrules: comma separated matrules\n");
- print(STDERR " Example: -t foo:eq,pres\n");
- print(STDERR " : -v - version\n");
+ print(STDERR "Usage: $0 [-v] -D rootdn { -w password | -w - | -j filename } \n");
+ print(STDERR " -n instance [-t attributeName[:indextypes[:matchingrules]]]\n");
+ print(STDERR " Opts: -D rootdn - Directory Manager\n");
+ print(STDERR " : -w password - Directory Manager's password\n");
+ print(STDERR " : -w - - Prompt for Directory Manager's password\n");
+ print(STDERR " : -j filename - Read Directory Manager's password from file\n");
+ print(STDERR " : -n instance - instance to be indexed\n");
+ print(STDERR " : -t attributeName[:indextypes[:matchingrules]]\n");
+ print(STDERR " - attribute: name of the attribute to be indexed\n");
+ print(STDERR " If omitted, all the indexes defined \n");
+ print(STDERR " for that instance are generated.\n");
+ print(STDERR " - indextypes: comma separated index types\n");
+ print(STDERR " - matchingrules: comma separated matrules\n");
+ print(STDERR " Example: -t foo:eq,pres\n");
+ print(STDERR " : -v - verbose\n");
}
$instance = "";
@@ -71,81 +71,81 @@
$i = 0;
while ($i <= $#ARGV)
{
- if ("$ARGV[$i]" eq "-n")
- {
- # instance
- $i++; $instance = $ARGV[$i];
- }
- elsif ("$ARGV[$i]" eq "-D")
- {
- # Directory Manager
- $i++; $rootdn = $ARGV[$i];
- }
- elsif ("$ARGV[$i]" eq "-w")
- {
- # Directory Manager's password
- $i++; $passwd = $ARGV[$i];
- }
- elsif ("$ARGV[$i]" eq "-j")
- {
- # Read Directory Manager's password from a file
- $i++; $passwdfile = $ARGV[$i];
- }
- elsif ("$ARGV[$i]" eq "-t")
- {
- # Attribute to index
- $i++; $attribute_arg = $ARGV[$i];
- }
- elsif ("$ARGV[$i]" eq "-T")
- {
- # Vlvattribute to index
- $i++; $vlvattribute_arg = $ARGV[$i];
- }
- elsif ("$ARGV[$i]" eq "-v")
- {
- # verbose
- $verbose = 1;
- }
- else
- {
- &usage; exit(1);
- }
- $i++;
+ if ("$ARGV[$i]" eq "-n")
+ {
+ # instance
+ $i++; $instance = $ARGV[$i];
+ }
+ elsif ("$ARGV[$i]" eq "-D")
+ {
+ # Directory Manager
+ $i++; $rootdn = $ARGV[$i];
+ }
+ elsif ("$ARGV[$i]" eq "-w")
+ {
+ # Directory Manager's password
+ $i++; $passwd = $ARGV[$i];
+ }
+ elsif ("$ARGV[$i]" eq "-j")
+ {
+ # Read Directory Manager's password from a file
+ $i++; $passwdfile = $ARGV[$i];
+ }
+ elsif ("$ARGV[$i]" eq "-t")
+ {
+ # Attribute to index
+ $i++; $attribute_arg = $ARGV[$i];
+ }
+ elsif ("$ARGV[$i]" eq "-T")
+ {
+ # Vlvattribute to index
+ $i++; $vlvattribute_arg = $ARGV[$i];
+ }
+ elsif ("$ARGV[$i]" eq "-v")
+ {
+ # verbose
+ $verbose = 1;
+ }
+ else
+ {
+ &usage; exit(1);
+ }
+ $i++;
}
if ($passwdfile ne ""){
# Open file and get the password
- unless (open (RPASS, $passwdfile)) {
- die "Error, cannot open password file $passwdfile\n";
- }
- $passwd = <RPASS>;
- chomp($passwd);
- close(RPASS);
+ unless (open (RPASS, $passwdfile)) {
+ die "Error, cannot open password file $passwdfile\n";
+ }
+ $passwd = <RPASS>;
+ chomp($passwd);
+ close(RPASS);
} elsif ($passwd eq "-"){
# Read the password from terminal
- die "The '-w -' option requires an extension library (Term::ReadKey) which is not\n",
- "part of the standard perl distribution. If you want to use it, you must\n",
- "download and install the module. You can find it at\n",
- "http://www.perl.com/CPAN/CPAN.html\n";
+ die "The '-w -' option requires an extension library (Term::ReadKey) which is not\n",
+ "part of the standard perl distribution. If you want to use it, you must\n",
+ "download and install the module. You can find it at\n",
+ "http://www.perl.com/CPAN/CPAN.html\n";
# Remove the previous line and uncomment the following 6 lines once you have installed Term::ReadKey module.
# use Term::ReadKey;
-# print "Bind Password: ";
-# ReadMode('noecho');
-# $passwd = ReadLine(0);
-# chomp($passwd);
-# ReadMode('normal');
+# print "Bind Password: ";
+# ReadMode('noecho');
+# $passwd = ReadLine(0);
+# chomp($passwd);
+# ReadMode('normal');
}
if ( $rootdn eq "" || $passwd eq "" )
{
- &usage;
- exit(1);
+ &usage;
+ exit(1);
}
$vstr = "";
if ($verbose != 0)
{
- $vstr = "-v";
+ $vstr = "-v";
}
($s, $m, $h, $dy, $mn, $yr, $wdy, $ydy, $r) = localtime(time);
@@ -154,74 +154,72 @@
if ( $instance eq "" )
{
- &usage;
- exit(1);
+ &usage;
+ exit(1);
}
-else
+
+# No attribute name has been specified: let's get them from the configuration
+$attribute="";
+$indexes_list="";
+$vlvattribute="";
+$vlvindexes_list="";
+chdir("$dsroot{{SEP}}shared{{SEP}}bin");
+if ( $attribute_arg eq "" && $vlvattribute_arg eq "" )
{
- # No attribute name has been specified: let's get them from the configuration
- $attribute="";
- $indexes_list="";
- $vlvattribute="";
- $vlvindexes_list="";
- if ( $attribute_arg eq "" && $vlvattribute_arg eq "" )
- {
- # Get the list of indexes from the entry
- $indexes_list="$dsroot{{SEP}}shared{{SEP}}bin{{SEP}}ldapsearch $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -s one " .
- "-b \"cn=index,cn=\"$instance\", cn=ldbm database,cn=plugins,cn=config\" \"(&(objectclass=*)(nsSystemIndex=false))\" cn";
-
- # build the values of the attribute nsIndexAttribute
- open(LDAP1, "$indexes_list |");
- while (<LDAP1>) {
- s/\n //g;
- if (/^cn: (.*)\n/) {
- $IndexAttribute="nsIndexAttribute";
- $attribute="$attribute$IndexAttribute: $1\n";
- }
- }
- close(LDAP1);
- if ( $attribute eq "" )
- {
- # No attribute to index, just exit
- exit(0);
+ # Get the list of indexes from the entry
+ $indexes_list="$dsroot{{SEP}}shared{{SEP}}bin{{SEP}}ldapsearch $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -s one " .
+ "-b \"cn=index,cn=\"$instance\", cn=ldbm database,cn=plugins,cn=config\" \"(&(objectclass=*)(nsSystemIndex=false))\" cn";
+
+ # build the values of the attribute nsIndexAttribute
+ open(LDAP1, "$indexes_list |");
+ while (<LDAP1>) {
+ s/\n //g;
+ if (/^cn: (.*)\n/) {
+ $IndexAttribute="nsIndexAttribute";
+ $attribute="$attribute$IndexAttribute: $1\n";
}
+ }
+ close(LDAP1);
+ if ( $attribute eq "" )
+ {
+ # No attribute to index, just exit
+ exit(0);
+ }
+
+ # Get the list of indexes from the entry
+ $vlvindexes_list="$dsroot{{SEP}}shared{{SEP}}bin{{SEP}}ldapsearch $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -s sub -b \"cn=\"$instance\", cn=ldbm database,cn=plugins,cn=config\" \"objectclass=vlvIndex\" cn";
- # Get the list of indexes from the entry
- $vlvindexes_list="$dsroot{{SEP}}shared{{SEP}}bin{{SEP}}ldapsearch $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -s sub -b \"cn=\"$instance\", cn=ldbm database,cn=plugins,cn=config\" \"objectclass=vlvIndex\" cn";
-
- # build the values of the attribute nsIndexVlvAttribute
- open(LDAP1, "$vlvindexes_list |");
- while (<LDAP1>) {
- s/\n //g;
- if (/^cn: (.*)\n/) {
- $vlvIndexAttribute="nsIndexVlvAttribute";
- $vlvattribute="$vlvattribute$vlvIndexAttribute: $1\n";
- }
+ # build the values of the attribute nsIndexVlvAttribute
+ open(LDAP1, "$vlvindexes_list |");
+ while (<LDAP1>) {
+ s/\n //g;
+ if (/^cn: (.*)\n/) {
+ $vlvIndexAttribute="nsIndexVlvAttribute";
+ $vlvattribute="$vlvattribute$vlvIndexAttribute: $1\n";
}
- close(LDAP1);
}
- else
+ close(LDAP1);
+}
+else
+{
+ if ( $attribute_arg ne "" )
{
- if ( $attribute_arg ne "" )
- {
- $attribute="nsIndexAttribute: $attribute_arg\n";
- }
- if ( $vlvattribute_arg ne "" )
- {
- $vlvattribute="nsIndexVlvAttribute: $vlvattribute_arg\n";
- }
+ $attribute="nsIndexAttribute: $attribute_arg\n";
+ }
+ if ( $vlvattribute_arg ne "" )
+ {
+ $vlvattribute="nsIndexVlvAttribute: $vlvattribute_arg\n";
}
-
- # Build the task entry to add
-
- $dn = "dn: cn=$taskname, cn=index, cn=tasks, cn=config\n";
- $misc = "changetype: add\nobjectclass: top\nobjectclass: extensibleObject\n";
- $cn = "cn: $taskname\n";
- $nsinstance = "nsInstance: ${instance}\n";
-
- $entry = "${dn}${misc}${cn}${nsinstance}${attribute}${vlvattribute}";
}
-chdir("$dsroot{{SEP}}shared{{SEP}}bin");
+
+# Build the task entry to add
+
+$dn = "dn: cn=$taskname, cn=index, cn=tasks, cn=config\n";
+$misc = "changetype: add\nobjectclass: top\nobjectclass: extensibleObject\n";
+$cn = "cn: $taskname\n";
+$nsinstance = "nsInstance: ${instance}\n";
+
+$entry = "${dn}${misc}${cn}${nsinstance}${attribute}${vlvattribute}";
open(FOO, "| $dsroot{{SEP}}shared{{SEP}}bin{{SEP}}ldapmodify $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -a" );
print(FOO "$entry");
close(FOO);
18 years, 7 months
[Fedora-directory-commits] ldapserver/ldap/admin/src/scripts template-db2index.pl, 1.4, 1.5
by Doctor Conrad
Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/admin/src/scripts
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv8477
Modified Files:
template-db2index.pl
Log Message:
[160003] db2index.pl cannot find libldap50.so if only certain parameters are used
In the perl script db2index.pl, before executing any ldap client command line
tools, should have chdir to the <dsroot>/shared/bin, where the rpath is set
from.
Index: template-db2index.pl
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/admin/src/scripts/template-db2index.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- template-db2index.pl 19 Apr 2005 22:07:00 -0000 1.4
+++ template-db2index.pl 25 Aug 2005 21:17:48 -0000 1.5
@@ -40,21 +40,21 @@
#
sub usage {
- print(STDERR "Usage: $0 [-v] -D rootdn { -w password | -w - | -j filename } \n");
- print(STDERR " -n instance [-t attributeName[:indextypes[:matchingrules]]]\n");
- print(STDERR " Opts: -D rootdn - Directory Manager\n");
- print(STDERR " : -w password - Directory Manager's password\n");
- print(STDERR " : -w - - Prompt for Directory Manager's password\n");
- print(STDERR " : -j filename - Read Directory Manager's password from file\n");
- print(STDERR " : -n instance - instance to be indexed\n");
- print(STDERR " : -t attributeName[:indextypes[:matchingrules]]\n");
- print(STDERR " - attribute: name of the attribute to be indexed\n");
- print(STDERR " If omitted, all the indexes defined \n");
- print(STDERR " for that instance are generated.\n");
- print(STDERR " - indextypes: comma separated index types\n");
- print(STDERR " - matchingrules: comma separated matrules\n");
- print(STDERR " Example: -t foo:eq,pres\n");
- print(STDERR " : -v - version\n");
+ print(STDERR "Usage: $0 [-v] -D rootdn { -w password | -w - | -j filename } \n");
+ print(STDERR " -n instance [-t attributeName[:indextypes[:matchingrules]]]\n");
+ print(STDERR " Opts: -D rootdn - Directory Manager\n");
+ print(STDERR " : -w password - Directory Manager's password\n");
+ print(STDERR " : -w - - Prompt for Directory Manager's password\n");
+ print(STDERR " : -j filename - Read Directory Manager's password from file\n");
+ print(STDERR " : -n instance - instance to be indexed\n");
+ print(STDERR " : -t attributeName[:indextypes[:matchingrules]]\n");
+ print(STDERR " - attribute: name of the attribute to be indexed\n");
+ print(STDERR " If omitted, all the indexes defined \n");
+ print(STDERR " for that instance are generated.\n");
+ print(STDERR " - indextypes: comma separated index types\n");
+ print(STDERR " - matchingrules: comma separated matrules\n");
+ print(STDERR " Example: -t foo:eq,pres\n");
+ print(STDERR " : -v - verbose\n");
}
$instance = "";
@@ -71,81 +71,81 @@
$i = 0;
while ($i <= $#ARGV)
{
- if ("$ARGV[$i]" eq "-n")
- {
- # instance
- $i++; $instance = $ARGV[$i];
- }
- elsif ("$ARGV[$i]" eq "-D")
- {
- # Directory Manager
- $i++; $rootdn = $ARGV[$i];
- }
- elsif ("$ARGV[$i]" eq "-w")
- {
- # Directory Manager's password
- $i++; $passwd = $ARGV[$i];
- }
- elsif ("$ARGV[$i]" eq "-j")
- {
- # Read Directory Manager's password from a file
- $i++; $passwdfile = $ARGV[$i];
- }
- elsif ("$ARGV[$i]" eq "-t")
- {
- # Attribute to index
- $i++; $attribute_arg = $ARGV[$i];
- }
- elsif ("$ARGV[$i]" eq "-T")
- {
- # Vlvattribute to index
- $i++; $vlvattribute_arg = $ARGV[$i];
- }
- elsif ("$ARGV[$i]" eq "-v")
- {
- # verbose
- $verbose = 1;
- }
- else
- {
- &usage; exit(1);
- }
- $i++;
+ if ("$ARGV[$i]" eq "-n")
+ {
+ # instance
+ $i++; $instance = $ARGV[$i];
+ }
+ elsif ("$ARGV[$i]" eq "-D")
+ {
+ # Directory Manager
+ $i++; $rootdn = $ARGV[$i];
+ }
+ elsif ("$ARGV[$i]" eq "-w")
+ {
+ # Directory Manager's password
+ $i++; $passwd = $ARGV[$i];
+ }
+ elsif ("$ARGV[$i]" eq "-j")
+ {
+ # Read Directory Manager's password from a file
+ $i++; $passwdfile = $ARGV[$i];
+ }
+ elsif ("$ARGV[$i]" eq "-t")
+ {
+ # Attribute to index
+ $i++; $attribute_arg = $ARGV[$i];
+ }
+ elsif ("$ARGV[$i]" eq "-T")
+ {
+ # Vlvattribute to index
+ $i++; $vlvattribute_arg = $ARGV[$i];
+ }
+ elsif ("$ARGV[$i]" eq "-v")
+ {
+ # verbose
+ $verbose = 1;
+ }
+ else
+ {
+ &usage; exit(1);
+ }
+ $i++;
}
if ($passwdfile ne ""){
# Open file and get the password
- unless (open (RPASS, $passwdfile)) {
- die "Error, cannot open password file $passwdfile\n";
- }
- $passwd = <RPASS>;
- chomp($passwd);
- close(RPASS);
+ unless (open (RPASS, $passwdfile)) {
+ die "Error, cannot open password file $passwdfile\n";
+ }
+ $passwd = <RPASS>;
+ chomp($passwd);
+ close(RPASS);
} elsif ($passwd eq "-"){
# Read the password from terminal
- die "The '-w -' option requires an extension library (Term::ReadKey) which is not\n",
- "part of the standard perl distribution. If you want to use it, you must\n",
- "download and install the module. You can find it at\n",
- "http://www.perl.com/CPAN/CPAN.html\n";
+ die "The '-w -' option requires an extension library (Term::ReadKey) which is not\n",
+ "part of the standard perl distribution. If you want to use it, you must\n",
+ "download and install the module. You can find it at\n",
+ "http://www.perl.com/CPAN/CPAN.html\n";
# Remove the previous line and uncomment the following 6 lines once you have installed Term::ReadKey module.
# use Term::ReadKey;
-# print "Bind Password: ";
-# ReadMode('noecho');
-# $passwd = ReadLine(0);
-# chomp($passwd);
-# ReadMode('normal');
+# print "Bind Password: ";
+# ReadMode('noecho');
+# $passwd = ReadLine(0);
+# chomp($passwd);
+# ReadMode('normal');
}
if ( $rootdn eq "" || $passwd eq "" )
{
- &usage;
- exit(1);
+ &usage;
+ exit(1);
}
$vstr = "";
if ($verbose != 0)
{
- $vstr = "-v";
+ $vstr = "-v";
}
($s, $m, $h, $dy, $mn, $yr, $wdy, $ydy, $r) = localtime(time);
@@ -154,74 +154,72 @@
if ( $instance eq "" )
{
- &usage;
- exit(1);
+ &usage;
+ exit(1);
}
-else
+
+# No attribute name has been specified: let's get them from the configuration
+$attribute="";
+$indexes_list="";
+$vlvattribute="";
+$vlvindexes_list="";
+chdir("$dsroot{{SEP}}shared{{SEP}}bin");
+if ( $attribute_arg eq "" && $vlvattribute_arg eq "" )
{
- # No attribute name has been specified: let's get them from the configuration
- $attribute="";
- $indexes_list="";
- $vlvattribute="";
- $vlvindexes_list="";
- if ( $attribute_arg eq "" && $vlvattribute_arg eq "" )
- {
- # Get the list of indexes from the entry
- $indexes_list="$dsroot{{SEP}}shared{{SEP}}bin{{SEP}}ldapsearch $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -s one " .
- "-b \"cn=index,cn=\"$instance\", cn=ldbm database,cn=plugins,cn=config\" \"(&(objectclass=*)(nsSystemIndex=false))\" cn";
-
- # build the values of the attribute nsIndexAttribute
- open(LDAP1, "$indexes_list |");
- while (<LDAP1>) {
- s/\n //g;
- if (/^cn: (.*)\n/) {
- $IndexAttribute="nsIndexAttribute";
- $attribute="$attribute$IndexAttribute: $1\n";
- }
- }
- close(LDAP1);
- if ( $attribute eq "" )
- {
- # No attribute to index, just exit
- exit(0);
+ # Get the list of indexes from the entry
+ $indexes_list="$dsroot{{SEP}}shared{{SEP}}bin{{SEP}}ldapsearch $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -s one " .
+ "-b \"cn=index,cn=\"$instance\", cn=ldbm database,cn=plugins,cn=config\" \"(&(objectclass=*)(nsSystemIndex=false))\" cn";
+
+ # build the values of the attribute nsIndexAttribute
+ open(LDAP1, "$indexes_list |");
+ while (<LDAP1>) {
+ s/\n //g;
+ if (/^cn: (.*)\n/) {
+ $IndexAttribute="nsIndexAttribute";
+ $attribute="$attribute$IndexAttribute: $1\n";
}
+ }
+ close(LDAP1);
+ if ( $attribute eq "" )
+ {
+ # No attribute to index, just exit
+ exit(0);
+ }
+
+ # Get the list of indexes from the entry
+ $vlvindexes_list="$dsroot{{SEP}}shared{{SEP}}bin{{SEP}}ldapsearch $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -s sub -b \"cn=\"$instance\", cn=ldbm database,cn=plugins,cn=config\" \"objectclass=vlvIndex\" cn";
- # Get the list of indexes from the entry
- $vlvindexes_list="$dsroot{{SEP}}shared{{SEP}}bin{{SEP}}ldapsearch $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -s sub -b \"cn=\"$instance\", cn=ldbm database,cn=plugins,cn=config\" \"objectclass=vlvIndex\" cn";
-
- # build the values of the attribute nsIndexVlvAttribute
- open(LDAP1, "$vlvindexes_list |");
- while (<LDAP1>) {
- s/\n //g;
- if (/^cn: (.*)\n/) {
- $vlvIndexAttribute="nsIndexVlvAttribute";
- $vlvattribute="$vlvattribute$vlvIndexAttribute: $1\n";
- }
+ # build the values of the attribute nsIndexVlvAttribute
+ open(LDAP1, "$vlvindexes_list |");
+ while (<LDAP1>) {
+ s/\n //g;
+ if (/^cn: (.*)\n/) {
+ $vlvIndexAttribute="nsIndexVlvAttribute";
+ $vlvattribute="$vlvattribute$vlvIndexAttribute: $1\n";
}
- close(LDAP1);
}
- else
+ close(LDAP1);
+}
+else
+{
+ if ( $attribute_arg ne "" )
{
- if ( $attribute_arg ne "" )
- {
- $attribute="nsIndexAttribute: $attribute_arg\n";
- }
- if ( $vlvattribute_arg ne "" )
- {
- $vlvattribute="nsIndexVlvAttribute: $vlvattribute_arg\n";
- }
+ $attribute="nsIndexAttribute: $attribute_arg\n";
+ }
+ if ( $vlvattribute_arg ne "" )
+ {
+ $vlvattribute="nsIndexVlvAttribute: $vlvattribute_arg\n";
}
-
- # Build the task entry to add
-
- $dn = "dn: cn=$taskname, cn=index, cn=tasks, cn=config\n";
- $misc = "changetype: add\nobjectclass: top\nobjectclass: extensibleObject\n";
- $cn = "cn: $taskname\n";
- $nsinstance = "nsInstance: ${instance}\n";
-
- $entry = "${dn}${misc}${cn}${nsinstance}${attribute}${vlvattribute}";
}
-chdir("$dsroot{{SEP}}shared{{SEP}}bin");
+
+# Build the task entry to add
+
+$dn = "dn: cn=$taskname, cn=index, cn=tasks, cn=config\n";
+$misc = "changetype: add\nobjectclass: top\nobjectclass: extensibleObject\n";
+$cn = "cn: $taskname\n";
+$nsinstance = "nsInstance: ${instance}\n";
+
+$entry = "${dn}${misc}${cn}${nsinstance}${attribute}${vlvattribute}";
open(FOO, "| $dsroot{{SEP}}shared{{SEP}}bin{{SEP}}ldapmodify $vstr -h {{SERVER-NAME}} -p {{SERVER-PORT}} -D \"$rootdn\" -w \"$passwd\" -a" );
print(FOO "$entry");
close(FOO);
18 years, 7 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd attr.c, 1.5, 1.5.2.1 attrlist.c, 1.4, 1.4.2.1 entry.c, 1.8.2.1, 1.8.2.2 proto-slap.h, 1.10, 1.10.2.1 valueset.c, 1.4, 1.4.2.1
by Doctor Conrad
Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv4127
Modified Files:
Tag: Directory71RtmBranch
attr.c attrlist.c entry.c proto-slap.h valueset.c
Log Message:
[Bug 164834] modify/replace allows multiple same valued attributes in an entry
1) Eliminated SLAPD_MODUTIL_TREE_THREASHHOLD from attr.c as well as valueset.c.
With this change, if an attribute has more than 1 value to add/replace/delete,
it creates an AVL tree to check the duplicates.
2) Replace was not checking the duplicated value at all. Added a code to put
the attribute values into the AVL tree as being done for add and delete.
Index: attr.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/attr.c,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -r1.5 -r1.5.2.1
--- attr.c 19 Apr 2005 22:07:36 -0000 1.5
+++ attr.c 25 Aug 2005 18:25:08 -0000 1.5.2.1
@@ -710,19 +710,12 @@
}
/*
- * If we are adding or deleting SLAPD_MODUTIL_TREE_THRESHHOLD or more
- * entries, we use an AVL tree to speed up searching for duplicates or
- * values we are trying to delete. This threshhold is somewhat arbitrary;
- * we should really take some measurements to determine an optimal number.
- */
-#define SLAPD_MODUTIL_TREE_THRESHHOLD 5
-
-/*
- * Add a value array to an attribute. If SLAPD_MODUTIL_TREE_THRESHHOLD or
- * more values are being added, we build an AVL tree of any existing
+ * Add a value array to an attribute.
+ * If more than one values are being added, we build an AVL tree of any existing
* values and then update that in parallel with the existing values. This
- * is done so that we do not waste a lot of CPU time searching for duplicate
- * values. The AVL tree is created and destroyed all within this function.
+ * AVL tree is used to detect the duplicates not only between the existing
+ * values and to-be-added values but also among the to-be-added values.
+ * The AVL tree is created and destroyed all within this function.
*
* Returns
* LDAP_SUCCESS - OK
@@ -733,28 +726,28 @@
attr_add_valuearray(Slapi_Attr *a, Slapi_Value **vals, const char *dn)
{
int i = 0;
- int duplicate_index = -1;
- int was_present_null = 0;
- int rc = LDAP_SUCCESS;
+ int numofvals = 0;
+ int duplicate_index = -1;
+ int was_present_null = 0;
+ int rc = LDAP_SUCCESS;
if (valuearray_isempty(vals)) {
/*
* No values to add (unexpected but acceptable).
*/
return rc;
- }
+ }
/*
* determine whether we should use an AVL tree of values or not
*/
- while ( i < SLAPD_MODUTIL_TREE_THRESHHOLD - 1 && vals[i] != NULL ) {
- i++;
- }
+ for ( i = 0; vals[i] != NULL; i++ ) ;
+ numofvals = i;
/*
* detect duplicate values
*/
- if ( i >= SLAPD_MODUTIL_TREE_THRESHHOLD - 1 ) {
+ if ( numofvals > 1 ) {
/*
* Several values to add: use an AVL tree to detect duplicates.
*/
@@ -763,82 +756,85 @@
"detect duplicate values\n", 0, 0, 0 );
if (valueset_isempty(&a->a_present_values)) {
- /* if the attribute contains no values yet, just check the
- * input vals array for duplicates
- */
+ /* if the attribute contains no values yet, just check the
+ * input vals array for duplicates
+ */
Avlnode *vtree = NULL;
rc= valuetree_add_valuearray(a->a_type, a->a_plugin, vals, &vtree, &duplicate_index);
valuetree_free(&vtree);
- was_present_null = 1;
+ was_present_null = 1;
} else {
- /* the attr and vals both contain values, check intersection */
+ /* the attr and vals both contain values, check intersection */
rc= valueset_intersectswith_valuearray(&a->a_present_values, a, vals, &duplicate_index);
}
} else if ( !valueset_isempty(&a->a_present_values) ) {
/*
- * Small number of values to add: don't bother constructing
+ * One or no value to add: don't bother constructing
* an AVL tree, etc. since it probably isn't worth the time.
*/
for ( i = 0; vals[i] != NULL; ++i ) {
if ( slapi_attr_value_find( a, slapi_value_get_berval(vals[i]) ) == 0 ) {
- duplicate_index = i;
- rc = LDAP_TYPE_OR_VALUE_EXISTS;
- break;
+ duplicate_index = i;
+ rc = LDAP_TYPE_OR_VALUE_EXISTS;
+ break;
}
- }
+ }
}
- /*
- * add values if no duplicates detected
- */
+ /*
+ * add values if no duplicates detected
+ */
if(rc==LDAP_SUCCESS) {
- valueset_add_valuearray( &a->a_present_values, vals );
- }
+ valueset_add_valuearray( &a->a_present_values, vals );
+ }
- /* In the case of duplicate value, rc == LDAP_TYPE_OR_VALUE_EXISTS or
- * LDAP_OPERATIONS_ERROR
- */
- else if ( duplicate_index >= 0 ) {
- char avdbuf[BUFSIZ];
- char bvvalcopy[BUFSIZ];
- char *duplicate_string = "null or non-ASCII";
-
- i = 0;
- while ( (unsigned int)i < vals[duplicate_index]->bv.bv_len &&
- i < BUFSIZ - 1 &&
- vals[duplicate_index]->bv.bv_val[i] &&
- isascii ( vals[duplicate_index]->bv.bv_val[i] )) {
- i++;
- }
-
- if ( i ) {
- if ( vals[duplicate_index]->bv.bv_val[i] == 0 ) {
- duplicate_string = vals[duplicate_index]->bv.bv_val;
- }
- else {
- strncpy ( &bvvalcopy[0], vals[duplicate_index]->bv.bv_val, i );
- bvvalcopy[i] = '\0';
- duplicate_string = bvvalcopy;
- }
- }
-
- slapi_log_error( SLAPI_LOG_FATAL, NULL, "add value \"%s\" to "
- "attribute type \"%s\" in entry \"%s\" failed: %s\n",
- duplicate_string,
- a->a_type,
- dn ? escape_string(dn,avdbuf) : "<null>",
- (was_present_null ? "duplicate new value" : "value exists"));
- }
+ /* In the case of duplicate value, rc == LDAP_TYPE_OR_VALUE_EXISTS or
+ * LDAP_OPERATIONS_ERROR
+ */
+ else if ( duplicate_index >= 0 ) {
+ char avdbuf[BUFSIZ];
+ char bvvalcopy[BUFSIZ];
+ char *duplicate_string = "null or non-ASCII";
+
+ i = 0;
+ while ( (unsigned int)i < vals[duplicate_index]->bv.bv_len &&
+ i < BUFSIZ - 1 &&
+ vals[duplicate_index]->bv.bv_val[i] &&
+ isascii ( vals[duplicate_index]->bv.bv_val[i] )) {
+ i++;
+ }
+
+ if ( i ) {
+ if ( vals[duplicate_index]->bv.bv_val[i] == 0 ) {
+ duplicate_string = vals[duplicate_index]->bv.bv_val;
+ }
+ else {
+ strncpy ( &bvvalcopy[0], vals[duplicate_index]->bv.bv_val, i );
+ bvvalcopy[i] = '\0';
+ duplicate_string = bvvalcopy;
+ }
+ }
+
+ slapi_log_error( SLAPI_LOG_FATAL, NULL, "add value \"%s\" to "
+ "attribute type \"%s\" in entry \"%s\" failed: %s\n",
+ duplicate_string,
+ a->a_type,
+ dn ? escape_string(dn,avdbuf) : "<null>",
+ (was_present_null ? "duplicate new value" : "value exists"));
+ }
return( rc );
}
/* quickly toss an attribute's values and replace them with new ones
* (used by attrlist_replace_fast)
+ * Returns
+ * LDAP_SUCCESS - OK
+ * LDAP_OPERATIONS_ERROR - Existing duplicates in attribute.
*/
-void attr_replace(Slapi_Attr *a, Slapi_Value **vals)
+int attr_replace(Slapi_Attr *a, Slapi_Value **vals)
{
- valueset_replace(&a->a_present_values, vals);
+ return valueset_replace(a, &a->a_present_values, vals);
}
int
Index: attrlist.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/attrlist.c,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- attrlist.c 19 Apr 2005 22:07:36 -0000 1.4
+++ attrlist.c 25 Aug 2005 18:25:08 -0000 1.4.2.1
@@ -268,18 +268,24 @@
/*
* attrlist_replace - replace the attribute value(s) with this value(s)
+ *
+ * Returns
+ * LDAP_SUCCESS - OK (including the attr not found)
+ * LDAP_OPERATIONS_ERROR - Existing duplicates in attribute.
*/
-void attrlist_replace(Slapi_Attr **alist, const char *type, struct berval **vals)
+int attrlist_replace(Slapi_Attr **alist, const char *type, struct berval **vals)
{
Slapi_Attr **a = NULL;
Slapi_Value **values = NULL;
+ int rc = LDAP_SUCCESS;
if (vals == NULL || vals[0] == NULL) {
(void)attrlist_delete(alist, type);
} else {
attrlist_find_or_create(alist, type, &a);
valuearray_init_bervalarray(vals, &values);
- attr_replace(*a, values);
+ rc = attr_replace(*a, values);
}
+ return rc;
}
Index: entry.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/entry.c,v
retrieving revision 1.8.2.1
retrieving revision 1.8.2.2
diff -u -r1.8.2.1 -r1.8.2.2
--- entry.c 1 Jun 2005 17:50:39 -0000 1.8.2.1
+++ entry.c 25 Aug 2005 18:25:08 -0000 1.8.2.2
@@ -2792,8 +2792,7 @@
struct berval **vals
)
{
- attrlist_replace( &e->e_attrs, type, vals );
- return 0;
+ return attrlist_replace( &e->e_attrs, type, vals );
}
int
Index: proto-slap.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/proto-slap.h,v
retrieving revision 1.10
retrieving revision 1.10.2.1
diff -u -r1.10 -r1.10.2.1
--- proto-slap.h 19 Apr 2005 22:07:36 -0000 1.10
+++ proto-slap.h 25 Aug 2005 18:25:08 -0000 1.10.2.1
@@ -61,7 +61,7 @@
*/
void attr_done(Slapi_Attr *a);
int attr_add_valuearray(Slapi_Attr *a, Slapi_Value **vals, const char *dn);
-void attr_replace(Slapi_Attr *a, Slapi_Value **vals);
+int attr_replace(Slapi_Attr *a, Slapi_Value **vals);
int attr_check_onoff ( const char *attr_name, char *value, long minval, long maxval, char *errorbuf );
int attr_check_minmax ( const char *attr_name, char *value, long minval, long maxval, char *errorbuf );
@@ -80,7 +80,7 @@
void attrlist_add(Slapi_Attr **attrs, Slapi_Attr *a);
int attrlist_count_subtypes(Slapi_Attr *a, const char *type);
Slapi_Attr *attrlist_find_ex( Slapi_Attr *a, const char *type, int *type_name_disposition, char** actual_type_name, void **hint );
-void attrlist_replace(Slapi_Attr **alist, const char *type, struct berval **vals);
+int attrlist_replace(Slapi_Attr **alist, const char *type, struct berval **vals);
/*
* attrsyntax.c
@@ -158,7 +158,7 @@
int valueset_intersectswith_valuearray(Slapi_ValueSet *vs, const Slapi_Attr *a, Slapi_Value **values, int *duplicate_index);
Slapi_ValueSet *valueset_dup(const Slapi_ValueSet *dupee);
void valueset_remove_string(const Slapi_Attr *a, Slapi_ValueSet *vs, const char *s);
-void valueset_replace(Slapi_ValueSet *vs, Slapi_Value **vals);
+int valueset_replace(Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value **vals);
void valueset_update_csn_for_valuearray(Slapi_ValueSet *vs, const Slapi_Attr *a, Slapi_Value **valuestoupdate, CSNType t, const CSN *csn, Slapi_Value ***valuesupdated);
void valueset_set_valuearray_byval(Slapi_ValueSet *vs, Slapi_Value **addvals);
void valueset_set_valuearray_passin(Slapi_ValueSet *vs, Slapi_Value **addvals);
Index: valueset.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/valueset.c,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- valueset.c 19 Apr 2005 22:07:37 -0000 1.4
+++ valueset.c 25 Aug 2005 18:25:08 -0000 1.4.2.1
@@ -1015,13 +1015,6 @@
}
/*
- * If we are adding or deleting SLAPD_MODUTIL_TREE_THRESHHOLD or more
- * entries, we use an AVL tree to speed up searching for duplicates or
- * values we are trying to delete. This threshhold is somewhat arbitrary;
- * we should really take some measurements to determine an optimal number.
- */
-#define SLAPD_MODUTIL_TREE_THRESHHOLD 5
-/*
* Remove an array of values from a value set.
* The removed values are passed back in an array.
*
@@ -1044,9 +1037,10 @@
}
/*
- * determine whether we should use an AVL tree of values or not
+ * If there are more then one values, build an AVL tree to check
+ * the duplicated values.
*/
- if ( numberofvaluestodelete >= SLAPD_MODUTIL_TREE_THRESHHOLD)
+ if ( numberofvaluestodelete > 1 )
{
/*
* Several values to delete: first build an AVL tree that
@@ -1132,7 +1126,7 @@
}
else
{
- /* We don't have to delete very many values, so we use brute force. */
+ /* We delete one or no value, so we use brute force. */
int i;
for ( i = 0; rc==LDAP_SUCCESS && valuestodelete[i] != NULL; ++i )
{
@@ -1210,7 +1204,7 @@
{
/* No intersection */
}
- else if ( numberofvalues >= SLAPD_MODUTIL_TREE_THRESHHOLD)
+ else if ( numberofvalues > 1 )
{
/*
* Several values to add: use an AVL tree to detect duplicates.
@@ -1234,7 +1228,7 @@
else
{
/*
- * Small number of values to add: don't bother constructing
+ * One value to add: don't bother constructing
* an AVL tree, etc. since it probably isn't worth the time.
*
* JCM - This is actually quite slow because the comparison function is looked up many times.
@@ -1267,15 +1261,39 @@
/* quickly throw away any old contents of this valueset, and stick in the
* new ones.
+ *
+ * return value: LDAP_SUCCESS - OK
+ * : LDAP_OPERATIONS_ERROR - duplicated values given
*/
-void
-valueset_replace(Slapi_ValueSet *vs, Slapi_Value **vals)
+int
+valueset_replace(Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value **valstoreplace)
{
+ int rc = LDAP_SUCCESS;
+ int numberofvalstoreplace= valuearray_count(valstoreplace);
if(!valuearray_isempty(vs->va))
- {
+ {
slapi_valueset_done(vs);
- }
- vs->va = vals;
+ }
+ /* verify the given values are not duplicated.
+ if replacing with one value, no need to check. just replace it.
+ */
+ if (numberofvalstoreplace > 1)
+ {
+ Avlnode *vtree = NULL;
+ rc = valuetree_add_valuearray( a->a_type, a->a_plugin, valstoreplace, &vtree, NULL );
+ valuetree_free(&vtree);
+ if ( LDAP_SUCCESS != rc )
+ {
+ /* There were already duplicate values in the value set */
+ rc = LDAP_OPERATIONS_ERROR;
+ }
+ }
+
+ if ( rc == LDAP_SUCCESS )
+ {
+ vs->va = valstoreplace;
+ }
+ return rc;
}
/*
@@ -1296,7 +1314,7 @@
struct valuearrayfast vaf_valuesupdated;
int numberofvaluestoupdate= valuearray_count(valuestoupdate);
valuearrayfast_init(&vaf_valuesupdated,*valuesupdated);
- if (numberofvaluestoupdate>=SLAPD_MODUTIL_TREE_THRESHHOLD)
+ if (numberofvaluestoupdate > 1) /* multiple values to update */
{
int i;
Avlnode *vtree = NULL;
18 years, 7 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd attr.c, 1.5, 1.6 attrlist.c, 1.4, 1.5 entry.c, 1.9, 1.10 proto-slap.h, 1.10, 1.11 valueset.c, 1.4, 1.5
by Doctor Conrad
Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv6551
Modified Files:
attr.c attrlist.c entry.c proto-slap.h valueset.c
Log Message:
[Bug 164834] modify/replace allows multiple same valued attributes in an entry
1) Eliminated SLAPD_MODUTIL_TREE_THREASHHOLD from attr.c as well as valueset.c.
With this change, if an attribute has more than 1 value to add/replace/delete,
it creates an AVL tree to check the duplicates.
2) Replace was not checking the duplicated value at all. Added a code to put
the attribute values into the AVL tree as being done for add and delete.
Index: attr.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/attr.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- attr.c 19 Apr 2005 22:07:36 -0000 1.5
+++ attr.c 25 Aug 2005 00:58:27 -0000 1.6
@@ -710,19 +710,12 @@
}
/*
- * If we are adding or deleting SLAPD_MODUTIL_TREE_THRESHHOLD or more
- * entries, we use an AVL tree to speed up searching for duplicates or
- * values we are trying to delete. This threshhold is somewhat arbitrary;
- * we should really take some measurements to determine an optimal number.
- */
-#define SLAPD_MODUTIL_TREE_THRESHHOLD 5
-
-/*
- * Add a value array to an attribute. If SLAPD_MODUTIL_TREE_THRESHHOLD or
- * more values are being added, we build an AVL tree of any existing
+ * Add a value array to an attribute.
+ * If more than one values are being added, we build an AVL tree of any existing
* values and then update that in parallel with the existing values. This
- * is done so that we do not waste a lot of CPU time searching for duplicate
- * values. The AVL tree is created and destroyed all within this function.
+ * AVL tree is used to detect the duplicates not only between the existing
+ * values and to-be-added values but also among the to-be-added values.
+ * The AVL tree is created and destroyed all within this function.
*
* Returns
* LDAP_SUCCESS - OK
@@ -733,28 +726,28 @@
attr_add_valuearray(Slapi_Attr *a, Slapi_Value **vals, const char *dn)
{
int i = 0;
- int duplicate_index = -1;
- int was_present_null = 0;
- int rc = LDAP_SUCCESS;
+ int numofvals = 0;
+ int duplicate_index = -1;
+ int was_present_null = 0;
+ int rc = LDAP_SUCCESS;
if (valuearray_isempty(vals)) {
/*
* No values to add (unexpected but acceptable).
*/
return rc;
- }
+ }
/*
* determine whether we should use an AVL tree of values or not
*/
- while ( i < SLAPD_MODUTIL_TREE_THRESHHOLD - 1 && vals[i] != NULL ) {
- i++;
- }
+ for ( i = 0; vals[i] != NULL; i++ ) ;
+ numofvals = i;
/*
* detect duplicate values
*/
- if ( i >= SLAPD_MODUTIL_TREE_THRESHHOLD - 1 ) {
+ if ( numofvals > 1 ) {
/*
* Several values to add: use an AVL tree to detect duplicates.
*/
@@ -763,82 +756,85 @@
"detect duplicate values\n", 0, 0, 0 );
if (valueset_isempty(&a->a_present_values)) {
- /* if the attribute contains no values yet, just check the
- * input vals array for duplicates
- */
+ /* if the attribute contains no values yet, just check the
+ * input vals array for duplicates
+ */
Avlnode *vtree = NULL;
rc= valuetree_add_valuearray(a->a_type, a->a_plugin, vals, &vtree, &duplicate_index);
valuetree_free(&vtree);
- was_present_null = 1;
+ was_present_null = 1;
} else {
- /* the attr and vals both contain values, check intersection */
+ /* the attr and vals both contain values, check intersection */
rc= valueset_intersectswith_valuearray(&a->a_present_values, a, vals, &duplicate_index);
}
} else if ( !valueset_isempty(&a->a_present_values) ) {
/*
- * Small number of values to add: don't bother constructing
+ * One or no value to add: don't bother constructing
* an AVL tree, etc. since it probably isn't worth the time.
*/
for ( i = 0; vals[i] != NULL; ++i ) {
if ( slapi_attr_value_find( a, slapi_value_get_berval(vals[i]) ) == 0 ) {
- duplicate_index = i;
- rc = LDAP_TYPE_OR_VALUE_EXISTS;
- break;
+ duplicate_index = i;
+ rc = LDAP_TYPE_OR_VALUE_EXISTS;
+ break;
}
- }
+ }
}
- /*
- * add values if no duplicates detected
- */
+ /*
+ * add values if no duplicates detected
+ */
if(rc==LDAP_SUCCESS) {
- valueset_add_valuearray( &a->a_present_values, vals );
- }
+ valueset_add_valuearray( &a->a_present_values, vals );
+ }
- /* In the case of duplicate value, rc == LDAP_TYPE_OR_VALUE_EXISTS or
- * LDAP_OPERATIONS_ERROR
- */
- else if ( duplicate_index >= 0 ) {
- char avdbuf[BUFSIZ];
- char bvvalcopy[BUFSIZ];
- char *duplicate_string = "null or non-ASCII";
-
- i = 0;
- while ( (unsigned int)i < vals[duplicate_index]->bv.bv_len &&
- i < BUFSIZ - 1 &&
- vals[duplicate_index]->bv.bv_val[i] &&
- isascii ( vals[duplicate_index]->bv.bv_val[i] )) {
- i++;
- }
-
- if ( i ) {
- if ( vals[duplicate_index]->bv.bv_val[i] == 0 ) {
- duplicate_string = vals[duplicate_index]->bv.bv_val;
- }
- else {
- strncpy ( &bvvalcopy[0], vals[duplicate_index]->bv.bv_val, i );
- bvvalcopy[i] = '\0';
- duplicate_string = bvvalcopy;
- }
- }
-
- slapi_log_error( SLAPI_LOG_FATAL, NULL, "add value \"%s\" to "
- "attribute type \"%s\" in entry \"%s\" failed: %s\n",
- duplicate_string,
- a->a_type,
- dn ? escape_string(dn,avdbuf) : "<null>",
- (was_present_null ? "duplicate new value" : "value exists"));
- }
+ /* In the case of duplicate value, rc == LDAP_TYPE_OR_VALUE_EXISTS or
+ * LDAP_OPERATIONS_ERROR
+ */
+ else if ( duplicate_index >= 0 ) {
+ char avdbuf[BUFSIZ];
+ char bvvalcopy[BUFSIZ];
+ char *duplicate_string = "null or non-ASCII";
+
+ i = 0;
+ while ( (unsigned int)i < vals[duplicate_index]->bv.bv_len &&
+ i < BUFSIZ - 1 &&
+ vals[duplicate_index]->bv.bv_val[i] &&
+ isascii ( vals[duplicate_index]->bv.bv_val[i] )) {
+ i++;
+ }
+
+ if ( i ) {
+ if ( vals[duplicate_index]->bv.bv_val[i] == 0 ) {
+ duplicate_string = vals[duplicate_index]->bv.bv_val;
+ }
+ else {
+ strncpy ( &bvvalcopy[0], vals[duplicate_index]->bv.bv_val, i );
+ bvvalcopy[i] = '\0';
+ duplicate_string = bvvalcopy;
+ }
+ }
+
+ slapi_log_error( SLAPI_LOG_FATAL, NULL, "add value \"%s\" to "
+ "attribute type \"%s\" in entry \"%s\" failed: %s\n",
+ duplicate_string,
+ a->a_type,
+ dn ? escape_string(dn,avdbuf) : "<null>",
+ (was_present_null ? "duplicate new value" : "value exists"));
+ }
return( rc );
}
/* quickly toss an attribute's values and replace them with new ones
* (used by attrlist_replace_fast)
+ * Returns
+ * LDAP_SUCCESS - OK
+ * LDAP_OPERATIONS_ERROR - Existing duplicates in attribute.
*/
-void attr_replace(Slapi_Attr *a, Slapi_Value **vals)
+int attr_replace(Slapi_Attr *a, Slapi_Value **vals)
{
- valueset_replace(&a->a_present_values, vals);
+ return valueset_replace(a, &a->a_present_values, vals);
}
int
Index: attrlist.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/attrlist.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- attrlist.c 19 Apr 2005 22:07:36 -0000 1.4
+++ attrlist.c 25 Aug 2005 00:58:27 -0000 1.5
@@ -268,18 +268,24 @@
/*
* attrlist_replace - replace the attribute value(s) with this value(s)
+ *
+ * Returns
+ * LDAP_SUCCESS - OK (including the attr not found)
+ * LDAP_OPERATIONS_ERROR - Existing duplicates in attribute.
*/
-void attrlist_replace(Slapi_Attr **alist, const char *type, struct berval **vals)
+int attrlist_replace(Slapi_Attr **alist, const char *type, struct berval **vals)
{
Slapi_Attr **a = NULL;
Slapi_Value **values = NULL;
+ int rc = LDAP_SUCCESS;
if (vals == NULL || vals[0] == NULL) {
(void)attrlist_delete(alist, type);
} else {
attrlist_find_or_create(alist, type, &a);
valuearray_init_bervalarray(vals, &values);
- attr_replace(*a, values);
+ rc = attr_replace(*a, values);
}
+ return rc;
}
Index: entry.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/entry.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- entry.c 24 May 2005 16:11:19 -0000 1.9
+++ entry.c 25 Aug 2005 00:58:27 -0000 1.10
@@ -2792,8 +2792,7 @@
struct berval **vals
)
{
- attrlist_replace( &e->e_attrs, type, vals );
- return 0;
+ return attrlist_replace( &e->e_attrs, type, vals );
}
int
Index: proto-slap.h
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/proto-slap.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- proto-slap.h 19 Apr 2005 22:07:36 -0000 1.10
+++ proto-slap.h 25 Aug 2005 00:58:27 -0000 1.11
@@ -61,7 +61,7 @@
*/
void attr_done(Slapi_Attr *a);
int attr_add_valuearray(Slapi_Attr *a, Slapi_Value **vals, const char *dn);
-void attr_replace(Slapi_Attr *a, Slapi_Value **vals);
+int attr_replace(Slapi_Attr *a, Slapi_Value **vals);
int attr_check_onoff ( const char *attr_name, char *value, long minval, long maxval, char *errorbuf );
int attr_check_minmax ( const char *attr_name, char *value, long minval, long maxval, char *errorbuf );
@@ -80,7 +80,7 @@
void attrlist_add(Slapi_Attr **attrs, Slapi_Attr *a);
int attrlist_count_subtypes(Slapi_Attr *a, const char *type);
Slapi_Attr *attrlist_find_ex( Slapi_Attr *a, const char *type, int *type_name_disposition, char** actual_type_name, void **hint );
-void attrlist_replace(Slapi_Attr **alist, const char *type, struct berval **vals);
+int attrlist_replace(Slapi_Attr **alist, const char *type, struct berval **vals);
/*
* attrsyntax.c
@@ -158,7 +158,7 @@
int valueset_intersectswith_valuearray(Slapi_ValueSet *vs, const Slapi_Attr *a, Slapi_Value **values, int *duplicate_index);
Slapi_ValueSet *valueset_dup(const Slapi_ValueSet *dupee);
void valueset_remove_string(const Slapi_Attr *a, Slapi_ValueSet *vs, const char *s);
-void valueset_replace(Slapi_ValueSet *vs, Slapi_Value **vals);
+int valueset_replace(Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value **vals);
void valueset_update_csn_for_valuearray(Slapi_ValueSet *vs, const Slapi_Attr *a, Slapi_Value **valuestoupdate, CSNType t, const CSN *csn, Slapi_Value ***valuesupdated);
void valueset_set_valuearray_byval(Slapi_ValueSet *vs, Slapi_Value **addvals);
void valueset_set_valuearray_passin(Slapi_ValueSet *vs, Slapi_Value **addvals);
Index: valueset.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/valueset.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- valueset.c 19 Apr 2005 22:07:37 -0000 1.4
+++ valueset.c 25 Aug 2005 00:58:27 -0000 1.5
@@ -1015,13 +1015,6 @@
}
/*
- * If we are adding or deleting SLAPD_MODUTIL_TREE_THRESHHOLD or more
- * entries, we use an AVL tree to speed up searching for duplicates or
- * values we are trying to delete. This threshhold is somewhat arbitrary;
- * we should really take some measurements to determine an optimal number.
- */
-#define SLAPD_MODUTIL_TREE_THRESHHOLD 5
-/*
* Remove an array of values from a value set.
* The removed values are passed back in an array.
*
@@ -1044,9 +1037,10 @@
}
/*
- * determine whether we should use an AVL tree of values or not
+ * If there are more then one values, build an AVL tree to check
+ * the duplicated values.
*/
- if ( numberofvaluestodelete >= SLAPD_MODUTIL_TREE_THRESHHOLD)
+ if ( numberofvaluestodelete > 1 )
{
/*
* Several values to delete: first build an AVL tree that
@@ -1132,7 +1126,7 @@
}
else
{
- /* We don't have to delete very many values, so we use brute force. */
+ /* We delete one or no value, so we use brute force. */
int i;
for ( i = 0; rc==LDAP_SUCCESS && valuestodelete[i] != NULL; ++i )
{
@@ -1210,7 +1204,7 @@
{
/* No intersection */
}
- else if ( numberofvalues >= SLAPD_MODUTIL_TREE_THRESHHOLD)
+ else if ( numberofvalues > 1 )
{
/*
* Several values to add: use an AVL tree to detect duplicates.
@@ -1234,7 +1228,7 @@
else
{
/*
- * Small number of values to add: don't bother constructing
+ * One value to add: don't bother constructing
* an AVL tree, etc. since it probably isn't worth the time.
*
* JCM - This is actually quite slow because the comparison function is looked up many times.
@@ -1267,15 +1261,39 @@
/* quickly throw away any old contents of this valueset, and stick in the
* new ones.
+ *
+ * return value: LDAP_SUCCESS - OK
+ * : LDAP_OPERATIONS_ERROR - duplicated values given
*/
-void
-valueset_replace(Slapi_ValueSet *vs, Slapi_Value **vals)
+int
+valueset_replace(Slapi_Attr *a, Slapi_ValueSet *vs, Slapi_Value **valstoreplace)
{
+ int rc = LDAP_SUCCESS;
+ int numberofvalstoreplace= valuearray_count(valstoreplace);
if(!valuearray_isempty(vs->va))
- {
+ {
slapi_valueset_done(vs);
- }
- vs->va = vals;
+ }
+ /* verify the given values are not duplicated.
+ if replacing with one value, no need to check. just replace it.
+ */
+ if (numberofvalstoreplace > 1)
+ {
+ Avlnode *vtree = NULL;
+ rc = valuetree_add_valuearray( a->a_type, a->a_plugin, valstoreplace, &vtree, NULL );
+ valuetree_free(&vtree);
+ if ( LDAP_SUCCESS != rc )
+ {
+ /* There were already duplicate values in the value set */
+ rc = LDAP_OPERATIONS_ERROR;
+ }
+ }
+
+ if ( rc == LDAP_SUCCESS )
+ {
+ vs->va = valstoreplace;
+ }
+ return rc;
}
/*
@@ -1296,7 +1314,7 @@
struct valuearrayfast vaf_valuesupdated;
int numberofvaluestoupdate= valuearray_count(valuestoupdate);
valuearrayfast_init(&vaf_valuesupdated,*valuesupdated);
- if (numberofvaluestoupdate>=SLAPD_MODUTIL_TREE_THRESHHOLD)
+ if (numberofvaluestoupdate > 1) /* multiple values to update */
{
int i;
Avlnode *vtree = NULL;
18 years, 7 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd/tools dbscan.c, 1.12, 1.13
by Doctor Conrad
Author: nhosoi
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/tools
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv6506
Modified Files:
dbscan.c
Log Message:
[Bug 166632] dbscan: not to truncate the entry even if it is larger than BUFSIZ
By default, it dumps the entire entry. (it used to be truncated at the BUFSIZ
size). In case no need to dump the entire entry, introduced the truncate option
"-t".
Index: dbscan.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/tools/dbscan.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- dbscan.c 19 Apr 2005 22:07:42 -0000 1.12
+++ dbscan.c 25 Aug 2005 00:41:44 -0000 1.13
@@ -68,25 +68,25 @@
#define CHANGELOGTYPE 0x8
/* display mode */
-#define RAWDATA 0x1
-#define SHOWCOUNT 0x2
-#define SHOWDATA 0x4
+#define RAWDATA 0x1
+#define SHOWCOUNT 0x2
+#define SHOWDATA 0x4
#define SHOWSUMMARY 0x8
/* stolen from slapi-plugin.h */
-#define SLAPI_OPERATION_BIND 0x00000001UL
-#define SLAPI_OPERATION_UNBIND 0x00000002UL
-#define SLAPI_OPERATION_SEARCH 0x00000004UL
-#define SLAPI_OPERATION_MODIFY 0x00000008UL
-#define SLAPI_OPERATION_ADD 0x00000010UL
-#define SLAPI_OPERATION_DELETE 0x00000020UL
-#define SLAPI_OPERATION_MODDN 0x00000040UL
-#define SLAPI_OPERATION_MODRDN SLAPI_OPERATION_MODDN
-#define SLAPI_OPERATION_COMPARE 0x00000080UL
-#define SLAPI_OPERATION_ABANDON 0x00000100UL
-#define SLAPI_OPERATION_EXTENDED 0x00000200UL
-#define SLAPI_OPERATION_ANY 0xFFFFFFFFUL
-#define SLAPI_OPERATION_NONE 0x00000000UL
+#define SLAPI_OPERATION_BIND 0x00000001UL
+#define SLAPI_OPERATION_UNBIND 0x00000002UL
+#define SLAPI_OPERATION_SEARCH 0x00000004UL
+#define SLAPI_OPERATION_MODIFY 0x00000008UL
+#define SLAPI_OPERATION_ADD 0x00000010UL
+#define SLAPI_OPERATION_DELETE 0x00000020UL
+#define SLAPI_OPERATION_MODDN 0x00000040UL
+#define SLAPI_OPERATION_MODRDN SLAPI_OPERATION_MODDN
+#define SLAPI_OPERATION_COMPARE 0x00000080UL
+#define SLAPI_OPERATION_ABANDON 0x00000100UL
+#define SLAPI_OPERATION_EXTENDED 0x00000200UL
+#define SLAPI_OPERATION_ANY 0xFFFFFFFFUL
+#define SLAPI_OPERATION_NONE 0x00000000UL
#define ONEMEG (1024*1024)
@@ -94,7 +94,7 @@
#include <getopt.h>
#endif
-typedef u_int32_t ID;
+typedef u_int32_t ID;
typedef unsigned int uint32;
@@ -104,29 +104,41 @@
uint32 id[1];
} IDL;
+uint32 file_type = 0;
+uint32 min_display = 0;
+uint32 display_mode = 0;
+int truncatesiz = 0;
+long pres_cnt = 0;
+long eq_cnt = 0;
+long app_cnt = 0;
+long sub_cnt = 0;
+long match_cnt = 0;
+long ind_cnt = 0;
+long allids_cnt = 0;
+long other_cnt = 0;
+
/** db_printf - functioning same as printf but a place for manipluating output.
*/
void db_printf(char *fmt, ...)
{
- va_list ap;
+ va_list ap;
- va_start(ap, fmt);
- vfprintf(stdout, fmt, ap);
+ va_start(ap, fmt);
+ vfprintf(stdout, fmt, ap);
}
void db_printfln(char *fmt, ...)
{
- va_list ap;
+ va_list ap;
- va_start(ap, fmt);
- vfprintf(stdout, fmt, ap);
- vfprintf(stdout, "\n", NULL);
+ va_start(ap, fmt);
+ vfprintf(stdout, fmt, ap);
+ vfprintf(stdout, "\n", NULL);
}
int MAX_BUFFER = 4096;
int MIN_BUFFER = 20;
-
static IDL *idl_make(DBT *data)
{
IDL *idl = NULL, *xidl;
@@ -174,14 +186,17 @@
/* format a string for easy printing */
#define FMT_LF_OK 1
#define FMT_SP_OK 2
-static char *format_raw(unsigned char *s, int len, int flags)
+static char *format_raw(unsigned char *s, int len, int flags,
+ unsigned char *buf, int buflen)
{
- static unsigned char buf[BUFSIZ]; /* not intended to be threadsafe */
static char hex[] = "0123456789ABCDEF";
- unsigned char *p, *o;
+ unsigned char *p, *o, *bufend = buf + buflen - 1;
int i;
- for (p = s, o = buf, i = 0; i < len; p++, i++) {
+ if (NULL == buf || buflen <= 0)
+ return NULL;
+
+ for (p = s, o = buf, i = 0; i < len && o < bufend; p++, i++) {
if ((*p == '%') || (*p <= ' ') || (*p >= 126)) {
/* index keys are stored with their trailing NUL */
if ((*p == 0) && (i == len-1))
@@ -199,24 +214,26 @@
} else {
*o++ = *p;
}
- if (o-buf > BUFSIZ-5) {
- /* out of space */
+ if (truncatesiz > 0 && o > bufend - 5) {
+ /* truncate it */
strcpy(o, " ...");
i = len;
+ o += 4;
}
}
*o = 0;
return (char *)buf;
}
-static char *format(unsigned char *s, int len)
+static char *format(unsigned char *s, int len, unsigned char *buf, int buflen)
{
- return format_raw(s, len, 0);
+ return format_raw(s, len, 0, buf, buflen);
}
-static char *format_entry(unsigned char *s, int len)
+static char *format_entry(unsigned char *s, int len,
+ unsigned char *buf, int buflen)
{
- return format_raw(s, len, FMT_LF_OK | FMT_SP_OK);
+ return format_raw(s, len, FMT_LF_OK | FMT_SP_OK, buf, buflen);
}
static char *idl_format(IDL *idl, int isfirsttime, int *done)
@@ -251,46 +268,46 @@
/*** Copied from cl5_api.c: _cl5ReadString ***/
void _cl5ReadString (char **str, char **buff)
{
- if (str)
- {
- int len = strlen (*buff);
-
- if (len)
- {
- *str = strdup(*buff);
- (*buff) += len + 1;
- }
- else /* just null char - skip it */
- {
- *str = NULL;
- (*buff) ++;
- }
- }
- else /* just skip this string */
- {
- (*buff) += strlen (*buff) + 1;
- }
+ if (str)
+ {
+ int len = strlen (*buff);
+
+ if (len)
+ {
+ *str = strdup(*buff);
+ (*buff) += len + 1;
+ }
+ else /* just null char - skip it */
+ {
+ *str = NULL;
+ (*buff) ++;
+ }
+ }
+ else /* just skip this string */
+ {
+ (*buff) += strlen (*buff) + 1;
+ }
}
/** print_attr - print attribute name followed by one value.
- assume the value stored as null terminated string.
+ assume the value stored as null terminated string.
*/
void print_attr(char *attrname, char **buff)
{
- char *val = NULL;
+ char *val = NULL;
+
+ _cl5ReadString(&val, buff);
+ if(attrname != NULL || val != NULL) {
+ db_printf("\t");
+ }
- _cl5ReadString(&val, buff);
- if(attrname != NULL || val != NULL) {
- db_printf("\t");
- }
-
- if(attrname) {
- db_printf("%s: ", attrname);
- }
- if(val != NULL) {
- db_printf("%s\n", val);
- free(val);
- }
+ if(attrname) {
+ db_printf("%s: ", attrname);
+ }
+ if(val != NULL) {
+ db_printf("%s\n", val);
+ free(val);
+ }
}
/*** Copied from cl5_api.c: _cl5ReadMods ***/
@@ -302,34 +319,34 @@
-----------
<1 byte modop><null terminated attr name><4 byte count>
{<4 byte size><value1><4 byte size><value2>... ||
- <null terminated str1> <null terminated str2>...}
+ <null terminated str1> <null terminated str2>...}
*/
void _cl5ReadMod(char **buff);
void _cl5ReadMods(char **buff)
{
- char *pos = *buff;
- uint32 i;
- uint32 mod_count;
-
- /* need to copy first, to skirt around alignment problems on certain
- architectures */
- memcpy((char *)&mod_count, *buff, sizeof(mod_count));
- mod_count = ntohl(mod_count);
- pos += sizeof (mod_count);
-
-
- for (i = 0; i < mod_count; i++)
- {
- _cl5ReadMod (&pos);
- }
+ char *pos = *buff;
+ uint32 i;
+ uint32 mod_count;
+
+ /* need to copy first, to skirt around alignment problems on certain
+ architectures */
+ memcpy((char *)&mod_count, *buff, sizeof(mod_count));
+ mod_count = ntohl(mod_count);
+ pos += sizeof (mod_count);
+
+
+ for (i = 0; i < mod_count; i++)
+ {
+ _cl5ReadMod (&pos);
+ }
- *buff = pos;
+ *buff = pos;
}
/** print_ber_attr - print one line of attribute, the value was stored
- in ber format, length followed by string.
+ in ber format, length followed by string.
*/
void print_ber_attr(char* attrname, char** buff)
{
@@ -341,18 +358,18 @@
*buff += sizeof (uint32);
if (bv_len > 0) {
- db_printf("\t\t");
+ db_printf("\t\t");
+
+ if(attrname != NULL) {
+ db_printf("%s: ", attrname);
+ }
- if(attrname != NULL) {
- db_printf("%s: ", attrname);
- }
-
- val = malloc(bv_len + 1);
- memcpy (val, *buff, bv_len);
- val[bv_len] = 0;
- *buff += bv_len;
- db_printf("%s\n", val);
- free(val);
+ val = malloc(bv_len + 1);
+ memcpy (val, *buff, bv_len);
+ val[bv_len] = 0;
+ *buff += bv_len;
+ db_printf("%s\n", val);
+ free(val);
}
}
@@ -362,51 +379,51 @@
*/
static ID id_stored_to_internal(char* b)
{
- ID i;
- i = (ID)b[3] & 0x000000ff;
- i |= (((ID)b[2]) << 8) & 0x0000ff00;
- i |= (((ID)b[1]) << 16) & 0x00ff0000;
- i |= ((ID)b[0]) << 24;
- return i;
+ ID i;
+ i = (ID)b[3] & 0x000000ff;
+ i |= (((ID)b[2]) << 8) & 0x0000ff00;
+ i |= (((ID)b[1]) << 16) & 0x00ff0000;
+ i |= ((ID)b[0]) << 24;
+ return i;
}
static void id_internal_to_stored(ID i,char *b)
{
- if ( sizeof(ID) > 4 ) {
- memset (b+4, 0, sizeof(ID)-4);
- }
+ if ( sizeof(ID) > 4 ) {
+ memset (b+4, 0, sizeof(ID)-4);
+ }
- b[0] = (char)(i >> 24);
- b[1] = (char)(i >> 16);
- b[2] = (char)(i >> 8);
- b[3] = (char)i;
+ b[0] = (char)(i >> 24);
+ b[1] = (char)(i >> 16);
+ b[2] = (char)(i >> 8);
+ b[3] = (char)i;
}
void _cl5ReadMod(char **buff)
{
- char *pos = *buff;
- uint32 i;
- uint32 val_count;
- char *type = NULL;
- int op;
-
- op = (*pos) & 0x000000FF;
- pos ++;
- _cl5ReadString (&type, &pos);
-
- /* need to do the copy first, to skirt around alignment problems on
- certain architectures */
- memcpy((char *)&val_count, pos, sizeof(val_count));
- val_count = ntohl(val_count);
- pos += sizeof (uint32);
-
- for (i = 0; i < val_count; i++)
- {
- print_ber_attr(type, &pos);
- }
+ char *pos = *buff;
+ uint32 i;
+ uint32 val_count;
+ char *type = NULL;
+ int op;
+
+ op = (*pos) & 0x000000FF;
+ pos ++;
+ _cl5ReadString (&type, &pos);
+
+ /* need to do the copy first, to skirt around alignment problems on
+ certain architectures */
+ memcpy((char *)&val_count, pos, sizeof(val_count));
+ val_count = ntohl(val_count);
+ pos += sizeof (uint32);
+
+ for (i = 0; i < val_count; i++)
+ {
+ print_ber_attr(type, &pos);
+ }
- (*buff) = pos;
- free(type);
+ (*buff) = pos;
+ free(type);
}
/*
@@ -427,93 +444,80 @@
*/
void print_changelog(unsigned char *data, int len)
{
- uint8_t version;
- unsigned long operation_type;
- char *pos = (char *)data;
- uint32 thetime32;
- time_t thetime;
- uint32 replgen;
-
- /* read byte of version */
- version = *((uint8_t *)pos);
- if (version != 5)
- {
- db_printf("Invalid changelog db version %i\nWorks for version 5 only.\n", version);
- exit(1);
- }
- pos += sizeof(version);
-
- /* read change type */
- operation_type = (unsigned long)(*(uint8_t *)pos);
- pos ++;
-
- /* need to do the copy first, to skirt around alignment problems on
- certain architectures */
- memcpy((char *)&thetime32, pos, sizeof(thetime32));
-
- replgen = ntohl(thetime32);
- pos += sizeof(uint32);
- thetime = (time_t)replgen;
- db_printf("\treplgen: %ld %s", replgen, ctime((time_t *)&thetime));
-
- /* read csn */
- print_attr("csn", &pos);
- /* read UniqueID */
- print_attr("uniqueid", &pos);
-
- /* figure out what else we need to read depending on the operation type */
- switch (operation_type)
- {
- case SLAPI_OPERATION_ADD:
- print_attr("parentuniqueid", &pos);
- print_attr("dn", &pos);
- /* convert mods to entry */
- db_printf("\toperation: add\n");
- _cl5ReadMods(&pos);
- break;
-
- case SLAPI_OPERATION_MODIFY:
- print_attr("dn", &pos);
- db_printf("\toperation: modify\n");
- _cl5ReadMods(&pos);
- break;
-
- case SLAPI_OPERATION_MODRDN:
- print_attr("dn", &pos);
- print_attr("newrdn", &pos);
- pos ++;
- print_attr("dn", &pos);
- print_attr("uniqueid", &pos);
- db_printf("\toperation: modrdn\n");
- _cl5ReadMods(&pos);
- break;
-
- case SLAPI_OPERATION_DELETE:
- print_attr("dn", &pos);
- db_printf("\toperation: delete\n");
- break;
-
- default:
- db_printf("Failed to format entry\n");
- break;
- }
-}
+ uint8_t version;
+ unsigned long operation_type;
+ char *pos = (char *)data;
+ uint32 thetime32;
+ time_t thetime;
+ uint32 replgen;
+
+ /* read byte of version */
+ version = *((uint8_t *)pos);
+ if (version != 5)
+ {
+ db_printf("Invalid changelog db version %i\nWorks for version 5 only.\n", version);
+ exit(1);
+ }
+ pos += sizeof(version);
-uint32 file_type = 0;
-uint32 min_display = 0;
-uint32 display_mode = 0;
-int verbose = 0;
-long pres_cnt = 0;
-long eq_cnt = 0;
-long app_cnt = 0;
-long sub_cnt = 0;
-long match_cnt = 0;
-long ind_cnt = 0;
-long allids_cnt = 0;
-long other_cnt = 0;
+ /* read change type */
+ operation_type = (unsigned long)(*(uint8_t *)pos);
+ pos ++;
+
+ /* need to do the copy first, to skirt around alignment problems on
+ certain architectures */
+ memcpy((char *)&thetime32, pos, sizeof(thetime32));
+
+ replgen = ntohl(thetime32);
+ pos += sizeof(uint32);
+ thetime = (time_t)replgen;
+ db_printf("\treplgen: %ld %s", replgen, ctime((time_t *)&thetime));
+
+ /* read csn */
+ print_attr("csn", &pos);
+ /* read UniqueID */
+ print_attr("uniqueid", &pos);
+
+ /* figure out what else we need to read depending on the operation type */
+ switch (operation_type)
+ {
+ case SLAPI_OPERATION_ADD:
+ print_attr("parentuniqueid", &pos);
+ print_attr("dn", &pos);
+ /* convert mods to entry */
+ db_printf("\toperation: add\n");
+ _cl5ReadMods(&pos);
+ break;
+ case SLAPI_OPERATION_MODIFY:
+ print_attr("dn", &pos);
+ db_printf("\toperation: modify\n");
+ _cl5ReadMods(&pos);
+ break;
-static void display_index_item(DBC *cursor, DBT *key, DBT *data)
+ case SLAPI_OPERATION_MODRDN:
+ print_attr("dn", &pos);
+ print_attr("newrdn", &pos);
+ pos ++;
+ print_attr("dn", &pos);
+ print_attr("uniqueid", &pos);
+ db_printf("\toperation: modrdn\n");
+ _cl5ReadMods(&pos);
+ break;
+
+ case SLAPI_OPERATION_DELETE:
+ print_attr("dn", &pos);
+ db_printf("\toperation: delete\n");
+ break;
+
+ default:
+ db_printf("Failed to format entry\n");
+ break;
+ }
+}
+
+static void display_index_item(DBC *cursor, DBT *key, DBT *data,
+ unsigned char *buf, int buflen)
{
IDL *idl = NULL;
int ret = 0;
@@ -527,9 +531,10 @@
if (file_type & VLVINDEXTYPE) { /* vlv index file */
if (1 > min_display) { /* recno is always 1 */
if (display_mode & SHOWCOUNT) { /* key size=1 */
- printf("%-40s 1\n", format(key->data, key->size));
+ printf("%-40s 1\n",
+ format(key->data, key->size, buf, buflen));
} else {
- printf("%-40s\n", format(key->data, key->size));
+ printf("%-40s\n", format(key->data, key->size, buf, buflen));
}
if (display_mode & SHOWDATA) {
cursor->c_get(cursor, key, data, DB_GET_RECNO);
@@ -558,17 +563,18 @@
if ( allids_cnt == 0 && (display_mode & SHOWSUMMARY)) {
printf("The following index keys reached allids:\n");
}
- printf("%-40s(allids)\n", format(key->data, key->size));
+ printf("%-40s(allids)\n", format(key->data, key->size, buf, buflen));
allids_cnt++;
} else {
if (idl->used < min_display) {
goto index_done; /* less than minimum display count */
} else if (display_mode & SHOWCOUNT) { /* key size */
- printf("%-40s%d\n", format(key->data, key->size), idl->used);
+ printf("%-40s%d\n",
+ format(key->data, key->size, buf, buflen), idl->used);
} else if (!(display_mode & SHOWSUMMARY) || (display_mode & SHOWDATA)) {
/* show keys only if show summary is not set or
- * even if it's set, but with show data */
- printf("%-40s\n", format(key->data, key->size));
+ * even if it's set, but with show data */
+ printf("%-40s\n", format(key->data, key->size, buf, buflen));
}
if (display_mode & SHOWDATA) {
char *formatted_idl = NULL;
@@ -632,26 +638,48 @@
static void display_item(DBC *cursor, DBT *key, DBT *data)
{
+ static unsigned char *buf = NULL;
+ static int buflen = 0;
+ int tmpbuflen;
+
+ if (truncatesiz > 0) {
+ tmpbuflen = truncatesiz;
+ } else if (file_type & INDEXTYPE) {
+ /* +256: extra buffer for '\t' and '%##' */
+ tmpbuflen = key->size + 256;
+ } else {
+ /* +1024: extra buffer for '\t' and '%##' */
+ tmpbuflen = (key->size > data->size ? key->size : data->size) + 1024;
+ }
+ if (buflen < tmpbuflen) {
+ buflen = tmpbuflen;
+ buf = (unsigned char *)realloc(buf, buflen);
+ if (NULL == buf) {
+ printf("\t(malloc failed -- %d bytes)\n", buflen);
+ return;
+ }
+ }
+
if (display_mode & RAWDATA) {
- printf("%s\n", format(key->data, key->size));
- printf("\t%s\n", format(data->data, data->size));
+ printf("%s\n", format(key->data, key->size, buf, buflen));
+ printf("\t%s\n", format(data->data, data->size, buf, buflen));
} else {
if (file_type & INDEXTYPE) {
- display_index_item(cursor, key, data);
+ display_index_item(cursor, key, data, buf, buflen);
} else if (file_type & CHANGELOGTYPE) {
- /* changelog db file */
- printf("\ndbid: %s\n", format(key->data, key->size));
+ /* changelog db file */
+ printf("\ndbid: %s\n", format(key->data, key->size, buf, buflen));
print_changelog(data->data, data->size);
return;
} else if (file_type & ENTRYTYPE) {
/* id2entry file */
ID entry_id = id_stored_to_internal(key->data);
printf("id %d\n", entry_id);
- printf("\t%s\n", format_entry(data->data, data->size));
+ printf("\t%s\n", format_entry(data->data, data->size, buf, buflen));
} else {
/* user didn't tell us what kind of file, dump it raw */
- printf("%s\n", format(key->data, key->size));
- printf("\t%s\n", format(data->data, data->size));
+ printf("%s\n", format(key->data, key->size, buf, buflen));
+ printf("\t%s\n", format(data->data, data->size, buf, buflen));
}
}
return;
@@ -704,6 +732,7 @@
printf(" common options:\n");
printf(" -f <filename> specify db file\n");
printf(" -R dump as raw data\n");
+ printf(" -t <size> entry truncate size (bytes)\n");
printf(" entry file options:\n");
printf(" -K <entry_id> lookup only a specific entry id\n");
printf(" index file options:\n");
@@ -743,7 +772,9 @@
uint32 entry_id = 0xffffffff;
int c;
- while ((c = getopt(argc, argv, "f:Rl:nG:srk:K:hv")) != EOF) {
+ key.flags = DB_DBT_REALLOC;
+ data.flags = DB_DBT_REALLOC;
+ while ((c = getopt(argc, argv, "f:Rl:nG:srk:K:hvt:")) != EOF) {
switch (c) {
case 'f':
filename = optarg;
@@ -782,7 +813,10 @@
find_key = optarg;
break;
case 'K':
- id_internal_to_stored((ID)atoi(optarg), (char *)&entry_id);
+ id_internal_to_stored((ID)atoi(optarg), (char *)&entry_id);
+ break;
+ case 't':
+ truncatesiz = atoi(optarg);
break;
case 'h':
default:
@@ -801,7 +835,7 @@
file_type |= INDEXTYPE;
if (0 == strncmp(filename, "vlv#", 4)) {
file_type |= VLVINDEXTYPE;
- }
+ }
}
ret = db_env_create(&env, 0);
@@ -907,37 +941,37 @@
if ( display_mode & SHOWSUMMARY) {
- if ( allids_cnt > 0 ) {
- printf("Index keys that reached ALLIDs threshold: %ld\n", allids_cnt);
- }
-
- if ( pres_cnt > 0 ) {
- printf("Presence index keys: %ld\n", pres_cnt);
- }
-
- if ( eq_cnt > 0 ) {
- printf("Equality index keys: %ld\n", eq_cnt);
- }
-
- if ( app_cnt > 0 ) {
- printf("Approximate index keys: %ld\n", app_cnt);
- }
-
- if ( sub_cnt > 0 ) {
- printf("Substring index keys: %ld\n", sub_cnt);
- }
-
- if ( match_cnt > 0 ) {
- printf("Match index keys: %ld\n", match_cnt);
- }
-
- if ( ind_cnt > 0 ) {
- printf("Indirect index keys: %ld\n", ind_cnt);
- }
-
- if ( other_cnt > 0 ) {
- printf("This file contains %ld number of unknown type ( possible corruption)\n",other_cnt);
- }
+ if ( allids_cnt > 0 ) {
+ printf("Index keys that reached ALLIDs threshold: %ld\n", allids_cnt);
+ }
+
+ if ( pres_cnt > 0 ) {
+ printf("Presence index keys: %ld\n", pres_cnt);
+ }
+
+ if ( eq_cnt > 0 ) {
+ printf("Equality index keys: %ld\n", eq_cnt);
+ }
+
+ if ( app_cnt > 0 ) {
+ printf("Approximate index keys: %ld\n", app_cnt);
+ }
+
+ if ( sub_cnt > 0 ) {
+ printf("Substring index keys: %ld\n", sub_cnt);
+ }
+
+ if ( match_cnt > 0 ) {
+ printf("Match index keys: %ld\n", match_cnt);
+ }
+
+ if ( ind_cnt > 0 ) {
+ printf("Indirect index keys: %ld\n", ind_cnt);
+ }
+
+ if ( other_cnt > 0 ) {
+ printf("This file contains %ld number of unknown type ( possible corruption)\n",other_cnt);
+ }
}
18 years, 7 months
[Fedora-directory-commits] ldapserver/ldap/servers/slapd/back-ldbm index.c, 1.7, 1.8
by Doctor Conrad
Author: nkinder
Update of /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv31167
Modified Files:
index.c
Log Message:
166012 - Use of incorrect iterator in indexing code was causing illegal access of memory which sometimes resulted in crashing.
Index: index.c
===================================================================
RCS file: /cvs/dirsec/ldapserver/ldap/servers/slapd/back-ldbm/index.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- index.c 12 Aug 2005 19:07:37 -0000 1.7
+++ index.c 15 Aug 2005 20:59:27 -0000 1.8
@@ -639,8 +639,12 @@
* removed.
*/
slapi_entry_attr_find( olde->ep_entry, mods[i]->mod_type, &curr_attr);
- if ( valuearray_find(curr_attr, evals, mods_valueArray[i]) == -1 ) {
- flags |= BE_INDEX_EQUALITY;
+ for (j = 0; mods_valueArray[j] != NULL; j++ ) {
+ if ( valuearray_find(curr_attr, evals, mods_valueArray[j]) == -1 ) {
+ if (!(flags & BE_INDEX_EQUALITY)) {
+ flags |= BE_INDEX_EQUALITY;
+ }
+ }
}
rc = index_addordel_values_sv( be, basetype,
18 years, 7 months