From 340f7f125db0d08ae47620e1c90a3dcd20201487 Mon Sep 17 00:00:00 2001 From: Shekhar Amlekar Date: Tue, 10 Sep 2013 10:39:03 +0530 Subject: s3:smbd/session: add filters to gather_sessioninfo() added capability to filter sessions based on remote machine name and user name. Reviewed-by: Volker Lendecke Reviewed-by: Jeremy Allison --- source3/smbd/session.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'source3/smbd') diff --git a/source3/smbd/session.c b/source3/smbd/session.c index 01a8194d2f..e4d68b4dea 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -114,6 +114,8 @@ void session_yield(struct smbXsrv_session *session) struct session_list { TALLOC_CTX *mem_ctx; int count; + const char *filter_user; + const char *filter_machine; struct sessionid *sessions; }; @@ -122,6 +124,21 @@ static int gather_sessioninfo(const char *key, struct sessionid *session, { struct session_list *sesslist = (struct session_list *)private_data; + /* filter the session if required */ + + if (sesslist->filter_user && + (sesslist->filter_user[0] != '\0') && + !strequal(session->username, sesslist->filter_user)) { + return 0; + } + + if (sesslist->filter_machine && + (sesslist->filter_machine[0] != '\0') && + !strequal(session->remote_machine, + sesslist->filter_machine)) { + return 0; + } + sesslist->sessions = talloc_realloc( sesslist->mem_ctx, sesslist->sessions, struct sessionid, sesslist->count+1); @@ -152,6 +169,8 @@ int list_sessions(TALLOC_CTX *mem_ctx, struct sessionid **session_list) sesslist.mem_ctx = mem_ctx; sesslist.count = 0; + sesslist.filter_user = NULL; + sesslist.filter_machine = NULL; sesslist.sessions = NULL; status = sessionid_traverse_read(gather_sessioninfo, (void *) &sesslist); -- cgit