uint32 rid;
fstring keystr;
fstring dom_name;
+ TDB_DATA key;
TDB_DATA key2;
+ TDB_DATA value;
struct convert_fn_state *s = (struct convert_fn_state *)private_data;
- DEBUG(10,("Converting %s\n", (const char *)rec->key.dptr));
+ key = dbwrap_record_get_key(rec);
- p = strchr((const char *)rec->key.dptr, '/');
+ DEBUG(10,("Converting %s\n", (const char *)key.dptr));
+
+ p = strchr((const char *)key.dptr, '/');
if (!p)
return 0;
*p = 0;
- fstrcpy(dom_name, (const char *)rec->key.dptr);
+ fstrcpy(dom_name, (const char *)key.dptr);
*p++ = '/';
domain = find_domain_from_name(dom_name);
if (domain == NULL) {
/* We must delete the old record. */
DEBUG(0,("Unable to find domain %s\n", dom_name ));
- DEBUG(0,("deleting record %s\n", (const char *)rec->key.dptr ));
+ DEBUG(0,("deleting record %s\n", (const char *)key.dptr ));
- status = rec->delete_rec(rec);
+ status = dbwrap_record_delete(rec);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("Unable to delete record %s:%s\n",
- (const char *)rec->key.dptr,
+ (const char *)key.dptr,
nt_errstr(status)));
s->failed = true;
return -1;
sid_to_fstring(keystr, &sid);
key2 = string_term_tdb_data(keystr);
- status = dbwrap_store(s->db, key2, rec->value, TDB_INSERT);
+ value = dbwrap_record_get_value(rec);
+
+ status = dbwrap_store(s->db, key2, value, TDB_INSERT);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("Unable to add record %s:%s\n",
(const char *)key2.dptr,
return -1;
}
- status = dbwrap_store(s->db, rec->value, key2, TDB_REPLACE);
+ status = dbwrap_store(s->db, value, key2, TDB_REPLACE);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("Unable to update record %s:%s\n",
- (const char *)rec->value.dptr,
+ (const char *)value.dptr,
nt_errstr(status)));
s->failed = true;
return -1;
}
- status = rec->delete_rec(rec);
+ status = dbwrap_record_delete(rec);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("Unable to delete record %s:%s\n",
- (const char *)rec->key.dptr,
+ (const char *)key.dptr,
nt_errstr(status)));
s->failed = true;
return -1;
int32 vers;
bool bigendianheader;
struct convert_fn_state s;
+ NTSTATUS status;
#if BUILD_TDB2
/* If we are bigendian, tdb is bigendian if NOT converted. */
} u;
u.large = 0x0102;
if (u.small[0] == 0x01)
- bigendianheader = !(db->get_flags(db) & TDB_CONVERT);
+ bigendianheader = !(dbwrap_get_flags(db) & TDB_CONVERT);
else {
assert(u.small[0] == 0x02);
- bigendianheader = (db->get_flags(db) & TDB_CONVERT);
+ bigendianheader = (dbwrap_get_flags(db) & TDB_CONVERT);
}
#else
- bigendianheader = (db->get_flags(db) & TDB_BIGENDIAN) ? True : False;
+ bigendianheader = (dbwrap_get_flags(db) & TDB_BIGENDIAN) ? True : False;
#endif
DEBUG(0, ("Upgrading winbindd_idmap.tdb from an old version\n"));
s.failed = false;
/* the old format stored as DOMAIN/rid - now we store the SID direct */
- db->traverse(db, convert_fn, &s);
+ status = dbwrap_traverse(db, convert_fn, &s, NULL);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0, ("Database traverse failed during conversion\n"));
+ return false;
+ }
if (s.failed) {
DEBUG(0, ("Problem during conversion\n"));
bool update_uid = false;
bool update_gid = false;
struct idmap_tdb_context *ctx;
+ bool status;
ctx = talloc_get_type(dom->private_data, struct idmap_tdb_context);
- low_uid = dbwrap_fetch_int32(ctx->db, HWM_USER);
- if (low_uid == -1 || low_uid < dom->low_id) {
+ status = dbwrap_fetch_uint32(ctx->db, HWM_USER, &low_uid);
+ if (!status || low_uid < dom->low_id) {
update_uid = true;
}
- low_gid = dbwrap_fetch_int32(ctx->db, HWM_GROUP);
- if (low_gid == -1 || low_gid < dom->low_id) {
+ status = dbwrap_fetch_uint32(ctx->db, HWM_GROUP, &low_gid);
+ if (!status || low_gid < dom->low_id) {
update_gid = true;
}
return NT_STATUS_OK;
}
- if (ctx->db->transaction_start(ctx->db) != 0) {
+ if (dbwrap_transaction_start(ctx->db) != 0) {
DEBUG(0, ("Unable to start upgrade transaction!\n"));
return NT_STATUS_INTERNAL_DB_ERROR;
}
if (update_uid) {
- ret = dbwrap_store_int32(ctx->db, HWM_USER, dom->low_id);
+ ret = dbwrap_store_uint32(ctx->db, HWM_USER, dom->low_id);
if (ret == -1) {
- ctx->db->transaction_cancel(ctx->db);
+ dbwrap_transaction_cancel(ctx->db);
DEBUG(0, ("Unable to initialise user hwm in idmap "
"database\n"));
return NT_STATUS_INTERNAL_DB_ERROR;
}
if (update_gid) {
- ret = dbwrap_store_int32(ctx->db, HWM_GROUP, dom->low_id);
+ ret = dbwrap_store_uint32(ctx->db, HWM_GROUP, dom->low_id);
if (ret == -1) {
- ctx->db->transaction_cancel(ctx->db);
+ dbwrap_transaction_cancel(ctx->db);
DEBUG(0, ("Unable to initialise group hwm in idmap "
"database\n"));
return NT_STATUS_INTERNAL_DB_ERROR;
}
}
- if (ctx->db->transaction_commit(ctx->db) != 0) {
+ if (dbwrap_transaction_commit(ctx->db) != 0) {
DEBUG(0, ("Unable to commit upgrade transaction!\n"));
return NT_STATUS_INTERNAL_DB_ERROR;
}
ret = NT_STATUS_UNSUCCESSFUL;
goto done;
}
- if (db->transaction_start(db) != 0) {
+ if (dbwrap_transaction_start(db) != 0) {
DEBUG(0, ("Unable to start upgrade transaction!\n"));
ret = NT_STATUS_INTERNAL_DB_ERROR;
goto done;
}
if (!idmap_tdb_upgrade(dom, db)) {
- db->transaction_cancel(db);
+ dbwrap_transaction_cancel(db);
DEBUG(0, ("Unable to open idmap database, it's in an old format, and upgrade failed!\n"));
ret = NT_STATUS_INTERNAL_DB_ERROR;
goto done;
}
- if (db->transaction_commit(db) != 0) {
+ if (dbwrap_transaction_commit(db) != 0) {
DEBUG(0, ("Unable to commit upgrade transaction!\n"));
ret = NT_STATUS_INTERNAL_DB_ERROR;
goto done;
NTSTATUS ret;
struct idmap_tdb_allocate_id_context *state;
uint32_t hwm;
+ bool ret2;
state = (struct idmap_tdb_allocate_id_context *)private_data;
- hwm = dbwrap_fetch_int32(db, state->hwmkey);
- if (hwm == -1) {
+ ret2 = dbwrap_fetch_uint32(db, state->hwmkey, &hwm);
+ if (!ret2) {
ret = NT_STATUS_INTERNAL_DB_ERROR;
goto done;
}
DEBUG(10,("Fetching record %s\n", keystr));
/* Check if the mapping exists */
- data = dbwrap_fetch_bystring(ctx->db, NULL, keystr);
+ ret = dbwrap_fetch_bystring(ctx->db, NULL, keystr, &data);
- if (!data.dptr) {
+ if (!NT_STATUS_IS_OK(ret)) {
DEBUG(10,("Record %s not found\n", keystr));
ret = NT_STATUS_NONE_MAPPED;
goto done;
DEBUG(10,("Fetching record %s\n", keystr));
/* Check if sid is present in database */
- data = dbwrap_fetch_bystring(ctx->db, tmp_ctx, keystr);
- if (!data.dptr) {
+ ret = dbwrap_fetch_bystring(ctx->db, tmp_ctx, keystr, &data);
+ if (!NT_STATUS_IS_OK(ret)) {
DEBUG(10,("Record %s not found\n", keystr));
ret = NT_STATUS_NONE_MAPPED;
goto done;