summaryrefslogtreecommitdiff
path: root/source3/nsswitch/idmap_tdb.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2007-04-18 21:10:37 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:19:27 -0500
commit01be4914b37f7e5887f3ecd4ecc53fbd846fc22e (patch)
tree3a5c3f59ddb48c4c2a369c9999b98801615c6c0d /source3/nsswitch/idmap_tdb.c
parent256f506c5b060c37ee22ee9ff0c371154721252a (diff)
downloadsamba-01be4914b37f7e5887f3ecd4ecc53fbd846fc22e.tar.gz
samba-01be4914b37f7e5887f3ecd4ecc53fbd846fc22e.tar.bz2
samba-01be4914b37f7e5887f3ecd4ecc53fbd846fc22e.zip
r22343: Commit to 3_0 as well after adapting the patch.
(tdb_delete_bystring instead of tdb_delete is used here) (This used to be commit ee40cead097ed2c005f5f80b24c9f681e054849a)
Diffstat (limited to 'source3/nsswitch/idmap_tdb.c')
-rw-r--r--source3/nsswitch/idmap_tdb.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/source3/nsswitch/idmap_tdb.c b/source3/nsswitch/idmap_tdb.c
index 73db1def0c..4eb47c42b8 100644
--- a/source3/nsswitch/idmap_tdb.c
+++ b/source3/nsswitch/idmap_tdb.c
@@ -586,7 +586,7 @@ struct idmap_tdb_context {
Initialise idmap database.
*****************************/
-static NTSTATUS idmap_tdb_db_init(struct idmap_domain *dom, const char *compat_params)
+static NTSTATUS idmap_tdb_db_init(struct idmap_domain *dom)
{
NTSTATUS ret;
struct idmap_tdb_context *ctx;
@@ -620,6 +620,7 @@ static NTSTATUS idmap_tdb_db_init(struct idmap_domain *dom, const char *compat_p
}
dom->private_data = ctx;
+ dom->initialized = True;
talloc_free(config_option);
return NT_STATUS_OK;
@@ -772,6 +773,14 @@ static NTSTATUS idmap_tdb_unixids_to_sids(struct idmap_domain *dom, struct id_ma
NTSTATUS ret;
int i;
+ /* make sure we initialized */
+ if ( ! dom->initialized) {
+ ret = idmap_tdb_db_init(dom);
+ if ( ! NT_STATUS_IS_OK(ret)) {
+ return ret;
+ }
+ }
+
ctx = talloc_get_type(dom->private_data, struct idmap_tdb_context);
for (i = 0; ids[i]; i++) {
@@ -810,6 +819,14 @@ static NTSTATUS idmap_tdb_sids_to_unixids(struct idmap_domain *dom, struct id_ma
NTSTATUS ret;
int i;
+ /* make sure we initialized */
+ if ( ! dom->initialized) {
+ ret = idmap_tdb_db_init(dom);
+ if ( ! NT_STATUS_IS_OK(ret)) {
+ return ret;
+ }
+ }
+
ctx = talloc_get_type(dom->private_data, struct idmap_tdb_context);
for (i = 0; ids[i]; i++) {
@@ -849,6 +866,14 @@ static NTSTATUS idmap_tdb_set_mapping(struct idmap_domain *dom, const struct id_
TDB_DATA ksid, kid, data;
char *ksidstr, *kidstr;
+ /* make sure we initialized */
+ if ( ! dom->initialized) {
+ ret = idmap_tdb_db_init(dom);
+ if ( ! NT_STATUS_IS_OK(ret)) {
+ return ret;
+ }
+ }
+
if (!map || !map->sid) {
return NT_STATUS_INVALID_PARAMETER;
}
@@ -954,6 +979,14 @@ static NTSTATUS idmap_tdb_remove_mapping(struct idmap_domain *dom, const struct
TDB_DATA ksid, kid, data;
char *ksidstr, *kidstr;
+ /* make sure we initialized */
+ if ( ! dom->initialized) {
+ ret = idmap_tdb_db_init(dom);
+ if ( ! NT_STATUS_IS_OK(ret)) {
+ return ret;
+ }
+ }
+
if (!map || !map->sid) {
return NT_STATUS_INVALID_PARAMETER;
}
@@ -1133,6 +1166,14 @@ static NTSTATUS idmap_tdb_dump_data(struct idmap_domain *dom, struct id_map **ma
struct dump_data *data;
NTSTATUS ret = NT_STATUS_OK;
+ /* make sure we initialized */
+ if ( ! dom->initialized) {
+ ret = idmap_tdb_db_init(dom);
+ if ( ! NT_STATUS_IS_OK(ret)) {
+ return ret;
+ }
+ }
+
ctx = talloc_get_type(dom->private_data, struct idmap_tdb_context);
data = talloc_zero(ctx, struct dump_data);