From 7e01b640bccb61f3aec0397e894be042575ff22b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 28 Mar 2013 14:10:32 -0700 Subject: [PATCH] Evil addition to check_ea function that always requests a non-existant EA. Proves that servers must return all entries in a queried list, with a length of zero if they don't exist. Signed-off-by: Jeremy Allison --- source4/torture/util_smb.c | 54 ++++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/source4/torture/util_smb.c b/source4/torture/util_smb.c index 343c8a7..09672a2 100644 --- a/source4/torture/util_smb.c +++ b/source4/torture/util_smb.c @@ -371,20 +371,28 @@ NTSTATUS torture_set_sparse(struct smbcli_tree *tree, int fnum) /* check that an EA has the right value */ + +#if !defined(DUMMY_EA_NAME) +#define DUMMY_EA_NAME "MISSING_EA" +#endif + NTSTATUS torture_check_ea(struct smbcli_state *cli, const char *fname, const char *eaname, const char *value) { union smb_fileinfo info; NTSTATUS status; - struct ea_name ea; + struct ea_name ea[2]; TALLOC_CTX *mem_ctx = talloc_new(cli); info.ea_list.level = RAW_FILEINFO_EA_LIST; info.ea_list.in.file.path = fname; - info.ea_list.in.num_names = 1; - info.ea_list.in.ea_names = &ea; + info.ea_list.in.num_names = 2; + info.ea_list.in.ea_names = ea; - ea.name.s = eaname; + memset(ea, '\0', 2*sizeof(struct ea_name)); + ea[0].name.s = eaname; + /* Add an additional name that we know won't be there. */ + ea[1].name.s = DUMMY_EA_NAME; status = smb_raw_pathinfo(cli->tree, mem_ctx, &info); if (!NT_STATUS_IS_OK(status)) { @@ -392,8 +400,8 @@ NTSTATUS torture_check_ea(struct smbcli_state *cli, return status; } - if (info.ea_list.out.num_eas != 1) { - printf("Expected 1 ea in ea_list\n"); + if (info.ea_list.out.num_eas != 2) { + printf("Expected 2 ea in ea_list\n"); talloc_free(mem_ctx); return NT_STATUS_EA_CORRUPT_ERROR; } @@ -411,27 +419,35 @@ NTSTATUS torture_check_ea(struct smbcli_state *cli, talloc_free(mem_ctx); return NT_STATUS_EA_CORRUPT_ERROR; } + } else if (!(strlen(value) == info.ea_list.out.eas[0].value.length && + memcmp(value, info.ea_list.out.eas[0].value.data, + info.ea_list.out.eas[0].value.length) == 0)) { + printf("Expected value '%s' not '%*.*s' for ea %s\n", + value, + (int)info.ea_list.out.eas[0].value.length, + (int)info.ea_list.out.eas[0].value.length, + info.ea_list.out.eas[0].value.data, + eaname); talloc_free(mem_ctx); - return NT_STATUS_OK; + return NT_STATUS_EA_CORRUPT_ERROR; } - if (strlen(value) == info.ea_list.out.eas[0].value.length && - memcmp(value, info.ea_list.out.eas[0].value.data, - info.ea_list.out.eas[0].value.length) == 0) { + if (strcasecmp_m(DUMMY_EA_NAME, info.ea_list.out.eas[1].name.s) != 0) { + printf("Expected ea %s not '%s' in ea_list\n", + DUMMY_EA_NAME, + info.ea_list.out.eas[1].name.s); talloc_free(mem_ctx); - return NT_STATUS_OK; + return NT_STATUS_EA_CORRUPT_ERROR; } - printf("Expected value '%s' not '%*.*s' for ea %s\n", - value, - (int)info.ea_list.out.eas[0].value.length, - (int)info.ea_list.out.eas[0].value.length, - info.ea_list.out.eas[0].value.data, - eaname); + if (info.ea_list.out.eas[1].value.length != 0) { + printf("Expected zero length ea for %s\n", DUMMY_EA_NAME); + talloc_free(mem_ctx); + return NT_STATUS_EA_CORRUPT_ERROR; + } talloc_free(mem_ctx); - - return NT_STATUS_EA_CORRUPT_ERROR; + return NT_STATUS_OK; } _PUBLIC_ bool torture_open_connection_share(TALLOC_CTX *mem_ctx, -- 1.8.1.3