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

lib/ldb: let ldb_ldif_parse_modrdn() handle names without 'rdn_name=' prefix

This is needed in order to process schema updates.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Stefan Metzmacher 2023-02-23 14:56:39 +01:00 committed by Andrew Bartlett
parent f860e19c84
commit cc5df80152

View File

@ -584,6 +584,7 @@ int ldb_ldif_parse_modrdn(struct ldb_context *ldb,
struct ldb_dn **_newdn)
{
struct ldb_message *msg = ldif->msg;
struct ldb_val _newrdn_val = {};
struct ldb_val *newrdn_val = NULL;
struct ldb_val *deleteoldrdn_val = NULL;
struct ldb_val *newsuperior_val = NULL;
@ -667,6 +668,25 @@ int ldb_ldif_parse_modrdn(struct ldb_context *ldb,
goto err_op;
}
if (newrdn_val->length != 0 && strchr((const char *)newrdn_val->data, '=') == NULL) {
const char *rdn_name = ldb_dn_get_rdn_name(olddn);
char *new_rdn = NULL;
new_rdn = talloc_asprintf(tmp_ctx,
"%s=%s",
rdn_name,
(const char *)newrdn_val->data);
if (new_rdn == NULL) {
ldb_debug(ldb, LDB_DEBUG_ERROR,
"Error: failed to allocate '%s=%s'",
rdn_name, (char *)newrdn_val->data);
goto err_op;
}
_newrdn_val.data = (uint8_t *)new_rdn;
_newrdn_val.length = strlen(new_rdn);
newrdn_val = &_newrdn_val;
}
newrdn = ldb_dn_from_ldb_val(tmp_ctx, ldb, newrdn_val);
if (!ldb_dn_validate(newrdn)) {
ldb_debug(ldb, LDB_DEBUG_ERROR,