summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorChristian Ambach <ambi@samba.org>2012-12-07 13:43:57 +0100
committerMichael Adam <obnox@samba.org>2013-02-05 17:36:34 +0100
commit8473764234bfec2f21b87ec69c213af4365749b4 (patch)
tree42fcfac45c18b7615a4c8f46e527424584792f12 /source3/utils
parent9aa79c11f07624d10f49a6840e93e84739997ffe (diff)
downloadsamba-8473764234bfec2f21b87ec69c213af4365749b4.tar.gz
samba-8473764234bfec2f21b87ec69c213af4365749b4.tar.bz2
samba-8473764234bfec2f21b87ec69c213af4365749b4.zip
s3:net_idmap_delete do not lock two records at the same time
the lock order check will prohibit this and as we are running inside a transaction there is no need to lock the records before deleting them Pair-Programmed-With: Michael Adam <obnox@samba.org> Signed-off-by: Christian Ambach <ambi@samba.org> Signed-off-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/utils')
-rw-r--r--source3/utils/net_idmap.c49
1 files changed, 25 insertions, 24 deletions
diff --git a/source3/utils/net_idmap.c b/source3/utils/net_idmap.c
index 28def038c0..1fb7be03cf 100644
--- a/source3/utils/net_idmap.c
+++ b/source3/utils/net_idmap.c
@@ -427,63 +427,64 @@ static
NTSTATUS dbwrap_delete_mapping(struct db_context *db, TDB_DATA key1, bool force)
{
TALLOC_CTX* mem_ctx = talloc_tos();
- struct db_record *rec1=NULL, *rec2=NULL;
- TDB_DATA key2;
bool is_valid_mapping;
NTSTATUS status = NT_STATUS_OK;
- TDB_DATA value;
+ TDB_DATA val1, val2;
+
+ ZERO_STRUCT(val1);
+ ZERO_STRUCT(val2);
- rec1 = dbwrap_fetch_locked(db, mem_ctx, key1);
- if (rec1 == NULL) {
+ status = dbwrap_fetch(db, mem_ctx, key1, &val1);
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("failed to fetch: %.*s\n", (int)key1.dsize, key1.dptr));
- status = NT_STATUS_NO_MEMORY;
goto done;
}
- key2 = dbwrap_record_get_value(rec1);
- if (key2.dptr == NULL) {
- DEBUG(1, ("could not find %.*s\n", (int)key1.dsize, key1.dptr));
- status = NT_STATUS_NOT_FOUND;
+
+ if (val1.dptr == NULL) {
+ DEBUG(1, ("invalid mapping: %.*s -> empty value\n",
+ (int)key1.dsize, key1.dptr));
+ status = NT_STATUS_FILE_INVALID;
goto done;
}
DEBUG(2, ("mapping: %.*s -> %.*s\n",
- (int)key1.dsize, key1.dptr, (int)key2.dsize, key2.dptr));
+ (int)key1.dsize, key1.dptr, (int)val1.dsize, val1.dptr));
- rec2 = dbwrap_fetch_locked(db, mem_ctx, key2);
- if (rec2 == NULL) {
- DEBUG(1, ("failed to fetch: %.*s\n", (int)key2.dsize, key2.dptr));
- status = NT_STATUS_NO_MEMORY;
+ status = dbwrap_fetch(db, mem_ctx, val1, &val2);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(1, ("failed to fetch: %.*s\n", (int)val1.dsize, val1.dptr));
goto done;
}
- value = dbwrap_record_get_value(rec2);
- is_valid_mapping = tdb_data_equal(key1, value);
+ is_valid_mapping = tdb_data_equal(key1, val2);
if (!is_valid_mapping) {
DEBUG(1, ("invalid mapping: %.*s -> %.*s -> %.*s\n",
- (int)key1.dsize, key1.dptr, (int)key2.dsize, key2.dptr,
- (int)value.dsize, value.dptr ));
+ (int)key1.dsize, key1.dptr,
+ (int)val1.dsize, val1.dptr,
+ (int)val2.dsize, val2.dptr));
if ( !force ) {
status = NT_STATUS_FILE_INVALID;
goto done;
}
}
- status = dbwrap_record_delete(rec1);
+ status = dbwrap_delete(db, key1);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("failed to delete: %.*s\n", (int)key1.dsize, key1.dptr));
goto done;
}
if (is_valid_mapping) {
- status = dbwrap_record_delete(rec2);
+ status = dbwrap_delete(db, val1);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(1, ("failed to delete: %.*s\n", (int)key2.dsize, key2.dptr));
+ DEBUG(1, ("failed to delete: %.*s\n", (int)val1.dsize, val1.dptr));
}
}
+
done:
- TALLOC_FREE(rec1);
- TALLOC_FREE(rec2);
+ TALLOC_FREE(val1.dptr);
+ TALLOC_FREE(val2.dptr);
return status;
}