[SCM] Samba Shared Repository - branch v4-2-test updated

Karolin Seeger kseeger at samba.org
Tue May 5 15:17:07 MDT 2015


The branch, v4-2-test has been updated
       via  bd7bc99 s3: nmbd: Don't set work_changed = True inside update_server_ttl().
       via  c79abc9 s3: nmbd: Ensure we only set work_changed = true if we modify the record.
       via  82f7a0c vfs: kernel_flock and named streams
       via  509f2bb s4: torture: Test for incorrect file size returned in the response of "FILE_SUPERSEDE Create".
       via  251accf s3: smbd: Incorrect file size returned in the response of "FILE_SUPERSEDE Create"
      from  794cc5d s4: rpc: Refactor dcesrv_alter() function into setup and send steps.

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-2-test


- Log -----------------------------------------------------------------
commit bd7bc99353b4d7842816dd5572accb7e9c2adb4c
Author: Jeremy Allison <jra at samba.org>
Date:   Fri May 1 09:56:59 2015 -0700

    s3: nmbd: Don't set work_changed = True inside update_server_ttl().
    
    This is taken care of inside expire_servers() when it calls
    remove_server_from_workgroup().
    
    Ensure the only functions in nmbd_serverlistdb.c that
    set subnet->work_changed are:
    
    remove_all_servers()
    add_server_to_workgroup()
    remove_server_from_workgroup()
    
    Fix inspired by a change from Volker.
    
    https://bugzilla.samba.org/show_bug.cgi?id=11254
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit c3c820a661c092de31d56c16c8cd1ec57999d2f7)
    
    Autobuild-User(v4-2-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-2-test): Tue May  5 23:16:30 CEST 2015 on sn-devel-104

commit c79abc91e1150c0b155745364b234aa68de2d62e
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Apr 30 12:05:17 2015 -0700

    s3: nmbd: Ensure we only set work_changed = true if we modify the record.
    
    https://bugzilla.samba.org/show_bug.cgi?id=11254
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit db6572ef80e20b0e577b9e9fb5d233f8bdd20713)

commit 82f7a0ce3e690cf0e41708d6cf228e08d928071d
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Apr 29 16:53:04 2015 +0200

    vfs: kernel_flock and named streams
    
    Streams implementing VFS modules may implement streams in a way that the
    fsp will have the basefile open in the fsp fd, so lacking a distinct fd
    for the stream, kernel_flock will apply on the basefile which is
    wrong. The actual check is deffered to the VFS module implementing the
    kernel_flock call.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=11243
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit d748652e5b1c1c0238a2b86cdf14d7f6de7ce9b2)

commit 509f2bb970165ff321c746362fb0176b24f778f8
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Apr 28 16:33:30 2015 -0700

    s4: torture: Test for incorrect file size returned in the response of "FILE_SUPERSEDE Create".
    
    https://bugzilla.samba.org/show_bug.cgi?id=11240
    
    Signed-off-by: Kenny Dinh <kdinh at peaxy.net>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Böhme <rb at sernet.de>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu Apr 30 22:12:22 CEST 2015 on sn-devel-104
    
    (cherry picked from commit 9d7ecb9fc3a1dcce0d71bc0c4f02f9c7dd9408ab)

commit 251accff51e650cfeb255acc83889676abc80ff6
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Apr 28 14:22:42 2015 -0700

    s3: smbd: Incorrect file size returned in the response of "FILE_SUPERSEDE Create"
    
    https://bugzilla.samba.org/show_bug.cgi?id=11240
    
    Signed-off-by: Kenny Dinh <kdinh at peaxy.net>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Ralph Böhme <rb at sernet.de>
    (cherry picked from commit d68383e9638254d1b6805b3d3ea3e5e897908374)

-----------------------------------------------------------------------

Summary of changes:
 selftest/knownfail                 |   1 +
 source3/modules/vfs_default.c      |   8 ++-
 source3/modules/vfs_gpfs.c         |  10 ++++
 source3/nmbd/nmbd_incomingdgrams.c |  22 ++++++--
 source3/nmbd/nmbd_serverlistdb.c   |   5 --
 source3/smbd/open.c                |   9 ++++
 source4/torture/raw/open.c         | 102 +++++++++++++++++++++++++++++++++++++
 7 files changed, 145 insertions(+), 12 deletions(-)


Changeset truncated at 500 lines:

diff --git a/selftest/knownfail b/selftest/knownfail
index af7e7fd..2c35a58 100644
--- a/selftest/knownfail
+++ b/selftest/knownfail
@@ -128,6 +128,7 @@
 # some operations don't work over the CIFS NTVFS backend yet (eg. root_fid)
 ^samba4.ntvfs.cifs.*.base.createx_sharemodes_dir
 ^samba4.raw.lock.*.async # bug 6960
+^samba4.raw.open.ntcreatex_supersede
 ^samba4.smb2.lock.*.multiple-unlock # bug 6959
 ^samba4.raw.sfileinfo.*.end-of-file\(.*\)$ # bug 6962
 ^samba4.raw.oplock.*.batch22 # bug 6963
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 46589bf..b13ad14 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -1904,8 +1904,6 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, off_t
 	   ftruncate extend but ext2 can. */
 
 	result = ftruncate(fsp->fh->fd, len);
-	if (result == 0)
-		goto done;
 
 	/* According to W. R. Stevens advanced UNIX prog. Pure 4.3 BSD cannot
 	   extend a file with ftruncate. Provide alternate implementation
@@ -1919,6 +1917,12 @@ static int vfswrap_ftruncate(vfs_handle_struct *handle, files_struct *fsp, off_t
 	if (!NT_STATUS_IS_OK(status)) {
 		goto done;
 	}
+
+	/* We need to update the files_struct after successful ftruncate */
+	if (result == 0) {
+		goto done;
+	}
+
 	pst = &fsp->fsp_name->st;
 
 #ifdef S_ISFIFO
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 6ead65b..e1e29fa 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -88,6 +88,16 @@ static int vfs_gpfs_kernel_flock(vfs_handle_struct *handle, files_struct *fsp,
 		return 0;
 	}
 
+	/*
+	 * A named stream fsp will have the basefile open in the fsp
+	 * fd, so lacking a distinct fd for the stream we have to skip
+	 * kernel_flock and set_gpfs_sharemode for stream.
+	 */
+	if (!is_ntfs_default_stream_smb_fname(fsp->fsp_name)) {
+		DEBUG(2,("%s: kernel_flock on stream\n", fsp_str_dbg(fsp)));
+		return 0;
+	}
+
 	kernel_flock(fsp->fh->fd, share_mode, access_mask);
 
 	if (!set_gpfs_sharemode(fsp, access_mask, fsp->share_access)) {
diff --git a/source3/nmbd/nmbd_incomingdgrams.c b/source3/nmbd/nmbd_incomingdgrams.c
index 153a86d..2dc684e 100644
--- a/source3/nmbd/nmbd_incomingdgrams.c
+++ b/source3/nmbd/nmbd_incomingdgrams.c
@@ -336,12 +336,25 @@ a local master browser for workgroup %s and we think we are master. Forcing elec
 				ttl, comment);
 		} else {
 			/* Update the record. */
-			servrec->serv.type = servertype|SV_TYPE_LOCAL_LIST_ONLY;
+			if (servrec->serv.type !=
+					(servertype|SV_TYPE_LOCAL_LIST_ONLY)) {
+				servrec->serv.type =
+					servertype|SV_TYPE_LOCAL_LIST_ONLY;
+				subrec->work_changed = true;
+			}
+			if (!strequal(servrec->serv.comment,comment)) {
+				strlcpy(servrec->serv.comment,
+					comment,
+					sizeof(servrec->serv.comment));
+				subrec->work_changed = true;
+			}
 			update_server_ttl(servrec, ttl);
-			strlcpy(servrec->serv.comment,comment,sizeof(servrec->serv.comment));
 		}
-	
-		set_workgroup_local_master_browser_name( work, server_name );
+
+		if (!strequal(work->local_master_browser_name, server_name)) {
+			set_workgroup_local_master_browser_name( work, server_name );
+			subrec->work_changed = true;
+		}
 	} else {
 		/*
 		 * This server is announcing it is going down. Remove it from the
@@ -353,7 +366,6 @@ a local master browser for workgroup %s and we think we are master. Forcing elec
 		}
 	}
 
-	subrec->work_changed = True;
 done:
 
 	END_PROFILE(local_master_announce);
diff --git a/source3/nmbd/nmbd_serverlistdb.c b/source3/nmbd/nmbd_serverlistdb.c
index f697f05..70a71ae 100644
--- a/source3/nmbd/nmbd_serverlistdb.c
+++ b/source3/nmbd/nmbd_serverlistdb.c
@@ -133,8 +133,6 @@ workgroup %s. This is a bug.\n", name, work->work_group));
 	DEBUG(3,("create_server_on_workgroup: Created server entry %s of type %x (%s) on \
 workgroup %s.\n", name,servertype,comment, work->work_group));
  
-	work->subnet->work_changed = True;
- 
 	return(servrec);
 }
 
@@ -151,8 +149,6 @@ void update_server_ttl(struct server_record *servrec, int ttl)
 		servrec->death_time = PERMANENT_TTL;
 	else
 		servrec->death_time = (ttl != PERMANENT_TTL) ? time(NULL)+(ttl*3) : PERMANENT_TTL;
-
-	servrec->subnet->work_changed = True;
 }
 
 /*******************************************************************
@@ -172,7 +168,6 @@ void expire_servers(struct work_record *work, time_t t)
 		if ((servrec->death_time != PERMANENT_TTL) && ((t == -1) || (servrec->death_time < t))) {
 			DEBUG(3,("expire_old_servers: Removing timed out server %s\n",servrec->serv.name));
 			remove_server_from_workgroup(work, servrec);
-			work->subnet->work_changed = True;
 		}
 	}
 }
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 773b146..86c1c31 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -3064,6 +3064,15 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
 
 	if (fsp->fh->fd != -1 && lp_kernel_share_modes(SNUM(conn))) {
 		int ret_flock;
+		/*
+		 * Beware: streams implementing VFS modules may
+		 * implement streams in a way that fsp will have the
+		 * basefile open in the fsp fd, so lacking a distinct
+		 * fd for the stream kernel_flock will apply on the
+		 * basefile which is wrong. The actual check is
+		 * deffered to the VFS module implementing the
+		 * kernel_flock call.
+		 */
 		ret_flock = SMB_VFS_KERNEL_FLOCK(fsp, share_access, access_mask);
 		if(ret_flock == -1 ){
 
diff --git a/source4/torture/raw/open.c b/source4/torture/raw/open.c
index 679a7c2..60b73f6 100644
--- a/source4/torture/raw/open.c
+++ b/source4/torture/raw/open.c
@@ -2118,6 +2118,107 @@ done:
 	return ret;
 }
 
+/**
+ * Test for file size to be 0 after create with FILE_SUPERSEDE
+ */
+static bool test_ntcreatex_supersede(struct torture_context *tctx, struct smbcli_state *cli)
+{
+	union smb_open io;
+	union smb_setfileinfo sfi;
+	union smb_fileinfo finfo;
+	const char *fname = BASEDIR "\\torture_ntcreatex_supersede.txt";
+	NTSTATUS status;
+	int fnum = -1;
+	bool ret = true;
+
+	torture_assert(tctx, torture_setup_dir(cli, BASEDIR), "Failed to setup up test directory: " BASEDIR);
+
+	/* reasonable default parameters */
+	io.generic.level = RAW_OPEN_NTCREATEX;
+	io.ntcreatex.in.flags = 0;
+	io.ntcreatex.in.root_fid.fnum = 0;
+	io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL;
+	io.ntcreatex.in.alloc_size = 0;
+	io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+	io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
+	io.ntcreatex.in.open_disposition = NTCREATEX_DISP_CREATE;
+	io.ntcreatex.in.create_options = 0;
+	io.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
+	io.ntcreatex.in.security_flags = 0;
+	io.ntcreatex.in.fname = fname;
+
+	status = smb_raw_open(cli->tree, tctx, &io);
+	CHECK_STATUS(status, NT_STATUS_OK);
+	fnum = io.ntcreatex.out.file.fnum;
+
+	CHECK_VAL(io.ntcreatex.out.oplock_level, 0);
+	CHECK_VAL(io.ntcreatex.out.create_action, NTCREATEX_ACTION_CREATED);
+	CHECK_NTTIME(io.ntcreatex.out.create_time, create_time);
+	CHECK_NTTIME(io.ntcreatex.out.access_time, access_time);
+	CHECK_NTTIME(io.ntcreatex.out.write_time, write_time);
+	CHECK_NTTIME(io.ntcreatex.out.change_time, change_time);
+	CHECK_ALL_INFO(io.ntcreatex.out.attrib, attrib);
+	CHECK_ALL_INFO(io.ntcreatex.out.alloc_size, alloc_size);
+	CHECK_ALL_INFO(io.ntcreatex.out.size, size);
+	CHECK_ALL_INFO(io.ntcreatex.out.is_directory, directory);
+	CHECK_VAL(io.ntcreatex.out.file_type, FILE_TYPE_DISK);
+
+	/* extend the file size */
+	ZERO_STRUCT(sfi);
+	sfi.generic.level = RAW_SFILEINFO_END_OF_FILE_INFO;
+	sfi.generic.in.file.fnum = fnum;
+	sfi.end_of_file_info.in.size = 512;
+	status = smb_raw_setfileinfo(cli->tree, &sfi);
+	CHECK_STATUS(status, NT_STATUS_OK);
+
+	/* close the file and re-open with to verify new size */
+	smbcli_close(cli->tree, fnum);
+	io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
+	io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_READ;
+	status = smb_raw_open(cli->tree, tctx, &io);
+	CHECK_STATUS(status, NT_STATUS_OK);
+	fnum = io.ntcreatex.out.file.fnum;
+
+	CHECK_VAL(io.ntcreatex.out.oplock_level, 0);
+	CHECK_VAL(io.ntcreatex.out.create_action, NTCREATEX_ACTION_EXISTED);
+	CHECK_NTTIME(io.ntcreatex.out.create_time, create_time);
+	CHECK_NTTIME(io.ntcreatex.out.access_time, access_time);
+	CHECK_NTTIME(io.ntcreatex.out.write_time, write_time);
+	CHECK_NTTIME(io.ntcreatex.out.change_time, change_time);
+	CHECK_ALL_INFO(io.ntcreatex.out.attrib, attrib);
+	CHECK_ALL_INFO(io.ntcreatex.out.alloc_size, alloc_size);
+	CHECK_VAL(io.ntcreatex.out.size, 512);
+	CHECK_ALL_INFO(io.ntcreatex.out.is_directory, directory);
+	CHECK_VAL(io.ntcreatex.out.file_type, FILE_TYPE_DISK);
+
+	/* close and re-open the file with SUPERSEDE flag */
+	smbcli_close(cli->tree, fnum);
+	io.ntcreatex.in.open_disposition = NTCREATEX_DISP_SUPERSEDE;
+	io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_READ;
+	io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
+	io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
+	io.ntcreatex.in.create_options = 0;
+
+	status = smb_raw_open(cli->tree, tctx, &io);
+	CHECK_STATUS(status, NT_STATUS_OK);
+	fnum = io.ntcreatex.out.file.fnum;
+
+	/* The file size in the superseded create response should be 0 */
+	CHECK_VAL(io.ntcreatex.out.size, 0);
+	CHECK_VAL(io.ntcreatex.out.oplock_level, 0);
+	CHECK_VAL(io.ntcreatex.out.create_action, FILE_WAS_SUPERSEDED);
+	CHECK_NTTIME(io.ntcreatex.out.create_time, create_time);
+	CHECK_NTTIME(io.ntcreatex.out.access_time, access_time);
+	CHECK_ALL_INFO(io.ntcreatex.out.attrib, attrib);
+	CHECK_ALL_INFO(io.ntcreatex.out.alloc_size, alloc_size);
+	CHECK_ALL_INFO(io.ntcreatex.out.is_directory, directory);
+	CHECK_VAL(io.ntcreatex.out.file_type, FILE_TYPE_DISK);
+done:
+	smbcli_close(cli->tree, fnum);
+	smbcli_deltree(cli->tree, BASEDIR);
+
+	return ret;
+}
 
 /* basic testing of all RAW_OPEN_* calls
 */
@@ -2143,6 +2244,7 @@ struct torture_suite *torture_raw_open(TALLOC_CTX *mem_ctx)
 	torture_suite_add_1smb_test(suite, "opendisp-dir", test_ntcreatex_opendisp_dir);
 	torture_suite_add_1smb_test(suite, "ntcreatedir", test_ntcreatexdir);
 	torture_suite_add_1smb_test(suite, "open-for-truncate", test_open_for_truncate);
+	torture_suite_add_1smb_test(suite, "ntcreatex_supersede", test_ntcreatex_supersede);
 
 	return suite;
 }


-- 
Samba Shared Repository


More information about the samba-cvs mailing list