summaryrefslogtreecommitdiff
path: root/source3/winbindd/idmap_tdb2.c
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2010-06-17 08:23:25 +0200
committerMichael Adam <obnox@samba.org>2010-08-14 02:10:45 +0200
commitd27992e70837850136b93b93886740c77ead0416 (patch)
treef7bd02a98a38789969b8d52f126c0a5ab5db4162 /source3/winbindd/idmap_tdb2.c
parent3bc40a09799ed3b39ff387d07b0a3928ae800444 (diff)
downloadsamba-d27992e70837850136b93b93886740c77ead0416.tar.gz
samba-d27992e70837850136b93b93886740c77ead0416.tar.bz2
samba-d27992e70837850136b93b93886740c77ead0416.zip
s3:idmap_tdb2: move idmap_tdb2_set_mapping() up to its _action callback.
Diffstat (limited to 'source3/winbindd/idmap_tdb2.c')
-rw-r--r--source3/winbindd/idmap_tdb2.c123
1 files changed, 62 insertions, 61 deletions
diff --git a/source3/winbindd/idmap_tdb2.c b/source3/winbindd/idmap_tdb2.c
index 85f3f03ea0..096e3a9411 100644
--- a/source3/winbindd/idmap_tdb2.c
+++ b/source3/winbindd/idmap_tdb2.c
@@ -317,6 +317,11 @@ failed:
return ret;
}
+
+/**
+ * store a mapping in the database.
+ */
+
struct idmap_tdb2_set_mapping_context {
const char *ksidstr;
const char *kidstr;
@@ -366,6 +371,63 @@ done:
return ret;
}
+static NTSTATUS idmap_tdb2_set_mapping(struct idmap_domain *dom, const struct id_map *map)
+{
+ struct idmap_tdb2_context *ctx;
+ NTSTATUS ret;
+ char *ksidstr, *kidstr;
+ struct idmap_tdb2_set_mapping_context state;
+
+ if (!map || !map->sid) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ ksidstr = kidstr = NULL;
+
+ /* TODO: should we filter a set_mapping using low/high filters ? */
+
+ ctx = talloc_get_type(dom->private_data, struct idmap_tdb2_context);
+
+ switch (map->xid.type) {
+
+ case ID_TYPE_UID:
+ kidstr = talloc_asprintf(ctx, "UID %lu", (unsigned long)map->xid.id);
+ break;
+
+ case ID_TYPE_GID:
+ kidstr = talloc_asprintf(ctx, "GID %lu", (unsigned long)map->xid.id);
+ break;
+
+ default:
+ DEBUG(2, ("INVALID unix ID type: 0x02%x\n", map->xid.type));
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
+ if (kidstr == NULL) {
+ DEBUG(0, ("ERROR: Out of memory!\n"));
+ ret = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+
+ ksidstr = sid_string_talloc(ctx, map->sid);
+ if (ksidstr == NULL) {
+ DEBUG(0, ("Out of memory!\n"));
+ ret = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+
+ state.ksidstr = ksidstr;
+ state.kidstr = kidstr;
+
+ ret = dbwrap_trans_do(ctx->db, idmap_tdb2_set_mapping_action,
+ &state);
+
+done:
+ talloc_free(ksidstr);
+ talloc_free(kidstr);
+ return ret;
+}
+
/*
run a script to perform a mapping
@@ -776,67 +838,6 @@ static NTSTATUS idmap_tdb2_sids_to_unixids(struct idmap_domain *dom, struct id_m
}
-/*
- set a mapping.
-*/
-
-static NTSTATUS idmap_tdb2_set_mapping(struct idmap_domain *dom, const struct id_map *map)
-{
- struct idmap_tdb2_context *ctx;
- NTSTATUS ret;
- char *ksidstr, *kidstr;
- struct idmap_tdb2_set_mapping_context state;
-
- if (!map || !map->sid) {
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- ksidstr = kidstr = NULL;
-
- /* TODO: should we filter a set_mapping using low/high filters ? */
-
- ctx = talloc_get_type(dom->private_data, struct idmap_tdb2_context);
-
- switch (map->xid.type) {
-
- case ID_TYPE_UID:
- kidstr = talloc_asprintf(ctx, "UID %lu", (unsigned long)map->xid.id);
- break;
-
- case ID_TYPE_GID:
- kidstr = talloc_asprintf(ctx, "GID %lu", (unsigned long)map->xid.id);
- break;
-
- default:
- DEBUG(2, ("INVALID unix ID type: 0x02%x\n", map->xid.type));
- return NT_STATUS_INVALID_PARAMETER;
- }
-
- if (kidstr == NULL) {
- DEBUG(0, ("ERROR: Out of memory!\n"));
- ret = NT_STATUS_NO_MEMORY;
- goto done;
- }
-
- ksidstr = sid_string_talloc(ctx, map->sid);
- if (ksidstr == NULL) {
- DEBUG(0, ("Out of memory!\n"));
- ret = NT_STATUS_NO_MEMORY;
- goto done;
- }
-
- state.ksidstr = ksidstr;
- state.kidstr = kidstr;
-
- ret = dbwrap_trans_do(ctx->db, idmap_tdb2_set_mapping_action,
- &state);
-
-done:
- talloc_free(ksidstr);
- talloc_free(kidstr);
- return ret;
-}
-
/**
* Create a new mapping for an unmapped SID, also allocating a new ID.
* This should be run inside a transaction.