Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
OpenLDAP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Joe Martin
OpenLDAP
Commits
e1e8cf7e
Commit
e1e8cf7e
authored
14 years ago
by
Quanah Gibson-Mount
Browse files
Options
Downloads
Patches
Plain Diff
ITS#6598
parent
8732e85f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGES
+2
-1
2 additions, 1 deletion
CHANGES
contrib/slapd-modules/noopsrch/Makefile
+52
-0
52 additions, 0 deletions
contrib/slapd-modules/noopsrch/Makefile
contrib/slapd-modules/noopsrch/noopsrch.c
+255
-0
255 additions, 0 deletions
contrib/slapd-modules/noopsrch/noopsrch.c
with
309 additions
and
1 deletion
CHANGES
+
2
−
1
View file @
e1e8cf7e
OpenLDAP 2.4 Change Log
OpenLDAP 2.4.24 Engineering
Addes slapadd attribute value checking (ITS#6592)
Added contrib/noopsrch for entry counting (ITS#6598)
Added slapadd attribute value checking (ITS#6592)
Added slapd-null back-config support (ITS#6624)
Added slapd-sql autocommit support (ITS#6612)
Addes slapd-sql support for long long keys (ITS#6617)
...
...
This diff is collapsed.
Click to expand it.
contrib/slapd-modules/noopsrch/Makefile
0 → 100644
+
52
−
0
View file @
e1e8cf7e
# $OpenLDAP$
# This work is part of OpenLDAP Software <http://www.openldap.org/>.
#
# Copyright 1998-2010 The OpenLDAP Foundation.
# Copyright 2004 Howard Chu, Symas Corp. All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted only as authorized by the OpenLDAP
# Public License.
#
# A copy of this license is available in the file LICENSE in the
# top-level directory of the distribution or, alternatively, at
# <http://www.OpenLDAP.org/license.html>.
LIBTOOL
=
../../../libtool
OPT
=
-DSLAPD_OVER_NOOPSRCH
=
2
-g
-O2
#LIBTOOL=../../../../ldap-devel/libtool
#OPT=-DSLAPD_OVER_NOOPSRCH=2 -g -O0
CC
=
gcc
LDAP_INC
=
-I
../../../include
-I
../../../servers/slapd
#LDAP_INC=-I../../../include -I../../../servers/slapd -I../../../../ldap-devel/include
INCS
=
$(
LDAP_INC
)
LDAP_LIB
=
-lldap_r
-llber
LIBS
=
$(
LDAP_LIB
)
prefix
=
/usr/local
exec_prefix
=
$(
prefix
)
ldap_subdir
=
/openldap
libdir
=
$(
exec_prefix
)
/lib
libexecdir
=
$(
exec_prefix
)
/libexec
moduledir
=
$(
libexecdir
)$(
ldap_subdir
)
all
:
noopsrch.la
noopsrch.lo
:
noopsrch.c
$(
LIBTOOL
)
--mode
=
compile
$(
CC
)
$(
OPT
)
$(
DEFS
)
$(
INCS
)
-c
$?
noopsrch.la
:
noopsrch.lo
$(
LIBTOOL
)
--mode
=
link
$(
CC
)
$(
OPT
)
-version-info
0:0:0
\
-rpath
$(
moduledir
)
-module
-o
$@
$?
$(
LIBS
)
clean
:
rm
-f
noopsrch.lo noopsrch.la
install
:
noopsrch.la
mkdir
-p
$(
DESTDIR
)$(
moduledir
)
$(
LIBTOOL
)
--mode
=
install cp
noopsrch.la
$(
DESTDIR
)$(
moduledir
)
This diff is collapsed.
Click to expand it.
contrib/slapd-modules/noopsrch/noopsrch.c
0 → 100644
+
255
−
0
View file @
e1e8cf7e
/* noopsrch.c - LDAP Control that counts entries a search would return */
/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
* Copyright 2010 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted only as authorized by the OpenLDAP
* Public License.
*
* A copy of this license is available in the file LICENSE in the
* top-level directory of the distribution or, alternatively, at
* <http://www.OpenLDAP.org/license.html>.
*/
/* ACKNOWLEDGEMENTS:
* This work was initially developed by Pierangelo Masarati for inclusion
* in OpenLDAP Software.
*/
#include
"portable.h"
/* define SLAPD_OVER_NOOPSRCH=2 to build as run-time loadable module */
#ifdef SLAPD_OVER_NOOPSRCH
/*
* Control OID
*/
#define LDAP_CONTROL_X_NOOPSRCH "1.3.6.1.4.1.4203.666.5.18"
#include
"slap.h"
#include
"ac/string.h"
#define o_noopsrch o_ctrlflag[noopsrch_cid]
#define o_ctrlnoopsrch o_controls[noopsrch_cid]
static
int
noopsrch_cid
;
static
slap_overinst
noopsrch
;
static
int
noopsrch_parseCtrl
(
Operation
*
op
,
SlapReply
*
rs
,
LDAPControl
*
ctrl
)
{
if
(
op
->
o_noopsrch
!=
SLAP_CONTROL_NONE
)
{
rs
->
sr_text
=
"No-op Search control specified multiple times"
;
return
LDAP_PROTOCOL_ERROR
;
}
if
(
!
BER_BVISNULL
(
&
ctrl
->
ldctl_value
)
)
{
rs
->
sr_text
=
"No-op Search control value is present"
;
return
LDAP_PROTOCOL_ERROR
;
}
op
->
o_ctrlnoopsrch
=
(
void
*
)
NULL
;
op
->
o_noopsrch
=
ctrl
->
ldctl_iscritical
?
SLAP_CONTROL_CRITICAL
:
SLAP_CONTROL_NONCRITICAL
;
rs
->
sr_err
=
LDAP_SUCCESS
;
return
rs
->
sr_err
;
}
int
dummy
;
typedef
struct
noopsrch_cb_t
{
slap_overinst
*
nc_on
;
ber_int_t
nc_nentries
;
ber_int_t
nc_nsearchref
;
AttributeName
*
nc_save_attrs
;
int
*
nc_pdummy
;
int
nc_save_slimit
;
}
noopsrch_cb_t
;
static
int
noopsrch_response
(
Operation
*
op
,
SlapReply
*
rs
)
{
noopsrch_cb_t
*
nc
=
(
noopsrch_cb_t
*
)
op
->
o_callback
->
sc_private
;
/* if the control is global, limits are not computed yet */
if
(
nc
->
nc_pdummy
==
&
dummy
)
{
nc
->
nc_save_slimit
=
op
->
ors_slimit
;
op
->
ors_slimit
=
SLAP_NO_LIMIT
;
nc
->
nc_pdummy
=
NULL
;
}
if
(
rs
->
sr_type
==
REP_SEARCH
)
{
nc
->
nc_nentries
++
;
#ifdef NOOPSRCH_DEBUG
Debug
(
LDAP_DEBUG_TRACE
,
"noopsrch_response(REP_SEARCH): nentries=%d
\n
"
,
nc
->
nc_nentries
,
0
,
0
);
#endif
return
0
;
}
else
if
(
rs
->
sr_type
==
REP_SEARCHREF
)
{
nc
->
nc_nsearchref
++
;
return
0
;
}
else
if
(
rs
->
sr_type
==
REP_RESULT
)
{
BerElementBuffer
berbuf
;
BerElement
*
ber
=
(
BerElement
*
)
&
berbuf
;
struct
berval
ctrlval
;
LDAPControl
*
ctrl
,
*
ctrlsp
[
2
];
int
rc
=
rs
->
sr_err
;
if
(
nc
->
nc_save_slimit
>=
0
&&
nc
->
nc_nentries
>=
nc
->
nc_save_slimit
)
{
rc
=
LDAP_SIZELIMIT_EXCEEDED
;
}
#ifdef NOOPSRCH_DEBUG
Debug
(
LDAP_DEBUG_TRACE
,
"noopsrch_response(REP_RESULT): err=%d nentries=%d nref=%d
\n
"
,
rc
,
nc
->
nc_nentries
,
nc
->
nc_nsearchref
);
#endif
ber_init2
(
ber
,
NULL
,
LBER_USE_DER
);
ber_printf
(
ber
,
"{iii}"
,
rc
,
nc
->
nc_nentries
,
nc
->
nc_nsearchref
);
if
(
ber_flatten2
(
ber
,
&
ctrlval
,
0
)
==
-
1
)
{
ber_free_buf
(
ber
);
if
(
op
->
o_noopsrch
==
SLAP_CONTROL_CRITICAL
)
{
return
LDAP_CONSTRAINT_VIOLATION
;
}
return
SLAP_CB_CONTINUE
;
}
ctrl
=
op
->
o_tmpcalloc
(
1
,
sizeof
(
LDAPControl
)
+
ctrlval
.
bv_len
+
1
,
op
->
o_tmpmemctx
);
ctrl
->
ldctl_value
.
bv_val
=
(
char
*
)
&
ctrl
[
1
];
ctrl
->
ldctl_oid
=
LDAP_CONTROL_X_NOOPSRCH
;
ctrl
->
ldctl_iscritical
=
0
;
ctrl
->
ldctl_value
.
bv_len
=
ctrlval
.
bv_len
;
AC_MEMCPY
(
ctrl
->
ldctl_value
.
bv_val
,
ctrlval
.
bv_val
,
ctrlval
.
bv_len
);
ctrl
->
ldctl_value
.
bv_val
[
ctrl
->
ldctl_value
.
bv_len
]
=
'\0'
;
ber_free_buf
(
ber
);
ctrlsp
[
0
]
=
ctrl
;
ctrlsp
[
1
]
=
NULL
;
slap_add_ctrls
(
op
,
rs
,
ctrlsp
);
return
SLAP_CB_CONTINUE
;
}
}
static
int
noopsrch_cleanup
(
Operation
*
op
,
SlapReply
*
rs
)
{
if
(
rs
->
sr_type
==
REP_RESULT
||
rs
->
sr_err
==
SLAPD_ABANDON
)
{
noopsrch_cb_t
*
nc
=
(
noopsrch_cb_t
*
)
op
->
o_callback
->
sc_private
;
op
->
ors_attrs
=
nc
->
nc_save_attrs
;
if
(
nc
->
nc_pdummy
==
NULL
)
{
op
->
ors_slimit
=
nc
->
nc_save_slimit
;
}
op
->
o_tmpfree
(
op
->
o_callback
,
op
->
o_tmpmemctx
);
op
->
o_callback
=
NULL
;
}
return
SLAP_CB_CONTINUE
;
}
static
int
noopsrch_op_search
(
Operation
*
op
,
SlapReply
*
rs
)
{
if
(
op
->
o_noopsrch
!=
SLAP_CONTROL_NONE
)
{
slap_callback
*
sc
;
noopsrch_cb_t
*
nc
;
sc
=
op
->
o_tmpcalloc
(
1
,
sizeof
(
slap_callback
)
+
sizeof
(
noopsrch_cb_t
),
op
->
o_tmpmemctx
);
nc
=
(
noopsrch_cb_t
*
)
&
sc
[
1
];
nc
->
nc_on
=
(
slap_overinst
*
)
op
->
o_bd
->
bd_info
;
nc
->
nc_nentries
=
0
;
nc
->
nc_nsearchref
=
0
;
nc
->
nc_save_attrs
=
op
->
ors_attrs
;
nc
->
nc_pdummy
=
&
dummy
;
sc
->
sc_response
=
noopsrch_response
;
sc
->
sc_cleanup
=
noopsrch_cleanup
;
sc
->
sc_private
=
(
void
*
)
nc
;
op
->
ors_attrs
=
slap_anlist_no_attrs
;
sc
->
sc_next
=
op
->
o_callback
->
sc_next
;
op
->
o_callback
->
sc_next
=
sc
;
}
return
SLAP_CB_CONTINUE
;
}
static
int
noopsrch_cnt
;
static
int
noopsrch_db_init
(
BackendDB
*
be
,
ConfigReply
*
cr
)
{
if
(
noopsrch_cnt
++
==
0
)
{
int
rc
;
rc
=
register_supported_control
(
LDAP_CONTROL_X_NOOPSRCH
,
SLAP_CTRL_SEARCH
,
NULL
,
noopsrch_parseCtrl
,
&
noopsrch_cid
);
if
(
rc
!=
LDAP_SUCCESS
)
{
Debug
(
LDAP_DEBUG_ANY
,
"noopsrch_initialize: Failed to register control '%s' (%d)
\n
"
,
LDAP_CONTROL_X_NOOPSRCH
,
rc
,
0
);
return
rc
;
}
}
return
LDAP_SUCCESS
;
}
static
int
noopsrch_db_destroy
(
BackendDB
*
be
,
ConfigReply
*
cr
)
{
assert
(
noopsrch_cnt
>
0
);
#ifdef SLAP_CONFIG_DELETE
overlay_unregister_control
(
be
,
LDAP_CONTROL_X_NOOPSRCH
);
#endif
/* SLAP_CONFIG_DELETE */
if
(
--
noopsrch_cnt
==
0
)
{
unregister_supported_control
(
LDAP_CONTROL_X_NOOPSRCH
);
}
return
0
;
}
#if SLAPD_OVER_NOOPSRCH == SLAPD_MOD_DYNAMIC
static
#endif
/* SLAPD_OVER_NOOPSRCH == SLAPD_MOD_DYNAMIC */
int
noopsrch_initialize
(
void
)
{
noopsrch
.
on_bi
.
bi_type
=
"noopsrch"
;
noopsrch
.
on_bi
.
bi_db_init
=
noopsrch_db_init
;
noopsrch
.
on_bi
.
bi_db_destroy
=
noopsrch_db_destroy
;
noopsrch
.
on_bi
.
bi_op_search
=
noopsrch_op_search
;
return
overlay_register
(
&
noopsrch
);
}
#if SLAPD_OVER_NOOPSRCH == SLAPD_MOD_DYNAMIC
int
init_module
(
int
argc
,
char
*
argv
[]
)
{
return
noopsrch_initialize
();
}
#endif
/* SLAPD_OVER_NOOPSRCH == SLAPD_MOD_DYNAMIC */
#endif
/* SLAPD_OVER_NOOPSRCH */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment