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
Oren Tirosh
OpenLDAP
Commits
b26ecba0
Commit
b26ecba0
authored
22 years ago
by
Pierangelo Masarati
Browse files
Options
Downloads
Patches
Plain Diff
- allow interactive pagedResults size change
- implement pagedResults abandon by setting size=0 - misc code cleanup
parent
acab9b32
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
clients/tools/ldapsearch.c
+33
-9
33 additions, 9 deletions
clients/tools/ldapsearch.c
servers/slapd/back-bdb/search.c
+10
-11
10 additions, 11 deletions
servers/slapd/back-bdb/search.c
servers/slapd/controls.c
+1
-1
1 addition, 1 deletion
servers/slapd/controls.c
with
44 additions
and
21 deletions
clients/tools/ldapsearch.c
+
33
−
9
View file @
b26ecba0
...
...
@@ -181,7 +181,7 @@ static int use_tls = 0;
static
char
*
sortattr
=
NULL
;
static
int
verbose
,
not
,
includeufn
,
vals2tmp
,
ldif
;
#ifdef LDAP_CONTROL_PAGEDRESULTS
static
int
pageSize
;
static
int
pageSize
=
0
;
static
ber_int_t
searchControlSize
=
0
;
static
ber_int_t
morePagedResults
=
1
;
static
struct
berval
cookie
=
{
0
,
NULL
};
...
...
@@ -222,7 +222,7 @@ main( int argc, char **argv )
#ifdef LDAP_CONTROL_PAGEDRESULTS
BerElement
*
pageber
=
NULL
;
struct
berval
*
bvalptr
=
NULL
;
int
num
=
0
,
moreEntries
,
searchControlCrit
=
0
;
int
num
=
0
,
searchControlCrit
=
0
;
#endif
/* LDAP_CONTROL_PAGEDRESULTS */
...
...
@@ -336,7 +336,7 @@ main( int argc, char **argv )
#ifdef LDAP_CONTROL_PAGEDRESULTS
}
else
if
(
strcasecmp
(
control
,
"pr"
)
==
0
)
{
/* PagedResults control */
if
(
searchControl
Size
!=
0
)
{
if
(
page
Size
!=
0
)
{
fprintf
(
stderr
,
"PagedResultsControl previously specified"
);
return
EXIT_FAILURE
;
}
...
...
@@ -1025,7 +1025,7 @@ main( int argc, char **argv )
#ifdef LDAP_CONTROL_PAGEDRESULTS
getNextPage:
if
(
manageDSAit
||
noop
||
valuesReturnFilter
||
searchControl
Size
)
{
if
(
manageDSAit
||
noop
||
valuesReturnFilter
||
page
Size
)
{
int
critical
=
0
;
#else
/* !LDAP_CONTROL_PAGEDRESULTS */
if
(
manageDSAit
||
noop
||
valuesReturnFilter
)
{
...
...
@@ -1119,7 +1119,7 @@ getNextPage:
}
#ifdef LDAP_CONTROL_PAGEDRESULTS
if
(
searchControl
Size
)
{
if
(
page
Size
)
{
if
((
pageber
=
ber_alloc_t
(
LBER_USE_DER
))
==
NULL
)
{
return
EXIT_FAILURE
;
}
...
...
@@ -1227,6 +1227,11 @@ getNextPage:
printf
(
"
\n
# with valuesReturnFilter %scontrol: %s"
,
valuesReturnFilter
>
1
?
"critical "
:
""
,
vrFilter
);
}
if
(
pageSize
)
{
printf
(
"
\n
# with pagedResults %scontrol: size=%d"
,
searchControlCrit
?
"critical "
:
""
,
searchControlSize
);
}
printf
(
"
\n
#
\n\n
"
);
}
...
...
@@ -1254,16 +1259,35 @@ getNextPage:
}
#ifdef LDAP_CONTROL_PAGEDRESULTS
if
(
(
searchControlSize
!=
0
)
&&
(
morePagedResults
!=
0
)
)
{
if
(
(
pageSize
!=
0
)
&&
(
morePagedResults
!=
0
)
)
{
char
buf
[
6
];
int
i
,
moreEntries
,
tmpSize
;
/* Loop to get the next pages when
* enter is pressed on the terminal.
*/
printf
(
"Press Enter for the next %d entries.
\n
"
,
printf
(
"Press
[size]
Enter for the next
{
%d
|size}
entries.
\n
"
,
(
int
)
searchControlSize
);
i
=
0
;
moreEntries
=
getchar
();
while
(
moreEntries
!=
EOF
&&
moreEntries
!=
'\n'
)
{
if
(
i
<
sizeof
(
buf
)
-
1
)
{
buf
[
i
]
=
moreEntries
;
i
++
;
}
moreEntries
=
getchar
();
}
buf
[
i
]
=
'\0'
;
if
(
i
>
0
&&
isdigit
(
buf
[
0
]
)
)
{
num
=
sscanf
(
buf
,
"%d"
,
&
tmpSize
);
if
(
num
!=
1
)
{
fprintf
(
stderr
,
"Invalid value for PagedResultsControl, %s.
\n
"
,
buf
);
return
EXIT_FAILURE
;
}
searchControlSize
=
(
ber_int_t
)
tmpSize
;
}
goto
getNextPage
;
}
...
...
@@ -1383,7 +1407,7 @@ static int dosearch(
case
LDAP_RES_SEARCH_RESULT
:
rc
=
print_result
(
ld
,
msg
,
1
);
#ifdef LDAP_CONTROL_PAGEDRESULTS
if
(
searchControl
Size
!=
0
)
{
if
(
page
Size
!=
0
)
{
rc
=
parse_page_control
(
ld
,
msg
,
&
cookie
);
}
#endif
/* LDAP_CONTROL_PAGEDRESULTS */
...
...
@@ -1401,7 +1425,7 @@ static int dosearch(
done:
#ifdef LDAP_CONTROL_PAGEDRESULTS
if
(
searchControl
Size
==
0
)
{
if
(
page
Size
==
0
)
{
if
(
ldif
<
2
)
{
printf
(
"
\n
# numResponses: %d
\n
"
,
nresponses
);
if
(
nentries
)
printf
(
"# numEntries: %d
\n
"
,
nentries
);
...
...
This diff is collapsed.
Click to expand it.
servers/slapd/back-bdb/search.c
+
10
−
11
View file @
b26ecba0
...
...
@@ -358,6 +358,12 @@ dn2entry_retry:
if
(
op
->
o_pagedresults_state
.
ps_cookie
==
0
)
{
id
=
0
;
}
else
{
if
(
op
->
o_pagedresults_size
==
0
)
{
send_search_result
(
conn
,
op
,
LDAP_SUCCESS
,
NULL
,
"search abandoned by pagedResult size=0"
,
NULL
,
NULL
,
0
);
goto
done
;
}
for
(
id
=
bdb_idl_first
(
candidates
,
&
cursor
);
id
!=
NOID
&&
id
<=
(
ID
)(
op
->
o_pagedresults_state
.
ps_cookie
);
id
=
bdb_idl_next
(
candidates
,
&
cursor
)
);
...
...
@@ -1114,20 +1120,13 @@ send_pagerequest_response(
respcookie
=
(
PagedResultsCookie
)
lastid
;
conn
->
c_pagedresults_state
.
ps_cookie
=
respcookie
;
cookie
.
bv_len
=
sizeof
(
respcookie
);
#if 0
cookie.bv_val = ber_memalloc( sizeof( respcookie ) );
AC_MEMCPY( cookie.bv_val, &respcookie, sizeof( respcookie ) );
#else
cookie
.
bv_val
=
(
char
*
)
&
respcookie
;
#endif
/*
conn->c_pagedresults_state.ps_cookie = cookie.bv_val;
*/
/*
* FIXME: we should consider sending an estimate of the entries
* left, after appropriate security check is done
*/
ber_printf
(
ber
,
"{iO}"
,
0
,
&
cookie
);
#if 0
ber_memfree( cookie.bv_val );
#endif
if
(
ber_flatten
(
ber
,
&
bvalp
)
==
LBER_ERROR
)
{
goto
done
;
...
...
This diff is collapsed.
Click to expand it.
servers/slapd/controls.c
+
1
−
1
View file @
b26ecba0
...
...
@@ -518,7 +518,7 @@ static int parsePagedResults (
return
LDAP_PROTOCOL_ERROR
;
}
if
(
size
<
=
0
)
{
if
(
size
<
0
)
{
*
text
=
"paged results control size invalid"
;
return
LDAP_PROTOCOL_ERROR
;
}
...
...
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