summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2003-02-12 01:12:33 +0000
committerJeremy Allison <jra@samba.org>2003-02-12 01:12:33 +0000
commitb792454963e7abe478196e17035ae2e7bc1341bc (patch)
treed0e692add85d3119b7c92d238c04c24775f9e41e /source3
parent0e42cf24608c78d0285fa7cf70f252f9f0703668 (diff)
downloadsamba-b792454963e7abe478196e17035ae2e7bc1341bc.tar.gz
samba-b792454963e7abe478196e17035ae2e7bc1341bc.tar.bz2
samba-b792454963e7abe478196e17035ae2e7bc1341bc.zip
Correctly return access denied on share mode deny when we can't open the
file. This is a regression that was damaged by other code. Jeremy. (This used to be commit 5cdc957ea6335d8bb4248065a3b60a0a26e766a8)
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/open.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 6570745816..6b3dcbe71b 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -79,6 +79,7 @@ static void check_for_pipe(char *fname)
DEBUG(3,("Rejecting named pipe open for %s\n",fname));
unix_ERR_class = ERRSRV;
unix_ERR_code = ERRaccess;
+ unix_ERR_ntstatus = NT_STATUS_ACCESS_DENIED;
}
}
@@ -255,6 +256,7 @@ static int truncate_unless_locked(struct connection_struct *conn, files_struct *
errno = EACCES;
unix_ERR_class = ERRDOS;
unix_ERR_code = ERRlock;
+ unix_ERR_ntstatus = dos_to_ntstatus(ERRDOS, ERRlock);
return -1;
} else {
return conn->vfs_ops.ftruncate(fsp,fsp->fd,0);
@@ -399,9 +401,10 @@ static BOOL check_share_mode(connection_struct *conn, share_mode_entry *share, i
if (GET_DELETE_ON_CLOSE_FLAG(share->share_mode)) {
DEBUG(5,("check_share_mode: Failing open on file %s as delete on close flag is set.\n",
fname ));
- unix_ERR_class = ERRDOS;
- unix_ERR_code = ERRnoaccess;
- unix_ERR_ntstatus = NT_STATUS_DELETE_PENDING;
+ /* Use errno to map to correct error. */
+ unix_ERR_class = SMB_SUCCESS;
+ unix_ERR_code = 0;
+ unix_ERR_ntstatus = NT_STATUS_OK;
return False;
}
@@ -444,6 +447,7 @@ static BOOL check_share_mode(connection_struct *conn, share_mode_entry *share, i
fname ));
unix_ERR_class = ERRDOS;
unix_ERR_code = ERRbadshare;
+ unix_ERR_ntstatus = NT_STATUS_SHARING_VIOLATION;
return False;
}
@@ -464,6 +468,7 @@ and existing desired access (0x%x) are non-data opens\n",
fname ));
unix_ERR_class = ERRDOS;
unix_ERR_code = ERRbadshare;
+ unix_ERR_ntstatus = NT_STATUS_SHARING_VIOLATION;
return False;
}
@@ -479,6 +484,7 @@ and existing desired access (0x%x) are non-data opens\n",
fname ));
unix_ERR_class = ERRDOS;
unix_ERR_code = ERRbadshare;
+ unix_ERR_ntstatus = NT_STATUS_SHARING_VIOLATION;
return False;
}
@@ -510,6 +516,7 @@ existing desired access (0x%x).\n", fname, (unsigned int)desired_access, (unsign
unix_ERR_class = ERRDOS;
unix_ERR_code = ERRbadshare;
+ unix_ERR_ntstatus = NT_STATUS_SHARING_VIOLATION;
return False;
}
@@ -596,6 +603,7 @@ dev = %x, inode = %.0f\n", old_shares[i].op_type, fname, (unsigned int)dev, (dou
errno = EACCES;
unix_ERR_class = ERRDOS;
unix_ERR_code = ERRbadshare;
+ unix_ERR_ntstatus = NT_STATUS_SHARING_VIOLATION;
return -1;
}
@@ -646,6 +654,7 @@ dev = %x, inode = %.0f. Deleting it to continue...\n", (int)broken_entry.pid, fn
errno = EACCES;
unix_ERR_class = ERRDOS;
unix_ERR_code = ERRbadshare;
+ unix_ERR_ntstatus = NT_STATUS_SHARING_VIOLATION;
return -1;
}
@@ -922,6 +931,7 @@ files_struct *open_file_shared1(connection_struct *conn,char *fname, SMB_STRUCT_
* we can do. We also ensure we're not going to create or tuncate
* the file as we only want an access decision at this stage. JRA.
*/
+ errno = 0;
fsp_open = open_file(fsp,conn,fname,psbuf,
flags|(flags2&~(O_TRUNC|O_CREAT)),mode,desired_access);
@@ -929,6 +939,12 @@ files_struct *open_file_shared1(connection_struct *conn,char *fname, SMB_STRUCT_
flags=0x%X flags2=0x%X mode=0%o returned %d\n",
flags,(flags2&~(O_TRUNC|O_CREAT)),(int)mode,(int)fsp_open ));
+ if (!fsp_open && errno) {
+ unix_ERR_class = ERRDOS;
+ unix_ERR_code = ERRnoaccess;
+ unix_ERR_ntstatus = NT_STATUS_ACCESS_DENIED;
+ }
+
unlock_share_entry(conn, dev, inode);
if (fsp_open)
fd_close(conn, fsp);