1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-26 10:04:02 +03:00

ldb_tdb: provide ldb_key_dn() and ldb_key_msg()

This will in time allow us to generate a TDB key from
the msg, eg from an objectGUID.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
This commit is contained in:
Andrew Bartlett 2017-08-10 14:31:18 +12:00
parent cd8ecb3332
commit 1b310ad99c
4 changed files with 23 additions and 9 deletions

View File

@ -1630,7 +1630,7 @@ static int re_key(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *st
/* check if the DN key has changed, perhaps due to the
case insensitivity of an element changing */
key2 = ltdb_key(module, msg->dn);
key2 = ltdb_key_dn(module, msg->dn);
if (key2.dptr == NULL) {
/* probably a corrupt record ... darn */
ldb_debug(ldb, LDB_DEBUG_ERROR, "Invalid DN in re_index: %s",

View File

@ -125,7 +125,7 @@ static int ltdb_search_base(struct ldb_module *module, struct ldb_dn *dn)
}
/* form the key */
tdb_key = ltdb_key(module, dn);
tdb_key = ltdb_key_dn(module, dn);
if (!tdb_key.dptr) {
return LDB_ERR_OPERATIONS_ERROR;
}
@ -214,7 +214,7 @@ int ltdb_search_dn1(struct ldb_module *module, struct ldb_dn *dn, struct ldb_mes
};
/* form the key */
tdb_key = ltdb_key(module, dn);
tdb_key = ltdb_key_dn(module, dn);
if (!tdb_key.dptr) {
return LDB_ERR_OPERATIONS_ERROR;
}

View File

@ -174,7 +174,7 @@ bool ltdb_key_is_record(TDB_DATA key)
note that the key for a record can depend on whether the
dn refers to a case sensitive index record or not
*/
TDB_DATA ltdb_key(struct ldb_module *module, struct ldb_dn *dn)
TDB_DATA ltdb_key_dn(struct ldb_module *module, struct ldb_dn *dn)
{
struct ldb_context *ldb = ldb_module_get_ctx(module);
TDB_DATA key;
@ -220,6 +220,19 @@ failed:
return key;
}
/*
form a TDB_DATA for a record key
caller frees
note that the key for a record can depend on whether the
dn refers to a case sensitive index record or not
*/
TDB_DATA ltdb_key_msg(struct ldb_module *module,
const struct ldb_message *msg)
{
return ltdb_key_dn(module, msg->dn);
}
/*
check special dn's have valid attributes
currently only @ATTRIBUTES is checked
@ -312,7 +325,7 @@ int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flg
return LDB_ERR_UNWILLING_TO_PERFORM;
}
tdb_key = ltdb_key(module, msg->dn);
tdb_key = ltdb_key_msg(module, msg);
if (tdb_key.dptr == NULL) {
return LDB_ERR_OTHER;
}
@ -484,7 +497,7 @@ int ltdb_delete_noindex(struct ldb_module *module, struct ldb_dn *dn)
return LDB_ERR_UNWILLING_TO_PERFORM;
}
tdb_key = ltdb_key(module, dn);
tdb_key = ltdb_key_dn(module, dn);
if (!tdb_key.dptr) {
return LDB_ERR_OTHER;
}
@ -1112,13 +1125,13 @@ static int ltdb_rename(struct ltdb_context *ctx)
/* We need to, before changing the DB, check if the new DN
* exists, so we can return this error to the caller with an
* unmodified DB */
tdb_key = ltdb_key(module, req->op.rename.newdn);
tdb_key = ltdb_key_dn(module, req->op.rename.newdn);
if (!tdb_key.dptr) {
talloc_free(msg);
return LDB_ERR_OPERATIONS_ERROR;
}
tdb_key_old = ltdb_key(module, req->op.rename.olddn);
tdb_key_old = ltdb_key_dn(module, req->op.rename.olddn);
if (!tdb_key_old.dptr) {
talloc_free(msg);
talloc_free(tdb_key.dptr);

View File

@ -117,7 +117,8 @@ int ltdb_unlock_read(struct ldb_module *module);
* index, the old DN index and a possible future ID=
*/
bool ltdb_key_is_record(TDB_DATA key);
TDB_DATA ltdb_key(struct ldb_module *module, struct ldb_dn *dn);
TDB_DATA ltdb_key_dn(struct ldb_module *module, struct ldb_dn *dn);
TDB_DATA ltdb_key_msg(struct ldb_module *module, const struct ldb_message *msg);
int ltdb_store(struct ldb_module *module, const struct ldb_message *msg, int flgs);
int ltdb_modify_internal(struct ldb_module *module, const struct ldb_message *msg, struct ldb_request *req);
int ltdb_delete_noindex(struct ldb_module *module, struct ldb_dn *dn);