Ignore:
Timestamp:
Nov 14, 2012, 12:59:34 PM (12 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to 3.6.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified vendor/current/source3/smbd/smb2_break.c

    r414 r740  
    44
    55   Copyright (C) Stefan Metzmacher 2009
     6   Copyright (C) Jeremy Allison 2010
    67
    78   This program is free software; you can redistribute it and/or modify
     
    2021
    2122#include "includes.h"
     23#include "smbd/smbd.h"
    2224#include "smbd/globals.h"
    2325#include "../libcli/smb/smb_common.h"
     26#include "../lib/util/tevent_ntstatus.h"
    2427
    2528static struct tevent_req *smbd_smb2_oplock_break_send(TALLOC_CTX *mem_ctx,
     
    5760
    5861        in_oplock_level         = CVAL(inbody, 0x02);
     62
     63        if (in_oplock_level != SMB2_OPLOCK_LEVEL_NONE &&
     64                        in_oplock_level != SMB2_OPLOCK_LEVEL_II) {
     65                return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
     66        }
     67
    5968        /* 0x03 1 bytes reserved */
    6069        /* 0x04 4 bytes reserved */
     
    6473        if (req->compat_chain_fsp) {
    6574                /* skip check */
    66         } else if (in_file_id_persistent != 0) {
     75        } else if (in_file_id_persistent != in_file_id_volatile) {
    6776                return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
    6877        }
     
    124133        SSVAL(outbody.data, 0x00, 0x18);        /* struct size */
    125134        SCVAL(outbody.data, 0x02,
    126               out_oplock_level);                /* oplock level */
     135              out_oplock_level);                /* SMB2 oplock level */
    127136        SCVAL(outbody.data, 0x03, 0);           /* reserved */
    128137        SIVAL(outbody.data, 0x04, 0);           /* reserved */
     
    142151struct smbd_smb2_oplock_break_state {
    143152        struct smbd_smb2_request *smb2req;
    144         uint8_t out_oplock_level;
     153        uint8_t out_oplock_level; /* SMB2 oplock level. */
    145154};
    146155
     
    155164        struct smb_request *smbreq;
    156165        connection_struct *conn = smb2req->tcon->compat_conn;
    157         files_struct *fsp;
     166        files_struct *fsp = NULL;
     167        int oplocklevel = map_smb2_oplock_levels_to_samba(in_oplock_level);
     168        bool break_to_none = (oplocklevel == NO_OPLOCK);
     169        bool result;
    158170
    159171        req = tevent_req_create(mem_ctx, &state,
     
    165177        state->out_oplock_level = SMB2_OPLOCK_LEVEL_NONE;
    166178
    167         DEBUG(10,("smbd_smb2_oplock_break_send: file_id[0x%016llX]\n",
    168                   (unsigned long long)in_file_id_volatile));
     179        DEBUG(10,("smbd_smb2_oplock_break_send: file_id[0x%016llX] "
     180                "samba level %d\n",
     181                (unsigned long long)in_file_id_volatile,
     182                oplocklevel));
    169183
    170184        smbreq = smbd_smb2_fake_smb_request(smb2req);
     
    187201        }
    188202
    189         tevent_req_nterror(req, NT_STATUS_NOT_IMPLEMENTED);
     203        DEBUG(5,("smbd_smb2_oplock_break_send: got SMB2 oplock break (%u) from client "
     204                "for file %s fnum = %d\n",
     205                (unsigned int)in_oplock_level,
     206                fsp_str_dbg(fsp),
     207                fsp->fnum ));
     208
     209        /* Are we awaiting a break message ? */
     210        if (fsp->oplock_timeout == NULL) {
     211                tevent_req_nterror(req, NT_STATUS_INVALID_OPLOCK_PROTOCOL);
     212                return tevent_req_post(req, ev);
     213        }
     214
     215        if ((fsp->sent_oplock_break == BREAK_TO_NONE_SENT) ||
     216                        (break_to_none)) {
     217                result = remove_oplock(fsp);
     218                state->out_oplock_level = SMB2_OPLOCK_LEVEL_NONE;
     219        } else {
     220                result = downgrade_oplock(fsp);
     221                state->out_oplock_level = SMB2_OPLOCK_LEVEL_II;
     222        }
     223
     224        if (!result) {
     225                DEBUG(0, ("smbd_smb2_oplock_break_send: error in removing "
     226                        "oplock on file %s\n", fsp_str_dbg(fsp)));
     227                /* Hmmm. Is this panic justified? */
     228                smb_panic("internal tdb error");
     229        }
     230
     231        reply_to_oplock_break_requests(fsp);
     232
     233        tevent_req_done(req);
    190234        return tevent_req_post(req, ev);
    191235}
     
    209253        return NT_STATUS_OK;
    210254}
     255
     256/*********************************************************
     257 Create and send an asynchronous
     258 SMB2 OPLOCK_BREAK_NOTIFICATION.
     259*********************************************************/
     260
     261void send_break_message_smb2(files_struct *fsp, int level)
     262{
     263        uint8_t smb2_oplock_level = (level == OPLOCKLEVEL_II) ?
     264                                SMB2_OPLOCK_LEVEL_II :
     265                                SMB2_OPLOCK_LEVEL_NONE;
     266        NTSTATUS status;
     267
     268        DEBUG(10,("send_break_message_smb2: sending oplock break "
     269                "for file %s, fnum = %d, smb2 level %u\n",
     270                fsp_str_dbg(fsp),
     271                fsp->fnum,
     272                (unsigned int)smb2_oplock_level ));
     273
     274        status = smbd_smb2_send_oplock_break(fsp->conn->sconn,
     275                                        (uint64_t)fsp->fnum,
     276                                        (uint64_t)fsp->fnum,
     277                                        smb2_oplock_level);
     278        if (!NT_STATUS_IS_OK(status)) {
     279                smbd_server_connection_terminate(fsp->conn->sconn,
     280                                 nt_errstr(status));
     281        }
     282}
Note: See TracChangeset for help on using the changeset viewer.