summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorShekhar Amlekar <samlekar@in.ibm.com>2013-09-10 10:39:03 +0530
committerJeremy Allison <jra@samba.org>2013-09-10 11:32:27 -0700
commit340f7f125db0d08ae47620e1c90a3dcd20201487 (patch)
treee9fde580f9ef3a57b50d25a36d12fdcaa4501b9f /source3
parentf942d019d183f2f6acb7c9a93f0128d22ba93b7a (diff)
downloadsamba-340f7f125db0d08ae47620e1c90a3dcd20201487.tar.gz
samba-340f7f125db0d08ae47620e1c90a3dcd20201487.tar.bz2
samba-340f7f125db0d08ae47620e1c90a3dcd20201487.zip
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 <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/session.c19
1 files changed, 19 insertions, 0 deletions
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);