diff options
author | Andrew Tridgell <tridge@samba.org> | 2003-08-13 16:04:21 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2003-08-13 16:04:21 +0000 |
commit | 75c0125fb71b0562e7bdd85c391764796b5f12f6 (patch) | |
tree | b589d2e6bbc2c517a3f79790d0ed309ef79f7507 /source4/torture/raw | |
parent | a3b86fe170beb70ffab8585a276ca1648fffd454 (diff) | |
download | samba-75c0125fb71b0562e7bdd85c391764796b5f12f6.tar.gz samba-75c0125fb71b0562e7bdd85c391764796b5f12f6.tar.bz2 samba-75c0125fb71b0562e7bdd85c391764796b5f12f6.zip |
- added SMBntrename test suite
- allow username of form DOMAIN\username or DOMAIN/username
- added ntrename to gentest
(This used to be commit 2b464472c17b791eb5b117f89d5aaea2bf60f6ad)
Diffstat (limited to 'source4/torture/raw')
-rw-r--r-- | source4/torture/raw/missing.txt | 1 | ||||
-rw-r--r-- | source4/torture/raw/rename.c | 208 |
2 files changed, 197 insertions, 12 deletions
diff --git a/source4/torture/raw/missing.txt b/source4/torture/raw/missing.txt index 8e026b78ff..9a33e7ed6f 100644 --- a/source4/torture/raw/missing.txt +++ b/source4/torture/raw/missing.txt @@ -92,6 +92,7 @@ trans2_setfileinfo trans2_fsctl trans2_mkdir trans2_findnext +NTrename SMB_QFS_ALLOCATION SMB_QFS_VOLUME SMB_QFS_VOLUME_INFO diff --git a/source4/torture/raw/rename.c b/source4/torture/raw/rename.c index 4cfa1c95c2..0e411299d0 100644 --- a/source4/torture/raw/rename.c +++ b/source4/torture/raw/rename.c @@ -28,6 +28,13 @@ goto done; \ }} while (0) +#define CHECK_VALUE(v, correct) do { \ + if ((v) != (correct)) { \ + printf("(%d) Incorrect %s %d - should be %d\n", \ + __LINE__, #v, (int)v, (int)correct); \ + ret = False; \ + }} while (0) + #define BASEDIR "\\testrename" /* @@ -35,13 +42,15 @@ */ static BOOL test_mv(struct cli_state *cli, TALLOC_CTX *mem_ctx) { - struct smb_rename io; + union smb_rename io; NTSTATUS status; BOOL ret = True; int fnum; const char *fname1 = BASEDIR "\\test1.txt"; const char *fname2 = BASEDIR "\\test2.txt"; + printf("Testing SMBmv\n"); + if (cli_deltree(cli, BASEDIR) == -1 || !cli_mkdir(cli, BASEDIR)) { printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli)); @@ -52,9 +61,10 @@ static BOOL test_mv(struct cli_state *cli, TALLOC_CTX *mem_ctx) fnum = create_complex_file(cli, mem_ctx, fname1); - io.in.pattern1 = fname1; - io.in.pattern2 = fname2; - io.in.attrib = 0; + io.generic.level = RAW_RENAME_RENAME; + io.rename.in.pattern1 = fname1; + io.rename.in.pattern2 = fname2; + io.rename.in.attrib = 0; status = smb_raw_rename(cli->tree, &io); CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION); @@ -62,11 +72,22 @@ static BOOL test_mv(struct cli_state *cli, TALLOC_CTX *mem_ctx) smb_raw_exit(cli->session); status = smb_raw_rename(cli->tree, &io); CHECK_STATUS(status, NT_STATUS_OK); + + printf("Trying self rename\n"); + io.rename.in.pattern1 = fname2; + io.rename.in.pattern2 = fname2; + status = smb_raw_rename(cli->tree, &io); + CHECK_STATUS(status, NT_STATUS_OK); + + io.rename.in.pattern1 = fname1; + io.rename.in.pattern2 = fname1; + status = smb_raw_rename(cli->tree, &io); + CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); printf("trying wildcard rename\n"); - io.in.pattern1 = BASEDIR "\\*.txt"; - io.in.pattern2 = fname1; + io.rename.in.pattern1 = BASEDIR "\\*.txt"; + io.rename.in.pattern2 = fname1; status = smb_raw_rename(cli->tree, &io); CHECK_STATUS(status, NT_STATUS_OK); @@ -76,8 +97,8 @@ static BOOL test_mv(struct cli_state *cli, TALLOC_CTX *mem_ctx) CHECK_STATUS(status, NT_STATUS_OK); printf("Trying extension change\n"); - io.in.pattern1 = BASEDIR "\\*.txt"; - io.in.pattern2 = BASEDIR "\\*.bak"; + io.rename.in.pattern1 = BASEDIR "\\*.txt"; + io.rename.in.pattern2 = BASEDIR "\\*.bak"; status = smb_raw_rename(cli->tree, &io); CHECK_STATUS(status, NT_STATUS_OK); @@ -86,13 +107,13 @@ static BOOL test_mv(struct cli_state *cli, TALLOC_CTX *mem_ctx) printf("Checking attrib handling\n"); torture_set_file_attribute(cli->tree, BASEDIR "\\test1.bak", FILE_ATTRIBUTE_HIDDEN); - io.in.pattern1 = BASEDIR "\\test1.bak"; - io.in.pattern2 = BASEDIR "\\*.txt"; - io.in.attrib = 0; + io.rename.in.pattern1 = BASEDIR "\\test1.bak"; + io.rename.in.pattern2 = BASEDIR "\\*.txt"; + io.rename.in.attrib = 0; status = smb_raw_rename(cli->tree, &io); CHECK_STATUS(status, NT_STATUS_NO_SUCH_FILE); - io.in.attrib = FILE_ATTRIBUTE_HIDDEN; + io.rename.in.attrib = FILE_ATTRIBUTE_HIDDEN; status = smb_raw_rename(cli->tree, &io); CHECK_STATUS(status, NT_STATUS_OK); @@ -103,6 +124,165 @@ done: } + +/* + test SMBntrename ops +*/ +static BOOL test_ntrename(struct cli_state *cli, TALLOC_CTX *mem_ctx) +{ + union smb_rename io; + NTSTATUS status; + BOOL ret = True; + int fnum; + const char *fname1 = BASEDIR "\\test1.txt"; + const char *fname2 = BASEDIR "\\test2.txt"; + union smb_fileinfo finfo; + + printf("Testing SMBntrename\n"); + + if (cli_deltree(cli, BASEDIR) == -1 || + !cli_mkdir(cli, BASEDIR)) { + printf("Unable to setup %s - %s\n", BASEDIR, cli_errstr(cli)); + return False; + } + + printf("Trying simple rename\n"); + + fnum = create_complex_file(cli, mem_ctx, fname1); + + io.generic.level = RAW_RENAME_NTRENAME; + io.ntrename.in.old_name = fname1; + io.ntrename.in.new_name = fname2; + io.ntrename.in.attrib = 0; + io.ntrename.in.root_fid = 0; + io.ntrename.in.flags = RENAME_FLAG_RENAME; + + status = smb_raw_rename(cli->tree, &io); + CHECK_STATUS(status, NT_STATUS_SHARING_VIOLATION); + + smb_raw_exit(cli->session); + status = smb_raw_rename(cli->tree, &io); + CHECK_STATUS(status, NT_STATUS_OK); + + printf("Trying self rename\n"); + io.ntrename.in.old_name = fname2; + io.ntrename.in.new_name = fname2; + status = smb_raw_rename(cli->tree, &io); + CHECK_STATUS(status, NT_STATUS_OK); + + io.ntrename.in.old_name = fname1; + io.ntrename.in.new_name = fname1; + status = smb_raw_rename(cli->tree, &io); + CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); + + printf("trying wildcard rename\n"); + io.ntrename.in.old_name = BASEDIR "\\*.txt"; + io.ntrename.in.new_name = fname1; + + status = smb_raw_rename(cli->tree, &io); + CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_SYNTAX_BAD); + + printf("Checking attrib handling\n"); + torture_set_file_attribute(cli->tree, fname2, FILE_ATTRIBUTE_HIDDEN); + io.ntrename.in.old_name = fname2; + io.ntrename.in.new_name = fname1; + io.ntrename.in.attrib = 0; + status = smb_raw_rename(cli->tree, &io); + CHECK_STATUS(status, NT_STATUS_NO_SUCH_FILE); + + io.ntrename.in.attrib = FILE_ATTRIBUTE_HIDDEN; + status = smb_raw_rename(cli->tree, &io); + CHECK_STATUS(status, NT_STATUS_OK); + + torture_set_file_attribute(cli->tree, fname1, FILE_ATTRIBUTE_NORMAL); + + printf("Checking hard link\n"); + io.ntrename.in.old_name = fname1; + io.ntrename.in.new_name = fname2; + io.ntrename.in.attrib = 0; + io.ntrename.in.flags = RENAME_FLAG_HARD_LINK; + status = smb_raw_rename(cli->tree, &io); + CHECK_STATUS(status, NT_STATUS_OK); + + torture_set_file_attribute(cli->tree, fname1, FILE_ATTRIBUTE_SYSTEM); + + finfo.generic.level = RAW_FILEINFO_ALL_INFO; + finfo.generic.in.fname = fname2; + status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo); + CHECK_STATUS(status, NT_STATUS_OK); + CHECK_VALUE(finfo.all_info.out.nlink, 2); + CHECK_VALUE(finfo.all_info.out.attrib, FILE_ATTRIBUTE_SYSTEM); + + finfo.generic.in.fname = fname1; + status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo); + CHECK_STATUS(status, NT_STATUS_OK); + CHECK_VALUE(finfo.all_info.out.nlink, 2); + CHECK_VALUE(finfo.all_info.out.attrib, FILE_ATTRIBUTE_SYSTEM); + + torture_set_file_attribute(cli->tree, fname1, FILE_ATTRIBUTE_NORMAL); + + cli_unlink(cli, fname2); + + finfo.generic.in.fname = fname1; + status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo); + CHECK_STATUS(status, NT_STATUS_OK); + CHECK_VALUE(finfo.all_info.out.nlink, 1); + + printf("Checking copy\n"); + io.ntrename.in.old_name = fname1; + io.ntrename.in.new_name = fname2; + io.ntrename.in.attrib = 0; + io.ntrename.in.flags = RENAME_FLAG_COPY; + status = smb_raw_rename(cli->tree, &io); + CHECK_STATUS(status, NT_STATUS_OK); + + torture_set_file_attribute(cli->tree, fname1, FILE_ATTRIBUTE_SYSTEM); + + finfo.generic.level = RAW_FILEINFO_ALL_INFO; + finfo.generic.in.fname = fname2; + status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo); + CHECK_STATUS(status, NT_STATUS_OK); + CHECK_VALUE(finfo.all_info.out.nlink, 1); + CHECK_VALUE(finfo.all_info.out.attrib, FILE_ATTRIBUTE_NORMAL); + + finfo.generic.in.fname = fname1; + status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo); + CHECK_STATUS(status, NT_STATUS_OK); + CHECK_VALUE(finfo.all_info.out.nlink, 1); + CHECK_VALUE(finfo.all_info.out.attrib, FILE_ATTRIBUTE_SYSTEM); + + torture_set_file_attribute(cli->tree, fname1, FILE_ATTRIBUTE_NORMAL); + + cli_unlink(cli, fname2); + + finfo.generic.in.fname = fname1; + status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo); + CHECK_STATUS(status, NT_STATUS_OK); + CHECK_VALUE(finfo.all_info.out.nlink, 1); + + printf("Checking invalid flags\n"); + io.ntrename.in.old_name = fname1; + io.ntrename.in.new_name = fname2; + io.ntrename.in.attrib = 0; + io.ntrename.in.flags = 0; + status = smb_raw_rename(cli->tree, &io); + CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); + + io.ntrename.in.flags = 300; + status = smb_raw_rename(cli->tree, &io); + CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); + + io.ntrename.in.flags = 0x106; + status = smb_raw_rename(cli->tree, &io); + CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); + +done: + smb_raw_exit(cli->session); + cli_deltree(cli, BASEDIR); + return ret; +} + + /* basic testing of rename calls */ @@ -122,6 +302,10 @@ BOOL torture_raw_rename(int dummy) ret = False; } + if (!test_ntrename(cli, mem_ctx)) { + ret = False; + } + torture_close_connection(cli); talloc_destroy(mem_ctx); return ret; |