From c1cbe6e0b0917a3781cb45fb732b7e457cfecdb1 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 12 Jun 2006 10:18:15 +0000 Subject: r16149: This is a very Samba3 specific test: It tests whether 'hide unreadable' and 'hide unwriteable files' actually do what they are supposed to do. Volker (This used to be commit 7bf02a5e0f2c53bd516033d31466cd0cf22d3496) --- source4/torture/raw/samba3hide.c | 321 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 321 insertions(+) create mode 100644 source4/torture/raw/samba3hide.c (limited to 'source4/torture/raw/samba3hide.c') diff --git a/source4/torture/raw/samba3hide.c b/source4/torture/raw/samba3hide.c new file mode 100644 index 0000000000..8f47816504 --- /dev/null +++ b/source4/torture/raw/samba3hide.c @@ -0,0 +1,321 @@ +/* + Unix SMB/CIFS implementation. + Test samba3 hide unreadable/unwriteable + Copyright (C) Volker Lendecke 2006 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "torture/torture.h" +#include "libcli/raw/libcliraw.h" +#include "system/time.h" +#include "system/filesys.h" +#include "libcli/libcli.h" +#include "torture/util.h" + +static void init_unixinfo_nochange(union smb_setfileinfo *info) +{ + ZERO_STRUCTP(info); + info->unix_basic.level = RAW_SFILEINFO_UNIX_BASIC; + info->unix_basic.in.mode = SMB_MODE_NO_CHANGE; + + info->unix_basic.in.end_of_file = SMB_SIZE_NO_CHANGE_HI; + info->unix_basic.in.end_of_file <<= 32; + info->unix_basic.in.end_of_file |= SMB_SIZE_NO_CHANGE_LO; + + info->unix_basic.in.num_bytes = SMB_SIZE_NO_CHANGE_HI; + info->unix_basic.in.num_bytes <<= 32; + info->unix_basic.in.num_bytes |= SMB_SIZE_NO_CHANGE_LO; + + info->unix_basic.in.status_change_time = SMB_TIME_NO_CHANGE_HI; + info->unix_basic.in.status_change_time <<= 32; + info->unix_basic.in.status_change_time = SMB_TIME_NO_CHANGE_LO; + + info->unix_basic.in.access_time = SMB_TIME_NO_CHANGE_HI; + info->unix_basic.in.access_time <<= 32; + info->unix_basic.in.access_time = SMB_TIME_NO_CHANGE_LO; + + info->unix_basic.in.change_time = SMB_TIME_NO_CHANGE_HI; + info->unix_basic.in.change_time <<= 32; + info->unix_basic.in.change_time = SMB_TIME_NO_CHANGE_LO; + + info->unix_basic.in.uid = SMB_UID_NO_CHANGE; + info->unix_basic.in.gid = SMB_GID_NO_CHANGE; +} + +struct list_state { + const char *fname; + BOOL visible; +}; + +static void set_visible(struct clilist_file_info *i, const char *mask, + void *priv) +{ + struct list_state *state = priv; + + if (strcasecmp_m(state->fname, i->name) == 0) + state->visible = True; +} + +static BOOL is_visible(struct smbcli_tree *tree, const char *fname) +{ + struct list_state state; + + state.visible = False; + state.fname = fname; + + if (smbcli_list(tree, "*.*", 0, set_visible, &state) < 0) { + return False; + } + return state.visible; +} + +static BOOL is_readable(struct smbcli_tree *tree, const char *fname) +{ + int fnum; + fnum = smbcli_open(tree, fname, O_RDONLY, DENY_NONE); + if (fnum < 0) { + return False; + } + smbcli_close(tree, fnum); + return True; +} + +static BOOL is_writeable(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree, + const char *fname) +{ + int fnum; + fnum = smbcli_open(tree, fname, O_WRONLY, DENY_NONE); + if (fnum < 0) { + return False; + } + smbcli_close(tree, fnum); + return True; +} + +/* + * This is not an exact method because there's a ton of reasons why a getatr + * might fail. But for our purposes it's sufficient. + */ + +static BOOL smbcli_file_exists(struct smbcli_tree *tree, const char *fname) +{ + return NT_STATUS_IS_OK(smbcli_getatr(tree, fname, NULL, NULL, NULL)); +} + +static NTSTATUS smbcli_chmod(struct smbcli_tree *tree, const char *fname, + uint64_t permissions) +{ + union smb_setfileinfo sfinfo; + init_unixinfo_nochange(&sfinfo); + sfinfo.unix_basic.in.file.path = fname; + sfinfo.unix_basic.in.permissions = permissions; + return smb_raw_setpathinfo(tree, &sfinfo); +} + +static NTSTATUS second_tcon(TALLOC_CTX *mem_ctx, + struct smbcli_session *session, + const char *sharename, + struct smbcli_tree **res) +{ + union smb_tcon tcon; + struct smbcli_tree *result; + TALLOC_CTX *tmp_ctx; + NTSTATUS status; + + if ((tmp_ctx = talloc_new(mem_ctx)) == NULL) { + return NT_STATUS_NO_MEMORY; + } + + result = smbcli_tree_init(session, tmp_ctx, False); + if (result == NULL) { + talloc_free(tmp_ctx); + return NT_STATUS_NO_MEMORY; + } + + tcon.generic.level = RAW_TCON_TCONX; + tcon.tconx.in.flags = 0; + + /* Ignore share mode security here */ + tcon.tconx.in.password = data_blob(NULL, 0); + tcon.tconx.in.path = sharename; + tcon.tconx.in.device = "????"; + + status = smb_raw_tcon(result, tmp_ctx, &tcon); + if (!NT_STATUS_IS_OK(status)) { + talloc_free(tmp_ctx); + return status; + } + + result->tid = tcon.tconx.out.tid; + *res = talloc_steal(mem_ctx, result); + talloc_free(tmp_ctx); + return NT_STATUS_OK; +} + +BOOL torture_samba3_hide(struct torture_context *torture) +{ + struct smbcli_state *cli; + BOOL ret = False; + TALLOC_CTX *mem_ctx; + const char *fname = "test.txt"; + int fnum; + NTSTATUS status; + struct smbcli_tree *hideunread; + struct smbcli_tree *hideunwrite; + + mem_ctx = talloc_init("torture_samba3_unixinfo"); + if (mem_ctx == NULL) { + d_printf("talloc_init failed\n"); + return False; + } + + if (!torture_open_connection_share( + mem_ctx, &cli, lp_parm_string(-1, "torture", "host"), + lp_parm_string(-1, "torture", "share"), NULL)) { + d_printf("torture_open_connection_share failed\n"); + goto done; + } + + status = second_tcon(mem_ctx, cli->session, "hideunread", + &hideunread); + if (!NT_STATUS_IS_OK(status)) { + d_printf("second_tcon(hideunread) failed: %s\n", + nt_errstr(status)); + goto done; + } + + status = second_tcon(mem_ctx, cli->session, "hideunwrite", + &hideunwrite); + if (!NT_STATUS_IS_OK(status)) { + d_printf("second_tcon(hideunwrite) failed: %s\n", + nt_errstr(status)); + goto done; + } + + status = smbcli_unlink(cli->tree, fname); + if (NT_STATUS_EQUAL(status, NT_STATUS_CANNOT_DELETE)) { + smbcli_setatr(cli->tree, fname, 0, -1); + smbcli_unlink(cli->tree, fname); + } + + fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); + if (fnum == -1) { + d_printf("Failed to create %s - %s\n", fname, + smbcli_errstr(cli->tree)); + goto done; + } + + smbcli_close(cli->tree, fnum); + + if (!smbcli_file_exists(cli->tree, fname)) { + d_printf("%s does not exist\n", fname); + goto done; + } + + /* R/W file should be visible everywhere */ + + status = smbcli_chmod(cli->tree, fname, UNIX_R_USR|UNIX_W_USR); + if (!NT_STATUS_IS_OK(status)) { + d_printf("smbcli_chmod failed: %s\n", nt_errstr(status)); + goto done; + } + if (!is_writeable(mem_ctx, cli->tree, fname)) { + d_printf("File not writable\n"); + goto done; + } + if (!is_readable(cli->tree, fname)) { + d_printf("File not readable\n"); + goto done; + } + if (!is_visible(cli->tree, fname)) { + d_printf("r/w file not visible via normal share\n"); + goto done; + } + if (!is_visible(hideunread, fname)) { + d_printf("r/w file not visible via hide unreadable\n"); + goto done; + } + if (!is_visible(hideunwrite, fname)) { + d_printf("r/w file not visible via hide unwriteable\n"); + goto done; + } + + /* R/O file should not be visible via hide unwriteable files */ + + status = smbcli_chmod(cli->tree, fname, UNIX_R_USR); + + if (!NT_STATUS_IS_OK(status)) { + d_printf("smbcli_chmod failed: %s\n", nt_errstr(status)); + goto done; + } + if (is_writeable(mem_ctx, cli->tree, fname)) { + d_printf("r/o is writable\n"); + goto done; + } + if (!is_readable(cli->tree, fname)) { + d_printf("r/o not readable\n"); + goto done; + } + if (!is_visible(cli->tree, fname)) { + d_printf("r/o file not visible via normal share\n"); + goto done; + } + if (!is_visible(hideunread, fname)) { + d_printf("r/o file not visible via hide unreadable\n"); + goto done; + } + if (is_visible(hideunwrite, fname)) { + d_printf("r/o file visible via hide unwriteable\n"); + goto done; + } + + /* inaccessible file should be only visible on normal share */ + + status = smbcli_chmod(cli->tree, fname, 0); + if (!NT_STATUS_IS_OK(status)) { + d_printf("smbcli_chmod failed: %s\n", nt_errstr(status)); + goto done; + } + if (is_writeable(mem_ctx, cli->tree, fname)) { + d_printf("inaccessible file is writable\n"); + goto done; + } + if (is_readable(cli->tree, fname)) { + d_printf("inaccessible file is readable\n"); + goto done; + } + if (!is_visible(cli->tree, fname)) { + d_printf("inaccessible file not visible via normal share\n"); + goto done; + } + if (is_visible(hideunread, fname)) { + d_printf("inaccessible file visible via hide unreadable\n"); + goto done; + } + if (is_visible(hideunwrite, fname)) { + d_printf("inaccessible file visible via hide unwriteable\n"); + goto done; + } + + + ret = True; + + done: + talloc_free(mem_ctx); + return ret; +} + -- cgit From dcbd023aa033b97bb685708efe6df40c331727f3 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 12 Jun 2006 11:45:43 +0000 Subject: r16151: |= fix found by metze (This used to be commit ce54a15384a42c971226ef513849a0ccbf9a1ed3) --- source4/torture/raw/samba3hide.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/torture/raw/samba3hide.c') diff --git a/source4/torture/raw/samba3hide.c b/source4/torture/raw/samba3hide.c index 8f47816504..1aeda643e3 100644 --- a/source4/torture/raw/samba3hide.c +++ b/source4/torture/raw/samba3hide.c @@ -46,11 +46,11 @@ static void init_unixinfo_nochange(union smb_setfileinfo *info) info->unix_basic.in.access_time = SMB_TIME_NO_CHANGE_HI; info->unix_basic.in.access_time <<= 32; - info->unix_basic.in.access_time = SMB_TIME_NO_CHANGE_LO; + info->unix_basic.in.access_time |= SMB_TIME_NO_CHANGE_LO; info->unix_basic.in.change_time = SMB_TIME_NO_CHANGE_HI; info->unix_basic.in.change_time <<= 32; - info->unix_basic.in.change_time = SMB_TIME_NO_CHANGE_LO; + info->unix_basic.in.change_time |= SMB_TIME_NO_CHANGE_LO; info->unix_basic.in.uid = SMB_UID_NO_CHANGE; info->unix_basic.in.gid = SMB_GID_NO_CHANGE; -- cgit From 90be000cd5d02e480bba8d68a56e5b8a2f8711ab Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 12 Jun 2006 23:01:51 +0000 Subject: r16173: Use memory context provided by smbtorture. (This used to be commit 88046d59517a595cfb8e9385ad87e8460eececac) --- source4/torture/raw/samba3hide.c | 73 +++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 43 deletions(-) (limited to 'source4/torture/raw/samba3hide.c') diff --git a/source4/torture/raw/samba3hide.c b/source4/torture/raw/samba3hide.c index 1aeda643e3..1f4f987a43 100644 --- a/source4/torture/raw/samba3hide.c +++ b/source4/torture/raw/samba3hide.c @@ -169,41 +169,33 @@ static NTSTATUS second_tcon(TALLOC_CTX *mem_ctx, BOOL torture_samba3_hide(struct torture_context *torture) { struct smbcli_state *cli; - BOOL ret = False; - TALLOC_CTX *mem_ctx; const char *fname = "test.txt"; int fnum; NTSTATUS status; struct smbcli_tree *hideunread; struct smbcli_tree *hideunwrite; - mem_ctx = talloc_init("torture_samba3_unixinfo"); - if (mem_ctx == NULL) { - d_printf("talloc_init failed\n"); - return False; - } - if (!torture_open_connection_share( - mem_ctx, &cli, lp_parm_string(-1, "torture", "host"), + torture, &cli, lp_parm_string(-1, "torture", "host"), lp_parm_string(-1, "torture", "share"), NULL)) { d_printf("torture_open_connection_share failed\n"); - goto done; + return False; } - status = second_tcon(mem_ctx, cli->session, "hideunread", + status = second_tcon(torture, cli->session, "hideunread", &hideunread); if (!NT_STATUS_IS_OK(status)) { d_printf("second_tcon(hideunread) failed: %s\n", nt_errstr(status)); - goto done; + return False; } - status = second_tcon(mem_ctx, cli->session, "hideunwrite", + status = second_tcon(torture, cli->session, "hideunwrite", &hideunwrite); if (!NT_STATUS_IS_OK(status)) { d_printf("second_tcon(hideunwrite) failed: %s\n", nt_errstr(status)); - goto done; + return False; } status = smbcli_unlink(cli->tree, fname); @@ -216,14 +208,14 @@ BOOL torture_samba3_hide(struct torture_context *torture) if (fnum == -1) { d_printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); - goto done; + return False; } smbcli_close(cli->tree, fnum); if (!smbcli_file_exists(cli->tree, fname)) { d_printf("%s does not exist\n", fname); - goto done; + return False; } /* R/W file should be visible everywhere */ @@ -231,27 +223,27 @@ BOOL torture_samba3_hide(struct torture_context *torture) status = smbcli_chmod(cli->tree, fname, UNIX_R_USR|UNIX_W_USR); if (!NT_STATUS_IS_OK(status)) { d_printf("smbcli_chmod failed: %s\n", nt_errstr(status)); - goto done; + return False; } - if (!is_writeable(mem_ctx, cli->tree, fname)) { + if (!is_writeable(torture, cli->tree, fname)) { d_printf("File not writable\n"); - goto done; + return False; } if (!is_readable(cli->tree, fname)) { d_printf("File not readable\n"); - goto done; + return False; } if (!is_visible(cli->tree, fname)) { d_printf("r/w file not visible via normal share\n"); - goto done; + return False; } if (!is_visible(hideunread, fname)) { d_printf("r/w file not visible via hide unreadable\n"); - goto done; + return False; } if (!is_visible(hideunwrite, fname)) { d_printf("r/w file not visible via hide unwriteable\n"); - goto done; + return False; } /* R/O file should not be visible via hide unwriteable files */ @@ -260,27 +252,27 @@ BOOL torture_samba3_hide(struct torture_context *torture) if (!NT_STATUS_IS_OK(status)) { d_printf("smbcli_chmod failed: %s\n", nt_errstr(status)); - goto done; + return False; } - if (is_writeable(mem_ctx, cli->tree, fname)) { + if (is_writeable(torture, cli->tree, fname)) { d_printf("r/o is writable\n"); - goto done; + return False; } if (!is_readable(cli->tree, fname)) { d_printf("r/o not readable\n"); - goto done; + return False; } if (!is_visible(cli->tree, fname)) { d_printf("r/o file not visible via normal share\n"); - goto done; + return False; } if (!is_visible(hideunread, fname)) { d_printf("r/o file not visible via hide unreadable\n"); - goto done; + return False; } if (is_visible(hideunwrite, fname)) { d_printf("r/o file visible via hide unwriteable\n"); - goto done; + return False; } /* inaccessible file should be only visible on normal share */ @@ -288,34 +280,29 @@ BOOL torture_samba3_hide(struct torture_context *torture) status = smbcli_chmod(cli->tree, fname, 0); if (!NT_STATUS_IS_OK(status)) { d_printf("smbcli_chmod failed: %s\n", nt_errstr(status)); - goto done; + return False; } - if (is_writeable(mem_ctx, cli->tree, fname)) { + if (is_writeable(torture, cli->tree, fname)) { d_printf("inaccessible file is writable\n"); - goto done; + return False; } if (is_readable(cli->tree, fname)) { d_printf("inaccessible file is readable\n"); - goto done; + return False; } if (!is_visible(cli->tree, fname)) { d_printf("inaccessible file not visible via normal share\n"); - goto done; + return False; } if (is_visible(hideunread, fname)) { d_printf("inaccessible file visible via hide unreadable\n"); - goto done; + return False; } if (is_visible(hideunwrite, fname)) { d_printf("inaccessible file visible via hide unwriteable\n"); - goto done; + return False; } - - ret = True; - - done: - talloc_free(mem_ctx); - return ret; + return True; } -- cgit From 414c47633d89d87011fda08c3c2b8dcbbfbcc2a8 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 28 Jun 2006 22:09:03 +0000 Subject: r16657: Test Jerry's iTunes bug, along with some more error conditions Volker (This used to be commit 12aa900eb2ffde3711a30c7e063bfba95128e91d) --- source4/torture/raw/samba3hide.c | 49 ++++------------------------------------ 1 file changed, 4 insertions(+), 45 deletions(-) (limited to 'source4/torture/raw/samba3hide.c') diff --git a/source4/torture/raw/samba3hide.c b/source4/torture/raw/samba3hide.c index 1f4f987a43..da23cfb1f1 100644 --- a/source4/torture/raw/samba3hide.c +++ b/source4/torture/raw/samba3hide.c @@ -126,46 +126,6 @@ static NTSTATUS smbcli_chmod(struct smbcli_tree *tree, const char *fname, return smb_raw_setpathinfo(tree, &sfinfo); } -static NTSTATUS second_tcon(TALLOC_CTX *mem_ctx, - struct smbcli_session *session, - const char *sharename, - struct smbcli_tree **res) -{ - union smb_tcon tcon; - struct smbcli_tree *result; - TALLOC_CTX *tmp_ctx; - NTSTATUS status; - - if ((tmp_ctx = talloc_new(mem_ctx)) == NULL) { - return NT_STATUS_NO_MEMORY; - } - - result = smbcli_tree_init(session, tmp_ctx, False); - if (result == NULL) { - talloc_free(tmp_ctx); - return NT_STATUS_NO_MEMORY; - } - - tcon.generic.level = RAW_TCON_TCONX; - tcon.tconx.in.flags = 0; - - /* Ignore share mode security here */ - tcon.tconx.in.password = data_blob(NULL, 0); - tcon.tconx.in.path = sharename; - tcon.tconx.in.device = "????"; - - status = smb_raw_tcon(result, tmp_ctx, &tcon); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(tmp_ctx); - return status; - } - - result->tid = tcon.tconx.out.tid; - *res = talloc_steal(mem_ctx, result); - talloc_free(tmp_ctx); - return NT_STATUS_OK; -} - BOOL torture_samba3_hide(struct torture_context *torture) { struct smbcli_state *cli; @@ -182,16 +142,16 @@ BOOL torture_samba3_hide(struct torture_context *torture) return False; } - status = second_tcon(torture, cli->session, "hideunread", - &hideunread); + status = torture_second_tcon(torture, cli->session, "hideunread", + &hideunread); if (!NT_STATUS_IS_OK(status)) { d_printf("second_tcon(hideunread) failed: %s\n", nt_errstr(status)); return False; } - status = second_tcon(torture, cli->session, "hideunwrite", - &hideunwrite); + status = torture_second_tcon(torture, cli->session, "hideunwrite", + &hideunwrite); if (!NT_STATUS_IS_OK(status)) { d_printf("second_tcon(hideunwrite) failed: %s\n", nt_errstr(status)); @@ -305,4 +265,3 @@ BOOL torture_samba3_hide(struct torture_context *torture) return True; } - -- cgit From a39f239cb28e4ac6be207d4179bacffce97f1b3e Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 18 Oct 2006 14:23:19 +0000 Subject: r19392: Use torture_setting_* rather than lp_parm_* where possible. (This used to be commit b28860978fe29c5b10abfb8c59d7182864e21dd6) --- source4/torture/raw/samba3hide.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/torture/raw/samba3hide.c') diff --git a/source4/torture/raw/samba3hide.c b/source4/torture/raw/samba3hide.c index da23cfb1f1..eed38eb772 100644 --- a/source4/torture/raw/samba3hide.c +++ b/source4/torture/raw/samba3hide.c @@ -136,8 +136,8 @@ BOOL torture_samba3_hide(struct torture_context *torture) struct smbcli_tree *hideunwrite; if (!torture_open_connection_share( - torture, &cli, lp_parm_string(-1, "torture", "host"), - lp_parm_string(-1, "torture", "share"), NULL)) { + torture, &cli, torture_setting_string(torture, "host", NULL), + torture_setting_string(torture, "share", NULL), NULL)) { d_printf("torture_open_connection_share failed\n"); return False; } -- cgit From 0221d44ef4b62101d61a5275dab914c96ad326ee Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 5 Jan 2007 15:12:32 +0000 Subject: r20549: obvious bug fix.. (This used to be commit f0aa63e39050c7ac10b9d51c5cecc753b257be9a) --- source4/torture/raw/samba3hide.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture/raw/samba3hide.c') diff --git a/source4/torture/raw/samba3hide.c b/source4/torture/raw/samba3hide.c index eed38eb772..4fa2a6ab9b 100644 --- a/source4/torture/raw/samba3hide.c +++ b/source4/torture/raw/samba3hide.c @@ -42,7 +42,7 @@ static void init_unixinfo_nochange(union smb_setfileinfo *info) info->unix_basic.in.status_change_time = SMB_TIME_NO_CHANGE_HI; info->unix_basic.in.status_change_time <<= 32; - info->unix_basic.in.status_change_time = SMB_TIME_NO_CHANGE_LO; + info->unix_basic.in.status_change_time |= SMB_TIME_NO_CHANGE_LO; info->unix_basic.in.access_time = SMB_TIME_NO_CHANGE_HI; info->unix_basic.in.access_time <<= 32; -- cgit From 9e1a690d2830fe0209424194399ae988d5498cef Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 5 Jan 2007 16:02:42 +0000 Subject: r20552: Little Samba3 test to force smb_close to return an error. Set delete on close, and then remove perms from the parent dir.... Volker (This used to be commit f24c5052576d4951738f83c3b238d2c251d4553b) --- source4/torture/raw/samba3hide.c | 72 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) (limited to 'source4/torture/raw/samba3hide.c') diff --git a/source4/torture/raw/samba3hide.c b/source4/torture/raw/samba3hide.c index 4fa2a6ab9b..8c90ed49b2 100644 --- a/source4/torture/raw/samba3hide.c +++ b/source4/torture/raw/samba3hide.c @@ -64,7 +64,7 @@ struct list_state { static void set_visible(struct clilist_file_info *i, const char *mask, void *priv) { - struct list_state *state = priv; + struct list_state *state = (struct list_state *)priv; if (strcasecmp_m(state->fname, i->name) == 0) state->visible = True; @@ -265,3 +265,73 @@ BOOL torture_samba3_hide(struct torture_context *torture) return True; } + +/* + * Try to force smb_close to return an error. The only way I can think of is + * to open a file with delete on close, chmod the parent dir to 000 and then + * close. smb_close should return NT_STATUS_ACCESS_DENIED. + */ + +BOOL torture_samba3_closeerr(struct torture_context *tctx) +{ + struct smbcli_state *cli = NULL; + BOOL result = False; + NTSTATUS status; + const char *dname = "closeerr.dir"; + const char *fname = "closeerr.dir\\closerr.txt"; + int fnum; + + if (!torture_open_connection(&cli, 0)) { + goto fail; + } + + smbcli_deltree(cli->tree, dname); + + torture_assert_ntstatus_ok( + tctx, smbcli_mkdir(cli->tree, dname), + talloc_asprintf(tctx, "smbcli_mdir failed: (%s)\n", + smbcli_errstr(cli->tree))); + + fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, + DENY_NONE); + torture_assert(tctx, fnum != -1, + talloc_asprintf(tctx, "smbcli_open failed: %s\n", + smbcli_errstr(cli->tree))); + smbcli_close(cli->tree, fnum); + + fnum = smbcli_nt_create_full(cli->tree, fname, 0, + SEC_RIGHTS_FILE_ALL, + FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_DELETE, + NTCREATEX_DISP_OPEN, 0, 0); + + torture_assert(tctx, fnum != -1, + talloc_asprintf(tctx, "smbcli_open failed: %s\n", + smbcli_errstr(cli->tree))); + + status = smbcli_nt_delete_on_close(cli->tree, fnum, True); + + torture_assert_ntstatus_ok(tctx, status, + "setting delete_on_close on file failed !"); + + status = smbcli_chmod(cli->tree, dname, 0); + + torture_assert_ntstatus_ok(tctx, status, + "smbcli_chmod on file failed !"); + + status = smbcli_close(cli->tree, fnum); + + smbcli_chmod(cli->tree, dname, UNIX_R_USR|UNIX_W_USR|UNIX_X_USR); + smbcli_deltree(cli->tree, dname); + + torture_assert_ntstatus_equal(tctx, status, NT_STATUS_ACCESS_DENIED, + "smbcli_close"); + + result = True; + + fail: + if (cli) { + torture_close_connection(cli); + } + return result; +} -- cgit From aeda6017ac8954a829cd300dd5e3c8cb05d0b896 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 8 Jan 2007 16:11:44 +0000 Subject: r20613: The individual tests are fine, I did run samba3badpath, but raw-samba3hide left test.txt with permissions 000 behind... Volker (This used to be commit fdd501f8032dceb05989c582132b036bb22e6fb1) --- source4/torture/raw/samba3hide.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/torture/raw/samba3hide.c') diff --git a/source4/torture/raw/samba3hide.c b/source4/torture/raw/samba3hide.c index 8c90ed49b2..d26ff98184 100644 --- a/source4/torture/raw/samba3hide.c +++ b/source4/torture/raw/samba3hide.c @@ -263,6 +263,9 @@ BOOL torture_samba3_hide(struct torture_context *torture) return False; } + smbcli_chmod(cli->tree, fname, UNIX_R_USR|UNIX_W_USR); + smbcli_unlink(cli->tree, fname); + return True; } -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/torture/raw/samba3hide.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/torture/raw/samba3hide.c') diff --git a/source4/torture/raw/samba3hide.c b/source4/torture/raw/samba3hide.c index d26ff98184..3fe151f009 100644 --- a/source4/torture/raw/samba3hide.c +++ b/source4/torture/raw/samba3hide.c @@ -5,7 +5,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -14,8 +14,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From cd962355abad90a2161765a7be7d26e63572cab7 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 7 Sep 2007 15:08:14 +0000 Subject: r25000: Fix some more C++ compatibility warnings. (This used to be commit 08bb1ef643ab906f1645cf6f32763dc73b1884e4) --- source4/torture/raw/samba3hide.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/torture/raw/samba3hide.c') diff --git a/source4/torture/raw/samba3hide.c b/source4/torture/raw/samba3hide.c index 3fe151f009..309f65487a 100644 --- a/source4/torture/raw/samba3hide.c +++ b/source4/torture/raw/samba3hide.c @@ -125,7 +125,7 @@ static NTSTATUS smbcli_chmod(struct smbcli_tree *tree, const char *fname, return smb_raw_setpathinfo(tree, &sfinfo); } -BOOL torture_samba3_hide(struct torture_context *torture) +bool torture_samba3_hide(struct torture_context *torture) { struct smbcli_state *cli; const char *fname = "test.txt"; @@ -274,7 +274,7 @@ BOOL torture_samba3_hide(struct torture_context *torture) * close. smb_close should return NT_STATUS_ACCESS_DENIED. */ -BOOL torture_samba3_closeerr(struct torture_context *tctx) +bool torture_samba3_closeerr(struct torture_context *tctx) { struct smbcli_state *cli = NULL; BOOL result = False; -- cgit From 2151cde58014ea2e822c13d2f8a369b45dc19ca8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 6 Oct 2007 22:28:14 +0000 Subject: r25554: Convert last instances of BOOL, True and False to the standard types. (This used to be commit 566aa14139510788548a874e9213d91317f83ca9) --- source4/torture/raw/samba3hide.c | 78 ++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 39 deletions(-) (limited to 'source4/torture/raw/samba3hide.c') diff --git a/source4/torture/raw/samba3hide.c b/source4/torture/raw/samba3hide.c index 309f65487a..8fe3aa4d2d 100644 --- a/source4/torture/raw/samba3hide.c +++ b/source4/torture/raw/samba3hide.c @@ -57,7 +57,7 @@ static void init_unixinfo_nochange(union smb_setfileinfo *info) struct list_state { const char *fname; - BOOL visible; + bool visible; }; static void set_visible(struct clilist_file_info *i, const char *mask, @@ -66,43 +66,43 @@ static void set_visible(struct clilist_file_info *i, const char *mask, struct list_state *state = (struct list_state *)priv; if (strcasecmp_m(state->fname, i->name) == 0) - state->visible = True; + state->visible = true; } -static BOOL is_visible(struct smbcli_tree *tree, const char *fname) +static bool is_visible(struct smbcli_tree *tree, const char *fname) { struct list_state state; - state.visible = False; + state.visible = false; state.fname = fname; if (smbcli_list(tree, "*.*", 0, set_visible, &state) < 0) { - return False; + return false; } return state.visible; } -static BOOL is_readable(struct smbcli_tree *tree, const char *fname) +static bool is_readable(struct smbcli_tree *tree, const char *fname) { int fnum; fnum = smbcli_open(tree, fname, O_RDONLY, DENY_NONE); if (fnum < 0) { - return False; + return false; } smbcli_close(tree, fnum); - return True; + return true; } -static BOOL is_writeable(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree, +static bool is_writeable(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree, const char *fname) { int fnum; fnum = smbcli_open(tree, fname, O_WRONLY, DENY_NONE); if (fnum < 0) { - return False; + return false; } smbcli_close(tree, fnum); - return True; + return true; } /* @@ -110,7 +110,7 @@ static BOOL is_writeable(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree, * might fail. But for our purposes it's sufficient. */ -static BOOL smbcli_file_exists(struct smbcli_tree *tree, const char *fname) +static bool smbcli_file_exists(struct smbcli_tree *tree, const char *fname) { return NT_STATUS_IS_OK(smbcli_getatr(tree, fname, NULL, NULL, NULL)); } @@ -138,7 +138,7 @@ bool torture_samba3_hide(struct torture_context *torture) torture, &cli, torture_setting_string(torture, "host", NULL), torture_setting_string(torture, "share", NULL), NULL)) { d_printf("torture_open_connection_share failed\n"); - return False; + return false; } status = torture_second_tcon(torture, cli->session, "hideunread", @@ -146,7 +146,7 @@ bool torture_samba3_hide(struct torture_context *torture) if (!NT_STATUS_IS_OK(status)) { d_printf("second_tcon(hideunread) failed: %s\n", nt_errstr(status)); - return False; + return false; } status = torture_second_tcon(torture, cli->session, "hideunwrite", @@ -154,7 +154,7 @@ bool torture_samba3_hide(struct torture_context *torture) if (!NT_STATUS_IS_OK(status)) { d_printf("second_tcon(hideunwrite) failed: %s\n", nt_errstr(status)); - return False; + return false; } status = smbcli_unlink(cli->tree, fname); @@ -167,14 +167,14 @@ bool torture_samba3_hide(struct torture_context *torture) if (fnum == -1) { d_printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); - return False; + return false; } smbcli_close(cli->tree, fnum); if (!smbcli_file_exists(cli->tree, fname)) { d_printf("%s does not exist\n", fname); - return False; + return false; } /* R/W file should be visible everywhere */ @@ -182,27 +182,27 @@ bool torture_samba3_hide(struct torture_context *torture) status = smbcli_chmod(cli->tree, fname, UNIX_R_USR|UNIX_W_USR); if (!NT_STATUS_IS_OK(status)) { d_printf("smbcli_chmod failed: %s\n", nt_errstr(status)); - return False; + return false; } if (!is_writeable(torture, cli->tree, fname)) { d_printf("File not writable\n"); - return False; + return false; } if (!is_readable(cli->tree, fname)) { d_printf("File not readable\n"); - return False; + return false; } if (!is_visible(cli->tree, fname)) { d_printf("r/w file not visible via normal share\n"); - return False; + return false; } if (!is_visible(hideunread, fname)) { d_printf("r/w file not visible via hide unreadable\n"); - return False; + return false; } if (!is_visible(hideunwrite, fname)) { d_printf("r/w file not visible via hide unwriteable\n"); - return False; + return false; } /* R/O file should not be visible via hide unwriteable files */ @@ -211,27 +211,27 @@ bool torture_samba3_hide(struct torture_context *torture) if (!NT_STATUS_IS_OK(status)) { d_printf("smbcli_chmod failed: %s\n", nt_errstr(status)); - return False; + return false; } if (is_writeable(torture, cli->tree, fname)) { d_printf("r/o is writable\n"); - return False; + return false; } if (!is_readable(cli->tree, fname)) { d_printf("r/o not readable\n"); - return False; + return false; } if (!is_visible(cli->tree, fname)) { d_printf("r/o file not visible via normal share\n"); - return False; + return false; } if (!is_visible(hideunread, fname)) { d_printf("r/o file not visible via hide unreadable\n"); - return False; + return false; } if (is_visible(hideunwrite, fname)) { d_printf("r/o file visible via hide unwriteable\n"); - return False; + return false; } /* inaccessible file should be only visible on normal share */ @@ -239,33 +239,33 @@ bool torture_samba3_hide(struct torture_context *torture) status = smbcli_chmod(cli->tree, fname, 0); if (!NT_STATUS_IS_OK(status)) { d_printf("smbcli_chmod failed: %s\n", nt_errstr(status)); - return False; + return false; } if (is_writeable(torture, cli->tree, fname)) { d_printf("inaccessible file is writable\n"); - return False; + return false; } if (is_readable(cli->tree, fname)) { d_printf("inaccessible file is readable\n"); - return False; + return false; } if (!is_visible(cli->tree, fname)) { d_printf("inaccessible file not visible via normal share\n"); - return False; + return false; } if (is_visible(hideunread, fname)) { d_printf("inaccessible file visible via hide unreadable\n"); - return False; + return false; } if (is_visible(hideunwrite, fname)) { d_printf("inaccessible file visible via hide unwriteable\n"); - return False; + return false; } smbcli_chmod(cli->tree, fname, UNIX_R_USR|UNIX_W_USR); smbcli_unlink(cli->tree, fname); - return True; + return true; } /* @@ -277,7 +277,7 @@ bool torture_samba3_hide(struct torture_context *torture) bool torture_samba3_closeerr(struct torture_context *tctx) { struct smbcli_state *cli = NULL; - BOOL result = False; + bool result = false; NTSTATUS status; const char *dname = "closeerr.dir"; const char *fname = "closeerr.dir\\closerr.txt"; @@ -311,7 +311,7 @@ bool torture_samba3_closeerr(struct torture_context *tctx) talloc_asprintf(tctx, "smbcli_open failed: %s\n", smbcli_errstr(cli->tree))); - status = smbcli_nt_delete_on_close(cli->tree, fnum, True); + status = smbcli_nt_delete_on_close(cli->tree, fnum, true); torture_assert_ntstatus_ok(tctx, status, "setting delete_on_close on file failed !"); @@ -329,7 +329,7 @@ bool torture_samba3_closeerr(struct torture_context *tctx) torture_assert_ntstatus_equal(tctx, status, NT_STATUS_ACCESS_DENIED, "smbcli_close"); - result = True; + result = true; fail: if (cli) { -- cgit From 0a2f1a46a02d2c9497d05d7e534829dc6e9430dc Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 3 Dec 2007 15:53:07 +0100 Subject: r26249: Remove a couple more uses of global_loadparm. (This used to be commit 80a61200508a00d5b16a3e748ce92d54b9fefcd2) --- source4/torture/raw/samba3hide.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/torture/raw/samba3hide.c') diff --git a/source4/torture/raw/samba3hide.c b/source4/torture/raw/samba3hide.c index 8fe3aa4d2d..814b5f57f4 100644 --- a/source4/torture/raw/samba3hide.c +++ b/source4/torture/raw/samba3hide.c @@ -135,7 +135,7 @@ bool torture_samba3_hide(struct torture_context *torture) struct smbcli_tree *hideunwrite; if (!torture_open_connection_share( - torture, &cli, torture_setting_string(torture, "host", NULL), + torture, &cli, torture, torture_setting_string(torture, "host", NULL), torture_setting_string(torture, "share", NULL), NULL)) { d_printf("torture_open_connection_share failed\n"); return false; @@ -283,7 +283,7 @@ bool torture_samba3_closeerr(struct torture_context *tctx) const char *fname = "closeerr.dir\\closerr.txt"; int fnum; - if (!torture_open_connection(&cli, 0)) { + if (!torture_open_connection(&cli, tctx, 0)) { goto fail; } -- cgit From 7f464f062899c96ebae04c899665500b998ce658 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 22 Apr 2008 16:37:54 -0400 Subject: Fix more failing tests to pass the event context. (This used to be commit d6c5d8baf0c48a6078a47bba33993a841ff526d9) --- source4/torture/raw/samba3hide.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/torture/raw/samba3hide.c') diff --git a/source4/torture/raw/samba3hide.c b/source4/torture/raw/samba3hide.c index 814b5f57f4..1f1501045c 100644 --- a/source4/torture/raw/samba3hide.c +++ b/source4/torture/raw/samba3hide.c @@ -136,7 +136,7 @@ bool torture_samba3_hide(struct torture_context *torture) if (!torture_open_connection_share( torture, &cli, torture, torture_setting_string(torture, "host", NULL), - torture_setting_string(torture, "share", NULL), NULL)) { + torture_setting_string(torture, "share", NULL), torture->ev)) { d_printf("torture_open_connection_share failed\n"); return false; } -- cgit