diff options
author | Shekhar Amlekar <samlekar@in.ibm.com> | 2013-09-10 11:58:07 +0530 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2013-09-10 11:32:46 -0700 |
commit | 69470a2efdf36f306292515c1ed596b576e95120 (patch) | |
tree | 506a1eb4da01532ef00a832356afea21c136346e | |
parent | 340f7f125db0d08ae47620e1c90a3dcd20201487 (diff) | |
download | samba-69470a2efdf36f306292515c1ed596b576e95120.tar.gz samba-69470a2efdf36f306292515c1ed596b576e95120.tar.xz samba-69470a2efdf36f306292515c1ed596b576e95120.zip |
s3:smbd/session: Added a routine find_sessions()
this routine builds a list of sessions from a
particular remote machine or user.
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
-rw-r--r-- | source3/smbd/proto.h | 2 | ||||
-rw-r--r-- | source3/smbd/session.c | 28 |
2 files changed, 30 insertions, 0 deletions
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 8b6987ec05b..54d6da0b4ce 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -1001,6 +1001,8 @@ bool session_init(void); bool session_claim(struct smbXsrv_session *session); void session_yield(struct smbXsrv_session *session); int list_sessions(TALLOC_CTX *mem_ctx, struct sessionid **session_list); +int find_sessions(TALLOC_CTX *mem_ctx, const char *username, + const char *machine, struct sessionid **session_list); /* The following definitions come from smbd/sesssetup.c */ diff --git a/source3/smbd/session.c b/source3/smbd/session.c index e4d68b4dead..4ddb856930d 100644 --- a/source3/smbd/session.c +++ b/source3/smbd/session.c @@ -184,3 +184,31 @@ int list_sessions(TALLOC_CTX *mem_ctx, struct sessionid **session_list) *session_list = sesslist.sessions; return sesslist.count; } + +/******************************************************************** +find the sessions that match the given username and machine +********************************************************************/ + +int find_sessions(TALLOC_CTX *mem_ctx, const char *username, + const char *machine, struct sessionid **session_list) +{ + struct session_list sesslist; + NTSTATUS status; + + sesslist.mem_ctx = mem_ctx; + sesslist.count = 0; + sesslist.filter_user = username; + sesslist.filter_machine = machine; + sesslist.sessions = NULL; + + status = sessionid_traverse_read(gather_sessioninfo, (void *)&sesslist); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(3, ("Session traverse failed: %s\n", nt_errstr(status))); + TALLOC_FREE(sesslist.sessions); + *session_list = NULL; + return 0; + } + + *session_list = sesslist.sessions; + return sesslist.count; +} |