summaryrefslogtreecommitdiff
path: root/source3/winbindd
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2011-10-06 20:34:55 +0200
committerMichael Adam <obnox@samba.org>2011-10-11 14:17:58 +0200
commit603c3e1bcb7b4106afe4aefdfed43e7832ede956 (patch)
tree3bbd74811e5a62786975aada7399931db36d1549 /source3/winbindd
parentce8626cbbe99b26f4e39ace87221792b468b9c93 (diff)
downloadsamba-603c3e1bcb7b4106afe4aefdfed43e7832ede956.tar.gz
samba-603c3e1bcb7b4106afe4aefdfed43e7832ede956.tar.bz2
samba-603c3e1bcb7b4106afe4aefdfed43e7832ede956.zip
s3:dbwrap: convert dbwrap_fetch_int32() to NTSTATUS return code
Return the int32 value retrieved from the db by reference. Before this, return value "-1" was used as a error indication, but it could also be a valid value from the database.
Diffstat (limited to 'source3/winbindd')
-rw-r--r--source3/winbindd/idmap_autorid.c21
-rw-r--r--source3/winbindd/idmap_tdb.c22
2 files changed, 35 insertions, 8 deletions
diff --git a/source3/winbindd/idmap_autorid.c b/source3/winbindd/idmap_autorid.c
index 68115f4c3e..ed00d3728d 100644
--- a/source3/winbindd/idmap_autorid.c
+++ b/source3/winbindd/idmap_autorid.c
@@ -354,8 +354,10 @@ static NTSTATUS idmap_autorid_db_init(void)
}
/* Initialize high water mark for the currently used range to 0 */
- hwm = dbwrap_fetch_int32(autorid_db, HWM);
- if ((hwm < 0)) {
+ status = dbwrap_fetch_int32(autorid_db, HWM, &hwm);
+ if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND) ||
+ (NT_STATUS_IS_OK(status) && (hwm < 0)))
+ {
status = dbwrap_trans_store_int32(autorid_db, HWM, 0);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,
@@ -363,11 +365,17 @@ static NTSTATUS idmap_autorid_db_init(void)
"database: %s\n", nt_errstr(status)));
return NT_STATUS_INTERNAL_DB_ERROR;
}
+ } else if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("unable to fetch HWM from autorid database: %s\n",
+ nt_errstr(status)));
+ return status;
}
/* Initialize high water mark for alloc pool to 0 */
- hwm = dbwrap_fetch_int32(autorid_db, ALLOC_HWM);
- if ((hwm < 0)) {
+ status = dbwrap_fetch_int32(autorid_db, ALLOC_HWM, &hwm);
+ if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND) ||
+ (NT_STATUS_IS_OK(status) && (hwm < 0)))
+ {
status = dbwrap_trans_store_int32(autorid_db, ALLOC_HWM, 0);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,
@@ -375,7 +383,12 @@ static NTSTATUS idmap_autorid_db_init(void)
"database: %s\n", nt_errstr(status)));
return NT_STATUS_INTERNAL_DB_ERROR;
}
+ } else if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("unable to fetch alloc HWM from autorid database: "
+ "%s\n", nt_errstr(status)));
+ return status;
}
+
return NT_STATUS_OK;
}
diff --git a/source3/winbindd/idmap_tdb.c b/source3/winbindd/idmap_tdb.c
index ec6b0a8e90..b520e09103 100644
--- a/source3/winbindd/idmap_tdb.c
+++ b/source3/winbindd/idmap_tdb.c
@@ -172,7 +172,10 @@ static bool idmap_tdb_upgrade(struct idmap_domain *dom, struct db_context *db)
#endif
DEBUG(0, ("Upgrading winbindd_idmap.tdb from an old version\n"));
- vers = dbwrap_fetch_int32(db, "IDMAP_VERSION");
+ status = dbwrap_fetch_int32(db, "IDMAP_VERSION", &vers);
+ if (!NT_STATUS_IS_OK(status)) {
+ vers = -1;
+ }
if (((vers == -1) && bigendianheader) || (IREV(vers) == IDMAP_VERSION)) {
/* Arrggghh ! Bytereversed or old big-endian - make order independent ! */
@@ -183,7 +186,10 @@ static bool idmap_tdb_upgrade(struct idmap_domain *dom, struct db_context *db)
int32 wm;
- wm = dbwrap_fetch_int32(db, HWM_USER);
+ status = dbwrap_fetch_int32(db, HWM_USER, &wm);
+ if (!NT_STATUS_IS_OK(status)) {
+ wm = -1;
+ }
if (wm != -1) {
wm = IREV(wm);
@@ -196,7 +202,11 @@ static bool idmap_tdb_upgrade(struct idmap_domain *dom, struct db_context *db)
return False;
}
- wm = dbwrap_fetch_int32(db, HWM_GROUP);
+ status = dbwrap_fetch_int32(db, HWM_GROUP, &wm);
+ if (!NT_STATUS_IS_OK(status)) {
+ wm = -1;
+ }
+
if (wm != -1) {
wm = IREV(wm);
} else {
@@ -331,7 +341,11 @@ static NTSTATUS idmap_tdb_open_db(struct idmap_domain *dom)
}
/* check against earlier versions */
- version = dbwrap_fetch_int32(db, "IDMAP_VERSION");
+ ret = dbwrap_fetch_int32(db, "IDMAP_VERSION", &version);
+ if (!NT_STATUS_IS_OK(ret)) {
+ version = -1;
+ }
+
if (version != IDMAP_VERSION) {
if (config_error) {
DEBUG(0,("Upgrade of IDMAP_VERSION from %d to %d is not "