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);
+NTSTATUS dbwrap_store_uint32(struct db_context *db, const char *keystr,
+ uint32_t v);
NTSTATUS dbwrap_change_uint32_atomic(struct db_context *db, const char *keystr,
uint32_t *oldval, uint32_t change_val);
NTSTATUS dbwrap_trans_change_uint32_atomic(struct db_context *db,
return NT_STATUS_OK;
}
-int dbwrap_store_uint32(struct db_context *db, const char *keystr, uint32_t v)
+NTSTATUS dbwrap_store_uint32(struct db_context *db, const char *keystr,
+ uint32_t v)
{
struct db_record *rec;
uint32 v_store;
rec = dbwrap_fetch_locked(db, NULL, string_term_tdb_data(keystr));
if (rec == NULL) {
- return -1;
+ return NT_STATUS_INVALID_PARAMETER;
}
SIVAL(&v_store, 0, v);
sizeof(v_store)),
TDB_REPLACE);
TALLOC_FREE(rec);
- return NT_STATUS_IS_OK(status) ? 0 : -1;
+ return status;
}
/**
}
if (version != DATABASE_VERSION) {
- if (dbwrap_store_uint32(db, vstring, DATABASE_VERSION) != 0) {
- DEBUG(0, ("dbwrap_store_uint32 failed\n"));
+ status = dbwrap_store_uint32(db, vstring, DATABASE_VERSION);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("dbwrap_store_uint32 failed: %s\n",
+ nt_errstr(status)));
goto cancel;
}
rid = BASE_RID;
}
- if (dbwrap_store_uint32(db, NEXT_RID_STRING, rid) != 0) {
+ status = dbwrap_store_uint32(db, NEXT_RID_STRING, rid);
+ if (!NT_STATUS_IS_OK(status)) {
return false;
}
static NTSTATUS idmap_tdb_init_hwm(struct idmap_domain *dom)
{
- int ret;
uint32_t low_uid;
uint32_t low_gid;
bool update_uid = false;
}
if (update_uid) {
- ret = dbwrap_store_uint32(ctx->db, HWM_USER, dom->low_id);
- if (ret == -1) {
+ status = dbwrap_store_uint32(ctx->db, HWM_USER, dom->low_id);
+ if (!NT_STATUS_IS_OK(status)) {
dbwrap_transaction_cancel(ctx->db);
DEBUG(0, ("Unable to initialise user hwm in idmap "
- "database\n"));
+ "database: %s\n", nt_errstr(status)));
return NT_STATUS_INTERNAL_DB_ERROR;
}
}
if (update_gid) {
- ret = dbwrap_store_uint32(ctx->db, HWM_GROUP, dom->low_id);
- if (ret == -1) {
+ status = dbwrap_store_uint32(ctx->db, HWM_GROUP, dom->low_id);
+ if (!NT_STATUS_IS_OK(status)) {
dbwrap_transaction_cancel(ctx->db);
DEBUG(0, ("Unable to initialise group hwm in idmap "
- "database\n"));
+ "database: %s\n", nt_errstr(status)));
return NT_STATUS_INTERNAL_DB_ERROR;
}
}