smbd: use OpenDir() in form_junctions()
authorRalph Boehme <slow@samba.org>
Wed, 18 Mar 2020 15:12:09 +0000 (16:12 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 24 Mar 2020 19:48:40 +0000 (19:48 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/msdfs.c

index 274e9d0f720850101e5d30b569b3b3aaed486422..ae2a89c3faa927d5cfbe13472601296332ba2bd5 100644 (file)
@@ -1611,7 +1611,6 @@ static int form_junctions(TALLOC_CTX *ctx,
        const struct loadparm_substitution *lp_sub =
                loadparm_s3_global_substitution();
        size_t cnt = 0;
-       DIR *dirp = NULL;
        const char *dname = NULL;
        char *talloced = NULL;
        const char *connect_path = lp_path(frame, lp_sub, snum);
@@ -1621,6 +1620,8 @@ static int form_junctions(TALLOC_CTX *ctx,
        connection_struct *conn = NULL;
        struct referral *ref = NULL;
        struct smb_filename *smb_fname = NULL;
+       struct smb_Dir *dir_hnd = NULL;
+       long offset = 0;
        NTSTATUS status;
 
        if (jn_remain == 0) {
@@ -1699,13 +1700,14 @@ static int form_junctions(TALLOC_CTX *ctx,
        }
 
        /* Now enumerate all dfs links */
-       dirp = SMB_VFS_OPENDIR(conn, smb_fname, NULL, 0);
-       if(!dirp) {
+       dir_hnd = OpenDir(frame, conn, smb_fname, NULL, 0);
+       if (dir_hnd == NULL) {
                goto out;
        }
 
-       while ((dname = vfs_readdirname(conn, dirp, NULL, &talloced))
-              != NULL) {
+        while ((dname = ReadDirName(dir_hnd, &offset, NULL, &talloced))
+              != NULL)
+       {
                struct smb_filename *smb_dname = NULL;
 
                if (cnt >= jn_remain) {
@@ -1747,11 +1749,6 @@ static int form_junctions(TALLOC_CTX *ctx,
        }
 
 out:
-
-       if (dirp) {
-               SMB_VFS_CLOSEDIR(conn,dirp);
-       }
-
        TALLOC_FREE(frame);
        return cnt;
 }