summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2009-07-29 13:43:29 +0200
committerMichael Adam <obnox@samba.org>2009-07-29 16:26:20 +0200
commitd916e56c4c9dc729dc88418f75ebbbf943597476 (patch)
tree41c51f61cfc653d06c20a211d075cdd1b576a800
parenta9bea871c963710fe06822dad56aa31029b59a1a (diff)
downloadsamba-d916e56c4c9dc729dc88418f75ebbbf943597476.tar.gz
samba-d916e56c4c9dc729dc88418f75ebbbf943597476.tar.bz2
samba-d916e56c4c9dc729dc88418f75ebbbf943597476.zip
s3:winbind: in idmap_tdb2_sid_to_id(), use transaction wrapped stores.
When a mapping is not found, then the idmap script is called (if defined). When this gives a reply for the desired sid, this reply is stored in the db. This patch wraps theses two store operations into a transaction by re-using the idmap_tdb2_set_mapping_action() function previously defined for idmap_tdb2_set_mapping(). Michael
-rw-r--r--source3/winbindd/idmap_tdb2.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/source3/winbindd/idmap_tdb2.c b/source3/winbindd/idmap_tdb2.c
index 6ae13d9777..92e1db8460 100644
--- a/source3/winbindd/idmap_tdb2.c
+++ b/source3/winbindd/idmap_tdb2.c
@@ -704,7 +704,8 @@ static NTSTATUS idmap_tdb2_sid_to_id(struct idmap_tdb2_context *ctx, struct id_m
/* Check if sid is present in database */
data = dbwrap_fetch_bystring(idmap_tdb2, tmp_ctx, keystr);
if (!data.dptr) {
- fstring idstr;
+ char *idstr;
+ struct idmap_tdb2_set_mapping_context store_state;
DEBUG(10,(__location__ " Record %s not found\n", keystr));
@@ -719,14 +720,19 @@ static NTSTATUS idmap_tdb2_sid_to_id(struct idmap_tdb2_context *ctx, struct id_m
goto done;
}
- snprintf(idstr, sizeof(idstr), "%cID %lu",
- map->xid.type == ID_TYPE_UID?'U':'G',
- (unsigned long)map->xid.id);
- /* store both forward and reverse mappings */
- dbwrap_store_bystring(idmap_tdb2, keystr, string_term_tdb_data(idstr),
- TDB_REPLACE);
- dbwrap_store_bystring(idmap_tdb2, idstr, string_term_tdb_data(keystr),
- TDB_REPLACE);
+ idstr = talloc_asprintf(tmp_ctx, "%cID %lu",
+ map->xid.type == ID_TYPE_UID?'U':'G',
+ (unsigned long)map->xid.id);
+ if (idstr == NULL) {
+ ret = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+
+ store_state.ksidstr = keystr;
+ store_state.kidstr = idstr;
+
+ ret = dbwrap_trans_do(idmap_tdb2, idmap_tdb2_set_mapping_action,
+ &store_state);
goto done;
}