summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-04-22 00:33:16 +0000
committerJeremy Allison <jra@samba.org>2000-04-22 00:33:16 +0000
commit6259f51dd9918eccc9697f3763d918f7c9b82b50 (patch)
tree1bbfa0d6eb5767f713b290743dd9fa9fb9f62ce9 /source3/printing
parentb7a1d19d114288ac3292a26d2d42825e26884d36 (diff)
downloadsamba-6259f51dd9918eccc9697f3763d918f7c9b82b50.tar.gz
samba-6259f51dd9918eccc9697f3763d918f7c9b82b50.tar.bz2
samba-6259f51dd9918eccc9697f3763d918f7c9b82b50.zip
This is a *big* checkin that may break some things, but implements the
new open mechanism Andrew & I discussed. config.sub: configure: Included the QNX patch. include/vfs.h: smbd/vfs-wrap.c: smbd/vfs.c: Added ftruncate vfs call (needed). Note that we will also need locking calls in the vfs (to be added). lib/util_unistr.c: nmbd/nmbd_processlogon.c: Fix for NT domain logons causing nmbd to core dump. Also fix for sidsize DOS bug. locking/locking.c: Check value of ret before using it for memdup. printing/printing.c: Convert print_fsp_open to return an allocated fsp. rpc_server/srv_lsa.c: Fix for NT domain logons. I have removed all use of lp_share_modes() from the code (although I left the parameter in the table for backwards compatibility). It no longer makes sense for this to exist. smbd/close.c: Removed lp_share_modes(). smbd/fileio.c: Fixed parameters to unlock_share_entry call in panic code. smbd/files.c: Correctly set the unix_ERR_code to ERRnofids on fsp allocation fail. smbd/nttrans.c: smbd/reply.c: smbd/trans2.c: Changed all occurrences of open_file_shared/open_directory/ open_file_stat to return an fsp from the call. smbd/open.c: Changed all occurrences of open_file_shared/open_directory/ open_file_stat to return an fsp from the call. In addition I have fixed a long standing race condition in the deny mode processing w.r.t. two smbd's creating a file. Andrew, please note that your original idea of using open with O_EXCL in this case would not work (I went over the races very carefully) and so we must re-check deny modes *after* the open() call returns. This is because there is a race between the open with O_EXCL and the lock of the share mode entry. Imagine the case where the first smbd does the open with O_EXCL and a deny mode of DENY_ALL, but is pre-empted before it locks the share modes and creates the deny mode entry for DENY_ALL. A second smbd could then come in with O_RDONLY and a deny mode of DENY_NONE and the two opens would be allowed. The *only* way to fix this race is to lock the share modes after the open and then do the deny mode checks *after* this lock in the case where the file did not originally exist. This code will need extensive testing but seems to initially work. Jeremy. (This used to be commit ab0ecc39d688f16b9692fe90b991f0b89287070a)
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/printing.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 3202c6937d..58f284b4fc 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -856,20 +856,27 @@ BOOL print_queue_purge(int snum)
open a print file and setup a fsp for it. This is a wrapper around
print_job_start().
***************************************************************************/
-void print_fsp_open(files_struct *fsp,connection_struct *conn,char *jobname)
+
+files_struct *print_fsp_open(connection_struct *conn,char *jobname)
{
int jobid;
SMB_STRUCT_STAT sbuf;
extern struct current_user current_user;
+ files_struct *fsp = file_new();
+
+ if(!fsp)
+ return NULL;
jobid = print_job_start(SNUM(conn), jobname);
- if (jobid == -1) return;
+ if (jobid == -1) {
+ file_free(fsp);
+ return NULL;
+ }
/* setup a full fsp */
fsp->print_jobid = jobid;
fsp->fd = print_job_fd(jobid);
conn->vfs_ops.fstat(fsp->fd, &sbuf);
- conn->num_files_open++;
fsp->mode = sbuf.st_mode;
fsp->inode = sbuf.st_ino;
fsp->dev = sbuf.st_dev;
@@ -893,6 +900,10 @@ void print_fsp_open(files_struct *fsp,connection_struct *conn,char *jobname)
string_set(&fsp->fsp_name,print_job_fname(jobid));
fsp->wbmpx_ptr = NULL;
fsp->wcp = NULL;
+
+ conn->num_files_open++;
+
+ return fsp;
}
/****************************************************************************