[SCM] Samba Shared Repository - branch master updated
Volker Lendecke
vlendec at samba.org
Thu Oct 7 10:52:01 MDT 2010
The branch, master has been updated
via fb75355 File winattr test
via 9af40be File BirthTime test
from d8c86a7 s3-spoolss: make it possible to have and announce a [prnproc$] share on the printserver.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit fb75355263c16ce17dadd483f0ad40e7c31846f4
Author: Abhidnya P Chirmule <achirmul at in.ibm.com>
Date: Thu Sep 30 16:26:25 2010 +0530
File winattr test
Autobuild-User: Volker Lendecke <vlendec at samba.org>
Autobuild-Date: Thu Oct 7 16:51:19 UTC 2010 on sn-devel-104
commit 9af40beda6a3f7c2b48142263cd798947b7c5698
Author: Abhidnya P Chirmule <achirmul at in.ibm.com>
Date: Wed Sep 29 18:00:49 2010 +0530
File BirthTime test
-----------------------------------------------------------------------
Summary of changes:
source4/selftest/skip | 2 +
source4/torture/basic/attr.c | 247 ++++++++++++++++++++++++++++++++++++++++++
source4/torture/basic/base.c | 115 ++++++++++++++++++++
3 files changed, 364 insertions(+), 0 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source4/selftest/skip b/source4/selftest/skip
index 047e4f7..e43fefe 100644
--- a/source4/selftest/skip
+++ b/source4/selftest/skip
@@ -77,6 +77,8 @@ base.scan.ioctl # bad idea in make test
base.scan.pipe_number # bad idea in make test
base.secleak # no point on build farm
base.delaywrite # This is randomly failing, depending on timing and filesystem features
+base.winattr
+base.birthtime
smb2.acls # new test which doesn't pass yet
# ktutil might not be installed or from mit...
# we should build a samba4ktutil and use that instead
diff --git a/source4/torture/basic/attr.c b/source4/torture/basic/attr.c
index 66d17b4..784ed37 100644
--- a/source4/torture/basic/attr.c
+++ b/source4/torture/basic/attr.c
@@ -22,6 +22,8 @@
#include "includes.h"
#include "libcli/libcli.h"
#include "torture/util.h"
+#include "system/filesys.h"
+#include "libcli/security/secace.h"
extern int torture_failures;
@@ -182,3 +184,248 @@ error_exit:
return true;
}
+bool torture_winattrtest(struct torture_context *tctx,
+ struct smbcli_state *cli1)
+{
+ const char *fname = "\\winattr1.file";
+ const char *dname = "\\winattr1.dir";
+ int fnum1;
+ uint16_t attr;
+ uint16_t j;
+ uint32_t aceno;
+ int failures = 0;
+ union smb_fileinfo query, query_org;
+ NTSTATUS status;
+ struct security_descriptor *sd1, *sd2;
+
+
+ /* Test winattrs for file */
+ smbcli_unlink(cli1->tree, fname);
+
+ /* Open a file*/
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDWR | O_CREAT | O_TRUNC,
+ DENY_NONE);
+ torture_assert(tctx, fnum1 != -1,
+ talloc_asprintf(tctx, "open(1) of %s failed (%s)\n",
+ fname, smbcli_errstr(cli1->tree)));
+
+
+ /* Get security descriptor and store it*/
+ query_org.generic.level = RAW_FILEINFO_SEC_DESC;
+ query_org.generic.in.file.fnum = fnum1;
+ status = smb_raw_fileinfo(cli1->tree, tctx, &query_org);
+ if(!NT_STATUS_IS_OK(status)){
+ torture_comment(tctx, "smb_raw_fileinfo(1) of %s failed (%s)\n",
+ fname, nt_errstr(status));
+ torture_assert_ntstatus_ok(tctx,
+ smbcli_close(cli1->tree, fnum1),
+ talloc_asprintf(tctx,
+ "close(1) of %s failed (%s)\n",
+ fname, smbcli_errstr(cli1->tree)));
+ CHECK_MAX_FAILURES(error_exit_file);
+ }
+ sd1 = query_org.query_secdesc.out.sd;
+
+ torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1),
+ talloc_asprintf(tctx, "close(1) of %s failed (%s)\n",
+ fname, smbcli_errstr(cli1->tree)));
+
+ /*Set and get attributes*/
+ for (j = 0; j < ARRAY_SIZE(open_attrs_table); j++) {
+ torture_assert_ntstatus_ok(tctx,
+ smbcli_setatr(cli1->tree, fname, open_attrs_table[j],0),
+ talloc_asprintf(tctx, "setatr(2) failed (%s)",
+ smbcli_errstr(cli1->tree)));
+
+ torture_assert_ntstatus_ok(tctx,
+ smbcli_getatr(cli1->tree, fname, &attr, NULL, NULL),
+ talloc_asprintf(tctx, "getatr(2) failed (%s)",
+ smbcli_errstr(cli1->tree)));
+
+ /* Check the result */
+ if((j == 0)&&(attr != FILE_ATTRIBUTE_ARCHIVE)){
+ torture_comment(tctx, "getatr check failed. \
+ Attr applied [0x%x], got attr [0x%x], \
+ should be [0x%x]",
+ open_attrs_table[j],
+ (uint16_t)attr,open_attrs_table[j +1]);
+ CHECK_MAX_FAILURES(error_exit_file);
+ }else{
+
+ if((j != 0) &&(attr != open_attrs_table[j])){
+ torture_comment(tctx, "getatr check failed. \
+ Attr applied [0x%x],got attr 0x%x, \
+ should be 0x%x ",
+ open_attrs_table[j], (uint16_t)attr,
+ open_attrs_table[j]);
+ CHECK_MAX_FAILURES(error_exit_file);
+ }
+
+ }
+
+ fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY | O_CREAT,
+ DENY_NONE);
+ torture_assert(tctx, fnum1 != -1,
+ talloc_asprintf(tctx, "open(2) of %s failed (%s)\n",
+ fname, smbcli_errstr(cli1->tree)));
+ /*Get security descriptor */
+ query.query_secdesc.level = RAW_FILEINFO_SEC_DESC;
+ query.query_secdesc.in.file.fnum = fnum1;
+ status = smb_raw_fileinfo(cli1->tree, tctx, &query);
+ if(!NT_STATUS_IS_OK(status)){
+ torture_comment(tctx,
+ "smb_raw_fileinfo(2) of %s failed (%s)\n",
+ fname, nt_errstr(status));
+ torture_assert_ntstatus_ok(tctx,
+ smbcli_close(cli1->tree, fnum1),
+ talloc_asprintf(tctx,
+ "close(2) of %s failed (%s)\n",
+ fname, smbcli_errstr(cli1->tree)));
+ CHECK_MAX_FAILURES(error_exit_file);
+ }
+ sd2 = query.query_secdesc.out.sd;
+
+ torture_assert_ntstatus_ok(tctx,smbcli_close(cli1->tree,fnum1),
+ talloc_asprintf(tctx, "close(2) of %s failed (%s)\n",
+ fname, smbcli_errstr(cli1->tree)));
+
+ /*Compare security descriptors -- Must be same*/
+ for (aceno=0;(sd1->dacl&&aceno < sd1->dacl->num_aces);aceno++){
+ struct security_ace *ace1 = &sd1->dacl->aces[aceno];
+ struct security_ace *ace2 = &sd2->dacl->aces[aceno];
+
+ if(!sec_ace_equal(ace1,ace2)){
+ torture_comment(tctx,
+ "ACLs changed! Not expected!\n");
+ CHECK_MAX_FAILURES(error_exit_file);
+ }
+ }
+
+ torture_comment(tctx, "[%d] setattr = [0x%x] got attr 0x%x\n",
+ j, open_attrs_table[j], attr );
+
+ }
+
+error_exit_file:
+ smbcli_setatr(cli1->tree, fname, 0, 0);
+ smbcli_unlink(cli1->tree, fname);
+
+/* Check for Directory. */
+
+ smbcli_deltree(cli1->tree, dname);
+ smbcli_rmdir(cli1->tree,dname);
+
+ /* Open a directory */
+ fnum1 = smbcli_nt_create_full(cli1->tree, dname, 0,
+ SEC_RIGHTS_DIR_ALL,
+ FILE_ATTRIBUTE_DIRECTORY,
+ NTCREATEX_SHARE_ACCESS_NONE,
+ NTCREATEX_DISP_OPEN_IF,
+ NTCREATEX_OPTIONS_DIRECTORY, 0);
+ /*smbcli_mkdir(cli1->tree,dname);*/
+
+ torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx,
+ "open (1) of %s failed (%s)",
+ dname, smbcli_errstr(cli1->tree)));
+
+
+ /* Get Security Descriptor */
+ query_org.generic.level = RAW_FILEINFO_SEC_DESC;
+ query_org.generic.in.file.fnum = fnum1;
+ status = smb_raw_fileinfo(cli1->tree, tctx, &query_org);
+ if(!NT_STATUS_IS_OK(status)){
+ torture_comment(tctx, "smb_raw_fileinfo(1) of %s failed (%s)\n",
+ dname, nt_errstr(status));
+ torture_assert_ntstatus_ok(tctx,
+ smbcli_close(cli1->tree, fnum1),
+ talloc_asprintf(tctx,
+ "close(1) of %s failed (%s)\n",
+ dname, smbcli_errstr(cli1->tree)));
+ CHECK_MAX_FAILURES(error_exit_dir);
+ }
+ sd1 = query_org.query_secdesc.out.sd;
+
+ torture_assert_ntstatus_ok(tctx,
+ smbcli_close(cli1->tree, fnum1),
+ talloc_asprintf(tctx,
+ "close (1) of %s failed (%s)", dname,
+ smbcli_errstr(cli1->tree)));
+
+ /* Set and get win attributes*/
+ for (j = 1; j < ARRAY_SIZE(open_attrs_table); j++) {
+
+ torture_assert_ntstatus_ok(tctx,
+ smbcli_setatr(cli1->tree, dname, open_attrs_table[j], 0),
+ talloc_asprintf(tctx, "setatr(2) failed (%s)",
+ smbcli_errstr(cli1->tree)));
+
+ torture_assert_ntstatus_ok(tctx,
+ smbcli_getatr(cli1->tree, dname, &attr, NULL, NULL),
+ talloc_asprintf(tctx, "getatr(2) failed (%s)",
+ smbcli_errstr(cli1->tree)));
+
+ torture_comment(tctx, "[%d] setatt = [0x%x] got attr 0x%x\n",
+ j, open_attrs_table[j], attr );
+
+ /* Check the result */
+ if(attr != (open_attrs_table[j]|FILE_ATTRIBUTE_DIRECTORY)){
+ torture_comment(tctx, "getatr check failed. set attr \
+ [0x%x], got attr 0x%x, should be 0x%x\n",
+ open_attrs_table[j],
+ (uint16_t)attr,
+ open_attrs_table[j]|FILE_ATTRIBUTE_DIRECTORY);
+ CHECK_MAX_FAILURES(error_exit_dir);
+ }
+
+ fnum1 = smbcli_nt_create_full(cli1->tree, dname, 0,
+ SEC_RIGHTS_DIR_READ,
+ FILE_ATTRIBUTE_DIRECTORY,
+ NTCREATEX_SHARE_ACCESS_NONE,
+ NTCREATEX_DISP_OPEN,
+ 0,0);
+
+ torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx,
+ "open (2) of %s failed (%s)",
+ dname, smbcli_errstr(cli1->tree)));
+ /* Get security descriptor */
+ query.generic.level = RAW_FILEINFO_SEC_DESC;
+ query.generic.in.file.fnum = fnum1;
+ status = smb_raw_fileinfo(cli1->tree, tctx, &query);
+ if(!NT_STATUS_IS_OK(status)){
+ torture_comment(tctx, "smb_raw_fileinfo(2) of %s failed\
+ (%s)\n", dname, nt_errstr(status));
+ torture_assert_ntstatus_ok(tctx,
+ smbcli_close(cli1->tree, fnum1),
+ talloc_asprintf(tctx,
+ "close (2) of %s failed (%s)", dname,
+ smbcli_errstr(cli1->tree)));
+ CHECK_MAX_FAILURES(error_exit_dir);
+ }
+ sd2 = query.query_secdesc.out.sd;
+ torture_assert_ntstatus_ok(tctx,
+ smbcli_close(cli1->tree, fnum1),
+ talloc_asprintf(tctx,
+ "close (2) of %s failed (%s)", dname,
+ smbcli_errstr(cli1->tree)));
+
+ /* Security descriptor must be same*/
+ for (aceno=0;(sd1->dacl&&aceno < sd1->dacl->num_aces);aceno++){
+ struct security_ace *ace1 = &sd1->dacl->aces[aceno];
+ struct security_ace *ace2 = &sd2->dacl->aces[aceno];
+
+ if(!sec_ace_equal(ace1,ace2)){
+ torture_comment(tctx,
+ "ACLs changed! Not expected!\n");
+ CHECK_MAX_FAILURES(error_exit_dir);
+ }
+ }
+
+ }
+error_exit_dir:
+ smbcli_deltree(cli1->tree, dname);
+ smbcli_rmdir(cli1->tree,dname);
+
+ if(failures)
+ return false;
+ return true;
+}
diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c
index 7b96e1c..eeba252 100644
--- a/source4/torture/basic/base.c
+++ b/source4/torture/basic/base.c
@@ -1720,6 +1720,119 @@ static bool torture_samba3_errorpaths(struct torture_context *tctx)
return result;
}
+/**
+ This checks file/dir birthtime
+*/
+static void list_fn(struct clilist_file_info *finfo, const char *name,
+ void *state){
+
+ /* Just to change dir access time*/
+ sleep(5);
+
+}
+
+static bool run_birthtimetest(struct torture_context *tctx,
+ struct smbcli_state *cli)
+{
+ int fnum;
+ size_t size;
+ time_t c_time, a_time, m_time, w_time, c_time1;
+ const char *fname = "\\birthtime.tst";
+ const char *dname = "\\birthtime";
+ const char *fname2 = "\\birthtime\\birthtime.tst";
+ bool correct = true;
+ uint8_t buf[16];
+
+
+ smbcli_unlink(cli->tree, fname);
+
+ torture_comment(tctx, "Testing Birthtime for File\n");
+
+ /* Save File birthtime/creationtime */
+ fnum = smbcli_open(cli->tree, fname, O_RDWR | O_CREAT | O_TRUNC,
+ DENY_NONE);
+ if (NT_STATUS_IS_ERR(smbcli_qfileinfo(cli->tree, fnum, NULL, &size,
+ &c_time, &a_time, &m_time, NULL, NULL))) {
+ torture_comment(tctx, "ERROR: qfileinfo failed (%s)\n",
+ smbcli_errstr(cli->tree));
+ correct = false;
+ }
+ smbcli_close(cli->tree, fnum);
+
+ sleep(10);
+
+ /* Change in File attribute changes file change time*/
+ smbcli_setatr(cli->tree, fname, FILE_ATTRIBUTE_SYSTEM, 0);
+
+ fnum = smbcli_open(cli->tree, fname, O_RDWR | O_CREAT , DENY_NONE);
+ /* Writing updates modification time*/
+ smbcli_smbwrite(cli->tree, fnum, &fname, 0, sizeof(fname));
+ /*Reading updates access time */
+ smbcli_read(cli->tree, fnum, buf, 0, 13);
+ smbcli_close(cli->tree, fnum);
+
+ if (NT_STATUS_IS_ERR(smbcli_qpathinfo2(cli->tree, fname, &c_time1,
+ &a_time, &m_time, &w_time, &size, NULL, NULL))) {
+ torture_comment(tctx, "ERROR: qpathinfo2 failed (%s)\n",
+ smbcli_errstr(cli->tree));
+ correct = false;
+ } else {
+ fprintf(stdout,"c_time = %d, c_time1 = %d\n",c_time,c_time1);
+ if (c_time1 != c_time) {
+ torture_comment(tctx, "This system updated file \
+ birth times! Not expected!\n");
+ correct = false;
+ }
+ }
+ smbcli_unlink(cli->tree, fname);
+
+ torture_comment(tctx, "Testing Birthtime for Directory\n");
+
+ /* check if the server does not update the directory birth time
+ when creating a new file */
+ if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, dname))) {
+ torture_comment(tctx, "ERROR: mkdir failed (%s)\n",
+ smbcli_errstr(cli->tree));
+ correct = false;
+ }
+ sleep(3);
+ if (NT_STATUS_IS_ERR(smbcli_qpathinfo2(cli->tree, "\\birthtime\\",
+ &c_time,&a_time,&m_time,&w_time, &size, NULL, NULL))){
+ torture_comment(tctx, "ERROR: qpathinfo2 failed (%s)\n",
+ smbcli_errstr(cli->tree));
+ correct = false;
+ }
+
+ /* Creating a new file changes dir modification time and change time*/
+ smbcli_unlink(cli->tree, fname2);
+ fnum = smbcli_open(cli->tree, fname2, O_RDWR | O_CREAT | O_TRUNC,
+ DENY_NONE);
+ smbcli_smbwrite(cli->tree, fnum, &fnum, 0, sizeof(fnum));
+ smbcli_read(cli->tree, fnum, buf, 0, 13);
+ smbcli_close(cli->tree, fnum);
+
+ /* dir listing changes dir access time*/
+ smbcli_list(cli->tree, "\\birthtime\\*", 0, list_fn, cli );
+
+ if (NT_STATUS_IS_ERR(smbcli_qpathinfo2(cli->tree, "\\birthtime\\",
+ &c_time1, &a_time, &m_time,&w_time,&size,NULL,NULL))){
+ torture_comment(tctx, "ERROR: qpathinfo2 failed (%s)\n",
+ smbcli_errstr(cli->tree));
+ correct = false;
+ } else {
+ fprintf(stdout,"c_time = %d, c_time1 = %d\n",c_time,c_time1);
+ if (c_time1 != c_time) {
+ torture_comment(tctx, "This system updated directory \
+ birth times! Not Expected!\n");
+ correct = false;
+ }
+ }
+ smbcli_unlink(cli->tree, fname2);
+ smbcli_rmdir(cli->tree, dname);
+
+ return correct;
+}
+
NTSTATUS torture_base_init(void)
{
@@ -1730,6 +1843,7 @@ NTSTATUS torture_base_init(void)
torture_suite_add_1smb_test(suite, "UNLINK", torture_unlinktest);
torture_suite_add_1smb_test(suite, "ATTR", run_attrtest);
torture_suite_add_1smb_test(suite, "TRANS2", run_trans2test);
+ torture_suite_add_1smb_test(suite, "BIRTHTIME", run_birthtimetest);
torture_suite_add_simple_test(suite, "NEGNOWAIT", run_negprot_nowait);
torture_suite_add_1smb_test(suite, "DIR1", torture_dirtest1);
torture_suite_add_1smb_test(suite, "DIR2", torture_dirtest2);
@@ -1752,6 +1866,7 @@ NTSTATUS torture_base_init(void)
torture_suite_add_1smb_test(suite, "PROPERTIES", torture_test_properties);
torture_suite_add_1smb_test(suite, "MANGLE", torture_mangle);
torture_suite_add_1smb_test(suite, "OPENATTR", torture_openattrtest);
+ torture_suite_add_1smb_test(suite, "WINATTR", torture_winattrtest);
torture_suite_add_suite(suite, torture_charset(suite));
torture_suite_add_1smb_test(suite, "CHKPATH", torture_chkpath_test);
torture_suite_add_1smb_test(suite, "SECLEAK", torture_sec_leak);
--
Samba Shared Repository
More information about the samba-cvs
mailing list