From: Ralph Boehme Date: Wed, 20 May 2020 15:01:48 +0000 (+0200) Subject: s3/vfs: add vfs_at_fspcwd() X-Git-Tag: ldb-2.2.0~408 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=19a1ed2cacf691cdf003f44cbe80a772e871254c;p=thirdparty%2Fsamba.git s3/vfs: add vfs_at_fspcwd() Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/include/proto.h b/source3/include/proto.h index 0e96fcccc65..12aa392abae 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -80,6 +80,10 @@ int map_errno_from_nt_status(NTSTATUS status); struct file_id vfs_file_id_from_sbuf(connection_struct *conn, const SMB_STRUCT_STAT *sbuf); +NTSTATUS vfs_at_fspcwd(TALLOC_CTX *mem_ctx, + struct connection_struct *conn, + struct files_struct **_fsp); + /* The following definitions come from lib/interface.c */ bool ismyaddr(const struct sockaddr *ip); diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index dbb2c05493b..454f88e5652 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -1555,6 +1555,37 @@ struct file_id vfs_file_id_from_sbuf(connection_struct *conn, const SMB_STRUCT_S return SMB_VFS_FILE_ID_CREATE(conn, sbuf); } +NTSTATUS vfs_at_fspcwd(TALLOC_CTX *mem_ctx, + struct connection_struct *conn, + struct files_struct **_fsp) +{ + struct files_struct *fsp = NULL; + + fsp = talloc_zero(mem_ctx, struct files_struct); + if (fsp == NULL) { + return NT_STATUS_NO_MEMORY; + } + + fsp->fsp_name = synthetic_smb_fname(fsp, ".", NULL, NULL, 0, 0); + if (fsp->fsp_name == NULL) { + TALLOC_FREE(fsp); + return NT_STATUS_NO_MEMORY; + } + + fsp->fh = talloc_zero(fsp, struct fd_handle); + if (fsp->fh == NULL) { + TALLOC_FREE(fsp); + return NT_STATUS_NO_MEMORY; + } + + fsp->fh->fd = AT_FDCWD; + fsp->fnum = FNUM_FIELD_INVALID; + fsp->conn = conn; + + *_fsp = fsp; + return NT_STATUS_OK; +} + int smb_vfs_call_connect(struct vfs_handle_struct *handle, const char *service, const char *user) {