The branch, v4-18-test has been updated
       via  c40f1619d96 s3/modules: Fix DFS links when widelinks = yes
       via  e949750d4f5 s3/modules: Add flag indicating if connected share is a 
dfs share
       via  5db858c1afd sefltest: Add new regression test dfs with widelinks = 
yes
       via  e50f377b4ab selftest: Add new dfs share (with widelinks enabled)
      from  ed62f4fabaf dsdb: Use samdb_system_container_dn() in 
pdb_samba_dsdb_*()

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


- Log -----------------------------------------------------------------
commit c40f1619d96c0332d3ad9d9b8e63a4fbc10f332f
Author: Noel Power <noel.po...@suse.com>
Date:   Thu Jul 27 13:26:21 2023 +0100

    s3/modules: Fix DFS links when widelinks = yes
    
    In openat(), even if we fail to open the file,
    propagate stat if and only if the object is a link in
    a DFS share. This allows calling code to further process
    the link.
    
    Also remove knownfail
    
    Pair-Programmed-With: Jeremy Alison <j...@samba.org>
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15435
    
    Signed-off-by: Noel Power <noel.po...@suse.com>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    
    Autobuild-User(master): Jeremy Allison <j...@samba.org>
    Autobuild-Date(master): Sat Jul 29 00:43:52 UTC 2023 on atb-devel-224
    
    (cherry picked from commit 0bf8b25aacdf2f5c746922320b32e3f0886c81f5)
    
    Autobuild-User(v4-18-test): Jule Anger <jan...@samba.org>
    Autobuild-Date(v4-18-test): Thu Aug  3 08:44:47 UTC 2023 on atb-devel-224

commit e949750d4f533d0c2a04ada4a02236f1b012107a
Author: Noel Power <noel.po...@suse.com>
Date:   Thu Jul 27 17:36:29 2023 +0100

    s3/modules: Add flag indicating if connected share is a dfs share
    
    Not used yet, will be used in the next commit to avoid testing
    if the connected share is a dfs one.
    
    Pair-Programmed-With: Jeremy Alison <j...@samba.org>
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15435
    
    Signed-off-by: Noel Power <noel.po...@suse.com>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit 2668dcd0968133cca4f8410bf8c41ed0483f5d87)

commit 5db858c1afde2fd0a20c81360f03f165eee2d53b
Author: Noel Power <noel.po...@suse.com>
Date:   Fri Jul 28 09:41:59 2023 +0100

    sefltest: Add new regression test dfs with widelinks = yes
    
    Adds a new test trying to cd into dfs path on share with
    widelinks enabled, should generate an error (see BUG:)
    
    Add a knownfail so CI continues
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15435
    
    Signed-off-by: Noel Power <noel.po...@suse.com>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit 3d2e9db8b95f9f45d486f8272e53584975f177fa)

commit e50f377b4ab853b11ea17778a3e5ea712548bc22
Author: Noel Power <noel.po...@suse.com>
Date:   Fri Jul 28 09:40:57 2023 +0100

    selftest: Add new dfs share (with widelinks enabled)
    
    Adds share (to be used in later test) that has dfs node
    but additionally has widelinks set to yes
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15435
    
    Signed-off-by: Noel Power <noel.po...@suse.com>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit b57cdfd7efb161cf96b3a39dc7a1652db817e602)

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

Summary of changes:
 selftest/target/Samba3.pm                          |  5 ++++
 source3/modules/vfs_widelinks.c                    | 30 +++++++++++++++++++---
 source3/script/tests/test_bug15435_widelink_dfs.sh | 28 ++++++++++++++++++++
 source3/selftest/tests.py                          | 10 ++++++++
 4 files changed, 70 insertions(+), 3 deletions(-)
 create mode 100755 source3/script/tests/test_bug15435_widelink_dfs.sh


Changeset truncated at 500 lines:

diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index d3ee7388026..fb581451801 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -3030,6 +3030,11 @@ sub provision($$)
        msdfs root = yes
        msdfs shuffle referrals = yes
        guest ok = yes
+[msdfs-share-wl]
+       path = $msdfs_shrdir
+       msdfs root = yes
+       wide links = yes
+       guest ok = yes
 [msdfs-share2]
        path = $msdfs_shrdir2
        msdfs root = yes
diff --git a/source3/modules/vfs_widelinks.c b/source3/modules/vfs_widelinks.c
index 2a35ea5eb68..c68468a950b 100644
--- a/source3/modules/vfs_widelinks.c
+++ b/source3/modules/vfs_widelinks.c
@@ -106,6 +106,7 @@
 
 struct widelinks_config {
        bool active;
+       bool is_dfs_share;
        char *cwd;
 };
 
@@ -134,7 +135,8 @@ static int widelinks_connect(struct vfs_handle_struct 
*handle,
                DBG_ERR("vfs_widelinks module loaded with "
                        "widelinks = no\n");
        }
-
+       config->is_dfs_share =
+               (lp_host_msdfs() && lp_msdfs_root(SNUM(handle->conn)));
         SMB_VFS_HANDLE_SET_DATA(handle,
                                config,
                                NULL, /* free_fn */
@@ -346,7 +348,7 @@ static int widelinks_openat(vfs_handle_struct *handle,
 {
        struct vfs_open_how how = *_how;
        struct widelinks_config *config = NULL;
-
+       int ret;
        SMB_VFS_HANDLE_GET_DATA(handle,
                                config,
                                struct widelinks_config,
@@ -363,11 +365,33 @@ static int widelinks_openat(vfs_handle_struct *handle,
                how.flags = (how.flags & ~O_NOFOLLOW);
        }
 
-       return SMB_VFS_NEXT_OPENAT(handle,
+       ret = SMB_VFS_NEXT_OPENAT(handle,
                                   dirfsp,
                                   smb_fname,
                                   fsp,
                                   &how);
+       if (config->is_dfs_share && ret == -1 && errno == ENOENT) {
+               struct smb_filename *full_fname = NULL;
+               int lstat_ret;
+
+               full_fname = full_path_from_dirfsp_atname(talloc_tos(),
+                               dirfsp,
+                               smb_fname);
+               if (full_fname == NULL) {
+                       errno = ENOMEM;
+                       return -1;
+               }
+               lstat_ret = SMB_VFS_NEXT_LSTAT(handle,
+                               full_fname);
+               if (lstat_ret != -1 &&
+                   VALID_STAT(full_fname->st) &&
+                   S_ISLNK(full_fname->st.st_ex_mode)) {
+                       fsp->fsp_name->st = full_fname->st;
+               }
+               TALLOC_FREE(full_fname);
+               errno = ENOENT;
+       }
+       return ret;
 }
 
 static struct dirent *widelinks_readdir(vfs_handle_struct *handle,
diff --git a/source3/script/tests/test_bug15435_widelink_dfs.sh 
b/source3/script/tests/test_bug15435_widelink_dfs.sh
new file mode 100755
index 00000000000..e239cd0c274
--- /dev/null
+++ b/source3/script/tests/test_bug15435_widelink_dfs.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+# regression test for dfs access with wide links enabled on dfs share
+
+if [ $# -lt 5 ]; then
+       cat <<EOF
+Usage: test_smbclient_basic.sh SERVER SERVER_IP DOMAIN USERNAME PASSWORD 
SMBCLIENT <smbclient arguments>
+EOF
+       exit 1
+fi
+
+SERVER="$1"
+SERVER_IP="$2"
+USERNAME="$3"
+PASSWORD="$4"
+smbclient="$5"
+CONFIGURATION="$6"
+shift 6
+ADDARGS="$@"
+
+incdir=$(dirname $0)/../../../testprogs/blackbox
+. $incdir/subunit.sh
+. $incdir/common_test_fns.inc
+
+# TEST
+test_smbclient "smbclient as $DOMAIN\\$USERNAME" 'ls' 
"//$SERVER/msdfs-share-wl" -U$DOMAIN\\$USERNAME%$PASSWORD $ADDARGS -c 'cd 
msdfs-src1' || failed=$(expr $failed + 1)
+
+exit $failed
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index afe408e0f64..83d72db003c 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -1673,6 +1673,16 @@ plantestsuite(
      "",
      "-b $PREFIX/clusteredmember/unclists/tmp.txt -N 5 -o 10"])
 
+plantestsuite("samba3.blackbox.smbclient-bug15435",
+              "fileserver",
+              [os.path.join(samba3srcdir, 
"script/tests/test_bug15435_widelink_dfs.sh"),
+               "$SERVER",
+               "$SERVER_IP",
+               "$USERNAME",
+               "$PASSWORD",
+               smbclient3,
+               configuration])
+
 plantestsuite(
     "samba3.net_machine_account",
     "clusteredmember",


-- 
Samba Shared Repository

Reply via email to