Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Joe Martin
OpenLDAP
Commits
ddd1acc3
Commit
ddd1acc3
authored
Dec 13, 2017
by
Ondřej Kuzník
Committed by
Ondřej Kuzník
Nov 17, 2020
Browse files
Passing the client directly will allow clearing it from op
parent
1fd7249f
Changes
4
Hide whitespace changes
Inline
Side-by-side
servers/lloadd/bind.c
View file @
ddd1acc3
...
...
@@ -333,9 +333,12 @@ request_bind( LloadConnection *client, LloadOperation *op )
}
int
handle_bind_response
(
LloadOperation
*
op
,
BerElement
*
ber
)
handle_bind_response
(
LloadConnection
*
client
,
LloadOperation
*
op
,
BerElement
*
ber
)
{
LloadConnection
*
client
=
op
->
o_client
,
*
upstream
=
op
->
o_upstream
;
LloadConnection
*
upstream
=
op
->
o_upstream
;
BerValue
response
;
BerElement
*
copy
;
ber_int_t
result
;
...
...
@@ -407,14 +410,16 @@ done:
ber_free
(
ber
,
1
);
return
LDAP_SUCCESS
;
}
return
forward_final_response
(
op
,
ber
);
return
forward_final_response
(
client
,
op
,
ber
);
}
#ifdef LDAP_API_FEATURE_VERIFY_CREDENTIALS
int
handle_vc_bind_response
(
LloadOperation
*
op
,
BerElement
*
ber
)
handle_vc_bind_response
(
LloadConnection
*
client
,
LloadOperation
*
op
,
BerElement
*
ber
)
{
LloadConnection
*
c
=
op
->
o_client
;
BerElement
*
output
;
BerValue
matched
,
diagmsg
,
creds
=
BER_BVNULL
,
controls
=
BER_BVNULL
;
ber_int_t
result
;
...
...
@@ -447,16 +452,16 @@ handle_vc_bind_response( LloadOperation *op, BerElement *ber )
"connid=%lu, result=%d
\n
"
,
op
->
o_client_msgid
,
op
->
o_client_connid
,
result
);
CONNECTION_LOCK
(
c
);
CONNECTION_LOCK
(
c
lient
);
if
(
tag
==
LDAP_TAG_EXOP_VERIFY_CREDENTIALS_COOKIE
)
{
if
(
!
BER_BVISNULL
(
&
c
->
c_vc_cookie
)
)
{
ber_memfree
(
c
->
c_vc_cookie
.
bv_val
);
if
(
!
BER_BVISNULL
(
&
c
lient
->
c_vc_cookie
)
)
{
ber_memfree
(
c
lient
->
c_vc_cookie
.
bv_val
);
}
tag
=
ber_scanf
(
ber
,
"o"
,
&
c
->
c_vc_cookie
);
tag
=
ber_scanf
(
ber
,
"o"
,
&
c
lient
->
c_vc_cookie
);
if
(
tag
==
LBER_ERROR
)
{
rc
=
-
1
;
CONNECTION_UNLOCK_INCREF
(
c
);
CONNECTION_UNLOCK_INCREF
(
c
lient
);
goto
done
;
}
tag
=
ber_peek_tag
(
ber
,
&
len
);
...
...
@@ -466,7 +471,7 @@ handle_vc_bind_response( LloadOperation *op, BerElement *ber )
tag
=
ber_scanf
(
ber
,
"m"
,
&
creds
);
if
(
tag
==
LBER_ERROR
)
{
rc
=
-
1
;
CONNECTION_UNLOCK_INCREF
(
c
);
CONNECTION_UNLOCK_INCREF
(
c
lient
);
goto
done
;
}
tag
=
ber_peek_tag
(
ber
,
&
len
);
...
...
@@ -476,51 +481,51 @@ handle_vc_bind_response( LloadOperation *op, BerElement *ber )
tag
=
ber_scanf
(
ber
,
"m"
,
&
controls
);
if
(
tag
==
LBER_ERROR
)
{
rc
=
-
1
;
CONNECTION_UNLOCK_INCREF
(
c
);
CONNECTION_UNLOCK_INCREF
(
c
lient
);
goto
done
;
}
}
if
(
c
->
c_state
==
LLOAD_C_BINDING
)
{
if
(
c
lient
->
c_state
==
LLOAD_C_BINDING
)
{
switch
(
result
)
{
case
LDAP_SASL_BIND_IN_PROGRESS
:
break
;
case
LDAP_SUCCESS
:
default:
{
c
->
c_state
=
LLOAD_C_READY
;
c
->
c_type
=
LLOAD_C_OPEN
;
c
lient
->
c_state
=
LLOAD_C_READY
;
c
lient
->
c_type
=
LLOAD_C_OPEN
;
if
(
result
!=
LDAP_SUCCESS
)
{
ber_memfree
(
c
->
c_auth
.
bv_val
);
BER_BVZERO
(
&
c
->
c_auth
);
ber_memfree
(
c
lient
->
c_auth
.
bv_val
);
BER_BVZERO
(
&
c
lient
->
c_auth
);
}
else
if
(
!
ber_bvstrcasecmp
(
&
c
->
c_auth
,
&
lloadd_identity
)
)
{
c
->
c_type
=
LLOAD_C_PRIVILEGED
;
&
c
lient
->
c_auth
,
&
lloadd_identity
)
)
{
c
lient
->
c_type
=
LLOAD_C_PRIVILEGED
;
}
if
(
!
BER_BVISNULL
(
&
c
->
c_vc_cookie
)
)
{
ber_memfree
(
c
->
c_vc_cookie
.
bv_val
);
BER_BVZERO
(
&
c
->
c_vc_cookie
);
if
(
!
BER_BVISNULL
(
&
c
lient
->
c_vc_cookie
)
)
{
ber_memfree
(
c
lient
->
c_vc_cookie
.
bv_val
);
BER_BVZERO
(
&
c
lient
->
c_vc_cookie
);
}
if
(
!
BER_BVISNULL
(
&
c
->
c_sasl_bind_mech
)
)
{
ber_memfree
(
c
->
c_sasl_bind_mech
.
bv_val
);
BER_BVZERO
(
&
c
->
c_sasl_bind_mech
);
if
(
!
BER_BVISNULL
(
&
c
lient
->
c_sasl_bind_mech
)
)
{
ber_memfree
(
c
lient
->
c_sasl_bind_mech
.
bv_val
);
BER_BVZERO
(
&
c
lient
->
c_sasl_bind_mech
);
}
break
;
}
}
}
else
{
assert
(
c
->
c_state
==
LLOAD_C_INVALID
||
c
->
c_state
==
LLOAD_C_CLOSING
);
assert
(
c
lient
->
c_state
==
LLOAD_C_INVALID
||
c
lient
->
c_state
==
LLOAD_C_CLOSING
);
}
CONNECTION_UNLOCK_INCREF
(
c
);
CONNECTION_UNLOCK_INCREF
(
c
lient
);
ldap_pvt_thread_mutex_lock
(
&
c
->
c_io_mutex
);
output
=
c
->
c_pendingber
;
ldap_pvt_thread_mutex_lock
(
&
c
lient
->
c_io_mutex
);
output
=
c
lient
->
c_pendingber
;
if
(
output
==
NULL
&&
(
output
=
ber_alloc
())
==
NULL
)
{
rc
=
-
1
;
ldap_pvt_thread_mutex_unlock
(
&
c
->
c_io_mutex
);
ldap_pvt_thread_mutex_unlock
(
&
c
lient
->
c_io_mutex
);
goto
done
;
}
c
->
c_pendingber
=
output
;
c
lient
->
c_pendingber
=
output
;
rc
=
ber_printf
(
output
,
"t{tit{eOOtO}tO}"
,
LDAP_TAG_MESSAGE
,
LDAP_TAG_MSGID
,
op
->
o_client_msgid
,
LDAP_RES_BIND
,
...
...
@@ -528,16 +533,16 @@ handle_vc_bind_response( LloadOperation *op, BerElement *ber )
LDAP_TAG_SASL_RES_CREDS
,
BER_BV_OPTIONAL
(
&
creds
),
LDAP_TAG_CONTROLS
,
BER_BV_OPTIONAL
(
&
controls
)
);
ldap_pvt_thread_mutex_unlock
(
&
c
->
c_io_mutex
);
ldap_pvt_thread_mutex_unlock
(
&
c
lient
->
c_io_mutex
);
if
(
rc
>=
0
)
{
connection_write_cb
(
-
1
,
0
,
c
);
connection_write_cb
(
-
1
,
0
,
c
lient
);
rc
=
0
;
}
done:
CONNECTION_LOCK_DECREF
(
c
);
CONNECTION_LOCK_DECREF
(
c
lient
);
operation_destroy_from_client
(
op
);
CONNECTION_UNLOCK_OR_DESTROY
(
c
);
CONNECTION_UNLOCK_OR_DESTROY
(
c
lient
);
ber_free
(
ber
,
1
);
return
rc
;
}
...
...
servers/lloadd/lload.h
View file @
ddd1acc3
...
...
@@ -148,7 +148,9 @@ struct LloadBackend {
LDAP_CIRCLEQ_ENTRY
(
LloadBackend
)
b_next
;
};
typedef
int
(
*
LloadOperationHandler
)(
LloadOperation
*
op
,
BerElement
*
ber
);
typedef
int
(
*
LloadOperationHandler
)(
LloadConnection
*
client
,
LloadOperation
*
op
,
BerElement
*
ber
);
typedef
int
(
*
RequestHandler
)(
LloadConnection
*
c
,
LloadOperation
*
op
);
typedef
struct
lload_exop_handlers_t
{
struct
berval
oid
;
...
...
servers/lloadd/proto-lload.h
View file @
ddd1acc3
...
...
@@ -50,8 +50,8 @@ LDAP_SLAPD_F (void) backends_destroy( void );
* bind.c
*/
LDAP_SLAPD_F
(
int
)
request_bind
(
LloadConnection
*
c
,
LloadOperation
*
op
);
LDAP_SLAPD_F
(
int
)
handle_bind_response
(
LloadOperation
*
op
,
BerElement
*
ber
);
LDAP_SLAPD_F
(
int
)
handle_vc_bind_response
(
LloadOperation
*
op
,
BerElement
*
ber
);
LDAP_SLAPD_F
(
int
)
handle_bind_response
(
LloadConnection
*
client
,
LloadOperation
*
op
,
BerElement
*
ber
);
LDAP_SLAPD_F
(
int
)
handle_vc_bind_response
(
LloadConnection
*
client
,
LloadOperation
*
op
,
BerElement
*
ber
);
/*
* client.c
...
...
@@ -151,8 +151,8 @@ LDAP_SLAPD_F (void) operations_timeout( evutil_socket_t s, short what, void *arg
/*
* upstream.c
*/
LDAP_SLAPD_F
(
int
)
forward_final_response
(
LloadOperation
*
op
,
BerElement
*
ber
);
LDAP_SLAPD_F
(
int
)
forward_response
(
LloadOperation
*
op
,
BerElement
*
ber
);
LDAP_SLAPD_F
(
int
)
forward_final_response
(
LloadConnection
*
client
,
LloadOperation
*
op
,
BerElement
*
ber
);
LDAP_SLAPD_F
(
int
)
forward_response
(
LloadConnection
*
client
,
LloadOperation
*
op
,
BerElement
*
ber
);
LDAP_SLAPD_F
(
LloadConnection
*
)
upstream_init
(
ber_socket_t
s
,
LloadBackend
*
b
);
LDAP_SLAPD_F
(
void
)
upstream_destroy
(
LloadConnection
*
c
);
...
...
servers/lloadd/upstream.c
View file @
ddd1acc3
...
...
@@ -25,9 +25,8 @@
#include
"lload.h"
int
forward_response
(
LloadOperation
*
op
,
BerElement
*
ber
)
forward_response
(
LloadConnection
*
client
,
LloadOperation
*
op
,
BerElement
*
ber
)
{
LloadConnection
*
c
=
op
->
o_client
;
BerElement
*
output
;
BerValue
response
,
controls
=
BER_BVNULL
;
ber_tag_t
tag
,
response_tag
;
...
...
@@ -45,29 +44,32 @@ forward_response( LloadOperation *op, BerElement *ber )
lload_msgtype2str
(
response_tag
),
op
->
o_client_connid
,
op
->
o_client_msgid
);
ldap_pvt_thread_mutex_lock
(
&
c
->
c_io_mutex
);
output
=
c
->
c_pendingber
;
ldap_pvt_thread_mutex_lock
(
&
c
lient
->
c_io_mutex
);
output
=
c
lient
->
c_pendingber
;
if
(
output
==
NULL
&&
(
output
=
ber_alloc
())
==
NULL
)
{
ber_free
(
ber
,
1
);
ldap_pvt_thread_mutex_unlock
(
&
c
->
c_io_mutex
);
ldap_pvt_thread_mutex_unlock
(
&
c
lient
->
c_io_mutex
);
return
-
1
;
}
c
->
c_pendingber
=
output
;
c
lient
->
c_pendingber
=
output
;
ber_printf
(
output
,
"t{titOtO}"
,
LDAP_TAG_MESSAGE
,
LDAP_TAG_MSGID
,
op
->
o_client_msgid
,
response_tag
,
&
response
,
LDAP_TAG_CONTROLS
,
BER_BV_OPTIONAL
(
&
controls
)
);
ldap_pvt_thread_mutex_unlock
(
&
c
->
c_io_mutex
);
ldap_pvt_thread_mutex_unlock
(
&
c
lient
->
c_io_mutex
);
ber_free
(
ber
,
1
);
connection_write_cb
(
-
1
,
0
,
c
);
connection_write_cb
(
-
1
,
0
,
c
lient
);
return
0
;
}
int
forward_final_response
(
LloadOperation
*
op
,
BerElement
*
ber
)
forward_final_response
(
LloadConnection
*
client
,
LloadOperation
*
op
,
BerElement
*
ber
)
{
int
rc
;
...
...
@@ -75,7 +77,7 @@ forward_final_response( LloadOperation *op, BerElement *ber )
"connid=%lu msgid=%d finishing up with a request for "
"client connid=%lu
\n
"
,
op
->
o_upstream_connid
,
op
->
o_upstream_msgid
,
op
->
o_client_connid
);
rc
=
forward_response
(
op
,
ber
);
rc
=
forward_response
(
client
,
op
,
ber
);
CONNECTION_LOCK_DECREF
(
op
->
o_upstream
);
operation_destroy_from_upstream
(
op
);
CONNECTION_UNLOCK_INCREF
(
op
->
o_upstream
);
...
...
@@ -223,7 +225,7 @@ handle_one_response( LloadConnection *c )
ldap_pvt_thread_mutex_unlock
(
&
op
->
o_link_mutex
);
if
(
client
)
{
rc
=
handler
(
op
,
ber
);
rc
=
handler
(
client
,
op
,
ber
);
CONNECTION_LOCK_DECREF
(
client
);
op
->
o_client_refcnt
--
;
if
(
!
op
->
o_client_refcnt
)
{
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment