[SCM] Samba Shared Repository - branch v4-0-test updated

Karolin Seeger kseeger at samba.org
Sun Apr 7 15:40:04 MDT 2013


The branch, v4-0-test has been updated
       via  6786a77 BUG 9758: Don't leak the epm_Map policy handle.
       via  247472b epm: Increase debug level for already registered endpoints.
       via  e5da98b Optimization suggested by Volker. Don't do a stat system call on normal read path.
       via  a46a40c smbd: Tune "dir" a bit.
       via  f81e922 BUG 9735: Fix winbind seperator in upn to username conversion.
       via  3bdf100 Fix bug #9733 - smbcontrol close-share is not working.
       via  1e64aee Fix bad SMB2 opcode reading in server.
       via  789df00 scripting: Fill the ProvisionNames hash with strings, not ldb.MessageElement or Dn
       via  77a5ced samba-tool ldapcmp: Remove the GUID -> name mappings
       via  03ed252 selftest: Add tests for samba-tool dbcheck --reset-well-known-acls
       via  ae5a3fd scripting: Modify samba.descriptor.get_diff_sds() to cope with a missing reference owner
       via  b27e595 samba-tool dbcheck: Allow dbcheck to correct an nTSecurityDescriptor without an owner or group
       via  82c6816 samba-tool dbcheck: Add --reset-well-known-acls
       via  d18dc20 scripting: Move get_diff_sds from samba.upgradehelpers to samba.descriptor
       via  142bfc3 scripting: Modify samba.descriptor.get_wellknown_sds() use samdb calls only
       via  90455cd scripting: Move samba.provision.descriptor to samba.descriptor
       via  64bec77 scripting: Make samba.provision.descriptor.get_wellknown_sds() return ldb.Dn objects
       via  9d871ea scripting: Fix documentation comment on upgradehelpers.py:get_clean_sd
       via  e960d7a scripting: Move the list of well known SDs to samba.provision.descriptor
       via  b73d32e selftest: Remove output directories to save disk space
       via  2b1f5d4 samba_upgradeprovision: Do not reset every DN when changing an SD
       via  3e840c5 samba_upgradeprovision: do not maintain dnNotToRecalculate as a list
       via  4129080 samba_upgradeprovision: only run rebuild_sd in --full mode
       via  c293976 samba_upgradeprovision: Remove alwaysRecalculate, this is too dangerous
       via  8bf62ac samba_upgradeprovision: Remove unused checkKeepAttributeOldMtd
       via  2c0eced samba_upgradeprovision: Remove inherited ACEs before comparing the SDs
       via  b3cb9b6 scripting: Rework samba.upgradehelpers.get_diff_sddls to be get_diff_sds
       via  6533b17 samba_upgradeprovision: Remove auto-detection of pre-alpha9 databases
       via  45b45e1 selftest: Rename samba4.blackbox.upgradeprovision.py to samba4.blackbox.upgradeprovision.current
       via  e8b2f58 selftest: Run dbcheck and improved upgrdeprovision tests against release-4-0-0
       via  eaf0455 selftest: Add ldapcmp to ensure upgradeprovision of a fresh DB is a no-op
       via  11a62da selftest: Add in a provision from 4.0.0 to run tests against
       via  0c81704 selftest: Do an ldapcmp run against the upgraded domain
       via  ce88c35 samba-tool ldapcmp: Add support for checking DNSDOMAIN and DNSFOREST by default
       via  b530c26 samba-tool dbcheck: fix msDS-HasInstantiatedNCs attributes to match instanceType on our ntdsDSA
       via  db6b939 scripting: Correct parsing of binary DN
       via  8bdc63c subunit: Add a sh macro for skipping a test
       via  48ac177 samba-tool ldapcmp: Add --skip-missing-dn to not error on DNs present in one DB but not the other
       via  fc4589d samba-tool domain classicupgrade: Fix typo in error path for multiple account flags
       via  e4712a5 samba-tool domain classicupgrade: Print a better error when the ldap backend PW was not found
       via  9144f1b samba-tool dbcheck: fix comment on err_wrong_sd
       via  9485a38 Move python modules from source4/scripting/python/ to python/.
       via  0e880eb build: Change bin/default/python -> bin/python symlink to bin/default/python_modules
       via  7d13d38 build: Rename samba_python waf node to avoid duplicate name
       via  c14c2b9 dsdb-descriptor: Avoid segfault copying an SD without an owner or group
       via  65cf47d dsdb-descriptor: Spell out security descriptor flags as constants
       via  2fa152c samba_upgradeprovision: Use tdb_util.tdb_copy not shutil.copy2
       via  116b8e6 samba_upgradeprovision: Do not update privileges.ldb any more (unchanged since 2009)
       via  3f5ae9b scripting: Make tdb_copy a common util function in samba.tdb_util
       via  157cfd0 scripting: Make tdb_copy use the python subprocess module
       via  58de518 samba_upgradeprovision: Remove options to fix FS ACLs
       via  607d33b wkssvc: Fix bug 9727, NULL pointer dereference
       via  4d09fb7 s3:waf fix build on AIX
      from  20b0adc Make sure that we only propogate the INHERITED flag when we are allowed to.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v4-0-test


- Log -----------------------------------------------------------------
commit 6786a777817976266e2bb4c38a46fcffdb920c17
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Apr 2 13:08:19 2013 +0200

    BUG 9758: Don't leak the epm_Map policy handle.
    
    Reviewed-by: Alexander Bokovoy <ab at samba.org>
    
    Autobuild-User(master): Alexander Bokovoy <ab at samba.org>
    Autobuild-Date(master): Tue Apr  2 17:16:56 CEST 2013 on sn-devel-104
    
    Autobuild-User(v4-0-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-0-test): Sun Apr  7 23:39:23 CEST 2013 on sn-devel-104

commit 247472bc551c91fae21a56cf764ae8cae1848dbf
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Apr 2 13:09:13 2013 +0200

    epm: Increase debug level for already registered endpoints.
    
    Reviewed-by: Alexander Bokovoy <ab at samba.org>

commit e5da98b956435c47669eba10a77887e9832fd9da
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Mar 25 09:54:50 2013 -0700

    Optimization suggested by Volker. Don't do a stat system call on normal read path.
    
    Only do it if we need it in the sendfile() path.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Thu Mar 28 17:51:22 CET 2013 on sn-devel-104
    
    Fix bug #9748 - Remove unneeded fstat system call from hot read path.

commit a46a40cfefa1c45ae8c9cd2bd6bdbc80bc0bcab2
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Mar 21 22:00:06 2013 +0100

    smbd: Tune "dir" a bit.
    
    for i in $(seq 1 20000) ; do echo dir ; done | smbclient //127.0.0.1/tmp -U%
    
    without and with this patch:
    
    $ time bin/smbd -d0 -i
    smbd version 4.1.0pre1-GIT-1f139ae started.
    Copyright Andrew Tridgell and the Samba Team 1992-2013
    Beendet
    
    real    0m28.342s
    user    0m10.249s
    sys     0m10.513s
    
    $ time bin/smbd -d0 -i
    smbd version 4.1.0pre1-GIT-1f139ae started.
    Copyright Andrew Tridgell and the Samba Team 1992-2013
    Beendet
    
    real    0m27.348s
    user    0m9.089s
    sys     0m10.853s
    
    The "real" timestamp is irrelevant, this also contains the time between
    starting smbd and the smbclient job. It's the "user" time. The result that this
    patch improves the time spent in user space by 10% is consistent.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Fix bug #9736 - Change to smbd/dir.c code gives significant performance
    increases on large directory listings.

commit f81e922cdd65646d1f52c1e1b35f4d4c6eaca988
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Mar 22 14:15:57 2013 +0100

    BUG 9735: Fix winbind seperator in upn to username conversion.
    
    Reviewed-by: Günther Deschner <gd at samba.org>
    Signed-off-by: Andreas Schneider <asn at samba.org>

commit 3bdf1003ee7c6c196e1232864e188507e1c2230a
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Mar 21 13:47:07 2013 -0700

    Fix bug #9733 - smbcontrol close-share is not working.
    
    As part of forcibly disconnecting a client from a share,
    smbd must atomically call reload_services() to ensure that
    the entry in the ServicePtrs[] array corresponding to
    that share is removed if the share was removed from
    the smb.conf or registry entries.
    
    Otherwise the ServicePtrs[] array entry for the share
    remains active and the client races to auto-reconnect to
    the share before a second message to reload the smb.conf
    file can be sent.
    
    This has to be done as part of the close-share message
    processing, as removing the share from the smb.conf file
    first, then telling the smbd to reload followed by the
    forcible disconnect message doesn't work as in this
    sequence of events when the reload message is received
    the client is still connected to the share, so the
    ServicePtrs[] entry is still left active.
    
    The forcible-disconnect + service reload has to be done
    together as an atomic operation in order for this to work.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>

commit 1e64aee93e0b89997a3ef07634aa5dd22af93b55
Author: Jeremy Allison <jra at samba.org>
Date:   Mon Apr 1 20:11:26 2013 -0700

    Fix bad SMB2 opcode reading in server.
    
    SMB2 opcodes are 16-bit values. We should *never*
    be reading them with IVAL(inhdr, SMB2_HDR_OPCODE),
    it should always be SVAL(inhdr, SMB2_HDR_OPCODE).
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Richard Sharpe <realrichardsharpe at gmail.com>
    
    Autobuild-User(master): Richard Sharpe <sharpe at samba.org>
    Autobuild-Date(master): Tue Apr  2 07:28:48 CEST 2013 on sn-devel-104
    
    Fix bug #9760 - Incorrect parsing of SMB2 command codes.

commit 789df00203a0b14b013ed09d10ca6de7928bed35
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Mar 22 21:58:25 2013 +1100

    scripting: Fill the ProvisionNames hash with strings, not ldb.MessageElement or Dn
    
    This avoids the need to fix it up again in samba_upgradedns.
    
    Andrew Bartlett
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Mon Mar 25 13:25:30 CET 2013 on sn-devel-104
    (cherry picked from commit 30adf0cdbae6d9aaf2e72513d9c33267248f20c0)
    
    The last 12 patches address bug #9740 - Add samba-tool dbcheck
    --reset-well-known-acls.

commit 77a5cedde8c61ff6d5385b474f47f4fe8ae2dbcd
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Mar 22 21:36:49 2013 +1100

    samba-tool ldapcmp: Remove the GUID -> name mappings
    
    These mappings are very convenient, however because they are not
    one-to-one, they lead to differences being reported when none exist,
    dependent only on the order the schema searches return results in.
    
    Sadly the time saved by the names is offset by the time wasted chasing
    the 'differences' that don't exist.
    
    This in turn fixes some tests that were previously knownfail
    
    Andrew Bartlett
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 5d42260eecfd4f26cc82637ce1bc989083c9eb9d)

commit 03ed25210e90bf52755751d4486be3b4a16f290e
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Mar 22 17:12:43 2013 +1100

    selftest: Add tests for samba-tool dbcheck --reset-well-known-acls
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 1589e46d11f29551f3598876b62e29fcbad06580)

commit ae5a3fd9dd58fc26289f8ae9923d5993bbf2177f
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Mar 22 22:16:03 2013 +1100

    scripting: Modify samba.descriptor.get_diff_sds() to cope with a missing reference owner
    
    This allows the reference SD not to have an owner specified, and still
    have the comparison with a database SD that does have an owner pass.
    (And the same for owning group).
    
    Andrew Bartlett
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 874a93bc1c437543474a6c574b0065b7b953ad38)

commit b27e59572d6f1b01d5d428f89548269e47e91ccc
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Feb 11 14:49:01 2013 +1100

    samba-tool dbcheck: Allow dbcheck to correct an nTSecurityDescriptor without an owner or group
    
    This is done by making a modification to the SD, which triggers it to be
    filled in if we have the correct session_info established on the DB.
    
    However, we normally want dbcheck running as system, so we wrap
    the session_info set around this operation only.
    
    Andrew Bartlett
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 4789a3072a4241841c096115dbdb0c3259968e68)

commit 82c681693886fc372f257cdf67c3ac5a937e4c38
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Feb 11 14:49:01 2013 +1100

    samba-tool dbcheck: Add --reset-well-known-acls
    
    This will allow an upgrade from Samba 4.0.0 without needing to run
    samba_upgradeprovision, which for now is not the preferred upgrade
    tool.
    
    Andrew Bartlett
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 810f8b48d925ea15f3439c4b228741d8fddaccd8)

commit d18dc202b3b56140251f06d2e1271ed19b5f32e5
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Mar 22 16:19:27 2013 +1100

    scripting: Move get_diff_sds from samba.upgradehelpers to samba.descriptor
    
    This helps avoid a dependency loop when we use get_diff_sds in dbcheck.
    
    Andrew Bartlett
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 9040e2684161ce75738e9da0fee191aa34858607)

commit 142bfc39c6996745e2b5f5535a06052016798372
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Mar 22 11:15:38 2013 +1100

    scripting: Modify samba.descriptor.get_wellknown_sds() use samdb calls only
    
    We need this routine not to use the names context as this is tied to
    provision, and we end up in a circular dependency if we use that in
    dbcheck.
    
    Andrew Bartlett
    (cherry picked from commit a113ddbf881c5905bbf7072638c7ba8843eeb85e)

commit 90455cd0e4ff66d0763f8cb639f40e8c2997bb22
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Mar 21 13:34:26 2013 +1100

    scripting: Move samba.provision.descriptor to samba.descriptor
    
    This will allow dbcheck to import it, without a cirucular dependency via
    samba.provision importing dbcheck.
    
    Andrew Bartlett
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 352aff8ed7e06c14b7a00a56b31c79ffddf71dd4)

commit 64bec776554040ff6f2d8f3cc13e19fe7c761ad6
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Mar 21 12:49:46 2013 +1100

    scripting: Make samba.provision.descriptor.get_wellknown_sds() return ldb.Dn objects
    
    As we look to use this function in more places, it does not make sense to constantly create
    Dn objects from the strings.
    
    Andrew Bartlett
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit e81a97dd6fc2da701f2cbf42513311a7a44adad3)

commit 9d871ea65ab9b982a81620a030112eb9ecf75535
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Wed Mar 20 14:50:55 2013 +1100

    scripting: Fix documentation comment on upgradehelpers.py:get_clean_sd
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 6df17fe799968ca7e2f92ce9e294e3962ac8cbaf)

commit e960d7a974597bfa1a76d22ba746644c3cf8a0c3
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Wed Mar 20 14:12:26 2013 +1100

    scripting: Move the list of well known SDs to samba.provision.descriptor
    
    This will allow us to call this from dbcheck.
    
    Andrew Bartlett
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 3da89b01faebba669434b07db344c203a4521ca2)

commit b73d32e35e7033a6966f2ec41fa0b7ddd8c6ee50
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sun Feb 17 22:45:59 2013 +1100

    selftest: Remove output directories to save disk space
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit b9b637569960ae7eef5ee12436624af34a718a9a)
    
    The last 32 patches address bug #9725 - upgradeprovision and samba-tool dbcheck
    patches for 4.0.NEXT.

commit 2b1f5d42f73f3a63b357696d8fee14ec97a91c03
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Feb 18 15:56:18 2013 +1100

    samba_upgradeprovision: Do not reset every DN when changing an SD
    
    SD propogation is handled by an LDB module, we do not need to touch each
    and every DN to make it happen.
    
    Now that we do not need to put this via a hash, the dnToRecalculate
    list is changed to be a list of Dn objects, not strings so that:
    
    if dn in listWellknown
    
    is handled using a schema comparison (avoiding different case forms
    tripping it up).
    
    Andrew Bartlett
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit d5d88bd82b1cb51da09cf3b3dec40f180f5ed29f)

commit 3e840c5186a6c374a5275f97485a20f508c7c9fb
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Feb 18 15:15:52 2013 +1100

    samba_upgradeprovision: do not maintain dnNotToRecalculate as a list
    
    We only need a boolean indication, not the actual values.
    
    Andrew Bartlett
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 0f247dce00fd26230cdb0566ce4f51a2ea8cfc2b)

commit 4129080ce4702c6f47a04aaec8220a5e1bea26ed
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Feb 18 15:05:00 2013 +1100

    samba_upgradeprovision: only run rebuild_sd in --full mode
    
    This is a potentially destructive routine, and should not be run by default.
    
    Andrew Bartlett
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 9bc32bfd65700c816ebb2a3004ad568327218f86)

commit c2939761b2453023a3372303f44383a81795f362
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Feb 18 13:00:31 2013 +1100

    samba_upgradeprovision: Remove alwaysRecalculate, this is too dangerous
    
    I am unclear on why this was added, but the idea that we ever always reset data
    in the directory is not reasonable to me, so I am removing it.
    
    Andrew Bartlett
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 81cda856faf2a5efd38965fd4c3b1f5551ad94d9)

commit 8bf62ac75a1f91b78e5cd5f505797011585666d0
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Feb 18 12:28:23 2013 +1100

    samba_upgradeprovision: Remove unused checkKeepAttributeOldMtd
    
    lastProvisionUSNs is never None, instead the code requries the administrator to populate this
    attribute in the directory.
    
    Andrew Bartlett
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 09b82d5fdc05a1f440aa96a690c202d4b0df134b)

commit 2c0ecedfe7ec0c6af77ce8880d1ffd469e8e8b21
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sun Feb 17 22:44:56 2013 +1100

    samba_upgradeprovision: Remove inherited ACEs before comparing the SDs
    
    This avoids changing an SD when it is not really required.
    
    Andrew Bartlett
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 9b8d5bba507615aee95a46fd9ae75aa782fd7e66)

commit b3cb9b6a5fffdece56b31db20a9eb0569feee399
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sun Feb 17 22:03:18 2013 +1100

    scripting: Rework samba.upgradehelpers.get_diff_sddls to be get_diff_sds
    
    This moves the SDDL conversion inside the get_diff_sds function and prepares
    for removing inherited ACEs from the SD before comparison.
    
    Andrew Bartlett
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 5074b98714c9e038cc31872111508c1d92562841)

commit 6533b17d64b5c8acb141900c4460c04499acb9e0
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Feb 16 21:58:57 2013 +1100

    samba_upgradeprovision: Remove auto-detection of pre-alpha9 databases
    
    These are incredibly rare, and administrators running such databases
    not only ask the Samba Team for help personally, they can read --help.
    
    Andrew Bartlett
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 787a6aacc3003731784b29fd92c683036c8730a7)

commit 45b45e19d5f1b18ffd5b11d7340ace8957073c58
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Feb 16 13:12:53 2013 +1100

    selftest: Rename samba4.blackbox.upgradeprovision.py to samba4.blackbox.upgradeprovision.current
    
    This name matches the other upgradeprovision tests for older saved provisions.
    
    Andrew Bartlett
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 9d6af4938f7bc80b10202d7055c2c32a483bbb5f)

commit e8b2f5827a52c022c376a655aae24fe189651559
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Feb 16 01:07:27 2013 +1100

    selftest: Run dbcheck and improved upgrdeprovision tests against release-4-0-0
    
    The improved upgradeprovision tests now call ldapcmp to verify the
    changes made do actually bring the database in line with a fresh
    provision.
    
    Andrew Bartlett
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 08f0562240155a871bd2a78d217db660e8ee3c91)

commit eaf0455faef38bd5cb91b7a898c8f9df8feff591
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Feb 16 01:08:20 2013 +1100

    selftest: Add ldapcmp to ensure upgradeprovision of a fresh DB is a no-op
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit d7936ee20c20635d62657cb821ff6dc4eb5fe33c)

commit 11a62da58c91834e2febae96dab2756999f03328
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Feb 16 01:05:56 2013 +1100

    selftest: Add in a provision from 4.0.0 to run tests against
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit f1f36ad3517cd0e6bceb4b0cc37721a15be4d588)

commit 0c8170424a91fca8941d7f6fb3ce5a8c9fa4fa8a
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Feb 14 15:01:10 2013 +1100

    selftest: Do an ldapcmp run against the upgraded domain
    
    This checks (with a set of known issues marked in the --filter attribute) that the upgraded
    domain matches a fresh provision.
    
    Andrew Bartlett
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 72f73ebaff8d75fc39770ec785964b0d3c9738cc)

commit ce88c359b8184687e05e49e5eaf01a32b1a68daa
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Feb 14 15:00:01 2013 +1100

    samba-tool ldapcmp: Add support for checking DNSDOMAIN and DNSFOREST by default
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 24c4d818d14c3931cf0cbff3070685fe409e66c6)

commit b530c264305826c2e655a3f87a9633c70eca1c95
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Feb 11 08:25:41 2013 +1100

    samba-tool dbcheck: fix msDS-HasInstantiatedNCs attributes to match instanceType on our ntdsDSA
    
    This value is only a link to the local value of intanceType on our server, so only fix it for our server.
    
    Andrew Bartlett
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit f508435d23445a8b3076f89cbe042e2da1ac0701)

commit db6b93916444f44708af0bdabd6f4d002630c834
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Fri Mar 1 17:29:09 2013 +1100

    scripting: Correct parsing of binary DN
    
    The DN is of the form B:8:01020304:DC=samba,DC=example,DC=com.  We need
    to account for the case where the 8 is actually (say) 16, and so not just
    one character.
    
    Andrew Bartlett
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 97389c3ec24526837e91fcfcaf7439491fcdb214)

commit 8bdc63c0fb004093212cc737db773ab9b27459e0
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Feb 16 09:36:07 2013 +1100

    subunit: Add a sh macro for skipping a test
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 0180a027cbc9725ae13023ddfdb8079f147864c5)

commit 48ac177c081b2be8bfbef64b1f14163c6c068916
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Thu Feb 14 14:59:28 2013 +1100

    samba-tool ldapcmp: Add --skip-missing-dn to not error on DNs present in one DB but not the other
    
    This is needed to compare some parts of the database, particularly in --two mode, which
    are just never going to have exactly the same DNs.
    
    Andrew Bartlett
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 606f5d6cc6b018259ba0306fe3b55e21b4b70fdb)

commit fc4589d1191d00d695dd33c3219b58c2ca453b5d
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Feb 12 09:20:03 2013 +1100

    samba-tool domain classicupgrade: Fix typo in error path for multiple account flags
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 161fa15697fab9effbe1db9640cece847dcf63cd)

commit e4712a538dbbd5a0866b23fab3de6b6d4f5920a5
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Jan 15 21:53:30 2013 +1100

    samba-tool domain classicupgrade: Print a better error when the ldap backend PW was not found
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 669c302f2d78ab4bbd35982373ae079246c8979d)

commit 9144f1bf0a85e166ef68202c2948b3f5975447c5
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Feb 11 14:50:49 2013 +1100

    samba-tool dbcheck: fix comment on err_wrong_sd
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 68f13f5d7e80f2041e140a12fc2f7139561c83ce)

commit 9485a38d191de393971929e8978a66da14ed2575
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Fri Dec 28 15:37:14 2012 +0100

    Move python modules from source4/scripting/python/ to python/.
    
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Sat Mar  2 03:57:34 CET 2013 on sn-devel-104
    (cherry picked from commit 87afc3aee1ea593069322a49355dd8780d99e123)

commit 0e880ebc70efa04e3bfa5455af2bb0b94aacf449
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Mar 2 10:58:50 2013 +1100

    build: Change bin/default/python -> bin/python symlink to bin/default/python_modules
    
    This avoids a collision with the new top level python directory.
    
    Andrew Bartlett
    (cherry picked from commit 80fce353e740c793619005ac102ab07fb5e7d280)

commit 7d13d38656efab943aca4db0456d2429e81e2170
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Mar 2 08:28:11 2013 +1100

    build: Rename samba_python waf node to avoid duplicate name
    
    This makes it clearer when debuging build issues.
    
    Andrew Bartlett
    (cherry picked from commit 2d13532cb3ad3a3deaee1f158408478284bc595a)

commit c14c2b9f7be6982bcd28731410cb1da89c7f519e
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Feb 11 14:46:43 2013 +1100

    dsdb-descriptor: Avoid segfault copying an SD without an owner or group
    
    This is an unusual SD, but it does exist is some very old upgraded databases.
    
    Andrew Bartlett
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    
    Autobuild-User(master): Stefan Metzmacher <metze at samba.org>
    Autobuild-Date(master): Fri Feb 22 11:06:17 CET 2013 on sn-devel-104
    (cherry picked from commit e4d85fa73d3ce1f397fdd416af6b8c903a473824)

commit 65cf47de48dcc9f22f1d3017a21e45e307beba42
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Mon Feb 11 14:45:57 2013 +1100

    dsdb-descriptor: Spell out security descriptor flags as constants
    
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 87db2331fc855473d8b3cad1c4149807823aa3c4)

commit 2fa152cc43f5be7b7f7d51642b9d3ef4289d3b00
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sun Feb 17 18:15:52 2013 +1100

    samba_upgradeprovision: Use tdb_util.tdb_copy not shutil.copy2
    
    This is really important, because copying a file will both ignore
    locks held by another process and break any locks we hold (due to
    POSIX brain-damage regarding multiple fds on one file in a process).
    
    By leaving this to tdbbackup in a child, both of these issues are avoided.
    
    Andrew Bartlett
    
    Reviewed-by: Matthieu Patou <mat at samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Tue Feb 19 07:48:18 CET 2013 on sn-devel-104
    (cherry picked from commit 2cf83f7c645e4b216cf6f23857fd72ec0e6ca7a6)

commit 116b8e605487a8bfa4ac4f4fc5167df03f5f486c
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sun Feb 17 18:41:00 2013 +1100

    samba_upgradeprovision: Do not update privileges.ldb any more (unchanged since 2009)
    
    This update was only a total oblitoration of the existing database
    and not a merge, and the shutil.copy would both disregard and break
    locks on the database that are held at this point.
    
    Andrew Bartlett
    
    Reviewed-by: Matthieu Patou <mat at samba.org>
    (cherry picked from commit 3c51e18a0cd1cb4b54cd29e312abd7cc2c0fbc98)

commit 3f5ae9bf5979b4528ff4bcbc7ede1b12300224fb
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sun Feb 17 18:14:06 2013 +1100

    scripting: Make tdb_copy a common util function in samba.tdb_util
    
    This will allow samba_upgradeprovision to also call it.
    
    Andrew Bartlett
    
    Reviewed-by: Matthieu Patou <mat at samba.org>
    (cherry picked from commit 396df64ef6f2c66c35989ecda3e564d5578fe9f3)

commit 157cfd05ea18482f5ac7537bfcea5195a932eb44
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sun Feb 17 17:57:42 2013 +1100

    scripting: Make tdb_copy use the python subprocess module
    
    This makes the code more robust to spaces in the file names (etc).
    
    Andrew Bartlett
    
    Reviewed-by: Matthieu Patou <mat at samba.org>
    (cherry picked from commit 2c2759e408d9c45c2aee0c2578f45edd246afec3)

commit 58de5187ea9b796efc895230d72132cab43c9874
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Sat Feb 16 08:51:51 2013 +1100

    samba_upgradeprovision: Remove options to fix FS ACLs
    
    samba-tool ntacl sysvolreset handles this better, and makes this tool
    much less confusing internally.
    
    Andrew Bartlett
    
    Reviewed-by: Matthieu Patou <mat at samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Tue Feb 19 06:06:41 CET 2013 on sn-devel-104
    (cherry picked from commit 06780ae82281fb62a08d0c3604d2e679976756c2)

commit 607d33ba903cc27d399d0d3247603e66593eb8af
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Mar 18 09:36:17 2013 +0100

    wkssvc: Fix bug 9727, NULL pointer dereference
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    
    Autobuild-User(master): Michael Adam <obnox at samba.org>
    Autobuild-Date(master): Mon Mar 18 11:39:27 CET 2013 on sn-devel-104
    (cherry picked from commit 05a7a10c88be99d864eacd6f9d37a340022f01f6)

commit 4d09fb7c2bcdc7f9b049a85420b061abcef42721
Author: Stefan Metzmacher <metze at samba.org>
Date:   Mon Mar 18 11:52:50 2013 +0000

    s3:waf fix build on AIX
    
    AIX acl code needs to be built by default on AIX,
    otherwise smbd will fail to start because of missing symbols
    
    This fixes Bug 9557 - build succeeds, but binaries don't run
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Christian Ambach <ambi at samba.org>
    
    Autobuild-User(master): Christian Ambach <ambi at samba.org>
    Autobuild-Date(master): Thu Mar 21 16:31:19 CET 2013 on sn-devel-104
    (cherry picked from commit 1f139ae2d162ebb045ce4eabb76a138baedfe44a)

-----------------------------------------------------------------------

Summary of changes:
 buildtools/wafsamba/samba_python.py                |    2 +-
 buildtools/wafsamba/wafsamba.py                    |    6 +-
 libcli/nbt/pynbt.c                                 |    2 +-
 nsswitch/pam_winbind.c                             |    2 +-
 .../python => python}/examples/dnsserver.py        |    0
 .../python => python}/examples/netbios.py          |    0
 .../scripting/python => python}/examples/samr.py   |    0
 .../scripting/python => python}/examples/winreg.py |    0
 python/modules.c                                   |   63 +
 {source4/scripting/python => python}/modules.h     |    0
 {source4/scripting/python => python}/pyglue.c      |    0
 .../scripting/python => python}/samba/__init__.py  |    0
 python/samba/common.py                             |   99 +
 python/samba/dbchecker.py                          | 1085 +
 python/samba/descriptor.py                         |  581 +
 .../scripting/python => python}/samba/drs_utils.py |    0
 .../scripting/python => python}/samba/getopt.py    |    0
 .../python => python}/samba/hostconfig.py          |    0
 .../scripting/python => python}/samba/idmap.py     |    0
 {source4/scripting/python => python}/samba/join.py |    0
 .../scripting/python => python}/samba/kcc_utils.py |    0
 .../samba/ms_display_specifiers.py                 |    0
 .../scripting/python => python}/samba/ms_schema.py |    0
 {source4/scripting/python => python}/samba/ndr.py  |    0
 .../python => python}/samba/netcmd/__init__.py     |    0
 .../python => python}/samba/netcmd/common.py       |    0
 python/samba/netcmd/dbcheck.py                     |  146 +
 .../python => python}/samba/netcmd/delegation.py   |    0
 .../python => python}/samba/netcmd/dns.py          |    0
 .../python => python}/samba/netcmd/domain.py       |    0
 .../python => python}/samba/netcmd/drs.py          |    0
 .../python => python}/samba/netcmd/dsacl.py        |    0
 .../python => python}/samba/netcmd/fsmo.py         |    0
 .../python => python}/samba/netcmd/gpo.py          |    0
 .../python => python}/samba/netcmd/group.py        |    0
 python/samba/netcmd/ldapcmp.py                     |  964 +
 .../python => python}/samba/netcmd/main.py         |    0
 .../python => python}/samba/netcmd/ntacl.py        |    0
 .../python => python}/samba/netcmd/processes.py    |    0
 .../python => python}/samba/netcmd/rodc.py         |    0
 .../python => python}/samba/netcmd/sites.py        |    0
 .../python => python}/samba/netcmd/spn.py          |    0
 .../python => python}/samba/netcmd/testparm.py     |    0
 .../python => python}/samba/netcmd/time.py         |    0
 .../python => python}/samba/netcmd/user.py         |    0
 .../python => python}/samba/netcmd/vampire.py      |    0
 .../scripting/python => python}/samba/ntacls.py    |    0
 python/samba/provision/__init__.py                 | 2269 +
 .../python => python}/samba/provision/backend.py   |    0
 .../python => python}/samba/provision/common.py    |    0
 python/samba/provision/sambadns.py                 | 1135 +
 .../python => python}/samba/samba3/__init__.py     |    0
 .../scripting/python => python}/samba/samdb.py     |    0
 .../scripting/python => python}/samba/schema.py    |    0
 .../scripting/python => python}/samba/sd_utils.py  |    0
 .../scripting/python => python}/samba/sites.py     |    0
 python/samba/tdb_util.py                           |   41 +
 .../python => python}/samba/tests/__init__.py      |    0
 .../python => python}/samba/tests/auth.py          |    0
 .../samba/tests/blackbox/__init__.py               |    0
 .../samba/tests/blackbox/ndrdump.py                |    0
 .../samba/tests/blackbox/samba_tool_drs.py         |    0
 .../python => python}/samba/tests/common.py        |    0
 .../python => python}/samba/tests/core.py          |    0
 .../python => python}/samba/tests/credentials.py   |    0
 .../samba/tests/dcerpc/__init__.py                 |    0
 .../python => python}/samba/tests/dcerpc/bare.py   |    0
 .../samba/tests/dcerpc/dnsserver.py                |    0
 .../python => python}/samba/tests/dcerpc/misc.py   |    0
 .../samba/tests/dcerpc/registry.py                 |    0
 .../samba/tests/dcerpc/rpc_talloc.py               |    0
 .../samba/tests/dcerpc/rpcecho.py                  |    0
 .../python => python}/samba/tests/dcerpc/sam.py    |    0
 .../python => python}/samba/tests/dcerpc/srvsvc.py |    0
 .../samba/tests/dcerpc/testrpc.py                  |    0
 .../python => python}/samba/tests/dcerpc/unix.py   |    0
 .../scripting/python => python}/samba/tests/dns.py |    0
 .../python => python}/samba/tests/docs.py          |    0
 .../python => python}/samba/tests/dsdb.py          |    0
 .../python => python}/samba/tests/gensec.py        |    0
 .../python => python}/samba/tests/getopt.py        |    0
 .../python => python}/samba/tests/hostconfig.py    |    0
 .../samba/tests/libsmb_samba_internal.py           |    0
 .../python => python}/samba/tests/messaging.py     |    0
 .../python => python}/samba/tests/netcmd.py        |    0
 .../python => python}/samba/tests/ntacls.py        |    0
 .../python => python}/samba/tests/param.py         |    0
 .../python => python}/samba/tests/policy.py        |    0
 .../python => python}/samba/tests/posixacl.py      |    0
 .../python => python}/samba/tests/provision.py     |    0
 .../python => python}/samba/tests/registry.py      |    0
 .../python => python}/samba/tests/samba3.py        |    0
 .../python => python}/samba/tests/samba3sam.py     |    0
 .../samba/tests/samba_tool/__init__.py             |    0
 .../samba/tests/samba_tool/base.py                 |    0
 .../samba/tests/samba_tool/gpo.py                  |    0
 .../samba/tests/samba_tool/group.py                |    0
 .../samba/tests/samba_tool/ntacl.py                |    0
 .../samba/tests/samba_tool/processes.py            |    0
 .../samba/tests/samba_tool/timecmd.py              |    0
 .../samba/tests/samba_tool/user.py                 |    0
 .../python => python}/samba/tests/samdb.py         |    0
 .../python => python}/samba/tests/security.py      |    0
 .../python => python}/samba/tests/source.py        |    0
 .../python => python}/samba/tests/strings.py       |    0
 .../python => python}/samba/tests/unicodenames.py  |    0
 .../python => python}/samba/tests/upgrade.py       |    0
 python/samba/tests/upgradeprovision.py             |  156 +
 .../samba/tests/upgradeprovisionneeddc.py          |    0
 .../python => python}/samba/tests/xattr.py         |    0
 python/samba/upgrade.py                            |  935 +
 python/samba/upgradehelpers.py                     |  798 +
 .../python => python}/samba/web_server/__init__.py |    0
 .../scripting/python => python}/samba/xattr.py     |    0
 .../python => python}/samba_external/README        |    0
 {source4/scripting/python => python}/uuidmodule.c  |    0
 python/wscript_build                               |   39 +
 selftest/knownfail                                 |    3 +
 selftest/tests.py                                  |    6 +-
 source3/modules/wscript_build                      |    2 +-
 source3/rpc_server/epmapper/srv_epmapper.c         |    2 +-
 source3/rpc_server/rpc_ep_register.c               |    4 +
 source3/rpc_server/wkssvc/srv_wkssvc_nt.c          |    8 +-
 source3/smbd/conn_idle.c                           |    3 +
 source3/smbd/dir.c                                 |   25 +-
 source3/smbd/reply.c                               |   30 +-
 source3/smbd/smb2_server.c                         |   10 +-
 source4/auth/gensec/pygensec.c                     |    2 +-
 source4/dsdb/samdb/ldb_modules/acl_util.c          |    2 +-
 source4/dsdb/samdb/ldb_modules/descriptor.c        |   18 +-
 source4/lib/messaging/pymessaging.c                |    2 +-
 source4/param/provision.c                          |    2 +-
 source4/scripting/bin/samba_upgradedns             |   16 +-
 source4/scripting/bin/samba_upgradeprovision       |  709 +-
 source4/scripting/bin/subunitrun                   |    2 +-
 source4/scripting/python/modules.c                 |   63 -
 source4/scripting/python/samba/common.py           |   99 -
 source4/scripting/python/samba/dbchecker.py        |  947 -
 source4/scripting/python/samba/netcmd/dbcheck.py   |  143 -
 source4/scripting/python/samba/netcmd/ldapcmp.py   |  998 -
 .../scripting/python/samba/provision/__init__.py   | 2270 -
 .../scripting/python/samba/provision/descriptor.py |  359 -
 .../scripting/python/samba/provision/sambadns.py   | 1152 -
 .../python/samba/tests/upgradeprovision.py         |  135 -
 source4/scripting/python/samba/upgrade.py          |  932 -
 source4/scripting/python/samba/upgradehelpers.py   |  960 -
 source4/scripting/python/wscript_build             |   39 -
 .../provisions/release-4-0-0/etc/smb.conf.template |   17 +
 .../release-4-0-0/private}/dns_update_list         |    0
 .../provisions/release-4-0-0/private/eadb.tdb.dump |   96 +
 .../provisions/release-4-0-0/private/hklm.ldb.dump |   80 +
 .../release-4-0-0/private/idmap.ldb.dump           |   48 +
 .../provisions/release-4-0-0/private/krb5.conf     |    4 +
 .../release-4-0-0/private/privilege.ldb.dump       |  156 +
 ...C%3DRELEASE-4-0-0,DC%3DSAMBA,DC%3DCORP.ldb.dump |28980 +++++++++++++
 ...C%3DRELEASE-4-0-0,DC%3DSAMBA,DC%3DCORP.ldb.dump |43468 ++++++++++++++++++++
 ...C%3DRELEASE-4-0-0,DC%3DSAMBA,DC%3DCORP.ldb.dump |  928 +
 ...C%3DRELEASE-4-0-0,DC%3DSAMBA,DC%3DCORP.ldb.dump |  488 +
 ...C%3DRELEASE-4-0-0,DC%3DSAMBA,DC%3DCORP.ldb.dump | 5736 +++
 .../private/sam.ldb.d/metadata.tdb.dump            |    4 +
 .../provisions/release-4-0-0/private/sam.ldb.dump  |   40 +
 .../release-4-0-0/private/secrets.keytab           |  Bin 0 -> 1317 bytes
 .../release-4-0-0/private/secrets.ldb.dump         |   44 +
 .../release-4-0-0/private/secrets.tdb.dump         |   16 +
 .../release-4-0-0/private/share.ldb.dump           |   32 +
 .../release-4-0-0/private}/spn_update_list         |    0
 .../{31B2F340-016D-11D2-945F-00C04FB984F9}/GPT.INI |    2 +
 .../{6AC1786C-016F-11D2-945F-00C04FB984F9}/GPT.INI |    2 +
 source4/selftest/tests.py                          |    2 +-
 source4/setup/tests/blackbox_upgradeprovision.sh   |   42 +-
 source4/web_server/wsgi.c                          |    2 +-
 testprogs/blackbox/dbcheck-alpha13.sh              |   64 -
 testprogs/blackbox/dbcheck-oldrelease.sh           |  123 +
 testprogs/blackbox/dbcheck.sh                      |    6 +
 testprogs/blackbox/subunit.sh                      |   10 +
 testprogs/blackbox/upgradeprovision-alpha13.sh     |  135 -
 testprogs/blackbox/upgradeprovision-oldrelease.sh  |  222 +
 wscript_build                                      |    2 +-
 178 files changed, 89203 insertions(+), 8812 deletions(-)
 rename {source4/scripting/python => python}/examples/dnsserver.py (100%)
 rename {source4/scripting/python => python}/examples/netbios.py (100%)
 rename {source4/scripting/python => python}/examples/samr.py (100%)
 rename {source4/scripting/python => python}/examples/winreg.py (100%)
 create mode 100644 python/modules.c
 rename {source4/scripting/python => python}/modules.h (100%)
 rename {source4/scripting/python => python}/pyglue.c (100%)
 rename {source4/scripting/python => python}/samba/__init__.py (100%)
 create mode 100644 python/samba/common.py
 create mode 100644 python/samba/dbchecker.py
 create mode 100644 python/samba/descriptor.py
 rename {source4/scripting/python => python}/samba/drs_utils.py (100%)
 rename {source4/scripting/python => python}/samba/getopt.py (100%)
 rename {source4/scripting/python => python}/samba/hostconfig.py (100%)
 rename {source4/scripting/python => python}/samba/idmap.py (100%)
 rename {source4/scripting/python => python}/samba/join.py (100%)
 rename {source4/scripting/python => python}/samba/kcc_utils.py (100%)
 rename {source4/scripting/python => python}/samba/ms_display_specifiers.py (100%)
 rename {source4/scripting/python => python}/samba/ms_schema.py (100%)
 rename {source4/scripting/python => python}/samba/ndr.py (100%)
 rename {source4/scripting/python => python}/samba/netcmd/__init__.py (100%)
 rename {source4/scripting/python => python}/samba/netcmd/common.py (100%)
 create mode 100644 python/samba/netcmd/dbcheck.py
 rename {source4/scripting/python => python}/samba/netcmd/delegation.py (100%)
 rename {source4/scripting/python => python}/samba/netcmd/dns.py (100%)
 rename {source4/scripting/python => python}/samba/netcmd/domain.py (100%)
 rename {source4/scripting/python => python}/samba/netcmd/drs.py (100%)
 rename {source4/scripting/python => python}/samba/netcmd/dsacl.py (100%)
 rename {source4/scripting/python => python}/samba/netcmd/fsmo.py (100%)
 rename {source4/scripting/python => python}/samba/netcmd/gpo.py (100%)
 rename {source4/scripting/python => python}/samba/netcmd/group.py (100%)
 create mode 100644 python/samba/netcmd/ldapcmp.py
 rename {source4/scripting/python => python}/samba/netcmd/main.py (100%)
 rename {source4/scripting/python => python}/samba/netcmd/ntacl.py (100%)
 rename {source4/scripting/python => python}/samba/netcmd/processes.py (100%)
 rename {source4/scripting/python => python}/samba/netcmd/rodc.py (100%)
 rename {source4/scripting/python => python}/samba/netcmd/sites.py (100%)
 rename {source4/scripting/python => python}/samba/netcmd/spn.py (100%)
 rename {source4/scripting/python => python}/samba/netcmd/testparm.py (100%)
 rename {source4/scripting/python => python}/samba/netcmd/time.py (100%)
 rename {source4/scripting/python => python}/samba/netcmd/user.py (100%)
 rename {source4/scripting/python => python}/samba/netcmd/vampire.py (100%)
 rename {source4/scripting/python => python}/samba/ntacls.py (100%)
 create mode 100644 python/samba/provision/__init__.py
 rename {source4/scripting/python => python}/samba/provision/backend.py (100%)
 rename {source4/scripting/python => python}/samba/provision/common.py (100%)
 create mode 100644 python/samba/provision/sambadns.py
 rename {source4/scripting/python => python}/samba/samba3/__init__.py (100%)
 rename {source4/scripting/python => python}/samba/samdb.py (100%)
 rename {source4/scripting/python => python}/samba/schema.py (100%)
 rename {source4/scripting/python => python}/samba/sd_utils.py (100%)
 rename {source4/scripting/python => python}/samba/sites.py (100%)
 create mode 100644 python/samba/tdb_util.py
 rename {source4/scripting/python => python}/samba/tests/__init__.py (100%)
 rename {source4/scripting/python => python}/samba/tests/auth.py (100%)
 rename {source4/scripting/python => python}/samba/tests/blackbox/__init__.py (100%)
 rename {source4/scripting/python => python}/samba/tests/blackbox/ndrdump.py (100%)
 rename {source4/scripting/python => python}/samba/tests/blackbox/samba_tool_drs.py (100%)
 rename {source4/scripting/python => python}/samba/tests/common.py (100%)
 rename {source4/scripting/python => python}/samba/tests/core.py (100%)
 rename {source4/scripting/python => python}/samba/tests/credentials.py (100%)
 rename {source4/scripting/python => python}/samba/tests/dcerpc/__init__.py (100%)
 rename {source4/scripting/python => python}/samba/tests/dcerpc/bare.py (100%)
 rename {source4/scripting/python => python}/samba/tests/dcerpc/dnsserver.py (100%)
 rename {source4/scripting/python => python}/samba/tests/dcerpc/misc.py (100%)
 rename {source4/scripting/python => python}/samba/tests/dcerpc/registry.py (100%)
 rename {source4/scripting/python => python}/samba/tests/dcerpc/rpc_talloc.py (100%)
 rename {source4/scripting/python => python}/samba/tests/dcerpc/rpcecho.py (100%)
 rename {source4/scripting/python => python}/samba/tests/dcerpc/sam.py (100%)
 rename {source4/scripting/python => python}/samba/tests/dcerpc/srvsvc.py (100%)
 rename {source4/scripting/python => python}/samba/tests/dcerpc/testrpc.py (100%)
 rename {source4/scripting/python => python}/samba/tests/dcerpc/unix.py (100%)
 rename {source4/scripting/python => python}/samba/tests/dns.py (100%)
 rename {source4/scripting/python => python}/samba/tests/docs.py (100%)
 rename {source4/scripting/python => python}/samba/tests/dsdb.py (100%)
 rename {source4/scripting/python => python}/samba/tests/gensec.py (100%)
 rename {source4/scripting/python => python}/samba/tests/getopt.py (100%)
 rename {source4/scripting/python => python}/samba/tests/hostconfig.py (100%)
 rename {source4/scripting/python => python}/samba/tests/libsmb_samba_internal.py (100%)
 rename {source4/scripting/python => python}/samba/tests/messaging.py (100%)
 rename {source4/scripting/python => python}/samba/tests/netcmd.py (100%)
 rename {source4/scripting/python => python}/samba/tests/ntacls.py (100%)
 rename {source4/scripting/python => python}/samba/tests/param.py (100%)
 rename {source4/scripting/python => python}/samba/tests/policy.py (100%)
 rename {source4/scripting/python => python}/samba/tests/posixacl.py (100%)
 rename {source4/scripting/python => python}/samba/tests/provision.py (100%)
 rename {source4/scripting/python => python}/samba/tests/registry.py (100%)
 rename {source4/scripting/python => python}/samba/tests/samba3.py (100%)
 rename {source4/scripting/python => python}/samba/tests/samba3sam.py (100%)
 rename {source4/scripting/python => python}/samba/tests/samba_tool/__init__.py (100%)
 rename {source4/scripting/python => python}/samba/tests/samba_tool/base.py (100%)
 rename {source4/scripting/python => python}/samba/tests/samba_tool/gpo.py (100%)
 rename {source4/scripting/python => python}/samba/tests/samba_tool/group.py (100%)
 rename {source4/scripting/python => python}/samba/tests/samba_tool/ntacl.py (100%)
 rename {source4/scripting/python => python}/samba/tests/samba_tool/processes.py (100%)
 rename {source4/scripting/python => python}/samba/tests/samba_tool/timecmd.py (100%)
 rename {source4/scripting/python => python}/samba/tests/samba_tool/user.py (100%)
 rename {source4/scripting/python => python}/samba/tests/samdb.py (100%)
 rename {source4/scripting/python => python}/samba/tests/security.py (100%)
 rename {source4/scripting/python => python}/samba/tests/source.py (100%)
 rename {source4/scripting/python => python}/samba/tests/strings.py (100%)
 rename {source4/scripting/python => python}/samba/tests/unicodenames.py (100%)
 rename {source4/scripting/python => python}/samba/tests/upgrade.py (100%)
 create mode 100644 python/samba/tests/upgradeprovision.py
 rename {source4/scripting/python => python}/samba/tests/upgradeprovisionneeddc.py (100%)
 rename {source4/scripting/python => python}/samba/tests/xattr.py (100%)
 create mode 100644 python/samba/upgrade.py
 create mode 100644 python/samba/upgradehelpers.py
 rename {source4/scripting/python => python}/samba/web_server/__init__.py (100%)
 rename {source4/scripting/python => python}/samba/xattr.py (100%)
 rename {source4/scripting/python => python}/samba_external/README (100%)
 rename {source4/scripting/python => python}/uuidmodule.c (100%)
 create mode 100644 python/wscript_build
 delete mode 100644 source4/scripting/python/modules.c
 delete mode 100644 source4/scripting/python/samba/common.py
 delete mode 100644 source4/scripting/python/samba/dbchecker.py
 delete mode 100644 source4/scripting/python/samba/netcmd/dbcheck.py
 delete mode 100644 source4/scripting/python/samba/netcmd/ldapcmp.py
 delete mode 100644 source4/scripting/python/samba/provision/__init__.py
 delete mode 100644 source4/scripting/python/samba/provision/descriptor.py
 delete mode 100644 source4/scripting/python/samba/provision/sambadns.py
 delete mode 100644 source4/scripting/python/samba/tests/upgradeprovision.py
 delete mode 100644 source4/scripting/python/samba/upgrade.py
 delete mode 100644 source4/scripting/python/samba/upgradehelpers.py
 delete mode 100644 source4/scripting/python/wscript_build
 create mode 100644 source4/selftest/provisions/release-4-0-0/etc/smb.conf.template
 copy source4/{setup => selftest/provisions/release-4-0-0/private}/dns_update_list (100%)
 create mode 100644 source4/selftest/provisions/release-4-0-0/private/eadb.tdb.dump
 create mode 100644 source4/selftest/provisions/release-4-0-0/private/hklm.ldb.dump
 create mode 100644 source4/selftest/provisions/release-4-0-0/private/idmap.ldb.dump
 create mode 100644 source4/selftest/provisions/release-4-0-0/private/krb5.conf
 create mode 100644 source4/selftest/provisions/release-4-0-0/private/privilege.ldb.dump
 create mode 100644 source4/selftest/provisions/release-4-0-0/private/sam.ldb.d/CN%3DCONFIGURATION,DC%3DRELEASE-4-0-0,DC%3DSAMBA,DC%3DCORP.ldb.dump
 create mode 100644 source4/selftest/provisions/release-4-0-0/private/sam.ldb.d/CN%3DSCHEMA,CN%3DCONFIGURATION,DC%3DRELEASE-4-0-0,DC%3DSAMBA,DC%3DCORP.ldb.dump
 create mode 100644 source4/selftest/provisions/release-4-0-0/private/sam.ldb.d/DC%3DDOMAINDNSZONES,DC%3DRELEASE-4-0-0,DC%3DSAMBA,DC%3DCORP.ldb.dump
 create mode 100644 source4/selftest/provisions/release-4-0-0/private/sam.ldb.d/DC%3DFORESTDNSZONES,DC%3DRELEASE-4-0-0,DC%3DSAMBA,DC%3DCORP.ldb.dump
 create mode 100644 source4/selftest/provisions/release-4-0-0/private/sam.ldb.d/DC%3DRELEASE-4-0-0,DC%3DSAMBA,DC%3DCORP.ldb.dump
 create mode 100644 source4/selftest/provisions/release-4-0-0/private/sam.ldb.d/metadata.tdb.dump
 create mode 100644 source4/selftest/provisions/release-4-0-0/private/sam.ldb.dump
 create mode 100644 source4/selftest/provisions/release-4-0-0/private/secrets.keytab
 create mode 100644 source4/selftest/provisions/release-4-0-0/private/secrets.ldb.dump
 create mode 100644 source4/selftest/provisions/release-4-0-0/private/secrets.tdb.dump
 create mode 100644 source4/selftest/provisions/release-4-0-0/private/share.ldb.dump
 copy source4/{setup => selftest/provisions/release-4-0-0/private}/spn_update_list (100%)
 create mode 100644 source4/selftest/provisions/release-4-0-0/sysvol/release-4-0-0.samba.corp/Policies/{31B2F340-016D-11D2-945F-00C04FB984F9}/GPT.INI
 create mode 100644 source4/selftest/provisions/release-4-0-0/sysvol/release-4-0-0.samba.corp/Policies/{6AC1786C-016F-11D2-945F-00C04FB984F9}/GPT.INI
 delete mode 100755 testprogs/blackbox/dbcheck-alpha13.sh
 create mode 100755 testprogs/blackbox/dbcheck-oldrelease.sh
 delete mode 100755 testprogs/blackbox/upgradeprovision-alpha13.sh
 create mode 100755 testprogs/blackbox/upgradeprovision-oldrelease.sh


Changeset truncated at 500 lines:

diff --git a/buildtools/wafsamba/samba_python.py b/buildtools/wafsamba/samba_python.py
index 6bc32f0..b2172f7 100644
--- a/buildtools/wafsamba/samba_python.py
+++ b/buildtools/wafsamba/samba_python.py
@@ -35,7 +35,7 @@ def SAMBA_PYTHON(bld, name,
     source = bld.EXPAND_VARIABLES(source, vars=vars)
 
     if realname is not None:
-        link_name = 'python/%s' % realname
+        link_name = 'python_modules/%s' % realname
     else:
         link_name = None
 
diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py
index dcbb047..f7156ec 100644
--- a/buildtools/wafsamba/wafsamba.py
+++ b/buildtools/wafsamba/wafsamba.py
@@ -64,10 +64,10 @@ def SAMBA_BUILD_ENV(conf):
     # this allows all of the bin/shared and bin/python targets
     # to be expressed in terms of build directory paths
     mkdir_p(os.path.join(conf.blddir, 'default'))
-    for p in ['python','shared', 'modules']:
-        link_target = os.path.join(conf.blddir, 'default/' + p)
+    for (source, target) in [('shared', 'shared'), ('modules', 'modules'), ('python', 'python_modules')]:
+        link_target = os.path.join(conf.blddir, 'default/' + target)
         if not os.path.lexists(link_target):
-            os.symlink('../' + p, link_target)
+            os.symlink('../' + source, link_target)
 
     # get perl to put the blib files in the build directory
     blib_bld = os.path.join(conf.blddir, 'default/pidl/blib')
diff --git a/libcli/nbt/pynbt.c b/libcli/nbt/pynbt.c
index 0bba2ec..8074fb6 100644
--- a/libcli/nbt/pynbt.c
+++ b/libcli/nbt/pynbt.c
@@ -20,7 +20,7 @@
 #include <Python.h>
 #include "includes.h"
 #include "libcli/util/pyerrors.h"
-#include "scripting/python/modules.h"
+#include "python/modules.h"
 #include "../libcli/nbt/libnbt.h"
 #include "lib/events/events.h"
 
diff --git a/nsswitch/pam_winbind.c b/nsswitch/pam_winbind.c
index 29d6f7c..1cc6b83 100644
--- a/nsswitch/pam_winbind.c
+++ b/nsswitch/pam_winbind.c
@@ -2449,7 +2449,7 @@ static char* winbind_upn_to_username(struct pwb_context *ctx,
 		return NULL;
 	}
 
-	return talloc_asprintf(ctx, "%s\\%s", domain, name);
+	return talloc_asprintf(ctx, "%s%c%s", domain, sep, name);
 }
 
 static int _pam_delete_cred(pam_handle_t *pamh, int flags,
diff --git a/source4/scripting/python/examples/dnsserver.py b/python/examples/dnsserver.py
similarity index 100%
rename from source4/scripting/python/examples/dnsserver.py
rename to python/examples/dnsserver.py
diff --git a/source4/scripting/python/examples/netbios.py b/python/examples/netbios.py
similarity index 100%
rename from source4/scripting/python/examples/netbios.py
rename to python/examples/netbios.py
diff --git a/source4/scripting/python/examples/samr.py b/python/examples/samr.py
similarity index 100%
rename from source4/scripting/python/examples/samr.py
rename to python/examples/samr.py
diff --git a/source4/scripting/python/examples/winreg.py b/python/examples/winreg.py
similarity index 100%
rename from source4/scripting/python/examples/winreg.py
rename to python/examples/winreg.py
diff --git a/python/modules.c b/python/modules.c
new file mode 100644
index 0000000..371f0d5
--- /dev/null
+++ b/python/modules.c
@@ -0,0 +1,63 @@
+/* 
+   Unix SMB/CIFS implementation.
+   Samba utility functions
+   Copyright (C) Jelmer Vernooij <jelmer at samba.org> 2007
+   
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+   
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+   
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <Python.h>
+#include "includes.h"
+#include "python/modules.h"
+#include "dynconfig/dynconfig.h"
+
+static bool PySys_PathPrepend(PyObject *list, const char *path)
+{
+	PyObject *py_path = PyString_FromString(path);
+	if (py_path == NULL)
+		return false;
+
+	return (PyList_Insert(list, 0, py_path) == 0);
+}
+
+bool py_update_path(void)
+{
+	PyObject *mod_sys, *py_path;
+
+	mod_sys = PyImport_ImportModule("sys");
+	if (mod_sys == NULL) {
+		return false;
+	}
+
+	py_path = PyObject_GetAttrString(mod_sys, "path");
+	if (py_path == NULL) {
+		return false;
+	}	
+
+	if (!PyList_Check(py_path)) {
+		return false;
+	}
+
+	if (!PySys_PathPrepend(py_path, dyn_PYTHONDIR)) {
+		return false;
+	}
+
+	if (strcmp(dyn_PYTHONARCHDIR, dyn_PYTHONDIR) != 0) {
+		if (!PySys_PathPrepend(py_path, dyn_PYTHONARCHDIR)) {
+			return false;
+		}
+	}
+
+	return true;
+}
diff --git a/source4/scripting/python/modules.h b/python/modules.h
similarity index 100%
rename from source4/scripting/python/modules.h
rename to python/modules.h
diff --git a/source4/scripting/python/pyglue.c b/python/pyglue.c
similarity index 100%
rename from source4/scripting/python/pyglue.c
rename to python/pyglue.c
diff --git a/source4/scripting/python/samba/__init__.py b/python/samba/__init__.py
similarity index 100%
rename from source4/scripting/python/samba/__init__.py
rename to python/samba/__init__.py
diff --git a/python/samba/common.py b/python/samba/common.py
new file mode 100644
index 0000000..c2a3584
--- /dev/null
+++ b/python/samba/common.py
@@ -0,0 +1,99 @@
+# Samba common functions
+#
+# Copyright (C) Matthieu Patou <mat at matws.net>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+
+import ldb
+import dsdb
+
+
+def confirm(msg, forced=False, allow_all=False):
+    """confirm an action with the user
+
+    :param msg: A string to print to the user
+    :param forced: Are the answer forced
+    """
+    if forced:
+        print("%s [YES]" % msg)
+        return True
+
+    mapping = {
+        'Y': True,
+        'YES': True,
+        '': False,
+        'N': False,
+        'NO': False,
+        }
+
+    prompt = '[y/N]'
+
+    if allow_all:
+        mapping['ALL'] = 'ALL'
+        mapping['NONE'] = 'NONE'
+        prompt = '[y/N/all/none]'
+
+    while True:
+        v = raw_input(msg + ' %s ' % prompt)
+        v = v.upper()
+        if v in mapping:
+            return mapping[v]
+        print("Unknown response '%s'" % v)
+
+
+def normalise_int32(ivalue):
+    '''normalise a ldap integer to signed 32 bit'''
+    if int(ivalue) & 0x80000000 and int(ivalue) > 0:
+        return str(int(ivalue) - 0x100000000)
+    return str(ivalue)
+
+
+class dsdb_Dn(object):
+    '''a class for binary DN'''
+
+    def __init__(self, samdb, dnstring, syntax_oid=None):
+        '''create a dsdb_Dn'''
+        if syntax_oid is None:
+            # auto-detect based on string
+            if dnstring.startswith("B:"):
+                syntax_oid = dsdb.DSDB_SYNTAX_BINARY_DN
+            elif dnstring.startswith("S:"):
+                syntax_oid = dsdb.DSDB_SYNTAX_STRING_DN
+            else:
+                syntax_oid = dsdb.DSDB_SYNTAX_OR_NAME
+        if syntax_oid in [dsdb.DSDB_SYNTAX_BINARY_DN, dsdb.DSDB_SYNTAX_STRING_DN]:
+            # it is a binary DN
+            colons = dnstring.split(':')
+            if len(colons) < 4:
+                raise RuntimeError("Invalid DN %s" % dnstring)
+            prefix_len = 4 + len(colons[1]) + int(colons[1])
+            self.prefix = dnstring[0:prefix_len]
+            self.binary = self.prefix[3+len(colons[1]):-1]
+            self.dnstring = dnstring[prefix_len:]
+        else:
+            self.dnstring = dnstring
+            self.prefix = ''
+            self.binary = ''
+        self.dn = ldb.Dn(samdb, self.dnstring)
+
+    def __str__(self):
+        return self.prefix + str(self.dn.extended_str(mode=1))
+
+    def get_binary_integer(self):
+        '''return binary part of a dsdb_Dn as an integer, or None'''
+        if self.prefix == '':
+            return None
+        return int(self.binary, 16)
diff --git a/python/samba/dbchecker.py b/python/samba/dbchecker.py
new file mode 100644
index 0000000..d0d0ab3
--- /dev/null
+++ b/python/samba/dbchecker.py
@@ -0,0 +1,1085 @@
+# Samba4 AD database checker
+#
+# Copyright (C) Andrew Tridgell 2011
+# Copyright (C) Matthieu Patou <mat at matws.net> 2011
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+import ldb
+from samba import dsdb
+from samba import common
+from samba.dcerpc import misc
+from samba.ndr import ndr_unpack, ndr_pack
+from samba.dcerpc import drsblobs
+from samba.common import dsdb_Dn
+from samba.dcerpc import security
+from samba.descriptor import get_wellknown_sds, get_diff_sds
+from samba.auth import system_session, admin_session
+
+
+class dbcheck(object):
+    """check a SAM database for errors"""
+
+    def __init__(self, samdb, samdb_schema=None, verbose=False, fix=False,
+                 yes=False, quiet=False, in_transaction=False,
+                 reset_well_known_acls=False):
+        self.samdb = samdb
+        self.dict_oid_name = None
+        self.samdb_schema = (samdb_schema or samdb)
+        self.verbose = verbose
+        self.fix = fix
+        self.yes = yes
+        self.quiet = quiet
+        self.remove_all_unknown_attributes = False
+        self.remove_all_empty_attributes = False
+        self.fix_all_normalisation = False
+        self.fix_all_DN_GUIDs = False
+        self.fix_all_binary_dn = False
+        self.remove_all_deleted_DN_links = False
+        self.fix_all_target_mismatch = False
+        self.fix_all_metadata = False
+        self.fix_time_metadata = False
+        self.fix_all_missing_backlinks = False
+        self.fix_all_orphaned_backlinks = False
+        self.fix_rmd_flags = False
+        self.fix_ntsecuritydescriptor = False
+        self.fix_ntsecuritydescriptor_owner_group = False
+        self.seize_fsmo_role = False
+        self.move_to_lost_and_found = False
+        self.fix_instancetype = False
+        self.reset_well_known_acls = reset_well_known_acls
+        self.reset_all_well_known_acls = False
+        self.in_transaction = in_transaction
+        self.infrastructure_dn = ldb.Dn(samdb, "CN=Infrastructure," + samdb.domain_dn())
+        self.naming_dn = ldb.Dn(samdb, "CN=Partitions,%s" % samdb.get_config_basedn())
+        self.schema_dn = samdb.get_schema_basedn()
+        self.rid_dn = ldb.Dn(samdb, "CN=RID Manager$,CN=System," + samdb.domain_dn())
+        self.ntds_dsa = ldb.Dn(samdb, samdb.get_dsServiceName())
+        self.class_schemaIDGUID = {}
+        self.wellknown_sds = get_wellknown_sds(self.samdb)
+
+        self.name_map = {}
+        try:
+            res = samdb.search(base="CN=DnsAdmins,CN=Users,%s" % samdb.domain_dn(), scope=ldb.SCOPE_BASE,
+                           attrs=["objectSid"])
+            dnsadmins_sid = ndr_unpack(security.dom_sid, res[0]["objectSid"][0])
+            self.name_map['DnsAdmins'] = str(dnsadmins_sid)
+        except ldb.LdbError, (enum, estr):
+            if enum != ldb.ERR_NO_SUCH_OBJECT:
+                raise
+            pass
+
+        self.system_session_info = system_session()
+        self.admin_session_info = admin_session(None, samdb.get_domain_sid())
+
+        res = self.samdb.search(base=self.ntds_dsa, scope=ldb.SCOPE_BASE, attrs=['msDS-hasMasterNCs', 'hasMasterNCs'])
+        if "msDS-hasMasterNCs" in res[0]:
+            self.write_ncs = res[0]["msDS-hasMasterNCs"]
+        else:
+            # If the Forest Level is less than 2003 then there is no
+            # msDS-hasMasterNCs, so we fall back to hasMasterNCs
+            # no need to merge as all the NCs that are in hasMasterNCs must
+            # also be in msDS-hasMasterNCs (but not the opposite)
+            if "hasMasterNCs" in res[0]:
+                self.write_ncs = res[0]["hasMasterNCs"]
+            else:
+                self.write_ncs = None
+
+
+    def check_database(self, DN=None, scope=ldb.SCOPE_SUBTREE, controls=[], attrs=['*']):
+        '''perform a database check, returning the number of errors found'''
+
+        res = self.samdb.search(base=DN, scope=scope, attrs=['dn'], controls=controls)
+        self.report('Checking %u objects' % len(res))
+        error_count = 0
+
+        for object in res:
+            error_count += self.check_object(object.dn, attrs=attrs)
+
+        if DN is None:
+            error_count += self.check_rootdse()
+
+        if error_count != 0 and not self.fix:
+            self.report("Please use --fix to fix these errors")
+
+        self.report('Checked %u objects (%u errors)' % (len(res), error_count))
+        return error_count
+
+    def report(self, msg):
+        '''print a message unless quiet is set'''
+        if not self.quiet:
+            print(msg)
+
+    def confirm(self, msg, allow_all=False, forced=False):
+        '''confirm a change'''
+        if not self.fix:
+            return False
+        if self.quiet:
+            return self.yes
+        if self.yes:
+            forced = True
+        return common.confirm(msg, forced=forced, allow_all=allow_all)
+
+    ################################################################
+    # a local confirm function with support for 'all'
+    def confirm_all(self, msg, all_attr):
+        '''confirm a change with support for "all" '''
+        if not self.fix:
+            return False
+        if self.quiet:
+            return self.yes
+        if getattr(self, all_attr) == 'NONE':
+            return False
+        if getattr(self, all_attr) == 'ALL':
+            forced = True
+        else:
+            forced = self.yes
+        c = common.confirm(msg, forced=forced, allow_all=True)
+        if c == 'ALL':
+            setattr(self, all_attr, 'ALL')
+            return True
+        if c == 'NONE':
+            setattr(self, all_attr, 'NONE')
+            return False
+        return c
+
+    def do_modify(self, m, controls, msg, validate=True):
+        '''perform a modify with optional verbose output'''
+        if self.verbose:
+            self.report(self.samdb.write_ldif(m, ldb.CHANGETYPE_MODIFY))
+        try:
+            controls = controls + ["local_oid:%s:0" % dsdb.DSDB_CONTROL_DBCHECK]
+            self.samdb.modify(m, controls=controls, validate=validate)
+        except Exception, err:
+            self.report("%s : %s" % (msg, err))
+            return False
+        return True
+
+    def do_rename(self, from_dn, to_rdn, to_base, controls, msg):
+        '''perform a modify with optional verbose output'''
+        if self.verbose:
+            self.report("""dn: %s
+changeType: modrdn
+newrdn: %s
+deleteOldRdn: 1
+newSuperior: %s""" % (str(from_dn), str(to_rdn), str(to_base)))
+        try:
+            to_dn = to_rdn + to_base
+            controls = controls + ["local_oid:%s:0" % dsdb.DSDB_CONTROL_DBCHECK]
+            self.samdb.rename(from_dn, to_dn, controls=controls)
+        except Exception, err:
+            self.report("%s : %s" % (msg, err))
+            return False
+        return True
+
+    def err_empty_attribute(self, dn, attrname):
+        '''fix empty attributes'''
+        self.report("ERROR: Empty attribute %s in %s" % (attrname, dn))
+        if not self.confirm_all('Remove empty attribute %s from %s?' % (attrname, dn), 'remove_all_empty_attributes'):
+            self.report("Not fixing empty attribute %s" % attrname)
+            return
+
+        m = ldb.Message()
+        m.dn = dn
+        m[attrname] = ldb.MessageElement('', ldb.FLAG_MOD_DELETE, attrname)
+        if self.do_modify(m, ["relax:0", "show_recycled:1"],
+                          "Failed to remove empty attribute %s" % attrname, validate=False):
+            self.report("Removed empty attribute %s" % attrname)
+
+    def err_normalise_mismatch(self, dn, attrname, values):
+        '''fix attribute normalisation errors'''
+        self.report("ERROR: Normalisation error for attribute %s in %s" % (attrname, dn))
+        mod_list = []
+        for val in values:
+            normalised = self.samdb.dsdb_normalise_attributes(
+                self.samdb_schema, attrname, [val])
+            if len(normalised) != 1:
+                self.report("Unable to normalise value '%s'" % val)
+                mod_list.append((val, ''))
+            elif (normalised[0] != val):
+                self.report("value '%s' should be '%s'" % (val, normalised[0]))
+                mod_list.append((val, normalised[0]))
+        if not self.confirm_all('Fix normalisation for %s from %s?' % (attrname, dn), 'fix_all_normalisation'):
+            self.report("Not fixing attribute %s" % attrname)
+            return
+
+        m = ldb.Message()
+        m.dn = dn
+        for i in range(0, len(mod_list)):
+            (val, nval) = mod_list[i]
+            m['value_%u' % i] = ldb.MessageElement(val, ldb.FLAG_MOD_DELETE, attrname)
+            if nval != '':
+                m['normv_%u' % i] = ldb.MessageElement(nval, ldb.FLAG_MOD_ADD,
+                    attrname)
+
+        if self.do_modify(m, ["relax:0", "show_recycled:1"],
+                          "Failed to normalise attribute %s" % attrname,
+                          validate=False):
+            self.report("Normalised attribute %s" % attrname)
+
+    def err_normalise_mismatch_replace(self, dn, attrname, values):
+        '''fix attribute normalisation errors'''
+        normalised = self.samdb.dsdb_normalise_attributes(self.samdb_schema, attrname, values)
+        self.report("ERROR: Normalisation error for attribute '%s' in '%s'" % (attrname, dn))


-- 
Samba Shared Repository


More information about the samba-cvs mailing list