From: Ralph Boehme Date: Fri, 17 Nov 2017 11:53:42 +0000 (+0100) Subject: s4/torture: fruit: remove use of localdir from test_adouble_conversion test X-Git-Tag: samba-4.6.12~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=775ec5ecc85adf73837da0fba0b8f738a88646bd;p=thirdparty%2Fsamba.git s4/torture: fruit: remove use of localdir from test_adouble_conversion test The previous use of localdir and torture_setup_local_file() was motivated by the fact that by default vfs_fruit rejects access to files with a "._" prefix. Since a previous commit allowed SMB access to ._ files, rewrite the test_adouble_conversion() test to create the ._ AppleDouble file over SMB. This also renders torture_setup_local_file() obsolete. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13155 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit ebbffd80862d7d7b025eca219bc0c8f818585ac9) --- diff --git a/source4/torture/vfs/fruit.c b/source4/torture/vfs/fruit.c index c78fd83377c..c40eca1aa28 100644 --- a/source4/torture/vfs/fruit.c +++ b/source4/torture/vfs/fruit.c @@ -1210,49 +1210,6 @@ static bool torture_setup_local_xattr(struct torture_context *tctx, return ret; } -static bool torture_setup_local_file(struct torture_context *tctx, - const char *path_option, - const char *name, - const char *buf, - size_t size) -{ - int fd; - const char *spath; - char *path; - ssize_t rsize; - - spath = torture_setting_string(tctx, path_option, NULL); - if (spath == NULL) { - printf("No sharepath for option %s\n", path_option); - return false; - } - - path = talloc_asprintf(tctx, "%s/%s", spath, name); - if (path == NULL) { - return false; - } - - fd = creat(path, S_IRWXU); - TALLOC_FREE(path); - if (fd == -1) { - return false; - } - - if ((buf == NULL) || (size == 0)) { - close(fd); - return true; - } - - rsize = write(fd, buf, size); - if (rsize != size) { - return false; - } - - close(fd); - - return true; -} - /** * Create a file or directory **/ @@ -1996,38 +1953,32 @@ static bool test_adouble_conversion(struct torture_context *tctx, { TALLOC_CTX *mem_ctx = talloc_new(tctx); const char *fname = BASEDIR "\\test_adouble_conversion"; - const char *fname_local = BASEDIR "/test_adouble_conversion"; - const char *adname_local = BASEDIR "/._test_adouble_conversion"; + const char *adname = BASEDIR "/._test_adouble_conversion"; NTSTATUS status; struct smb2_handle testdirh; bool ret = true; const char *data = "This resource fork intentionally left blank"; size_t datalen = strlen(data); - const char *localdir = NULL; - - localdir = torture_setting_string(tctx, "localdir", NULL); - if (localdir == NULL) { - torture_skip(tctx, "Need localdir for test"); - } - smb2_util_unlink(tree, fname); + smb2_deltree(tree, BASEDIR); status = torture_smb2_testdir(tree, BASEDIR, &testdirh); CHECK_STATUS(status, NT_STATUS_OK); smb2_util_close(tree, testdirh); - ret = torture_setup_local_file(tctx, "localdir", fname_local, - NULL, 0); - if (ret == false) { - goto done; - } + ret = torture_setup_file(tctx, tree, fname, false); + torture_assert_goto(tctx, ret == true, ret, done, + "torture_setup_file failed\n"); - ret = torture_setup_local_file(tctx, "localdir", adname_local, - osx_adouble_w_xattr, - sizeof(osx_adouble_w_xattr)); - if (ret == false) { - goto done; - } + ret = torture_setup_file(tctx, tree, adname, false); + torture_assert_goto(tctx, ret == true, ret, done, + "torture_setup_file failed\n"); + + ret = write_stream(tree, __location__, tctx, mem_ctx, + adname, NULL, + 0, sizeof(osx_adouble_w_xattr), osx_adouble_w_xattr); + torture_assert_goto(tctx, ret == true, ret, done, + "write_stream failed\n"); torture_comment(tctx, "(%s) test OS X AppleDouble conversion\n", __location__);