LCOV - code coverage report
Current view: top level - source4/lib/registry - samba.c (source / functions) Hit Total Coverage
Test: coverage report for vadcx-master-patch-75612 fe003de8 Lines: 17 23 73.9 %
Date: 2024-02-29 22:57:05 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             :    Copyright (C) Jelmer Vernooij                        2004-2007.
       4             : 
       5             :    This program is free software; you can redistribute it and/or modify
       6             :    it under the terms of the GNU General Public License as published by
       7             :    the Free Software Foundation; either version 3 of the License, or
       8             :    (at your option) any later version.
       9             : 
      10             :    This program is distributed in the hope that it will be useful,
      11             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      12             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      13             :    GNU General Public License for more details.
      14             : 
      15             :    You should have received a copy of the GNU General Public License
      16             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      17             : */
      18             : 
      19             : #include "includes.h"
      20             : #include "registry.h"
      21             : #include "param/param.h"
      22             : 
      23             : /**
      24             :  * @file
      25             :  * @brief Samba-specific registry functions
      26             :  */
      27             : 
      28        1292 : static WERROR mount_samba_hive(struct registry_context *ctx,
      29             :                                struct tevent_context *event_ctx,
      30             :                                struct loadparm_context *lp_ctx,
      31             :                                struct auth_session_info *auth_info,
      32             :                                struct cli_credentials *creds,
      33             :                                const char *name,
      34             :                                uint32_t hive_id)
      35             : {
      36           0 :         WERROR error;
      37           0 :         struct hive_key *hive;
      38           0 :         const char *location;
      39             : 
      40        1292 :         location = talloc_asprintf(ctx, "%s/%s.ldb",
      41             :                                    lpcfg_private_dir(lp_ctx),
      42             :                                    name);
      43        1292 :         W_ERROR_HAVE_NO_MEMORY(location);
      44             : 
      45        1292 :         error = reg_open_hive(ctx, location, auth_info, creds, event_ctx, lp_ctx, &hive);
      46             : 
      47        1292 :         if (W_ERROR_EQUAL(error, WERR_FILE_NOT_FOUND))
      48          27 :                 error = reg_open_ldb_file(ctx, location, auth_info,
      49             :                                           creds, event_ctx, lp_ctx, &hive);
      50             : 
      51        1292 :         talloc_free(discard_const_p(char, location));
      52             : 
      53        1292 :         if (!W_ERROR_IS_OK(error))
      54           0 :                 return error;
      55             : 
      56        1292 :         return reg_mount_hive(ctx, hive, hive_id, NULL);
      57             : }
      58             : 
      59             : 
      60         323 : _PUBLIC_ WERROR reg_open_samba(TALLOC_CTX *mem_ctx,
      61             :                                struct registry_context **ctx,
      62             :                                struct tevent_context *ev_ctx,
      63             :                                struct loadparm_context *lp_ctx,
      64             :                                struct auth_session_info *session_info,
      65             :                                struct cli_credentials *credentials)
      66             : {
      67           0 :         WERROR result;
      68             : 
      69         323 :         result = reg_open_local(mem_ctx, ctx);
      70         323 :         if (!W_ERROR_IS_OK(result)) {
      71           0 :                 return result;
      72             :         }
      73             : 
      74         323 :         mount_samba_hive(*ctx, ev_ctx, lp_ctx, session_info, credentials,
      75             :                          "hklm", HKEY_LOCAL_MACHINE);
      76             : 
      77         323 :         mount_samba_hive(*ctx, ev_ctx, lp_ctx, session_info, credentials,
      78             :                          "hkcr", HKEY_CLASSES_ROOT);
      79             : 
      80             :         /* FIXME: Should be mounted from NTUSER.DAT in the home directory of the
      81             :          * current user */
      82         323 :         mount_samba_hive(*ctx, ev_ctx, lp_ctx, session_info, credentials,
      83             :                          "hkcu", HKEY_CURRENT_USER);
      84             : 
      85         323 :         mount_samba_hive(*ctx, ev_ctx, lp_ctx, session_info, credentials,
      86             :                          "hku", HKEY_USERS);
      87             : 
      88             :         /* FIXME: Different hive backend for HKEY_CLASSES_ROOT: merged view of HKEY_LOCAL_MACHINE\Software\Classes
      89             :          * and HKEY_CURRENT_USER\Software\Classes */
      90             : 
      91             :         /* FIXME: HKEY_CURRENT_CONFIG is an alias for HKEY_LOCAL_MACHINE\System\CurrentControlSet\Hardware Profiles\Current */
      92             : 
      93             :         /* FIXME: HKEY_PERFORMANCE_DATA is dynamically generated */
      94             : 
      95             :         /* FIXME: HKEY_LOCAL_MACHINE\Hardware is autogenerated */
      96             : 
      97             :         /* FIXME: HKEY_LOCAL_MACHINE\Security\SAM is an alias for HKEY_LOCAL_MACHINE\SAM */
      98             : 
      99         323 :         return WERR_OK;
     100             : }

Generated by: LCOV version 1.14