Use new session entry points to get remote and user rather than dereference
the DCB directly.
This commit is contained in:
@ -730,4 +730,17 @@ bool session_route_query (
|
|||||||
return_succp:
|
return_succp:
|
||||||
return succp;
|
return succp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the username of the user connected to the client side of the
|
||||||
|
* session.
|
||||||
|
*
|
||||||
|
* @param session The session pointer.
|
||||||
|
* @return The user name or NULL if it can not be determined.
|
||||||
|
*/
|
||||||
|
char *
|
||||||
|
session_getUser(SESSION *session)
|
||||||
|
{
|
||||||
|
return (session && session->client) ? session->client->user : NULL;
|
||||||
|
}
|
||||||
|
@ -150,6 +150,7 @@ bool session_free(SESSION *);
|
|||||||
int session_isvalid(SESSION *);
|
int session_isvalid(SESSION *);
|
||||||
int session_reply(void *inst, void *session, GWBUF *data);
|
int session_reply(void *inst, void *session, GWBUF *data);
|
||||||
char *session_get_remote(SESSION *);
|
char *session_get_remote(SESSION *);
|
||||||
|
char *session_getUser(SESSION *);
|
||||||
void printAllSessions();
|
void printAllSessions();
|
||||||
void printSession(SESSION *);
|
void printSession(SESSION *);
|
||||||
void dprintAllSessions(struct dcb *);
|
void dprintAllSessions(struct dcb *);
|
||||||
|
@ -270,11 +270,8 @@ char *remote, *userName;
|
|||||||
if (strcmp(remote, my_instance->source))
|
if (strcmp(remote, my_instance->source))
|
||||||
my_session->active = 0;
|
my_session->active = 0;
|
||||||
}
|
}
|
||||||
if (session && session->client && session->client->user)
|
userName = session_getUser(session);
|
||||||
userName = session->client->user;
|
if (my_instance->userName && userName && strcmp(userName,
|
||||||
else
|
|
||||||
userName = NULL;
|
|
||||||
if (my_instance->userName && strcmp(userName,
|
|
||||||
my_instance->userName))
|
my_instance->userName))
|
||||||
my_session->active = 0;
|
my_session->active = 0;
|
||||||
sprintf(my_session->filename, "%s.%d", my_instance->filebase,
|
sprintf(my_session->filename, "%s.%d", my_instance->filebase,
|
||||||
|
@ -218,7 +218,7 @@ newSession(FILTER *instance, SESSION *session)
|
|||||||
{
|
{
|
||||||
REGEX_INSTANCE *my_instance = (REGEX_INSTANCE *)instance;
|
REGEX_INSTANCE *my_instance = (REGEX_INSTANCE *)instance;
|
||||||
REGEX_SESSION *my_session;
|
REGEX_SESSION *my_session;
|
||||||
char *remote;
|
char *remote, *user;
|
||||||
|
|
||||||
if ((my_session = calloc(1, sizeof(REGEX_SESSION))) != NULL)
|
if ((my_session = calloc(1, sizeof(REGEX_SESSION))) != NULL)
|
||||||
{
|
{
|
||||||
@ -231,10 +231,9 @@ char *remote;
|
|||||||
if (strcmp(remote, my_instance->source))
|
if (strcmp(remote, my_instance->source))
|
||||||
my_session->active = 0;
|
my_session->active = 0;
|
||||||
}
|
}
|
||||||
if (my_instance->user
|
|
||||||
&& session && session->client && session->client->user
|
if (my_instance->user && (user = session_getUser(session))
|
||||||
&& strcmp(session->client->user,
|
&& strcmp(user, my_instance->user))
|
||||||
my_instance->user))
|
|
||||||
{
|
{
|
||||||
my_session->active = 0;
|
my_session->active = 0;
|
||||||
}
|
}
|
||||||
|
@ -274,6 +274,7 @@ newSession(FILTER *instance, SESSION *session)
|
|||||||
TOPN_INSTANCE *my_instance = (TOPN_INSTANCE *)instance;
|
TOPN_INSTANCE *my_instance = (TOPN_INSTANCE *)instance;
|
||||||
TOPN_SESSION *my_session;
|
TOPN_SESSION *my_session;
|
||||||
int i;
|
int i;
|
||||||
|
char *remote, *user;
|
||||||
|
|
||||||
if ((my_session = calloc(1, sizeof(TOPN_SESSION))) != NULL)
|
if ((my_session = calloc(1, sizeof(TOPN_SESSION))) != NULL)
|
||||||
{
|
{
|
||||||
@ -298,12 +299,12 @@ int i;
|
|||||||
my_session->total.tv_sec = 0;
|
my_session->total.tv_sec = 0;
|
||||||
my_session->total.tv_usec = 0;
|
my_session->total.tv_usec = 0;
|
||||||
my_session->current = NULL;
|
my_session->current = NULL;
|
||||||
if (session && session->client && session->client->remote)
|
if ((remote = session_get_remote(session)) != NULL)
|
||||||
my_session->clientHost = strdup(session->client->remote);
|
my_session->clientHost = strdup(remote);
|
||||||
else
|
else
|
||||||
my_session->clientHost = NULL;
|
my_session->clientHost = NULL;
|
||||||
if (session && session->client && session->client->user)
|
if ((user = session_getUser(session)) != NULL)
|
||||||
my_session->userName = strdup(session->client->user);
|
my_session->userName = strdup(user);
|
||||||
else
|
else
|
||||||
my_session->userName = NULL;
|
my_session->userName = NULL;
|
||||||
my_session->active = 1;
|
my_session->active = 1;
|
||||||
|
Reference in New Issue
Block a user