[SCM] Samba Shared Repository - branch master updated

Volker Lendecke vlendec at samba.org
Tue Dec 13 11:01:02 MST 2011


The branch, master has been updated
       via  5efd7e1 s3: Move can_delete_directory to smbd/, remove shim
       via  34d58c9 s3: Move can_set_delete_on_close to smbd/
       via  2d2d72e s3: Remove an else{} in remove_deferred_open_entry
       via  3239c72 s3-dbwrap: Simplify db_tdb_fetchlock_parse a bit
      from  3cf275c s3:smbd/msdfs: enum_msdfs_links() doesn't need a smbd_server_connection anymore

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 5efd7e16c24ed7d1ab510158ea9b2f6fd0b81922
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Dec 13 16:07:18 2011 +0100

    s3: Move can_delete_directory to smbd/, remove shim
    
    Autobuild-User: Volker Lendecke <vlendec at samba.org>
    Autobuild-Date: Tue Dec 13 19:00:37 CET 2011 on sn-devel-104

commit 34d58c9d92f852e908acb78e040c1a22ce1591c1
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Dec 13 16:01:59 2011 +0100

    s3: Move can_set_delete_on_close to smbd/

commit 2d2d72e479142ad7d1a40955793bcf63d5b4ee14
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Dec 13 13:56:49 2011 +0100

    s3: Remove an else{} in remove_deferred_open_entry

commit 3239c722aa528a4f00f3201425182f7f105dbfe2
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Dec 9 16:39:09 2011 +0100

    s3-dbwrap: Simplify db_tdb_fetchlock_parse a bit
    
    Introduce a local variable for the result, replace "state->result" by "result"

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

Summary of changes:
 source3/lib/dbwrap/dbwrap_tdb.c |   21 +++++++------
 source3/lib/smbd_shim.c         |    9 ------
 source3/lib/smbd_shim.h         |    3 --
 source3/locking/locking.c       |   59 ---------------------------------------
 source3/locking/proto.h         |    1 -
 source3/smbd/dir.c              |    4 +-
 source3/smbd/file_access.c      |   59 +++++++++++++++++++++++++++++++++++++++
 source3/smbd/globals.c          |    1 -
 source3/smbd/open.c             |    6 ++--
 source3/smbd/proto.h            |    3 +-
 10 files changed, 76 insertions(+), 90 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/dbwrap/dbwrap_tdb.c b/source3/lib/dbwrap/dbwrap_tdb.c
index 6a4636a..fbb05cc 100644
--- a/source3/lib/dbwrap/dbwrap_tdb.c
+++ b/source3/lib/dbwrap/dbwrap_tdb.c
@@ -73,28 +73,29 @@ static int db_tdb_fetchlock_parse(TDB_DATA key, TDB_DATA data,
 {
 	struct tdb_fetch_locked_state *state =
 		(struct tdb_fetch_locked_state *)private_data;
+	struct db_record *result;
 
-	state->result = (struct db_record *)talloc_size(
+	result = (struct db_record *)talloc_size(
 		state->mem_ctx,
 		sizeof(struct db_record) + key.dsize + data.dsize);
 
-	if (state->result == NULL) {
+	if (result == NULL) {
 		return 0;
 	}
+	state->result = result;
 
-	state->result->key.dsize = key.dsize;
-	state->result->key.dptr = ((uint8 *)state->result)
-		+ sizeof(struct db_record);
-	memcpy(state->result->key.dptr, key.dptr, key.dsize);
+	result->key.dsize = key.dsize;
+	result->key.dptr = ((uint8 *)result) + sizeof(struct db_record);
+	memcpy(result->key.dptr, key.dptr, key.dsize);
 
-	state->result->value.dsize = data.dsize;
+	result->value.dsize = data.dsize;
 
 	if (data.dsize > 0) {
-		state->result->value.dptr = state->result->key.dptr+key.dsize;
-		memcpy(state->result->value.dptr, data.dptr, data.dsize);
+		result->value.dptr = result->key.dptr+key.dsize;
+		memcpy(result->value.dptr, data.dptr, data.dsize);
 	}
 	else {
-		state->result->value.dptr = NULL;
+		result->value.dptr = NULL;
 	}
 
 	return 0;
diff --git a/source3/lib/smbd_shim.c b/source3/lib/smbd_shim.c
index 72ae366..a7d386b 100644
--- a/source3/lib/smbd_shim.c
+++ b/source3/lib/smbd_shim.c
@@ -51,15 +51,6 @@ void send_stat_cache_delete_message(struct messaging_context *msg_ctx,
 	}
 }
 
-NTSTATUS can_delete_directory(struct connection_struct *conn,
-				const char *dirname)
-{
-	if (shim.can_delete_directory) {
-		return shim.can_delete_directory(conn, dirname);
-	}
-	return NT_STATUS_OK;
-}
-
 bool change_to_root_user(void)
 {
 	if (shim.change_to_root_user) {
diff --git a/source3/lib/smbd_shim.h b/source3/lib/smbd_shim.h
index 89cae2b..0b802fe 100644
--- a/source3/lib/smbd_shim.h
+++ b/source3/lib/smbd_shim.h
@@ -35,9 +35,6 @@ struct smbd_shim
 	void (*send_stat_cache_delete_message)(struct messaging_context *msg_ctx,
 					       const char *name);
 
-	NTSTATUS (*can_delete_directory)(struct connection_struct *conn,
-					 const char *dirname);
-
 	bool (*change_to_root_user)(void);
 
 	void (*contend_level2_oplocks_begin)(files_struct *fsp,
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index c1f9943..b0f719b 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -1182,65 +1182,6 @@ bool downgrade_share_oplock(struct share_mode_lock *lck, files_struct *fsp)
 	return True;
 }
 
-/****************************************************************************
- Check if setting delete on close is allowed on this fsp.
-****************************************************************************/
-
-NTSTATUS can_set_delete_on_close(files_struct *fsp, uint32 dosmode)
-{
-	/*
-	 * Only allow delete on close for writable files.
-	 */
-
-	if ((dosmode & FILE_ATTRIBUTE_READONLY) &&
-	    !lp_delete_readonly(SNUM(fsp->conn))) {
-		DEBUG(10,("can_set_delete_on_close: file %s delete on close "
-			  "flag set but file attribute is readonly.\n",
-			  fsp_str_dbg(fsp)));
-		return NT_STATUS_CANNOT_DELETE;
-	}
-
-	/*
-	 * Only allow delete on close for writable shares.
-	 */
-
-	if (!CAN_WRITE(fsp->conn)) {
-		DEBUG(10,("can_set_delete_on_close: file %s delete on "
-			  "close flag set but write access denied on share.\n",
-			  fsp_str_dbg(fsp)));
-		return NT_STATUS_ACCESS_DENIED;
-	}
-
-	/*
-	 * Only allow delete on close for files/directories opened with delete
-	 * intent.
-	 */
-
-	if (!(fsp->access_mask & DELETE_ACCESS)) {
-		DEBUG(10,("can_set_delete_on_close: file %s delete on "
-			  "close flag set but delete access denied.\n",
-			  fsp_str_dbg(fsp)));
-		return NT_STATUS_ACCESS_DENIED;
-	}
-
-	/* Don't allow delete on close for non-empty directories. */
-	if (fsp->is_directory) {
-		SMB_ASSERT(!is_ntfs_stream_smb_fname(fsp->fsp_name));
-
-		/* Or the root of a share. */
-		if (ISDOT(fsp->fsp_name->base_name)) {
-			DEBUG(10,("can_set_delete_on_close: can't set delete on "
-				  "close for the root of a share.\n"));
-			return NT_STATUS_ACCESS_DENIED;
-		}
-
-		return can_delete_directory(fsp->conn,
-					    fsp->fsp_name->base_name);
-	}
-
-	return NT_STATUS_OK;
-}
-
 /*************************************************************************
  Return a talloced copy of a struct security_unix_token. NULL on fail.
  (Should this be in locking.c.... ?).
diff --git a/source3/locking/proto.h b/source3/locking/proto.h
index b7c8990..5be8acc 100644
--- a/source3/locking/proto.h
+++ b/source3/locking/proto.h
@@ -172,7 +172,6 @@ void del_deferred_open_entry(struct share_mode_lock *lck, uint64_t mid,
 			     struct server_id pid);
 bool remove_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
 bool downgrade_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
-NTSTATUS can_set_delete_on_close(files_struct *fsp, uint32 dosmode);
 const struct security_unix_token *get_delete_on_close_token(struct share_mode_lock *lck, uint32_t name_hash);
 void set_delete_on_close_lck(files_struct *fsp,
 			struct share_mode_lock *lck,
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index a7dc537..63a7887 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -1674,8 +1674,8 @@ bool SearchDir(struct smb_Dir *dirp, const char *name, long *poffset)
  Is this directory empty ?
 *****************************************************************/
 
-NTSTATUS smbd_can_delete_directory(struct connection_struct *conn,
-				   const char *dirname)
+NTSTATUS can_delete_directory(struct connection_struct *conn,
+			      const char *dirname)
 {
 	NTSTATUS status = NT_STATUS_OK;
 	long dirpos = 0;
diff --git a/source3/smbd/file_access.c b/source3/smbd/file_access.c
index 4a473d7..9fff8e3 100644
--- a/source3/smbd/file_access.c
+++ b/source3/smbd/file_access.c
@@ -170,3 +170,62 @@ bool directory_has_default_acl(connection_struct *conn, const char *fname)
 	TALLOC_FREE(secdesc);
 	return false;
 }
+
+/****************************************************************************
+ Check if setting delete on close is allowed on this fsp.
+****************************************************************************/
+
+NTSTATUS can_set_delete_on_close(files_struct *fsp, uint32 dosmode)
+{
+	/*
+	 * Only allow delete on close for writable files.
+	 */
+
+	if ((dosmode & FILE_ATTRIBUTE_READONLY) &&
+	    !lp_delete_readonly(SNUM(fsp->conn))) {
+		DEBUG(10,("can_set_delete_on_close: file %s delete on close "
+			  "flag set but file attribute is readonly.\n",
+			  fsp_str_dbg(fsp)));
+		return NT_STATUS_CANNOT_DELETE;
+	}
+
+	/*
+	 * Only allow delete on close for writable shares.
+	 */
+
+	if (!CAN_WRITE(fsp->conn)) {
+		DEBUG(10,("can_set_delete_on_close: file %s delete on "
+			  "close flag set but write access denied on share.\n",
+			  fsp_str_dbg(fsp)));
+		return NT_STATUS_ACCESS_DENIED;
+	}
+
+	/*
+	 * Only allow delete on close for files/directories opened with delete
+	 * intent.
+	 */
+
+	if (!(fsp->access_mask & DELETE_ACCESS)) {
+		DEBUG(10,("can_set_delete_on_close: file %s delete on "
+			  "close flag set but delete access denied.\n",
+			  fsp_str_dbg(fsp)));
+		return NT_STATUS_ACCESS_DENIED;
+	}
+
+	/* Don't allow delete on close for non-empty directories. */
+	if (fsp->is_directory) {
+		SMB_ASSERT(!is_ntfs_stream_smb_fname(fsp->fsp_name));
+
+		/* Or the root of a share. */
+		if (ISDOT(fsp->fsp_name->base_name)) {
+			DEBUG(10,("can_set_delete_on_close: can't set delete on "
+				  "close for the root of a share.\n"));
+			return NT_STATUS_ACCESS_DENIED;
+		}
+
+		return can_delete_directory(fsp->conn,
+					    fsp->fsp_name->base_name);
+	}
+
+	return NT_STATUS_OK;
+}
diff --git a/source3/smbd/globals.c b/source3/smbd/globals.c
index aa17f69..82de70a 100644
--- a/source3/smbd/globals.c
+++ b/source3/smbd/globals.c
@@ -151,7 +151,6 @@ static const struct smbd_shim smbd_shim_fns =
 {
 	.cancel_pending_lock_requests_by_fid = smbd_cancel_pending_lock_requests_by_fid,
 	.send_stat_cache_delete_message = smbd_send_stat_cache_delete_message,
-	.can_delete_directory = smbd_can_delete_directory,
 	.change_to_root_user = smbd_change_to_root_user,
 
 	.contend_level2_oplocks_begin = smbd_contend_level2_oplocks_begin,
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index a697ee8..ee0ba08 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -1548,10 +1548,10 @@ void remove_deferred_open_entry(struct file_id id, uint64_t mid,
 			NULL, NULL, NULL);
 	if (lck == NULL) {
 		DEBUG(0, ("could not get share mode lock\n"));
-	} else {
-		del_deferred_open_entry(lck, mid, pid);
-		TALLOC_FREE(lck);
+		return;
 	}
+	del_deferred_open_entry(lck, mid, pid);
+	TALLOC_FREE(lck);
 }
 
 /****************************************************************
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index e0f48b7..daaa914 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -241,8 +241,6 @@ void DirCacheAdd(struct smb_Dir *dirp, const char *name, long offset);
 bool SearchDir(struct smb_Dir *dirp, const char *name, long *poffset);
 NTSTATUS can_delete_directory(struct connection_struct *conn,
 				const char *dirname);
-NTSTATUS smbd_can_delete_directory(struct connection_struct *conn,
-				const char *dirname);
 
 /* The following definitions come from smbd/dmapi.c  */
 
@@ -310,6 +308,7 @@ bool can_delete_file_in_directory(connection_struct *conn,
 bool can_write_to_file(connection_struct *conn,
 		       const struct smb_filename *smb_fname);
 bool directory_has_default_acl(connection_struct *conn, const char *fname);
+NTSTATUS can_set_delete_on_close(files_struct *fsp, uint32 dosmode);
 
 /* The following definitions come from smbd/fileio.c  */
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list