[SCM] Samba Shared Repository - branch v3-6-test updated

Karolin Seeger kseeger at samba.org
Wed Jun 5 04:02:25 MDT 2013


The branch, v3-6-test has been updated
       via  fe51e23 Fix bug #9822 - Samba crashing during Win8 sync.
       via  abff441 Remove dependency on detection of HAVE_DIRFD for use of fdopendir().
       via  8d96eb3 Remove the "Ugly hack" that was the second use of dirfd().
       via  93417c9 In the struct smb_Dir destructor, use the fsp back pointer to release resources.
       via  2683c9b Maintain a back-pointer to the fsp in struct smb_Dir when opening with FDOPENDIR.
      from  577b2e5 Fix bug 9900: is_printer_published GUID retrieval

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


- Log -----------------------------------------------------------------
commit fe51e23801b24af43ce605f51f3e607fae74d3b7
Author: Jeremy Allison <jra at samba.org>
Date:   Fri Apr 26 10:47:41 2013 -0700

    Fix bug #9822 - Samba crashing during Win8 sync.
    
    When refactoring the dptr desctructor in the
    fix for bug:
    
    9778 (Samba directory code uses dirfd() without vectoring through a VFS call)
    
    I removed the code to NULL out the struct smb_Dir *
    pointer inside the fsp struct by mistake.
    
    Re-add the NULLing out of that pointer when
    closing a directory pointer associated with
    an open file.
    
    Reporter confirms it fixes the crash.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: David Disseldorp <ddiss at samba.org>
    
    Autobuild-User(master): David Disseldorp <ddiss at samba.org>
    Autobuild-Date(master): Sat Apr 27 20:44:55 CEST 2013 on sn-devel-104
    (cherry picked from commit 251767cde9a146d8122d76e257ab232c05ad452a)

commit abff441e445431970d1e25fa79e10276e576d9e3
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Apr 10 16:30:10 2013 -0700

    Remove dependency on detection of HAVE_DIRFD for use of fdopendir().
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Fri Apr 12 16:21:10 CEST 2013 on sn-devel-104
    (cherry picked from commit 7a4dd845958f1411daa8031ca242987001ab2f26)

commit 8d96eb3666ce2e0f016068dfae60eb32ed2b518e
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Apr 10 16:29:03 2013 -0700

    Remove the "Ugly hack" that was the second use of dirfd().
    
    The destructor does all the resource deallocation needed.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit 0fe894fb89f4867e266bb04670a58101311e0234)

commit 93417c945e12c3d03ba5c4b1cc0b02fb8dd692e0
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Apr 10 16:24:15 2013 -0700

    In the struct smb_Dir destructor, use the fsp back pointer to release resources.
    
    Removes one use of dirfd().
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit ea14c9443178da9ae6ccbe71e573156396f6f699)

commit 2683c9ba9d85ca7f341ae3b21d6e0430a4e7b8d7
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Apr 10 16:21:39 2013 -0700

    Maintain a back-pointer to the fsp in struct smb_Dir when opening with FDOPENDIR.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit e89ec641fc98ffd7f7193deb3728b0a284a093eb)

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

Summary of changes:
 source3/lib/system.c |    8 +++-----
 source3/smbd/dir.c   |   46 +++++++++++++++++++++++-----------------------
 2 files changed, 26 insertions(+), 28 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/system.c b/source3/lib/system.c
index 7c0bb3f..1ca2f5e 100644
--- a/source3/lib/system.c
+++ b/source3/lib/system.c
@@ -882,16 +882,14 @@ SMB_STRUCT_DIR *sys_opendir(const char *name)
 }
 
 /*******************************************************************
- An fdopendir wrapper that will deal with 64 bit filesizes.
- Ugly hack - we need dirfd for this to work correctly in the
- calling code.. JRA.
+ An fdopendir wrapper.
 ********************************************************************/
 
 SMB_STRUCT_DIR *sys_fdopendir(int fd)
 {
-#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_FDOPENDIR64) && defined(HAVE_DIRFD)
+#if defined(HAVE_EXPLICIT_LARGEFILE_SUPPORT) && defined(HAVE_FDOPENDIR64)
 	return fdopendir64(fd);
-#elif defined(HAVE_FDOPENDIR) && defined(HAVE_DIRFD)
+#elif defined(HAVE_FDOPENDIR)
 	return fdopendir(fd);
 #else
 	errno = ENOSYS;
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index f7bc325..e6c8106 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -49,6 +49,8 @@ struct smb_Dir {
 	struct name_cache_entry *name_cache;
 	unsigned int name_cache_index;
 	unsigned int file_number;
+	files_struct *fsp; /* Back pointer to containing fsp, only
+			      set from OpenDir_fsp(). */
 };
 
 struct dptr_struct {
@@ -590,18 +592,11 @@ done:
 void dptr_CloseDir(files_struct *fsp)
 {
 	if (fsp->dptr) {
-/*
- * Ugly hack. We have defined fdopendir to return ENOSYS if dirfd also isn't
- * present. I hate Solaris. JRA.
- */
-#ifdef HAVE_DIRFD
-		if (fsp->fh->fd != -1 &&
-				fsp->dptr->dir_hnd &&
-				dirfd(fsp->dptr->dir_hnd->dir)) {
-			/* The call below closes the underlying fd. */
-			fsp->fh->fd = -1;
-		}
-#endif
+		/*
+		 * The destructor for the struct smb_Dir
+		 * (fsp->dptr->dir_hnd) now handles
+		 * all resource deallocation.
+		 */
 		dptr_close_internal(fsp->dptr);
 		fsp->dptr = NULL;
 	}
@@ -1345,18 +1340,21 @@ bool is_visible_file(connection_struct *conn, const char *dir_path,
 
 static int smb_Dir_destructor(struct smb_Dir *dirp)
 {
-	if (dirp->dir) {
-#ifdef HAVE_DIRFD
-		if (dirp->conn->sconn) {
-			files_struct *fsp = file_find_fd(dirp->conn->sconn,
-						dirfd(dirp->dir));
-			if (fsp) {
-				/* The call below closes the underlying fd. */
-				fsp->fh->fd = -1;
+	if (dirp->dir != NULL) {
+		SMB_VFS_CLOSEDIR(dirp->conn,dirp->dir);
+		if (dirp->fsp != NULL) {
+			/*
+			 * The SMB_VFS_CLOSEDIR above
+			 * closes the underlying fd inside
+			 * dirp->fsp.
+			 */
+			dirp->fsp->fh->fd = -1;
+			if (dirp->fsp->dptr != NULL) {
+				SMB_ASSERT(dirp->fsp->dptr->dir_hnd == dirp);
+				dirp->fsp->dptr->dir_hnd = NULL;
 			}
+			dirp->fsp = NULL;
 		}
-#endif
-		SMB_VFS_CLOSEDIR(dirp->conn,dirp->dir);
 	}
 	if (dirp->conn->sconn && !dirp->conn->sconn->using_smb2) {
 		dirp->conn->sconn->searches.dirhandles_open--;
@@ -1440,7 +1438,9 @@ static struct smb_Dir *OpenDir_fsp(TALLOC_CTX *mem_ctx, connection_struct *conn,
 
 	if (fsp->is_directory && fsp->fh->fd != -1) {
 		dirp->dir = SMB_VFS_FDOPENDIR(fsp, mask, attr);
-		if (dirp->dir == NULL) {
+		if (dirp->dir != NULL) {
+			dirp->fsp = fsp;
+		} else {
 			DEBUG(10,("OpenDir_fsp: SMB_VFS_FDOPENDIR on %s returned "
 				"NULL (%s)\n",
 				dirp->dir_path,


-- 
Samba Shared Repository


More information about the samba-cvs mailing list