O_EXCL fixes for printing files & oplocks.
authorJeremy Allison <jra@samba.org>
Mon, 16 Nov 1998 21:38:13 +0000 (21:38 +0000)
committerJeremy Allison <jra@samba.org>
Mon, 16 Nov 1998 21:38:13 +0000 (21:38 +0000)
Jeremy.
(This used to be commit 4ca71c90985b1c88d92bdd0f9079a4afc263dc46)

source3/smbd/open.c
source3/smbd/oplock.c
source3/smbd/reply.c

index f9ddc969a8e57b7e75a8bae42569515486683f4f..c81334c8ae56ba889d6208435316cf16f1801033 100644 (file)
@@ -312,7 +312,7 @@ static void open_file(files_struct *fsp,connection_struct *conn,
   /* this handles a bug in Win95 - it doesn't say to create the file when it 
      should */
   if (conn->printer) {
-         flags |= O_CREAT;
+         flags |= (O_CREAT|O_EXCL);
   }
 
 /*
@@ -770,6 +770,9 @@ void open_file_shared(files_struct *fsp,connection_struct *conn,char *fname,int
   if (GET_FILE_OPEN_DISPOSITION(ofun) == FILE_EXISTS_TRUNCATE)
     flags2 |= O_TRUNC;
 
+  if (GET_FILE_OPEN_DISPOSITION(ofun) == FILE_EXISTS_FAIL)
+    flags2 |= O_EXCL;
+
   /* note that we ignore the append flag as 
      append does not mean the same thing under dos and unix */
 
index 89a2adb9006332b2aaaed59c9d14a49fb9b289a9..e0e1658a781613b67ac8e2d5bd62d604c8276d95 100644 (file)
@@ -1057,7 +1057,7 @@ void check_kernel_oplocks(void)
       return;
     }
 
-    if((fd = open(tmpname, O_RDWR|O_CREAT|O_TRUNC, 0600)) < 0) {
+    if((fd = open(tmpname, O_RDWR|O_CREAT|O_TRUNC|O_EXCL, 0600)) < 0) {
       DEBUG(0,("check_kernel_oplocks: Unable to open temp test file %s. Error was %s\n",
             tmpname, strerror(errno) ));
       unlink( tmpname );
index d466884ab6d04a690a9cd2eaeb457191c7f3d3cf..ee0053aed077b0e89824e81d2e9babf72cc90f10 100644 (file)
@@ -2728,7 +2728,7 @@ int reply_printopen(connection_struct *conn,
 
        /* Open for exclusive use, write only. */
        open_file_shared(fsp,conn,fname2, SET_DENY_MODE(DENY_ALL)|SET_OPEN_MODE(DOS_OPEN_WRONLY),
-                     (FILE_CREATE_IF_NOT_EXIST|FILE_EXISTS_TRUNCATE), unix_mode(conn,0), 0, NULL, NULL);
+                     (FILE_CREATE_IF_NOT_EXIST|FILE_EXISTS_FAIL), unix_mode(conn,0), 0, NULL, NULL);
 
        if (!fsp->open) {
                file_free(fsp);