summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2009-07-29 13:36:18 +0200
committerMichael Adam <obnox@samba.org>2009-07-29 16:26:20 +0200
commita9bea871c963710fe06822dad56aa31029b59a1a (patch)
tree04683f4d5acc6bb03fdf5cbd58a6294564041dcc /source3
parent9e20e178b3500fe4a32f4b4b1651a3514484fd28 (diff)
downloadsamba-a9bea871c963710fe06822dad56aa31029b59a1a.tar.gz
samba-a9bea871c963710fe06822dad56aa31029b59a1a.tar.bz2
samba-a9bea871c963710fe06822dad56aa31029b59a1a.zip
s3:winbind: in idmap_tdb2_id_to_sid(), 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 id, 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
Diffstat (limited to 'source3')
-rw-r--r--source3/winbindd/idmap_tdb2.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/source3/winbindd/idmap_tdb2.c b/source3/winbindd/idmap_tdb2.c
index 540c3f85fc..6ae13d9777 100644
--- a/source3/winbindd/idmap_tdb2.c
+++ b/source3/winbindd/idmap_tdb2.c
@@ -632,7 +632,8 @@ static NTSTATUS idmap_tdb2_id_to_sid(struct idmap_tdb2_context *ctx, struct id_m
data = dbwrap_fetch_bystring(idmap_tdb2, keystr, keystr);
if (!data.dptr) {
- fstring sidstr;
+ char *sidstr;
+ struct idmap_tdb2_set_mapping_context store_state;
DEBUG(10,("Record %s not found\n", keystr));
if (idmap_tdb2_state.idmap_script == NULL) {
@@ -647,15 +648,17 @@ static NTSTATUS idmap_tdb2_id_to_sid(struct idmap_tdb2_context *ctx, struct id_m
goto done;
}
- if (sid_to_fstring(sidstr, map->sid)) {
- /* both forward and reverse mappings */
- dbwrap_store_bystring(idmap_tdb2, keystr,
- string_term_tdb_data(sidstr),
- TDB_REPLACE);
- dbwrap_store_bystring(idmap_tdb2, sidstr,
- string_term_tdb_data(keystr),
- TDB_REPLACE);
+ sidstr = sid_string_talloc(keystr, map->sid);
+ if (!sidstr) {
+ ret = NT_STATUS_NO_MEMORY;
+ goto done;
}
+
+ store_state.ksidstr = sidstr;
+ store_state.kidstr = keystr;
+
+ ret = dbwrap_trans_do(idmap_tdb2, idmap_tdb2_set_mapping_action,
+ &store_state);
goto done;
}