~ubuntu-branches/ubuntu/vivid/samba/vivid

« back to all changes in this revision

Viewing changes to source3/smbd/smb2_notify.c

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-12-21 13:18:04 UTC
  • mfrom: (0.39.21 sid)
  • Revision ID: package-import@ubuntu.com-20111221131804-xtlr39wx6njehxxr
Tags: 2:3.6.1-3ubuntu1
* Merge from Debian testing.  Remaining changes:
  + debian/patches/VERSION.patch:
    - set SAMBA_VERSION_SUFFIX to Ubuntu.
  + debian/patches/error-trans.fix-276472:
    - Add the translation of Unix Error code -ENOTSUP to NT Error Code
    - NT_STATUS_NOT_SUPPORTED to prevent the Permission denied error.
  + debian/smb.conf:
    - add "(Samba, Ubuntu)" to server string.
    - comment out the default [homes] share, and add a comment about
      "valid users = %S" to show users how to restrict access to
      \\server\username to only username.
    - Set 'usershare allow guests', so that usershare admins are 
      allowed to create public shares in addition to authenticated
      ones.
    - add map to guest = Bad user, maps bad username to guest access.
  + debian/samba-common.config:
    - Do not change priority to high if dhclient3 is installed.
    - Use priority medium instead of high for the workgroup question.
  + debian/control:
    - Don't build against or suggest ctdb.
    - Add dependency on samba-common-bin to samba.
  + Add ufw integration:
    - Created debian/samba.ufw.profile
    - debian/rules, debian/samba.dirs, debian/samba.files: install
      profile
    - debian/control: have samba suggest ufw
  + Add apport hook:
    - Created debian/source_samba.py.
    - debian/rules, debian/samba.dirs, debian/samba-common-bin.files: install
  + Switch to upstart:
    - Add debian/samba.{nmbd,smbd}.upstart.
  + debian/samba.logrotate, debian/samba-common.dhcp, debian/samba.if-up:
    - Make them upstart compatible
  + debian/samba.postinst: 
    - Avoid scary pdbedit warnings on first import.
  + debian/samba-common.postinst: Add more informative error message for
    the case where smb.conf was manually deleted
  + debian/patches/fix-debuglevel-name-conflict.patch: don't use 'debug_level'
    as a global variable name in an NSS module 
  + Dropped:
    - debian/patches/error-trans.fix-276472
    - debian/patches/fix-debuglevel-name-conflict.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
   Core SMB2 server
4
4
 
5
5
   Copyright (C) Stefan Metzmacher 2009
 
6
   Copyright (C) Jeremy Allison 2010
6
7
 
7
8
   This program is free software; you can redistribute it and/or modify
8
9
   it under the terms of the GNU General Public License as published by
19
20
*/
20
21
 
21
22
#include "includes.h"
 
23
#include "smbd/smbd.h"
22
24
#include "smbd/globals.h"
23
25
#include "../libcli/smb/smb_common.h"
 
26
#include "../lib/util/tevent_ntstatus.h"
 
27
 
 
28
struct smbd_smb2_notify_state {
 
29
        struct smbd_smb2_request *smb2req;
 
30
        struct smb_request *smbreq;
 
31
        struct tevent_immediate *im;
 
32
        NTSTATUS status;
 
33
        DATA_BLOB out_output_buffer;
 
34
};
24
35
 
25
36
static struct tevent_req *smbd_smb2_notify_send(TALLOC_CTX *mem_ctx,
26
37
                                                struct tevent_context *ev,
36
47
static void smbd_smb2_request_notify_done(struct tevent_req *subreq);
37
48
NTSTATUS smbd_smb2_request_process_notify(struct smbd_smb2_request *req)
38
49
{
39
 
        const uint8_t *inhdr;
 
50
        NTSTATUS status;
40
51
        const uint8_t *inbody;
41
52
        int i = req->current_idx;
42
 
        size_t expected_body_size = 0x20;
43
 
        size_t body_size;
44
53
        uint16_t in_flags;
45
54
        uint32_t in_output_buffer_length;
46
55
        uint64_t in_file_id_persistent;
48
57
        uint64_t in_completion_filter;
49
58
        struct tevent_req *subreq;
50
59
 
51
 
        inhdr = (const uint8_t *)req->in.vector[i+0].iov_base;
52
 
        if (req->in.vector[i+1].iov_len != (expected_body_size & 0xFFFFFFFE)) {
53
 
                return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
 
60
        status = smbd_smb2_request_verify_sizes(req, 0x20);
 
61
        if (!NT_STATUS_IS_OK(status)) {
 
62
                return smbd_smb2_request_error(req, status);
54
63
        }
55
 
 
56
64
        inbody = (const uint8_t *)req->in.vector[i+1].iov_base;
57
65
 
58
 
        body_size = SVAL(inbody, 0x00);
59
 
        if (body_size != expected_body_size) {
60
 
                return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
61
 
        }
62
 
 
63
66
        in_flags                = SVAL(inbody, 0x02);
64
67
        in_output_buffer_length = IVAL(inbody, 0x04);
65
68
        in_file_id_persistent   = BVAL(inbody, 0x08);
70
73
         * 0x00010000 is what Windows 7 uses,
71
74
         * Windows 2008 uses 0x00080000
72
75
         */
73
 
        if (in_output_buffer_length > 0x00010000) {
 
76
        if (in_output_buffer_length > req->sconn->smb2.max_trans) {
74
77
                return smbd_smb2_request_error(req, NT_STATUS_INVALID_PARAMETER);
75
78
        }
76
79
 
77
80
        if (req->compat_chain_fsp) {
78
81
                /* skip check */
79
 
        } else if (in_file_id_persistent != 0) {
 
82
        } else if (in_file_id_persistent != in_file_id_volatile) {
80
83
                return smbd_smb2_request_error(req, NT_STATUS_FILE_CLOSED);
81
84
        }
82
85
 
108
111
        NTSTATUS status;
109
112
        NTSTATUS error; /* transport error */
110
113
 
 
114
        if (req->cancelled) {
 
115
                struct smbd_smb2_notify_state *state = tevent_req_data(subreq,
 
116
                                               struct smbd_smb2_notify_state);
 
117
                const uint8_t *inhdr = (const uint8_t *)req->in.vector[i].iov_base;
 
118
                uint64_t mid = BVAL(inhdr, SMB2_HDR_MESSAGE_ID);
 
119
 
 
120
                DEBUG(10,("smbd_smb2_request_notify_done: cancelled mid %llu\n",
 
121
                        (unsigned long long)mid ));
 
122
                error = smbd_smb2_request_error(req, NT_STATUS_CANCELLED);
 
123
                if (!NT_STATUS_IS_OK(error)) {
 
124
                        smbd_server_connection_terminate(req->sconn,
 
125
                                nt_errstr(error));
 
126
                        return;
 
127
                }
 
128
                TALLOC_FREE(state->im);
 
129
                return;
 
130
        }
 
131
 
111
132
        status = smbd_smb2_notify_recv(subreq,
112
133
                                       req,
113
134
                                       &out_output_buffer);
153
174
        }
154
175
}
155
176
 
156
 
struct smbd_smb2_notify_state {
157
 
        struct smbd_smb2_request *smb2req;
158
 
        struct smb_request *smbreq;
159
 
        struct tevent_immediate *im;
160
 
        NTSTATUS status;
161
 
        DATA_BLOB out_output_buffer;
162
 
};
163
 
 
164
177
static void smbd_smb2_notify_reply(struct smb_request *smbreq,
165
178
                                   NTSTATUS error_code,
166
179
                                   uint8_t *buf, size_t len);
264
277
                 * here.
265
278
                 */
266
279
 
267
 
                change_notify_reply(fsp->conn, smbreq,
 
280
                change_notify_reply(smbreq,
268
281
                                    NT_STATUS_OK,
269
282
                                    in_output_buffer_length,
270
283
                                    fsp->notify,
361
374
        struct smbd_smb2_notify_state *state = tevent_req_data(req,
362
375
                                               struct smbd_smb2_notify_state);
363
376
 
364
 
        smbd_notify_cancel_by_smbreq(state->smb2req->sconn,
365
 
                                     state->smbreq);
 
377
        smbd_notify_cancel_by_smbreq(state->smbreq);
366
378
 
 
379
        state->smb2req->cancelled = true;
 
380
        tevent_req_done(req);
367
381
        return true;
368
382
}
369
383