summaryrefslogtreecommitdiffstats
path: root/source3/smbd/nttrans.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-03-30 08:57:24 +0000
committerJeremy Allison <jra@samba.org>2001-03-30 08:57:24 +0000
commit6e7f03f9b920d1b81056959cca8c0b27ada4ee2d (patch)
treebf6426290c5aae2012dc4769158b3495cbbc031f /source3/smbd/nttrans.c
parent9874ebc3d3355465f884f3aad4d69914a4e1f0c5 (diff)
downloadsamba-6e7f03f9b920d1b81056959cca8c0b27ada4ee2d.tar.gz
samba-6e7f03f9b920d1b81056959cca8c0b27ada4ee2d.tar.xz
samba-6e7f03f9b920d1b81056959cca8c0b27ada4ee2d.zip
This is a big, rather ugly patch. Whilst investigating the files not truncated
when copying to a full disk problem, I discovered that we were not allowing the delete on close flag to be set properly, this led to other things, and after investigation of the proper delete on close semantics and their relationship to the file_share_delete flag I discovered there were some cases where we weren't doing the deny modes properly. And this after only 5 years working on them..... :-) :-). So here's the latest attempt. I realised the delete on close flag needs to be set across all smbds with a dev/ino pair open - in addition, the delete on close flag, allow share delete and delete access requested all need to be stored in the share mode tdb. The "delete_on_close" entry in the fsp struct is now redundant and should really be removed. This may also mean we can get rid of the "iterate_fsp" calls that I didn't like adding in the first place. Whilst doing this patch, I also discovered we needed to do the se_map_generic() call for file opens and POSIX ACL mapping, so I added that also. This code, although ugly, now passes the deny mode torture tests plus the delete on close tests I added. I do need to add one more multiple connection delete on close test to make sure I got the semantics exactly right, plus we should also (as Andrew suggested) move to random testing here. The good news is that NT should now correctly delete the file on disk full error when copying to a disk :-). Jeremy. (This used to be commit 51987684bd231c744da2e5f3705fd236d5616173)
Diffstat (limited to 'source3/smbd/nttrans.c')
-rw-r--r--source3/smbd/nttrans.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index 58b484f44d6..b67815ff694 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -47,6 +47,15 @@ static char *known_nt_pipes[] = {
NULL
};
+/* Map generic permissions to file object specific permissions */
+
+struct generic_mapping file_generic_mapping = {
+ FILE_GENERIC_READ,
+ FILE_GENERIC_WRITE,
+ FILE_GENERIC_EXECUTE,
+ FILE_GENERIC_ALL
+};
+
/****************************************************************************
Send the required number of replies back.
We assume all fields other than the data fields are
@@ -332,6 +341,12 @@ static int map_share_mode( BOOL *pstat_open_only, char *fname,
*pstat_open_only = False;
+ /*
+ * Convert GENERIC bits to specific bits.
+ */
+
+ se_map_generic(&desired_access, &file_generic_mapping);
+
switch( desired_access & (FILE_READ_DATA|FILE_WRITE_DATA|FILE_APPEND_DATA) ) {
case FILE_READ_DATA:
smb_open_mode = DOS_OPEN_RDONLY;
@@ -395,8 +410,22 @@ static int map_share_mode( BOOL *pstat_open_only, char *fname,
* JRA.
*/
- if(share_access & FILE_SHARE_DELETE)
+ if(share_access & FILE_SHARE_DELETE) {
smb_open_mode |= ALLOW_SHARE_DELETE;
+ DEBUG(10,("map_share_mode: FILE_SHARE_DELETE requested. open_mode = %x\n", smb_open_mode));
+ }
+
+ /*
+ * We need to store the intent to open for Delete. This
+ * is what determines if a delete on close flag can be set.
+ * This is the wrong way (and place) to store this, but for 2.2 this
+ * is the only practical way. JRA.
+ */
+
+ if(desired_access & DELETE_ACCESS) {
+ smb_open_mode |= DELETE_ACCESS_REQUESTED;
+ DEBUG(10,("map_share_mode: DELETE_ACCESS requested. open_mode = %x\n", smb_open_mode));
+ }
/* Add in the requested share mode. */
switch( share_access & (FILE_SHARE_READ|FILE_SHARE_WRITE)) {