svn commit: samba r8574 - in branches/SAMBA_4_0/source: librpc/idl
smb_server
tridge at samba.org
tridge at samba.org
Tue Jul 19 03:58:45 GMT 2005
Author: tridge
Date: 2005-07-19 03:58:44 +0000 (Tue, 19 Jul 2005)
New Revision: 8574
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=8574
Log:
added server side irpc calls for listing the current sessions
Added:
branches/SAMBA_4_0/source/smb_server/management.c
Modified:
branches/SAMBA_4_0/source/librpc/idl/irpc.idl
branches/SAMBA_4_0/source/smb_server/config.mk
branches/SAMBA_4_0/source/smb_server/session.c
branches/SAMBA_4_0/source/smb_server/smb_server.c
branches/SAMBA_4_0/source/smb_server/smb_server.h
Changeset:
Modified: branches/SAMBA_4_0/source/librpc/idl/irpc.idl
===================================================================
--- branches/SAMBA_4_0/source/librpc/idl/irpc.idl 2005-07-19 03:54:01 UTC (rev 8573)
+++ branches/SAMBA_4_0/source/librpc/idl/irpc.idl 2005-07-19 03:58:44 UTC (rev 8574)
@@ -47,4 +47,34 @@
[out,switch_is(level)] nbtd_info info
);
+
+ /******************************************************
+ management calls for the smb server
+ ******************************************************/
+ typedef [v1_enum] enum {
+ SMBSRV_INFO_SESSIONS
+ } smbsrv_info_level;
+
+ typedef struct {
+ uint16 vuid;
+ astring account_name;
+ astring domain_name;
+ astring client_ip;
+ NTTIME connect_time;
+ } smbsrv_session_info;
+
+ typedef struct {
+ uint32 num_sessions;
+ [size_is(num_sessions)] smbsrv_session_info *sessions;
+ } smbsrv_sessions;
+
+ typedef union {
+ [case(SMBSRV_INFO_SESSIONS)] smbsrv_sessions sessions;
+ } smbsrv_info;
+
+ void smbsrv_information(
+ [in] smbsrv_info_level level,
+ [out,switch_is(level)] smbsrv_info info
+ );
+
}
Modified: branches/SAMBA_4_0/source/smb_server/config.mk
===================================================================
--- branches/SAMBA_4_0/source/smb_server/config.mk 2005-07-19 03:54:01 UTC (rev 8573)
+++ branches/SAMBA_4_0/source/smb_server/config.mk 2005-07-19 03:58:44 UTC (rev 8574)
@@ -17,7 +17,8 @@
smb_server/sesssetup.o \
smb_server/srvtime.o \
smb_server/trans2.o \
- smb_server/signing.o
+ smb_server/signing.o \
+ smb_server/management.o
REQUIRED_SUBSYSTEMS = \
NTVFS
# End SUBSYSTEM SMB
Added: branches/SAMBA_4_0/source/smb_server/management.c
===================================================================
--- branches/SAMBA_4_0/source/smb_server/management.c 2005-07-19 03:54:01 UTC (rev 8573)
+++ branches/SAMBA_4_0/source/smb_server/management.c 2005-07-19 03:58:44 UTC (rev 8574)
@@ -0,0 +1,83 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ management calls for smb server
+
+ Copyright (C) Andrew Tridgell 2005
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "smb_server/smb_server.h"
+#include "smbd/service_stream.h"
+#include "lib/messaging/irpc.h"
+#include "librpc/gen_ndr/ndr_irpc.h"
+#include "auth/auth.h"
+
+/*
+ return a list of open sessions
+*/
+static NTSTATUS smbsrv_session_information(struct irpc_message *msg,
+ struct smbsrv_information *r)
+{
+ struct smbsrv_connection *smb_conn = talloc_get_type(msg->private, struct smbsrv_connection);
+ int i=0, count=0;
+ struct smbsrv_session *sess;
+
+ /* count the number of sessions */
+ for (sess=smb_conn->sessions.list; sess; sess=sess->next) {
+ count++;
+ }
+
+ r->out.info.sessions.num_sessions = count;
+ r->out.info.sessions.sessions = talloc_array(r, struct smbsrv_session_info, count);
+ NT_STATUS_HAVE_NO_MEMORY(r->out.info.sessions.sessions);
+
+ for (sess=smb_conn->sessions.list; sess; sess=sess->next) {
+ struct smbsrv_session_info *info = &r->out.info.sessions.sessions[i];
+ info->vuid = sess->vuid;
+ info->account_name = sess->session_info->server_info->account_name;
+ info->domain_name = sess->session_info->server_info->domain_name;
+ info->connect_time = timeval_to_nttime(&sess->connect_time);
+ info->client_ip = socket_get_peer_addr(smb_conn->connection->socket, r);
+ i++;
+ }
+
+ return NT_STATUS_OK;
+}
+
+/*
+ serve smbserver information via irpc
+*/
+static NTSTATUS smbsrv_information(struct irpc_message *msg,
+ struct smbsrv_information *r)
+{
+ switch (r->in.level) {
+ case SMBSRV_INFO_SESSIONS:
+ return smbsrv_session_information(msg, r);
+ }
+
+ return NT_STATUS_OK;
+}
+
+/*
+ initialise irpc management calls on a connection
+*/
+void smbsrv_management_init(struct smbsrv_connection *smb_conn)
+{
+ IRPC_REGISTER(smb_conn->connection->msg_ctx, irpc, SMBSRV_INFORMATION,
+ smbsrv_information, smb_conn);
+}
Modified: branches/SAMBA_4_0/source/smb_server/session.c
===================================================================
--- branches/SAMBA_4_0/source/smb_server/session.c 2005-07-19 03:54:01 UTC (rev 8573)
+++ branches/SAMBA_4_0/source/smb_server/session.c 2005-07-19 03:58:44 UTC (rev 8574)
@@ -1,7 +1,7 @@
/*
Unix SMB/CIFS implementation.
Password and authentication handling
- Copyright (C) Andrew Tridgell 1992-1998
+ Copyright (C) Andrew Tridgell 1992-2005
Copyright (C) Andrew Bartlett <abartlet at samba.org> 2005
This program is free software; you can redistribute it and/or modify
@@ -21,6 +21,7 @@
#include "includes.h"
#include "smb_server/smb_server.h"
+#include "dlinklist.h"
/****************************************************************************
@@ -61,7 +62,7 @@
****************************************************************************/
static int smbsrv_session_destructor(void *p)
{
- struct smbsrv_session *sess = p;
+ struct smbsrv_session *sess = talloc_get_type(p, struct smbsrv_session);
struct smbsrv_connection *smb_conn = sess->smb_conn;
/* clear the vuid from the 'cache' on each connection, and
@@ -71,6 +72,8 @@
smb_conn->sessions.num_validated_vuids--;
idr_remove(smb_conn->sessions.idtree_vuid, sess->vuid);
+
+ DLIST_REMOVE(smb_conn->sessions.list, sess);
return 0;
}
@@ -129,9 +132,11 @@
sess->session_info = talloc_reference(sess, session_info);
sess->gensec_ctx = talloc_reference(sess, gensec_ctx);
-
sess->smb_conn = smb_conn;
+ sess->connect_time = timeval_current();
+ DLIST_ADD(smb_conn->sessions.list, sess);
+
talloc_set_destructor(sess, smbsrv_session_destructor);
return sess;
Modified: branches/SAMBA_4_0/source/smb_server/smb_server.c
===================================================================
--- branches/SAMBA_4_0/source/smb_server/smb_server.c 2005-07-19 03:54:01 UTC (rev 8573)
+++ branches/SAMBA_4_0/source/smb_server/smb_server.c 2005-07-19 03:58:44 UTC (rev 8574)
@@ -774,6 +774,8 @@
conn->private = smb_conn;
irpc_add_name(conn->msg_ctx, "smb_server");
+
+ smbsrv_management_init(smb_conn);
}
Modified: branches/SAMBA_4_0/source/smb_server/smb_server.h
===================================================================
--- branches/SAMBA_4_0/source/smb_server/smb_server.h 2005-07-19 03:54:01 UTC (rev 8573)
+++ branches/SAMBA_4_0/source/smb_server/smb_server.h 2005-07-19 03:58:44 UTC (rev 8574)
@@ -51,6 +51,8 @@
/* Distinguish between a VUID allocated for the multi-pass
* extended secrity session setup and one that is finished */
BOOL finished_sesssetup;
+
+ struct timeval connect_time;
};
/* we need a forward declaration of the ntvfs_ops strucutre to prevent
@@ -224,6 +226,10 @@
/* this holds info on session vuids that are already
* validated for this VC */
struct idr_context *idtree_vuid;
+
+ /* also kept as a link list so it can be enumerated by
+ the management code */
+ struct smbsrv_session *list;
} sessions;
/* the server_context holds a linked list of pending requests,
More information about the samba-cvs
mailing list