summaryrefslogtreecommitdiff
path: root/source3/winbindd/idmap_autorid.c
Commit message (Collapse)AuthorAgeFilesLines
* autorid: use the db argument in the initialize traverse action.Michael Adam2014-04-031-2/+2
| | | | | | | | | | | | | | By a copy and paste error, the global autorid_db was used. This was not currently a problem in behaviour, because this autorid_db is passed as the argument. This change fixes the callback function for consistency. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Apr 3 08:36:55 CEST 2014 on sn-devel-104
* autorid: make the whole initialization atomic with one transaction.Michael Adam2014-04-031-10/+38
| | | | | | | | | | | | | | | | | | | | | | | | Originally, there were several writing operations: - store the range HWM - store the alloc uid HWM - store the alloc gid HWM - store the config - create mappings for a whole list of wellknown sids Each of these consisted of its own transaction, the wellknown preallocation even of one transaction per sid. This change wrapps all of these in one big transaction. Thereby making the whole initialization atomic, and with respect to the creation of the wellknown mappings also more deterministic. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Apr 3 02:41:25 CEST 2014 on sn-devel-104
* autorid: initialize: fix typo in and further improve a debug message.Michael Adam2014-04-031-2/+2
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* autorid: initialize: use the split db_open and init_hwms function instead of ↵Michael Adam2014-04-031-1/+6
| | | | | | | | | db_init This way, we can later put all of the storing functions inside one transaction. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* autorid: initialize: open the autorid db as late as possible.Michael Adam2014-04-031-8/+9
| | | | | | | But make sure to link the db context to commonconfig afterwards. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* autorid: initialize: link config to commonconfig as soon as it is allocated.Michael Adam2014-04-031-1/+1
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* autorid: initialize: link commonconfig to dom as soon as it is allocatedMichael Adam2014-04-031-2/+1
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* autorid: initialize: store config directly before allocating well knowns.Michael Adam2014-04-031-7/+6
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* Rename module init functions from samba_init_moduleChristof Schmitt2014-04-021-1/+1
| | | | | | | | | | | | | | | Some modules use samba_init_module as the name for the init functions, others use a name based on the module name. Rename the init functions from samba_init_module, to be consistent across all modules. This change also allows to build idmap_tdb2 and perfcount_test statically. Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Wed Apr 2 08:50:04 CEST 2014 on sn-devel-104
* idmap_autorid: fix failure in reverse lookup if ID is from domain range index #0Abhidnya Joshi2013-11-071-1/+1
| | | | | | | | | Domain range index #0 is not included in the database record. So in this special case we only have the SID, not SID#IDX... Signed-off-by: Abhidnya Joshi <achirmul@in.ibm.com> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* idmap_autorid: remove autorid_global_config member from autorid_range_configAtul Kulkarni2013-10-021-11/+0
| | | | | | | | | | | | global config is not part of range config. By removing this, autorid_range_config becomes more suitable for using it elsewhere. Pair-Programmed-With: Michael Adam <obnox@samba.org> Signed-off-by: Atul Kulkarni <atul.kulkarni@in.ibm.com> Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* idmap_autorid: move the checks from idmap_autorid_initialize to ↵Atul Kulkarni2013-10-021-54/+0
| | | | | | | | | | idmap_autorid_saveconfig() Pair-Programmed-With: Michael Adam <obnox@samba.org> Signed-off-by: Atul Kulkarni <atul.kulkarni@in.ibm.com> Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* idmap_autorid: change idmap_autorid_loadconfig() to return NTSTATUSMichael Adam2013-10-011-1/+8
| | | | | | | | | | for better error propagation. Pair-Programmed-With: Atul Kulkarni <atul.kulkarni@in.ibm.com> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Atul Kulkarni <atul.kulkarni@in.ibm.com> Reviewed-by: Volker Lendecke <vl@samba.org>
* idmap_autorid: extract common code to separate fileAtul Kulkarni2013-10-011-277/+1
| | | | | | | | | | This is in preparation of adding "net idmap autorid" functionality. Pair-Programmed-With: Michael Adam <obnox@samba.org> Signed-off-by: Atul Kulkarni <atul.kulkarni@in.ibm.com> Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* idmap_autorid: remove the ignore_builtin bool from the global_config structMichael Adam2013-10-011-4/+5
| | | | | | | | | | | The ignore_builtin flag is used only to change the bahaviour of the daemon code, not in the database. Pair-Programmed-With: Michael Adam <obnox@samba.org> Signed-off-by: Atul Kulkarni <atul.kulkarni@in.ibm.com> Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* idmap_autorid: add path, and db parameters to idmap_autorid_db_init()Atul Kulkarni2013-10-011-12/+14
| | | | | | | | | | In preparation of calling this from net for different dbs. Pair-Programmed-With: Michael Adam <obnox@samba.org> Signed-off-by: Atul Kulkarni <atul.kulkarni@in.ibm.com> Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* idmap_autorid: add a db_context argument to idmap_autorid_init_hwm()Michael Adam2013-10-011-7/+7
| | | | | | | | Pair-Programmed-With: Atul Kulkarni <atul.kulkarni@in.ibm.com> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Atul Kulkarni <atul.kulkarni@in.ibm.com> Reviewed-by: Volker Lendecke <vl@samba.org>
* idmap_autorid: add a db_context argument to idmap_autorid_saveconfig()Michael Adam2013-10-011-4/+4
| | | | | | | | Pair-Programmed-with: Atul Kulkarni <atul.kulkarni@in.ibm.com> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Atul Kulkarni <atul.kulkarni@in.ibm.com> Reviewed-by: Volker Lendecke <vl@samba.org>
* idmap_autorid: add a db_context argument to idmap_autorid_loadconfig()Michael Adam2013-10-011-3/+4
| | | | | | | | Pair-Programmed-with: Atul Kulkarni <atul.kulkarni@in.ibm.com> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Atul Kulkarni <atul.kulkarni@in.ibm.com> Reviewed-by: Volker Lendecke <vl@samba.org>
* idmap_autorid: add a db_context argument to idmap_autorid_get_domainrange()Michael Adam2013-10-011-5/+7
| | | | | | | | Pair-Programmed-with: Atul Kulkarni <atul.kulkarni@in.ibm.com> Signed-off-by: Michael Adam <obnox@samba.org> Signed-off-by: Atul Kulkarni <atul.kulkarni@in.ibm.com> Reviewed-by: Volker Lendecke <vl@samba.org>
* s3:idmap_autorid: Add a NULL check in idmap_autorid_preallocate_wellknownVolker Lendecke2013-07-081-0/+4
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christian Ambach <ambi@samba.org>
* s3:idmap_autorid: Don't zero in idmap_autorid_preallocate_wellknownVolker Lendecke2013-07-081-1/+1
| | | | | | | We initialize everything later anyway Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christian Ambach <ambi@samba.org>
* s3:idmap_autorid: Use ARRAY_SIZE where appropriateVolker Lendecke2013-07-081-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christian Ambach <ambi@samba.org>
* s3:idmap:autorid: add a comment block explaining the calculationsMichael Adam2013-05-061-0/+51
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Christian Ambach <ambi@samba.org>
* s3:idmap:autorid: simplify the id->sid calculationMichael Adam2013-05-061-7/+13
| | | | | | | | | | | | | To make it more intutive. rid = reduced_rid + domain_range_index * range_size where reduced_rid = (id - id_low) % range_size Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Christian Ambach <ambi@samba.org>
* s3:idmap:autorid: calculate the range's low_id in ↵Michael Adam2013-05-061-8/+9
| | | | | | | | | | idmap_autorid_get_domainrange() This way, the calculation needs to be don only in one central place and the formulas get simpler. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Christian Ambach <ambi@samba.org>
* s3:idmap:autorid: make calculation in idmap_autorid_sid_to_id much more obviousMichael Adam2013-05-061-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is my attempt to make the sid->unix-id calculation much more obvious. Especially with the introduction of the multi-range support an the originally named "multiplier", the calculation id = low_id + range_size * domain_number + rid - range_size * multiplier was rather opaque to me. What really happens here is this: The rid is split into a reduced_rid part that is < rangesize and a multiple of rangesize. This is given by the formula rid = rid % range_size + (rid / range_size) * range_size We define reduced_rid := rid % range_size and domain_range_index := rid / range_size ( == the original multiplier) and the original formula is equivalent to: id = reduced_rid + low_id + range_number * range_size; and reads id = reduced_rid + range_minvalue if we set range_minvalue := low_id + range_number * range_size. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Christian Ambach <ambi@samba.org>
* s3:idmap:autorid: rename range.multiplier to domain_range_indexMichael Adam2013-05-061-15/+17
| | | | | | | | | The name multiplier is very confusing (at least for me). This is an index that is used to reference the various per-domain ranges. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Christian Ambach <ambi@samba.org>
* s3:idmap:autorid: rename autorid_range_config.sid to domsid, along with ↵Michael Adam2013-05-061-12/+12
| | | | | | | instances Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Christian Ambach <ambi@samba.org>
* s3:idmap:autorid: rename autorid_domain_config --> autorid_range_config and ↵Michael Adam2013-05-061-37/+37
| | | | | | | | | instances to "range" This describes it better with the new support for multiple ranges for domains. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Christian Ambach <ambi@samba.org>
* s3:idmap:autorid: rename domainnum to rangenumMichael Adam2013-05-061-12/+13
| | | | | | | | | Now ranges don't correspond to domains any more, but multiple ranges are associated to a domain. So the name is misleading. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Christian Ambach <ambi@samba.org>
* s3:winbindd/autorid multiple range supportAbhidnya Joshi2013-05-061-19/+36
| | | | | | | | | | | | | | | | | when a mapping request for a RID comes in that is larger than the rangesize, allocate an extension range to be able to map this one This is especially important for large installations which might have large RIDs being used in a trusted domain that the administrator was not aware of when planning for autorid usage and so those objects could not be mapped up to now. As it is not possible to change the rangesize after the first start of autorid, this would lead to big trouble. Signed-off-by: Abhidnya Joshi <achirmul@in.ibm.com> Reviewed-by: Christian Ambach <ambi@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* s3:idmap_autorid: fix freeing of non-talloced memory (uninitialized pointer) ↵Michael Adam2013-02-131-1/+1
| | | | | | | | | | (bug #9653) Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Wed Feb 13 09:51:53 CET 2013 on sn-devel-104
* s3-idmap: Check return value of string_to_sid().Andreas Schneider2013-01-021-1/+6
| | | | | | | | Found by Coverity. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Günther Deschner <gd@samba.org> Reviewed-by: Christian Ambach <ambi@samba.org>
* s3:idmap_autorid: force mapping type to ID_TYPE_BOTH for sid->unixid mappingMichael Adam2012-12-031-0/+3
| | | | | | | | | | | | | | | | | This is to remove problems with the same unix-id being used both as a uid and a gid. The autorid backend will map a given number to the same SID, no matter whether this is a uid or a gid. This will prime the idmap cache with mappings. The sid-to-u/gid mapping, when not going through the cache, instead checks for the type of the sid and only allows unix ids of the corresponding type. Hence the rid backend will give different results, depending on whether the cache is filled or not. This patch lets the autorid backend always create sid->id mappings of type both. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* dbwrap: dbwrap_trans_store_int32->dbwrap_trans_store_int32_bystringVolker Lendecke2012-06-151-1/+1
| | | | Signed-off-by: Michael Adam <obnox@samba.org>
* dbwrap: dbwrap_change_uint32_atomic->dbwrap_change_uint32_atomic_bystringVolker Lendecke2012-06-151-1/+1
| | | | Signed-off-by: Michael Adam <obnox@samba.org>
* dbwrap: dbwrap_store_uint32->dbwrap_store_uint32_bystringVolker Lendecke2012-06-151-1/+1
| | | | Signed-off-by: Michael Adam <obnox@samba.org>
* dbwrap: dbwrap_fetch_uint32->dbwrap_fetch_uint32_bystringVolker Lendecke2012-06-151-5/+6
| | | | Signed-off-by: Michael Adam <obnox@samba.org>
* s3:winbindd:autorid check that transaction start did workChristian Ambach2012-05-091-1/+5
| | | | | | | this fixes Coverity #700172 CHECKED_RETURN Autobuild-User: Christian Ambach <ambi@samba.org> Autobuild-Date: Wed May 9 00:27:08 CEST 2012 on sn-devel-104
* s3:winbindd/autorid add ignore builtin parameterChristian Ambach2012-05-081-0/+13
| | | | | | | BUILTIN should be handled by passdb, however if passdb does not know about a SID, autorid creates a range for BUILTIN and does deterministic mapping make it possible to turn off this behavior
* s3:winbindd/autorid add support for read-only modeChristian Ambach2012-05-081-6/+38
| | | | | | | make it possible to set read-only = yes for the backend so users can replicate an autorid.tdb to another server to use the same mappings without risking that updates are done on both sides
* s3:winbindd/autorid preallocate well-known SIDsChristian Ambach2012-05-081-0/+42
| | | | | | | | preallocate the list of well-known SIDs that Win2008R2 reports to be groups and that are on the list in KB243330 This will allow for deterministic mapping of these SIDs, even if they are stored in the allocation pool as this is the first thing that autorid will allocate from the pool during module initialization
* s3:winbindd/autorid use idmap_tdb_common code in autoridChristian Ambach2012-05-011-86/+227
| | | | | | - use common logic for the allocation pool - add a idmap_tdb style 1on1 mapping for non-domain SIDs like Everyone (S-1-1-0)
* s3: Add a "lock_order" argument to db_openVolker Lendecke2012-01-181-1/+2
| | | | | | | This will be used to enforce a lock hierarchy between the databases. We have seen deadlocks between locking.tdb, brlock.tdb, serverid.tdb and notify*.tdb. These should be fixed by refusing a dbwrap_fetch_locked that does not follow a defined lock hierarchy.
* s3:idmap_autorid: use less transactionsChristian Ambach2011-12-161-55/+76
| | | | | | | | reduce the amount of transactions that are mostly unnecessary because no updates were done, only reads Autobuild-User: Christian Ambach <ambi@samba.org> Autobuild-Date: Fri Dec 16 20:18:37 CET 2011 on sn-devel-104
* Revert making public of the samba-module library.Jelmer Vernooij2011-12-031-1/+1
| | | | | | | | | | | | | | | This library was tiny - containing just two public functions than were themselves trivial. The amount of overhead this causes isn't really worth the benefits of sharing the code with other projects like OpenChange. In addition, this code isn't really generically useful anyway, as it can only load from the module path set for Samba at configure time. Adding a new library was breaking the API/ABI anyway, so OpenChange had to be updated to cope with the new situation one way or another. I've added a simpler (compatible) routine for loading modules to OpenChange, which is less than 100 lines of code. Autobuild-User: Jelmer Vernooij <jelmer@samba.org> Autobuild-Date: Sat Dec 3 08:36:33 CET 2011 on sn-devel-104
* lib/util Rename samba_init_module -> samba_module_initAndrew Bartlett2011-10-281-1/+1
| | | | | | | This is to provide a cleaner namespace in the public samba plugin functions. Andrew Bartlett
* s3:idmap_autorid: add an allocation range to autoridChristian Ambach2011-10-211-1/+96
| | | | | | | | | | this is needed to allocate gids for BUILTIN\Users and BUILTIN\Administrators and for local users/group that admins might want to create autorid will now allocate one range for this purpose and can so give out as many uids and gids as the configured rangesize allows
* s3:idmap_autorid: move HWM initialization into a functionChristian Ambach2011-10-211-17/+27
| | | | | we will need some more HWM soon, so move out initialization and optimize the logic using the new interface of dbwrap_fetch_uint32