r5318: Fix a small problem in where we ignore the response from a SamrGetGroupsForUser
authorRichard Sharpe <sharpe@samba.org>
Thu, 10 Feb 2005 18:27:23 +0000 (18:27 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:55:37 +0000 (10:55 -0500)
that says the user is in 0 groups, and we issue an RPC to LookupIds for 0 RIDs.

The printing that there are no groups the user is a member of might be overkill
in that it might upset existing scripts that don't expect that output.
(This used to be commit d3482e118f99002c0460291d41708fdf7708c41f)

source3/utils/net_rpc.c
source3/utils/profiles.c

index 76b53d611369fd46f57bdb1a3c036541f14268e4..ff754c33dc58056cddb714baec502e14e0b727f7 100644 (file)
@@ -1005,26 +1005,32 @@ rpc_user_info_internals(const DOM_SID *domain_sid, const char *domain_name,
        result = cli_samr_query_usergroups(cli, mem_ctx, &user_pol,
                                           &num_rids, &user_gids);
 
-       /* Look up rids */
+       if (!NT_STATUS_IS_OK(result)) goto done;
 
-       rids = TALLOC_ARRAY(mem_ctx, uint32, num_rids);
+       /* Look up rids */
 
-       for (i = 0; i < num_rids; i++)
-                rids[i] = user_gids[i].g_rid;
+       if (rids) {
+               rids = TALLOC_ARRAY(mem_ctx, uint32, num_rids);
 
-       result = cli_samr_lookup_rids(cli, mem_ctx, &domain_pol,
-                                     flags, num_rids, rids,
-                                     &num_names, &names, &name_types);
+               for (i = 0; i < num_rids; i++)
+                       rids[i] = user_gids[i].g_rid;
 
-       if (!NT_STATUS_IS_OK(result)) {
-               goto done;
-       }
+               result = cli_samr_lookup_rids(cli, mem_ctx, &domain_pol,
+                                             flags, num_rids, rids,
+                                             &num_names, &names, &name_types);
 
-       /* Display results */
+               if (!NT_STATUS_IS_OK(result)) {
+                       goto done;
+               }
 
-       for (i = 0; i < num_names; i++)
-               printf("%s\n", names[i]);
+               /* Display results */
 
+               for (i = 0; i < num_names; i++)
+                       printf("%s\n", names[i]);
+       }
+       else {
+               printf("no groups\n");
+       }
  done:
        return result;
 }
index 6911341708f6cf414da28b8528323ce28b4b30aa..5b5cb7f07b2f71effeb0ece9c62fd98c3fef93be 100644 (file)
@@ -521,7 +521,7 @@ static void process_acl(ACL *acl, const char *prefix)
 int main(int argc, char *argv[])
 {
   int opt;
-  int fd, start = 0;
+  int fd;
   char *base;
   struct stat sbuf;
   REGF_HDR *regf_hdr;
@@ -608,10 +608,9 @@ int main(int argc, char *argv[])
    * Now, mmap the file into memory, check the header and start
    * dealing with the records. We are interested in the sk record
    */
-  start = 0;
 
 #ifdef HAVE_MMAP
-  base = mmap(&start, sbuf.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+  base = mmap(NULL, sbuf.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
 #else
   base = (char *)-1;
   errno = ENOSYS;