smbd: Remove struct open_symlink_err
[samba.git] / source3 / smbd / files.c
index e223034acc06b9ce512043b1273f7e42563a9f52..046b58023bd98045ecc3e9603b7504996159e0e3 100644 (file)
@@ -816,29 +816,6 @@ static bool full_path_extend(char **dir, const char *atname)
        return (*dir) != NULL;
 }
 
-NTSTATUS create_open_symlink_err(TALLOC_CTX *mem_ctx,
-                                files_struct *dirfsp,
-                                struct smb_filename *smb_relname,
-                                struct open_symlink_err **_err)
-{
-       struct open_symlink_err *err = NULL;
-       NTSTATUS status;
-
-       err = talloc_zero(mem_ctx, struct open_symlink_err);
-       if (err == NULL) {
-               return NT_STATUS_NO_MEMORY;
-       }
-
-       status = read_symlink_reparse(err, dirfsp, smb_relname, &err->reparse);
-       if (!NT_STATUS_IS_OK(status)) {
-               TALLOC_FREE(err);
-               return status;
-       }
-
-       *_err = err;
-       return NT_STATUS_OK;
-}
-
 /*
  * Create the memcache-key for GETREALFILENAME_CACHE: This supplements
  * the stat cache for the last component to be looked up. Cache
@@ -1017,14 +994,15 @@ lookup:
        return fd;
 }
 
-NTSTATUS openat_pathref_fsp_nosymlink(TALLOC_CTX *mem_ctx,
-                                     struct connection_struct *conn,
-                                     struct files_struct *in_dirfsp,
-                                     const char *path_in,
-                                     NTTIME twrp,
-                                     bool posix,
-                                     struct smb_filename **_smb_fname,
-                                     struct open_symlink_err **_symlink_err)
+NTSTATUS openat_pathref_fsp_nosymlink(
+       TALLOC_CTX *mem_ctx,
+       struct connection_struct *conn,
+       struct files_struct *in_dirfsp,
+       const char *path_in,
+       NTTIME twrp,
+       bool posix,
+       struct smb_filename **_smb_fname,
+       struct reparse_data_buffer **_symlink_err)
 {
        struct files_struct *dirfsp = in_dirfsp;
        struct smb_filename full_fname = {
@@ -1038,7 +1016,7 @@ NTSTATUS openat_pathref_fsp_nosymlink(TALLOC_CTX *mem_ctx,
                .flags = full_fname.flags,
        };
        struct smb_filename *result = NULL;
-       struct open_symlink_err *symlink_err = NULL;
+       struct reparse_data_buffer *symlink_err = NULL;
        struct files_struct *fsp = NULL;
        char *path = NULL, *next = NULL;
        bool ok, is_toplevel;
@@ -1234,12 +1212,12 @@ next:
                 * below.
                 */
 
-               status = create_open_symlink_err(mem_ctx,
-                                                dirfsp,
-                                                &rel_fname,
-                                                &symlink_err);
+               status = read_symlink_reparse(mem_ctx,
+                                             dirfsp,
+                                             &rel_fname,
+                                             &symlink_err);
                if (!NT_STATUS_IS_OK(status)) {
-                       DBG_DEBUG("create_open_symlink_err failed: %s\n",
+                       DBG_DEBUG("read_symlink_reparse failed: %s\n",
                                  nt_errstr(status));
                        goto fail;
                }
@@ -1301,13 +1279,13 @@ next:
                 * freadlink.
                 */
 
-               status = create_open_symlink_err(mem_ctx,
-                                                dirfsp,
-                                                NULL,
-                                                &symlink_err);
+               status = read_symlink_reparse(mem_ctx,
+                                             dirfsp,
+                                             NULL,
+                                             &symlink_err);
 
                if (!NT_STATUS_IS_OK(status)) {
-                       DBG_DEBUG("create_open_symlink_err failed: %s\n",
+                       DBG_DEBUG("read_symlink_reparse failed: %s\n",
                                  nt_errstr(status));
                        status = NT_STATUS_NOT_A_DIRECTORY;
                        goto fail;
@@ -1322,8 +1300,7 @@ next:
                        goto fail;
                }
 
-               symlink_err->reparse->parsed.lnk
-                       .unparsed_path_length = unparsed;
+               symlink_err->parsed.lnk.unparsed_path_length = unparsed;
 
                status = NT_STATUS_STOPPED_ON_SYMLINK;
                goto fail;
@@ -1401,10 +1378,10 @@ done:
                 * Last component was a symlink we opened with O_PATH, fail it
                 * here.
                 */
-               status = create_open_symlink_err(mem_ctx,
-                                                fsp,
-                                                NULL,
-                                                &symlink_err);
+               status = read_symlink_reparse(mem_ctx,
+                                             fsp,
+                                             NULL,
+                                             &symlink_err);
                if (!NT_STATUS_IS_OK(status)) {
                        return status;
                }