From 269c93401ea523ef9a1278d0798cf2613ccc0cb6 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 28 Feb 2008 08:36:13 +1100 Subject: Do not re-randomise in an individual test. smbtorture calls srandom() once for the whole suite, with command line override to allow reproduceable random tests. Andrew Bartlett (This used to be commit 68dcd1073cfed830fb6e2013e27d2ebbc443c451) --- source4/torture/libnet/libnet_user.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source4/torture') diff --git a/source4/torture/libnet/libnet_user.c b/source4/torture/libnet/libnet_user.c index 6ea670629e..94711c1dea 100644 --- a/source4/torture/libnet/libnet_user.c +++ b/source4/torture/libnet/libnet_user.c @@ -343,8 +343,6 @@ static void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r, struct timeval now; int i, testfld; - srandom((unsigned)time(NULL)); - printf("Fields to change: ["); for (i = 0; i < num_changes && i < FIELDS_NUM; i++) { -- cgit From 5043215f219f90a899a8dc75518540a04b93301f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 28 Feb 2008 08:50:00 +1100 Subject: Generate ACB_PW_EXPIRED correctly More correctly handle expired passwords, and do not expire machine accounts. Test that the behaviour is consistant with windows, using the RPC-SAMR test. Change NETLOGON to directly query the userAccountControl, just because we don't want to do the extra expiry processing here. Andrew Bartlett (This used to be commit acda1f69bc9b9c43e157e254d0bae54d11363661) --- source4/torture/rpc/samr.c | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) (limited to 'source4/torture') diff --git a/source4/torture/rpc/samr.c b/source4/torture/rpc/samr.c index 9d6c73891b..1d6ec43399 100644 --- a/source4/torture/rpc/samr.c +++ b/source4/torture/rpc/samr.c @@ -416,11 +416,6 @@ static bool test_SetUserInfo(struct dcerpc_pipe *p, struct torture_context *tctx TEST_USERINFO_INT(21, logon_hours.bits[3], 21, logon_hours.bits[3], 4, SAMR_FIELD_LOGON_HOURS); - if (torture_setting_bool(tctx, "samba4", false)) { - printf("skipping Set Account Flag tests against Samba4\n"); - return ret; - } - TEST_USERINFO_INT_EXP(16, acct_flags, 5, acct_flags, (base_acct_flags | ACB_DISABLED | ACB_HOMDIRREQ), (base_acct_flags | ACB_DISABLED | ACB_HOMDIRREQ | user_extra_flags), @@ -1989,9 +1984,12 @@ static bool test_user_ops(struct dcerpc_pipe *p, const char *base_acct_name, enum torture_samr_choice which_ops) { char *password = NULL; + struct samr_QueryUserInfo q; + NTSTATUS status; bool ret = true; int i; + uint32_t rid; const uint32_t password_fields[] = { SAMR_FIELD_PASSWORD, SAMR_FIELD_PASSWORD2, @@ -1999,6 +1997,11 @@ static bool test_user_ops(struct dcerpc_pipe *p, 0 }; + status = test_LookupName(p, tctx, domain_handle, base_acct_name, &rid); + if (!NT_STATUS_IS_OK(status)) { + ret = false; + } + switch (which_ops) { case TORTURE_SAMR_USER_ATTRIBUTES: if (!test_QuerySecurity(p, tctx, user_handle)) { @@ -2091,6 +2094,29 @@ static bool test_user_ops(struct dcerpc_pipe *p, ret = false; } + q.in.user_handle = user_handle; + q.in.level = 5; + + status = dcerpc_samr_QueryUserInfo(p, tctx, &q); + if (!NT_STATUS_IS_OK(status)) { + printf("QueryUserInfo level %u failed - %s\n", + q.in.level, nt_errstr(status)); + ret = false; + } else { + uint32_t expected_flags = (base_acct_flags | ACB_PWNOTREQ | ACB_DISABLED); + if ((q.out.info->info5.acct_flags) != expected_flags) { + printf("QuerUserInfo level 5 failed, it returned 0x%08x when we expected flags of 0x%08x\n", + q.out.info->info5.acct_flags, + expected_flags); + ret = false; + } + if (q.out.info->info5.rid != rid) { + printf("QuerUserInfo level 5 failed, it returned %u when we expected rid of %u\n", + q.out.info->info5.rid, rid); + + } + } + break; case TORTURE_SAMR_OTHER: /* We just need the account to exist */ @@ -2667,10 +2693,14 @@ static bool test_CreateUser2(struct dcerpc_pipe *p, struct torture_context *tctx q.in.level, nt_errstr(status)); ret = false; } else { - if ((q.out.info->info5.acct_flags & acct_flags) != acct_flags) { + uint32_t expected_flags = (acct_flags | ACB_PWNOTREQ | ACB_DISABLED); + if (acct_flags == ACB_NORMAL) { + expected_flags |= ACB_PW_EXPIRED; + } + if ((q.out.info->info5.acct_flags) != expected_flags) { printf("QuerUserInfo level 5 failed, it returned 0x%08x when we expected flags of 0x%08x\n", q.out.info->info5.acct_flags, - acct_flags); + expected_flags); ret = false; } switch (acct_flags) { @@ -3887,7 +3917,6 @@ static bool test_GroupList(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, for (j=0; j Date: Thu, 28 Feb 2008 10:32:06 +1100 Subject: Fix up the libnet tests. These tests still do not pass against windows, but at least now it doesn't reset acct_flags to 0. This is enough to have Samba4 pass it's own tests for the moment. Andrew Bartlett (This used to be commit aa3901311eb7ce6f2d2b2413323e31a5b064cfc4) --- source4/torture/libnet/libnet_user.c | 15 ++++++++++++--- source4/torture/libnet/userman.c | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'source4/torture') diff --git a/source4/torture/libnet/libnet_user.c b/source4/torture/libnet/libnet_user.c index 94711c1dea..31300a7937 100644 --- a/source4/torture/libnet/libnet_user.c +++ b/source4/torture/libnet/libnet_user.c @@ -339,6 +339,9 @@ static void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r, const char* logon_scripts[] = { "start_login.cmd", "login.bat", "start.cmd" }; const char* home_dirs[] = { "\\\\srv\\home", "\\\\homesrv\\home\\user", "\\\\pdcsrv\\domain" }; const char* home_drives[] = { "H:", "z:", "I:", "J:", "n:" }; + const uint32_t flags[] = { (ACB_DISABLED | ACB_NORMAL), + (ACB_NORMAL | ACB_PWNOEXP), + (ACB_NORMAL) }; const char *homedir, *homedrive, *logonscript; struct timeval now; int i, testfld; @@ -380,14 +383,14 @@ static void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r, case home_directory: continue_if_field_set(r->in.home_directory); - homedir = home_dirs[random() % (sizeof(home_dirs)/sizeof(char*))]; + homedir = home_dirs[random() % ARRAY_SIZE(home_dirs)]; r->in.home_directory = talloc_strdup(mem_ctx, homedir); fldname = "home_dir"; break; case home_drive: continue_if_field_set(r->in.home_drive); - homedrive = home_drives[random() % (sizeof(home_drives)/sizeof(char*))]; + homedrive = home_drives[random() % ARRAY_SIZE(home_drives)]; r->in.home_drive = talloc_strdup(mem_ctx, homedrive); fldname = "home_drive"; break; @@ -401,7 +404,7 @@ static void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r, case logon_script: continue_if_field_set(r->in.logon_script); - logonscript = logon_scripts[random() % (sizeof(logon_scripts)/sizeof(char*))]; + logonscript = logon_scripts[random() % ARRAY_SIZE(logon_scripts)]; r->in.logon_script = talloc_strdup(mem_ctx, logonscript); fldname = "logon_script"; break; @@ -420,6 +423,12 @@ static void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r, fldname = "acct_expiry"; break; + case acct_flags: + continue_if_field_set(r->in.acct_flags); + r->in.acct_flags = flags[random() % ARRAY_SIZE(flags)]; + fldname = "acct_flags"; + break; + default: fldname = "unknown_field"; } diff --git a/source4/torture/libnet/userman.c b/source4/torture/libnet/userman.c index 0d08284a9f..1d630e5ecd 100644 --- a/source4/torture/libnet/userman.c +++ b/source4/torture/libnet/userman.c @@ -189,7 +189,7 @@ static bool test_usermod(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, case acct_flags: continue_if_field_set(mod->in.change.acct_flags); - mod->in.change.acct_flags = flags[random() % (sizeof(flags)/sizeof(uint32_t))]; + mod->in.change.acct_flags = flags[random() % ARRAY_SIZE(flags)]; mod->in.change.fields |= USERMOD_FIELD_ACCT_FLAGS; fldname = "acct_flags"; break; -- cgit