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

Karolin Seeger kseeger at samba.org
Wed Aug 14 01:06:12 MDT 2013


The branch, v3-6-stable has been updated
       via  ce76b26 WHATSNEW: Prepare release notes for Samba 3.6.18.
       via  27c7a57 Ensure gpfs kernel leases are wrapped in a become_root()/unbecome_root() pair.
       via  7421d38 Wrap setting leases in become_root()/unbecome_root() to ensure correct delivery of signals.
       via  1596219 Fix bug 9678 - Windows 8 Roaming profiles fail
       via  3f66ac6 security.idl: add new security_secinfo bits
       via  9a04cd0 build:autoconf: fix output of syslog-facility check
       via  b07ade6 PIDL: fix parsing linemarkers in preprocessor output
       via  5d6f750 libreplace: add a missing "eval" to the AC_VERIFY_C_PROTOTYPE macro
       via  c251fed docs: mention AD prerequirements for using idmap_ad
       via  3d41fed winbind/idmap_ad: be verbose about the user that we fail to map
       via  a7cdc3a Ensure we test the dirsort module in make test.
       via  0bbf306 Remove unneeded initializations (we already talloc_zero).
       via  77cacee Remove the use of dirfd inside the vfs_dirsort.c.
       via  66ee839 Convert mtime from a time_t to a struct timespec.
       via  33ead72 Check SMB_VFS_NEXT_OPENDIR return in dirsort_opendir().
       via  94f7d0c Clean error paths in opendir and fd_opendir by only setting handle data on success.
       via  d302cb6 Protect open_and_sort_dir() from the directory changing size.
       via  bc3714f Use an index i rather than re-using a state variable.
       via  0a3b024 Protect against early error in SMB_VFS_NEXT_READDIR.
       via  629e302 Change source3/modules/vfs_dirsort.c from MALLOC -> TALLOC.
      from  0694139 WHATSNEW: Start release notes for Samba 3.6.18.

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


- Log -----------------------------------------------------------------
commit ce76b268af425b102ea27e2e09e0104608a6ccc4
Author: Karolin Seeger <kseeger at samba.org>
Date:   Mon Aug 12 09:20:38 2013 +0200

    WHATSNEW: Prepare release notes for Samba 3.6.18.
    
    Signed-off-by: Karolin Seeger <kseeger at samba.org>
    (cherry picked from commit 3a8cab366ce6ce0f2a32a6df2f6f8fcf549a9dd3)

commit 27c7a577414447a208652626c177956b9615b4ff
Author: Ralph Wuerthner <ralphw at de.ibm.com>
Date:   Wed Jul 31 16:33:48 2013 -0700

    Ensure gpfs kernel leases are wrapped in a become_root()/unbecome_root() pair.
    
    Ensures correct lease owner for signal delivery.
    
    Signed-off-by: Ralph Wuerthner <ralphw at de.ibm.com>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu Aug  1 03:57:11 CEST 2013 on sn-devel-104
    
    The last 2 patches address bug #10064 - Linux kernel oplock breaks can miss
    signals.
    (cherry picked from commit 9ef80fcff6e0d03e30bd675cd7ebfc88608e81d6)

commit 7421d38f7bbf760a20963468ec8e13c70c3aaad6
Author: Jeremy Allison <jra at samba.org>
Date:   Wed Jul 31 16:32:20 2013 -0700

    Wrap setting leases in become_root()/unbecome_root() to ensure correct delivery of signals.
    
    Remove workaround for Linux kernel bug https://bugzilla.kernel.org/show_bug.cgi?id=43336
    as we don't need to set capabilities when we're already root.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Simo Sorce <idra at samba.org>
    (cherry picked from commit 363025491d97171e130a7b8dd03296b9559799a0)

commit 1596219a7e877e26560b4f737f043b20047aabc8
Author: Gregor Beck <gbeck at sernet.de>
Date:   Thu Aug 1 14:16:24 2013 +0200

    Fix bug 9678 - Windows 8 Roaming profiles fail
    
    Windows 8 tries to set 'ATTRIBUTE_SECURITY_INFORMATION' on some
    dirs. Ignoring it makes roaming profiles work again.
    Just like w2k3 gracefully ignore all the other bits.
    
    Signed-off-by: Gregor Beck <gbeck at sernet.de>
    (cherry picked from commit b085c39d9e39d305b715fd73c267eff0fc5fd4c4)

commit 3f66ac634809da7f692660472c83aed2169ac911
Author: Gregor Beck <gbeck at sernet.de>
Date:   Wed Jul 31 15:28:51 2013 +0200

    security.idl: add new security_secinfo bits
    
    [MS-DTYP].pdf 2.4.7
    
    Signed-off-by: Gregor Beck <gbeck at sernet.de>
    (cherry picked from commit 326ebbdaca4d13fa498779f960a202955531576b)

commit 9a04cd047e342dd2ca4d0f2a18bc3990b6e0797d
Author: Björn Jacke <bj at sernet.de>
Date:   Wed Feb 20 19:57:24 2013 +0100

    build:autoconf: fix output of syslog-facility check
    
    thanks to Thomas Bork for reporting!
    
    Signed-off-by: Bjoern Jacke <bj at sernet.de>
    
    Fix bug #9983 - configure and syslog facility and disk-quotas support.
    (cherry picked from commit dbb52ee98b84659386d70f0e75b0fa93fada1a97)

commit b07ade6e6fcc8b844cf1fb8b6038617281c4c2d0
Author: Alexander Bokovoy <ab at samba.org>
Date:   Wed Feb 6 10:17:57 2013 +0200

    PIDL: fix parsing linemarkers in preprocessor output
    
    When PIDL calls out to C preprocessor to expand IDL files
    and parse the output, it filters out linemarkers and line control
    information as described in http://gcc.gnu.org/onlinedocs/cpp/Preprocessor-Output.html
    and http://gcc.gnu.org/onlinedocs/cpp/Line-Control.html#Line-Control
    
    With gcc 4.8 stdc-predef.h is included automatically and linemarker for the
    file has extended flags that PIDL couldn't parse ('system header that needs to
    be extern "C" protected for C++')
    
    Thanks to Jakub Jelinek <jakub at redhat.com> for explanation of the linemarker format.
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=906517
    
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit 6ba7ab5c14801aecae96373d5a9db7ab82957526)
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    
    Fix bug #9636 - pidl can't parse new linemarkers in preprocessor output.
    (cherry picked from commit 643571470f2e4cd2f58bd60ac7189abb826d33cc)
    (cherry picked from commit b5a8afd6550e9091d169d3010751913bb483fc4b)

commit 5d6f7502e34fa25c146b28ecacf49841b8f2c7f7
Author: Michael Adam <obnox at samba.org>
Date:   Fri Oct 14 14:05:09 2011 +0200

    libreplace: add a missing "eval" to the AC_VERIFY_C_PROTOTYPE macro
    
    Without this eval, upon test success the corresponding actions
    (like defining corresponding variables) are not taken.
    
    Found by Timur I. Bakeyev, and based on his patch for 3.5.
    (cherry picked from commit 0ef506d4f31d206c300e4f3f326edac2b60bdc15)
    (cherry picked from commit e98d3b7648fe298f03e408ab91b8b53904bab8ca)

commit c251fed51d4c7dbfe5e48fd3cfb1d48475b0b0f3
Author: Björn Jacke <bj at sernet.de>
Date:   Wed May 15 15:52:25 2013 +0200

    docs: mention AD prerequirements for using idmap_ad
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit c3057f69a274f0d8e0e66183bd5e8be7703b6750)
    
    Reviewed-by: David Disseldorp <ddiss at samba.org>
    
    The last 2 patches address bug #9880 - Use of wrong RFC2307 primary group field.
    (cherry picked from commit 006ba0cc73a3fe484452f594a25dd3bfee9b39fd)

commit 3d41fed060fe5bbc72d489d3d957dbe9b54dd992
Author: Björn Jacke <bj at sernet.de>
Date:   Tue May 14 16:51:28 2013 +0200

    winbind/idmap_ad: be verbose about the user that we fail to map
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit f08205be7003f6c0a15fd5fd99d01951164ad15c)
    
    Reviewed-by: David Disseldorp <ddiss at samba.org>
    (cherry picked from commit 17794737fedf095212cf45920dd1e29b5a1a9fa0)

commit a7cdc3afa809d894decf7f2ba03ebbc26132e4a7
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Apr 9 16:56:24 2013 -0700

    Ensure we test the dirsort module in make test.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu Apr 11 21:17:21 CEST 2013 on sn-devel-104
    
    The last 10 patches address bug #9777 - vfs_dirsort uses non-stackable calls,
    dirfd(), malloc instead of talloc and doesn't cope with directories being
    modified whilst reading.
    (cherry picked from commit 1f601d14d0ee440126d7202924e5cf7af88f6ea3)

commit 0bbf306af5aae08265be4302626f3c72912feab3
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Apr 9 11:02:58 2013 -0700

    Remove unneeded initializations (we already talloc_zero).
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit 8a1ec80ee233405f2f484c31a8d6e4b2702678e0)

commit 77cacee2b3438287ffc6ca143da2a2ef45d3adce
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Apr 9 10:50:55 2013 -0700

    Remove the use of dirfd inside the vfs_dirsort.c.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit ffc2d250d2d0fd59a1524e15c4be5cf53d5b0135)

commit 66ee8396bcfa76e99e303a880a3c27b6abbe4395
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Apr 9 10:43:53 2013 -0700

    Convert mtime from a time_t to a struct timespec.
    
    In preparation for removing the dirfd and using fsp_stat()
    and VFS_STAT functions.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit 8a761c7806fddd0faa919f343a079f8d4f343316)

commit 33ead72e36b35fb1a5a44e7761b86ce85abbf8fd
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Apr 9 10:38:24 2013 -0700

    Check SMB_VFS_NEXT_OPENDIR return in dirsort_opendir().
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit 052f74c2122301a3be19ab84ee4551f3259a3ee5)

commit 94f7d0cdbb859842613f3c0acfeb36965f54635a
Author: Jeremy Allison <jra at samba.org>
Date:   Tue Apr 9 10:29:47 2013 -0700

    Clean error paths in opendir and fd_opendir by only setting handle data on success.
    
    Pass extra struct dirsort_privates * to open_and_sort_dir() function
    to avoid it having to re-read the handle data.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit a2da5a78c48e9be6ec2ecad99ddd23d4773b2267)

commit d302cb6faee3282379d87e2c65dde392ab6a1750
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Apr 8 16:40:35 2013 -0700

    Protect open_and_sort_dir() from the directory changing size.
    
    Otherwise there could be an error between initial count, allocation
    and re-read.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit 582d8ca565ad12133a4319650e886f58246b3bd9)

commit bc3714f54e7de35bacbeb1f22851b857fcac63ac
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Apr 8 16:38:03 2013 -0700

    Use an index i rather than re-using a state variable.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit f81822166d8d41c6c3ee6f17924ebe87e4303211)

commit 0a3b0242514c2372b1028c604a5a377ceab3ed8f
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Apr 8 16:31:53 2013 -0700

    Protect against early error in SMB_VFS_NEXT_READDIR.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit f34063ed9cd3d6a4542c39ad576c6ecc807878e8)

commit 629e302899eb905bec5e6bfa7831b7c7980f8d03
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Apr 8 15:11:28 2013 -0700

    Change source3/modules/vfs_dirsort.c from MALLOC -> TALLOC.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    (cherry picked from commit e2118fd251ac64f47a9ee4ea18a441ae1941fe4e)

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

Summary of changes:
 WHATSNEW.txt                       |   23 +++++-
 docs-xml/manpages-3/idmap_ad.8.xml |    9 ++-
 lib/replace/libreplace_macros.m4   |    2 +-
 librpc/idl/security.idl            |    3 +
 pidl/idl.yp                        |    4 +-
 pidl/lib/Parse/Pidl/IDL.pm         |    4 +-
 selftest/target/Samba3.pm          |    2 +
 source3/configure.in               |    5 +-
 source3/modules/vfs_dirsort.c      |  142 +++++++++++++++++++++--------------
 source3/modules/vfs_gpfs.c         |    6 ++
 source3/smbd/nttrans.c             |    9 +--
 source3/smbd/oplock_linux.c        |   33 +++++---
 source3/winbindd/idmap_ad.c        |    5 +-
 13 files changed, 157 insertions(+), 90 deletions(-)


Changeset truncated at 500 lines:

diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 125d793..c8e7607 100644
--- a/WHATSNEW.txt
+++ b/WHATSNEW.txt
@@ -6,15 +6,30 @@
 
 This is is the latest stable release of Samba 3.6.
 
-Major enhancements in Samba 3.6.18 include:
-
-o
-
 
 Changes since 3.6.17:
 ---------------------
 
 o   Jeremy Allison <jra at samba.org>
+    * BUG 9777: vfs_dirsort uses non-stackable calls, dirfd(), malloc instead
+      of talloc and doesn't cope with directories being modified whilst reading.
+
+
+o   Gregor Beck <gbeck at sernet.de>
+    * BUG 9678: Windows 8 Roaming profiles fail.
+
+
+o   Alexander Bokovoy <ab at samba.org>
+    * BUG 9636: Fix parsing linemarkers in preprocessor output.
+
+
+o   Björn Jacke <bj at sernet.de>
+    * BUG 9880: Use of wrong RFC2307 primary group field.
+    * BUG 9983: Fix output of syslog-facility check.
+
+
+o   Ralph Wuerthner <ralphw at de.ibm.com>
+    * BUG 10064: Linux kernel oplock breaks can miss signals.
 
 
 ######################################################################
diff --git a/docs-xml/manpages-3/idmap_ad.8.xml b/docs-xml/manpages-3/idmap_ad.8.xml
index fbadaf2..2f7c0f1 100644
--- a/docs-xml/manpages-3/idmap_ad.8.xml
+++ b/docs-xml/manpages-3/idmap_ad.8.xml
@@ -22,9 +22,12 @@
 	id mappings from an AD server that uses RFC2307/SFU schema
 	extensions. This module implements only the "idmap"
 	API, and is READONLY. Mappings must be provided in advance
-	by the administrator by adding the posixAccount/posixGroup
-	classes and relative attribute/value pairs to the user and
-	group objects in the AD.</para>
+	by the administrator by adding the uidNumber attributes for
+	users and gidNumber attributes for groups in the AD. Winbind
+	will only map users that have a uidNumber and whose primary
+	group have a gidNumber attribute set. It is however
+	recommended that all groups in use have gidNumber attributes
+	assigned, otherwise they are not working.</para>
 
 	<para>
 	Note that the idmap_ad module has changed considerably since
diff --git a/lib/replace/libreplace_macros.m4 b/lib/replace/libreplace_macros.m4
index 46aedd3..42b8847 100644
--- a/lib/replace/libreplace_macros.m4
+++ b/lib/replace/libreplace_macros.m4
@@ -298,7 +298,7 @@ AC_DEFUN(AC_VERIFY_C_PROTOTYPE,
 		eval AS_TR_SH([ac_cv_c_prototype_$1])=no
 	])
 )
-AS_IF([test $AS_TR_SH([ac_cv_c_prototype_$1]) = yes],[$3],[$4])
+AS_IF([eval test $AS_TR_SH([ac_cv_c_prototype_$1]) = yes],[$3],[$4])
 ])
 
 AC_DEFUN(LIBREPLACE_PROVIDE_HEADER, 
diff --git a/librpc/idl/security.idl b/librpc/idl/security.idl
index 696d5a5..0ea79a3 100644
--- a/librpc/idl/security.idl
+++ b/librpc/idl/security.idl
@@ -593,6 +593,9 @@ interface security
 		SECINFO_DACL                 = 0x00000004,
 		SECINFO_SACL                 = 0x00000008,
 		SECINFO_LABEL                = 0x00000010,
+		SECINFO_ATTRIBUTE	     = 0x00000020,
+		SECINFO_SCOPE                = 0x00000040,
+		SECINFO_BACKUP		     = 0x00010000,
 		SECINFO_UNPROTECTED_SACL     = 0x10000000,
 		SECINFO_UNPROTECTED_DACL     = 0x20000000,
 		SECINFO_PROTECTED_SACL	     = 0x40000000,
diff --git a/pidl/idl.yp b/pidl/idl.yp
index b5c5185..c8a65f6 100644
--- a/pidl/idl.yp
+++ b/pidl/idl.yp
@@ -610,7 +610,9 @@ again:
 
 	for ($parser->YYData->{INPUT}) {
 		if (/^\#/) {
-			if (s/^\# (\d+) \"(.*?)\"( \d+|)//) {
+			# Linemarker format is described at
+			# http://gcc.gnu.org/onlinedocs/cpp/Preprocessor-Output.html
+			if (s/^\# (\d+) \"(.*?)\"(( \d+){1,4}|)//) {
 				$parser->YYData->{LINE} = $1-1;
 				$parser->YYData->{FILE} = $2;
 				goto again;
diff --git a/pidl/lib/Parse/Pidl/IDL.pm b/pidl/lib/Parse/Pidl/IDL.pm
index d4820ff..6927c89 100644
--- a/pidl/lib/Parse/Pidl/IDL.pm
+++ b/pidl/lib/Parse/Pidl/IDL.pm
@@ -2576,7 +2576,9 @@ again:
 
 	for ($parser->YYData->{INPUT}) {
 		if (/^\#/) {
-			if (s/^\# (\d+) \"(.*?)\"( \d+|)//) {
+			# Linemarker format is described at
+			# http://gcc.gnu.org/onlinedocs/cpp/Preprocessor-Output.html
+			if (s/^\# (\d+) \"(.*?)\"(( \d+){1,4}|)//) {
 				$parser->YYData->{LINE} = $1-1;
 				$parser->YYData->{FILE} = $2;
 				goto again;
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index 864f3dc..01a1c47 100644
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -650,6 +650,8 @@ sub provision($$$$$$)
 	print CONF "
 [tmp]
 	path = $shrdir
+	comment = smb username is [%U]
+	vfs objects = $vfs_modulesdir_abs/dirsort.so
 [tmpguest]
 	path = $shrdir
         guest ok = yes
diff --git a/source3/configure.in b/source3/configure.in
index 5b14a24..42c23e3 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -4876,12 +4876,15 @@ AC_ARG_WITH(syslog-facility,
   if test "$withval" = "no" ; then
     AC_MSG_ERROR([argument to --with-syslog-facility must be a string])
   else
+     AC_MSG_RESULT([$withval])
      if test "$withval" != "yes" ; then
         syslog_facility="$withval"
 	AC_DEFINE_UNQUOTED(SYSLOG_FACILITY,$syslog_facility, [syslog facility to log to])
      fi
   fi
-])
+],
+AC_MSG_RESULT(no)
+)
 
 #################################################
 # check for experimental disk-quotas support
diff --git a/source3/modules/vfs_dirsort.c b/source3/modules/vfs_dirsort.c
index adeab04..698e96b 100644
--- a/source3/modules/vfs_dirsort.c
+++ b/source3/modules/vfs_dirsort.c
@@ -30,40 +30,60 @@ static int compare_dirent (const SMB_STRUCT_DIRENT *da, const SMB_STRUCT_DIRENT
 struct dirsort_privates {
 	long pos;
 	SMB_STRUCT_DIRENT *directory_list;
-	long number_of_entries;
-	time_t mtime;
+	unsigned int number_of_entries;
+	struct timespec mtime;
 	SMB_STRUCT_DIR *source_directory;
-	int fd;
+	files_struct *fsp; /* If open via FDOPENDIR. */
+	struct smb_filename *smb_fname; /* If open via OPENDIR */
 };
 
 static void free_dirsort_privates(void **datap) {
-	struct dirsort_privates *data = (struct dirsort_privates *) *datap;
-	SAFE_FREE(data->directory_list);
-	SAFE_FREE(data);
-	*datap = NULL;
-
-	return;
+	TALLOC_FREE(*datap);
 }
 
-static bool open_and_sort_dir (vfs_handle_struct *handle)
+static bool get_sorted_dir_mtime(vfs_handle_struct *handle,
+				struct dirsort_privates *data,
+				struct timespec *ret_mtime)
 {
-	SMB_STRUCT_DIRENT *dp;
-	struct stat dir_stat;
-	long current_pos;
-	struct dirsort_privates *data = NULL;
+	int ret;
+	struct timespec mtime;
+
+	if (data->fsp) {
+		ret = fsp_stat(data->fsp);
+		mtime = data->fsp->fsp_name->st.st_ex_mtime;
+	} else {
+		ret = SMB_VFS_STAT(handle->conn, data->smb_fname);
+		mtime = data->smb_fname->st.st_ex_mtime;
+	}
 
-	SMB_VFS_HANDLE_GET_DATA(handle, data, struct dirsort_privates,
-				return false);
+	if (ret == -1) {
+		return false;
+	}
+
+	*ret_mtime = mtime;
+
+	return true;
+}
+
+static bool open_and_sort_dir(vfs_handle_struct *handle,
+				struct dirsort_privates *data)
+{
+	unsigned int i = 0;
+	unsigned int total_count = 0;
 
 	data->number_of_entries = 0;
 
-	if (fstat(data->fd, &dir_stat) == 0) {
-		data->mtime = dir_stat.st_mtime;
+	if (get_sorted_dir_mtime(handle, data, &data->mtime) == false) {
+		return false;
 	}
 
 	while (SMB_VFS_NEXT_READDIR(handle, data->source_directory, NULL)
 	       != NULL) {
-		data->number_of_entries++;
+		total_count++;
+	}
+
+	if (total_count == 0) {
+		return false;
 	}
 
 	/* Open the underlying directory and count the number of entries
@@ -71,21 +91,26 @@ static bool open_and_sort_dir (vfs_handle_struct *handle)
 	SMB_VFS_NEXT_REWINDDIR(handle, data->source_directory);
 
 	/* Set up an array and read the directory entries into it */
-	SAFE_FREE(data->directory_list); /* destroy previous cache if needed */
-	data->directory_list = (SMB_STRUCT_DIRENT *)SMB_MALLOC(
-		data->number_of_entries * sizeof(SMB_STRUCT_DIRENT));
+	TALLOC_FREE(data->directory_list); /* destroy previous cache if needed */
+	data->directory_list = talloc_zero_array(data,
+						 SMB_STRUCT_DIRENT,
+						 total_count);
 	if (!data->directory_list) {
 		return false;
 	}
-	current_pos = data->pos;
-	data->pos = 0;
-	while ((dp = SMB_VFS_NEXT_READDIR(handle, data->source_directory,
-					  NULL)) != NULL) {
-		data->directory_list[data->pos++] = *dp;
+	for (i = 0; i < total_count; i++) {
+		SMB_STRUCT_DIRENT *dp = SMB_VFS_NEXT_READDIR(handle,
+						data->source_directory,
+						NULL);
+		if (dp == NULL) {
+			break;
+		}
+		data->directory_list[i] = *dp;
 	}
 
+	data->number_of_entries = i;
+
 	/* Sort the directory entries by name */
-	data->pos = current_pos;
 	TYPESAFE_QSORT(data->directory_list, data->number_of_entries, compare_dirent);
 	return true;
 }
@@ -94,33 +119,43 @@ static SMB_STRUCT_DIR *dirsort_opendir(vfs_handle_struct *handle,
 				       const char *fname, const char *mask,
 				       uint32 attr)
 {
+	NTSTATUS status;
 	struct dirsort_privates *data = NULL;
 
 	/* set up our private data about this directory */
-	data = (struct dirsort_privates *)SMB_MALLOC(
-		sizeof(struct dirsort_privates));
-
+	data = talloc_zero(handle->conn, struct dirsort_privates);
 	if (!data) {
 		return NULL;
 	}
 
-	data->directory_list = NULL;
-	data->pos = 0;
+	status = create_synthetic_smb_fname(data,
+					fname,
+					NULL,
+					NULL,
+					&data->smb_fname);
+	if (!NT_STATUS_IS_OK(status)) {
+		TALLOC_FREE(data);
+		return NULL;
+	}
 
 	/* Open the underlying directory and count the number of entries */
 	data->source_directory = SMB_VFS_NEXT_OPENDIR(handle, fname, mask,
 						      attr);
 
-	data->fd = dirfd(data->source_directory);
-
-	SMB_VFS_HANDLE_SET_DATA(handle, data, free_dirsort_privates,
-				struct dirsort_privates, return NULL);
+	if (data->source_directory == NULL) {
+		TALLOC_FREE(data);
+		return NULL;
+	}
 
-	if (!open_and_sort_dir(handle)) {
+	if (!open_and_sort_dir(handle, data)) {
 		SMB_VFS_NEXT_CLOSEDIR(handle,data->source_directory);
+		TALLOC_FREE(data);
 		return NULL;
 	}
 
+	SMB_VFS_HANDLE_SET_DATA(handle, data, free_dirsort_privates,
+				struct dirsort_privates, return NULL);
+
 	return data->source_directory;
 }
 
@@ -132,37 +167,33 @@ static SMB_STRUCT_DIR *dirsort_fdopendir(vfs_handle_struct *handle,
 	struct dirsort_privates *data = NULL;
 
 	/* set up our private data about this directory */
-	data = (struct dirsort_privates *)SMB_MALLOC(
-		sizeof(struct dirsort_privates));
-
+	data = talloc_zero(handle->conn, struct dirsort_privates);
 	if (!data) {
 		return NULL;
 	}
 
-	data->directory_list = NULL;
-	data->pos = 0;
+	data->fsp = fsp;
 
 	/* Open the underlying directory and count the number of entries */
 	data->source_directory = SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask,
 						      attr);
 
 	if (data->source_directory == NULL) {
-		SAFE_FREE(data);
+		TALLOC_FREE(data);
 		return NULL;
 	}
 
-	data->fd = dirfd(data->source_directory);
-
-	SMB_VFS_HANDLE_SET_DATA(handle, data, free_dirsort_privates,
-				struct dirsort_privates, return NULL);
-
-	if (!open_and_sort_dir(handle)) {
+	if (!open_and_sort_dir(handle, data)) {
 		SMB_VFS_NEXT_CLOSEDIR(handle,data->source_directory);
+		TALLOC_FREE(data);
 		/* fd is now closed. */
 		fsp->fh->fd = -1;
 		return NULL;
 	}
 
+	SMB_VFS_HANDLE_SET_DATA(handle, data, free_dirsort_privates,
+				struct dirsort_privates, return NULL);
+
 	return data->source_directory;
 }
 
@@ -171,21 +202,18 @@ static SMB_STRUCT_DIRENT *dirsort_readdir(vfs_handle_struct *handle,
 					  SMB_STRUCT_STAT *sbuf)
 {
 	struct dirsort_privates *data = NULL;
-	time_t current_mtime;
-	struct stat dir_stat;
+	struct timespec current_mtime;
 
 	SMB_VFS_HANDLE_GET_DATA(handle, data, struct dirsort_privates,
 				return NULL);
 
-	if (fstat(data->fd, &dir_stat) == -1) {
+	if (get_sorted_dir_mtime(handle, data, &current_mtime) == false) {
 		return NULL;
 	}
 
-	current_mtime = dir_stat.st_mtime;
-
 	/* throw away cache and re-read the directory if we've changed */
-	if (current_mtime > data->mtime) {
-		open_and_sort_dir(handle);
+	if (timespec_compare(&current_mtime, &data->mtime) > 1) {
+		open_and_sort_dir(handle, data);
 	}
 
 	if (data->pos >= data->number_of_entries) {
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index 7bc2832..4aad679 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -97,7 +97,13 @@ static int vfs_gpfs_setlease(vfs_handle_struct *handle, files_struct *fsp,
 		return -1;
 
 	if (config->leases) {
+		/*
+		 * Ensure the lease owner is root to allow
+		 * correct delivery of lease-break signals.
+		 */
+		become_root();
 		ret = set_gpfs_lease(fsp->fh->fd,leasetype);
+		unbecome_root();
 	}
 
 	if (ret < 0) {
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index 5fc3a09..a884b2f 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -885,13 +885,8 @@ NTSTATUS set_sd(files_struct *fsp, struct security_descriptor *psd,
 
 	/* Ensure we have at least one thing set. */
 	if ((security_info_sent & (SECINFO_OWNER|SECINFO_GROUP|SECINFO_DACL|SECINFO_SACL)) == 0) {
-		if (security_info_sent & SECINFO_LABEL) {
-			/* Only consider SECINFO_LABEL if no other
-			   bits are set. Just like W2K3 we don't
-			   store this. */
-			return NT_STATUS_OK;
-		}
-		return NT_STATUS_INVALID_PARAMETER;
+		/* Just like W2K3 */
+		return NT_STATUS_OK;
 	}
 
 	/* Ensure we have the rights to do this. */
diff --git a/source3/smbd/oplock_linux.c b/source3/smbd/oplock_linux.c
index 02bd32a..82523f2 100644
--- a/source3/smbd/oplock_linux.c
+++ b/source3/smbd/oplock_linux.c
@@ -75,26 +75,33 @@ int linux_set_lease_sighandler(int fd)
 int linux_setlease(int fd, int leasetype)
 {
 	int ret;
+	int saved_errno;
+
+	/*
+	 * Ensure the lease owner is root to allow
+	 * correct delivery of lease-break signals.
+	 */
+
+	become_root();
 
 	/* First set the signal handler. */
 	if (linux_set_lease_sighandler(fd) == -1) {
-		return -1;
+		saved_errno = errno;
+		ret = -1;
+		goto out;
 	}
 	ret = fcntl(fd, F_SETLEASE, leasetype);
-	if (ret == -1 && errno == EACCES) {
-		set_effective_capability(LEASE_CAPABILITY);
-		/*
-		 * Bug 8974 - work around Linux kernel bug
-		 * https://bugzilla.kernel.org/show_bug.cgi?id=43336.
-		 * "fcntl(F_SETLEASE) resets signal number when
-		 *  called multiple times"
-		 */
-		if (linux_set_lease_sighandler(fd) == -1) {
-			return -1;
-		}
-		ret = fcntl(fd, F_SETLEASE, leasetype);
+	if (ret == -1) {
+		saved_errno = errno;
 	}
 
+  out:
+
+	unbecome_root();
+
+	if (ret == -1) {
+		errno = saved_errno;
+	}
 	return ret;
 }
 
diff --git a/source3/winbindd/idmap_ad.c b/source3/winbindd/idmap_ad.c
index cf15f03..2b35a4f 100644
--- a/source3/winbindd/idmap_ad.c
+++ b/source3/winbindd/idmap_ad.c
@@ -457,7 +457,7 @@ again:
 				                 ctx->ad_schema->posix_gidnumber_attr,
 				     &id)) 
 		{
-			DEBUG(1, ("Could not get unix ID\n"));
+			DEBUG(1, ("Could not get SID for unix ID %u\n", (unsigned) id));
 			continue;
 		}
 
@@ -654,7 +654,8 @@ again:
 				                 ctx->ad_schema->posix_gidnumber_attr,


-- 
Samba Shared Repository


More information about the samba-cvs mailing list