~lefteris-nikoltsios/+junk/samba-lp1016895

« back to all changes in this revision

Viewing changes to source4/ntvfs/common/brlock_tdb.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:
26
26
 
27
27
#include "includes.h"
28
28
#include "system/filesys.h"
29
 
#include "../tdb/include/tdb.h"
 
29
#include <tdb.h>
30
30
#include "messaging/messaging.h"
31
 
#include "tdb_wrap.h"
 
31
#include "lib/util/tdb_wrap.h"
32
32
#include "lib/messaging/irpc.h"
33
33
#include "libcli/libcli.h"
34
34
#include "cluster/cluster.h"
80
80
        struct lock_struct last_lock;
81
81
};
82
82
 
 
83
/* see if we have wrapped locks, which are no longer allowed (windows
 
84
 * changed this in win7 */
 
85
static bool brl_invalid_lock_range(uint64_t start, uint64_t size)
 
86
{
 
87
        return (size > 1 && (start + size < start));
 
88
}
 
89
 
83
90
/*
84
91
  Open up the brlock.tdb database. Close it down using
85
92
  talloc_free(). We need the messaging_ctx to allow for
299
306
        kbuf.dptr = brlh->key.data;
300
307
        kbuf.dsize = brlh->key.length;
301
308
 
 
309
        if (brl_invalid_lock_range(start, size)) {
 
310
                return NT_STATUS_INVALID_LOCK_RANGE;
 
311
        }
 
312
 
302
313
        if (tdb_chainlock(brl->w->tdb, kbuf) != 0) {
303
314
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
304
315
        }
449
460
        kbuf.dptr = brlh->key.data;
450
461
        kbuf.dsize = brlh->key.length;
451
462
 
 
463
        if (brl_invalid_lock_range(start, size)) {
 
464
                return NT_STATUS_INVALID_LOCK_RANGE;
 
465
        }
 
466
 
452
467
        if (tdb_chainlock(brl->w->tdb, kbuf) != 0) {
453
468
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
454
469
        }
620
635
        kbuf.dptr = brlh->key.data;
621
636
        kbuf.dsize = brlh->key.length;
622
637
 
 
638
        if (brl_invalid_lock_range(start, size)) {
 
639
                return NT_STATUS_INVALID_LOCK_RANGE;
 
640
        }
 
641
 
623
642
        dbuf = tdb_fetch(brl->w->tdb, kbuf);
624
643
        if (dbuf.dptr == NULL) {
625
644
                return NT_STATUS_OK;
719
738
        return status;
720
739
}
721
740
 
 
741
static NTSTATUS brl_tdb_count(struct brl_context *brl, struct brl_handle *brlh,
 
742
                              int *count)
 
743
{
 
744
        TDB_DATA kbuf, dbuf;
 
745
 
 
746
        kbuf.dptr = brlh->key.data;
 
747
        kbuf.dsize = brlh->key.length;
 
748
        *count = 0;
 
749
 
 
750
        if (tdb_chainlock(brl->w->tdb, kbuf) != 0) {
 
751
                return NT_STATUS_INTERNAL_DB_CORRUPTION;
 
752
        }
 
753
 
 
754
        dbuf = tdb_fetch(brl->w->tdb, kbuf);
 
755
        if (!dbuf.dptr) {
 
756
                tdb_chainunlock(brl->w->tdb, kbuf);
 
757
                return NT_STATUS_OK;
 
758
        }
 
759
 
 
760
        *count = dbuf.dsize / sizeof(struct lock_struct);
 
761
 
 
762
        free(dbuf.dptr);
 
763
        tdb_chainunlock(brl->w->tdb, kbuf);
 
764
 
 
765
        return NT_STATUS_OK;
 
766
}
722
767
 
723
768
static const struct brlock_ops brlock_tdb_ops = {
724
769
        .brl_init           = brl_tdb_init,
727
772
        .brl_unlock         = brl_tdb_unlock,
728
773
        .brl_remove_pending = brl_tdb_remove_pending,
729
774
        .brl_locktest       = brl_tdb_locktest,
730
 
        .brl_close          = brl_tdb_close
 
775
        .brl_close          = brl_tdb_close,
 
776
        .brl_count          = brl_tdb_count
731
777
};
732
778
 
733
779