]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: add full_path_from_dirfsp_atname()
authorRalph Boehme <slow@samba.org>
Tue, 14 Apr 2020 15:44:37 +0000 (17:44 +0200)
committerRalph Boehme <slow@samba.org>
Wed, 16 Dec 2020 09:08:30 +0000 (09:08 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/include/proto.h
source3/smbd/filename.c

index 2ce632c54000583ccc298f7cee507c6ce49785c6..6e14ac42777bf5cbf9b47120002ba77970c37fb9 100644 (file)
@@ -788,6 +788,10 @@ struct smb_filename *synthetic_smb_fname(TALLOC_CTX *mem_ctx,
                                         const SMB_STRUCT_STAT *psbuf,
                                         NTTIME twrp,
                                         uint32_t flags);
+struct smb_filename *full_path_from_dirfsp_atname(
+       TALLOC_CTX *mem_ctx,
+       const struct files_struct *dirfsp,
+       const struct smb_filename *atname);
 struct smb_filename *synthetic_smb_fname_split(TALLOC_CTX *ctx,
                                                const char *fname,
                                                bool posix_path);
index 716e10d99147e74c9992ffbdef3ac23c5dada7d2..20e44a76204cc06cef1ca5f704a85969b716f214 100644 (file)
@@ -2034,3 +2034,41 @@ NTSTATUS filename_convert_with_privilege(TALLOC_CTX *ctx,
                                        0,
                                        pp_smb_fname);
 }
+
+/*
+ * Build the full path from a dirfsp and dirfsp relative name
+ */
+struct smb_filename *full_path_from_dirfsp_atname(
+       TALLOC_CTX *mem_ctx,
+       const struct files_struct *dirfsp,
+       const struct smb_filename *atname)
+{
+       struct smb_filename *fname = NULL;
+       char *path = NULL;
+
+       if (dirfsp == dirfsp->conn->cwd_fsp ||
+           ISDOT(dirfsp->fsp_name->base_name))
+       {
+               path = talloc_strdup(mem_ctx, atname->base_name);
+       } else {
+               path = talloc_asprintf(mem_ctx, "%s/%s",
+                                      dirfsp->fsp_name->base_name,
+                                      atname->base_name);
+       }
+       if (path == NULL) {
+               return NULL;
+       }
+
+       fname = synthetic_smb_fname(mem_ctx,
+                                   path,
+                                   atname->stream_name,
+                                   &atname->st,
+                                   atname->twrp,
+                                   atname->flags);
+       TALLOC_FREE(path);
+       if (fname == NULL) {
+               return NULL;
+       }
+
+       return fname;
+}