Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
openldap
OpenLDAP
Commits
40913816
Commit
40913816
authored
Feb 28, 2000
by
Kurt Zeilenga
Browse files
Yet another round of SLAPD_SCHEMA_NOT_COMPAT changes, including:
limited subtype support, modlist handling, filter updates, lastmod attribute handling.
parent
76553ea5
Changes
15
Hide whitespace changes
Inline
Side-by-side
servers/slapd/acl.c
View file @
40913816
...
...
@@ -713,12 +713,7 @@ acl_check_modlist(
}
for
(
i
=
0
;
mlist
->
sml_bvalues
[
i
]
!=
NULL
;
i
++
)
{
if
(
!
access_allowed
(
be
,
conn
,
op
,
e
,
#ifdef SLAPD_SCHEMA_NOT_COMPAT
&
mlist
->
sml_desc
,
#else
mlist
->
sml_type
,
#endif
mlist
->
sml_bvalues
[
i
],
ACL_WRITE
)
)
mlist
->
sml_desc
,
mlist
->
sml_bvalues
[
i
],
ACL_WRITE
)
)
{
return
(
0
);
}
...
...
@@ -728,12 +723,7 @@ acl_check_modlist(
case
LDAP_MOD_DELETE
:
if
(
mlist
->
sml_bvalues
==
NULL
)
{
if
(
!
access_allowed
(
be
,
conn
,
op
,
e
,
#ifdef SLAPD_SCHEMA_NOT_COMPAT
&
mlist
->
sml_desc
,
#else
mlist
->
sml_type
,
#endif
NULL
,
ACL_WRITE
)
)
mlist
->
sml_desc
,
NULL
,
ACL_WRITE
)
)
{
return
(
0
);
}
...
...
@@ -741,12 +731,7 @@ acl_check_modlist(
}
for
(
i
=
0
;
mlist
->
sml_bvalues
[
i
]
!=
NULL
;
i
++
)
{
if
(
!
access_allowed
(
be
,
conn
,
op
,
e
,
#ifdef SLAPD_SCHEMA_NOT_COMPAT
&
mlist
->
sml_desc
,
#else
mlist
->
sml_type
,
#endif
mlist
->
sml_bvalues
[
i
],
ACL_WRITE
)
)
mlist
->
sml_desc
,
mlist
->
sml_bvalues
[
i
],
ACL_WRITE
)
)
{
return
(
0
);
}
...
...
servers/slapd/ad.c
View file @
40913816
...
...
@@ -19,6 +19,25 @@
#include
"slap.h"
#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription
*
ad_dup
(
AttributeDescription
*
desc
)
{
AttributeDescription
*
ad
;
if
(
desc
==
NULL
)
{
return
NULL
;
}
ad
=
(
AttributeDescription
*
)
ch_malloc
(
sizeof
(
AttributeDescription
)
);
*
ad
=
*
desc
;
ad
->
ad_cname
=
ber_bvdup
(
ad
->
ad_cname
);
ad
->
ad_lang
=
ch_strdup
(
ad
->
ad_lang
);
return
ad
;
}
void
ad_free
(
AttributeDescription
*
ad
,
int
freeit
)
{
...
...
@@ -171,6 +190,29 @@ done:
return
rtn
;
}
int
is_ad_subtype
(
AttributeDescription
*
sub
,
AttributeDescription
*
super
)
{
if
(
!
is_at_subtype
(
sub
->
ad_type
,
super
->
ad_type
)
)
{
return
0
;
}
if
(
super
->
ad_flags
&&
(
super
->
ad_flags
==
sub
->
ad_flags
))
{
return
0
;
}
if
(
super
->
ad_lang
!=
NULL
&&
(
sub
->
ad_lang
==
NULL
||
strcasecmp
(
super
->
ad_lang
,
sub
->
ad_lang
)))
{
return
0
;
}
return
1
;
}
int
ad_inlist
(
AttributeDescription
*
desc
,
char
**
attrs
)
...
...
@@ -179,31 +221,17 @@ int ad_inlist(
for
(
i
=
0
;
attrs
[
i
]
!=
NULL
;
i
++
)
{
AttributeDescription
*
ad
=
NULL
;
char
*
text
;
int
rc
=
slap_str2ad
(
attrs
[
i
],
&
ad
,
&
text
);
if
(
rc
!=
LDAP_SUCCESS
)
{
goto
cont
;
}
int
rc
;
rc
=
slap_str2ad
(
attrs
[
i
],
&
ad
,
&
text
);
if
(
!
is_at_subtype
(
desc
->
ad_type
,
ad
->
ad_type
)
)
{
goto
cont
;
}
if
(
rc
!=
LDAP_SUCCESS
)
continue
;
if
(
ad
->
ad_flags
&&
(
ad
->
ad_flags
==
desc
->
ad_flags
))
{
goto
cont
;
}
if
(
ad
->
ad_lang
!=
NULL
&&
(
desc
->
ad_lang
==
NULL
||
strcasecmp
(
ad
->
ad_lang
,
desc
->
ad_lang
)))
{
goto
cont
;
}
rc
=
is_ad_subtype
(
desc
,
ad
);
ad_free
(
ad
,
1
);
return
1
;
cont:
ad_free
(
ad
,
1
);
if
(
rc
)
return
1
;
}
return
0
;
...
...
servers/slapd/add.c
View file @
40913816
...
...
@@ -306,8 +306,32 @@ static int slap_mods2entry(
Entry
**
e
,
char
**
text
)
{
*
text
=
"Not yet implemented"
;
return
LDAP_NOT_SUPPORTED
;
Attribute
**
tail
=
&
(
*
e
)
->
e_attrs
;
assert
(
*
tail
==
NULL
);
for
(
;
mods
!=
NULL
;
mods
=
mods
->
sml_next
)
{
Attribute
*
attr
;
assert
(
mods
->
sml_op
==
LDAP_MOD_ADD
);
attr
=
attr_find
(
(
*
e
)
->
e_attrs
,
mods
->
sml_desc
);
if
(
attr
!=
NULL
)
{
*
text
=
"Attribute provided more than once"
;
return
LDAP_OPERATIONS_ERROR
;
}
attr
=
ch_calloc
(
1
,
sizeof
(
Attribute
)
);
/* should check for duplicates */
attr
->
a_vals
=
mods
->
sml_bvalues
;
mods
->
sml_bvalues
=
NULL
;
*
tail
=
attr
;
tail
=
&
attr
->
a_next
;
}
return
LDAP_SUCCESS
;
}
#else
...
...
servers/slapd/attr.c
View file @
40913816
...
...
@@ -30,7 +30,7 @@ void
attr_free
(
Attribute
*
a
)
{
#ifdef SLAPD_SCHEMA_NOT_COMPAT
ad_free
(
&
a
->
a_desc
,
0
);
ad_free
(
a
->
a_desc
,
1
);
#else
free
(
a
->
a_type
);
#endif
...
...
@@ -79,9 +79,7 @@ Attribute *attr_dup( Attribute *a )
}
#ifdef SLAPD_SCHEMA_NOT_COMPAT
tmp
->
a_desc
=
a
->
a_desc
;
tmp
->
a_desc
.
ad_cname
=
ber_bvdup
(
a
->
a_desc
.
ad_cname
);
tmp
->
a_desc
.
ad_lang
=
ch_strdup
(
a
->
a_desc
.
ad_lang
);
tmp
->
a_desc
=
ad_dup
(
a
->
a_desc
);
#else
tmp
->
a_type
=
ch_strdup
(
a
->
a_type
);
tmp
->
a_syntax
=
a
->
a_syntax
;
...
...
@@ -210,6 +208,28 @@ attr_merge(
return
(
value_add
(
&
(
*
a
)
->
a_vals
,
vals
)
);
}
#ifdef SLAPD_SCHEMA_NOT_COMPAT
/*
* attrs_find - find attribute(s) by AttributeDescription
* returns next attribute which is subtype of provided description.
*/
Attribute
*
attrs_find
(
Attribute
*
a
,
AttributeDescription
*
desc
)
{
for
(
;
a
!=
NULL
;
a
=
a
->
a_next
)
{
if
(
is_ad_subtype
(
a
->
a_desc
,
desc
)
==
0
)
{
return
(
a
);
}
}
return
(
NULL
);
}
#endif
/*
* attr_find - find attribute by type
*/
...
...
@@ -226,12 +246,13 @@ attr_find(
{
for
(
;
a
!=
NULL
;
a
=
a
->
a_next
)
{
#ifdef SLAPD_SCHEMA_NOT_COMPAT
/* not yet implemented */
if
(
ad_cmp
(
a
->
a_desc
,
desc
)
==
0
)
#else
if
(
strcasecmp
(
a
->
a_type
,
type
)
==
0
)
{
if
(
strcasecmp
(
a
->
a_type
,
type
)
==
0
)
#endif
{
return
(
a
);
}
#endif
}
return
(
NULL
);
...
...
servers/slapd/back-ldbm/compare.c
View file @
40913816
...
...
@@ -94,30 +94,39 @@ ldbm_back_compare(
goto
return_results
;
}
rc
=
LDAP_NO_SUCH_ATTRIBUTE
;
#ifdef SLAPD_SCHEMA_NOT_COMPAT
if
(
(
a
=
attr_find
(
e
->
e_attrs
,
ava
->
aa_desc
))
==
NULL
)
for
(
a
=
attrs_find
(
e
->
e_attrs
,
ava
->
aa_desc
);
a
!=
NULL
;
a
=
attrs_find
(
a
,
ava
->
aa_desc
))
#else
if
(
(
a
=
attr_find
(
e
->
e_attrs
,
ava
->
ava_type
))
=
=
NULL
)
if
((
a
=
attr_find
(
e
->
e_attrs
,
ava
->
ava_type
))
!
=
NULL
)
#endif
{
send_ldap_result
(
conn
,
op
,
LDAP_NO_SUCH_ATTRIBUTE
,
NULL
,
NULL
,
NULL
,
NULL
);
rc
=
1
;
goto
return_results
;
}
rc
=
LDAP_COMPARE_FALSE
;
#ifdef SLAPD_SCHEMA_NOT_COMPAT
/* not yet implemented */
/* not yet implemented */
#else
if
(
value_find
(
a
->
a_vals
,
&
ava
->
ava_value
,
a
->
a_syntax
,
1
)
==
0
)
send_ldap_result
(
conn
,
op
,
LDAP_COMPARE_TRUE
,
NULL
,
NULL
,
NULL
,
NULL
);
else
if
(
value_find
(
a
->
a_vals
,
&
ava
->
ava_value
,
a
->
a_syntax
,
1
)
==
0
)
#endif
send_ldap_result
(
conn
,
op
,
LDAP_COMPARE_FALSE
,
NULL
,
NULL
,
NULL
,
NULL
);
{
rc
=
LDAP_COMPARE_TRUE
;
#ifdef SLAPD_SCHEMA_NOT_COMPAT
break
;
#endif
}
}
send_ldap_result
(
conn
,
op
,
rc
,
NULL
,
NULL
,
NULL
,
NULL
);
if
(
rc
!=
LDAP_NO_SUCH_ATTRIBUTE
)
{
rc
=
0
;
}
rc
=
0
;
return_results:
;
cache_return_entry_r
(
&
li
->
li_cache
,
e
);
...
...
servers/slapd/back-ldbm/external.h
View file @
40913816
...
...
@@ -92,9 +92,18 @@ extern ID ldbm_tool_entry_first LDAP_P(( BackendDB *be ));
extern
ID
ldbm_tool_entry_next
LDAP_P
((
BackendDB
*
be
));
extern
Entry
*
ldbm_tool_entry_get
LDAP_P
((
BackendDB
*
be
,
ID
id
));
extern
ID
ldbm_tool_entry_put
LDAP_P
((
BackendDB
*
be
,
Entry
*
e
));
#ifdef SLAPD_SCHEMA_NOT_COMPAT
extern
int
ldbm_tool_index_attr
LDAP_P
((
BackendDB
*
be
,
AttributeDescription
*
desc
));
extern
int
ldbm_tool_index_change
LDAP_P
((
BackendDB
*
be
,
AttributeDescription
*
desc
,
struct
berval
**
bv
,
ID
id
,
int
op
));
#else
extern
int
ldbm_tool_index_attr
LDAP_P
((
BackendDB
*
be
,
char
*
type
));
extern
int
ldbm_tool_index_change
LDAP_P
((
BackendDB
*
be
,
char
*
type
,
struct
berval
**
bv
,
ID
id
,
int
op
));
#endif
extern
int
ldbm_tool_sync
LDAP_P
((
BackendDB
*
be
));
...
...
servers/slapd/back-ldbm/tools.c
View file @
40913816
...
...
@@ -194,35 +194,21 @@ ID ldbm_tool_entry_put(
int
ldbm_tool_index_attr
(
BackendDB
*
be
,
char
*
type
)
#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription
*
desc
#else
char
*
type
#endif
)
{
static
DBCache
*
db
=
NULL
;
int
indexmask
;
char
*
at_cn
;
#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeType
*
at
;
#endif
assert
(
slapMode
&
SLAP_TOOL_MODE
);
#ifdef SLAPD_SCHEMA_NOT_COMPAT
at
=
at_find
(
type
);
if
(
at
==
NULL
)
{
Debug
(
LDAP_DEBUG_ANY
,
"<= index_attr NULL (could not find attribute type %s)
\n
"
,
type
,
0
,
0
);
return
0
;
}
at_cn
=
at_canonical_name
(
at
);
if
(
at_cn
==
NULL
)
{
Debug
(
LDAP_DEBUG_ANY
,
"<= index_attr NULL (attribute type %s (%s) has no canonical name)
\n
"
,
at
->
sat_oid
,
type
,
0
);
return
0
;
}
at_cn
=
desc
->
ad_cname
->
bv_val
;
#else
attr_normalize
(
type
);
at_cn
=
at_canonical_name
(
type
);
...
...
@@ -234,7 +220,7 @@ int ldbm_tool_index_attr(
return
0
;
}
#endif
assert
(
at_cn
!=
NULL
);
attr_mask
(
be
->
be_private
,
at_cn
,
&
indexmask
);
if
(
(
db
=
ldbm_cache_open
(
be
,
at_cn
,
LDBM_SUFFIX
,
LDBM_NEWDB
))
...
...
@@ -253,11 +239,19 @@ int ldbm_tool_index_attr(
int
ldbm_tool_index_change
(
BackendDB
*
be
,
#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription
*
desc
,
#else
char
*
type
,
#endif
struct
berval
**
bv
,
ID
id
,
int
op
)
{
#ifdef SLAPD_SCHEMA_NOT_COMPAT
char
*
type
=
desc
->
ad_cname
->
bv_val
;
#endif
assert
(
slapMode
&
SLAP_TOOL_MODE
);
index_change_values
(
be
,
...
...
servers/slapd/entry.c
View file @
40913816
...
...
@@ -201,14 +201,14 @@ entry2str(
for
(
i
=
0
;
a
->
a_vals
[
i
]
!=
NULL
;
i
++
)
{
bv
=
a
->
a_vals
[
i
];
#ifdef SLAPD_SCHEMA_NOT_COMPAT
tmplen
=
a
->
a_desc
.
ad_cname
->
bv_len
;
tmplen
=
a
->
a_desc
->
ad_cname
->
bv_len
;
#else
tmplen
=
strlen
(
a
->
a_type
);
#endif
MAKE_SPACE
(
LDIF_SIZE_NEEDED
(
tmplen
,
bv
->
bv_len
));
ldif_sput
(
(
char
**
)
&
ecur
,
LDIF_PUT_VALUE
,
#ifdef SLAPD_SCHEMA_NOT_COMPAT
a
->
a_desc
.
ad_cname
->
bv_val
,
a
->
a_desc
->
ad_cname
->
bv_val
,
#else
a
->
a_type
,
#endif
...
...
servers/slapd/filterentry.c
View file @
40913816
...
...
@@ -153,14 +153,16 @@ test_filter(
}
break
;
#ifdef SLAPD_EXT_FILTERS
case
LDAP_FILTER_EXT
:
Debug
(
LDAP_DEBUG_FILTER
,
" EXT
\n
"
,
0
,
0
,
0
);
#if SLAPD_SCHEMA_NOT_COMPAT
&& notyet
#if SLAPD_SCHEMA_NOT_COMPAT
rc
=
test_mra_filter
(
be
,
conn
,
op
,
e
,
f
->
f_mra
);
#else
rc
=
-
1
;
#endif
break
;
#endif
case
0
:
Debug
(
LDAP_DEBUG_FILTER
,
" UNDEFINED
\n
"
,
0
,
0
,
0
);
...
...
@@ -208,63 +210,52 @@ test_ava_filter(
}
#ifdef SLAPD_SCHEMA_NOT_COMPAT
if
(
(
a
=
attr_find
(
e
->
e_attrs
,
ava
->
aa_desc
))
==
NULL
)
for
(
a
=
attrs_find
(
e
->
e_attrs
,
ava
->
aa_desc
);
a
!=
NULL
;
a
=
attrs_find
(
a
,
ava
->
aa_desc
)
)
#else
if
(
(
a
=
attr_find
(
e
->
e_attrs
,
ava
->
ava_type
))
==
NULL
)
a
=
attr_find
(
e
->
e_attrs
,
ava
->
ava_type
);
if
(
a
!=
NULL
)
#endif
{
return
LDAP_COMPARE_FALSE
;
}
#ifdef SLAPD_SCHEMA_NOT_COMPAT
/* not yet implemented */
#else
if
(
a
->
a_syntax
==
0
)
{
a
->
a_syntax
=
attr_syntax
(
ava
->
ava_type
);
}
#ifndef SLAPD_SCHEMA_NOT_COMPAT
if
(
a
->
a_syntax
==
0
)
{
a
->
a_syntax
=
attr_syntax
(
ava
->
ava_type
);
}
#endif
for
(
i
=
0
;
a
->
a_vals
[
i
]
!=
NULL
;
i
++
)
{
#ifdef SLAPD_SCHEMA_NOT_COMPAT
int
rc
=
-
1
;
switch
(
type
)
{
case
LDAP_FILTER_EQUALITY
:
break
;
case
LDAP_FILTER_APPROX
:
break
;
case
LDAP_FILTER_GE
:
case
LDAP_FILTER_LE
:
break
;
}
for
(
i
=
0
;
a
->
a_vals
[
i
]
!=
NULL
;
i
++
)
{
int
rc
;
if
(
rc
==
LDAP_COMPARE_TRUE
)
return
LDAP_COMPARE_TRUE
;
#ifdef SLAPD_SCHEMA_NOT_COMPAT
/* not yet implemented */
rc
=
0
;
#else
int
rc
=
value_cmp
(
a
->
a_vals
[
i
],
&
ava
->
ava_value
,
a
->
a_syntax
,
3
);
rc
=
value_cmp
(
a
->
a_vals
[
i
],
&
ava
->
ava_value
,
a
->
a_syntax
,
3
);
#endif
switch
(
type
)
{
case
LDAP_FILTER_EQUALITY
:
case
LDAP_FILTER_APPROX
:
if
(
rc
==
0
)
{
return
LDAP_COMPARE_TRUE
;
}
break
;
switch
(
type
)
{
case
LDAP_FILTER_EQUALITY
:
case
LDAP_FILTER_APPROX
:
if
(
rc
==
0
)
{
return
LDAP_COMPARE_TRUE
;
}
break
;
case
LDAP_FILTER_GE
:
if
(
rc
>=
0
)
{
return
LDAP_COMPARE_TRUE
;
}
break
;
case
LDAP_FILTER_GE
:
if
(
rc
>=
0
)
{
return
LDAP_COMPARE_TRUE
;
}
break
;
case
LDAP_FILTER_LE
:
if
(
rc
<=
0
)
{
return
LDAP_COMPARE_TRUE
;
case
LDAP_FILTER_LE
:
if
(
rc
<=
0
)
{
return
LDAP_COMPARE_TRUE
;
}
break
;
}
break
;
}
#endif
}
return
(
LDAP_COMPARE_FALSE
);
...
...
@@ -280,31 +271,25 @@ test_presence_filter(
#ifdef SLAPD_SCHEMA_NOT_COMPAT
AttributeDescription
*
desc
#else
char
*
type
char
*
desc
#endif
)
{
#ifdef SLAPD_SCHEMA_NOT_COMPAT
if
(
be
!=
NULL
&&
!
access_allowed
(
be
,
conn
,
op
,
e
,
desc
,
NULL
,
ACL_SEARCH
)
)
#else
if
(
be
!=
NULL
&&
!
access_allowed
(
be
,
conn
,
op
,
e
,
type
,
NULL
,
ACL_SEARCH
)
)
#endif
{
return
(
-
2
);
}
#ifdef SLAPD_SCHEMA_NOT_COMPAT
return
attr_find
(
e
->
e_attrs
,
desc
)
!=
NULL
return
attr
s
_find
(
e
->
e_attrs
,
desc
)
!=
NULL
#else
return
attr_find
(
e
->
e_attrs
,
type
)
!=
NULL
return
attr_find
(
e
->
e_attrs
,
desc
)
!=
NULL
#endif
?
LDAP_COMPARE_TRUE
:
LDAP_COMPARE_FALSE
;
}
#ifndef SLAPD_SCHEMA_NOT_COMPAT
static
int
test_approx_filter
(
Backend
*
be
,
...
...
@@ -324,64 +309,62 @@ test_approx_filter(
return
(
-
2
);
}
if
(
(
a
=
attr_find
(
e
->
e_attrs
,
ava
->
ava_type
))
==
NULL
)
{
return
LDAP_COMPARE_FALSE
;
}
/* for each value in the attribute */
for
(
i
=
0
;
a
->
a_vals
[
i
]
!=
NULL
;
i
++
)
{
/*
* try to match words in the filter value in order
* in the attribute value.
*/
w2
=
a
->
a_vals
[
i
]
->
bv_val
;
/* for each word in the filter value */
for
(
w1
=
first_word
(
ava
->
ava_value
.
bv_val
);
w1
!=
NULL
;
w1
=
next_word
(
w1
)
)
{
if
(
(
c1
=
phonetic
(
w1
))
==
NULL
)
{
break
;
}
a
=
attr_find
(
e
->
e_attrs
,
ava
->
ava_type
);
if
(
a
!=
NULL
)
{
/* for each value in the attribute */
for
(
i
=
0
;
a
->
a_vals
[
i
]
!=
NULL
;
i
++
)
{
/*
*
for ea
ch word in the
attribu
te value
from
*
where we left off..
.
*
try to mat
ch word
s
in the
fil
te
r
value
in order
*
in the attribute value
.
*/
for
(
w2
=
first_word
(
w2
);
w2
!=
NULL
;
w2
=
next_word
(
w2
)
)
{
c2
=
phonetic
(
w2
);
if
(
strcmp
(
c1
,
c2
)
==
0
)
{
w2
=
a
->
a_vals
[
i
]
->
bv_val
;
/* for each word in the filter value */
for
(
w1
=
first_word
(
ava
->
ava_value
.
bv_val
);
w1
!=
NULL
;
w1
=
next_word
(
w1
)
)
{
if
(
(
c1
=
phonetic
(
w1
))
==
NULL
)
{
break
;
}
/*
* for each word in the attribute value from
* where we left off...
*/
for
(
w2
=
first_word
(
w2
);
w2
!=
NULL
;
w2
=
next_word
(
w2
)
)
{
c2
=
phonetic
(
w2
);
if
(
strcmp
(
c1
,
c2
)
==
0
)
{
free
(
c2
);
break
;
}
free
(
c2
);
}
free
(
c1
);
/*
* if we stopped because we ran out of words
* before making a match, go on to the next
* value. otherwise try to keep matching
* words in this value from where we left off.
*/
if
(
w2
==
NULL
)
{