diff options
author | Jeremy Allison <jra@samba.org> | 2017-07-21 15:11:08 -0700 |
---|---|---|
committer | Ralph Boehme <slow@samba.org> | 2017-07-25 17:43:16 +0200 |
commit | bfa07323590357542eb06ad5faa2dc5a5736e3f1 (patch) | |
tree | 1d765702f3032615db0f9e2a05a445bf53ab4b44 /source3/torture | |
parent | b1e5b894b089433e59c96915a27559d179bdb6c5 (diff) | |
download | samba-bfa07323590357542eb06ad5faa2dc5a5736e3f1.tar.gz |
s3: torture: Add a test for cli_setpathinfo_basic() to smbtorture3.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12913
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Diffstat (limited to 'source3/torture')
-rw-r--r-- | source3/torture/torture.c | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/source3/torture/torture.c b/source3/torture/torture.c index 6959b715b00..31e2bcc3497 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -3162,6 +3162,29 @@ static bool run_browsetest(int dummy) } +static bool check_attributes(struct cli_state *cli, + const char *fname, + uint16_t expected_attrs) +{ + uint16_t attrs = 0; + NTSTATUS status = cli_getatr(cli, + fname, + &attrs, + NULL, + NULL); + if (!NT_STATUS_IS_OK(status)) { + printf("cli_getatr failed with %s\n", + nt_errstr(status)); + return false; + } + if (attrs != expected_attrs) { + printf("Attributes incorrect 0x%x, should be 0x%x\n", + (unsigned int)attrs, + (unsigned int)expected_attrs); + return false; + } + return true; +} /* This checks how the getatr calls works @@ -3222,6 +3245,120 @@ static bool run_attrtest(int dummy) cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); + /* Check cli_setpathinfo_basic() */ + /* Re-create the file. */ + status = cli_openx(cli, fname, + O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum); + if (!NT_STATUS_IS_OK(status)) { + printf("Failed to recreate %s (%s)\n", + fname, nt_errstr(status)); + correct = false; + } + cli_close(cli, fnum); + + status = cli_setpathinfo_basic(cli, + fname, + 0, /* create */ + 0, /* access */ + 0, /* write */ + 0, /* change */ + FILE_ATTRIBUTE_SYSTEM | + FILE_ATTRIBUTE_HIDDEN | + FILE_ATTRIBUTE_READONLY); + if (!NT_STATUS_IS_OK(status)) { + printf("cli_setpathinfo_basic failed with %s\n", + nt_errstr(status)); + correct = false; + } + + /* Check attributes are correct. */ + correct = check_attributes(cli, + fname, + FILE_ATTRIBUTE_SYSTEM | + FILE_ATTRIBUTE_HIDDEN | + FILE_ATTRIBUTE_READONLY); + if (correct == false) { + goto out; + } + + /* Setting to FILE_ATTRIBUTE_NORMAL should be ignored. */ + status = cli_setpathinfo_basic(cli, + fname, + 0, /* create */ + 0, /* access */ + 0, /* write */ + 0, /* change */ + FILE_ATTRIBUTE_NORMAL); + if (!NT_STATUS_IS_OK(status)) { + printf("cli_setpathinfo_basic failed with %s\n", + nt_errstr(status)); + correct = false; + } + + /* Check attributes are correct. */ + correct = check_attributes(cli, + fname, + FILE_ATTRIBUTE_SYSTEM | + FILE_ATTRIBUTE_HIDDEN | + FILE_ATTRIBUTE_READONLY); + if (correct == false) { + goto out; + } + + /* Setting to (uint16_t)-1 should also be ignored. */ + status = cli_setpathinfo_basic(cli, + fname, + 0, /* create */ + 0, /* access */ + 0, /* write */ + 0, /* change */ + (uint16_t)-1); + if (!NT_STATUS_IS_OK(status)) { + printf("cli_setpathinfo_basic failed with %s\n", + nt_errstr(status)); + correct = false; + } + + /* Check attributes are correct. */ + correct = check_attributes(cli, + fname, + FILE_ATTRIBUTE_SYSTEM | + FILE_ATTRIBUTE_HIDDEN | + FILE_ATTRIBUTE_READONLY); + if (correct == false) { + goto out; + } + + /* Setting to 0 should clear them all. */ + status = cli_setpathinfo_basic(cli, + fname, + 0, /* create */ + 0, /* access */ + 0, /* write */ + 0, /* change */ + 0); + if (!NT_STATUS_IS_OK(status)) { + printf("cli_setpathinfo_basic failed with %s\n", + nt_errstr(status)); + correct = false; + } + + /* Check attributes are correct. */ + correct = check_attributes(cli, + fname, + FILE_ATTRIBUTE_NORMAL); + if (correct == false) { + goto out; + } + + out: + + cli_unlink(cli, + fname, + FILE_ATTRIBUTE_SYSTEM | + FILE_ATTRIBUTE_HIDDEN| + FILE_ATTRIBUTE_READONLY); + if (!torture_close_connection(cli)) { correct = False; } |