1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

vfs: RIP SMB_VFS_GET_DOS_ATTRIBUTES()

(\  _  /)
                ( \ O / )
                 (// \\)
                    X
                   / \
                  /___\
           _____/      \\_____
          |         +         ||
          |                   ||
          |   SMB_VFS_GET_    ||
          | DOS_ATTRIBUTES()  ||
          |                   ||
          |                   ||
          |                   ||
          |  _     ___   _    ||
          | | \     |   | \   ||
          | |  |    |   |  |  ||
          | |_/     |   |_/   ||
          | | \     |   |     ||
          | |  \    |   |     ||
          | |   \. _|_. | .   ||
          |                   ||
  *     * | *   **    * **    |**     **
   \)),.,\(/.,(//,,..,,\||(,,.,\\,.((//

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Ralph Boehme 2020-10-19 21:48:32 +02:00
parent d466ba6d61
commit 04b4dc8649
13 changed files with 1 additions and 279 deletions

View File

@ -715,13 +715,6 @@ static NTSTATUS skel_readdir_attr(struct vfs_handle_struct *handle,
return NT_STATUS_NOT_IMPLEMENTED;
}
static NTSTATUS skel_get_dos_attributes(struct vfs_handle_struct *handle,
struct smb_filename *smb_fname,
uint32_t *dosmode)
{
return NT_STATUS_NOT_IMPLEMENTED;
}
struct skel_get_dos_attributes_state {
struct vfs_aio_state aio_state;
uint32_t dosmode;
@ -1128,7 +1121,6 @@ static struct vfs_fn_pointers skel_opaque_fns = {
.audit_file_fn = skel_audit_file,
/* DOS attributes. */
.get_dos_attributes_fn = skel_get_dos_attributes,
.get_dos_attributes_send_fn = skel_get_dos_attributes_send,
.get_dos_attributes_recv_fn = skel_get_dos_attributes_recv,
.fget_dos_attributes_fn = skel_fget_dos_attributes,

View File

@ -935,15 +935,6 @@ static NTSTATUS skel_readdir_attr(struct vfs_handle_struct *handle,
return SMB_VFS_NEXT_READDIR_ATTR(handle, fname, mem_ctx, pattr_data);
}
static NTSTATUS skel_get_dos_attributes(struct vfs_handle_struct *handle,
struct smb_filename *smb_fname,
uint32_t *dosmode)
{
return SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle,
smb_fname,
dosmode);
}
struct skel_get_dos_attributes_state {
struct vfs_aio_state aio_state;
uint32_t dosmode;
@ -1435,7 +1426,6 @@ static struct vfs_fn_pointers skel_transparent_fns = {
.audit_file_fn = skel_audit_file,
/* DOS attributes. */
.get_dos_attributes_fn = skel_get_dos_attributes,
.get_dos_attributes_send_fn = skel_get_dos_attributes_send,
.get_dos_attributes_recv_fn = skel_get_dos_attributes_recv,
.fget_dos_attributes_fn = skel_fget_dos_attributes,

View File

@ -338,6 +338,7 @@
* Version 44 - Add 'have_proc_fds' flag to struct connection_struct.
* Version 44 - Add 'have_proc_fds' flag to struct files_struct.
* Version 44 - Add dirfsp arg to SMB_VFS_READDIR()
* Version 44 - Remove SMB_VFS_GET_DOS_ATTRIBUTES()
*/
#define SMB_VFS_INTERFACE_VERSION 44
@ -1149,10 +1150,6 @@ struct vfs_fn_pointers {
uint32_t max_out_len,
uint32_t *out_len);
NTSTATUS (*get_dos_attributes_fn)(struct vfs_handle_struct *handle,
struct smb_filename *smb_fname,
uint32_t *dosmode);
NTSTATUS (*fget_dos_attributes_fn)(struct vfs_handle_struct *handle,
struct files_struct *fsp,
uint32_t *dosmode);
@ -1637,9 +1634,6 @@ NTSTATUS smb_vfs_call_fsctl(struct vfs_handle_struct *handle,
uint8_t **_out_data,
uint32_t max_out_len,
uint32_t *out_len);
NTSTATUS smb_vfs_call_get_dos_attributes(struct vfs_handle_struct *handle,
struct smb_filename *smb_fname,
uint32_t *dosmode);
NTSTATUS smb_vfs_call_fget_dos_attributes(struct vfs_handle_struct *handle,
struct files_struct *fsp,
uint32_t *dosmode);
@ -2122,9 +2116,6 @@ NTSTATUS vfs_not_implemented_readdir_attr(struct vfs_handle_struct *handle,
const struct smb_filename *fname,
TALLOC_CTX *mem_ctx,
struct readdir_attr_data **pattr_data);
NTSTATUS vfs_not_implemented_get_dos_attributes(struct vfs_handle_struct *handle,
struct smb_filename *smb_fname,
uint32_t *dosmode);
struct tevent_req *vfs_not_implemented_get_dos_attributes_send(
TALLOC_CTX *mem_ctx,
struct tevent_context *ev,

View File

@ -394,10 +394,6 @@
#define SMB_VFS_NEXT_FSCTL(handle, fsp, ctx, function, req_flags, in_data, in_len, out_data, max_out_len, out_len) \
smb_vfs_call_fsctl((handle)->next, (fsp), (ctx), (function), (req_flags), (in_data), (in_len), (out_data), (max_out_len), (out_len))
#define SMB_VFS_GET_DOS_ATTRIBUTES(conn, smb_fname, attributes) \
smb_vfs_call_get_dos_attributes((conn)->vfs_handles, (smb_fname), (attributes))
#define SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle, smb_fname, attributes) \
smb_vfs_call_get_dos_attributes((handle)->next, (smb_fname), (attributes))
#define SMB_VFS_FGET_DOS_ATTRIBUTES(conn, fsp, attributes) \
smb_vfs_call_fget_dos_attributes((conn)->vfs_handles, (fsp), (attributes))
#define SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle, fsp, attributes) \

View File

@ -2300,45 +2300,6 @@ static NTSTATUS catia_readdir_attr(struct vfs_handle_struct *handle,
return status;
}
static NTSTATUS catia_get_dos_attributes(struct vfs_handle_struct *handle,
struct smb_filename *smb_fname,
uint32_t *dosmode)
{
char *mapped_name = NULL;
const char *path = smb_fname->base_name;
struct smb_filename *mapped_smb_fname = NULL;
NTSTATUS status;
status = catia_string_replace_allocate(handle->conn,
path, &mapped_name, vfs_translate_to_unix);
if (!NT_STATUS_IS_OK(status)) {
errno = map_errno_from_nt_status(status);
return status;
}
mapped_smb_fname = synthetic_smb_fname(talloc_tos(),
mapped_name,
NULL,
&smb_fname->st,
smb_fname->twrp,
smb_fname->flags);
if (mapped_smb_fname == NULL) {
TALLOC_FREE(mapped_name);
return NT_STATUS_NO_MEMORY;
}
status = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle,
mapped_smb_fname,
dosmode);
if (NT_STATUS_IS_OK(status)) {
smb_fname->st = mapped_smb_fname->st;
}
TALLOC_FREE(mapped_name);
TALLOC_FREE(mapped_smb_fname);
return status;
}
static NTSTATUS catia_set_dos_attributes(struct vfs_handle_struct *handle,
const struct smb_filename *smb_fname,
uint32_t dosmode)
@ -2502,7 +2463,6 @@ static struct vfs_fn_pointers vfs_catia_fns = {
.strict_lock_check_fn = catia_strict_lock_check,
.translate_name_fn = catia_translate_name,
.fsctl_fn = catia_fsctl,
.get_dos_attributes_fn = catia_get_dos_attributes,
.get_dos_attributes_send_fn = vfs_not_implemented_get_dos_attributes_send,
.get_dos_attributes_recv_fn = vfs_not_implemented_get_dos_attributes_recv,
.set_dos_attributes_fn = catia_set_dos_attributes,

View File

@ -1703,20 +1703,6 @@ static NTSTATUS vfswrap_fsctl(struct vfs_handle_struct *handle,
static bool vfswrap_is_offline(struct connection_struct *conn,
const struct smb_filename *fname);
static NTSTATUS vfswrap_get_dos_attributes(struct vfs_handle_struct *handle,
struct smb_filename *smb_fname,
uint32_t *dosmode)
{
bool offline;
offline = vfswrap_is_offline(handle->conn, smb_fname);
if (offline) {
*dosmode |= FILE_ATTRIBUTE_OFFLINE;
}
return get_ea_dos_attribute(handle->conn, smb_fname, dosmode);
}
struct vfswrap_get_dos_attributes_state {
struct vfs_aio_state aio_state;
connection_struct *conn;
@ -3870,7 +3856,6 @@ static struct vfs_fn_pointers vfs_default_fns = {
.fsctl_fn = vfswrap_fsctl,
.set_dos_attributes_fn = vfswrap_set_dos_attributes,
.fset_dos_attributes_fn = vfswrap_fset_dos_attributes,
.get_dos_attributes_fn = vfswrap_get_dos_attributes,
.get_dos_attributes_send_fn = vfswrap_get_dos_attributes_send,
.get_dos_attributes_recv_fn = vfswrap_get_dos_attributes_recv,
.fget_dos_attributes_fn = vfswrap_fget_dos_attributes,

View File

@ -182,7 +182,6 @@ typedef enum _vfs_op_type {
SMB_VFS_OP_SNAP_DELETE,
/* DOS attribute operations. */
SMB_VFS_OP_GET_DOS_ATTRIBUTES,
SMB_VFS_OP_GET_DOS_ATTRIBUTES_SEND,
SMB_VFS_OP_GET_DOS_ATTRIBUTES_RECV,
SMB_VFS_OP_FGET_DOS_ATTRIBUTES,
@ -324,7 +323,6 @@ static struct {
{ SMB_VFS_OP_SNAP_CHECK_PATH, "snap_check_path" },
{ SMB_VFS_OP_SNAP_CREATE, "snap_create" },
{ SMB_VFS_OP_SNAP_DELETE, "snap_delete" },
{ SMB_VFS_OP_GET_DOS_ATTRIBUTES, "get_dos_attributes" },
{ SMB_VFS_OP_GET_DOS_ATTRIBUTES_SEND, "get_dos_attributes_send" },
{ SMB_VFS_OP_GET_DOS_ATTRIBUTES_RECV, "get_dos_attributes_recv" },
{ SMB_VFS_OP_FGET_DOS_ATTRIBUTES, "fget_dos_attributes" },
@ -2224,26 +2222,6 @@ static NTSTATUS smb_full_audit_readdir_attr(struct vfs_handle_struct *handle,
return status;
}
static NTSTATUS smb_full_audit_get_dos_attributes(
struct vfs_handle_struct *handle,
struct smb_filename *smb_fname,
uint32_t *dosmode)
{
NTSTATUS status;
status = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle,
smb_fname,
dosmode);
do_log(SMB_VFS_OP_GET_DOS_ATTRIBUTES,
NT_STATUS_IS_OK(status),
handle,
"%s",
smb_fname_str_do_log(handle->conn, smb_fname));
return status;
}
struct smb_full_audit_get_dos_attributes_state {
struct vfs_aio_state aio_state;
vfs_handle_struct *handle;
@ -3051,7 +3029,6 @@ static struct vfs_fn_pointers vfs_full_audit_fns = {
.strict_lock_check_fn = smb_full_audit_strict_lock_check,
.translate_name_fn = smb_full_audit_translate_name,
.fsctl_fn = smb_full_audit_fsctl,
.get_dos_attributes_fn = smb_full_audit_get_dos_attributes,
.get_dos_attributes_send_fn = smb_full_audit_get_dos_attributes_send,
.get_dos_attributes_recv_fn = smb_full_audit_get_dos_attributes_recv,
.fget_dos_attributes_fn = smb_full_audit_fget_dos_attributes,

View File

@ -1621,49 +1621,6 @@ static unsigned int vfs_gpfs_dosmode_to_winattrs(uint32_t dosmode)
return winattrs;
}
static int get_dos_attr_with_capability(struct smb_filename *smb_fname,
unsigned int *litemask,
struct gpfs_iattr64 *iattr)
{
int saved_errno = 0;
int ret;
/*
* According to MS-FSA 2.1.5.1.2.1 "Algorithm to Check Access to an
* Existing File" FILE_LIST_DIRECTORY on a directory implies
* FILE_READ_ATTRIBUTES for directory entries. Being able to stat() a
* file implies FILE_LIST_DIRECTORY for the directory containing the
* file.
*/
if (!VALID_STAT(smb_fname->st)) {
/*
* Safety net: dos_mode() already checks this, but as we set
* DAC_OVERRIDE_CAPABILITY based on this, add an additional
* layer of defense.
*/
DBG_ERR("Rejecting DAC override, invalid stat [%s]\n",
smb_fname_str_dbg(smb_fname));
errno = EACCES;
return -1;
}
set_effective_capability(DAC_OVERRIDE_CAPABILITY);
ret = gpfswrap_stat_x(smb_fname->base_name, litemask,
iattr, sizeof(*iattr));
if (ret == -1) {
saved_errno = errno;
}
drop_effective_capability(DAC_OVERRIDE_CAPABILITY);
if (saved_errno != 0) {
errno = saved_errno;
}
return ret;
}
static NTSTATUS vfs_gpfs_get_file_id(struct gpfs_iattr64 *iattr,
uint64_t *fileid)
{
@ -1703,66 +1660,6 @@ static struct timespec gpfs_timestruc64_to_timespec(struct gpfs_timestruc64 g)
return (struct timespec) { .tv_sec = g.tv_sec, .tv_nsec = g.tv_nsec };
}
static NTSTATUS vfs_gpfs_get_dos_attributes(struct vfs_handle_struct *handle,
struct smb_filename *smb_fname,
uint32_t *dosmode)
{
struct gpfs_config_data *config;
struct gpfs_iattr64 iattr = { };
unsigned int litemask = 0;
struct timespec ts;
uint64_t file_id;
NTSTATUS status;
int ret;
SMB_VFS_HANDLE_GET_DATA(handle, config,
struct gpfs_config_data,
return NT_STATUS_INTERNAL_ERROR);
if (!config->winattr) {
return SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle,
smb_fname, dosmode);
}
ret = gpfswrap_stat_x(smb_fname->base_name, &litemask,
&iattr, sizeof(iattr));
if (ret == -1 && errno == ENOSYS) {
return SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle, smb_fname,
dosmode);
}
if (ret == -1 && errno == EACCES) {
ret = get_dos_attr_with_capability(smb_fname, &litemask,
&iattr);
}
if (ret == -1 && errno == EBADF) {
/*
* Returned for directory listings in gpfs root for
* .. entry which steps out of gpfs.
*/
DBG_DEBUG("Getting winattrs for %s returned EBADF.\n",
smb_fname->base_name);
return map_nt_error_from_unix(errno);
} else if (ret == -1) {
DBG_WARNING("Getting winattrs failed for %s: %s\n",
smb_fname->base_name, strerror(errno));
return map_nt_error_from_unix(errno);
}
status = vfs_gpfs_get_file_id(&iattr, &file_id);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
ts = gpfs_timestruc64_to_timespec(iattr.ia_createtime);
*dosmode |= vfs_gpfs_winattrs_to_dosmode(iattr.ia_winflags);
update_stat_ex_create_time(&smb_fname->st, ts);
update_stat_ex_file_id(&smb_fname->st, file_id);
return NT_STATUS_OK;
}
static NTSTATUS vfs_gpfs_fget_dos_attributes(struct vfs_handle_struct *handle,
struct files_struct *fsp,
uint32_t *dosmode)
@ -2735,7 +2632,6 @@ static struct vfs_fn_pointers vfs_gpfs_fns = {
.kernel_flock_fn = vfs_gpfs_kernel_flock,
.linux_setlease_fn = vfs_gpfs_setlease,
.get_real_filename_fn = vfs_gpfs_get_real_filename,
.get_dos_attributes_fn = vfs_gpfs_get_dos_attributes,
.get_dos_attributes_send_fn = vfs_not_implemented_get_dos_attributes_send,
.get_dos_attributes_recv_fn = vfs_not_implemented_get_dos_attributes_recv,
.fget_dos_attributes_fn = vfs_gpfs_fget_dos_attributes,

View File

@ -718,13 +718,6 @@ NTSTATUS vfs_not_implemented_readdir_attr(struct vfs_handle_struct *handle,
return NT_STATUS_NOT_IMPLEMENTED;
}
NTSTATUS vfs_not_implemented_get_dos_attributes(struct vfs_handle_struct *handle,
struct smb_filename *smb_fname,
uint32_t *dosmode)
{
return NT_STATUS_NOT_IMPLEMENTED;
}
struct vfs_not_implemented_get_dos_attributes_state {
struct vfs_aio_state aio_state;
uint32_t dosmode;
@ -1132,7 +1125,6 @@ static struct vfs_fn_pointers vfs_not_implemented_fns = {
.audit_file_fn = vfs_not_implemented_audit_file,
/* DOS attributes. */
.get_dos_attributes_fn = vfs_not_implemented_get_dos_attributes,
.get_dos_attributes_send_fn = vfs_not_implemented_get_dos_attributes_send,
.get_dos_attributes_recv_fn = vfs_not_implemented_get_dos_attributes_recv,
.fget_dos_attributes_fn = vfs_not_implemented_fget_dos_attributes,

View File

@ -27,14 +27,6 @@ static uint32_t offline_fs_capabilities(struct vfs_handle_struct *handle,
FILE_SUPPORTS_REMOTE_STORAGE;
}
static NTSTATUS offline_get_dos_attributes(struct vfs_handle_struct *handle,
struct smb_filename *smb_fname,
uint32_t *dosmode)
{
*dosmode |= FILE_ATTRIBUTE_OFFLINE;
return SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle, smb_fname, dosmode);
}
static NTSTATUS offline_fget_dos_attributes(struct vfs_handle_struct *handle,
struct files_struct *fsp,
uint32_t *dosmode)
@ -45,7 +37,6 @@ static NTSTATUS offline_fget_dos_attributes(struct vfs_handle_struct *handle,
static struct vfs_fn_pointers offline_fns = {
.fs_capabilities_fn = offline_fs_capabilities,
.get_dos_attributes_fn = offline_get_dos_attributes,
.get_dos_attributes_send_fn = vfs_not_implemented_get_dos_attributes_send,
.get_dos_attributes_recv_fn = vfs_not_implemented_get_dos_attributes_recv,
.fget_dos_attributes_fn = offline_fget_dos_attributes,

View File

@ -1786,30 +1786,6 @@ static NTSTATUS smb_time_audit_fsctl(struct vfs_handle_struct *handle,
return result;
}
static NTSTATUS smb_time_get_dos_attributes(struct vfs_handle_struct *handle,
struct smb_filename *smb_fname,
uint32_t *dosmode)
{
NTSTATUS result;
struct timespec ts1,ts2;
double timediff;
clock_gettime_mono(&ts1);
result = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle,
smb_fname,
dosmode);
clock_gettime_mono(&ts2);
timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
if (timediff > audit_timeout) {
smb_time_audit_log_fname("get_dos_attributes",
timediff,
smb_fname->base_name);
}
return result;
}
struct smb_time_audit_get_dos_attributes_state {
struct vfs_aio_state aio_state;
files_struct *dir_fsp;
@ -2921,7 +2897,6 @@ static struct vfs_fn_pointers vfs_time_audit_fns = {
.strict_lock_check_fn = smb_time_audit_strict_lock_check,
.translate_name_fn = smb_time_audit_translate_name,
.fsctl_fn = smb_time_audit_fsctl,
.get_dos_attributes_fn = smb_time_get_dos_attributes,
.get_dos_attributes_send_fn = smb_time_audit_get_dos_attributes_send,
.get_dos_attributes_recv_fn = smb_time_audit_get_dos_attributes_recv,
.fget_dos_attributes_fn = smb_time_fget_dos_attributes,

View File

@ -268,20 +268,6 @@ done:
return offline;
}
static NTSTATUS tsmsm_get_dos_attributes(struct vfs_handle_struct *handle,
struct smb_filename *fname,
uint32_t *dosmode)
{
bool offline;
offline = tsmsm_is_offline(handle, fname, &fname->st);
if (offline) {
*dosmode |= FILE_ATTRIBUTE_OFFLINE;
}
return SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle, fname, dosmode);
}
static NTSTATUS tsmsm_fget_dos_attributes(struct vfs_handle_struct *handle,
files_struct *fsp,
uint32_t *dosmode)
@ -606,7 +592,6 @@ static struct vfs_fn_pointers tsmsm_fns = {
.sendfile_fn = tsmsm_sendfile,
.set_dos_attributes_fn = tsmsm_set_dos_attributes,
.fset_dos_attributes_fn = tsmsm_fset_dos_attributes,
.get_dos_attributes_fn = tsmsm_get_dos_attributes,
.get_dos_attributes_send_fn = vfs_not_implemented_get_dos_attributes_send,
.get_dos_attributes_recv_fn = vfs_not_implemented_get_dos_attributes_recv,
.fget_dos_attributes_fn = tsmsm_fget_dos_attributes,

View File

@ -2450,14 +2450,6 @@ NTSTATUS smb_vfs_call_fsctl(struct vfs_handle_struct *handle,
out_len);
}
NTSTATUS smb_vfs_call_get_dos_attributes(struct vfs_handle_struct *handle,
struct smb_filename *smb_fname,
uint32_t *dosmode)
{
VFS_FIND(get_dos_attributes);
return handle->fns->get_dos_attributes_fn(handle, smb_fname, dosmode);
}
NTSTATUS smb_vfs_call_fget_dos_attributes(struct vfs_handle_struct *handle,
struct files_struct *fsp,
uint32_t *dosmode)