mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +03:00
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>
This commit is contained in:
parent
9aa79c11f0
commit
8473764234
@ -427,63 +427,64 @@ static
|
|||||||
NTSTATUS dbwrap_delete_mapping(struct db_context *db, TDB_DATA key1, bool force)
|
NTSTATUS dbwrap_delete_mapping(struct db_context *db, TDB_DATA key1, bool force)
|
||||||
{
|
{
|
||||||
TALLOC_CTX* mem_ctx = talloc_tos();
|
TALLOC_CTX* mem_ctx = talloc_tos();
|
||||||
struct db_record *rec1=NULL, *rec2=NULL;
|
|
||||||
TDB_DATA key2;
|
|
||||||
bool is_valid_mapping;
|
bool is_valid_mapping;
|
||||||
NTSTATUS status = NT_STATUS_OK;
|
NTSTATUS status = NT_STATUS_OK;
|
||||||
TDB_DATA value;
|
TDB_DATA val1, val2;
|
||||||
|
|
||||||
rec1 = dbwrap_fetch_locked(db, mem_ctx, key1);
|
ZERO_STRUCT(val1);
|
||||||
if (rec1 == NULL) {
|
ZERO_STRUCT(val2);
|
||||||
|
|
||||||
|
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));
|
DEBUG(1, ("failed to fetch: %.*s\n", (int)key1.dsize, key1.dptr));
|
||||||
status = NT_STATUS_NO_MEMORY;
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
key2 = dbwrap_record_get_value(rec1);
|
|
||||||
if (key2.dptr == NULL) {
|
if (val1.dptr == NULL) {
|
||||||
DEBUG(1, ("could not find %.*s\n", (int)key1.dsize, key1.dptr));
|
DEBUG(1, ("invalid mapping: %.*s -> empty value\n",
|
||||||
status = NT_STATUS_NOT_FOUND;
|
(int)key1.dsize, key1.dptr));
|
||||||
|
status = NT_STATUS_FILE_INVALID;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(2, ("mapping: %.*s -> %.*s\n",
|
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);
|
status = dbwrap_fetch(db, mem_ctx, val1, &val2);
|
||||||
if (rec2 == NULL) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
DEBUG(1, ("failed to fetch: %.*s\n", (int)key2.dsize, key2.dptr));
|
DEBUG(1, ("failed to fetch: %.*s\n", (int)val1.dsize, val1.dptr));
|
||||||
status = NT_STATUS_NO_MEMORY;
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = dbwrap_record_get_value(rec2);
|
is_valid_mapping = tdb_data_equal(key1, val2);
|
||||||
is_valid_mapping = tdb_data_equal(key1, value);
|
|
||||||
|
|
||||||
if (!is_valid_mapping) {
|
if (!is_valid_mapping) {
|
||||||
DEBUG(1, ("invalid mapping: %.*s -> %.*s -> %.*s\n",
|
DEBUG(1, ("invalid mapping: %.*s -> %.*s -> %.*s\n",
|
||||||
(int)key1.dsize, key1.dptr, (int)key2.dsize, key2.dptr,
|
(int)key1.dsize, key1.dptr,
|
||||||
(int)value.dsize, value.dptr ));
|
(int)val1.dsize, val1.dptr,
|
||||||
|
(int)val2.dsize, val2.dptr));
|
||||||
if ( !force ) {
|
if ( !force ) {
|
||||||
status = NT_STATUS_FILE_INVALID;
|
status = NT_STATUS_FILE_INVALID;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
status = dbwrap_record_delete(rec1);
|
status = dbwrap_delete(db, key1);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
DEBUG(1, ("failed to delete: %.*s\n", (int)key1.dsize, key1.dptr));
|
DEBUG(1, ("failed to delete: %.*s\n", (int)key1.dsize, key1.dptr));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_valid_mapping) {
|
if (is_valid_mapping) {
|
||||||
status = dbwrap_record_delete(rec2);
|
status = dbwrap_delete(db, val1);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
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:
|
done:
|
||||||
TALLOC_FREE(rec1);
|
TALLOC_FREE(val1.dptr);
|
||||||
TALLOC_FREE(rec2);
|
TALLOC_FREE(val2.dptr);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user