smbd: use OpenDir() in count_dfs_links()
authorRalph Boehme <slow@samba.org>
Wed, 18 Mar 2020 11:05:06 +0000 (12:05 +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 cc32ebc9d29682eadc974e9259d389c1e0957224..274e9d0f720850101e5d30b569b3b3aaed486422 100644 (file)
@@ -1514,7 +1514,6 @@ static size_t count_dfs_links(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);
@@ -1523,6 +1522,8 @@ static size_t count_dfs_links(TALLOC_CTX *ctx,
        connection_struct *conn = NULL;
        NTSTATUS status;
        struct smb_filename *smb_fname = NULL;
+       struct smb_Dir *dir_hnd = NULL;
+       long offset = 0;
 
        if(*connect_path == '\0') {
                TALLOC_FREE(frame);
@@ -1564,13 +1565,14 @@ static size_t count_dfs_links(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 =
                        synthetic_smb_fname(frame,
                                        dname,
@@ -1591,8 +1593,6 @@ static size_t count_dfs_links(TALLOC_CTX *ctx,
                TALLOC_FREE(smb_dname);
        }
 
-       SMB_VFS_CLOSEDIR(conn,dirp);
-
 out:
        TALLOC_FREE(frame);
        return cnt;