summaryrefslogtreecommitdiff
path: root/source4/torture
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2006-07-02 17:40:35 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:09:43 -0500
commit81d09a7f2ede7e1a25a14dbf942a5850d4f97bf0 (patch)
treeb82d63f1e721f90c59b4d8489e657e93f72a152f /source4/torture
parent81d590104493d0ff73c8c08d2573dd02dee78981 (diff)
downloadsamba-81d09a7f2ede7e1a25a14dbf942a5850d4f97bf0.tar.gz
samba-81d09a7f2ede7e1a25a14dbf942a5850d4f97bf0.tar.bz2
samba-81d09a7f2ede7e1a25a14dbf942a5850d4f97bf0.zip
r16759: Jeremy, another little error case for you :-)
For the paths with illegal characters we should return ERRDOS:ERRbadpath in the DOS error case. We return ERRDOS:ERRinvalidname... Volker (This used to be commit c2203068f46064d067bf43fe50f330ce49dfc08a)
Diffstat (limited to 'source4/torture')
-rw-r--r--source4/torture/raw/samba3misc.c135
1 files changed, 135 insertions, 0 deletions
diff --git a/source4/torture/raw/samba3misc.c b/source4/torture/raw/samba3misc.c
index cc996ca4a8..8b2fbd99a2 100644
--- a/source4/torture/raw/samba3misc.c
+++ b/source4/torture/raw/samba3misc.c
@@ -155,3 +155,138 @@ BOOL torture_samba3_checkfsp(struct torture_context *torture)
return ret;
}
+
+BOOL torture_samba3_badpath(struct torture_context *torture)
+{
+ struct smbcli_state *cli_nt;
+ struct smbcli_state *cli_dos;
+ const char *fname = "test.txt";
+ const char *dirname = "testdir";
+ char *fpath;
+ int fnum;
+ NTSTATUS status;
+ BOOL ret = True;
+ TALLOC_CTX *mem_ctx;
+ ssize_t nread;
+ char buf[16];
+ struct smbcli_tree *tree2;
+ BOOL nt_status_support;
+
+ if (!(mem_ctx = talloc_init("torture_samba3_badpath"))) {
+ d_printf("talloc_init failed\n");
+ return False;
+ }
+
+ nt_status_support = lp_nt_status_support();
+
+ if (!lp_set_cmdline("nt status support", "yes")) {
+ printf("Could not set 'nt status support = yes'\n");
+ goto fail;
+ }
+
+ if (!torture_open_connection(&cli_nt)) {
+ goto fail;
+ }
+
+ if (!lp_set_cmdline("nt status support", "no")) {
+ printf("Could not set 'nt status support = yes'\n");
+ goto fail;
+ }
+
+ if (!torture_open_connection(&cli_dos)) {
+ goto fail;
+ }
+
+ if (!lp_set_cmdline("nt status support",
+ nt_status_support ? "yes":"no")) {
+ printf("Could not reset 'nt status support = yes'");
+ goto fail;
+ }
+
+ smbcli_deltree(cli_nt->tree, dirname);
+
+ status = smbcli_mkdir(cli_nt->tree, dirname);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_printf("smbcli_mkdir failed: %s\n", nt_errstr(status));
+ ret = False;
+ goto done;
+ }
+
+ status = smbcli_chkpath(cli_nt->tree, dirname);
+ CHECK_STATUS(status, NT_STATUS_OK);
+
+ status = smbcli_chkpath(cli_nt->tree,
+ talloc_asprintf(mem_ctx, "%s\\bla", dirname));
+ CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND);
+
+ status = smbcli_chkpath(cli_dos->tree,
+ talloc_asprintf(mem_ctx, "%s\\bla", dirname));
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+ status = smbcli_chkpath(cli_nt->tree,
+ talloc_asprintf(mem_ctx, "%s\\bla\\blub",
+ dirname));
+ CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_NOT_FOUND);
+ status = smbcli_chkpath(cli_dos->tree,
+ talloc_asprintf(mem_ctx, "%s\\bla\\blub",
+ dirname));
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+ if (!(fpath = talloc_asprintf(mem_ctx, "%s\\%s", dirname, fname))) {
+ goto fail;
+ }
+ fnum = smbcli_open(cli_nt->tree, fpath, O_RDWR | O_CREAT, DENY_NONE);
+ if (fnum == -1) {
+ d_printf("Could not create file %s: %s\n", fpath,
+ smbcli_errstr(cli_nt->tree));
+ goto fail;
+ }
+ smbcli_close(cli_nt->tree, fnum);
+
+ status = smbcli_chkpath(cli_nt->tree, fpath);
+ CHECK_STATUS(status, NT_STATUS_NOT_A_DIRECTORY);
+ status = smbcli_chkpath(cli_dos->tree, fpath);
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+ status = smbcli_chkpath(cli_nt->tree, "..");
+ CHECK_STATUS(status, NT_STATUS_OBJECT_PATH_SYNTAX_BAD);
+ status = smbcli_chkpath(cli_dos->tree, "..");
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRinvalidpath));
+
+ status = smbcli_chkpath(cli_nt->tree, "\t");
+ CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID);
+ status = smbcli_chkpath(cli_dos->tree, "\t");
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+ status = smbcli_chkpath(cli_nt->tree, "\t\\bla");
+ CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID);
+ status = smbcli_chkpath(cli_dos->tree, "\t\\bla");
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+ status = smbcli_chkpath(cli_nt->tree, "<");
+ CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID);
+ status = smbcli_chkpath(cli_dos->tree, "<");
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+ status = smbcli_chkpath(cli_nt->tree, "<\\bla");
+ CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID);
+ status = smbcli_chkpath(cli_dos->tree, "<\\bla");
+ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS, ERRbadpath));
+
+ goto done;
+
+ fail:
+ ret = False;
+
+ done:
+ if (cli_nt != NULL) {
+ smbcli_deltree(cli_nt->tree, dirname);
+ torture_close_connection(cli_nt);
+ }
+ if (cli_dos != NULL) {
+ torture_close_connection(cli_dos);
+ }
+ talloc_free(mem_ctx);
+
+ return ret;
+}