[SCM] Samba Shared Repository - branch master updated

Michael Adam obnox at samba.org
Wed Oct 2 04:24:03 MDT 2013


The branch, master has been updated
       via  280f21a net: allow "net idmap get ranges" to list all ranges
       via  b2ed2d8 idmap_autorid: allow iterate functions to operate on all domain ranges
       via  7c2b83d net: implement "net idmap delete ranges"
       via  a6f6ad8 idmap_autorid: add idmap_autorid_delete_domain_ranges()
       via  fe8a8b5 net: add "net idmap get ranges" operation for autorid
       via  97dfa06 idmap_autorid: add idmap_autorid_iterate_domain_ranges[_read]()
       via  54a33eb net: implement "net idmap delete range"
       via  1dd9218 idmap_autorid: add idmap_autorid_delete_range_by_num()
       via  6cdae0d idmap_autorid: add idmap_autorid_delete_range_by_sid()
       via  9b7f9f9 idmap_autorid: add idmap_autorid_build_keystr_talloc()
       via  6d8cc47 idmap_autorid: extend idmap_autorid_addrange to allow to set mappings below the HWM
       via  350916c net: implement "net idmap get range"
       via  8371f59 idmap_autorid: improve clarity of idmap_autorid_addrange_action() by adding mem_ctx.
       via  5aed3fa net: add "net idmap set range" (for autorid backend)
       via  d2c892c net idmap: add utility function parse_uint32()
       via  063ec55 net: add "net idmap get config" to read the autorid config from the database
       via  1be6c57 net: add "net idmap get" command
       via  050fb74 net: add "net idmap set config" command to store the autorid global config
       via  375168a idmap_autorid: add idmap_autorid_saveconfigstr()
       via  d560cd1 net: add new function net_idmap_opendb_autorid()
       via  f531c36 net: rename "idmap_dump_ctx" to "net_idmap_ctx".
       via  29a94b0 net: move the "net idmap delete" functionality to subcommand "net idmap delete mapping"
       via  68c4414 net: add the "net idmap set secret" subcommand as alias for "net idmap secret"
       via  a064119 net: move the "net idmap set" functionality to subcommand "net idmap set mapping"
       via  601b67b net: rename "net idmap setmap" to "net idmap set"
       via  873ae9c net: improve help text for "net idmap restore"
       via  01e1794 net: improve help text for "net idmap dump"
       via  4d0d348 idmap_autorid: add a comment explaining idmap_autorid_saveconfig()
       via  ae88bcd idmap_autorid: add a comment explaining idmap_autorid_loadconfig()
       via  4deba60 idmap_autorid: add a comment explaining idmap_autorid_db_init()
       via  4c937f2 idmap_autorid: add a comment explaining idmap_autorid_init_hwm()
       via  7cde714 idmap_autorid: add a comment explaining idmap_autorid_get_domainrange()
       via  e8c9161 idmap_autorid: Don't use db as a temporary talloc context.
       via  11ea83e idmap_autorid: improve two debug messages by printing NT error codes
       via  85a15ca idmap_autorid: fix a debug message in idmap_autorid_addrange()
       via  266fddf idmap_autorid: for clarity, add a wrapper idmap_autorid_acquire_range() to idmap_autorid_addrange()
       via  4350bfb idmap_autorid: add new function idmap_autorid_setrange()
       via  6e08f5a idmap_autorid: factor out domain range adding code into a separate function
       via  69dbc15 idmap_autorid: add idmap_autorid_getrange()
       via  e598ed1 idmap_autorid: improve a debug message in idmap_autorid_getrange_int()
       via  7d2fdaa idmap_autorid: factor out domain range fetching part from idmap_autorid_get_domainrange()
       via  94ca5dc idmap_autorid: Use fstr_sprintf in idmap_autorid_build_keystr()
       via  2d8cc3e idmap_autorid: factor building of the keystr into a function
       via  f8767cd idmap_autorid: remove fstring keystr from autorid_range_config
       via  7cacc48 idmap_autorid: remove autorid_global_config member from autorid_range_config
       via  65d7df1 idmap_autorid: improve idmap_autorid_saveconfig() by adding a talloc stackframe
       via  65881c3 idmap_autorid: move the checks from idmap_autorid_initialize to idmap_autorid_saveconfig()
       via  802b9d7 idmap_autorid: change idmap_autorid_loadconfig() to return NTSTATUS
       via  f6c34b1 idmap_autorid: refactor idmap_autorid_parse_configstr() out of idmap_autorid_loadconfig()
       via  42a6bb7 idmap_autorid: rename TALLOC_CTX argument of idmap_autorid_loadconfig() to mem_ctx
       via  56c80d1 idmap_autorid: refactor idmap_autorid_loadconfig to use idmap_config_getconfigstr
       via  173cdfe idmap_autorid_tdb: add idmap_autorid_getconfigstr()
       via  f80f43c idmap_autorid: extract common code to separate file
       via  41450fe idmap_autorid: remove the ignore_builtin bool from the global_config struct
       via  954d9fb idmap_autorid: add path, and db parameters to idmap_autorid_db_init()
       via  105475c idmap_autorid: add a db_context argument to idmap_autorid_init_hwm()
       via  a54e21b idmap_autorid: add a db_context argument to idmap_autorid_saveconfig()
       via  dd004e8 idmap_autorid: add a db_context argument to idmap_autorid_loadconfig()
       via  fdf8d93 idmap_autorid: add a db_context argument to idmap_autorid_get_domainrange()
      from  6bf9a77 Stop use after free

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 280f21a9612982be4ad3e08e39608e6218529980
Author: Michael Adam <obnox at samba.org>
Date:   Wed Oct 2 00:43:27 2013 +0200

    net: allow "net idmap get ranges" to list all ranges
    
    Omission of SID parameter lists ranges for all domains.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Michael Adam <obnox at samba.org>
    Autobuild-Date(master): Wed Oct  2 12:23:33 CEST 2013 on sn-devel-104

commit b2ed2d814b44f766158ed1891173e8cd561b0e7e
Author: Michael Adam <obnox at samba.org>
Date:   Wed Oct 2 00:39:07 2013 +0200

    idmap_autorid: allow iterate functions to operate on all domain ranges
    
    by allowing handed in domsid to be NULL
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 7c2b83d15eb5e64a4ad7b8dcd1bbd73bfe78de24
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 18 03:19:58 2013 +0200

    net: implement "net idmap delete ranges"
    
    Inspired by a patch by Atul Kulkarni <atul.kulkarni at in.ibm.com>.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit a6f6ad8d22e1e1030681e98c10fdd08b8f319d98
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 18 03:04:52 2013 +0200

    idmap_autorid: add idmap_autorid_delete_domain_ranges()
    
    This uses the new idmap_autorid_iterate_domain_ranges() function.
    Based on earlier patch by Atul Kulkarni <atul.kulkarni at in.ibm.com>.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit fe8a8b50b59e6ca14c799f25635a5c2b43c0962a
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 18 02:39:51 2013 +0200

    net: add "net idmap get ranges" operation for autorid
    
    Implemented using the idmap_autorid_iterate_domain_ranges_read() function.
    Based on earlier patch by Atul Kulkarni <atul.kulkarni at in.ibm.com>.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 97dfa06151e8ea843c393f63c2c4b956810b2994
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 18 01:54:58 2013 +0200

    idmap_autorid: add idmap_autorid_iterate_domain_ranges[_read]()
    
    Functions to perform an action on all domain range mappings for
    a given domain, specified by the domain sid.
    
    Inspired by a previous patch by Atul Kulkarni <atul.kulkarni at in.ibm.com>.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 54a33ebf273d8f5c9d66b20257f7baf5cc920386
Author: Michael Adam <obnox at samba.org>
Date:   Thu Sep 12 13:45:22 2013 +0200

    net: implement "net idmap delete range"
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 1dd9218de9b7b78fd23d3d19315c49dd4a9c3142
Author: Michael Adam <obnox at samba.org>
Date:   Thu Sep 12 23:59:15 2013 +0200

    idmap_autorid: add idmap_autorid_delete_range_by_num()
    
    query and delete a mapping specified by the range number.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 6cdae0dd304707b844dc462f0743270758475335
Author: Michael Adam <obnox at samba.org>
Date:   Thu Sep 12 13:44:53 2013 +0200

    idmap_autorid: add idmap_autorid_delete_range_by_sid()
    
    Delete a range mapping as specified by domain SID and range index.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 9b7f9f90d2cdc8fd5919f7a94558f5346d35481e
Author: Michael Adam <obnox at samba.org>
Date:   Sun Sep 15 11:58:02 2013 +0200

    idmap_autorid: add idmap_autorid_build_keystr_talloc()
    
    talloc version of idmap_autorid_build_keystr()
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 6d8cc470396a03b937f1c532946dfaf916ad454c
Author: Michael Adam <obnox at samba.org>
Date:   Thu Sep 12 07:37:17 2013 +0200

    idmap_autorid: extend idmap_autorid_addrange to allow to set mappings below the HWM
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 350916c11d879d2289f7518625547b88e8dd5705
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 11 01:05:02 2013 +0200

    net: implement "net idmap get range"
    
    get the range for a domain sid and range index.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 8371f5981dea11ac29451ccccac345e5a0350b5d
Author: Michael Adam <obnox at samba.org>
Date:   Tue Sep 10 13:35:56 2013 +0200

    idmap_autorid: improve clarity of idmap_autorid_addrange_action() by adding mem_ctx.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 5aed3fabac20f026f68fc72aec0ff3e67e0478ae
Author: Michael Adam <obnox at samba.org>
Date:   Mon Sep 9 16:09:52 2013 +0200

    net: add "net idmap set range" (for autorid backend)
    
    This lets the admin store a range for a domain/index pair.
    Call syntax is:
    
    net idmap set range <RANGE> <DOMSID> [<INDEX>]
    
    INDEX defaults to 0.
    
    Pair-Programmed-With: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Signed-off-by: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit d2c892cd2e6b35898208296522ab83042a0ee28c
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Oct 1 23:29:53 2013 +0200

    net idmap: add utility function parse_uint32()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 063ec55e13d5ca09533cf2201b250769f7dbe27c
Author: Atul Kulkarni <atul.kulkarni at in.ibm.com>
Date:   Mon Aug 12 13:09:31 2013 +0530

    net: add "net idmap get config" to read the autorid config from the database
    
    Pair-Programmed-With: Michael Adam <obnox at samba.org>
    
    Signed-off-by: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 1be6c5787b9bfba37bc94b4a9517a357817ed2ac
Author: Michael Adam <obnox at samba.org>
Date:   Tue Sep 10 01:53:14 2013 +0200

    net: add "net idmap get" command
    
    This has no subcommands yet and is added in preparation of adding some.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 050fb746b3ed615af9572d975ba3449ffe6657e1
Author: Atul Kulkarni <atul.kulkarni at in.ibm.com>
Date:   Tue Sep 10 01:47:46 2013 +0200

    net: add "net idmap set config" command to store the autorid global config
    
    Pair-Programmed-With: Michael Adam <obnox at samba.org>
    
    Signed-off-by: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 375168a16eedab3e60153a2b5f7cce1a22e21d5e
Author: Michael Adam <obnox at samba.org>
Date:   Tue Sep 10 01:45:52 2013 +0200

    idmap_autorid: add idmap_autorid_saveconfigstr()
    
    Store a configuration as provided by a config string
    after parsing and validating the string.
    
    Based on similar patch by Atul Kulkarni <atul.kulkarni at in.ibm.com>.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit d560cd11e4de818ff997eea52d020e360c3ef7d0
Author: Atul Kulkarni <atul.kulkarni at in.ibm.com>
Date:   Tue Sep 10 01:19:52 2013 +0200

    net: add new function net_idmap_opendb_autorid()
    
    This checks the backend is autorid, and opens the db if so.
    If readonly == true, the DB is simply opened for reading.
    If readonly == false, the DB is created if necessary and
    initialized with HWMs.
    
    Pair-Programmed-With: Michael Adam <obnox at samba.org>
    
    Signed-off-by: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit f531c369eb65ab9c0150bb1693a1b89006254a12
Author: Michael Adam <obnox at samba.org>
Date:   Tue Sep 10 01:19:05 2013 +0200

    net: rename "idmap_dump_ctx" to "net_idmap_ctx".
    
    This started specific, but is now generic.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 29a94b0e1b9f7bb5824df5d66337a6b26a86a343
Author: Michael Adam <obnox at samba.org>
Date:   Mon Sep 9 17:30:32 2013 +0200

    net: move the "net idmap delete" functionality to subcommand "net idmap delete mapping"
    
    This is in preparation of adding more types of entries to delete...
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 68c4414fa5200914cba726f964dbe4f2e6407fff
Author: Michael Adam <obnox at samba.org>
Date:   Mon Sep 9 17:13:47 2013 +0200

    net: add the "net idmap set secret" subcommand as alias for "net idmap secret"
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit a064119cf295ff10a5c753405f5d9013751f0010
Author: Michael Adam <obnox at samba.org>
Date:   Fri Sep 6 18:01:20 2013 +0200

    net: move the "net idmap set" functionality to subcommand "net idmap set mapping"
    
    This is in preparation of adding more "net idmap set" subcommands for the autorid backend.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 601b67bc5774dbdbdec34862436d18c1ffb65f1c
Author: Michael Adam <obnox at samba.org>
Date:   Fri Sep 6 17:48:40 2013 +0200

    net: rename "net idmap setmap" to "net idmap set"
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 873ae9c6b7397769b01b23d022d0589ee501618f
Author: Michael Adam <obnox at samba.org>
Date:   Mon Sep 9 16:58:42 2013 +0200

    net: improve help text for "net idmap restore"
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 01e1794a11f4c4ff78ae63d57eb2de93e8f3798e
Author: Michael Adam <obnox at samba.org>
Date:   Mon Sep 9 16:58:05 2013 +0200

    net: improve help text for "net idmap dump"
    
    With idmap autorid "dump ID mappings" is not precise enough any more.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 4d0d348994e7e5322618aad891de57d223b8e10f
Author: Michael Adam <obnox at samba.org>
Date:   Thu Sep 5 14:53:11 2013 +0200

    idmap_autorid: add a comment explaining idmap_autorid_saveconfig()
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit ae88bcd1f0997e6349039973bf44292b87977305
Author: Michael Adam <obnox at samba.org>
Date:   Thu Sep 5 14:48:28 2013 +0200

    idmap_autorid: add a comment explaining idmap_autorid_loadconfig()
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 4deba6090b1d8c7bc2b8ff85e196905ad3a8ec43
Author: Michael Adam <obnox at samba.org>
Date:   Thu Sep 5 14:47:43 2013 +0200

    idmap_autorid: add a comment explaining idmap_autorid_db_init()
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 4c937f2dd2bf3d6fa695f07efbeb7c80b257fd10
Author: Michael Adam <obnox at samba.org>
Date:   Thu Sep 5 14:45:29 2013 +0200

    idmap_autorid: add a comment explaining idmap_autorid_init_hwm()
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 7cde714cfd4c526c35ada2597c58e5e7fc02e327
Author: Michael Adam <obnox at samba.org>
Date:   Thu Sep 5 14:43:26 2013 +0200

    idmap_autorid: add a comment explaining idmap_autorid_get_domainrange()
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit e8c9161a95471e9bdaacbc4beb7f96607c60c3a0
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 4 13:29:56 2013 +0200

    idmap_autorid: Don't use db as a temporary talloc context.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 11ea83e9ae3b90fdd6c9b097256958683d473105
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 4 13:13:15 2013 +0200

    idmap_autorid: improve two debug messages by printing NT error codes
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 85a15cac4495d7be5155e8c0bd6a6c60bd3eee51
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 4 13:11:28 2013 +0200

    idmap_autorid: fix a debug message in idmap_autorid_addrange()
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 266fddfe6a12d729c37b2cd28ee8095fa59b57a2
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 4 17:49:36 2013 +0200

    idmap_autorid: for clarity, add a wrapper idmap_autorid_acquire_range() to idmap_autorid_addrange()
    
    This one calls into the HWM bumping acquire code path.
    
    Pair-Programmed-With: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Signed-off-by: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 4350bfba4624710e66f0d9775d146086054a97cc
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 4 17:43:28 2013 +0200

    idmap_autorid: add new function idmap_autorid_setrange()
    
    This allows to directly set a range for a domsid#index pair.
    It fails if a stored range is found which is different from
    the requested one.
    
    Pair-Programmed-With: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Signed-off-by: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 6e08f5a7924fbf55477a1f53a72f23236c01c1d6
Author: Michael Adam <obnox at samba.org>
Date:   Fri Aug 30 18:49:28 2013 +0530

    idmap_autorid: factor out domain range adding code into a separate function
    
    This also adds a new mode to the new idmap_autorid_addrange() function
    that allows to set a provided range if the range is available, instead
    of the original only mode of automatically allocating a new range
    by incrementing the HWM counter.
    
    Pair-Programmed-With: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Signed-off-by: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 69dbc1577b113918e0ac7ffbfcfa1b54f51daf71
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 11 01:04:13 2013 +0200

    idmap_autorid: add idmap_autorid_getrange()
    
    Wrapper to idmap_autorid_getrange_int().
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit e598ed1698c1c2e23cae7c2eecb56e973e6cf5f7
Author: Michael Adam <obnox at samba.org>
Date:   Sun Sep 15 13:07:21 2013 +0200

    idmap_autorid: improve a debug message in idmap_autorid_getrange_int()
    
    Add output of status code.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 7d2fdaac6e9b04c0d738b6f682d384149ae0d165
Author: Atul Kulkarni <atul.kulkarni at in.ibm.com>
Date:   Fri Aug 30 16:18:39 2013 +0530

    idmap_autorid: factor out domain range fetching part from idmap_autorid_get_domainrange()
    
    Fatored out read-only function idmap_autorid_getrange() will be used elsewhere.
    
    Pair-Programmed-With: Michael Adam <obnox at samba.org>
    
    Signed-off-by: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 94ca5dc0bd99999921fb0dfb05e4f3d90e7a85b5
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Oct 1 12:23:06 2013 +0000

    idmap_autorid: Use fstr_sprintf in idmap_autorid_build_keystr()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 2d8cc3ed9e14d5de98794b131ecf4f4675d1f9d7
Author: Michael Adam <obnox at samba.org>
Date:   Fri Aug 30 17:31:16 2013 +0200

    idmap_autorid: factor building of the keystr into a function
    
    to avoid code duplication.
    
    Pair-Programmed-with: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Signed-off-by: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit f8767cd9d838b726b40271668f18199ee11a3791
Author: Atul Kulkarni <atul.kulkarni at in.ibm.com>
Date:   Fri Aug 30 13:49:10 2013 +0530

    idmap_autorid: remove fstring keystr from autorid_range_config
    
    This is just used to change the behaviour of the function.
    Making it more suitable to be used at other places.
    
    Signed-off-by: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    Reviewed-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 7cacc48563f6d16a74669bf572437b13f6f54250
Author: Atul Kulkarni <atul.kulkarni at in.ibm.com>
Date:   Fri Aug 30 13:35:49 2013 +0530

    idmap_autorid: remove autorid_global_config member from autorid_range_config
    
    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 at samba.org>
    
    Signed-off-by: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 65d7df105587fe14d057c3fa84c889f2c8c4500e
Author: Michael Adam <obnox at samba.org>
Date:   Tue Sep 10 18:27:46 2013 +0200

    idmap_autorid: improve idmap_autorid_saveconfig() by adding a talloc stackframe
    
    Pair-Programmed-With: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Signed-off-by: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 65881c3118044e101d4b04737c471725802a4e09
Author: Atul Kulkarni <atul.kulkarni at in.ibm.com>
Date:   Wed Aug 28 17:19:30 2013 +0200

    idmap_autorid: move the checks from idmap_autorid_initialize to idmap_autorid_saveconfig()
    
    Pair-Programmed-With: Michael Adam <obnox at samba.org>
    
    Signed-off-by: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 802b9d7ec614e25ff99c367cfaf267d8334311f1
Author: Michael Adam <obnox at samba.org>
Date:   Tue Sep 10 18:07:15 2013 +0200

    idmap_autorid: change idmap_autorid_loadconfig() to return NTSTATUS
    
    for better error propagation.
    
    Pair-Programmed-With: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Signed-off-by: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit f6c34b1e236aab275d6cfbc12e57af7d692b8c19
Author: Michael Adam <obnox at samba.org>
Date:   Wed Aug 28 15:29:37 2013 +0200

    idmap_autorid: refactor idmap_autorid_parse_configstr() out of idmap_autorid_loadconfig()
    
    This will be used for other purposes as well.
    
    Pair-Programmed-with: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Signed-off-by: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 42a6bb722884de1ba2d876fcb62343aad7594bb7
Author: Michael Adam <obnox at samba.org>
Date:   Tue Sep 10 13:43:15 2013 +0200

    idmap_autorid: rename TALLOC_CTX argument of idmap_autorid_loadconfig() to mem_ctx
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 56c80d1c829978ac394a022ff2e069c2ccfee5b4
Author: Michael Adam <obnox at samba.org>
Date:   Wed Aug 28 14:32:19 2013 +0200

    idmap_autorid: refactor idmap_autorid_loadconfig to use idmap_config_getconfigstr
    
    Pair-Programmed-with: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Signed-off-by: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 173cdfe0a42f6d4917b0d28bfd23d7fff1ccf232
Author: Michael Adam <obnox at samba.org>
Date:   Wed Aug 28 14:20:13 2013 +0200

    idmap_autorid_tdb: add idmap_autorid_getconfigstr()
    
    Pair-Programmed-With: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Signed-off-by: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit f80f43c772e8c5504111dd4274eb928e61fa56ed
Author: Atul Kulkarni <atul.kulkarni at in.ibm.com>
Date:   Wed Aug 28 13:19:27 2013 +0530

    idmap_autorid: extract common code to separate file
    
    This is in preparation of adding "net idmap autorid" functionality.
    
    Pair-Programmed-With: Michael Adam <obnox at samba.org>
    
    Signed-off-by: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 41450fe1c39ff56ff9384a3055b44f3310336abb
Author: Michael Adam <obnox at samba.org>
Date:   Wed Aug 28 15:07:44 2013 +0200

    idmap_autorid: remove the ignore_builtin bool from the global_config struct
    
    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 at samba.org>
    
    Signed-off-by: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 954d9fbd45dd37cf99fa65c0ffc7ef2f43b353ca
Author: Atul Kulkarni <atul.kulkarni at in.ibm.com>
Date:   Fri Aug 30 13:29:01 2013 +0200

    idmap_autorid: add path, and db parameters to idmap_autorid_db_init()
    
    In preparation of calling this from net for different dbs.
    
    Pair-Programmed-With: Michael Adam <obnox at samba.org>
    
    Signed-off-by: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit 105475c77e8a721476010a1cf9be8998cebd48bb
Author: Michael Adam <obnox at samba.org>
Date:   Fri Aug 30 13:20:15 2013 +0200

    idmap_autorid: add a db_context argument to idmap_autorid_init_hwm()
    
    Pair-Programmed-With: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Signed-off-by: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit a54e21bdc3624ab85bbe2a2112598c05feb2d56f
Author: Michael Adam <obnox at samba.org>
Date:   Wed Aug 28 14:03:33 2013 +0200

    idmap_autorid: add a db_context argument to idmap_autorid_saveconfig()
    
    Pair-Programmed-with: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Signed-off-by: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit dd004e8193ccdbb94de4c32e301a163f0b6d2d0e
Author: Michael Adam <obnox at samba.org>
Date:   Wed Aug 28 14:00:24 2013 +0200

    idmap_autorid: add a db_context argument to idmap_autorid_loadconfig()
    
    Pair-Programmed-with: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Signed-off-by: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

commit fdf8d93ac51d57a91fe51de9bfddf363e1cfab81
Author: Michael Adam <obnox at samba.org>
Date:   Wed Aug 28 13:53:22 2013 +0200

    idmap_autorid: add a db_context argument to idmap_autorid_get_domainrange()
    
    Pair-Programmed-with: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Signed-off-by: Atul Kulkarni <atul.kulkarni at in.ibm.com>
    Reviewed-by: Volker Lendecke <vl at samba.org>

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

Summary of changes:
 source3/include/idmap_autorid_tdb.h  |  199 ++++++
 source3/utils/net_idmap.c            |  684 +++++++++++++++++++-
 source3/winbindd/idmap_autorid.c     |  352 +----------
 source3/winbindd/idmap_autorid_tdb.c | 1159 ++++++++++++++++++++++++++++++++++
 source3/winbindd/wscript_build       |    6 +-
 source3/wscript_build                |    3 +-
 6 files changed, 2042 insertions(+), 361 deletions(-)
 create mode 100644 source3/include/idmap_autorid_tdb.h
 create mode 100644 source3/winbindd/idmap_autorid_tdb.c


Changeset truncated at 500 lines:

diff --git a/source3/include/idmap_autorid_tdb.h b/source3/include/idmap_autorid_tdb.h
new file mode 100644
index 0000000..acf4026
--- /dev/null
+++ b/source3/include/idmap_autorid_tdb.h
@@ -0,0 +1,199 @@
+/*
+ *  idmap_autorid: static map between Active Directory/NT RIDs
+ *  and RFC 2307 accounts. This file contains common functions
+ *  and structures used by idmap_autorid and net idmap autorid utilities
+ *
+ *  Copyright (C) Christian Ambach, 2010-2012
+ *  Copyright (C) Atul Kulkarni, 2013
+ *  Copyright (C) Michael Adam, 2012-2013
+ *
+ *  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/>.
+ *
+ */
+
+#ifndef _IDMAP_AUTORID_H_
+#define _IDMAP_AUTORID_H_
+
+#include "includes.h"
+#include "system/filesys.h"
+#include "dbwrap/dbwrap.h"
+#include "dbwrap/dbwrap_open.h"
+#include "../lib/util/util_tdb.h"
+#include "winbindd/idmap_tdb_common.h"
+
+#define HWM "NEXT RANGE"
+#define ALLOC_HWM_UID "NEXT ALLOC UID"
+#define ALLOC_HWM_GID "NEXT ALLOC GID"
+#define ALLOC_RANGE "ALLOC"
+#define CONFIGKEY "CONFIG"
+
+struct autorid_global_config {
+	uint32_t minvalue;
+	uint32_t rangesize;
+	uint32_t maxranges;
+};
+
+struct autorid_range_config {
+	fstring domsid;
+	uint32_t rangenum;
+	uint32_t domain_range_index;
+	uint32_t low_id;
+};
+
+/**
+ * Get the range for a pair consisting of the domain sid
+ * and a domain range. If there is no stored range for
+ * this pair and read_only == false, a new range is
+ * acquired by incrementing that range HWM counter in the
+ * database.
+ */
+NTSTATUS idmap_autorid_get_domainrange(struct db_context *db,
+				       struct autorid_range_config *range,
+				       bool read_only);
+
+/**
+ * get the domain range and low_id for the domain
+ * identified by domsid and domain_range_index
+ */
+NTSTATUS idmap_autorid_getrange(struct db_context *db,
+				const char *domsid,
+				uint32_t domain_range_index,
+				uint32_t *rangenum,
+				uint32_t *low_id);
+
+/**
+ * Set a range for a domain#index pair to a given
+ * number. Fail if a different range was already stored.
+ */
+NTSTATUS idmap_autorid_setrange(struct db_context *db,
+				const char *domsid,
+				uint32_t domain_range_index,
+				uint32_t rangenum);
+
+/**
+ * Delete a domain#index <-> range maping from the database.
+ * The mapping is specified by the sid and index.
+ * If force == true, invalid mapping records are deleted as far
+ * as possible, otherwise they are left untouched.
+ */
+NTSTATUS idmap_autorid_delete_range_by_sid(struct db_context *db,
+					   const char *domsid,
+					   uint32_t domain_range_index,
+					   bool force);
+
+/**
+ * Delete a domain#index <-> range maping from the database.
+ * The mapping is specified by the range number.
+ * If force == true, invalid mapping records are deleted as far
+ * as possible, otherwise they are left untouched.
+ */
+NTSTATUS idmap_autorid_delete_range_by_num(struct db_context *db,
+					   uint32_t rangenum,
+					   bool force);
+
+/**
+ * Initialize a specified HWM value to 0 if it is not
+ * yet present in the database.
+ */
+NTSTATUS idmap_autorid_init_hwm(struct db_context *db, const char *hwm);
+
+/**
+ * Initialize an idmap_autorid database.
+ * After this function has successfully completed, the following are true:
+ * - the database exists
+ * - the required HWM keys exist (range, alloc-uid, alloc-gid)
+ */
+NTSTATUS idmap_autorid_db_init(const char *path,
+			       TALLOC_CTX *mem_ctx,
+			       struct db_context **db);
+
+/**
+ * Load the configuration stored in the autorid database.
+ */
+NTSTATUS idmap_autorid_loadconfig(struct db_context *db,
+				  TALLOC_CTX *ctx,
+				  struct autorid_global_config **result);
+
+/**
+ * Save the global autorid configuration into the autorid database.
+ * The stored configuration consists of:
+ * - the low value of the idmap range
+ * - the rangesize
+ * - the maximum number of ranges
+ */
+NTSTATUS idmap_autorid_saveconfig(struct db_context *db,
+				  struct autorid_global_config *cfg);
+
+/**
+ * get the range config string stored in the database
+ */
+NTSTATUS idmap_autorid_getconfigstr(struct db_context *db, TALLOC_CTX *mem_ctx,
+				    char **result);
+
+/**
+ * parse the handed in config string and fill the provided config structure.
+ * return false if the string could not be parsed.
+ */
+bool idmap_autorid_parse_configstr(const char *configstr,
+				   struct autorid_global_config *cfg);
+
+
+/**
+ * Save the global autorid configuration into the autorid database
+ * as provided in the config string.
+ * First parse the configstr and validate it.
+ */
+NTSTATUS idmap_autorid_saveconfigstr(struct db_context *db,
+				     const char *configstr);
+
+
+/**
+ * idmap_autorid_iterate_domain_ranges:
+ * perform an action on all domain range mappings for a given domain
+ * specified by domain sid.
+ */
+NTSTATUS idmap_autorid_iterate_domain_ranges(struct db_context *db,
+					const char *domsid,
+					NTSTATUS (*fn)(struct db_context *db,
+						       const char *domsid,
+						       uint32_t index,
+						       uint32_t rangenum,
+						       void *private_data),
+					void *private_data,
+					int *count);
+
+/**
+ * idmap_autorid_iterate_domain_ranges_read:
+ * perform a read only action on all domain range mappings for a given domain
+ * specified by domain sid.
+ */
+NTSTATUS idmap_autorid_iterate_domain_ranges_read(struct db_context *db,
+					const char *domsid,
+					NTSTATUS (*fn)(struct db_context *db,
+						       const char *domsid,
+						       uint32_t index,
+						       uint32_t rangenum,
+						       void *private_data),
+					void *private_data,
+					int *count);
+
+/**
+ * delete all range mappings for a given domain
+ */
+NTSTATUS idmap_autorid_delete_domain_ranges(struct db_context *db,
+					    const char *domsid,
+					    bool force,
+					    int *count);
+
+#endif /* _IDMAP_AUTORID_H_ */
diff --git a/source3/utils/net_idmap.c b/source3/utils/net_idmap.c
index fbeca3e..de2d509 100644
--- a/source3/utils/net_idmap.c
+++ b/source3/utils/net_idmap.c
@@ -27,6 +27,7 @@
 #include "../libcli/security/security.h"
 #include "net_idmap_check.h"
 #include "util_tdb.h"
+#include "idmap_autorid_tdb.h"
 
 #define ALLOC_CHECK(mem) do { \
 	if (!mem) { \
@@ -40,7 +41,7 @@ enum idmap_dump_backend {
 	AUTORID
 };
 
-struct idmap_dump_ctx {
+struct net_idmap_ctx {
 	enum idmap_dump_backend backend;
 };
 
@@ -129,7 +130,7 @@ static int net_idmap_dump_one_tdb_entry(struct db_record *rec,
 }
 
 static const char* net_idmap_dbfile(struct net_context *c,
-				    struct idmap_dump_ctx *ctx)
+				    struct net_idmap_ctx *ctx)
 {
 	const char* dbfile = NULL;
 	const char *backend = NULL;
@@ -180,6 +181,56 @@ static const char* net_idmap_dbfile(struct net_context *c,
 	return dbfile;
 }
 
+static bool net_idmap_opendb_autorid(TALLOC_CTX *mem_ctx,
+				     struct net_context *c,
+				     bool readonly,
+				     struct db_context **db)
+{
+	bool ret = false;
+	const char *dbfile;
+	struct net_idmap_ctx ctx = { .backend = AUTORID };
+
+	if (c == NULL) {
+		goto done;
+	}
+
+	dbfile = net_idmap_dbfile(c, &ctx);
+	if (dbfile == NULL) {
+		goto done;
+	}
+
+	if (ctx.backend != AUTORID) {
+		d_fprintf(stderr, _("Unsupported backend\n"));
+		goto done;
+	}
+
+	if (readonly) {
+		*db = db_open(mem_ctx, dbfile, 0, TDB_DEFAULT, O_RDONLY, 0,
+			     DBWRAP_LOCK_ORDER_1);
+		if (*db == NULL) {
+			d_fprintf(stderr,
+				  _("Could not open autorid db (%s): %s\n"),
+				 dbfile, strerror(errno));
+			goto done;
+		}
+	} else {
+		NTSTATUS status;
+		status = idmap_autorid_db_init(dbfile, mem_ctx, db);
+		if (!NT_STATUS_IS_OK(status)) {
+			d_fprintf(stderr,
+				_("Error calling idmap_autorid_db_init: %s\n"),
+				nt_errstr(status));
+			goto done;
+		}
+	}
+
+	ret = true;
+
+done:
+	return ret;
+}
+
+
 /***********************************************************
  Dump the current idmap
  **********************************************************/
@@ -190,7 +241,7 @@ static int net_idmap_dump(struct net_context *c, int argc, const char **argv)
 	const char* dbfile;
 	NTSTATUS status;
 	int ret = -1;
-	struct idmap_dump_ctx ctx = { .backend = TDB };
+	struct net_idmap_ctx ctx = { .backend = TDB };
 
 	if ( argc > 1  || c->display_usage) {
 		d_printf("%s\n%s",
@@ -292,7 +343,7 @@ static int net_idmap_restore(struct net_context *c, int argc, const char **argv)
 	struct db_context *db;
 	const char *dbfile = NULL;
 	int ret = 0;
-	struct idmap_dump_ctx ctx = { .backend = TDB };
+	struct net_idmap_ctx ctx = { .backend = TDB };
 
 	if (c->display_usage) {
 		d_printf("%s\n%s",
@@ -516,7 +567,8 @@ static bool delete_args_ok(int argc, const char **argv)
 	return false;
 }
 
-static int net_idmap_delete(struct net_context *c, int argc, const char **argv)
+static int net_idmap_delete_mapping(struct net_context *c, int argc,
+				    const char **argv)
 {
 	int ret = -1;
 	struct db_context *db;
@@ -524,12 +576,12 @@ static int net_idmap_delete(struct net_context *c, int argc, const char **argv)
 	TDB_DATA key;
 	NTSTATUS status;
 	const char* dbfile;
-	struct idmap_dump_ctx ctx = { .backend = TDB };
+	struct net_idmap_ctx ctx = { .backend = TDB };
 
 	if ( !delete_args_ok(argc,argv) || c->display_usage) {
 		d_printf("%s\n%s",
 			 _("Usage:"),
-			 _("net idmap delete [-f] [--db=<TDB>] <ID>\n"
+			 _("net idmap delete mapping [-f] [--db=<TDB>] <ID>\n"
 			   "  Delete mapping of ID from TDB.\n"
 			   "    -f\tforce\n"
 			   "    TDB\tidmap database\n"
@@ -570,11 +622,292 @@ done:
 	return ret;
 }
 
-static int net_idmap_set(struct net_context *c, int argc, const char **argv)
+static bool parse_uint32(const char *str, uint32_t *result)
+{
+	unsigned long val;
+	char *endptr;
+
+	val = strtoul(str, &endptr, 10);
+
+	if (str == endptr) {
+		return false;
+	}
+	if (*endptr != '\0') {
+		return false;
+	}
+	if ((val == ULONG_MAX) && (errno == ERANGE)) {
+		return false;
+	}
+	if ((val & UINT32_MAX) != val) {
+		/* overflow */
+		return false;
+	}
+	*result = val;		/* Potential crop */
+	return true;
+}
+
+static void net_idmap_autorid_delete_range_usage(void)
+{
+	d_printf("%s\n%s",
+		 _("Usage:"),
+		 _("net idmap delete range [-f] [--db=<TDB>] <RANGE>|(<SID>[ <INDEX>])\n"
+		   "  Delete a domain range mapping from the database.\n"
+		   "    -f\tforce\n"
+		   "    TDB\tidmap database\n"
+		   "    RANGE\tthe range number to delete\n"
+		   "    SID\t\tSID of the domain\n"
+		   "    INDEX\trange index number do delete for the domain\n"));
+}
+
+static int net_idmap_autorid_delete_range(struct net_context *c, int argc,
+					  const char **argv)
+{
+	int ret = -1;
+	struct db_context *db = NULL;
+	NTSTATUS status;
+	uint32_t rangenum;
+	uint32_t range_index;
+	const char *domsid;
+	TALLOC_CTX *mem_ctx = NULL;
+	bool ok;
+	bool force = (c->opt_force != 0);
+
+	if (c->display_usage) {
+		net_idmap_autorid_delete_range_usage();
+		return 0;
+	}
+
+	if (argc < 1 || argc > 2) {
+		net_idmap_autorid_delete_range_usage();
+		return -1;
+	}
+
+	mem_ctx = talloc_stackframe();
+	if (!net_idmap_opendb_autorid(mem_ctx, c, false, &db)) {
+		goto done;
+	}
+
+	ok = parse_uint32(argv[0], &rangenum);
+	if (ok) {
+		d_printf("%s: %"PRIu32"\n", _("Deleting range number"),
+			 rangenum);
+
+		status = idmap_autorid_delete_range_by_num(db, rangenum,
+							   force);
+		if (!NT_STATUS_IS_OK(status)) {
+			d_fprintf(stderr, "%s: %s\n",
+				  _("Failed to delete domain range mapping"),
+				  nt_errstr(status));
+		} else {
+			ret = 0;
+		}
+
+		goto done;
+	}
+
+	domsid = argv[0];
+
+	if (argc == 2) {
+		ok = parse_uint32(argv[1], &range_index);
+		if (!ok) {
+			d_printf("%s: %s\n",
+				 _("Invalid index specification"), argv[1]);
+			net_idmap_autorid_delete_range_usage();
+			goto done;
+		}
+	}
+
+	status = idmap_autorid_delete_range_by_sid(db, domsid, range_index,
+						   force);
+	if (!NT_STATUS_IS_OK(status)) {
+		d_fprintf(stderr, "%s: %s\n",
+			  _("Failed to delete domain range mapping"),
+			  nt_errstr(status));
+		goto done;
+	}
+
+	ret = 0;
+
+done:
+	talloc_free(mem_ctx);
+	return ret;
+}
+
+static void net_idmap_autorid_delete_ranges_usage(void)
+{
+	d_printf("%s\n%s",
+		 _("Usage:"),
+		 _("net idmap delete ranges [-f] [--db=<TDB>] <SID>)\n"
+		   "  Delete all domain range mappings for a given domain.\n"
+		   "    -f\tforce\n"
+		   "    TDB\tidmap database\n"
+		   "    SID\t\tSID of the domain\n"));
+}
+
+static int net_idmap_autorid_delete_ranges(struct net_context *c, int argc,
+					   const char **argv)
+{
+	int ret = -1;
+	struct db_context *db = NULL;
+	NTSTATUS status;
+	const char *domsid;
+	TALLOC_CTX *mem_ctx = NULL;
+	bool force = (c->opt_force != 0);
+	int count = 0;
+
+	if (c->display_usage) {
+		net_idmap_autorid_delete_ranges_usage();
+		return 0;
+	}
+
+	if (argc != 1) {
+		net_idmap_autorid_delete_ranges_usage();
+		return -1;
+	}
+
+	domsid = argv[0];
+
+	mem_ctx = talloc_stackframe();
+	if (!net_idmap_opendb_autorid(mem_ctx, c, false, &db)) {
+		goto done;
+	}
+
+	status = idmap_autorid_delete_domain_ranges(db, domsid, force, &count);
+	if (!NT_STATUS_IS_OK(status)) {
+		d_fprintf(stderr, "%s %s: %s\n",
+			  _("Failed to delete domain range mappings for "
+			    "domain"),
+			  domsid,
+			  nt_errstr(status));
+		goto done;
+	}
+


-- 
Samba Shared Repository


More information about the samba-cvs mailing list