summaryrefslogtreecommitdiff
path: root/python/samba/dbchecker.py
AgeCommit message (Collapse)AuthorFilesLines
2018-07-03dbchecker: Fixing up incorrect DNs wasn't workingTim Beale1-5/+14
dbcheck would fail to fix up attributes where the extended DN's GUID is correct, but the DN itself is incorrect. The code failed attempting to remove the old/incorrect DN, e.g. NOTE: old (due to rename or delete) DN string component for objectCategory in object CN=alice,CN=Users,DC=samba,DC=example,DC=com - <GUID=7bfdf9d8-62f9-420c-8a71-e3d3e931c91e>; CN=Person,CN=Schema,CN=Configuration,DC=samba,DC=bad,DC=com Change DN to <GUID=7bfdf9d8-62f9-420c-8a71-e3d3e931c91e>; CN=Person,CN=Schema,CN=Configuration,DC=samba,DC=example,DC=com? [y/N/all/none] y Failed to fix old DN string on attribute objectCategory : (16, "attribute 'objectCategory': no matching attribute value while deleting attribute on 'CN=alice,CN=Users,DC=samba,DC=example,DC=com'") The problem was the LDB message specified the value to delete with its full DN, including the GUID. The LDB code then helpfully corrected this value on the way through, so that the DN got updated to reflect the correct DN (i.e. 'DC=example,DC=com') of the object matching that GUID, rather than the incorrect DN (i.e. 'DC=bad,DC=com') that we were trying to remove. Because the requested value and the existing DB value didn't match, the operation failed. We can avoid this problem by passing down just the DN (not the extended DN) of the value we want to delete. Without the GUID portion of the DN, the LDB code will no longer try to correct it on the way through, and the dbcheck operation will succeed. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13495 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> Pair-programmed-with: Andrew Bartlett <abartlet@samba.org>
2018-07-03dbcheck: Use symbolic control name for DSDB_CONTROL_DBCHECK_FIX_DUPLICATE_LINKSAndrew Bartlett1-1/+1
While we do not wish to encourage use of this control, manually typed OIDs are even more trouble, so pass out via pydsdb. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2018-04-30python: Bulk conversion callers of ldb.Dn second paramNoel Power1-5/+5
Convert second param passed to ldb.Dn to be unicode so py2 & py3 code will work Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Alexander Bokovoy <ab@samba.org>
2018-04-30python/samba: bulk conversion of caller to dsdb_Dn 2nd param.Noel Power1-7/+7
Convert second param to dsdb_Dn to be unicode so py2 & py3 code will work Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Alexander Bokovoy <ab@samba.org>
2018-03-23samba python libs: convert print func to be py2/py3 compatibleNoel Power1-1/+2
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-02-28samba python libs: convert 'except X, (tuple)' to 'except X as e'Noel Power1-12/+24
In addition to converting the except line another line is also added for each except to extract the tuple contents. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-02-15samba python libs: convert 'except X, e' to 'except X as e'Douglas Bagnall1-5/+5
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-02-05dbcheck: skip find_missing_forward_links_from_backlinks() if the db has the ↵Stefan Metzmacher1-0/+25
sortedLinks feature BUG: https://bugzilla.samba.org/show_bug.cgi?id=13228 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Mon Feb 5 18:32:51 CET 2018 on sn-devel-144
2018-02-05dbcheck: add support for restoring missing forward linksRalph Boehme1-6/+37
This recovers broken databases with duplicate and missing forward links. See commit a25c99c9f1fd1814c56c21848c748cd0e038eed7 for the fix that prevents to problem from happening. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13228 Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Ralph Boehme <slow@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
2018-02-05dbcheck: add find_missing_forward_links_from_backlinks()Ralph Boehme1-0/+96
find_missing_forward_links_from_backlinks() finds and returns missing forward-links by searching all for all objects that link to the object in the backlink attribute. This will be used in the next commit to restore forward links in a corrupted forward link attribute by passing the missing backling objects to err_recover_forward_links(). BUG: https://bugzilla.samba.org/show_bug.cgi?id=13228 Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Ralph Boehme <slow@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
2018-02-05dbcheck: make sure we ask for replPropertyMetaData if we need to process any ↵Stefan Metzmacher1-0/+12
forward link attributes BUG: https://bugzilla.samba.org/show_bug.cgi?id=13228 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2018-02-05dbcheck: make sure we always ask for the objectGUID attribute explicitlyStefan Metzmacher1-2/+1
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13228 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2018-02-05dbcheck: add a helper function that checks is a value has duplicate linksRalph Boehme1-0/+32
Will be used in a subsequent commit. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13228 Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Ralph Boehme <slow@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
2018-02-05dbcheck: add a dict where we remember attributes with duplicate linksRalph Boehme1-0/+7
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13228 Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Ralph Boehme <slow@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
2018-02-05dbcheck: split out check_duplicate_links from check_dnRalph Boehme1-16/+29
Refactoring, no change in behaviour. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13228 Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Ralph Boehme <slow@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
2018-02-05dbcheck: store fixed forward link attributes with the correct sortingStefan Metzmacher1-11/+6
The corruption we're trying to fix messed up the sorting, so there's no point in keeping the current order. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13228 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2018-02-05dbcheck: remove ldb.FLAG_MOD_REPLACE when replacing search results for ↵Stefan Metzmacher1-1/+1
forward links Search results don't have an ldb.FLAG_MOD_* flags set. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13228 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2018-02-05dbcheck: rename err_duplicate_links() to err_recover_forward_links() and ↵Ralph Boehme1-5/+8
adjust the output message It's really a fatal error to have duplicate values as it's very likely that some forward links got lost. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13228 Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Ralph Boehme <slow@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
2018-02-05dbcheck: add link direction to error message for duplicate linksRalph Boehme1-1/+2
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13228 Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Ralph Boehme <slow@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
2018-02-05dbcheck: rename err_duplicate_links argumentsRalph Boehme1-6/+6
In preperation of adding more arguments. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13228 Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2018-02-05dbcheck: only pass obj_dn to err_orphaned_backlink()Stefan Metzmacher1-5/+6
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13228 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2018-02-05dbcheck: add forward_syntax argument to err_orphaned_backlinkRalph Boehme1-3/+4
Will be used in a subsequent commit. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13228 Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Ralph Boehme <slow@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
2018-02-05dbcheck: rename and reorder err_orphaned_backlink argumentsRalph Boehme1-11/+11
In preperation of adding more arguments. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13228 Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Ralph Boehme <slow@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
2018-02-05Revert "dbcheck: disable fixing duplicate linked attributes until we can ↵Ralph Boehme1-19/+3
recover lost forward links" This reverts commit 43e3f79d54c5aeaea820865d298d4249cf47af99. The real fix will follow in the next commits. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13228 Signed-off-by: Ralph Boehme <slow@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
2018-01-22dbcheck: disable fixing duplicate linked attributes until we can recover ↵Stefan Metzmacher1-3/+19
lost forward links BUG: https://bugzilla.samba.org/show_bug.cgi?id=13228 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2017-11-24dbcheck: detect and fix duplicate linksStefan Metzmacher1-46/+147
Check with git show -w BUG: https://bugzilla.samba.org/show_bug.cgi?id=13095 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2017-11-24dbcheck: only calculate linked attribute helper variables once in check_dn()Stefan Metzmacher1-2/+6
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13095 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2017-11-24dbcheck: remove indentation levelStefan Metzmacher1-63/+62
Check with git show -w BUG: https://bugzilla.samba.org/show_bug.cgi?id=13095 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2017-11-24dbcheck: Use the GUID as the DN to fix replPropertyMetaDataAndrew Bartlett1-3/+6
This allows this to still work after an object is renamed under the deleted objects container. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2017-11-24dbcheck: Clarify error count bumping in deleted/gone DN handlingAndrew Bartlett1-7/+33
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2017-10-19dbcheck: Allow removal of one-way links to missing objectsAndrew Bartlett1-2/+20
If dbcheck is not run within the tombstone lifetime, these links can persist in the database forever. The risk of unintentional information loss is why these links are only removed within the same partition. A replication may be in progress which has created only one end of the link, so we must keep that. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Rowland Penny <rpenny@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Oct 19 00:50:19 CEST 2017 on sn-devel-144
2017-03-13dbcheck: Improve dbcheck to find (and may fix) dangling msDS-RevealedUsersGarming Sam1-0/+48
We cannot add missing backlinks because of the duplicate checking. There seems to be no trivial way to add the bypass. Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2017-02-23dbchecker: Stop ignoring linked cases where both objects are aliveGarming Sam1-10/+13
Previously, this did nothing and the code was both untested and unused. Removes the knownfail entry for dbcheck. Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> BUG: https://bugzilla.samba.org/show_bug.cgi?id=12600
2017-02-13dbcheck: Do not regard old one-way-links as errorsAndrew Bartlett1-8/+39
Samba does not maintain one way links when the target is deleted or renamed so do not fail dbcheck because of such links, but allow them to be updated. This matters because administrators and make test expect that normal Samba operation do NOT cause the database to become corrupt, and any error from dbcheck tends to trigger alarms (or test failures). If an object pointed at by a one way link is renamed or deleted in normal operations (such as intersiteTopologyGenerator pointing at a demoted DC), or make test, then this could trigger. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> BUG: https://bugzilla.samba.org/show_bug.cgi?id=12577
2016-11-22dbcheck: Correct message for orphaned backlinksAndrew Bartlett1-4/+4
The backlink name is in attrname, not in link_name Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> BUG: https://bugzilla.samba.org/show_bug.cgi?id=12297
2016-11-22dbcheck: Be more careful with link checksAndrew Bartlett1-7/+23
Here we are more careful when checking links, flagging errors only when a non-deleted forward link appears incorrect. In particular, we trust the GUID more than we trust the name, as otherwise we can get caught out if there is a swap of names, (the link should follow the swap, staying on the same target GUID). Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> BUG: https://bugzilla.samba.org/show_bug.cgi?id=12297
2016-11-04dbcheck: Correctly initialise keep_transaction in missing_parent testAndrew Bartlett1-1/+1
Otherwise there is no point to this variable, we are trying to work out if the subsequent modify succeded Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> BUG: https://bugzilla.samba.org/show_bug.cgi?id=9954
2016-11-04dbcheck: confirm RID Set presence and consistencyClive Ferreira1-0/+132
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> BUG: https://bugzilla.samba.org/show_bug.cgi?id=9954
2016-08-29dbcheck: Abandon dbcheck if we get an error during a transactionAndrew Bartlett1-0/+7
Otherwise, anything that the transaction has already done to the DB will be left in the DB even despite the failure. For example, if a fix wrote to the DB, but then failed a post-write check, then the fix will not be unrolled. This is because we do not have nested transactions in TDB. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12178 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Mon Aug 29 12:46:21 CEST 2016 on sn-devel-144
2016-07-21dbcheck: Add a rule regarding replica locationsGarming Sam1-1/+57
This fixes any RW DCs with repsFrom without the corresponding link. On any RODC, this just reports an error (and doesn't fix it). (the knownfail entry is also now removed) BUG: https://bugzilla.samba.org/show_bug.cgi?id=9200 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-07-15dbcheck: Split out valid stale DN links and invalid onesGarming Sam1-8/+35
Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-07-15dbcheck: change argument to specify a partial --yesGarming Sam1-2/+2
Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-07-15dbcheck: check for linked atributes that should not existDouglas Bagnall1-44/+90
In order to do this we need to use the reveal internals control, which breaks the comparison against extended DNs. So we compare the components instead. Because this patch makes our code notice and fix stale one-way-links (eg, after a rename) now, the renamedc test needs to be adjusted to match. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2016-07-15dbcheck: cache linkIDs and reverse attribute namesDouglas Bagnall1-5/+17
This avoids fetching the same same schema things again and again. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-07-15dbcheck: Script swallows input when given a carriage returnGarming Sam1-1/+1
Signed-off-by: Garming Sam <garming@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-07-06provision: Ignore duplicate attid and governsID checkBob Campbell1-0/+10
During the provision this causes a huge performance hit as these two attributes are unindexed. Signed-off-by: Garming Sam <garming@catalyst.net.nz> Signed-off-by: Bob Campbell <bobcampbell@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Pair-programmed-with: Garming Sam <garming@catalyst.net.nz>
2016-06-07dsdb: Fix incorrect sorting of replPropertyMetaData with RDN lastAndrew Bartlett1-11/+4
Per tests against Windows 2012R2 the RDN is not sorted last and is instead sorted normally with all the other elements. The RDN attribute, unlike name, is not replicated over DRS, so this has no interopability impact. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz
2016-06-06dbcheck: Find and fix a missing Deleted Objects containerAndrew Bartlett1-15/+137
Older Samba versions could delete this. This patch tries very hard to put back the original object, with the original GUID, so that if another replica has the correct container, that we just merge rather than conflict. The existing "wrong dn" check can then put any deleted objects under this container correctly. Pair-programmed-with: Garming Sam <garming@catalyst.net.nz> Pair-programmed-with: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2016-04-20dbcheck: Avoid pathological behaviour in operational moduleGarming Sam1-0/+4
Because replPropertyMetadata was repeated for every object in the database, the attrs list became very long. This single line saves 20% of the time for make test TESTS=dbcheck. Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Garming Sam <garming@samba.org> Autobuild-Date(master): Wed Apr 20 09:12:47 CEST 2016 on sn-devel-144
2016-03-08dbcheck: Check for and remove duplicate values in attributesAndrew Bartlett1-0/+26
This can happen with three DCs and custom schema, but we test it by just forcing the values directly into the backing tdb. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>