Fix a comment typo copied around Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
lib: relicense smb_strtoul(l) under LGPLv3 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Mon Aug 3 22:21:04 UTC 2020 on sn-devel-184
source4: Update all consumers of strtoul_err(), strtoull_err() to new API Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
source4: Use wrapper for string to integer conversion In order to detect an value overflow error during the string to integer conversion with strtoul/strtoull, the errno variable must be set to zero before the execution and checked after the conversion is performed. This is achieved by using the wrapper function strtoul_err and strtoull_err. Signed-off-by: Swen Schillig <swen@linux.ibm.com> Reviewed-by: Ralph Böhme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
drepl: schema repl race condition fix Adds final schema consistency check before committing changes. Aborts if corruption found. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12889 Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
dsdb: Remove readOnlySchema concept from Samba This is a hold-over from the LDAP backend project, which has not yet been revived. There will be bigger issues than what to do if the schema changes if this ever comes back and our schema code is way to complex at the moment. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
dsdb: Fix CID 1435453 Null pointer dereferences Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
dsdb:schema_load: make use of ldb_relative_path() in partition_metadata_open() Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
dsdb: Use talloc_get_type_abort() in schema_load_{start,end}_transaction BUG: https://bugzilla.samba.org/show_bug.cgi?id=13379 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
dsdb: ensure we take out a read lock during the dsdb_init We have to also take it out in the partitions code when we load the partition backends. This ensures that the init handlers hold a whole-db lock just as the search code does. To ensure the locking count in schema_load is balanced, the private data is now created in the first lock_read() call. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13379 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
dsdb: Rework schema reload during the read lock Rather than refusing the reload based on making cached sequence numbers match just load it once at the time the DB is globally locked, if required. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13379 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
dsdb: Load schema during the read_lock() hook, not the search This should trigger slightly less often and is the more correct place, as we only load it during the first lock when not in a transaction. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13379 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
dsdb: Wait until a transaction starts to call dsdb_schema_set_indices_and_attributes() This avoids starting a transaction in schema_load_init() and allows it to operate with a read lock held, which will avoid locking issues (deadlock detected due to lock odering if we do not have a global read lock). BUG: https://bugzilla.samba.org/show_bug.cgi?id=13379 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
dsdb: The schema should be reloaded during the transaction Reload the schema just after getting the tranaction lock but before the transaction counter is bumped. This ensures we reload the schema exactly once but with the DB locked. Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
samdb/schema_load: do schema loading with one search It appears that there was a race condition between searching for the attribute & class definitions, and searching for the schema object, if the schema was changed in-between the two searches. This is likely the cause of ldap_schema being flapping. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12889 Signed-off-by: Bob Campbell <bobcampbell@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
schema: Do not read different schema sequence values during a read transaction During a read lock, we find ourselves seeing an unchanged schema, but reading any updates to the metadata.tdb (in the case of lmdb, where reads do not block writes). The alternative is to read-lock the entire metadata.tdb, however, this allows more concurrency by allowing reads not to block writes. Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
schema: Allow schemaUpdateNow to refresh schema during a transaction When we upgrade a schema from 2008R2 to 2012R2, we want to apply all the changes in a single transaction - if we can't apply all the updates then we don't want to be left with a schema halfway in between the two. However, as we apply each LDIF update, we also want to refresh the schema. There are 2 reasons for this: 1. The adprep .LDIF files provided by Microsoft have some writes to schemaUpdateNow in them. 2. Microsoft uses attribute OIDs in their adprep .LDIF files, which Samba doesn't handle so well. However, we can replace the OIDs with the attribute's ldapDisplayName and they work fine. But to do this, we need to query the schema to map the OID to attribute name. And to query the schema successfully, the schema needs to be refreshed after the new attribute object has been added. Basically this patch avoids bailing out during the dsdb_schema_refresh() if we are writing schemaUpdateNow as part of a larger transaction. Pair-programmed-with: Garming Sam <garming@catalyst.net.nz> Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
schema: Make writing indices flag an enum for a new state In schema_load_init, we find that the writing of indices is not locked in any way. This leads to race conditions. To resolve this, we need to have a new state (SCHEMA_COMPARE) which can report to the caller that we need to open a transaction to write the indices. Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
dsdb: Rework schema_init module to always use valid memory The schema can go away unless the second argument (the memory context) is supplied Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
dsdb: Add comment explaining requirements on DSDB_EXTENDED_SCHEMA_UPDATE_NOW_OID 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): Fri Jun 16 23:43:46 CEST 2017 on sn-devel-144