summaryrefslogtreecommitdiff
path: root/source3/rpc_server/srvsvc
diff options
context:
space:
mode:
authorShekhar Amlekar <samlekar@in.ibm.com>2013-06-23 19:44:34 +0530
committerJeremy Allison <jra@samba.org>2013-08-13 07:42:23 +0200
commit0260601b19a003ef03072e676ee6869f3cbe0b3f (patch)
treede93f8c9b7ccbe93826a4a3f6715c90d5edc8dfd /source3/rpc_server/srvsvc
parent906de702e641bb0da8ec9074b80d6e94bdb17cfe (diff)
downloadsamba-0260601b19a003ef03072e676ee6869f3cbe0b3f.tar.gz
samba-0260601b19a003ef03072e676ee6869f3cbe0b3f.tar.bz2
samba-0260601b19a003ef03072e676ee6869f3cbe0b3f.zip
s3: smbd/connection: added routines to compute share connections
Added routines to compute share connections and used it in srvsvc NetShareEnum call. Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue Aug 13 07:42:23 CEST 2013 on sn-devel-104
Diffstat (limited to 'source3/rpc_server/srvsvc')
-rw-r--r--source3/rpc_server/srvsvc/srv_srvsvc_nt.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
index 655b0c70a8..1af350ac51 100644
--- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
+++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
@@ -250,7 +250,7 @@ static void init_srv_share_info_2(struct pipes_struct *p,
r->comment = remark ? remark : "";
r->permissions = 0;
r->max_users = max_uses;
- r->current_users = count_current_connections(net_name, false);
+ r->current_users = 0; /* computed later */
r->path = path ? path : "";
r->password = "";
}
@@ -464,6 +464,49 @@ static bool is_enumeration_allowed(struct pipes_struct *p,
FILE_READ_DATA, NULL);
}
+/****************************************************************************
+ Count an entry against the respective service.
+****************************************************************************/
+
+static int count_for_all_fn(struct smbXsrv_tcon_global0 *tcon, void *udp)
+{
+ union srvsvc_NetShareCtr *ctr = NULL;
+ struct srvsvc_NetShareInfo2 *info2 = NULL;
+ int share_entries = 0;
+ int i = 0;
+
+ ctr = (union srvsvc_NetShareCtr *) udp;
+
+ /* for level 2 */
+ share_entries = ctr->ctr2->count;
+ info2 = &ctr->ctr2->array[0];
+
+ for (i = 0; i < share_entries; i++, info2++) {
+ if (strequal(tcon->share_name, info2->name)) {
+ info2->current_users++;
+ break;
+ }
+ }
+
+ return 0;
+}
+
+/****************************************************************************
+ Count the entries belonging to all services in the connection db.
+****************************************************************************/
+
+static void count_connections_for_all_shares(union srvsvc_NetShareCtr *ctr)
+{
+ NTSTATUS status;
+ status = smbXsrv_tcon_global_traverse(count_for_all_fn, ctr);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0,("count_connections_for_all_shares: traverse of "
+ "smbXsrv_tcon_global.tdb failed - %s\n",
+ nt_errstr(status)));
+ }
+}
+
/*******************************************************************
Fill in a share info structure.
********************************************************************/
@@ -568,6 +611,7 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
}
}
+ count_connections_for_all_shares(&ctr);
break;
case 501:
@@ -1382,6 +1426,8 @@ WERROR _srvsvc_NetShareGetInfo(struct pipes_struct *p,
info->info2 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo2);
W_ERROR_HAVE_NO_MEMORY(info->info2);
init_srv_share_info_2(p, info->info2, snum);
+ info->info2->current_users =
+ count_current_connections(info->info2->name, false);
break;
case 501:
info->info501 = talloc(p->mem_ctx, struct srvsvc_NetShareInfo501);