Skip to content

Commit

Permalink
dsdb: Expose ldb error string to dsdb_garbage_collect_tombstones() ca…
Browse files Browse the repository at this point in the history
…llers

Signed-off-by: Andrew Bartlett <[email protected]>
Reviewed-by: Garming Sam <[email protected]>
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12382
(cherry picked from commit 2400389)
  • Loading branch information
abartlet authored and kseeger committed Oct 20, 2016
1 parent 68598e4 commit 679700a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
10 changes: 6 additions & 4 deletions source4/dsdb/kcc/garbage_collect_tombstones.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

/*
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion source4/dsdb/kcc/garbage_collect_tombstones.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
6 changes: 4 additions & 2 deletions source4/dsdb/kcc/kcc_periodic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 "
Expand All @@ -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;
}
Expand Down
11 changes: 9 additions & 2 deletions source4/dsdb/pydsdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 679700a

Please sign in to comment.