summaryrefslogtreecommitdiff
path: root/source3/sam
diff options
context:
space:
mode:
Diffstat (limited to 'source3/sam')
-rw-r--r--source3/sam/idmap_tdb.c21
-rw-r--r--source3/sam/idmap_util.c14
2 files changed, 19 insertions, 16 deletions
diff --git a/source3/sam/idmap_tdb.c b/source3/sam/idmap_tdb.c
index 27cf706e7d..13e3affbd6 100644
--- a/source3/sam/idmap_tdb.c
+++ b/source3/sam/idmap_tdb.c
@@ -252,8 +252,9 @@ static NTSTATUS db_set_mapping(const DOM_SID *sid, unid_t id, int id_type)
static NTSTATUS db_idmap_init(void)
{
SMB_STRUCT_STAT stbuf;
- char *tdbfile;
+ char *tdbfile = NULL;
int32 version;
+ BOOL tdb_is_new = False;
/* use the old database if present */
if (!file_exist(lock_path("idmap.tdb"), &stbuf)) {
@@ -264,8 +265,11 @@ static NTSTATUS db_idmap_init(void)
DEBUG(0, ("idmap_init: out of memory!\n"));
return NT_STATUS_NO_MEMORY;
}
+ } else {
+ tdb_is_new = True;
}
- } else {
+ }
+ if (!tdbfile) {
tdbfile = strdup(lock_path("idmap.tdb"));
if (!tdbfile) {
DEBUG(0, ("idmap_init: out of memory!\n"));
@@ -285,10 +289,15 @@ static NTSTATUS db_idmap_init(void)
SAFE_FREE(tdbfile);
/* check against earlier versions */
- version = tdb_fetch_int32(idmap_tdb, "IDMAP_VERSION");
- if (version != IDMAP_VERSION) {
- DEBUG(0, ("idmap_init: Unable to open idmap database, it's in an old format!\n"));
- return NT_STATUS_INTERNAL_DB_ERROR;
+ if (tdb_is_new) {
+ /* TODO: delete the file if this fail */
+ tdb_store_int32(idmap_tdb, "IDMAP_VERSION", IDMAP_VERSION);
+ } else {
+ version = tdb_fetch_int32(idmap_tdb, "IDMAP_VERSION");
+ if (version != IDMAP_VERSION) {
+ DEBUG(0, ("idmap_init: Unable to open idmap database, it's in an old format!\n"));
+ return NT_STATUS_INTERNAL_DB_ERROR;
+ }
}
/* Create high water marks for group and user id */
diff --git a/source3/sam/idmap_util.c b/source3/sam/idmap_util.c
index fd44938989..b282d2ef83 100644
--- a/source3/sam/idmap_util.c
+++ b/source3/sam/idmap_util.c
@@ -97,15 +97,13 @@ DOM_SID *gid_to_sid(DOM_SID *psid, gid_t gid)
was done correctly, False if not. sidtype is set by this function.
*****************************************************************/
-BOOL sid_to_uid(const DOM_SID *psid, uid_t *puid, enum SID_NAME_USE *sidtype)
+BOOL sid_to_uid(const DOM_SID *psid, uid_t *puid)
{
unid_t id;
int type;
DEBUG(10,("sid_to_uid: sid = [%s]\n", sid_string_static(psid)));
- *sidtype = SID_NAME_USER;
-
type = ID_USERID;
if (NT_STATUS_IS_OK(idmap_get_id_from_sid(&id, &type, psid))) {
DEBUG(10,("sid_to_uid: uid = [%d]\n", id.uid));
@@ -123,7 +121,7 @@ BOOL sid_to_uid(const DOM_SID *psid, uid_t *puid, enum SID_NAME_USE *sidtype)
DEBUG(0, ("sid_to_uid: Error extracting RID from SID\n!"));
return False;
}
- if (!pdb_rid_is_user(rid)) {
+ if (!fallback_pdb_rid_is_user(rid)) {
DEBUG(3, ("sid_to_uid: RID %u is *NOT* a user\n", (unsigned)rid));
return False;
}
@@ -140,15 +138,13 @@ BOOL sid_to_uid(const DOM_SID *psid, uid_t *puid, enum SID_NAME_USE *sidtype)
was done correctly, False if not.
*****************************************************************/
-BOOL sid_to_gid(const DOM_SID *psid, gid_t *pgid, enum SID_NAME_USE *sidtype)
+BOOL sid_to_gid(const DOM_SID *psid, gid_t *pgid)
{
unid_t id;
int type;
DEBUG(10,("sid_to_gid: sid = [%s]\n", sid_string_static(psid)));
- *sidtype = SID_NAME_ALIAS;
-
type = ID_GROUPID;
if (NT_STATUS_IS_OK(idmap_get_id_from_sid(&id, &type, psid))) {
DEBUG(10,("sid_to_gid: gid = [%d]\n", id.gid));
@@ -166,7 +162,6 @@ BOOL sid_to_gid(const DOM_SID *psid, gid_t *pgid, enum SID_NAME_USE *sidtype)
return False;
*pgid = map.gid;
- *sidtype = map.sid_name_use;
return True;
} else {
uint32 rid;
@@ -175,12 +170,11 @@ BOOL sid_to_gid(const DOM_SID *psid, gid_t *pgid, enum SID_NAME_USE *sidtype)
DEBUG(0, ("sid_to_gid: Error extracting RID from SID\n!"));
return False;
}
- if (pdb_rid_is_user(rid)) {
+ if (fallback_pdb_rid_is_user(rid)) {
DEBUG(3, ("sid_to_gid: RID %u is *NOT* a group\n", (unsigned)rid));
return False;
}
*pgid = pdb_group_rid_to_gid(rid);
- *sidtype = SID_NAME_ALIAS;
}
}