summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2010-12-16 16:50:31 -0800
committerJeremy Allison <jra@samba.org>2010-12-17 21:56:38 +0100
commit16d6da8a9bc87a43e4d31a7c220969bd0eaefa3e (patch)
tree68f46abab0a2b65cf417420b72c177408f2d248a /source3
parentfe50632d54b7946bf7d7ca776d41aaaf657c895a (diff)
downloadsamba-16d6da8a9bc87a43e4d31a7c220969bd0eaefa3e.tar.gz
samba-16d6da8a9bc87a43e4d31a7c220969bd0eaefa3e.tar.bz2
samba-16d6da8a9bc87a43e4d31a7c220969bd0eaefa3e.zip
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
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/dosmode.c22
-rw-r--r--source3/smbd/nttrans.c18
2 files changed, 21 insertions, 19 deletions
diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c
index 86f7807506..628f887187 100644
--- a/source3/smbd/dosmode.c
+++ b/source3/smbd/dosmode.c
@@ -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;
}
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index 55804b9035..cccb47a97f 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -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",