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

Karolin Seeger kseeger at samba.org
Tue Mar 5 13:02:02 UTC 2019


The branch, v4-8-test has been updated
       via  7c476487867 vfs_ceph: remove ceph_fallocate/ceph_ftruncate fallback
       via  c539cf176a6 vfs_ceph: fix strict_allocate_ftruncate()
       via  cf279fbdd53 vfs_ceph: add missing fallocate hook
       via  03e4555f344 s3: smbd: filenames - ensure we replace the missing '/' if we error in an intermediate POSIX path.
       via  c249c88cdb7 s3: torture: Add additional POSIX mkdir tests.
       via  1ca055cb13b smbd: unix_convert: Ensure we don't call get_real_filename on POSIX paths.
       via  8d407971129 smbd: SMB1-POSIX: Add missing info-level SMB_POSIX_PATH_OPEN for UCF_UNIX_NAME_LOOKUP flag.
       via  3060221960b s3: smbtorture3: Add POSIX-MKDIR test for posix_mkdir case sensitive bug.
       via  89c3db2e9bb winbindd: set idmap cache entries as the last step in async wb_xids2sids
       via  29e16f4737c winbindd: track whether a result from xid2sid was coming from the cache
       via  447b0ad3a95 winbindd: switch send-next/done order
       via  19d06f27688 winbindd: update xid in wb_xids2sids_state->xids with what we got
       via  3197810fe1f winbindd: convert id to a pointer in wb_xids2sids_dom_done()
       via  8234ef264a7 winbindd: make xids a const argument to wb_xids2sids_send()
       via  a76277af385 winbindd: make a copy of xid's in wb_xids2sids_send()
       via  0f1525d430e messages_dgm: Properly handle receiver re-initialization
       via  e2b7d3ff627 torture3: Extend read3 for the "messaging target re-inits" failure
       via  069dd7189c1 messages_dgm: Use saved errno value
       via  1cb278ddaea notifyd: Fix SIGBUS on sparc
      from  8be2836cd82 PVE-2019-3824 ldb: Release ldb 1.3.8

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


- Log -----------------------------------------------------------------
commit 7c476487867e5dc83b9e844db7be4c3d358fc006
Author: David Disseldorp <ddiss at samba.org>
Date:   Wed Feb 27 11:52:42 2019 +0100

    vfs_ceph: remove ceph_fallocate/ceph_ftruncate fallback
    
    Both libcephfs functions are supported and capable of extending files,
    so fallback can be dropped.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13807
    
    Signed-off-by: David Disseldorp <ddiss at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    (cherry picked from commit 155f1289ba7a4802fbb99fbc9ea90d8bc6cff0c9)
    [ddiss at samba.org: rebase atop 48t without 532ff3a5b958]
    
    Autobuild-User(v4-8-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-8-test): Tue Mar  5 13:01:15 UTC 2019 on sn-devel-144

commit c539cf176a669e54ccddefa6b57a9285d12c93a9
Author: David Disseldorp <ddiss at samba.org>
Date:   Tue Feb 26 16:07:27 2019 +0100

    vfs_ceph: fix strict_allocate_ftruncate()
    
    The vfs_ceph "strict allocate = yes" ftruncate wrapper may attempt
    *local* filesystem ftruncate(). Fix this.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13807
    
    Signed-off-by: David Disseldorp <ddiss at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    (cherry picked from commit 70329c36ed91dd0e50ff66f9b0a85c62ac8a621e)

commit cf279fbdd531d4cab9cb0e6b8341e6cb1bbd9978
Author: David Disseldorp <ddiss at samba.org>
Date:   Tue Feb 26 21:26:27 2019 +0100

    vfs_ceph: add missing fallocate hook
    
    SMB_VFS_FALLOCATE() calls atop a vfs_ceph share currently fall through
    to vfs_default, which results in a local filesystem I/O attempt using a
    libcephfs file-descriptor. Add the missing fallocate hook to vfs_ceph.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13807
    
    Signed-off-by: David Disseldorp <ddiss at samba.org>
    Reviewed-by: Guenther Deschner <gd at samba.org>
    (cherry picked from commit 5a7e7280813559fb70a9fc8e4238cb6015ee3b53)

commit 03e4555f344e6806c80fefc8cf00a08d6ea2766e
Author: Jeremy Allison <jra at samba.org>
Date:   Sun Feb 24 08:15:23 2019 -0800

    s3: smbd: filenames - ensure we replace the missing '/' if we error in an intermediate POSIX path.
    
    Previous regression test ensures we still return the correct
    error code for POSIX pathname operations.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13803
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Mon Feb 25 09:33:27 CET 2019 on sn-devel-144
    
    (cherry picked from commit 3f1a13a94a753c5cb3b9f2cf795df5adb0f74205)

commit c249c88cdb731026da04819e165717bb89278a42
Author: Jeremy Allison <jra at samba.org>
Date:   Sun Feb 24 08:03:32 2019 -0800

    s3: torture: Add additional POSIX mkdir tests.
    
    Ensure that if POSIX_foo exists as a file
    we return the correct error code NT_STATUS_OBJECT_PATH_NOT_FOUND
    if we try and traverse it as a directory.
    
    Also ensure creation/deletion of POSIX_foo/foo fails
    for directories and files with NT_STATUS_OBJECT_PATH_NOT_FOUND
    if the directory POSIX_foo/ doesn't exist.
    
    knownfail is back :-).
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13803
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 632d0db8c42d50f5eecd002d9573f739cd945960)

commit 1ca055cb13b750180e268714a34472225c773fec
Author: Jeremy Allison <jra at samba.org>
Date:   Sat Feb 23 12:24:31 2019 -0800

    smbd: unix_convert: Ensure we don't call get_real_filename on POSIX paths.
    
    For posix_pathnames don't blunder into the name_has_wildcard OR
    get_real_filename() codepaths as they may be doing case insensitive lookups.
    So when creating a new POSIX directory 'Foo' they might
    match on name 'foo'.
    
    Remove POSIX-MKDIR from knownfail.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13803
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Sun Feb 24 14:04:14 CET 2019 on sn-devel-144
    
    (cherry picked from commit 12da33e2bbce657f25abe9bc4cb936ca4615b30f)

commit 8d407971129ae308c574c0d9dc7e0cfd7c7483b1
Author: Jeremy Allison <jra at samba.org>
Date:   Sat Feb 23 12:26:01 2019 -0800

    smbd: SMB1-POSIX: Add missing info-level SMB_POSIX_PATH_OPEN for UCF_UNIX_NAME_LOOKUP flag.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13803
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 980db8debde68f9edce13fc01bc45a904379cffd)

commit 3060221960b6d76a98f1a3eaf8afefe12a0fc717
Author: Jeremy Allison <jra at samba.org>
Date:   Sat Feb 23 17:52:34 2019 -0800

    s3: smbtorture3: Add POSIX-MKDIR test for posix_mkdir case sensitive bug.
    
    Test does:
    
    mkdir POSIX_foo
    mkdir POSIX_Foo
    mkdir POSIX_foo/Foo
    mkdir POSIX_foo/foo
    mkdir POSIX_Foo/Foo
    mkdir POSIX_Foo/foo
    
    Which should pass a SMB1 POSIX extensions server
    as posix mkdir should always be case sensitive
    no matter what the share is set to.
    
    Mark as knownfail for now.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13803
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit f0decb31fff24ceb57d23bebbfb87aa0e5103947)

commit 89c3db2e9bbb39d3665db0f2eecd62f253771199
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Feb 21 16:55:09 2019 +0100

    winbindd: set idmap cache entries as the last step in async wb_xids2sids
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13802
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Sat Feb 23 09:23:22 CET 2019 on sn-devel-144
    
    (cherry picked from commit 9b9565c3e69b92c298c7168e516387bb249c9e36)

commit 29e16f4737c6e955a18bc1130d06dcf17b7cb0d1
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Feb 22 11:00:00 2019 +0100

    winbindd: track whether a result from xid2sid was coming from the cache
    
    This is needed in preparation of moving the step to update the idmap
    cache from the per-idmap-domain callback wb_xids2sids_dom_done() to the
    top-level callback wb_xids2sids_done().
    
    Currently the sequence of action is:
    
    * check cache, if not found:
      * ask backends
      * cache result from backend
    * return results
    
    Iow, if we got something from the cache, we don't write the cache.
    
    The next commit defers updating the cache to the top-level callback, so
    the sequence becomes
    
    * check cache, if not found:
      * ask backends
    * cache results
    * return results
    
    This has two problems:
    
    * it needlessly writes to the cache what we just got from it
    
    * it possibly overwrites the ID_TYPE_BOTH for a SID-to-xid mapping in
      the following case:
    
      - existing ID_TYPE_BOTH mapping in the cache, eg:
    
        IDMAP/SID2XID/S-1-5-21-2180672342-2513613279-2566592647-512 -> Value: 3000000:B
    
      - someone calls wb_xids2sids_send() with xid.id=3000000,xid.type=ID_TYPE_GID
    
      - cache lookup with idmap_cache_find_gid2sid() succeeds
    
      - when caching results we'd call idmap_cache_set_sid2unixid() with the
        callers xid.type=ID_TYPE_GID, so idmap_cache_set_sid2unixid() will
        overwrite the SID-to-xid mapping with ID_TYPE_GID
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13802
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 62f54229fced20102e11ad1da02faef45c2a7c2e)

commit 447b0ad3a956909d72ce9de6cfa60f34ae23b437
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Feb 21 16:52:21 2019 +0100

    winbindd: switch send-next/done order
    
    In preparation of adding more logic to the done step. No change in
    behaviour.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13802
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 8e9c2a1f6ceb06d695a6572701b96a3e3821ac42)

commit 19d06f27688b0931624911d15d26dbabaa39deb1
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Feb 21 18:40:20 2019 +0100

    winbindd: update xid in wb_xids2sids_state->xids with what we got
    
    In preparation of priming the idmap cache in the top-level
    wb_xids2sids_done(), not in the per-idmap-domain callback
    wb_xids2sids_dom_done().
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13802
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 7f23ef7b2cf7bd6e8dc087aa15137292b421a689)

commit 3197810fe1f2675afdb2b7b7e863c0f05cc26370
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Feb 21 18:39:46 2019 +0100

    winbindd: convert id to a pointer in wb_xids2sids_dom_done()
    
    No change in behaviour.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13802
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit f8bf4fc608639695651f75c52b31f95e796a5a26)

commit 8234ef264a7d9344b412a0b2b36dc4c6b47876e4
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Feb 22 16:29:07 2019 +0100

    winbindd: make xids a const argument to wb_xids2sids_send()
    
    The previous commit made an internal copy of xids, this commit makes it
    more obvious that we must not mess with the xids argument but treat it as
    an in-parameter and don't write to it.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13802
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 5d277ea7ea258676b9ea5081a451a5874af115f6)

commit a76277af385b10518dccf83ccb1b49173d625881
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Feb 21 18:34:51 2019 +0100

    winbindd: make a copy of xid's in wb_xids2sids_send()
    
    This is in preparation of setting the result of the mapping in the top-
    level callback wb_xids2sids_done(), not in the per-idmap-domain callback
    wb_xids2sids_dom_done().
    
    When caching the mapping we need the id-type from the backend, so we
    need a way to pass up that information from wb_xids2sids_dom_done() up
    to wb_xids2sids_done()
    
    The xids array copy gets passed from wb_xids2sids_send() to
    wb_xids2sids_dom_send(), so wb_xids2sids_dom_done() can then directly
    update the top-level copy.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13802
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit f5a8bc2f945be45cdade5f70d4f975bae8337f67)

commit 0f1525d430ec4975952520b00cbd4c5e49f9b097
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Feb 7 16:15:46 2019 +0100

    messages_dgm: Properly handle receiver re-initialization
    
    This only properly covers the small-message nonblocking case. Covering
    the large-message and the blocking case is a much larger effort assuming
    we want to re-send the failed message if parts of the message has gone
    through properly. Don't do that for now.
    
    This was found by sanba_dnsupdate constantly recreating its irpc handle to
    winbindd in the RODC case.
    
    The messaging_dgm code cached connected datagram sockets based on the
    destination pid for 1 second. Which means the IRPC responses from
    winbindd are never delivered to samba_dnsupdate,
    which will then hit a timeout.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13786
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit 2543bba0364d8054e9ad316f5611621841bc061d)

commit e2b7d3ff62745c1205a36b296e9371636950cc85
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Feb 7 17:48:34 2019 +0100

    torture3: Extend read3 for the "messaging target re-inits" failure
    
    Do ping_pong a hundred times, re-initializing the msg_ctx every time.
    
    https://bugzilla.samba.org/show_bug.cgi?id=13786
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit 8d8f62c4b9dea381ce9f5833bc794553ae358173)

commit 069dd7189c10ba5ffdbe5f70f91a11ba4e55981f
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Feb 7 15:57:06 2019 +0100

    messages_dgm: Use saved errno value
    
    In this case this is just a cleanup, the value has just been set by
    messaging_dgm_sendmsg. But as that already saves errno into a local
    variable, use that.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13786
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit c27afc098398274abaed6dc9bef2019091c1b635)

commit 1cb278ddaea03c946ed9f32665517ffaec833823
Author: Jiří Šašek <jiri.sasek at oracle.com>
Date:   Thu Dec 6 14:10:53 2018 +0100

    notifyd: Fix SIGBUS on sparc
    
    Problem is the structure "struct notify_instance" can lay in message buffer on
    address not dividable by 8 but this structure begins by uint_64 (secs in
    time-stamp). Structure should be re-packed to standalone buffer before the use.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13704
    Signed-off-by: jiri.sasek at oracle.com
    Reviewed-by: Volker Lendecke <vl at samba.org>

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

Summary of changes:
 selftest/skip                         |   1 +
 source3/lib/messages_dgm.c            |  18 ++-
 source3/modules/vfs_ceph.c            | 117 +++++---------------
 source3/selftest/tests.py             |   2 +-
 source3/smbd/filename.c               |  43 ++++++++
 source3/smbd/notifyd/notifyd.c        |  11 +-
 source3/smbd/trans2.c                 |   1 +
 source3/torture/test_messaging_read.c |  44 ++++----
 source3/torture/torture.c             | 202 ++++++++++++++++++++++++++++++++++
 source3/winbindd/wb_xids2sids.c       |  74 +++++++++----
 source3/winbindd/winbindd_proto.h     |   2 +-
 11 files changed, 375 insertions(+), 140 deletions(-)


Changeset truncated at 500 lines:

diff --git a/selftest/skip b/selftest/skip
index dd60ab5a1fb..4d6648f3369 100644
--- a/selftest/skip
+++ b/selftest/skip
@@ -48,6 +48,7 @@
 ^samba3.smbtorture_s3.plain\(ad_dc_ntvfs\).POSIX-SYMLINK-EA # Fails against the s4 ntvfs server
 ^samba3.smbtorture_s3.plain\(ad_dc_ntvfs\).POSIX-OFD-LOCK # Fails against the s4 ntvfs server
 ^samba3.smbtorture_s3.plain\(ad_dc_ntvfs\).POSIX-STREAM-DELETE # Fails against the s4 ntvfs server
+^samba3.smbtorture_s3.plain\(ad_dc_ntvfs\).POSIX-MKDIR # Fails against the s4 ntvfs server
 ^samba3.smbtorture_s3.plain\(ad_dc_ntvfs\).WINDOWS-BAD-SYMLINK # Fails against the s4 ntvfs server
 ^samba3.smbtorture_s3.plain\(ad_dc_ntvfs\).RENAME-ACCESS # Fails against the s4 ntvfs server
 ^samba3.smbtorture_s3.plain\(ad_dc_ntvfs\).OWNER-RIGHTS # Don't test against the s4 ntvfs server anymore
diff --git a/source3/lib/messages_dgm.c b/source3/lib/messages_dgm.c
index b9cddc274c2..2fd63008b69 100644
--- a/source3/lib/messages_dgm.c
+++ b/source3/lib/messages_dgm.c
@@ -553,7 +553,7 @@ static void messaging_dgm_out_threaded_job(void *private_data)
 		if (state->sent != -1) {
 			return;
 		}
-		if (errno != ENOBUFS) {
+		if (state->err != ENOBUFS) {
 			return;
 		}
 
@@ -1415,6 +1415,7 @@ int messaging_dgm_send(pid_t pid,
 	struct messaging_dgm_context *ctx = global_dgm_context;
 	struct messaging_dgm_out *out;
 	int ret;
+	unsigned retries = 0;
 
 	if (ctx == NULL) {
 		return ENOTCONN;
@@ -1422,6 +1423,7 @@ int messaging_dgm_send(pid_t pid,
 
 	messaging_dgm_validate(ctx);
 
+again:
 	ret = messaging_dgm_out_get(ctx, pid, &out);
 	if (ret != 0) {
 		return ret;
@@ -1431,6 +1433,20 @@ int messaging_dgm_send(pid_t pid,
 
 	ret = messaging_dgm_out_send_fragmented(ctx->ev, out, iov, iovlen,
 						fds, num_fds);
+	if (ret == ECONNREFUSED) {
+		/*
+		 * We cache outgoing sockets. If the receiver has
+		 * closed and re-opened the socket since our last
+		 * message, we get connection refused. Retry.
+		 */
+
+		TALLOC_FREE(out);
+
+		if (retries < 5) {
+			retries += 1;
+			goto again;
+		}
+	}
 	return ret;
 }
 
diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c
index b6707458b77..5d67142997d 100644
--- a/source3/modules/vfs_ceph.c
+++ b/source3/modules/vfs_ceph.c
@@ -1124,9 +1124,7 @@ static struct smb_filename *cephwrap_getwd(struct vfs_handle_struct *handle,
 static int strict_allocate_ftruncate(struct vfs_handle_struct *handle, files_struct *fsp, off_t len)
 {
 	off_t space_to_write;
-	uint64_t space_avail;
-	uint64_t bsize,dfree,dsize;
-	int ret;
+	int result;
 	NTSTATUS status;
 	SMB_STRUCT_STAT *pst;
 
@@ -1145,111 +1143,45 @@ static int strict_allocate_ftruncate(struct vfs_handle_struct *handle, files_str
 		return 0;
 
 	/* Shrink - just ftruncate. */
-	if (pst->st_ex_size > len)
-		return ftruncate(fsp->fh->fd, len);
-
-	space_to_write = len - pst->st_ex_size;
-
-	/* for allocation try fallocate first. This can fail on some
-	   platforms e.g. when the filesystem doesn't support it and no
-	   emulation is being done by the libc (like on AIX with JFS1). In that
-	   case we do our own emulation. fallocate implementations can
-	   return ENOTSUP or EINVAL in cases like that. */
-	ret = SMB_VFS_FALLOCATE(fsp, 0, pst->st_ex_size, space_to_write);
-	if (ret == -1 && errno == ENOSPC) {
-		return -1;
-	}
-	if (ret == 0) {
-		return 0;
-	}
-	DEBUG(10,("[CEPH] strict_allocate_ftruncate: SMB_VFS_FALLOCATE failed with "
-		"error %d. Falling back to slow manual allocation\n", errno));
-
-	/* available disk space is enough or not? */
-	space_avail =
-	    get_dfree_info(fsp->conn, fsp->fsp_name, &bsize, &dfree, &dsize);
-	/* space_avail is 1k blocks */
-	if (space_avail == (uint64_t)-1 ||
-			((uint64_t)space_to_write/1024 > space_avail) ) {
-		errno = ENOSPC;
-		return -1;
+	if (pst->st_ex_size > len) {
+		result = ceph_ftruncate(handle->data, fsp->fh->fd, len);
+		WRAP_RETURN(result);
 	}
 
-	/* Write out the real space on disk. */
-	return vfs_slow_fallocate(fsp, pst->st_ex_size, space_to_write);
+	space_to_write = len - pst->st_ex_size;
+	result = ceph_fallocate(handle->data, fsp->fh->fd, 0, pst->st_ex_size,
+				space_to_write);
+	WRAP_RETURN(result);
 }
 
 static int cephwrap_ftruncate(struct vfs_handle_struct *handle, files_struct *fsp, off_t len)
 {
 	int result = -1;
-	SMB_STRUCT_STAT st;
-	char c = 0;
-	off_t currpos;
 
 	DBG_DEBUG("[CEPH] ftruncate(%p, %p, %llu\n", handle, fsp, llu(len));
 
 	if (lp_strict_allocate(SNUM(fsp->conn))) {
-		result = strict_allocate_ftruncate(handle, fsp, len);
-		return result;
+		return strict_allocate_ftruncate(handle, fsp, len);
 	}
 
-	/* we used to just check HAVE_FTRUNCATE_EXTEND and only use
-	   sys_ftruncate if the system supports it. Then I discovered that
-	   you can have some filesystems that support ftruncate
-	   expansion and some that don't! On Linux fat can't do
-	   ftruncate extend but ext2 can. */
-
 	result = ceph_ftruncate(handle->data, 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
-	   for this */
-	currpos = SMB_VFS_LSEEK(fsp, 0, SEEK_CUR);
-	if (currpos == -1) {
-		goto done;
-	}
-
-	/* Do an fstat to see if the file is longer than the requested
-	   size in which case the ftruncate above should have
-	   succeeded or shorter, in which case seek to len - 1 and
-	   write 1 byte of zero */
-	if (SMB_VFS_FSTAT(fsp, &st) == -1) {
-		goto done;
-	}
-
-#ifdef S_ISFIFO
-	if (S_ISFIFO(st.st_ex_mode)) {
-		result = 0;
-		goto done;
-	}
-#endif
-
-	if (st.st_ex_size == len) {
-		result = 0;
-		goto done;
-	}
-
-	if (st.st_ex_size > len) {
-		/* the sys_ftruncate should have worked */
-		goto done;
-	}
-
-	if (SMB_VFS_LSEEK(fsp, len-1, SEEK_SET) != len -1)
-		goto done;
-
-	if (SMB_VFS_WRITE(fsp, &c, 1)!=1)
-		goto done;
-
-	/* Seek to where we were */
-	if (SMB_VFS_LSEEK(fsp, currpos, SEEK_SET) != currpos)
-		goto done;
-	result = 0;
+	WRAP_RETURN(result);
+}
 
-  done:
+static int cephwrap_fallocate(struct vfs_handle_struct *handle,
+			      struct files_struct *fsp,
+			      uint32_t mode,
+			      off_t offset,
+			      off_t len)
+{
+	int result;
 
-	return result;
+	DBG_DEBUG("[CEPH] fallocate(%p, %p, %u, %llu, %llu\n",
+		  handle, fsp, mode, llu(offset), llu(len));
+	/* unsupported mode flags are rejected by libcephfs */
+	result = ceph_fallocate(handle->data, fsp->fh->fd, mode, offset, len);
+	DBG_DEBUG("[CEPH] fallocate(...) = %d\n", result);
+	WRAP_RETURN(result);
 }
 
 static bool cephwrap_lock(struct vfs_handle_struct *handle, files_struct *fsp, int op, off_t offset, off_t count, int type)
@@ -1613,6 +1545,7 @@ static struct vfs_fn_pointers ceph_fns = {
 	.getwd_fn = cephwrap_getwd,
 	.ntimes_fn = cephwrap_ntimes,
 	.ftruncate_fn = cephwrap_ftruncate,
+	.fallocate_fn = cephwrap_fallocate,
 	.lock_fn = cephwrap_lock,
 	.kernel_flock_fn = cephwrap_kernel_flock,
 	.linux_setlease_fn = cephwrap_linux_setlease,
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 0625c7e924e..e5433a55118 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -117,7 +117,7 @@ for t in tests:
     plantestsuite("samba3.smbtorture_s3.vfs_aio_fork(simpleserver).%s" % t, "simpleserver", [os.path.join(samba3srcdir, "script/tests/test_smbtorture_s3.sh"), t, '//$SERVER_IP/vfs_aio_fork', '$USERNAME', '$PASSWORD', smbtorture3, "", "-l $LOCAL_PATH"])
 
 posix_tests = ["POSIX", "POSIX-APPEND", "POSIX-SYMLINK-ACL", "POSIX-SYMLINK-EA", "POSIX-OFD-LOCK",
-              "POSIX-STREAM-DELETE", "WINDOWS-BAD-SYMLINK" ]
+              "POSIX-STREAM-DELETE", "WINDOWS-BAD-SYMLINK", "POSIX-MKDIR" ]
 
 for t in posix_tests:
     plantestsuite("samba3.smbtorture_s3.plain(nt4_dc).%s" % t, "nt4_dc", [os.path.join(samba3srcdir, "script/tests/test_smbtorture_s3.sh"), t, '//$SERVER_IP/posix_share', '$USERNAME', '$PASSWORD', smbtorture3, "", "-l $LOCAL_PATH"])
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index ede14b95e79..8a00fbb06e7 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -906,6 +906,49 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
 			/* Stat failed - ensure we don't use it. */
 			SET_STAT_INVALID(smb_fname->st);
 
+			if (posix_pathnames) {
+				/*
+				 * For posix_pathnames, we're done.
+				 * Don't blunder into the name_has_wildcard OR
+				 * get_real_filename() codepaths as they may
+				 * be doing case insensitive lookups. So when
+				 * creating a new POSIX directory Foo they might
+				 * match on name foo.
+				 *
+				 * BUG: https://bugzilla.samba.org/show_bug.cgi?id=13803
+				 */
+				if (end != NULL) {
+					const char *morepath = NULL;
+					/*
+					 * If this is intermediate we must
+					 * restore the full path.
+					 */
+					*end = '/';
+					/*
+					 * If there are any more components
+					 * after the failed LSTAT we cannot
+					 * continue.
+					 */
+					morepath = strchr(end + 1, '/');
+					if (morepath != NULL) {
+						status = NT_STATUS_OBJECT_PATH_NOT_FOUND;
+						goto fail;
+					}
+				}
+				if (errno == ENOENT) {
+					/* New file or directory. */
+					goto done;
+				}
+				if ((errno == EACCES) &&
+				    (ucf_flags & UCF_PREP_CREATEFILE)) {
+					/* POSIX Dropbox case. */
+					errno = 0;
+					goto done;
+				}
+				status = map_nt_error_from_unix(errno);
+				goto fail;
+			}
+
 			/*
 			 * Reset errno so we can detect
 			 * directory open errors.
diff --git a/source3/smbd/notifyd/notifyd.c b/source3/smbd/notifyd/notifyd.c
index e4e5c785472..4fcef508a91 100644
--- a/source3/smbd/notifyd/notifyd.c
+++ b/source3/smbd/notifyd/notifyd.c
@@ -575,6 +575,7 @@ static void notifyd_rec_change(struct messaging_context *msg_ctx,
 	struct notify_rec_change_msg *msg;
 	size_t pathlen;
 	bool ok;
+	struct notify_instance instance;
 
 	DBG_DEBUG("Got %zu bytes from %s\n", data->length,
 		  server_id_str_buf(src, &idbuf));
@@ -585,8 +586,10 @@ static void notifyd_rec_change(struct messaging_context *msg_ctx,
 		return;
 	}
 
+	memcpy(&instance, &msg->instance, sizeof(instance)); /* avoid SIGBUS */
+
 	ok = notifyd_apply_rec_change(
-		&src, msg->path, pathlen, &msg->instance,
+		&src, msg->path, pathlen, &instance,
 		state->entries, state->sys_notify_watch, state->sys_notify_ctx,
 		state->msg_ctx);
 	if (!ok) {
@@ -1337,6 +1340,7 @@ static void notifyd_apply_reclog(struct notifyd_peer *peer,
 		struct notify_rec_change_msg *chg;
 		size_t pathlen;
 		bool ok;
+		struct notify_instance instance;
 
 		ok = notifyd_parse_rec_change(r->buf.data, r->buf.length,
 					      &chg, &pathlen);
@@ -1346,8 +1350,11 @@ static void notifyd_apply_reclog(struct notifyd_peer *peer,
 			goto fail;
 		}
 
+		/* avoid SIGBUS */
+		memcpy(&instance, &chg->instance, sizeof(instance));
+
 		ok = notifyd_apply_rec_change(&r->src, chg->path, pathlen,
-					      &chg->instance, peer->db,
+					      &instance, peer->db,
 					      state->sys_notify_watch,
 					      state->sys_notify_ctx,
 					      state->msg_ctx);
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index bb20ebeec86..a2dbf344bb7 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -8829,6 +8829,7 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
 		if (info_level == SMB_SET_FILE_UNIX_BASIC ||
 				info_level == SMB_SET_FILE_UNIX_INFO2 ||
 				info_level == SMB_FILE_RENAME_INFORMATION ||
+				info_level == SMB_POSIX_PATH_OPEN ||
 				info_level == SMB_POSIX_PATH_UNLINK) {
 			ucf_flags |= UCF_UNIX_NAME_LOOKUP;
 		}
diff --git a/source3/torture/test_messaging_read.c b/source3/torture/test_messaging_read.c
index d3e4079074b..555f084c040 100644
--- a/source3/torture/test_messaging_read.c
+++ b/source3/torture/test_messaging_read.c
@@ -250,14 +250,13 @@ fail:
 }
 
 struct msg_pingpong_state {
-	uint8_t dummy;
+	struct messaging_context *msg_ctx;
 };
 
 static void msg_pingpong_done(struct tevent_req *subreq);
 
 static struct tevent_req *msg_pingpong_send(TALLOC_CTX *mem_ctx,
 					    struct tevent_context *ev,
-					    struct messaging_context *msg_ctx,
 					    struct server_id dst)
 {
 	struct tevent_req *req, *subreq;
@@ -269,13 +268,23 @@ static struct tevent_req *msg_pingpong_send(TALLOC_CTX *mem_ctx,
 		return NULL;
 	}
 
-	status = messaging_send_buf(msg_ctx, dst, MSG_PING, NULL, 0);
+	if (!tevent_req_set_endtime(req, ev, timeval_current_ofs(10, 0))) {
+		return tevent_req_post(req, ev);
+	}
+
+	state->msg_ctx = messaging_init(state, ev);
+	if (tevent_req_nomem(state->msg_ctx, req)) {
+		return tevent_req_post(req, ev);
+	}
+
+	status = messaging_send_buf(state->msg_ctx, dst, MSG_PING, NULL, 0);
 	if (!NT_STATUS_IS_OK(status)) {
+		DBG_DEBUG("messaging_send_buf failed: %s\n", nt_errstr(status));
 		tevent_req_error(req, map_errno_from_nt_status(status));
 		return tevent_req_post(req, ev);
 	}
 
-	subreq = messaging_read_send(state, ev, msg_ctx, MSG_PONG);
+	subreq = messaging_read_send(state, ev, state->msg_ctx, MSG_PONG);
 	if (tevent_req_nomem(subreq, req)) {
 		return tevent_req_post(req, ev);
 	}
@@ -308,18 +317,17 @@ static int msg_pingpong_recv(struct tevent_req *req)
 	return 0;
 }
 
-static int msg_pingpong(struct messaging_context *msg_ctx,
-			struct server_id dst)
+static int msg_pingpong(struct server_id dst)
 {
 	struct tevent_context *ev;
 	struct tevent_req *req;
 	int ret = ENOMEM;
 
-	ev = tevent_context_init(msg_ctx);
+	ev = tevent_context_init(talloc_tos());
 	if (ev == NULL) {
 		goto fail;
 	}
-	req = msg_pingpong_send(ev, ev, msg_ctx, dst);
+	req = msg_pingpong_send(ev, ev, dst);
 	if (req == NULL) {
 		goto fail;
 	}
@@ -398,7 +406,7 @@ bool run_messaging_read3(int dummy)
 	pid_t child;
 	int ready_pipe[2];
 	int exit_pipe[2];
-	int ret;
+	int i, ret;
 	char c;
 	struct server_id dst;
 	ssize_t written;
@@ -433,19 +441,15 @@ bool run_messaging_read3(int dummy)
 		fprintf(stderr, "tevent_context_init failed\n");
 		goto fail;
 	}
-	msg_ctx = messaging_init(ev, ev);
-	if (msg_ctx == NULL) {
-		fprintf(stderr, "messaging_init failed\n");
-		goto fail;
-	}
 
-	dst = messaging_server_id(msg_ctx);
-	dst.pid = child;
+	dst = (struct server_id){ .pid = child, .vnn = NONCLUSTER_VNN, };
 
-	ret = msg_pingpong(msg_ctx, dst);
-	if (ret != 0){
-		fprintf(stderr, "msg_pingpong failed\n");
-		goto fail;
+	for (i=0; i<100; i++) {
+		ret = msg_pingpong(dst);
+		if (ret != 0){
+			fprintf(stderr, "msg_pingpong failed\n");
+			goto fail;
+		}
 	}
 
 	printf("Parent: telling child to exit\n");
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index ed7390a47a7..206cc860e5a 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -7254,6 +7254,207 @@ static bool run_posix_ofd_lock_test(int dummy)
 	return correct;
 }
 
+/*
+  Test POSIX mkdir is case-sensitive.
+ */
+static bool run_posix_mkdir_test(int dummy)
+{
+	static struct cli_state *cli;
+	const char *fname_foo = "POSIX_foo";
+	const char *fname_foo_Foo = "POSIX_foo/Foo";
+	const char *fname_foo_foo = "POSIX_foo/foo";
+	const char *fname_Foo = "POSIX_Foo";
+	const char *fname_Foo_Foo = "POSIX_Foo/Foo";
+	const char *fname_Foo_foo = "POSIX_Foo/foo";
+	bool correct = false;
+	NTSTATUS status;
+	TALLOC_CTX *frame = NULL;
+	uint16_t fnum = (uint16_t)-1;
+
+	frame = talloc_stackframe();
+
+	printf("Starting POSIX mkdir test\n");
+
+	if (!torture_open_connection(&cli, 0)) {
+		TALLOC_FREE(frame);
+		return false;
+	}
+
+	smbXcli_conn_set_sockopt(cli->conn, sockops);
+
+	status = torture_setup_unix_extensions(cli);
+	if (!NT_STATUS_IS_OK(status)) {
+		TALLOC_FREE(frame);
+		return false;
+	}
+
+	cli_posix_rmdir(cli, fname_foo_foo);
+	cli_posix_rmdir(cli, fname_foo_Foo);
+	cli_posix_rmdir(cli, fname_foo);
+
+	cli_posix_rmdir(cli, fname_Foo_foo);
+	cli_posix_rmdir(cli, fname_Foo_Foo);
+	cli_posix_rmdir(cli, fname_Foo);
+
+	/*
+	 * Create a file POSIX_foo then try


-- 
Samba Shared Repository



More information about the samba-cvs mailing list