diff options
author | Matthias Dieter Wallnöfer <mdw@samba.org> | 2010-10-18 20:07:49 +0200 |
---|---|---|
committer | Matthias Dieter Wallnöfer <mdw@samba.org> | 2010-10-18 20:10:14 +0200 |
commit | 94a445869c5fa3bb6df542c494e8822478f790e8 (patch) | |
tree | f5015dd7e20b0c5bc3dbfd8e4ff28513b24725aa | |
parent | 3ead246062b927e44cb75e684cc67c41109d63c4 (diff) | |
download | samba-94a445869c5fa3bb6df542c494e8822478f790e8.tar.gz samba-94a445869c5fa3bb6df542c494e8822478f790e8.tar.bz2 samba-94a445869c5fa3bb6df542c494e8822478f790e8.zip |
ldb:ldb_tdb.c - improve the error outputs
- Fix indentation
- Include always the failing DN
- Reorder the outputs to make them consistent
-rw-r--r-- | source4/lib/ldb/ldb_tdb/ldb_tdb.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c index f12bc58f65..a92f1dca9e 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c @@ -4,7 +4,7 @@ Copyright (C) Andrew Tridgell 2004 Copyright (C) Stefan Metzmacher 2004 Copyright (C) Simo Sorce 2006-2008 - Copyright (C) Matthias Dieter Wallnöfer 2009 + Copyright (C) Matthias Dieter Wallnöfer 2009-2010 ** NOTE! The following LGPL license applies to the ldb ** library. This does NOT imply that all of Samba is released @@ -296,7 +296,7 @@ static int ltdb_add_internal(struct ldb_module *module, struct ldb_message_element *el = &msg->elements[i]; if (el->num_values == 0) { - ldb_asprintf_errstring(ldb, "attribute %s on %s specified, but with 0 values (illegal)", + ldb_asprintf_errstring(ldb, "attribute '%s' on '%s' specified, but with 0 values (illegal)", el->name, ldb_dn_get_linearized(msg->dn)); return LDB_ERR_CONSTRAINT_VIOLATION; } @@ -655,7 +655,8 @@ int ltdb_modify_internal(struct ldb_module *module, case LDB_FLAG_MOD_ADD: if (el->num_values == 0) { - ldb_asprintf_errstring(ldb, "attribute %s on %s specified, but with 0 values (illigal)", + ldb_asprintf_errstring(ldb, + "attribute '%s': attribute on '%s' specified, but with 0 values (illegal)", el->name, ldb_dn_get_linearized(msg2->dn)); ret = LDB_ERR_CONSTRAINT_VIOLATION; goto done; @@ -691,7 +692,8 @@ int ltdb_modify_internal(struct ldb_module *module, ret = LDB_ERR_OTHER; goto done; } - ret = ltdb_index_add_element(module, msg2->dn, el); + ret = ltdb_index_add_element(module, msg2->dn, + el); if (ret != LDB_SUCCESS) { goto done; } @@ -713,12 +715,16 @@ int ltdb_modify_internal(struct ldb_module *module, continue; } - ldb_asprintf_errstring(ldb, "%s: value #%d already exists", el->name, j); + ldb_asprintf_errstring(ldb, + "attribute '%s': value #%u on '%s' already exists", + el->name, j, ldb_dn_get_linearized(msg2->dn)); ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS; goto done; } if (ldb_msg_find_val(el, &el->values[j]) != &el->values[j]) { - ldb_asprintf_errstring(ldb, "%s: value #%d provided more than once", el->name, j); + ldb_asprintf_errstring(ldb, + "attribute '%s': value #%u on '%s' provided more than once", + el->name, j, ldb_dn_get_linearized(msg2->dn)); ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS; goto done; } @@ -756,12 +762,15 @@ int ltdb_modify_internal(struct ldb_module *module, /* TODO: This is O(n^2) - replace with more efficient check */ for (j=0; j<el->num_values; j++) { if (ldb_msg_find_val(el, &el->values[j]) != &el->values[j]) { - ldb_asprintf_errstring(ldb, "%s: value #%d provided more than once", el->name, j); + ldb_asprintf_errstring(ldb, + "attribute '%s': value #%u on '%s' provided more than once", + el->name, j, ldb_dn_get_linearized(msg2->dn)); ret = LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS; goto done; } } + /* Checks if element already exists */ idx = find_element(msg2, el->name); if (idx != -1) { el2 = &(msg2->elements[idx]); @@ -771,7 +780,8 @@ int ltdb_modify_internal(struct ldb_module *module, } /* Delete the attribute if it exists in the DB */ - if (msg_delete_attribute(module, ldb, msg2, el->name) != 0) { + if (msg_delete_attribute(module, ldb, msg2, + el->name) != 0) { ret = LDB_ERR_OTHER; goto done; } @@ -805,7 +815,8 @@ int ltdb_modify_internal(struct ldb_module *module, control_permissive) { ret = LDB_SUCCESS; } else { - ldb_asprintf_errstring(ldb, "No such attribute: %s for delete on %s", + ldb_asprintf_errstring(ldb, + "attribute '%s': no such attribute for delete on '%s'", msg->elements[i].name, dn); } if (ret != LDB_SUCCESS) { @@ -822,7 +833,8 @@ int ltdb_modify_internal(struct ldb_module *module, control_permissive) { ret = LDB_SUCCESS; } else { - ldb_asprintf_errstring(ldb, "No matching attribute value when deleting attribute: %s on %s", + ldb_asprintf_errstring(ldb, + "attribute '%s': no matching attribute value while deleting attribute on '%s'", msg->elements[i].name, dn); } if (ret != LDB_SUCCESS) { @@ -833,9 +845,9 @@ int ltdb_modify_internal(struct ldb_module *module, break; default: ldb_asprintf_errstring(ldb, - "Invalid ldb_modify flags on %s: 0x%x", - msg->elements[i].name, - msg->elements[i].flags & LDB_FLAG_MOD_MASK); + "attribute '%s': invalid modify flags on '%s': 0x%x", + msg->elements[i].name, ldb_dn_get_linearized(msg->dn), + msg->elements[i].flags & LDB_FLAG_MOD_MASK); ret = LDB_ERR_PROTOCOL_ERROR; goto done; } |