summaryrefslogtreecommitdiff
path: root/source3/registry
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2005-06-17 15:53:01 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:57:19 -0500
commitfee4b03e02af795a55ba0b955b9e6b07856d05dd (patch)
treeaac6aadaa70cb2df68622438e836690e3e9af5c7 /source3/registry
parent2129d3c711a109b47c3c1596a6a639520d2f72d2 (diff)
downloadsamba-fee4b03e02af795a55ba0b955b9e6b07856d05dd.tar.gz
samba-fee4b03e02af795a55ba0b955b9e6b07856d05dd.tar.bz2
samba-fee4b03e02af795a55ba0b955b9e6b07856d05dd.zip
r7692: start versioning the registry.tdb file since it can be modified now
(This used to be commit a091b37d59d1e0228a9c8d4bd2a31e9bbaafde99)
Diffstat (limited to 'source3/registry')
-rw-r--r--source3/registry/reg_db.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/source3/registry/reg_db.c b/source3/registry/reg_db.c
index a459aa5f5f..ce44e490ab 100644
--- a/source3/registry/reg_db.c
+++ b/source3/registry/reg_db.c
@@ -55,6 +55,8 @@ static const char *builtin_registry_paths[] = {
"HKU",
"HKCR",
NULL };
+
+#define REGVER_V1 1 /* first db version with write support */
/***********************************************************************
Open the registry data in the tdb
@@ -125,15 +127,15 @@ static BOOL init_registry_data( void )
BOOL init_registry_db( void )
{
- static pid_t local_pid;
+ const char *vstring = "INFO/version";
+ uint32 vers_id;
- if (tdb_reg && local_pid == sys_getpid())
+ if ( tdb_reg )
return True;
/* placeholder tdb; reinit upon startup */
- tdb_reg = tdb_open_log(lock_path("registry.tdb"), 0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST, O_RDWR, 0600);
- if ( !tdb_reg )
+ if ( !(tdb_reg = tdb_open_log(lock_path("registry.tdb"), 0, TDB_DEFAULT, O_RDWR, 0600)) )
{
tdb_reg = tdb_open_log(lock_path("registry.tdb"), 0, TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
if ( !tdb_reg ) {
@@ -145,15 +147,19 @@ BOOL init_registry_db( void )
DEBUG(10,("init_registry: Successfully created registry tdb\n"));
}
- /* create the registry here */
- if ( !init_registry_data() ) {
- DEBUG(0,("init_registry: Failed to initiailize data in registry!\n"));
- return False;
+ vers_id = tdb_fetch_int32(tdb_reg, vstring);
+
+ if ( vers_id != REGVER_V1 ) {
+
+ /* create the registry here */
+
+ if ( !init_registry_data() ) {
+ DEBUG(0,("init_registry: Failed to initiailize data in registry!\n"));
+ return False;
+ }
}
- local_pid = sys_getpid();
-
return True;
}