****************************************************************************/
static bool init_group_mapping(void)
{
- const char *ldb_path;
+ char *tdb_path;
+ char *ldb_path;
if (db != NULL) {
return true;
}
- db = db_open(NULL, state_path("group_mapping.tdb"), 0,
- TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
+ tdb_path = state_path("group_mapping.tdb");
+ if (tdb_path == NULL) {
+ return false;
+ }
+ db = db_open(NULL, tdb_path, 0,
+ TDB_DEFAULT, O_RDWR|O_CREAT, 0600,
+ DBWRAP_LOCK_ORDER_1, DBWRAP_FLAG_NONE);
if (db == NULL) {
DEBUG(0, ("Failed to open group mapping database: %s\n",
strerror(errno)));
+ talloc_free(tdb_path);
return false;
}
ldb_path = state_path("group_mapping.ldb");
+ if (ldb_path == NULL) {
+ return false;
+ }
if (file_exist(ldb_path) && !mapping_switch(ldb_path)) {
- unlink(state_path("group_mapping.tdb"));
+ unlink(tdb_path);
+ talloc_free(tdb_path);
+ talloc_free(ldb_path);
return false;
} else {
}
#endif
}
+ talloc_free(tdb_path);
+ talloc_free(ldb_path);
return true;
}
static char *group_mapping_key(TALLOC_CTX *mem_ctx, const struct dom_sid *sid)
{
- char *sidstr, *result;
+ char sidstr[DOM_SID_STR_BUFLEN];
+ int len;
- sidstr = sid_string_talloc(talloc_tos(), sid);
- if (sidstr == NULL) {
+ len = dom_sid_string_buf(sid, sidstr, sizeof(sidstr));
+ if (len >= sizeof(sidstr)) {
return NULL;
}
- result = talloc_asprintf(mem_ctx, "%s%s", GROUP_PREFIX, sidstr);
-
- TALLOC_FREE(sidstr);
- return result;
+ return talloc_asprintf(mem_ctx, "%s%s", GROUP_PREFIX, sidstr);
}
/****************************************************************************
TALLOC_FREE(name);
}
+ if (map->nt_name == NULL) {
+ errno = EIO;
+ goto failed;
+ }
+
+ if (map->comment == NULL) {
+ map->comment = talloc_strdup(map, "");
+ }
+ if (map->comment == NULL) {
+ errno = ENOMEM;
+ goto failed;
+ }
+
if (!add_mapping_entry(map, 0)) {
errno = EIO;
goto failed;