diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-07-19 04:26:58 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:29:40 -0500 |
commit | a32fe0f293fb86d69f3f7001daac2614adfb6b98 (patch) | |
tree | 5f4477d2e4a04c2855ec1d1ce38aa704dc11ffb6 /source4 | |
parent | f3d61cc61545605cb8ea07b21b07577ccde4e1e8 (diff) | |
download | samba-a32fe0f293fb86d69f3f7001daac2614adfb6b98.tar.gz samba-a32fe0f293fb86d69f3f7001daac2614adfb6b98.tar.bz2 samba-a32fe0f293fb86d69f3f7001daac2614adfb6b98.zip |
r8577: added management calls to list current tree connects
(This used to be commit 658befc1e4df44bee1f365a730951001f0f36640)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/librpc/idl/irpc.idl | 16 | ||||
-rwxr-xr-x | source4/scripting/bin/smbstatus | 11 | ||||
-rw-r--r-- | source4/scripting/libjs/management.js | 41 | ||||
-rw-r--r-- | source4/smb_server/conn.c | 1 | ||||
-rw-r--r-- | source4/smb_server/management.c | 33 | ||||
-rw-r--r-- | source4/smb_server/smb_server.h | 2 |
6 files changed, 102 insertions, 2 deletions
diff --git a/source4/librpc/idl/irpc.idl b/source4/librpc/idl/irpc.idl index 4c4a8810fe..3ecbc11d58 100644 --- a/source4/librpc/idl/irpc.idl +++ b/source4/librpc/idl/irpc.idl @@ -52,7 +52,8 @@ management calls for the smb server ******************************************************/ typedef [v1_enum] enum { - SMBSRV_INFO_SESSIONS + SMBSRV_INFO_SESSIONS, + SMBSRV_INFO_TREES } smbsrv_info_level; typedef struct { @@ -68,8 +69,21 @@ [size_is(num_sessions)] smbsrv_session_info *sessions; } smbsrv_sessions; + typedef struct { + uint16 tid; + astring share_name; + astring client_ip; + NTTIME connect_time; + } smbsrv_tree_info; + + typedef struct { + uint32 num_trees; + [size_is(num_trees)] smbsrv_tree_info *trees; + } smbsrv_trees; + typedef union { [case(SMBSRV_INFO_SESSIONS)] smbsrv_sessions sessions; + [case(SMBSRV_INFO_TREES)] smbsrv_trees trees; } smbsrv_info; void smbsrv_information( diff --git a/source4/scripting/bin/smbstatus b/source4/scripting/bin/smbstatus index fd3009012b..9f7566a642 100755 --- a/source4/scripting/bin/smbstatus +++ b/source4/scripting/bin/smbstatus @@ -21,6 +21,17 @@ if (ok == false) { var sessions = smbsrv_sessions(); +if (sessions == undefined) { + println("No sessions"); + exit(0); +} printVars(sessions); +var trees = smbsrv_trees(); +if (trees == undefined) { + println("No trees"); + exit(0); +} +printVars(trees); + return 0; diff --git a/source4/scripting/libjs/management.js b/source4/scripting/libjs/management.js index 371ddc026b..d989541661 100644 --- a/source4/scripting/libjs/management.js +++ b/source4/scripting/libjs/management.js @@ -4,6 +4,7 @@ Released under the GNU GPL v2 or later */ + /* return a list of current sessions */ @@ -12,11 +13,16 @@ function smbsrv_sessions() var conn = new Object(); var irpc = irpc_init(); status = irpc_connect(conn, "smb_server"); - assert(status.is_ok == true); + if (status.is_ok != true) { + return undefined; + } var io = irpcObj(); io.input.level = irpc.SMBSRV_INFO_SESSIONS; status = irpc.smbsrv_information(conn, io); + if (status.is_ok != true) { + return undefined; + } /* gather the results into a single array */ var i, count=0, ret = new Object(); @@ -31,3 +37,36 @@ function smbsrv_sessions() ret.length = count; return ret; } + +/* + return a list of current tree connects +*/ +function smbsrv_trees() +{ + var conn = new Object(); + var irpc = irpc_init(); + status = irpc_connect(conn, "smb_server"); + if (status.is_ok != true) { + return undefined; + } + + var io = irpcObj(); + io.input.level = irpc.SMBSRV_INFO_TREES; + status = irpc.smbsrv_information(conn, io); + if (status.is_ok != true) { + return undefined; + } + + /* gather the results into a single array */ + var i, count=0, ret = new Object(); + for (i=0;i<io.results.length;i++) { + var trees = io.results[i].info.trees.trees; + var j; + for (j=0;j<trees.length;j++) { + ret[count] = trees[j]; + count++; + } + } + ret.length = count; + return ret; +} diff --git a/source4/smb_server/conn.c b/source4/smb_server/conn.c index dfc310a161..a9cd71e801 100644 --- a/source4/smb_server/conn.c +++ b/source4/smb_server/conn.c @@ -81,6 +81,7 @@ struct smbsrv_tcon *smbsrv_tcon_new(struct smbsrv_connection *smb_conn) tcon->tid = i; tcon->smb_conn = smb_conn; + tcon->connect_time = timeval_current(); talloc_set_destructor(tcon, smbsrv_tcon_destructor); diff --git a/source4/smb_server/management.c b/source4/smb_server/management.c index 8282818360..234adac414 100644 --- a/source4/smb_server/management.c +++ b/source4/smb_server/management.c @@ -60,6 +60,37 @@ static NTSTATUS smbsrv_session_information(struct irpc_message *msg, } /* + return a list of tree connects +*/ +static NTSTATUS smbsrv_tree_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_tcon *tcon; + + /* count the number of tcons */ + for (tcon=smb_conn->tree.tcons; tcon; tcon=tcon->next) { + count++; + } + + r->out.info.trees.num_trees = count; + r->out.info.trees.trees = talloc_array(r, struct smbsrv_tree_info, count); + NT_STATUS_HAVE_NO_MEMORY(r->out.info.trees.trees); + + for (tcon=smb_conn->tree.tcons; tcon; tcon=tcon->next) { + struct smbsrv_tree_info *info = &r->out.info.trees.trees[i]; + info->tid = tcon->tid; + info->share_name = lp_servicename(tcon->service); + info->connect_time = timeval_to_nttime(&tcon->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, @@ -68,6 +99,8 @@ static NTSTATUS smbsrv_information(struct irpc_message *msg, switch (r->in.level) { case SMBSRV_INFO_SESSIONS: return smbsrv_session_information(msg, r); + case SMBSRV_INFO_TREES: + return smbsrv_tree_information(msg, r); } return NT_STATUS_OK; diff --git a/source4/smb_server/smb_server.h b/source4/smb_server/smb_server.h index df49825e0e..819a70cbae 100644 --- a/source4/smb_server/smb_server.h +++ b/source4/smb_server/smb_server.h @@ -79,6 +79,8 @@ struct smbsrv_tcon { /* the reported device type */ char *dev_type; + + struct timeval connect_time; }; /* a set of flags to control handling of request structures */ |