almost...
authorStefan Metzmacher <metze@samba.org>
Thu, 23 Feb 2012 07:18:41 +0000 (08:18 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 10 May 2012 16:41:58 +0000 (18:41 +0200)
source3/smbd/smb2_create.c

index abe2e925817b2e5363e09f0b5b8d97f0afccece7..5a6dc3d156dc259bde078a016a8332fc94f9519f 100644 (file)
@@ -464,6 +464,7 @@ static NTSTATUS smb2_create_durable_reconnect(struct smbXsrv_open *op,
                                              files_struct **_fsp)
 {
        struct share_mode_lock *sharemode_lock;
+       struct share_mode_entry *e;
        files_struct *fsp = NULL;
        NTSTATUS status;
 
@@ -501,7 +502,9 @@ DEBUG(0, ("OBNOX - durable_reconnect: more than one share-mode entry - can't be
                return NT_STATUS_OBJECT_NAME_NOT_FOUND;
        }
 
-       if (serverid_exists(&sharemode_lock->data->share_modes[0].pid))  {
+       e = &sharemode_lock->data->share_modes[0];
+
+       if (e->pid.pid != UINT64_MAX && serverid_exists(&e->pid))  {
                /*
                 * server still exists
                 * TODO: check whether session exists
@@ -527,6 +530,7 @@ DEBUG(0, ("OBNOX - durable_reconnect: serverid exists - denying access to durabl
 
        sharemode_lock->data->share_modes[0].pid =
                messaging_server_id(op->connection->sconn->msg_ctx);
+       sharemode_lock->data->modified = true;
 
        /*
         * circumstances seems ok, do the open
@@ -539,30 +543,14 @@ DEBUG(0, ("OBNOX - durable_reconnect: failed to create new fsp: %s (%s:%s)\n", n
 
 DEBUG(0, ("OBNOX - durable_reconnect: new fsp created (%s:%s)\n", __location__, __FUNCTION__));
 
-       fsp->fh->fd = SMB_VFS_OPEN(conn,
-                                  smb_fname,
-                                  fsp,
-                                  sharemode_lock->data->share_modes[0].flags,
-                                  0 /* mode */);
-       if (fsp->fh->fd == -1) {
-DEBUG(0, ("OBNOX - durable_reconnect: failed to open file: %s (%s:%s)\n", nt_errstr(status), __location__, __FUNCTION__));
-               status = map_nt_error_from_unix(errno);
-               return status;
-       }
-
-DEBUG(0, ("OBNOX - durable_reconnect: opened file (%s:%s)\n", __location__, __FUNCTION__));
-
-       /* - release the sharemode lock: this writes the changes */
-       talloc_free(sharemode_lock);
-
        fsp->file_id = op->global->backend_file_id;
        fsp->initial_allocation_size = 0;//TODO
-       fsp->file_pid = 0;//smb1req->pid;
+       fsp->file_pid = smb1req->smbpid;
        fsp->vuid = smb1req->vuid;//
        //fsp->open_time = 0;//from->open_time;
-       fsp->access_mask = sharemode_lock->data->share_modes[0].access_mask;
-       fsp->share_access = sharemode_lock->data->share_modes[0].share_access;
-       //fsp->oplock_type = sharemode_lock->data->share_modes[0].oplock_type;
+       fsp->access_mask = e->access_mask;
+       fsp->share_access = e->share_access;
+       fsp->oplock_type = e->op_type;
        fsp->can_lock = true;//from->can_lock;
        fsp->can_read = (fsp->access_mask & (FILE_READ_DATA)) ? True : False;
        if (!CAN_WRITE(conn)) {
@@ -574,6 +562,25 @@ DEBUG(0, ("OBNOX - durable_reconnect: opened file (%s:%s)\n", __location__, __FU
        fsp->is_directory = false;//from->is_directory;
        fsp->aio_write_behind = false;//from->aio_write_behind;
 
+DEBUG(0, ("OBNOX - durable_reconnect: before open file (%s:%s)\n", __location__, __FUNCTION__));
+
+       fsp->fh->fd = SMB_VFS_OPEN(conn,
+                                  smb_fname,
+                                  fsp,
+                                  e->flags,
+                                  0 /* mode */);
+       if (fsp->fh->fd == -1) {
+               status = map_nt_error_from_unix(errno);
+DEBUG(0, ("OBNOX - durable_reconnect: failed to open file: %s (%s:%s)\n", nt_errstr(status), __location__, __FUNCTION__));
+               return status;
+       }
+
+DEBUG(0, ("OBNOX - durable_reconnect: opened file (%s:%s)\n", __location__, __FUNCTION__));
+
+       /* - release the sharemode lock: this writes the changes */
+       talloc_free(sharemode_lock);
+
+
        /* Q: do this in fsp creation? */
        op->fsp = fsp;
        fsp->smbXsrv = op;