NTSTATUS dbwrap_fetch_int32(struct db_context *db, const char *keystr,
int32_t *result);
-int dbwrap_store_int32(struct db_context *db, const char *keystr, int32_t v);
+NTSTATUS dbwrap_store_int32(struct db_context *db, const char *keystr,
+ int32_t v);
NTSTATUS dbwrap_fetch_uint32(struct db_context *db, const char *keystr,
uint32_t *val);
int dbwrap_store_uint32(struct db_context *db, const char *keystr, uint32_t v);
return NT_STATUS_OK;
}
-int dbwrap_store_int32(struct db_context *db, const char *keystr, int32_t v)
+NTSTATUS dbwrap_store_int32(struct db_context *db, const char *keystr,
+ int32_t v)
{
struct db_record *rec;
int32 v_store;
rec = dbwrap_fetch_locked(db, NULL, string_term_tdb_data(keystr));
if (rec == NULL) {
- return -1;
+ return NT_STATUS_UNSUCCESSFUL;
}
SIVAL(&v_store, 0, v);
sizeof(v_store)),
TDB_REPLACE);
TALLOC_FREE(rec);
- return NT_STATUS_IS_OK(status) ? 0 : -1;
+ return status;
}
NTSTATUS dbwrap_fetch_uint32(struct db_context *db, const char *keystr,
if ((vers_id == SHARE_DATABASE_VERSION_V1) || (IREV(vers_id) == SHARE_DATABASE_VERSION_V1)) {
/* Written on a bigendian machine with old fetch_int code. Save as le. */
- if (dbwrap_store_int32(share_db, vstring,
- SHARE_DATABASE_VERSION_V2) != 0) {
- DEBUG(0, ("dbwrap_store_int32 failed\n"));
+ status = dbwrap_store_int32(share_db, vstring,
+ SHARE_DATABASE_VERSION_V2);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("dbwrap_store_int32 failed: %s\n",
+ nt_errstr(status)));
goto cancel;
}
vers_id = SHARE_DATABASE_VERSION_V2;
DEBUG(0, ("traverse failed\n"));
goto cancel;
}
- if (dbwrap_store_int32(share_db, vstring,
- SHARE_DATABASE_VERSION_V2) != 0) {
- DEBUG(0, ("dbwrap_store_int32 failed\n"));
+ status = dbwrap_store_int32(share_db, vstring,
+ SHARE_DATABASE_VERSION_V2);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("dbwrap_store_int32 failed: %s\n",
+ nt_errstr(status)));
goto cancel;
}
}
DEBUG(0, ("traverse failed\n"));
goto cancel;
}
- if (dbwrap_store_int32(share_db, vstring,
- SHARE_DATABASE_VERSION_V3) != 0) {
- DEBUG(0, ("dbwrap_store_int32 failed\n"));
+ status = dbwrap_store_int32(share_db, vstring,
+ SHARE_DATABASE_VERSION_V3);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("dbwrap_store_int32 failed: %s\n",
+ nt_errstr(status)));
goto cancel;
}
goto cancel;
}
- if (dbwrap_store_int32(db, TDBSAM_VERSION_STRING,
- TDBSAM_VERSION) != 0) {
- DEBUG(0, ("tdbsam_convert: Could not store tdbsam version\n"));
+ status = dbwrap_store_int32(db, TDBSAM_VERSION_STRING,
+ TDBSAM_VERSION);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("tdbsam_convert: Could not store tdbsam version: "
+ "%s\n", nt_errstr(status)));
goto cancel;
}
- if (dbwrap_store_int32(db, TDBSAM_MINOR_VERSION_STRING,
- TDBSAM_MINOR_VERSION) != 0) {
- DEBUG(0, ("tdbsam_convert: Could not store tdbsam minor version\n"));
+ status = dbwrap_store_int32(db, TDBSAM_MINOR_VERSION_STRING,
+ TDBSAM_MINOR_VERSION);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("tdbsam_convert: Could not store tdbsam minor "
+ "version: %s\n", nt_errstr(status)));
goto cancel;
}
char line[128], sid_string[128];
int len;
unsigned long idval;
+ NTSTATUS status;
if (fgets(line, 127, input) == NULL)
break;
break;
}
} else if (sscanf(line, "USER HWM %lu", &idval) == 1) {
- ret = dbwrap_store_int32(db, "USER HWM", idval);
- if (ret != 0) {
- d_fprintf(stderr, _("Could not store USER HWM.\n"));
+ status = dbwrap_store_int32(db, "USER HWM", idval);
+ if (!NT_STATUS_IS_OK(status)) {
+ d_fprintf(stderr,
+ _("Could not store USER HWM: %s\n"),
+ nt_errstr(status));
break;
}
} else if (sscanf(line, "GROUP HWM %lu", &idval) == 1) {
- ret = dbwrap_store_int32(db, "GROUP HWM", idval);
- if (ret != 0) {
+ status = dbwrap_store_int32(db, "GROUP HWM", idval);
+ if (!NT_STATUS_IS_OK(status)) {
d_fprintf(stderr,
- _("Could not store GROUP HWM.\n"));
+ _("Could not store GROUP HWM: %s\n"),
+ nt_errstr(status));
break;
}
} else {
wm = dom->low_id;
}
- if (dbwrap_store_int32(db, HWM_USER, wm) == -1) {
- DEBUG(0, ("Unable to byteswap user hwm in idmap database\n"));
+ status = dbwrap_store_int32(db, HWM_USER, wm);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("Unable to byteswap user hwm in idmap "
+ "database: %s\n", nt_errstr(status)));
return False;
}
wm = dom->low_id;
}
- if (dbwrap_store_int32(db, HWM_GROUP, wm) == -1) {
- DEBUG(0, ("Unable to byteswap group hwm in idmap database\n"));
+ status = dbwrap_store_int32(db, HWM_GROUP, wm);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("Unable to byteswap group hwm in idmap "
+ "database: %s\n", nt_errstr(status)));
return False;
}
}
return False;
}
- if (dbwrap_store_int32(db, "IDMAP_VERSION", IDMAP_VERSION) == -1) {
- DEBUG(0, ("Unable to store idmap version in database\n"));
+ status = dbwrap_store_int32(db, "IDMAP_VERSION", IDMAP_VERSION);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("Unable to store idmap version in database: %s\n",
+ nt_errstr(status)));
return False;
}