From 658f72128ff6950c6a03994198b4464a273fb300 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Thu, 6 Oct 2011 21:07:27 +0200 Subject: s3:dbwrap: change dbwrap_fetch_uint32() to NTSTATUS return type (instead of bool) for consistency and better error propagation --- source3/winbindd/idmap_autorid.c | 19 ++++++++++++------- source3/winbindd/idmap_tdb.c | 11 +++++------ source3/winbindd/idmap_tdb2.c | 14 ++++++-------- 3 files changed, 23 insertions(+), 21 deletions(-) (limited to 'source3/winbindd') diff --git a/source3/winbindd/idmap_autorid.c b/source3/winbindd/idmap_autorid.c index ed00d3728d..62339f1328 100644 --- a/source3/winbindd/idmap_autorid.c +++ b/source3/winbindd/idmap_autorid.c @@ -66,13 +66,15 @@ static NTSTATUS idmap_autorid_get_domainrange(struct db_context *db, cfg = (struct autorid_domain_config *)private_data; dom_sid_string_buf(&(cfg->sid), sidstr, sizeof(sidstr)); - if (!dbwrap_fetch_uint32(db, sidstr, &domainnum)) { + ret = dbwrap_fetch_uint32(db, sidstr, &domainnum); + if (!NT_STATUS_IS_OK(ret)) { DEBUG(10, ("Acquiring new range for domain %s\n", sidstr)); /* fetch the current HWM */ - if (!dbwrap_fetch_uint32(db, HWM, &hwm)) { + ret = dbwrap_fetch_uint32(db, HWM, &hwm); + if (!NT_STATUS_IS_OK(ret)) { DEBUG(1, ("Fatal error while fetching current " - "HWM value!\n")); + "HWM value: %s\n", nt_errstr(ret))); ret = NT_STATUS_INTERNAL_ERROR; goto error; } @@ -519,9 +521,10 @@ static NTSTATUS idmap_autorid_initialize(struct idmap_domain *dom) /* read previously stored config and current HWM */ storedconfig = idmap_autorid_loadconfig(talloc_tos()); - if (!dbwrap_fetch_uint32(autorid_db, HWM, &hwm)) { + status = dbwrap_fetch_uint32(autorid_db, HWM, &hwm); + if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("Fatal error while fetching current " - "HWM value!\n")); + "HWM value: %s\n", nt_errstr(status))); status = NT_STATUS_INTERNAL_ERROR; goto error; } @@ -590,8 +593,10 @@ static NTSTATUS idmap_autorid_allocate_id(struct idmap_domain *dom, globalcfg = talloc_get_type(dom->private_data, struct autorid_global_config); - if (!dbwrap_fetch_uint32(autorid_db, ALLOC_HWM, &hwm)) { - DEBUG(1, ("Failed to fetch current allocation HWM value!\n")); + ret = dbwrap_fetch_uint32(autorid_db, ALLOC_HWM, &hwm); + if (!NT_STATUS_IS_OK(ret)) { + DEBUG(1, ("Failed to fetch current allocation HWM value: %s\n", + nt_errstr(ret))); return NT_STATUS_INTERNAL_ERROR; } diff --git a/source3/winbindd/idmap_tdb.c b/source3/winbindd/idmap_tdb.c index b520e09103..c19c9c8163 100644 --- a/source3/winbindd/idmap_tdb.c +++ b/source3/winbindd/idmap_tdb.c @@ -251,17 +251,17 @@ static NTSTATUS idmap_tdb_init_hwm(struct idmap_domain *dom) bool update_uid = false; bool update_gid = false; struct idmap_tdb_context *ctx; - bool status; + NTSTATUS status; ctx = talloc_get_type(dom->private_data, struct idmap_tdb_context); status = dbwrap_fetch_uint32(ctx->db, HWM_USER, &low_uid); - if (!status || low_uid < dom->low_id) { + if (!NT_STATUS_IS_OK(status) || low_uid < dom->low_id) { update_uid = true; } status = dbwrap_fetch_uint32(ctx->db, HWM_GROUP, &low_gid); - if (!status || low_gid < dom->low_id) { + if (!NT_STATUS_IS_OK(status) || low_gid < dom->low_id) { update_gid = true; } @@ -404,12 +404,11 @@ static NTSTATUS idmap_tdb_allocate_id_action(struct db_context *db, NTSTATUS ret; struct idmap_tdb_allocate_id_context *state; uint32_t hwm; - bool ret2; state = (struct idmap_tdb_allocate_id_context *)private_data; - ret2 = dbwrap_fetch_uint32(db, state->hwmkey, &hwm); - if (!ret2) { + ret = dbwrap_fetch_uint32(db, state->hwmkey, &hwm); + if (!NT_STATUS_IS_OK(ret)) { ret = NT_STATUS_INTERNAL_DB_ERROR; goto done; } diff --git a/source3/winbindd/idmap_tdb2.c b/source3/winbindd/idmap_tdb2.c index 0f50f615a1..ab47fe5389 100644 --- a/source3/winbindd/idmap_tdb2.c +++ b/source3/winbindd/idmap_tdb2.c @@ -63,14 +63,13 @@ static NTSTATUS idmap_tdb2_init_hwm(struct idmap_domain *dom) NTSTATUS status; uint32 low_id; struct idmap_tdb2_context *ctx; - bool ret; ctx = talloc_get_type(dom->private_data, struct idmap_tdb2_context); /* Create high water marks for group and user id */ - ret = dbwrap_fetch_uint32(ctx->db, HWM_USER, &low_id); - if (!ret || (low_id < dom->low_id)) { + status = dbwrap_fetch_uint32(ctx->db, HWM_USER, &low_id); + if (!NT_STATUS_IS_OK(status) || (low_id < dom->low_id)) { status = dbwrap_trans_store_uint32(ctx->db, HWM_USER, dom->low_id); if (!NT_STATUS_IS_OK(status)) { @@ -80,8 +79,8 @@ static NTSTATUS idmap_tdb2_init_hwm(struct idmap_domain *dom) } } - ret = dbwrap_fetch_uint32(ctx->db, HWM_GROUP, &low_id); - if (!ret || (low_id < dom->low_id)) { + status = dbwrap_fetch_uint32(ctx->db, HWM_GROUP, &low_id); + if (!NT_STATUS_IS_OK(status) || (low_id < dom->low_id)) { status = dbwrap_trans_store_uint32(ctx->db, HWM_GROUP, dom->low_id); if (!NT_STATUS_IS_OK(status)) { @@ -144,12 +143,11 @@ static NTSTATUS idmap_tdb2_allocate_id_action(struct db_context *db, NTSTATUS ret; struct idmap_tdb2_allocate_id_context *state; uint32_t hwm; - bool ret2; state = (struct idmap_tdb2_allocate_id_context *)private_data; - ret2 = dbwrap_fetch_uint32(db, state->hwmkey, &hwm); - if (!ret2) { + ret = dbwrap_fetch_uint32(db, state->hwmkey, &hwm); + if (!NT_STATUS_IS_OK(ret)) { ret = NT_STATUS_INTERNAL_DB_ERROR; goto done; } -- cgit