Skip to content

Commit

Permalink
WL#15524 Patch #1 "START TLS" for management API
Browse files Browse the repository at this point in the history
Post push fix.

Do not allow ndb_mgm_listen_event to return a socket that uses TLS since
user can not access the corresponding SSL object thorugh the public
MgmAPI.

Change-Id: I2a741efe4f80db750419101ecabb03fb5e025346
  • Loading branch information
zmur committed Aug 22, 2023
1 parent d3aea14 commit b604ade
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
7 changes: 4 additions & 3 deletions storage/ndb/src/mgmapi/mgmapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2464,7 +2464,7 @@ ndb_mgm_set_loglevel_node(NdbMgmHandle handle, int nodeId,

int
ndb_mgm_listen_event_internal(NdbMgmHandle handle, const int filter[],
int parsable, ndb_socket_t* sock)
int parsable, ndb_socket_t* sock, bool allow_tls)
{
DBUG_ENTER("ndb_mgm_listen_event_internal");
CHECK_HANDLE(handle, -1);
Expand Down Expand Up @@ -2561,7 +2561,7 @@ ndb_mgm_listen_event_internal(NdbMgmHandle handle, const int filter[],
ndb_mgm::handle_ptr tmp_handle(ndb_mgm_create_handle());
tmp_handle->socket.init_from_new(sockfd);

if(handle->ssl_ctx)
if(allow_tls && handle->ssl_ctx)
{
ndb_mgm_set_ssl_ctx(tmp_handle.get(), handle->ssl_ctx);
ndb_mgm_start_tls(tmp_handle.get());
Expand All @@ -2588,7 +2588,8 @@ socket_t
ndb_mgm_listen_event(NdbMgmHandle handle, const int filter[])
{
ndb_socket_t s;
if(ndb_mgm_listen_event_internal(handle,filter,0,&s)<0)
constexpr bool no_tls = false;
if(ndb_mgm_listen_event_internal(handle, filter, 0, &s, no_tls)<0)
ndb_socket_invalidate(&s);
return ndb_socket_get_native(s);
}
Expand Down
3 changes: 3 additions & 0 deletions storage/ndb/src/mgmapi/mgmapi_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,7 @@ ndb_mgm_get_configuration2(NdbMgmHandle handle,
enum ndb_mgm_node_type nodetype,
int from_node = 0);

int ndb_mgm_listen_event_internal(NdbMgmHandle, const int filter[], int,
ndb_socket_t*, bool allow_tls);

#endif
7 changes: 2 additions & 5 deletions storage/ndb/src/mgmapi/ndb_logevent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@

#include "ndb_logevent.hpp"

extern
int ndb_mgm_listen_event_internal(NdbMgmHandle, const int filter[],
int, ndb_socket_t*);

struct ndb_logevent_error_msg {
enum ndb_logevent_handle_error code;
const char *msg;
Expand Down Expand Up @@ -87,7 +83,8 @@ ndb_mgm_create_logevent_handle(NdbMgmHandle mh,
return nullptr;

ndb_socket_t sock;
if(ndb_mgm_listen_event_internal(mh, filter, 1, &sock) < 0)
constexpr bool allow_tls = true;
if(ndb_mgm_listen_event_internal(mh, filter, 1, &sock, allow_tls) < 0)
{
free(h);
return nullptr;
Expand Down

0 comments on commit b604ade

Please sign in to comment.