s4/test-libnet: Refactor test_user_create() little bit to:
authorKamen Mazdrashki <kamenim@samba.org>
Fri, 11 Jun 2010 12:37:12 +0000 (15:37 +0300)
committerKamen Mazdrashki <kamenim@samba.org>
Fri, 11 Jun 2010 12:37:12 +0000 (15:37 +0300)
- fix a flaw that user RID is not returned in case
  user is recreated
- close unused policy handle to created user
- do not take into account the result from
  test_samr_close_handle - we don't case

source4/torture/libnet/utils.c

index 58db297a99086bf57f355a8ef8c4d03859642484..b4b2374acf035d0b4f9261408a126db24216b8ab 100644 (file)
@@ -253,7 +253,8 @@ bool test_user_create(struct torture_context *tctx,
        r.in.account_name  = &username;
        r.in.access_mask   = SEC_FLAG_MAXIMUM_ALLOWED;
        r.out.user_handle  = &user_handle;
-       r.out.rid          = &user_rid;
+       /* return user's RID only if requested */
+       r.out.rid          = rid ? rid : &user_rid;
 
        torture_comment(tctx, "creating user '%s'\n", username.string);
 
@@ -280,21 +281,16 @@ bool test_user_create(struct torture_context *tctx,
                        torture_assert_ntstatus_ok(tctx, r.out.result,
                                                   "CreateUser failed");
 
+                       /* be nice and close opened handles */
+                       test_samr_close_handle(tctx, b, mem_ctx, &user_handle);
+
                        return true;
                }
                return false;
        }
 
-       torture_comment(tctx, "closing user '%s'\n", username.string);
-
-       if (!test_samr_close_handle(tctx, b, mem_ctx, &user_handle)) {
-               return false;
-       }
-
-       /* return user RID only if requested */
-       if (rid) {
-               *rid = user_rid;
-       }
+       /* be nice and close opened handles */
+       test_samr_close_handle(tctx, b, mem_ctx, &user_handle);
 
        return true;
 }