#include "includes.h"
#include "system/filesys.h"
#include "winbindd.h"
-#include "dbwrap.h"
+#include "dbwrap/dbwrap.h"
+#include "dbwrap/dbwrap_open.h"
#include "idmap.h"
#include "../libcli/security/dom_sid.h"
#include "util_tdb.h"
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;
}
TDB_DATA data;
char *keystr;
struct dom_sid sid;
+ NTSTATUS status;
/* can this be one of our ids? */
if (map->xid.id < cfg->minvalue) {
return NT_STATUS_NO_MEMORY;
}
- data = dbwrap_fetch_bystring(autorid_db, talloc_tos(), keystr);
+ status = dbwrap_fetch_bystring(autorid_db, talloc_tos(), keystr, &data);
TALLOC_FREE(keystr);
- if (!data.dptr) {
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG(4, ("id %d belongs to range %d which does not have "
"domain mapping, ignoring mapping request\n",
map->xid.id, range));
static NTSTATUS idmap_autorid_db_init(void)
{
int32_t hwm;
+ NTSTATUS status;
if (autorid_db) {
/* its already open */
}
/* Initialize high water mark for the currently used range to 0 */
- hwm = dbwrap_fetch_int32(autorid_db, HWM);
- if ((hwm < 0)) {
- if (!NT_STATUS_IS_OK
- (dbwrap_trans_store_int32(autorid_db, 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,
("Unable to initialise HWM in autorid "
- "database\n"));
+ "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;
}
return NT_STATUS_OK;
TDB_DATA data;
struct autorid_global_config *cfg;
unsigned long minvalue, rangesize, maxranges;
+ NTSTATUS status;
- data = dbwrap_fetch_bystring(autorid_db, ctx, CONFIGKEY);
+ status = dbwrap_fetch_bystring(autorid_db, ctx, CONFIGKEY, &data);
- if (!data.dptr) {
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG(10, ("No saved config found\n"));
return NULL;
}
/* 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;
}
.sids_to_unixids = idmap_autorid_sids_to_unixids,
};
-NTSTATUS idmap_autorid_init(void)
+NTSTATUS samba_init_module(void)
{
return smb_register_idmap(SMB_IDMAP_INTERFACE_VERSION,
"autorid", &autorid_methods);