[SCM] Samba Shared Repository - branch master updated

Ralph Böhme slow at samba.org
Mon Jul 25 12:57:01 UTC 2022


The branch, master has been updated
       via  8ff2fe33bda smbd: Userspace symlink eval in filename_convert_dirfsp()
       via  9fc4659215a smbd: Take care of @GMT in SMB1's reply_ntcreate_and_X()
       via  7bb8af3f74c vfs_error_inject: Ignore openat() from openat_pathref_dirfsp_nosymlink()
       via  d6fcae23f47 smbd: Add openat_pathref_dirfsp_nosymlink()
       via  9826da77b90 smbd: Make get_real_filename_at public
       via  87f03333e8b smbd: Some more assert in fd_openat()
       via  f292b1ae002 smbd: Simplify open_stream_pathref_fsp()
       via  348f19d35b3 smbd: open_stream_pathref_fsp() does not need a dirfsp
       via  52ecf98688d smbd: Simplify openat_pathref_fullname()
       via  afe1b94b230 smbd: Open openat_pathref_fullname() for streams
       via  45168bffe02 smbd: Hand full_fname from openat_pathref_nostream()
       via  37fd029e6ff smbd: A stream open does not need O_NOFOLLOW
       via  8420f62c01a smbd: Simplify openat_pathref_fsp()
       via  7295377a41c smbd: Simplify non_widelink_open()
       via  c267c9839eb VFS: NULL dirfsp for openat on stream opens
       via  0c8d55ed899 vfs_shadow_copy2: Don't reference dirfsp for streams
       via  dd5e10d6013 smbd: Make fsp_attach_smb_fname() talloc_move() the name to the fsp
       via  d67c7c091fe smbd: Update fsp->fsp_flags.is_directory in vfs_stat_fsp()
       via  217e7c162c2 libcli: Modernize a few DEBUG statements
       via  d2e5c9c96be test3: Fix a debug message
       via  5c702e03f52 smbd: Factor out extract_snapshot_token() from canonicalize_snapshot_path()
       via  b5c17b79364 smbd: Simplify canonicalize_snapshot_path()
       via  53f9b32a95b smbd: Don't create a fsp->base_fsp for a "::$DATA" stream
       via  08f4ee6cabb torture3: Fix an error check in torture_delete_fn()
       via  3fc5f9f409e registry3: Align an integer type
       via  138fdfaa40e registry3: Align function types to what is returned
       via  1d02c462f01 lib: Simplify canonicalize_absolute_path()
       via  e2d30fd5b76 lib: Remove a few #include "includes.h"
       via  b4a3c22acd5 smbd: Avoid a "? True : False"
       via  58d7b76a0ac smbd: Open up openat_internal_dir_from_pathref() for general dirs
      from  930426db02e lib: On FreeBSD util_paths.c does not find struct stat

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


- Log -----------------------------------------------------------------
commit 8ff2fe33bdad605a2abfb5f3fac28b32f3211b96
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jul 14 19:47:23 2022 +0200

    smbd: Userspace symlink eval in filename_convert_dirfsp()
    
    This converts filename_convert_dirfsp to do symlink evaluation in user
    space. It uses openat_pathref_dirfsp_nosymlink() to open the dirpath
    and looks at the proper NT_STATUS_STOPPED_ON_SYMLINK response. Using
    this avoids filename_convert() and thus unix_convert() completely for
    the SMB2_CREATE case.
    
    The tests
    
    samba3.blackbox.smbclient_s3.NT1.plain.Recursive ls across MS-DFS links
    
    now correctly stop the symlink lookup recursion with
    NT_STATUS_OBJECT_PATH_NOT_FOUND. Previously we did not correcly pass up the
    ELOOP coming back from the stat-call.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    
    Autobuild-User(master): Ralph Böhme <slow at samba.org>
    Autobuild-Date(master): Mon Jul 25 12:56:08 UTC 2022 on sn-devel-184

commit 9fc4659215ac6586003d43c1552e79915093fb58
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jul 12 17:48:25 2022 +0200

    smbd: Take care of @GMT in SMB1's reply_ntcreate_and_X()
    
    Next we want to avoid filename_convert() to take care of this. The
    SMB2 code has a proper TWRP token anyway, so let's push the
    @GMT-handling to the SMB1 code that will be converted to
    filename_convert_dirfsp().
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 7bb8af3f74cb6a2e3a9836bb36bbad5e1d1e6a6d
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Jul 24 16:47:37 2022 +0200

    vfs_error_inject: Ignore openat() from openat_pathref_dirfsp_nosymlink()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit d6fcae23f4757d3684862c45ff43155613060ae4
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jul 14 19:44:04 2022 +0200

    smbd: Add openat_pathref_dirfsp_nosymlink()
    
    This does a step-by-step path resolution for a directory by splitting
    up the path into individual components and does a loop like that
    
    for component in components:
        fd = openat(dirfd, component, O_NOFOLLOW);
        close(dirfd);
        dirfd = fd
    
    and it will report any symlink it finds in a way that will be
    indirectly consumable for the smb2 symlink error response.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 9826da77b90a4b4d93c0d8e89ad3821c30cc8571
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jul 14 19:37:30 2022 +0200

    smbd: Make get_real_filename_at public
    
    We'll use this in files.c, which creates a bit of a cyclic
    dependency. But files.c has all the lowlevel fsp handling, and we'll
    add another routine there next which needs get_real_filename_at()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 87f03333e8b13b1a145b8332bb93f9603c170905
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jun 14 16:15:15 2022 +0200

    smbd: Some more assert in fd_openat()
    
    Before this patch we asserted that if we have a base_fsp then
    smb_fname must have a stream name attached. Now we also assert that if
    we don't have a base_fsp smb_fname is not a stream.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit f292b1ae0025af6d7432116aee3decb16a1699cf
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jun 14 17:17:54 2022 +0200

    smbd: Simplify open_stream_pathref_fsp()
    
    The main point of this function was to avoid fd_openat() and thus the
    expensive non_widelink_open(). Now that fd_openat() has the direct
    SMB_VFS_OPENAT() fast-path for streams, we can avoid duplicating the
    logic in open_stream_pathref_fsp() again.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 348f19d35b3c12ee67cc262614d41a2f165e1f7d
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Jun 13 17:31:16 2022 +0200

    smbd: open_stream_pathref_fsp() does not need a dirfsp
    
    It opens relative to fsp->base_fsp
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 52ecf98688d7ba3ce6a203791df6a21d654fd1b5
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jun 14 17:21:54 2022 +0200

    smbd: Simplify openat_pathref_fullname()
    
    Don't set O_RDONLY|O_NONBLOCK in two steps into a variable
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit afe1b94b230acba062c1f344c4a7fad26fd43d48
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jun 14 17:06:16 2022 +0200

    smbd: Open openat_pathref_fullname() for streams
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 45168bffe0247cd4db52885317870f0cb3a34330
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jun 14 17:05:09 2022 +0200

    smbd: Hand full_fname from openat_pathref_nostream()
    
    Rename it to openat_pathref_fullname(), it will be used for stream
    open next
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 37fd029e6ffc6f697af09ceab044cafe5198abd1
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jun 14 17:03:17 2022 +0200

    smbd: A stream open does not need O_NOFOLLOW
    
    Would not have hurt either, but this makes the next patch easier to
    verify properly
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 8420f62c01a2c3bf066652b3477f4c1ee08d5ae5
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Jun 13 17:50:32 2022 +0200

    smbd: Simplify openat_pathref_fsp()
    
    Remove the implicit recursion
    
    openat_pathref_fsp->openat_pathref_base_fsp->openat_pathref_fsp
    
    by introducing openat_pathref_nostream() and use
    open_stream_pathref_fsp() where possible. openat_pathref_nostream()
    will change its name in further refactoring patches, but for
    understanding this patch I think this name is good :-)
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 7295377a41c0945043bce5931cde6929a53f5909
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Jun 13 17:34:29 2022 +0200

    smbd: Simplify non_widelink_open()
    
    Now that non_widelink_open() does not see streams opens, we don't need
    to take care of fsp->base_fsp anymore.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit c267c9839eb75ee458e28d545e8941aec35b8062
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jun 14 16:33:57 2022 +0200

    VFS: NULL dirfsp for openat on stream opens
    
    The main optimization is to avoid non_widelink_open() for streams
    opens based on the fact that all streams opens are relative to
    fsp->base_fsp, which is a pathref fsp already.
    
    Neither streams_xattr nor streams_depot referenced dirfsp for the
    streams case. Make this more obvious in the callers by passing NULL
    and asserting this: non-streams opens and streams opens are just
    different things, streams-opens can and do reference a base fsp and
    don't need the non_widelink_open logic.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 0c8d55ed899f5035f1168f9d018b87806289be1e
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jun 14 16:28:25 2022 +0200

    vfs_shadow_copy2: Don't reference dirfsp for streams
    
    A stream open is always relative to fsp->base_fsp. This already holds
    the full path name in fsp->base_fsp->fsp_name, so we don't really need
    the full_path_from_dirfsp_atname(). full_path_from_dirfsp_atname() is
    not really bad, but the next patches will avoid having a dirfsp for
    stream opens overall.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit dd5e10d60130375c527ef794c9f6482bed5070db
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jun 14 16:52:39 2022 +0200

    smbd: Make fsp_attach_smb_fname() talloc_move() the name to the fsp
    
    For the current callers this does not make a difference, they have
    already allocated *_smb_fname as a talloc child of fsp, but the next
    patches will add one where it does.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit d67c7c091fec5b196df6064bd9ff115a58388234
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jun 30 10:45:54 2022 +0200

    smbd: Update fsp->fsp_flags.is_directory in vfs_stat_fsp()
    
    The type of a fsp should never change, but if this call to
    vfs_stat_fsp() is the very first one on this fsp, we must update this
    flag.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 217e7c162c2c5a7fdcef379ecf88b2123945c2b7
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Jul 2 09:43:35 2022 +0200

    libcli: Modernize a few DEBUG statements
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit d2e5c9c96bec013baa47f93d99676ed03b070639
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jul 12 09:11:41 2022 +0200

    test3: Fix a debug message
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 5c702e03f52dcfafa5ab0eb114ca8a6e7cac076f
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Jul 14 15:13:40 2022 +0200

    smbd: Factor out extract_snapshot_token() from canonicalize_snapshot_path()
    
    We'll use this elsewhere soon.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit b5c17b7936457596a013d51d6479168370b254d3
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jul 12 17:08:19 2022 +0200

    smbd: Simplify canonicalize_snapshot_path()
    
    All we need to do is to convert the @GMT-Token and move the
    rest. Before this patch we did a lot of talloc to move the @GMT token
    to the beginning of the path only to cut it off immediately
    again. Merge that logic into a simple memmove()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 53f9b32a95b66d1309ac47361cd9749c04714acb
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Jun 13 16:15:21 2022 +0200

    smbd: Don't create a fsp->base_fsp for a "::$DATA" stream
    
    "::$DATA" is the main file, we don't need the overhead of base_fsp here.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 08f4ee6cabb918b79dc9643f147bf3ef8e15fa47
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jun 28 11:58:19 2022 +0200

    torture3: Fix an error check in torture_delete_fn()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 3fc5f9f409e86bb6549f1a12d7747321ef6dd909
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 1 18:24:53 2022 +0200

    registry3: Align an integer type
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 138fdfaa40e89d50d2e556024e5b2eaeaa868dc7
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 1 18:24:31 2022 +0200

    registry3: Align function types to what is returned
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 1d02c462f019b8f73047d4db68af8ef052f620f0
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jul 5 13:48:18 2022 +0200

    lib: Simplify canonicalize_absolute_path()
    
    We don't need the separate "wrote_slash" boolean variable, we can just
    look at what we wrote into p[-1]
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit e2d30fd5b7670c58cc26610a4aeb9ef091edbd3c
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Jun 25 11:07:44 2022 +0200

    lib: Remove a few #include "includes.h"
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit b4a3c22acd5fcc0233b72ecde4afe1d916958f81
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jun 17 09:38:24 2022 +0200

    smbd: Avoid a "? True : False"
    
    Just came across this, looked weird...
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

commit 58d7b76a0acb2c6770fe8c5f702853cc518c43b0
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jul 15 15:26:33 2022 +0200

    smbd: Open up openat_internal_dir_from_pathref() for general dirs
    
    We open "." fixed here, and fd_openat (or rather SMB_VFS_OPENAT) will
    tell us if "dirfsp" does not point at a proper directory
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>

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

Summary of changes:
 lib/util/dprintf.c                        |   3 +-
 lib/util/fsusage.c                        |   3 +-
 lib/util/genrand_util.c                   |   4 +-
 lib/util/ms_fnmatch.c                     |   3 +-
 lib/util/util_id.c                        |   3 +-
 lib/util/util_paths.c                     |   2 +-
 lib/util/util_str.c                       |   3 +-
 lib/util/util_str_common.c                |   4 +-
 lib/util/util_str_escape.c                |   3 +-
 libcli/smb/reparse_symlink.c              |  45 +--
 source3/lib/util_path.c                   |  18 +-
 source3/modules/vfs_error_inject.c        |  18 +-
 source3/modules/vfs_fruit.c               |   2 +-
 source3/modules/vfs_shadow_copy2.c        |  33 +-
 source3/modules/vfs_streams_depot.c       |   1 +
 source3/modules/vfs_streams_xattr.c       |   1 +
 source3/registry/reg_api.c                |   2 +-
 source3/registry/reg_objects.c            |   4 +-
 source3/registry/reg_objects.h            |   4 +-
 source3/script/tests/test_smbclient_s3.sh |  10 +-
 source3/script/tests/test_timestamps.sh   |   2 +-
 source3/smbd/filename.c                   | 410 +++++++++++++++--------
 source3/smbd/files.c                      | 533 ++++++++++++++++++++++--------
 source3/smbd/open.c                       |  83 ++---
 source3/smbd/proto.h                      |  14 +-
 source3/smbd/smb1_nttrans.c               |   6 +-
 source3/smbd/smb2_trans2.c                |   2 +-
 source3/smbd/vfs.c                        |   1 +
 source3/torture/cmd_vfs.c                 |   2 +
 source3/torture/torture.c                 |   2 +-
 30 files changed, 825 insertions(+), 396 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/dprintf.c b/lib/util/dprintf.c
index 749fb3d5a21..9d1573f671f 100644
--- a/lib/util/dprintf.c
+++ b/lib/util/dprintf.c
@@ -31,8 +31,9 @@
   conversion
 */
 
-#include "includes.h"
+#include "replace.h"
 #include "system/locale.h"
+#include "lib/util/samba_util.h"
 
 static int d_vfprintf(FILE *f, const char *format, va_list ap)
 		      PRINTF_ATTRIBUTE(2,0);
diff --git a/lib/util/fsusage.c b/lib/util/fsusage.c
index bf07baf0296..d769b452eaa 100644
--- a/lib/util/fsusage.c
+++ b/lib/util/fsusage.c
@@ -17,7 +17,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "includes.h"
+#include "replace.h"
+#include "lib/util/samba_util.h"
 #include "system/filesys.h"
  
 /**
diff --git a/lib/util/genrand_util.c b/lib/util/genrand_util.c
index 1ef4e446e18..9aa35de3ae7 100644
--- a/lib/util/genrand_util.c
+++ b/lib/util/genrand_util.c
@@ -19,8 +19,10 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "includes.h"
+#include "replace.h"
 #include "system/locale.h"
+#include "lib/util/samba_util.h"
+#include "lib/util/debug.h"
 
 /**
  * @file
diff --git a/lib/util/ms_fnmatch.c b/lib/util/ms_fnmatch.c
index 5e05312f25a..e43d4e0a3be 100644
--- a/lib/util/ms_fnmatch.c
+++ b/lib/util/ms_fnmatch.c
@@ -28,7 +28,8 @@
  * @brief MS-style Filename matching
  */
 
-#include "includes.h"
+#include "replace.h"
+#include "lib/util/samba_util.h"
 #include "libcli/smb/smb_constants.h"
 
 static int null_match(const char *p)
diff --git a/lib/util/util_id.c b/lib/util/util_id.c
index c5bf911d484..19486f942d4 100644
--- a/lib/util/util_id.c
+++ b/lib/util/util_id.c
@@ -19,7 +19,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "includes.h"
+#include "replace.h"
+#include "lib/util/samba_util.h"
 
 /****************************************************************************
  Add a gid to an array of gids if it's not already there.
diff --git a/lib/util/util_paths.c b/lib/util/util_paths.c
index d162e0a8295..ce93028d563 100644
--- a/lib/util/util_paths.c
+++ b/lib/util/util_paths.c
@@ -22,7 +22,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "includes.h"
+#include "replace.h"
 #include "dynconfig/dynconfig.h"
 #include "lib/util/util_paths.h"
 #include "system/passwd.h"
diff --git a/lib/util/util_str.c b/lib/util/util_str.c
index 721e7cc8644..a0f95348bc1 100644
--- a/lib/util/util_str.c
+++ b/lib/util/util_str.c
@@ -21,7 +21,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "includes.h"
+#include "replace.h"
+#include "lib/util/samba_util.h"
 #include "system/locale.h"
 #include "smb_strtox.h"
 #undef strncasecmp
diff --git a/lib/util/util_str_common.c b/lib/util/util_str_common.c
index bf0fec8eca4..bf6664741ad 100644
--- a/lib/util/util_str_common.c
+++ b/lib/util/util_str_common.c
@@ -21,7 +21,9 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "includes.h"
+#include "replace.h"
+#include "system/locale.h"
+#include "lib/util/samba_util.h"
 
 /**
 Do a case-insensitive, whitespace-ignoring ASCII string compare.
diff --git a/lib/util/util_str_escape.c b/lib/util/util_str_escape.c
index 93cdd8de4a8..ea0fcc2f905 100644
--- a/lib/util/util_str_escape.c
+++ b/lib/util/util_str_escape.c
@@ -17,7 +17,8 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "includes.h"
+#include "replace.h"
+#include "lib/util/debug.h"
 #include "lib/util/util_str_escape.h"
 
 
diff --git a/libcli/smb/reparse_symlink.c b/libcli/smb/reparse_symlink.c
index c06195f324c..04f26dc1162 100644
--- a/libcli/smb/reparse_symlink.c
+++ b/libcli/smb/reparse_symlink.c
@@ -122,12 +122,13 @@ struct symlink_reparse_struct *symlink_reparse_buffer_parse(
 	bool ok;
 
 	if (srclen < 20) {
-		DEBUG(10, ("srclen = %d, expected >= 20\n", (int)srclen));
+		DBG_DEBUG("srclen = %zu, expected >= 20\n", srclen);
 		goto fail;
 	}
 	if (IVAL(src, 0) != IO_REPARSE_TAG_SYMLINK) {
-		DEBUG(10, ("Got ReparseTag %8.8x, expected %8.8x\n",
-			   IVAL(src, 0), IO_REPARSE_TAG_SYMLINK));
+		DBG_DEBUG("Got ReparseTag %8.8x, expected %8.8x\n",
+			  IVAL(src, 0),
+			  IO_REPARSE_TAG_SYMLINK);
 		goto fail;
 	}
 
@@ -138,32 +139,33 @@ struct symlink_reparse_struct *symlink_reparse_buffer_parse(
 	print_name_length	= SVAL(src, 14);
 
 	if (reparse_data_length < 12) {
-		DEBUG(10, ("reparse_data_length = %d, expected >= 12\n",
-			   (int)reparse_data_length));
+		DBG_DEBUG("reparse_data_length = %"PRIu16", expected >= 12\n",
+			  reparse_data_length);
 		goto fail;
 	}
 	if (smb_buffer_oob(srclen - 8, reparse_data_length, 0)) {
-		DEBUG(10, ("reparse_data_length (%d) too large for "
-			   "src_len (%d)\n", (int)reparse_data_length,
-			   (int)srclen));
+		DBG_DEBUG("reparse_data_length (%"PRIu16") too large for "
+			   "src_len (%zu)\n",
+			  reparse_data_length,
+			  srclen);
 		goto fail;
 	}
 	if (smb_buffer_oob(reparse_data_length - 12, substitute_name_offset,
 			   substitute_name_length)) {
-		DEBUG(10, ("substitute_name (%d/%d) does not fit in "
-			   "reparse_data_length (%d)\n",
-			   (int)substitute_name_offset,
-			   (int)substitute_name_length,
-			   (int)reparse_data_length - 12));
+		DBG_DEBUG("substitute_name (%"PRIu16"/%"PRIu16") does not fit "
+			  "in reparse_data_length (%"PRIu16")\n",
+			  substitute_name_offset,
+			  substitute_name_length,
+			  reparse_data_length - 12);
 		goto fail;
 	}
 	if (smb_buffer_oob(reparse_data_length - 12, print_name_offset,
 			   print_name_length)) {
-		DEBUG(10, ("print_name (%d/%d) does not fit in "
-			   "reparse_data_length (%d)\n",
-			   (int)print_name_offset,
-			   (int)print_name_length,
-			   (int)reparse_data_length - 12));
+		DBG_DEBUG("print_name (%"PRIu16"/%"PRIu16") does not fit in "
+			  "reparse_data_length (%"PRIu16")\n",
+			  print_name_offset,
+			  print_name_length,
+			  reparse_data_length - 12);
 		goto fail;
 	}
 
@@ -182,8 +184,8 @@ struct symlink_reparse_struct *symlink_reparse_buffer_parse(
 		&result->substitute_name,
 		NULL);
 	if (!ok) {
-		DEBUG(10, ("convert_string_talloc for substitute_name "
-			   "failed\n"));
+		DBG_DEBUG("convert_string_talloc for substitute_name "
+			  "failed\n");
 		goto fail;
 	}
 
@@ -196,8 +198,7 @@ struct symlink_reparse_struct *symlink_reparse_buffer_parse(
 		&result->print_name,
 		NULL);
 	if (!ok) {
-		DEBUG(10, ("convert_string_talloc for print_name "
-			   "failed\n"));
+		DBG_DEBUG("convert_string_talloc for print_name failed\n");
 		goto fail;
 	}
 
diff --git a/source3/lib/util_path.c b/source3/lib/util_path.c
index c34b734384c..3591589cb8e 100644
--- a/source3/lib/util_path.c
+++ b/source3/lib/util_path.c
@@ -116,7 +116,6 @@ char *canonicalize_absolute_path(TALLOC_CTX *ctx, const char *pathname_in)
 	char *pathname = talloc_array(ctx, char, strlen(pathname_in)+2);
 	const char *s = pathname_in;
 	char *p = pathname;
-	bool wrote_slash = false;
 
 	if (pathname == NULL) {
 		return NULL;
@@ -124,7 +123,6 @@ char *canonicalize_absolute_path(TALLOC_CTX *ctx, const char *pathname_in)
 
 	/* Always start with a '/'. */
 	*p++ = '/';
-	wrote_slash = true;
 
 	while (*s) {
 		/* Deal with '/' or multiples of '/'. */
@@ -134,13 +132,12 @@ char *canonicalize_absolute_path(TALLOC_CTX *ctx, const char *pathname_in)
 				s++;
 			}
 			/* Update target with one '/' */
-			if (!wrote_slash) {
+			if (p[-1] != '/') {
 				*p++ = '/';
-				wrote_slash = true;
 			}
 			continue;
 		}
-		if (wrote_slash) {
+		if (p[-1] == '/') {
 			/* Deal with "./" or ".\0" */
 			if (s[0] == '.' &&
 					(s[1] == '/' || s[1] == '\0')) {
@@ -151,7 +148,6 @@ char *canonicalize_absolute_path(TALLOC_CTX *ctx, const char *pathname_in)
 					s++;
 				}
 				/* Don't write anything to target. */
-				/* wrote_slash is still true. */
 				continue;
 			}
 			/* Deal with "../" or "..\0" */
@@ -164,9 +160,9 @@ char *canonicalize_absolute_path(TALLOC_CTX *ctx, const char *pathname_in)
 					s++;
 				}
 				/*
-				 * As wrote_slash is true, we go back
-				 * one character to point p at the slash
-				 * we just saw.
+				 * As we're on the slash, we go back
+				 * one character to point p at the
+				 * slash we just saw.
 				 */
 				if (p > pathname) {
 					p--;
@@ -188,15 +184,13 @@ char *canonicalize_absolute_path(TALLOC_CTX *ctx, const char *pathname_in)
 				p++;
 
 				/* Don't write anything to target. */
-				/* wrote_slash is still true. */
 				continue;
 			}
 		}
 		/* Non-separator character, just copy. */
 		*p++ = *s++;
-		wrote_slash = false;
 	}
-	if (wrote_slash) {
+	if (p[-1] == '/') {
 		/*
 		 * We finished on a '/'.
 		 * Remove the trailing '/', but not if it's
diff --git a/source3/modules/vfs_error_inject.c b/source3/modules/vfs_error_inject.c
index dca8783edaf..9ead2c26727 100644
--- a/source3/modules/vfs_error_inject.c
+++ b/source3/modules/vfs_error_inject.c
@@ -116,8 +116,22 @@ static int vfs_error_inject_openat(struct vfs_handle_struct *handle,
 				   mode_t mode)
 {
 	int error = inject_unix_error("openat", handle);
-
-	if (!fsp->fsp_flags.is_pathref && error != 0) {
+	int dirfsp_flags = (O_NOFOLLOW|O_DIRECTORY);
+	bool return_error;
+
+#ifdef O_PATH
+	dirfsp_flags |= O_PATH;
+#else
+#ifdef O_SEARCH
+	dirfsp_flags |= O_SEARCH;
+#endif
+#endif
+
+	return_error = (error != 0);
+	return_error &= !fsp->fsp_flags.is_pathref;
+	return_error &= ((flags & dirfsp_flags) != dirfsp_flags);
+
+	if (return_error) {
 		errno = error;
 		return -1;
 	}
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 05ab8fcea69..685c15bcaa7 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -2666,7 +2666,7 @@ static ssize_t fruit_pwrite_meta_stream(vfs_handle_struct *handle,
 		}
 
 		fd = SMB_VFS_NEXT_OPENAT(handle,
-					 fsp->conn->cwd_fsp,
+					 NULL, /* opening a stream */
 					 fsp->fsp_name,
 					 fsp,
 					 fio->flags,
diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c
index 62c6df5ce72..e8aa224648c 100644
--- a/source3/modules/vfs_shadow_copy2.c
+++ b/source3/modules/vfs_shadow_copy2.c
@@ -1510,6 +1510,34 @@ static int shadow_copy2_fstatat(
 	return 0;
 }
 
+static struct smb_filename *shadow_copy2_openat_name(
+	TALLOC_CTX *mem_ctx,
+	const struct files_struct *dirfsp,
+	const struct files_struct *fsp,
+	const struct smb_filename *smb_fname_in)
+{
+	struct smb_filename *result = NULL;
+
+	if (fsp->base_fsp != NULL) {
+		struct smb_filename *base_fname = fsp->base_fsp->fsp_name;
+
+		SMB_ASSERT(is_named_stream(smb_fname_in));
+
+		result = synthetic_smb_fname(
+			mem_ctx,
+			base_fname->base_name,
+			smb_fname_in->stream_name,
+			&smb_fname_in->st,
+			smb_fname_in->twrp,
+			smb_fname_in->flags);
+	} else {
+		result = full_path_from_dirfsp_atname(
+			mem_ctx, dirfsp, smb_fname_in);
+	}
+
+	return result;
+}
+
 static int shadow_copy2_openat(vfs_handle_struct *handle,
 			       const struct files_struct *dirfsp,
 			       const struct smb_filename *smb_fname_in,
@@ -1525,9 +1553,8 @@ static int shadow_copy2_openat(vfs_handle_struct *handle,
 	int ret;
 	bool ok;
 
-	smb_fname = full_path_from_dirfsp_atname(talloc_tos(),
-						 dirfsp,
-						 smb_fname_in);
+	smb_fname = shadow_copy2_openat_name(
+		talloc_tos(), dirfsp, fsp, smb_fname_in);
 	if (smb_fname == NULL) {
 		errno = ENOMEM;
 		return -1;
diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c
index 107543f6bbc..6722d712bff 100644
--- a/source3/modules/vfs_streams_depot.c
+++ b/source3/modules/vfs_streams_depot.c
@@ -684,6 +684,7 @@ static int streams_depot_openat(struct vfs_handle_struct *handle,
 	}
 
 	SMB_ASSERT(fsp_is_alternate_stream(fsp));
+	SMB_ASSERT(dirfsp == NULL);
 	SMB_ASSERT(VALID_STAT(fsp->base_fsp->fsp_name->st));
 
 	create_it = (mode & O_CREAT);
diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c
index 3e39770bb37..dd689261449 100644
--- a/source3/modules/vfs_streams_xattr.c
+++ b/source3/modules/vfs_streams_xattr.c
@@ -344,6 +344,7 @@ static int streams_xattr_openat(struct vfs_handle_struct *handle,
 	}
 
 	SMB_ASSERT(fsp_is_alternate_stream(fsp));
+	SMB_ASSERT(dirfsp == NULL);
 
 	status = streams_xattr_get_name(handle, talloc_tos(),
 					smb_fname->stream_name, &xattr_name);
diff --git a/source3/registry/reg_api.c b/source3/registry/reg_api.c
index 62cb0e5f846..60caa5a27c1 100644
--- a/source3/registry/reg_api.c
+++ b/source3/registry/reg_api.c
@@ -922,7 +922,7 @@ WERROR reg_getversion(uint32_t *version)
 WERROR reg_deleteallvalues(struct registry_key *key)
 {
 	WERROR err;
-	int i;
+	uint32_t i;
 
 	if (!(key->key->access_granted & KEY_SET_VALUE)) {
 		return WERR_ACCESS_DENIED;
diff --git a/source3/registry/reg_objects.c b/source3/registry/reg_objects.c
index 6ee652a482b..20556b1a174 100644
--- a/source3/registry/reg_objects.c
+++ b/source3/registry/reg_objects.c
@@ -299,7 +299,7 @@ bool regsubkey_ctr_key_exists( struct regsubkey_ctr *ctr, const char *keyname )
  How many keys does the container hold ?
  **********************************************************************/
 
-int regsubkey_ctr_numkeys( struct regsubkey_ctr *ctr )
+uint32_t regsubkey_ctr_numkeys( struct regsubkey_ctr *ctr )
 {
 	return ctr->num_subkeys;
 }
@@ -341,7 +341,7 @@ WERROR regval_ctr_init(TALLOC_CTX *mem_ctx, struct regval_ctr **ctr)
  How many keys does the container hold ?
  **********************************************************************/
 
-int regval_ctr_numvals(struct regval_ctr *ctr)
+uint32_t regval_ctr_numvals(struct regval_ctr *ctr)
 {
 	return ctr->num_values;
 }
diff --git a/source3/registry/reg_objects.h b/source3/registry/reg_objects.h
index 959fbe63183..f8a1788e444 100644
--- a/source3/registry/reg_objects.h
+++ b/source3/registry/reg_objects.h
@@ -43,10 +43,10 @@ int regsubkey_ctr_get_seqnum(struct regsubkey_ctr *ctr);
 WERROR regsubkey_ctr_addkey( struct regsubkey_ctr *ctr, const char *keyname );
 WERROR regsubkey_ctr_delkey( struct regsubkey_ctr *ctr, const char *keyname );
 bool regsubkey_ctr_key_exists( struct regsubkey_ctr *ctr, const char *keyname );
-int regsubkey_ctr_numkeys( struct regsubkey_ctr *ctr );
+uint32_t regsubkey_ctr_numkeys( struct regsubkey_ctr *ctr );
 char* regsubkey_ctr_specific_key( struct regsubkey_ctr *ctr, uint32_t key_index );
 WERROR regval_ctr_init(TALLOC_CTX *mem_ctx, struct regval_ctr **ctr);
-int regval_ctr_numvals(struct regval_ctr *ctr);
+uint32_t regval_ctr_numvals(struct regval_ctr *ctr);
 uint8_t* regval_data_p(struct regval_blob *val);
 uint32_t regval_size(struct regval_blob *val);
 char* regval_name(struct regval_blob *val);
diff --git a/source3/script/tests/test_smbclient_s3.sh b/source3/script/tests/test_smbclient_s3.sh
index bc03f432411..33737b22273 100755
--- a/source3/script/tests/test_smbclient_s3.sh
+++ b/source3/script/tests/test_smbclient_s3.sh
@@ -407,7 +407,6 @@ EOF
 test_msdfs_recursive_dir()
 {
 	tmpfile=$PREFIX/smbclient.in.$$
-	error="NT_STATUS_OBJECT_PATH_NOT_FOUND"
 
 	cat >$tmpfile <<EOF
 recurse
@@ -425,13 +424,12 @@ EOF
 		return 1
 	fi
 
-	echo "$out" | grep "$error" >/dev/null 2>&1
+	echo "$out" | grep 'NT_STATUS_OBJECT_PATH_NOT_FOUND listing \widelinks\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\dot\*' > /dev/null 2>&1
 
 	ret="$?"
-	if [ "$ret" -eq 0 ]; then
-		echo "$out"
-		echo "Listing \\msdfs-share recursively found $error"
-		return 1
+	if [ "$ret" -ne 0 ]; then
+	    echo "$out"
+	    echo "Listing \\msdfs-share recursively did not properly end in symlink recursion"
 	fi
 
 	return 0
diff --git a/source3/script/tests/test_timestamps.sh b/source3/script/tests/test_timestamps.sh
index c942ee14bcd..a158beb03d1 100755
--- a/source3/script/tests/test_timestamps.sh
+++ b/source3/script/tests/test_timestamps.sh
@@ -46,7 +46,7 @@ test_time()
 
 	$SMBCLIENT //$SERVER/tmp -U $USERNAME%$PASSWORD -c "allinfo $file"


-- 
Samba Shared Repository



More information about the samba-cvs mailing list