svn commit: samba r8090 - in trunk/source/smbd: .
jra at samba.org
jra at samba.org
Sun Jul 3 06:30:28 GMT 2005
Author: jra
Date: 2005-07-03 06:30:27 +0000 (Sun, 03 Jul 2005)
New Revision: 8090
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=8090
Log:
We now pass Samba4 BASE-DENY1 test. We won't pass the DENY-DOS
tests until I re-factor out the open file fd into a manner
strangely remenicent of the way I did it in Samba 1.9.x...
The more things change, the more they stay the same :-).
Jeremy.
Modified:
trunk/source/smbd/files.c
trunk/source/smbd/open.c
Changeset:
Modified: trunk/source/smbd/files.c
===================================================================
--- trunk/source/smbd/files.c 2005-07-03 02:05:01 UTC (rev 8089)
+++ trunk/source/smbd/files.c 2005-07-03 06:30:27 UTC (rev 8090)
@@ -506,3 +506,50 @@
{
chain_fsp = oplock_save_chain_fsp;
}
+
+files_struct *dup_file_fsp(files_struct *fsp,
+ uint32 access_mask,
+ uint32 share_access,
+ uint32 create_options)
+{
+ files_struct *dup_fsp = file_new(fsp->conn);
+
+ if (!dup_fsp) {
+ return NULL;
+ }
+
+ dup_fsp->fd = fsp->fd;
+ dup_fsp->dev = fsp->dev;
+ dup_fsp->inode = fsp->inode;
+ dup_fsp->delete_on_close = fsp->delete_on_close;
+ dup_fsp->pos = fsp->pos;
+ dup_fsp->initial_allocation_size = fsp->initial_allocation_size;
+ dup_fsp->position_information = fsp->position_information;
+ dup_fsp->mode = fsp->mode;
+ dup_fsp->file_pid = fsp->file_pid;
+ dup_fsp->vuid = fsp->vuid;
+ dup_fsp->open_time = fsp->open_time;
+ dup_fsp->access_mask = access_mask;
+ dup_fsp->share_access = share_access;
+ dup_fsp->create_options = create_options;
+ dup_fsp->pending_modtime_owner = fsp->pending_modtime_owner;
+ dup_fsp->pending_modtime = fsp->pending_modtime;
+ dup_fsp->last_write_time = fsp->last_write_time;
+ dup_fsp->oplock_type = fsp->oplock_type;
+ dup_fsp->can_lock = fsp->can_lock;
+ dup_fsp->can_read = (access_mask & (FILE_READ_DATA)) ? True : False;
+ if (!CAN_WRITE(fsp->conn)) {
+ dup_fsp->can_write = False;
+ } else {
+ dup_fsp->can_write = (access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) ? True : False;
+ }
+ dup_fsp->print_file = fsp->print_file;
+ dup_fsp->modified = fsp->modified;
+ dup_fsp->is_directory = fsp->is_directory;
+ dup_fsp->is_stat = fsp->is_stat;
+ dup_fsp->directory_delete_on_close = fsp->directory_delete_on_close;
+ dup_fsp->aio_write_behind = fsp->aio_write_behind;
+ string_set(&dup_fsp->fsp_name,fsp->fsp_name);
+
+ return dup_fsp;
+}
Modified: trunk/source/smbd/open.c
===================================================================
--- trunk/source/smbd/open.c 2005-07-03 02:05:01 UTC (rev 8089)
+++ trunk/source/smbd/open.c 2005-07-03 06:30:27 UTC (rev 8090)
@@ -322,8 +322,12 @@
fsp->vuid = current_user.vuid;
fsp->file_pid = global_smbpid;
fsp->can_lock = True;
- fsp->can_read = ((flags & O_WRONLY)==0);
- fsp->can_write = ((flags & (O_WRONLY|O_RDWR))!=0);
+ fsp->can_read = (access_mask & (FILE_READ_DATA)) ? True : False;
+ if (!CAN_WRITE(conn)) {
+ fsp->can_write = False;
+ } else {
+ fsp->can_write = (access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) ? True : False;
+ }
fsp->print_file = False;
fsp->modified = False;
fsp->oplock_type = NO_OPLOCK;
@@ -894,10 +898,13 @@
Try and find a duplicated file handle.
****************************************************************************/
-static files_struct *fcb_or_dos_open(connection_struct *conn, const char *fname,
- SMB_DEV_T dev, SMB_INO_T inode)
+static files_struct *fcb_or_dos_open(connection_struct *conn, const char *fname, SMB_DEV_T dev, SMB_INO_T inode,
+ uint32 access_mask,
+ uint32 share_access,
+ uint32 create_options)
{
files_struct *fsp;
+ files_struct *dup_fsp;
DEBUG(5,("fcb_or_dos_open: attempting old open semantics for file %s.\n", fname ));
@@ -929,7 +936,13 @@
return NULL;
}
- return fsp;
+ /* We need to duplicate this fsp. */
+ dup_fsp = dup_file_fsp(fsp, access_mask, share_access, create_options);
+ if (!dup_fsp) {
+ return NULL;
+ }
+
+ return dup_fsp;
}
/****************************************************************************
@@ -1294,11 +1307,7 @@
*/
if (access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) {
- if ((access_mask & (FILE_READ_DATA|FILE_EXECUTE)) == 0) {
- flags = O_WRONLY;
- } else {
- flags = O_RDWR;
- }
+ flags = O_RDWR;
} else {
flags = O_RDONLY;
}
@@ -1354,6 +1363,31 @@
&all_current_opens_are_level_II);
if(num_share_modes == -1) {
+ if (!internal_only_open) {
+ NTSTATUS status;
+ get_saved_error_triple(NULL, NULL, &status);
+ if (NT_STATUS_EQUAL(status,NT_STATUS_SHARING_VIOLATION)) {
+ /* Check if this can be done with the deny_dos and fcb calls. */
+ if (create_options & (NTCREATEX_OPTIONS_PRIVATE_DENY_DOS|
+ NTCREATEX_OPTIONS_PRIVATE_DENY_FCB)) {
+ files_struct *fsp_dup = fcb_or_dos_open(conn, fname, dev, inode,
+ access_mask,
+ share_access,
+ create_options);
+
+ if (fsp_dup) {
+ unlock_share_entry(conn, dev, inode);
+ file_free(fsp);
+ if (pinfo) {
+ *pinfo = FILE_WAS_OPENED;
+ }
+ conn->num_files_open++;
+ return fsp_dup;
+ }
+ }
+ }
+ }
+
/*
* This next line is a subtlety we need for MS-Access. If a file open will
* fail due to share permissions and also for security (access)
@@ -1390,20 +1424,6 @@
NTSTATUS status;
get_saved_error_triple(NULL, NULL, &status);
if (NT_STATUS_EQUAL(status,NT_STATUS_SHARING_VIOLATION)) {
- /* Check if this can be done with the deny_dos and fcb calls. */
- if (create_options & (NTCREATEX_OPTIONS_PRIVATE_DENY_DOS|
- NTCREATEX_OPTIONS_PRIVATE_DENY_FCB)) {
- files_struct *fsp_dup = fcb_or_dos_open(conn, fname, dev, inode);
- if (fsp_dup) {
- unlock_share_entry(conn, dev, inode);
- if (fsp_open) {
- fd_close(conn, fsp);
- }
- file_free(fsp);
- return fsp_dup;
- }
- }
-
/* The fsp->open_time here represents
* the current time of day. */
defer_open_sharing_error(conn,
@@ -1491,26 +1511,33 @@
&all_current_opens_are_level_II);
if(num_share_modes == -1) {
- /*
- * If we're returning a share violation, ensure we cope with
- * the braindead 1 second delay.
- */
-
NTSTATUS status;
get_saved_error_triple(NULL, NULL, &status);
if (NT_STATUS_EQUAL(status,NT_STATUS_SHARING_VIOLATION)) {
/* Check if this can be done with the deny_dos and fcb calls. */
if (create_options & (NTCREATEX_OPTIONS_PRIVATE_DENY_DOS|
NTCREATEX_OPTIONS_PRIVATE_DENY_FCB)) {
- files_struct *fsp_dup = fcb_or_dos_open(conn, fname, dev, inode);
+ files_struct *fsp_dup = fcb_or_dos_open(conn, fname, dev, inode,
+ access_mask,
+ share_access,
+ create_options);
if (fsp_dup) {
unlock_share_entry(conn, dev, inode);
fd_close(conn, fsp);
file_free(fsp);
+ if (pinfo) {
+ *pinfo = FILE_WAS_OPENED;
+ }
+ conn->num_files_open++;
return fsp_dup;
}
}
+ /*
+ * If we're returning a share violation, ensure we cope with
+ * the braindead 1 second delay.
+ */
+
/* The fsp->open_time here represents the current time of day. */
defer_open_sharing_error(conn, &fsp->open_time, fname, dev, inode);
}
More information about the samba-cvs
mailing list