[SCM] Samba Shared Repository - branch v3-4-test updated - release-4-0-0alpha7-972-g4fe9f5e

Tim Prouty tprouty at samba.org
Wed May 13 00:25:06 GMT 2009


The branch, v3-4-test has been updated
       via  4fe9f5e1204fd5578a6043ad314614dc541decda (commit)
       via  d07c3437aa9f6262abab87bc298c74fd953ebcfc (commit)
      from  37d0afc095e43d707ff3b86c9ebda22e8a10f77f (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-4-test


- Log -----------------------------------------------------------------
commit 4fe9f5e1204fd5578a6043ad314614dc541decda
Author: Tim Prouty <tprouty at samba.org>
Date:   Tue May 12 16:32:32 2009 -0700

    s3: Fix strict locking with chained reads
    
    Move the strict lock/unlock code down a level for reads to avoid
    calling chain_reply before the unlock.
    (cherry picked from commit c60bb39df355c2ef36e4cfdff69cc348adc6dae1)

commit d07c3437aa9f6262abab87bc298c74fd953ebcfc
Author: Aravind Srinivasan <aravind.srinivasan at isilon.com>
Date:   Thu Apr 16 20:42:40 2009 +0000

    s3: Fallback to the legacy sid_to_(uid|gid) instead of returning NULL.
    
    This is very similar to be1dfff02d562e42a7847bd02fed8538630d3f41
    (cherry picked from commit 5aefb44bf04becc6b80e7c3bf038d79851c5b0f9)

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

Summary of changes:
 source3/passdb/lookup_sid.c  |   13 +++--------
 source3/passdb/pdb_wbc_sam.c |   17 ---------------
 source3/smbd/reply.c         |   46 +++++++++++++++++++++--------------------
 3 files changed, 28 insertions(+), 48 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/passdb/lookup_sid.c b/source3/passdb/lookup_sid.c
index c1249f5..b45000e 100644
--- a/source3/passdb/lookup_sid.c
+++ b/source3/passdb/lookup_sid.c
@@ -1430,13 +1430,10 @@ bool sid_to_uid(const DOM_SID *psid, uid_t *puid)
 	if (!ret || expired) {
 		/* Not in cache. Ask winbindd. */
 		if (!winbind_sid_to_uid(puid, psid)) {
-			if (!winbind_ping()) {
-				return legacy_sid_to_uid(psid, puid);
-			}
-
 			DEBUG(5, ("winbind failed to find a uid for sid %s\n",
 				  sid_string_dbg(psid)));
-			return false;
+			/* winbind failed. do legacy */
+			return legacy_sid_to_uid(psid, puid);
 		}
 	}
 
@@ -1497,13 +1494,11 @@ bool sid_to_gid(const DOM_SID *psid, gid_t *pgid)
 		 * (Idmap will check it is a valid SID and of the right type) */
 
 		if ( !winbind_sid_to_gid(pgid, psid) ) {
-			if (!winbind_ping()) {
-				return legacy_sid_to_gid(psid, pgid);
-			}
 
 			DEBUG(10,("winbind failed to find a gid for sid %s\n",
 				  sid_string_dbg(psid)));
-			return false;
+			/* winbind failed. do legacy */
+			return legacy_sid_to_gid(psid, pgid);
 		}
 	}
 
diff --git a/source3/passdb/pdb_wbc_sam.c b/source3/passdb/pdb_wbc_sam.c
index e8116d0..9c31a0d 100644
--- a/source3/passdb/pdb_wbc_sam.c
+++ b/source3/passdb/pdb_wbc_sam.c
@@ -81,22 +81,6 @@ static bool pdb_wbc_sam_gid_to_sid(struct pdb_methods *methods, gid_t gid,
 	return winbind_gid_to_sid(sid, gid);
 }
 
-static bool pdb_wbc_sam_sid_to_id(struct pdb_methods *methods,
-				  const DOM_SID *sid,
-				  union unid_t *id, enum lsa_SidType *type)
-{
-	if (winbind_sid_to_uid(&id->uid, sid)) {
-		*type = SID_NAME_USER;
-	} else if (winbind_sid_to_gid(&id->gid, sid)) {
-		/* We assume all gids are groups, not aliases */
-		*type = SID_NAME_DOM_GRP;
-	} else {
-		return false;
-	}
-
-	return true;
-}
-
 static NTSTATUS pdb_wbc_sam_enum_group_members(struct pdb_methods *methods,
 					       TALLOC_CTX *mem_ctx,
 					       const DOM_SID *group,
@@ -430,7 +414,6 @@ static NTSTATUS pdb_init_wbc_sam(struct pdb_methods **pdb_method, const char *lo
 	(*pdb_method)->set_account_policy = pdb_wbc_sam_set_account_policy;
 	(*pdb_method)->uid_to_sid = pdb_wbc_sam_uid_to_sid;
 	(*pdb_method)->gid_to_sid = pdb_wbc_sam_gid_to_sid;
-	(*pdb_method)->sid_to_id = pdb_wbc_sam_sid_to_id;
 
 	(*pdb_method)->search_groups = pdb_wbc_sam_search_groups;
 	(*pdb_method)->search_aliases = pdb_wbc_sam_search_aliases;
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index f35900b..9cf5280 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -3257,12 +3257,22 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req,
 {
 	SMB_STRUCT_STAT sbuf;
 	ssize_t nread = -1;
+	struct lock_struct lock;
 
 	if(SMB_VFS_FSTAT(fsp, &sbuf) == -1) {
 		reply_unixerror(req, ERRDOS, ERRnoaccess);
 		return;
 	}
 
+	init_strict_lock_struct(fsp, (uint32)req->smbpid,
+	    (uint64_t)startpos, (uint64_t)smb_maxcnt, READ_LOCK,
+	    &lock);
+
+	if (!SMB_VFS_STRICT_LOCK(conn, fsp, &lock)) {
+		reply_doserror(req, ERRDOS, ERRlock);
+		return;
+	}
+
 	if (!S_ISREG(sbuf.st_mode) || (startpos > sbuf.st_size)
 	    || (smb_maxcnt > (sbuf.st_size - startpos))) {
 		/*
@@ -3323,8 +3333,7 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req,
 				DEBUG( 3, ( "send_file_readX: fake_sendfile fnum=%d max=%d nread=%d\n",
 					fsp->fnum, (int)smb_maxcnt, (int)nread ) );
 				/* No outbuf here means successful sendfile. */
-				TALLOC_FREE(req->outbuf);
-				return;
+				goto strict_unlock;
 			}
 
 			DEBUG(0,("send_file_readX: sendfile failed for file %s (%s). Terminating\n",
@@ -3351,12 +3360,10 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req,
 		if (nread != smb_maxcnt + sizeof(headerbuf)) {
 			sendfile_short_send(fsp, nread, sizeof(headerbuf), smb_maxcnt);
 		}
-
 		/* No outbuf here means successful sendfile. */
-		TALLOC_FREE(req->outbuf);
 		SMB_PERFCOUNT_SET_MSGLEN_OUT(&req->pcd, nread);
 		SMB_PERFCOUNT_END(&req->pcd);
-		return;
+		goto strict_unlock;
 	}
 
 normal_read:
@@ -3382,8 +3389,7 @@ normal_read:
 				fsp->fsp_name, strerror(errno) ));
 			exit_server_cleanly("send_file_readX: fake_sendfile failed");
 		}
-		TALLOC_FREE(req->outbuf);
-		return;
+		goto strict_unlock;
 	}
 
 nosendfile_read:
@@ -3391,6 +3397,9 @@ nosendfile_read:
 	reply_outbuf(req, 12, smb_maxcnt);
 
 	nread = read_file(fsp, smb_buf(req->outbuf), startpos, smb_maxcnt);
+
+	SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock);
+
 	if (nread < 0) {
 		reply_unixerror(req, ERRDOS, ERRnoaccess);
 		return;
@@ -3402,6 +3411,12 @@ nosendfile_read:
 		    fsp->fnum, (int)smb_maxcnt, (int)nread ) );
 
 	chain_reply(req);
+	return;
+
+ strict_unlock:
+	SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock);
+	TALLOC_FREE(req->outbuf);
+	return;
 }
 
 /****************************************************************************
@@ -3414,7 +3429,6 @@ void reply_read_and_X(struct smb_request *req)
 	files_struct *fsp;
 	SMB_OFF_T startpos;
 	size_t smb_maxcnt;
-	struct lock_struct lock;
 	bool big_readX = False;
 #if 0
 	size_t smb_mincnt = SVAL(req->vwv+6, 0);
@@ -3502,26 +3516,14 @@ void reply_read_and_X(struct smb_request *req)
 
 	}
 
-	init_strict_lock_struct(fsp, (uint32)req->smbpid,
-	    (uint64_t)startpos, (uint64_t)smb_maxcnt, READ_LOCK,
-	    &lock);
-
-	if (!SMB_VFS_STRICT_LOCK(conn, fsp, &lock)) {
-		END_PROFILE(SMBreadX);
-		reply_doserror(req, ERRDOS, ERRlock);
-		return;
-	}
-
 	if (!big_readX &&
 	    schedule_aio_read_and_X(conn, req, fsp, startpos, smb_maxcnt)) {
-		goto strict_unlock;
+		goto out;
 	}
 
 	send_file_readX(conn, req, fsp,	startpos, smb_maxcnt);
 
-strict_unlock:
-	SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock);
-
+ out:
 	END_PROFILE(SMBreadX);
 	return;
 }


-- 
Samba Shared Repository


More information about the samba-cvs mailing list