2002-07-16 02:27:07 +04:00
/*
* Unix SMB / CIFS implementation .
2005-05-23 20:25:31 +04:00
* Virtual Windows Registry Layer
* Copyright ( C ) Gerald Carter 2002 - 2005
2008-01-21 02:32:01 +03:00
* Copyright ( C ) Michael Adam 2008
2002-07-16 02:27:07 +04:00
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
2007-07-09 23:25:36 +04:00
* the Free Software Foundation ; either version 3 of the License , or
2002-07-16 02:27:07 +04:00
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2007-07-10 09:23:25 +04:00
* along with this program ; if not , see < http : //www.gnu.org/licenses/>.
2002-07-16 02:27:07 +04:00
*/
2008-01-21 02:32:01 +03:00
/* Initialize the registry with all available backends. */
2002-07-16 02:27:07 +04:00
# include "includes.h"
# undef DBGC_CLASS
2007-09-29 03:05:52 +04:00
# define DBGC_CLASS DBGC_REGISTRY
2002-07-16 02:27:07 +04:00
2002-07-19 03:00:24 +04:00
extern REGISTRY_OPS printing_ops ;
2005-03-24 02:26:33 +03:00
extern REGISTRY_OPS eventlog_ops ;
2005-05-23 20:25:31 +04:00
extern REGISTRY_OPS shares_reg_ops ;
2006-11-30 10:38:40 +03:00
extern REGISTRY_OPS smbconf_reg_ops ;
2008-01-18 11:40:42 +03:00
extern REGISTRY_OPS netlogon_params_reg_ops ;
2008-01-18 18:15:43 +03:00
extern REGISTRY_OPS prod_options_reg_ops ;
2008-01-20 01:46:13 +03:00
extern REGISTRY_OPS tcpip_params_reg_ops ;
2008-01-20 03:00:14 +03:00
extern REGISTRY_OPS hkpt_params_reg_ops ;
2008-01-20 05:24:13 +03:00
extern REGISTRY_OPS current_version_reg_ops ;
2008-01-20 05:39:27 +03:00
extern REGISTRY_OPS perflib_reg_ops ;
2002-07-19 22:49:44 +04:00
extern REGISTRY_OPS regdb_ops ; /* these are the default */
2002-07-16 02:27:07 +04:00
2002-07-19 03:00:24 +04:00
/* array of REGISTRY_HOOK's which are read into a tree for easy access */
2005-06-29 20:35:32 +04:00
/* #define REG_TDB_ONLY 1 */
2002-07-16 02:27:07 +04:00
2002-07-19 03:00:24 +04:00
REGISTRY_HOOK reg_hooks [ ] = {
2005-06-29 20:35:32 +04:00
# ifndef REG_TDB_ONLY
2005-05-23 20:25:31 +04:00
{ KEY_PRINTING , & printing_ops } ,
{ KEY_PRINTING_2K , & printing_ops } ,
{ KEY_PRINTING_PORTS , & printing_ops } ,
{ KEY_SHARES , & shares_reg_ops } ,
2006-11-30 10:38:40 +03:00
{ KEY_SMBCONF , & smbconf_reg_ops } ,
2008-01-18 11:40:42 +03:00
{ KEY_NETLOGON_PARAMS , & netlogon_params_reg_ops } ,
2008-01-18 18:15:43 +03:00
{ KEY_PROD_OPTIONS , & prod_options_reg_ops } ,
2008-01-20 01:46:13 +03:00
{ KEY_TCPIP_PARAMS , & tcpip_params_reg_ops } ,
2008-01-20 03:00:14 +03:00
{ KEY_HKPT , & hkpt_params_reg_ops } ,
2008-01-20 05:24:13 +03:00
{ KEY_CURRENT_VERSION , & current_version_reg_ops } ,
2008-01-20 05:39:27 +03:00
{ KEY_PERFLIB , & perflib_reg_ops } ,
2005-06-29 20:35:32 +04:00
# endif
2002-07-19 03:00:24 +04:00
{ NULL , NULL }
} ;
2002-07-16 02:27:07 +04:00
2002-07-23 08:55:06 +04:00
/***********************************************************************
Open the registry database and initialize the REGISTRY_HOOK cache
2008-01-21 02:32:01 +03:00
with all available backens .
2002-07-23 08:55:06 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2007-10-19 04:40:25 +04:00
bool init_registry ( void )
2002-07-23 08:55:06 +04:00
{
int i ;
2007-12-14 00:20:58 +03:00
bool ret = false ;
TALLOC_CTX * frame = talloc_stackframe ( ) ;
2002-07-23 08:55:06 +04:00
2005-09-30 21:13:37 +04:00
2006-12-03 20:16:45 +03:00
if ( ! regdb_init ( ) ) {
2006-12-03 20:34:11 +03:00
DEBUG ( 0 , ( " init_registry: failed to initialize the registry tdb! \n " ) ) ;
2007-12-14 00:20:58 +03:00
goto fail ;
2006-12-03 20:16:45 +03:00
}
2006-12-03 20:34:11 +03:00
/* build the cache tree of registry hooks */
reghook_cache_init ( ) ;
2002-07-23 08:55:06 +04:00
for ( i = 0 ; reg_hooks [ i ] . keyname ; i + + ) {
if ( ! reghook_cache_add ( & reg_hooks [ i ] ) )
2007-12-14 00:20:58 +03:00
goto fail ;
2002-07-23 08:55:06 +04:00
}
if ( DEBUGLEVEL > = 20 )
reghook_dump_cache ( 20 ) ;
2005-10-06 21:48:03 +04:00
/* add any keys for other services */
2005-09-30 21:13:37 +04:00
svcctl_init_keys ( ) ;
2005-10-06 21:48:03 +04:00
eventlog_init_keys ( ) ;
2005-11-08 19:33:45 +03:00
perfcount_init_keys ( ) ;
2005-09-30 21:13:37 +04:00
2005-10-07 16:14:25 +04:00
/* close and let each smbd open up as necessary */
regdb_close ( ) ;
2007-12-14 00:20:58 +03:00
ret = true ;
fail :
TALLOC_FREE ( frame ) ;
return ret ;
2002-07-23 08:55:06 +04:00
}