1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-24 02:04:21 +03:00

Move checks inside file_set_sparse() to allow it to be called from anywhere.

Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Fri Dec 17 21:56:38 CET 2010 on sn-devel-104
This commit is contained in:
Jeremy Allison 2010-12-16 16:50:31 -08:00
parent fe50632d54
commit 16d6da8a9b
2 changed files with 21 additions and 19 deletions

View File

@ -20,6 +20,7 @@
#include "includes.h"
#include "librpc/gen_ndr/ndr_xattr.h"
#include "../libcli/security/security.h"
static uint32_t filter_mode_by_protocol(uint32_t mode)
{
@ -855,6 +856,25 @@ NTSTATUS file_set_sparse(connection_struct *conn,
uint32_t new_dosmode;
NTSTATUS status;
if (!CAN_WRITE(conn)) {
DEBUG(9,("file_set_sparse: fname[%s] set[%u] "
"on readonly share[%s]\n",
smb_fname_str_dbg(fsp->fsp_name),
sparse,
lp_servicename(SNUM(conn))));
return NT_STATUS_MEDIA_WRITE_PROTECTED;
}
if (!(fsp->access_mask & FILE_WRITE_DATA) &&
!(fsp->access_mask & FILE_WRITE_ATTRIBUTES)) {
DEBUG(9,("file_set_sparse: fname[%s] set[%u] "
"access_mask[0x%08X] - access denied\n",
smb_fname_str_dbg(fsp->fsp_name),
sparse,
fsp->access_mask));
return NT_STATUS_ACCESS_DENIED;
}
DEBUG(10,("file_set_sparse: setting sparse bit %u on file %s\n",
sparse, smb_fname_str_dbg(fsp->fsp_name)));
@ -888,7 +908,7 @@ NTSTATUS file_set_sparse(connection_struct *conn,
notify_fname(conn, NOTIFY_ACTION_MODIFIED,
FILE_NOTIFY_CHANGE_ATTRIBUTES,
smb_fname->base_name);
fsp->fsp_name->base_name);
return NT_STATUS_OK;
}

View File

@ -2122,24 +2122,6 @@ static void call_nt_transact_ioctl(connection_struct *conn,
return;
}
if (!CAN_WRITE(conn)) {
DEBUG(9,("FSCTL_SET_SPARSE: fname[%s] set[%u] "
"on readonly share[%s]\n",
smb_fname_str_dbg(fsp->fsp_name), set_sparse,
lp_servicename(SNUM(conn))));
reply_nterror(req, NT_STATUS_MEDIA_WRITE_PROTECTED);
return;
}
if (!(fsp->access_mask & FILE_WRITE_DATA) &&
!(fsp->access_mask & FILE_WRITE_ATTRIBUTES)) {
DEBUG(9,("FSCTL_SET_SPARSE: fname[%s] set[%u] "
"access_mask[0x%08X] - access denied\n",
smb_fname_str_dbg(fsp->fsp_name), set_sparse, fsp->access_mask));
reply_nterror(req, NT_STATUS_ACCESS_DENIED);
return;
}
status = file_set_sparse(conn, fsp, set_sparse);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(9,("FSCTL_SET_SPARSE: fname[%s] set[%u] - %s\n",