s3:auth Remove NT_USER_TOKEN
[abartlet/samba.git/.git] / source3 / smbd / open.c
index e0fcfb967963f6ad418239c208a46a25d117d32c..e9f0e6cd4f68415bed28f4ec32e4de4ad338c836 100644 (file)
@@ -20,7 +20,9 @@
 */
 
 #include "includes.h"
+#include "printing.h"
 #include "smbd/globals.h"
+#include "fake_file.h"
 #include "librpc/gen_ndr/messaging.h"
 #include "../librpc/gen_ndr/ndr_security.h"
 
@@ -54,7 +56,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
 
 NTSTATUS smb1_file_se_access_check(struct connection_struct *conn,
                                const struct security_descriptor *sd,
-                               const NT_USER_TOKEN *token,
+                               const struct security_token *token,
                                uint32_t access_desired,
                                uint32_t *access_granted)
 {
@@ -1090,7 +1092,8 @@ static void defer_open(struct share_mode_lock *lck,
                                       state->id, (char *)state, sizeof(*state))) {
                exit_server("push_deferred_open_message_smb failed");
        }
-       add_deferred_open(lck, req->mid, request_time, state->id);
+       add_deferred_open(lck, req->mid, request_time,
+                         sconn_server_id(req->sconn), state->id);
 }
 
 
@@ -1454,14 +1457,15 @@ static NTSTATUS calculate_access_mask(connection_struct *conn,
  Remove the deferred open entry under lock.
 ****************************************************************************/
 
-void remove_deferred_open_entry(struct file_id id, uint64_t mid)
+void remove_deferred_open_entry(struct file_id id, uint64_t mid,
+                               struct server_id pid)
 {
        struct share_mode_lock *lck = get_share_mode_lock(talloc_tos(), id,
                        NULL, NULL, NULL);
        if (lck == NULL) {
                DEBUG(0, ("could not get share mode lock\n"));
        } else {
-               del_deferred_open_entry(lck, mid);
+               del_deferred_open_entry(lck, mid, pid);
                TALLOC_FREE(lck);
        }
 }
@@ -1524,8 +1528,8 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
                        return NT_STATUS_INTERNAL_ERROR;
                }
 
-               return print_fsp_open(req, conn, smb_fname->base_name,
-                                     req->vuid, fsp);
+               return print_spool_open(fsp, smb_fname->base_name,
+                                       req->vuid);
        }
 
        if (!parent_dirname(talloc_tos(), smb_fname->base_name, &parent_dir,
@@ -1574,7 +1578,9 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
                           see if this has timed out. */
 
                        /* Remove the deferred open entry under lock. */
-                       remove_deferred_open_entry(state->id, req->mid);
+                       remove_deferred_open_entry(
+                               state->id, req->mid,
+                               sconn_server_id(req->sconn));
 
                        /* Ensure we don't reprocess this message. */
                        remove_deferred_open_message_smb(req->mid);
@@ -2137,7 +2143,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
         * If requested, truncate the file.
         */
 
-       if (flags2&O_TRUNC) {
+       if (file_existed && (flags2&O_TRUNC)) {
                /*
                 * We are modifing the file after open - update the stat
                 * struct..
@@ -2271,7 +2277,8 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
        /* If this is a successful open, we must remove any deferred open
         * records. */
        if (req != NULL) {
-               del_deferred_open_entry(lck, req->mid);
+               del_deferred_open_entry(lck, req->mid,
+                                       sconn_server_id(req->sconn));
        }
        TALLOC_FREE(lck);