/* load the idmap allocation ranges and high/low water marks */ static NTSTATUS idmap_tdb2_alloc_load(void) { NTSTATUS status; uint32 low_id; /* see if a idmap script is configured */ idmap_tdb2_state.idmap_script = lp_parm_const_string(-1, "idmap", "script", NULL); if (idmap_tdb2_state.idmap_script) { DEBUG(1, ("using idmap script '%s'\n", idmap_tdb2_state.idmap_script)); } /* load ranges */ status = idmap_tdb2_load_ranges(); if (!NT_STATUS_IS_OK(status)) { return status; } /* Create high water marks for group and user id */ low_id = dbwrap_fetch_int32(idmap_tdb2, HWM_USER); if ((low_id == -1) || (low_id < idmap_tdb2_state.low_uid)) { if (!NT_STATUS_IS_OK(dbwrap_trans_store_int32( idmap_tdb2, HWM_USER, idmap_tdb2_state.low_uid))) { DEBUG(0, ("Unable to initialise user hwm in idmap " "database\n")); return NT_STATUS_INTERNAL_DB_ERROR; } } low_id = dbwrap_fetch_int32(idmap_tdb2, HWM_GROUP); if ((low_id == -1) || (low_id < idmap_tdb2_state.low_gid)) { if (!NT_STATUS_IS_OK(dbwrap_trans_store_int32( idmap_tdb2, HWM_GROUP, idmap_tdb2_state.low_gid))) { DEBUG(0, ("Unable to initialise group hwm in idmap " "database\n")); return NT_STATUS_INTERNAL_DB_ERROR; } } return NT_STATUS_OK; }
static int dbwrap_tool_store_int32(struct db_context *db, const char *keyname, const char *data) { NTSTATUS status; int32_t value = (int32_t)strtol(data, NULL, 10); status = dbwrap_trans_store_int32(db, keyname, value); if (!NT_STATUS_IS_OK(status)) { d_fprintf(stderr, "ERROR: could not store int32 key '%s': %s\n", keyname, nt_errstr(status)); return -1; } return 0; }
static WERROR regdb_store_regdb_version(struct db_context *db, uint32_t version) { NTSTATUS status; if (db == NULL) { return WERR_CAN_NOT_COMPLETE; } status = dbwrap_trans_store_int32(db, REGDB_VERSION_KEYNAME, version); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("regdb_store_regdb_version: error storing %s = %d: %s\n", REGDB_VERSION_KEYNAME, version, nt_errstr(status))); return ntstatus_to_werror(status); } else { DEBUG(10, ("regdb_store_regdb_version: stored %s = %d\n", REGDB_VERSION_KEYNAME, version)); return WERR_OK; } }
static WERROR regdb_store_regdb_version(uint32_t version) { NTSTATUS status; const char *version_keyname = "INFO/version"; if (!regdb) { return WERR_CAN_NOT_COMPLETE; } status = dbwrap_trans_store_int32(regdb, version_keyname, version); if (!NT_STATUS_IS_OK(status)) { DEBUG(1, ("regdb_store_regdb_version: error storing %s = %d: %s\n", version_keyname, version, nt_errstr(status))); return ntstatus_to_werror(status); } else { DEBUG(10, ("regdb_store_regdb_version: stored %s = %d\n", version_keyname, version)); return WERR_OK; } }
/* load the idmap allocation ranges and high/low water marks */ static NTSTATUS idmap_tdb2_alloc_load(void) { uid_t low_uid = 0; uid_t high_uid = 0; gid_t low_gid = 0; gid_t high_gid = 0; uint32 low_id; /* see if a idmap script is configured */ idmap_tdb2_state.idmap_script = lp_parm_const_string(-1, "idmap", "script", NULL); if (idmap_tdb2_state.idmap_script) { DEBUG(1, ("using idmap script '%s'\n", idmap_tdb2_state.idmap_script)); } /* load ranges */ /* Create high water marks for group and user id */ if (!lp_idmap_uid(&low_uid, &high_uid) || !lp_idmap_gid(&low_gid, &high_gid)) { DEBUG(1, ("idmap uid or idmap gid missing\n")); return NT_STATUS_UNSUCCESSFUL; } idmap_tdb2_state.low_uid = low_uid; idmap_tdb2_state.high_uid = high_uid; idmap_tdb2_state.low_gid = low_gid; idmap_tdb2_state.high_gid = high_gid; if (idmap_tdb2_state.high_uid <= idmap_tdb2_state.low_uid) { DEBUG(1, ("idmap uid range missing or invalid\n")); DEBUGADD(1, ("idmap will be unable to map foreign SIDs\n")); return NT_STATUS_UNSUCCESSFUL; } if (((low_id = dbwrap_fetch_int32(idmap_tdb2, HWM_USER)) == -1) || (low_id < idmap_tdb2_state.low_uid)) { if (!NT_STATUS_IS_OK(dbwrap_trans_store_int32( idmap_tdb2, HWM_USER, idmap_tdb2_state.low_uid))) { DEBUG(0, ("Unable to initialise user hwm in idmap " "database\n")); return NT_STATUS_INTERNAL_DB_ERROR; } } if (idmap_tdb2_state.high_gid <= idmap_tdb2_state.low_gid) { DEBUG(1, ("idmap gid range missing or invalid\n")); DEBUGADD(1, ("idmap will be unable to map foreign SIDs\n")); return NT_STATUS_UNSUCCESSFUL; } if (((low_id = dbwrap_fetch_int32(idmap_tdb2, HWM_GROUP)) == -1) || (low_id < idmap_tdb2_state.low_gid)) { if (!NT_STATUS_IS_OK(dbwrap_trans_store_int32( idmap_tdb2, HWM_GROUP, idmap_tdb2_state.low_gid))) { DEBUG(0, ("Unable to initialise group hwm in idmap " "database\n")); return NT_STATUS_INTERNAL_DB_ERROR; } } return NT_STATUS_OK; }