r9894: Add new registry key expected by Windows XP clients.
authorGerald Carter <jerry@samba.org>
Thu, 1 Sep 2005 14:00:53 +0000 (14:00 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:03:27 +0000 (11:03 -0500)
  HKLM\\SYSTEM\\CurrentControlSet\\Control\\Termininal Server\\DefaultUserConfiguration

Apparently this started showing up after the winreg-write support
was added in 3.0.20rc1 or so.

Also modifed init_registry_data() to always run and add the
required keys.  Initial values however are only written if
they don't already exist.

This makes it easier to add new keys without having to rev the
tdb version number (which is really unnecessary in this case).

Portions of patch reviewed by Thomas Bork on the general samba ml.
(This used to be commit b12a05b23782cfcb93fb4811807ef388de97c95c)

source3/registry/reg_db.c

index 19f9abd80dda05cd2ced1234f1b6737d1821a094..c67d18c19d4ef45d49690ac549c9724737dea0cc 100644 (file)
@@ -49,6 +49,7 @@ static const char *builtin_registry_paths[] = {
        "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib\\009",
        "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Print\\Monitors",
        "HKLM\\SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
+       "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Termininal Server\\DefaultUserConfiguration",
        "HKLM\\SYSTEM\\CurrentControlSet\\Services\\TcpIp\\Parameters",
        "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Netlogon\\Parameters",
        "HKU",
@@ -163,7 +164,12 @@ static BOOL init_registry_data( void )
                }
 
                regdb_fetch_values( builtin_registry_values[i].path, values );
-               switch( builtin_registry_values[i].type ) {
+
+               /* preserve existing values across restarts.  Only add new ones */
+
+               if ( !regval_ctr_key_exists( values, builtin_registry_values[i].valuename ) ) 
+               {
+                       switch( builtin_registry_values[i].type ) {
                        case REG_DWORD:
                                regval_ctr_addvalue( values, 
                                                     builtin_registry_values[i].valuename,
@@ -184,8 +190,9 @@ static BOOL init_registry_data( void )
                        default:
                                DEBUG(0,("init_registry_data: invalid value type in builtin_registry_values [%d]\n",
                                        builtin_registry_values[i].type));
+                       }
+                       regdb_store_values( builtin_registry_values[i].path, values );
                }
-               regdb_store_values( builtin_registry_values[i].path, values );
                
                TALLOC_FREE( values );
        }
@@ -205,8 +212,6 @@ BOOL init_registry_db( void )
        if ( tdb_reg )
                return True;
 
-       /* placeholder tdb; reinit upon startup */
-       
        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);
@@ -223,13 +228,14 @@ BOOL init_registry_db( void )
        vers_id = tdb_fetch_int32(tdb_reg, vstring);
 
        if ( vers_id != REGVER_V1 ) {
+               /* any upgrade code here if needed */
+       }
 
-               /* create the registry here */
+       /* always setup the necessary keys and values */
 
-               if ( !init_registry_data() ) {
-                       DEBUG(0,("init_registry: Failed to initiailize data in registry!\n"));
-                       return False;
-               }
+       if ( !init_registry_data() ) {
+               DEBUG(0,("init_registry: Failed to initiailize data in registry!\n"));
+               return False;
        }
 
        return True;