1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

dsdb: Expose ldb error string to dsdb_garbage_collect_tombstones() callers

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
This commit is contained in:
Andrew Bartlett 2016-08-30 10:22:47 +12:00 committed by Garming Sam
parent 55b9b9a969
commit 240038979d
4 changed files with 21 additions and 9 deletions

View File

@ -40,7 +40,8 @@ NTSTATUS dsdb_garbage_collect_tombstones(TALLOC_CTX *mem_ctx,
time_t current_time,
uint32_t tombstoneLifetime,
unsigned int *num_objects_removed,
unsigned int *num_links_removed)
unsigned int *num_links_removed,
char **error_string)
{
int ret;
@ -57,7 +58,7 @@ NTSTATUS dsdb_garbage_collect_tombstones(TALLOC_CTX *mem_ctx,
*num_objects_removed = 0;
*num_links_removed = 0;
*error_string = NULL;
num_link_attrs = 0;
/*
@ -132,8 +133,9 @@ NTSTATUS dsdb_garbage_collect_tombstones(TALLOC_CTX *mem_ctx,
attrs, flags, filter);
if (ret != LDB_SUCCESS) {
DEBUG(1,(__location__ ": Failed to search for deleted objects in %s\n",
ldb_dn_get_linearized(do_dn)));
*error_string = talloc_asprintf(mem_ctx, "Failed to search for deleted objects in %s: %s",
ldb_dn_get_linearized(do_dn),
ldb_errstring(samdb));
TALLOC_FREE(tmp_ctx);
return NT_STATUS_INTERNAL_ERROR;
}

View File

@ -30,4 +30,5 @@ NTSTATUS dsdb_garbage_collect_tombstones(TALLOC_CTX *mem_ctx,
time_t current_time,
uint32_t tombstoneLifetime,
unsigned int *num_objects_removed,
unsigned int *num_links_removed);
unsigned int *num_links_removed,
char **error_string);

View File

@ -609,6 +609,7 @@ static NTSTATUS kccsrv_check_deleted(struct kccsrv_service *s, TALLOC_CTX *mem_c
unsigned int num_objects_removed = 0;
unsigned int num_links_removed = 0;
NTSTATUS status;
char *error_string = NULL;
if (current_time - s->last_deleted_check < interval) {
return NT_STATUS_OK;
@ -626,7 +627,8 @@ static NTSTATUS kccsrv_check_deleted(struct kccsrv_service *s, TALLOC_CTX *mem_c
s->partitions,
current_time, tombstoneLifetime,
&num_objects_removed,
&num_links_removed);
&num_links_removed,
&error_string);
if (NT_STATUS_IS_OK(status)) {
DEBUG(5, ("garbage_collect_tombstones: Removed %u tombstone objects "
@ -637,7 +639,7 @@ static NTSTATUS kccsrv_check_deleted(struct kccsrv_service *s, TALLOC_CTX *mem_c
"objects and links after removing %u tombstone objects "
"and %u tombstone links successfully: %s\n",
num_objects_removed, num_links_removed,
nt_errstr(status)));
error_string ? error_string : nt_errstr(status)));
}
return status;
}

View File

@ -1092,6 +1092,7 @@ static PyObject *py_dsdb_garbage_collect_tombstones(PyObject *self, PyObject *ar
NTSTATUS status;
unsigned int num_objects_removed = 0;
unsigned int num_links_removed = 0;
char *error_string = NULL;
if (!PyArg_ParseTuple(args, "OOL|L", &py_ldb,
&py_list_dn, &_current_time, &_tombstone_lifetime)) {
@ -1156,10 +1157,16 @@ static PyObject *py_dsdb_garbage_collect_tombstones(PyObject *self, PyObject *ar
part, current_time,
tombstone_lifetime,
&num_objects_removed,
&num_links_removed);
&num_links_removed,
&error_string);
if (!NT_STATUS_IS_OK(status)) {
PyErr_SetNTSTATUS(status);
if (error_string) {
PyErr_Format(PyExc_RuntimeError, "%s", error_string);
} else {
PyErr_SetNTSTATUS(status);
}
TALLOC_FREE(mem_ctx);
return NULL;
}