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

« back to all changes in this revision

Viewing changes to source3/lib/messages_local.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:
2
2
   Unix SMB/CIFS implementation.
3
3
   Samba internal messaging functions
4
4
   Copyright (C) 2007 by Volker Lendecke
5
 
   
 
5
 
6
6
   This program is free software; you can redistribute it and/or modify
7
7
   it under the terms of the GNU General Public License as published by
8
8
   the Free Software Foundation; either version 3 of the License, or
9
9
   (at your option) any later version.
10
 
   
 
10
 
11
11
   This program is distributed in the hope that it will be useful,
12
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
14
   GNU General Public License for more details.
15
 
   
 
15
 
16
16
   You should have received a copy of the GNU General Public License
17
17
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
18
*/
21
21
  @defgroup messages Internal messaging framework
22
22
  @{
23
23
  @file messages.c
24
 
  
 
24
 
25
25
  @brief  Module for internal messaging between Samba daemons. 
26
26
 
27
27
   The idea is that if a part of Samba wants to do communication with
43
43
*/
44
44
 
45
45
#include "includes.h"
46
 
#include "librpc/gen_ndr/messaging.h"
47
 
#include "librpc/gen_ndr/ndr_messaging.h"
 
46
#include "system/filesys.h"
 
47
#include "messages.h"
 
48
#include "lib/util/tdb_wrap.h"
48
49
 
49
50
struct messaging_tdb_context {
50
51
        struct messaging_context *msg_ctx;
103
104
        ctx->msg_ctx = msg_ctx;
104
105
 
105
106
        ctx->tdb = tdb_wrap_open(ctx, lock_path("messages.tdb"), 0,
106
 
                                 TDB_CLEAR_IF_FIRST|TDB_DEFAULT|TDB_VOLATILE,
 
107
                                 TDB_CLEAR_IF_FIRST|TDB_DEFAULT|TDB_VOLATILE|TDB_INCOMPATIBLE_HASH,
107
108
                                 O_RDWR|O_CREAT,0600);
108
109
 
109
110
        if (!ctx->tdb) {
110
111
                NTSTATUS status = map_nt_error_from_unix(errno);
111
 
                DEBUG(0, ("ERROR: Failed to initialise messages database: "
 
112
                DEBUG(2, ("ERROR: Failed to initialise messages database: "
112
113
                          "%s\n", strerror(errno)));
113
114
                TALLOC_FREE(result);
114
115
                return status;
133
134
        return NT_STATUS_OK;
134
135
}
135
136
 
 
137
bool messaging_tdb_parent_init(TALLOC_CTX *mem_ctx)
 
138
{
 
139
        struct tdb_wrap *db;
 
140
 
 
141
        /*
 
142
         * Open the tdb in the parent process (smbd) so that our
 
143
         * CLEAR_IF_FIRST optimization in tdb_reopen_all can properly
 
144
         * work.
 
145
         */
 
146
 
 
147
        db = tdb_wrap_open(mem_ctx, lock_path("messages.tdb"), 0,
 
148
                           TDB_CLEAR_IF_FIRST|TDB_DEFAULT|TDB_VOLATILE|TDB_INCOMPATIBLE_HASH,
 
149
                           O_RDWR|O_CREAT,0600);
 
150
        if (db == NULL) {
 
151
                DEBUG(1, ("could not open messaging.tdb: %s\n",
 
152
                          strerror(errno)));
 
153
                return false;
 
154
        }
 
155
        return true;
 
156
}
 
157
 
136
158
/*******************************************************************
137
159
 Form a static tdb key from a pid.
138
160
******************************************************************/
145
167
        key = talloc_asprintf(talloc_tos(), "PID/%s", procid_str_static(&pid));
146
168
 
147
169
        SMB_ASSERT(key != NULL);
148
 
        
 
170
 
149
171
        kbuf.dptr = (uint8 *)key;
150
172
        kbuf.dsize = strlen(key)+1;
151
173
        return kbuf;
179
201
        blob = data_blob_const(data.dptr, data.dsize);
180
202
 
181
203
        ndr_err = ndr_pull_struct_blob(
182
 
                &blob, result, NULL, result,
 
204
                &blob, result, result,
183
205
                (ndr_pull_flags_fn_t)ndr_pull_messaging_array);
184
206
 
185
207
        SAFE_FREE(data.dptr);
221
243
                return NT_STATUS_NO_MEMORY;
222
244
        }
223
245
 
224
 
        ndr_err = ndr_push_struct_blob(
225
 
                &blob, mem_ctx, NULL, array,
 
246
        ndr_err = ndr_push_struct_blob(&blob, mem_ctx, array,
226
247
                (ndr_push_flags_fn_t)ndr_push_messaging_array);
227
248
 
228
249
        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
360
381
        rec[msg_array->num_messages].msg_version = MESSAGE_VERSION;
361
382
        rec[msg_array->num_messages].msg_type = msg_type & MSG_TYPE_MASK;
362
383
        rec[msg_array->num_messages].dest = pid;
363
 
        rec[msg_array->num_messages].src = procid_self();
 
384
        rec[msg_array->num_messages].src = msg_ctx->id;
364
385
        rec[msg_array->num_messages].buf = *data;
365
386
 
366
387
        msg_array->messages = rec;
371
392
        if (!NT_STATUS_IS_OK(status)) {
372
393
                goto done;
373
394
        }
374
 
        
 
395
 
375
396
        status = message_notify(pid);
376
397
 
377
398
        if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) {
387
408
}
388
409
 
389
410
/****************************************************************************
390
 
 Retrieve all messages for the current process.
 
411
 Retrieve all messages for a process.
391
412
****************************************************************************/
392
413
 
393
414
static NTSTATUS retrieve_all_messages(TDB_CONTEXT *msg_tdb,
 
415
                                      struct server_id id,
394
416
                                      TALLOC_CTX *mem_ctx,
395
417
                                      struct messaging_array **presult)
396
418
{
397
419
        struct messaging_array *result;
398
 
        TDB_DATA key = message_key_pid(mem_ctx, procid_self());
 
420
        TDB_DATA key = message_key_pid(mem_ctx, id);
399
421
        NTSTATUS status;
400
422
 
401
423
        if (tdb_chainlock(msg_tdb, key) == -1) {
443
465
        DEBUG(10, ("message_dispatch: received_messages = %d\n",
444
466
                   ctx->received_messages));
445
467
 
446
 
        status = retrieve_all_messages(tdb->tdb, NULL, &msg_array);
 
468
        status = retrieve_all_messages(tdb->tdb, msg_ctx->id, NULL, &msg_array);
447
469
        if (!NT_STATUS_IS_OK(status)) {
448
470
                DEBUG(0, ("message_dispatch: failed to retrieve messages: %s\n",
449
471
                           nt_errstr(status)));