]> git.samba.org - nivanova/samba-autobuild/.git/commitdiff
s3: rpc_server/srvsvc: count open files in NetConnEnum
authorShekhar Amlekar <samlekar@in.ibm.com>
Tue, 25 Mar 2014 11:36:18 +0000 (17:06 +0530)
committerJeremy Allison <jra@samba.org>
Thu, 3 Apr 2014 19:19:43 +0000 (21:19 +0200)
Signed-off-by: Shekhar Amlekar <samlekar@in.ibm.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Apr  3 21:19:43 CEST 2014 on sn-devel-104

source3/rpc_server/srvsvc/srv_srvsvc_nt.c

index 8a7fc2f03f56f114ed903ab1da625776e14adeef..39d5e05bfec937a3f7caaea9634cda530fe22391 100644 (file)
@@ -1157,29 +1157,65 @@ static WERROR init_srv_conn_info_1(const char *name,
                return WERR_OK;
        }
 
+       /*
+        * We know num_entries must be positive, due to
+        * the check resume_handle >= *total_entries above.
+        */
+
+       num_entries = *total_entries - resume_handle;
 
        ZERO_STRUCTP(ctr1);
 
-       for (; resume_handle < *total_entries; resume_handle++) {
+       ctr1->array = talloc_zero_array(talloc_tos(),
+                                       struct srvsvc_NetConnInfo1,
+                                       num_entries);
 
-               ctr1->array = talloc_realloc(talloc_tos(),
-                                                  ctr1->array,
-                                                  struct srvsvc_NetConnInfo1,
-                                                  num_entries+1);
-               if (!ctr1->array) {
-                       return WERR_NOMEM;
-               }
+       W_ERROR_HAVE_NO_MEMORY(ctr1->array);
+
+       for (num_entries = 0; resume_handle < *total_entries;
+               num_entries++, resume_handle++) {
 
                ctr1->array[num_entries].conn_id        = *total_entries;
                ctr1->array[num_entries].conn_type      = 0x3;
-               ctr1->array[num_entries].num_open       = 1;
+
+               /*
+                * if these are connections to a share, we are going to
+                * compute the opens on them later. If it's for the server,
+                * it's unimplemented.
+                */
+
+               if (!share_name) {
+                       ctr1->array[num_entries].num_open = 1;
+               }
+
                ctr1->array[num_entries].num_users      = 1;
                ctr1->array[num_entries].conn_time      = 3;
                ctr1->array[num_entries].user           = "dummy_user";
                ctr1->array[num_entries].share          = "IPC$";
+       }
+
+       /* now compute open files on the share connections */
+
+       if (share_name) {
+
+               /*
+                * the locking tdb, which has the open files information,
+                * does not store share name or share (service) number, but
+                * just the share path. So, we can compute open files only
+                * on the share path. If more than one shares are  defined
+                * on a share path, open files on all of them are included
+                * in the count.
+                *
+                * To have the correct behavior in case multiple shares
+                * are defined on the same path, changes to tdb records
+                * would be required. That would be lot more effort, so
+                * this seems a good stopgap fix.
+                */
+
+               count_share_opens(ctr1->array, svrid_arr,
+                                 lp_path(talloc_tos(), snum),
+                                 num_entries, *total_entries);
 
-               /* move on to creating next connection */
-               num_entries++;
        }
 
        ctr1->count = num_entries;