LCOV - code coverage report
Current view: top level - source3/registry - reg_init_full.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 10 15 66.7 %
Date: 2024-04-21 15:09:00 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /* 
       2             :  *  Unix SMB/CIFS implementation.
       3             :  *  Virtual Windows Registry Layer
       4             :  *  Copyright (C) Gerald Carter                     2002-2005
       5             :  *  Copyright (C) Michael Adam                      2008
       6             :  *
       7             :  *  This program is free software; you can redistribute it and/or modify
       8             :  *  it under the terms of the GNU General Public License as published by
       9             :  *  the Free Software Foundation; either version 3 of the License, or
      10             :  *  (at your option) any later version.
      11             :  *  
      12             :  *  This program is distributed in the hope that it will be useful,
      13             :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15             :  *  GNU General Public License for more details.
      16             :  *  
      17             :  *  You should have received a copy of the GNU General Public License
      18             :  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
      19             :  */
      20             : 
      21             : /* Initialize the registry with all available backends. */
      22             : 
      23             : #include "includes.h"
      24             : #include "registry.h"
      25             : #include "reg_cachehook.h"
      26             : #include "reg_backend_db.h"
      27             : #include "reg_init_basic.h"
      28             : #include "reg_init_full.h"
      29             : 
      30             : #undef DBGC_CLASS
      31             : #define DBGC_CLASS DBGC_REGISTRY
      32             : 
      33             : extern struct registry_ops printing_ops;
      34             : extern struct registry_ops eventlog_ops;
      35             : extern struct registry_ops shares_reg_ops;
      36             : extern struct registry_ops smbconf_reg_ops;
      37             : extern struct registry_ops netlogon_params_reg_ops;
      38             : extern struct registry_ops prod_options_reg_ops;
      39             : extern struct registry_ops tcpip_params_reg_ops;
      40             : extern struct registry_ops hkpt_params_reg_ops;
      41             : extern struct registry_ops current_version_reg_ops;
      42             : extern struct registry_ops perflib_reg_ops;
      43             : extern struct registry_ops regdb_ops;           /* these are the default */
      44             : 
      45             : /* array of registry_hook's which are read into a tree for easy access */
      46             : /* #define REG_TDB_ONLY         1 */
      47             : 
      48             : struct registry_hook {
      49             :         const char      *keyname;       /* full path to name of key */
      50             :         struct registry_ops     *ops;   /* registry function hooks */
      51             : };
      52             : 
      53             : struct registry_hook reg_hooks[] = {
      54             : #ifndef REG_TDB_ONLY 
      55             :   { KEY_PRINTING "\\Printers",        &printing_ops },
      56             :   { KEY_PRINTING_2K,            &regdb_ops },
      57             :   { KEY_PRINTING_PORTS,         &regdb_ops },
      58             :   { KEY_PCC,                    &regdb_ops },
      59             :   { KEY_SHARES,                 &shares_reg_ops },
      60             :   { KEY_SMBCONF,                &smbconf_reg_ops },
      61             :   { KEY_NETLOGON_PARAMS,        &netlogon_params_reg_ops },
      62             :   { KEY_PROD_OPTIONS,           &prod_options_reg_ops },
      63             :   { KEY_TCPIP_PARAMS,           &tcpip_params_reg_ops },
      64             :   { KEY_HKPT,                   &hkpt_params_reg_ops },
      65             :   { KEY_CURRENT_VERSION,        &current_version_reg_ops },
      66             :   { KEY_PERFLIB,                &perflib_reg_ops },
      67             : #endif
      68             :   { NULL, NULL }
      69             : };
      70             : 
      71             : /***********************************************************************
      72             :  Open the registry database and initialize the registry_hook cache
      73             :  with all available backends.
      74             :  ***********************************************************************/
      75             : 
      76         186 : WERROR registry_init_full(void)
      77             : {
      78           0 :         int i;
      79           0 :         WERROR werr;
      80             : 
      81         186 :         werr = registry_init_common();
      82         186 :         if (!W_ERROR_IS_OK(werr)) {
      83           0 :                 goto fail;
      84             :         }
      85             : 
      86             :         /* build the cache tree of registry hooks */
      87             : 
      88        2418 :         for ( i=0; reg_hooks[i].keyname; i++ ) {
      89        2232 :                 werr = reghook_cache_add(reg_hooks[i].keyname, reg_hooks[i].ops);
      90        2232 :                 if (!W_ERROR_IS_OK(werr)) {
      91           0 :                         goto fail;
      92             :                 }
      93             :         }
      94             : 
      95         186 :         if ( DEBUGLEVEL >= 20 )
      96           0 :                 reghook_dump_cache(20);
      97             : 
      98         186 : fail:
      99             :         /* close and let each smbd open up as necessary */
     100         186 :         regdb_close();
     101         186 :         return werr;
     102             : }

Generated by: LCOV version 1.14