summaryrefslogtreecommitdiff
path: root/source3/nsswitch
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2003-04-06 09:35:16 +0000
committerSimo Sorce <idra@samba.org>2003-04-06 09:35:16 +0000
commit0ac2b380018bd50eaaf6d6bcfbb6e949b85a6601 (patch)
tree99d701957698c8c4e8f7c99e4c83424b5009e088 /source3/nsswitch
parent588b1978a19f8bb468165740dc293ae1a4e28951 (diff)
downloadsamba-0ac2b380018bd50eaaf6d6bcfbb6e949b85a6601.tar.gz
samba-0ac2b380018bd50eaaf6d6bcfbb6e949b85a6601.tar.bz2
samba-0ac2b380018bd50eaaf6d6bcfbb6e949b85a6601.zip
This commit make winbindd copy winbindd_idmap.tdb into idmap.tdb on the
first run if idmap.tdb is not found, and then eventually convert it to the new format. This is done to unify winbind and idmap databases and to make a backup of winbindd_idmap.tdb in case you want to downgrade (of course it will not be updated). This is needed because idmap.tdb contains also local mappings, not only foreign domains mappings. Added some other fixes/improvements Simo. (This used to be commit cf17261519fd8775500f9b9d6caa2bc462e04633)
Diffstat (limited to 'source3/nsswitch')
-rw-r--r--source3/nsswitch/winbindd_idmap_tdb.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/source3/nsswitch/winbindd_idmap_tdb.c b/source3/nsswitch/winbindd_idmap_tdb.c
index b47b7ed07d..12d6972bae 100644
--- a/source3/nsswitch/winbindd_idmap_tdb.c
+++ b/source3/nsswitch/winbindd_idmap_tdb.c
@@ -106,7 +106,7 @@ static int tdb_convert_fn(TDB_CONTEXT * tdb, TDB_DATA key, TDB_DATA data,
/*****************************************************************************
Convert the idmap database from an older version.
*****************************************************************************/
-static BOOL tdb_idmap_convert(const char *idmap_name)
+static BOOL tdb_idmap_convert(void)
{
int32 vers = tdb_fetch_int32(idmap_tdb, "IDMAP_VERSION");
BOOL bigendianheader =
@@ -280,8 +280,27 @@ static BOOL tdb_get_id_from_sid(DOM_SID * sid, uid_t * id, BOOL isgroup)
*****************************************************************************/
static BOOL tdb_idmap_init(void)
{
+ SMB_STRUCT_STAT stbuf;
+
+ /* move to the new database on first startup */
+ if (!file_exist(lock_path("idmap.tdb"), &stbuf)) {
+ if (file_exist(lock_path("winbindd_idmap.tdb"), &stbuf)) {
+ char *cmd = NULL;
+
+ /* lazy file copy */
+ if (asprintf(&cmd, "cp -p %s/winbindd_idmap.tdb %s/idmap.tdb", lp_lockdir(), lp_lockdir()) != -1) {
+ system(cmd);
+ free(cmd);
+ }
+ if (!file_exist(lock_path("idmap.tdb"), &stbuf)) {
+ DEBUG(0, ("idmap_init: Unable to make a new database copy\n"));
+ return False;
+ }
+ }
+ }
+
/* Open tdb cache */
- if (!(idmap_tdb = tdb_open_log(lock_path("winbindd_idmap.tdb"), 0,
+ if (!(idmap_tdb = tdb_open_log(lock_path("idmap.tdb"), 0,
TDB_DEFAULT, O_RDWR | O_CREAT,
0600))) {
DEBUG(0,
@@ -290,9 +309,8 @@ static BOOL tdb_idmap_init(void)
}
/* possibly convert from an earlier version */
- if (!tdb_idmap_convert(lock_path("winbindd_idmap.tdb"))) {
- DEBUG(0,
- ("winbindd_idmap_init: Unable to open idmap database\n"));
+ if (!tdb_idmap_convert()) {
+ DEBUG(0, ("winbindd_idmap_init: Unable to open idmap database\n"));
return False;
}