diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-06-24 16:26:23 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-06-24 16:26:23 +1000 |
commit | 6da26870e0ae5acd6ff49a30ec2f6886b44d095e (patch) | |
tree | 850c71039563c16a5d563c47e7ba2ab645baf198 /source4/torture/dfs/domaindfs.c | |
parent | 6925a799d04c6fa59dd2ddef1f5510f9bb7d17d1 (diff) | |
parent | 2610c05b5b95cc7036b3d6dfb894c6cfbdb68483 (diff) | |
download | samba-6da26870e0ae5acd6ff49a30ec2f6886b44d095e.tar.gz samba-6da26870e0ae5acd6ff49a30ec2f6886b44d095e.tar.bz2 samba-6da26870e0ae5acd6ff49a30ec2f6886b44d095e.zip |
Merge 2610c05b5b95cc7036b3d6dfb894c6cfbdb68483 as Samba-4.0alpha16
Diffstat (limited to 'source4/torture/dfs/domaindfs.c')
-rw-r--r-- | source4/torture/dfs/domaindfs.c | 143 |
1 files changed, 92 insertions, 51 deletions
diff --git a/source4/torture/dfs/domaindfs.c b/source4/torture/dfs/domaindfs.c index 467e104e25..89e9cc1426 100644 --- a/source4/torture/dfs/domaindfs.c +++ b/source4/torture/dfs/domaindfs.c @@ -55,20 +55,24 @@ static bool test_getdomainreferral(struct torture_context *tctx, talloc_asprintf(tctx, "Not expected version for referral entry 0 got %d expected 3", resp.referral_entries[0].version)); - torture_assert_int_equal(tctx, resp.referral_entries[0].referral.v3.data.server_type, + torture_assert_int_equal(tctx, resp.referral_entries[0].referral.v3.server_type, DFS_SERVER_NON_ROOT, talloc_asprintf(tctx, "Wrong server type, expected non root server and got %d", - resp.referral_entries[0].referral.v3.data.server_type)); - torture_assert_int_equal(tctx, resp.referral_entries[0].referral.v3.data.entry_flags, + resp.referral_entries[0].referral.v3.server_type)); + torture_assert_int_equal(tctx, resp.referral_entries[0].referral.v3.entry_flags, DFS_FLAG_REFERRAL_DOMAIN_RESP, talloc_asprintf(tctx, "Wrong entry flag expected to have a domain response and got %d", - resp.referral_entries[0].referral.v3.data.entry_flags)); + resp.referral_entries[0].referral.v3.entry_flags)); torture_assert_int_equal(tctx, strlen( - resp.referral_entries[0].referral.v3.data.referrals.r2.special_name) > 0, + resp.referral_entries[0].referral.v3.referrals.r2.special_name) > 0, 1, "Length of domain is 0 or less"); + torture_assert_int_equal(tctx, + resp.referral_entries[0].referral.v3.referrals.r2.special_name[0] == '\\', + 1, + "domain didn't start with a \\"); return true; } @@ -88,9 +92,9 @@ static bool test_getdcreferral(struct torture_context *tctx, dfs_cli_do_call(cli->tree, &r), "Get Domain referral failed"); - str = resp.referral_entries[0].referral.v3.data.referrals.r2.special_name; + str = resp.referral_entries[0].referral.v3.referrals.r2.special_name; if( strchr(str, '.') == NULL ) { - str = resp.referral_entries[1].referral.v3.data.referrals.r2.special_name; + str = resp.referral_entries[1].referral.v3.referrals.r2.special_name; } r2.in.req.max_referral_level = 3; @@ -112,34 +116,38 @@ static bool test_getdcreferral(struct torture_context *tctx, talloc_asprintf(tctx, "Not expected version for referral entry 0 got %d expected 3", resp2.referral_entries[0].version)); - torture_assert_int_equal(tctx, resp2.referral_entries[0].referral.v3.data.server_type, + torture_assert_int_equal(tctx, resp2.referral_entries[0].referral.v3.server_type, DFS_SERVER_NON_ROOT, talloc_asprintf(tctx, "Wrong server type, expected non root server and got %d", - resp2.referral_entries[0].referral.v3.data.server_type)); - torture_assert_int_equal(tctx, resp2.referral_entries[0].referral.v3.data.entry_flags, + resp2.referral_entries[0].referral.v3.server_type)); + torture_assert_int_equal(tctx, resp2.referral_entries[0].referral.v3.entry_flags, DFS_FLAG_REFERRAL_DOMAIN_RESP, talloc_asprintf(tctx, "Wrong entry flag expected to have a domain response and got %d", - resp2.referral_entries[0].referral.v3.data.entry_flags)); + resp2.referral_entries[0].referral.v3.entry_flags)); torture_assert_int_equal(tctx, strlen( - resp2.referral_entries[0].referral.v3.data.referrals.r2.special_name) > 0, + resp2.referral_entries[0].referral.v3.referrals.r2.special_name) > 0, 1, "Length of domain is 0 or less"); torture_assert_int_equal(tctx, strlen( - resp2.referral_entries[0].referral.v3.data.referrals.r2.expanded_names[0]) > 0, + resp2.referral_entries[0].referral.v3.referrals.r2.expanded_names[0]) > 0, 1, "Length of first dc is less than 0"); - str = strchr(resp2.referral_entries[0].referral.v3.data.referrals.r2.expanded_names[0], '.'); - str2 = resp2.referral_entries[0].referral.v3.data.referrals.r2.special_name; + str = strchr(resp2.referral_entries[0].referral.v3.referrals.r2.expanded_names[0], '.'); + str2 = resp2.referral_entries[0].referral.v3.referrals.r2.special_name; if (str2[0] == '\\') { str2++; } torture_assert_int_equal(tctx, strlen(str) >0, 1 ,"Length of domain too short"); str++; torture_assert_int_equal(tctx, strcmp(str,str2), 0, - talloc_asprintf(tctx, "Pb domain of the dc is not"\ - "the same as the requested: domain = %s got =%s",str2 ,str)); + talloc_asprintf(tctx, "Pb domain of the dc is not "\ + "the same as the requested: domain was = %s got =%s",str2 ,str)); + torture_assert_int_equal(tctx, + resp.referral_entries[0].referral.v3.referrals.r2.special_name[0] == '\\', + 1, + "dc name didn't start with a \\"); r3.in.req.max_referral_level = 3; /* @@ -164,22 +172,22 @@ static bool test_getdcreferral(struct torture_context *tctx, talloc_asprintf(tctx, "Not expected version for referral entry 0 got %d expected 3", resp3.referral_entries[0].version)); - torture_assert_int_equal(tctx, resp3.referral_entries[0].referral.v3.data.server_type, + torture_assert_int_equal(tctx, resp3.referral_entries[0].referral.v3.server_type, DFS_SERVER_NON_ROOT, talloc_asprintf(tctx, "Wrong server type, expected non root server and got %d", - resp3.referral_entries[0].referral.v3.data.server_type)); - torture_assert_int_equal(tctx, resp3.referral_entries[0].referral.v3.data.entry_flags, + resp3.referral_entries[0].referral.v3.server_type)); + torture_assert_int_equal(tctx, resp3.referral_entries[0].referral.v3.entry_flags, DFS_FLAG_REFERRAL_DOMAIN_RESP, talloc_asprintf(tctx, "Wrong entry flag expected to have a domain response and got %d", - resp3.referral_entries[0].referral.v3.data.entry_flags)); + resp3.referral_entries[0].referral.v3.entry_flags)); torture_assert_int_equal(tctx, strlen( - resp3.referral_entries[0].referral.v3.data.referrals.r2.special_name) > 0, + resp3.referral_entries[0].referral.v3.referrals.r2.special_name) > 0, 1, "Length of domain is 0 or less"); torture_assert_int_equal(tctx, strlen( - resp3.referral_entries[0].referral.v3.data.referrals.r2.expanded_names[0]) > 0, + resp3.referral_entries[0].referral.v3.referrals.r2.expanded_names[0]) > 0, 1, "Length of first dc is less than 0"); return true; @@ -202,9 +210,9 @@ static bool test_getdcreferral_netbios(struct torture_context *tctx, r2.in.req.max_referral_level = 3; - str = resp.referral_entries[0].referral.v3.data.referrals.r2.special_name; + str = resp.referral_entries[0].referral.v3.referrals.r2.special_name; if( strchr(str, '.') != NULL ) { - str = resp.referral_entries[1].referral.v3.data.referrals.r2.special_name; + str = resp.referral_entries[1].referral.v3.referrals.r2.special_name; } r2.in.req.servername = str; @@ -224,26 +232,26 @@ static bool test_getdcreferral_netbios(struct torture_context *tctx, talloc_asprintf(tctx, "Not expected version for referral entry 0 got %d expected 3", resp2.referral_entries[0].version)); - torture_assert_int_equal(tctx, resp2.referral_entries[0].referral.v3.data.server_type, + torture_assert_int_equal(tctx, resp2.referral_entries[0].referral.v3.server_type, DFS_SERVER_NON_ROOT, talloc_asprintf(tctx, "Wrong server type, expected non root server and got %d", - resp2.referral_entries[0].referral.v3.data.server_type)); - torture_assert_int_equal(tctx, resp2.referral_entries[0].referral.v3.data.entry_flags, + resp2.referral_entries[0].referral.v3.server_type)); + torture_assert_int_equal(tctx, resp2.referral_entries[0].referral.v3.entry_flags, DFS_FLAG_REFERRAL_DOMAIN_RESP, talloc_asprintf(tctx, "Wrong entry flag expected to have a domain response and got %d", - resp2.referral_entries[0].referral.v3.data.entry_flags)); + resp2.referral_entries[0].referral.v3.entry_flags)); torture_assert_int_equal(tctx, strlen( - resp2.referral_entries[0].referral.v3.data.referrals.r2.special_name) > 0, + resp2.referral_entries[0].referral.v3.referrals.r2.special_name) > 0, 1, "Length of domain is 0 or less"); torture_assert_int_equal(tctx, strlen( - resp2.referral_entries[0].referral.v3.data.referrals.r2.expanded_names[0]) > 0, + resp2.referral_entries[0].referral.v3.referrals.r2.expanded_names[0]) > 0, 1, "Length of first dc is less than 0"); torture_assert(tctx, strchr( - resp2.referral_entries[0].referral.v3.data.referrals.r2.expanded_names[0],'.') == NULL, + resp2.referral_entries[0].referral.v3.referrals.r2.expanded_names[0],'.') == NULL, "referral contains dots it's not a netbios name"); r3.in.req.max_referral_level = 3; @@ -269,26 +277,26 @@ static bool test_getdcreferral_netbios(struct torture_context *tctx, talloc_asprintf(tctx, "Not expected version for referral entry 0 got %d expected 3", resp3.referral_entries[0].version)); - torture_assert_int_equal(tctx, resp3.referral_entries[0].referral.v3.data.server_type, + torture_assert_int_equal(tctx, resp3.referral_entries[0].referral.v3.server_type, DFS_SERVER_NON_ROOT, talloc_asprintf(tctx, "Wrong server type, expected non root server and got %d", - resp3.referral_entries[0].referral.v3.data.server_type)); - torture_assert_int_equal(tctx, resp3.referral_entries[0].referral.v3.data.entry_flags, + resp3.referral_entries[0].referral.v3.server_type)); + torture_assert_int_equal(tctx, resp3.referral_entries[0].referral.v3.entry_flags, DFS_FLAG_REFERRAL_DOMAIN_RESP, talloc_asprintf(tctx, "Wrong entry flag expected to have a domain response and got %d", - resp3.referral_entries[0].referral.v3.data.entry_flags)); + resp3.referral_entries[0].referral.v3.entry_flags)); torture_assert_int_equal(tctx, strlen( - resp3.referral_entries[0].referral.v3.data.referrals.r2.special_name) > 0, + resp3.referral_entries[0].referral.v3.referrals.r2.special_name) > 0, 1, "Length of domain is 0 or less"); torture_assert_int_equal(tctx, strlen( - resp3.referral_entries[0].referral.v3.data.referrals.r2.expanded_names[0]) > 0, + resp3.referral_entries[0].referral.v3.referrals.r2.expanded_names[0]) > 0, 1, "Length of first dc is less than 0"); torture_assert(tctx, strchr( - resp3.referral_entries[0].referral.v3.data.referrals.r2.expanded_names[0],'.') == NULL, + resp3.referral_entries[0].referral.v3.referrals.r2.expanded_names[0],'.') == NULL, "referral contains dots it's not a netbios name"); return true; } @@ -299,6 +307,9 @@ static bool test_getsysvolreferral(struct torture_context *tctx, const char* str; struct dfs_GetDFSReferral r, r2, r3; struct dfs_referral_resp resp, resp2, resp3; + uint8_t zeros[16]; + + memset(zeros, 0, sizeof(zeros)); r.in.req.max_referral_level = 3; r.in.req.servername = ""; @@ -308,9 +319,9 @@ static bool test_getsysvolreferral(struct torture_context *tctx, dfs_cli_do_call(cli->tree, &r), "Get Domain referral failed"); - str = resp.referral_entries[0].referral.v3.data.referrals.r2.special_name; + str = resp.referral_entries[0].referral.v3.referrals.r2.special_name; if( strchr(str, '.') == NULL ) { - str = resp.referral_entries[1].referral.v3.data.referrals.r2.special_name; + str = resp.referral_entries[1].referral.v3.referrals.r2.special_name; } r2.in.req.max_referral_level = 3; @@ -339,25 +350,41 @@ static bool test_getsysvolreferral(struct torture_context *tctx, talloc_asprintf(tctx, "Not expected version for referral entry 0 got %d expected 3", resp3.referral_entries[0].version)); - torture_assert_int_equal(tctx, resp3.referral_entries[0].referral.v3.data.server_type, + torture_assert_int_equal(tctx, resp3.referral_entries[0].referral.v3.server_type, DFS_SERVER_NON_ROOT, talloc_asprintf(tctx, "Wrong server type, expected non root server and got %d", - resp3.referral_entries[0].referral.v3.data.server_type)); - torture_assert_int_equal(tctx, resp3.referral_entries[0].referral.v3.data.entry_flags, + resp3.referral_entries[0].referral.v3.server_type)); + torture_assert_int_equal(tctx, resp3.referral_entries[0].referral.v3.entry_flags, 0, talloc_asprintf(tctx, "Wrong entry flag expected to have a non domain response and got %d", - resp3.referral_entries[0].referral.v3.data.entry_flags)); + resp3.referral_entries[0].referral.v3.entry_flags)); torture_assert_int_equal(tctx, strlen( - resp3.referral_entries[0].referral.v3.data.referrals.r2.special_name) > 0, + resp3.referral_entries[0].referral.v3.referrals.r1.DFS_path) > 0, 1, "Length of domain is 0 or less"); + torture_assert_int_equal(tctx, strstr(resp3.referral_entries[0].referral.v3.referrals.r1.DFS_path, + str+1) != NULL, 1, + talloc_asprintf(tctx, + "Wrong DFS_path %s unable to find substring %s in it", + resp3.referral_entries[0].referral.v3.referrals.r1.DFS_path, + str+1)); torture_assert_int_equal(tctx, strlen( - resp2.referral_entries[0].referral.v3.data.referrals.r2.expanded_names[0]) > 0, + resp3.referral_entries[0].referral.v3.referrals.r1.netw_address) > 0, 1, "Length of first referral is less than 0"); - + torture_assert_int_equal(tctx, strstr(resp3.referral_entries[0].referral.v3.referrals.r1.netw_address, + str+1) != NULL, 1, + talloc_asprintf(tctx, + "Wrong DFS_path %s unable to find substring %s in it", + resp3.referral_entries[0].referral.v3.referrals.r1.netw_address, + str+1)); +#if 0 + /* + * Due to strange behavior with XP and level 4 + * we are obliged to degrade to level 3 ... + */ r3.in.req.max_referral_level = 4; torture_assert_ntstatus_ok(tctx, @@ -368,6 +395,20 @@ static bool test_getsysvolreferral(struct torture_context *tctx, talloc_asprintf(tctx, "Not expected version for referral entry 0 got %d expected 4", resp3.referral_entries[0].version)); + torture_assert_int_equal(tctx, memcmp(resp3.referral_entries[0].referral.v3.service_site_guid.value, zeros, 16), 0, + talloc_asprintf(tctx, + "Service_site_guid is not NULL as expected")); +#endif + r3.in.req.max_referral_level = 4; + + torture_assert_ntstatus_ok(tctx, + dfs_cli_do_call(cli->tree, &r3), + "Get sysvol Domain referral failed"); + + torture_assert_int_equal(tctx, resp3.referral_entries[0].version, 3, + talloc_asprintf(tctx, + "Not expected version for referral entry 0 got %d expected 3 in degraded mode", + resp3.referral_entries[0].version)); #if 0 /* * We do not support fallback indication for the moment @@ -375,12 +416,12 @@ static bool test_getsysvolreferral(struct torture_context *tctx, torture_assert_int_equal(tctx, resp3.header_flags, DFS_HEADER_FLAG_STORAGE_SVR | DFS_HEADER_FLAG_TARGET_BCK, "Header flag different it's not a referral for a storage with fallback"); -#endif torture_assert_int_equal(tctx, resp3.referral_entries[0].referral.v4.entry_flags, DFS_FLAG_REFERRAL_FIRST_TARGET_SET, talloc_asprintf(tctx, "Wrong entry flag expected to have a non domain response and got %d", resp3.referral_entries[0].referral.v4.entry_flags)); +#endif return true; } @@ -426,14 +467,14 @@ static bool test_getsysvolplusreferral(struct torture_context *tctx, "Get Domain referral failed"); r2.in.req.max_referral_level = 3; - r2.in.req.servername = resp.referral_entries[0].referral.v3.data.referrals.r2.special_name; + r2.in.req.servername = resp.referral_entries[0].referral.v3.referrals.r2.special_name; r2.out.resp = &resp2; torture_assert_ntstatus_ok(tctx, dfs_cli_do_call(cli->tree, &r2), "Get DC Domain referral failed"); - str = resp2.referral_entries[0].referral.v3.data.referrals.r2.special_name; + str = resp2.referral_entries[0].referral.v3.referrals.r2.special_name; r3.in.req.max_referral_level = 3; r3.in.req.servername = talloc_asprintf(tctx, "%s\\sysvol\\foo", str); r3.out.resp = &resp3; |