summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2003-06-25 08:15:51 +0000
committerSimo Sorce <idra@samba.org>2003-06-25 08:15:51 +0000
commitd993c171b242bf42b35d510ab4cd32912020509e (patch)
treedfcfaec2438cbd82ae0704cdb769e1d43c61c4c0 /source3
parent86c9ba789c8d4a0f7b4418ec367a0298ff333534 (diff)
downloadsamba-d993c171b242bf42b35d510ab4cd32912020509e.tar.gz
samba-d993c171b242bf42b35d510ab4cd32912020509e.tar.bz2
samba-d993c171b242bf42b35d510ab4cd32912020509e.zip
Tought I already done.
Set back 3.0 to use only winbindd_idmap.tdb as idmap database as told on samba-technical. Tested and working so far. (This used to be commit e154e50fed8968567f75fcd581de2b41914ea2c1)
Diffstat (limited to 'source3')
-rw-r--r--source3/sam/idmap_tdb.c44
-rw-r--r--source3/sam/idmap_util.c10
2 files changed, 22 insertions, 32 deletions
diff --git a/source3/sam/idmap_tdb.c b/source3/sam/idmap_tdb.c
index d494759a2b..1f53321c9b 100644
--- a/source3/sam/idmap_tdb.c
+++ b/source3/sam/idmap_tdb.c
@@ -404,29 +404,19 @@ static NTSTATUS db_idmap_init( char *params )
BOOL tdb_is_new = False;
/* use the old database if present */
- if (!file_exist(lock_path("idmap.tdb"), &stbuf)) {
- if (file_exist(lock_path("winbindd_idmap.tdb"), &stbuf)) {
- DEBUG(0, ("idmap_init: using winbindd_idmap.tdb file!\n"));
- tdbfile = strdup(lock_path("winbindd_idmap.tdb"));
- if (!tdbfile) {
- DEBUG(0, ("idmap_init: out of memory!\n"));
- return NT_STATUS_NO_MEMORY;
- }
- } else {
- tdb_is_new = True;
- }
- }
+ tdbfile = strdup(lock_path("winbindd_idmap.tdb"));
if (!tdbfile) {
- tdbfile = strdup(lock_path("idmap.tdb"));
- if (!tdbfile) {
- DEBUG(0, ("idmap_init: out of memory!\n"));
- return NT_STATUS_NO_MEMORY;
- }
+ DEBUG(0, ("idmap_init: out of memory!\n"));
+ return NT_STATUS_NO_MEMORY;
}
- DEBUG(10,("db_idmap_init: Opening tdbfile\n", tdbfile ));
+ if (!file_exist(tdbfile, &stbuf)) {
+ tdb_is_new = True;
+ }
+
+ DEBUG(10,("db_idmap_init: Opening tdbfile\n", tdbfile ));
- /* Open tdb cache */
+ /* Open idmap repository */
if (!(idmap_tdb = tdb_open_log(tdbfile, 0,
TDB_DEFAULT, O_RDWR | O_CREAT,
0644))) {
@@ -438,12 +428,16 @@ static NTSTATUS db_idmap_init( char *params )
SAFE_FREE(tdbfile);
/* check against earlier versions */
- 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) {
+ version = tdb_fetch_int32(idmap_tdb, "IDMAP_VERSION");
+ if (version != IDMAP_VERSION) {
+ if (tdb_is_new) {
+ /* the file didn't existed before opening it, let's
+ * store idmap version as nobody else yet opened and
+ * stored it. I do not like this method but didn't
+ * found a way to understand if an opened tdb have
+ * been just created or not --- SSS */
+ tdb_store_int32(idmap_tdb, "IDMAP_VERSION", IDMAP_VERSION);
+ } else {
DEBUG(0, ("idmap_init: Unable to open idmap database, it's in an old format!\n"));
return NT_STATUS_INTERNAL_DB_ERROR;
}
diff --git a/source3/sam/idmap_util.c b/source3/sam/idmap_util.c
index 7d7e716397..21f827bb9e 100644
--- a/source3/sam/idmap_util.c
+++ b/source3/sam/idmap_util.c
@@ -226,12 +226,11 @@ NTSTATUS sid_to_uid(const DOM_SID *sid, uid_t *uid)
}
}
- if (NT_STATUS_IS_OK(idmap_get_id_from_sid(&id, &flags, sid))) {
+ if (NT_STATUS_IS_OK(ret = idmap_get_id_from_sid(&id, &flags, sid))) {
DEBUG(10,("sid_to_uid: uid = [%d]\n", id.uid));
*uid = id.uid;
- ret = NT_STATUS_OK;
} else if (fallback) {
uint32 rid;
@@ -284,19 +283,17 @@ NTSTATUS sid_to_gid(const DOM_SID *sid, gid_t *gid)
}
}
- if (NT_STATUS_IS_OK(idmap_get_id_from_sid(&id, &flags, sid))) {
+ if (NT_STATUS_IS_OK(ret = idmap_get_id_from_sid(&id, &flags, sid))) {
DEBUG(10,("sid_to_gid: gid = [%d]\n", id.gid));
*gid = id.gid;
- ret = NT_STATUS_OK;
} else if (fallback) {
uint32 rid;
if (!sid_peek_rid(sid, &rid)) {
DEBUG(10,("sid_to_uid: invalid SID!\n"));
- ret = NT_STATUS_INVALID_PARAMETER;
- goto done;
+ return NT_STATUS_INVALID_PARAMETER;
}
DEBUG(10,("sid_to_gid: Fall back to algorithmic mapping\n"));
@@ -311,7 +308,6 @@ NTSTATUS sid_to_gid(const DOM_SID *sid, gid_t *gid)
}
}
-done:
return ret;
}