LCOV - code coverage report
Current view: top level - source3/registry - reg_backend_shares.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 0 41 0.0 %
Date: 2024-04-21 15:09:00 Functions: 0 5 0.0 %

          Line data    Source code
       1             : /* 
       2             :  *  Unix SMB/CIFS implementation.
       3             :  *  Virtual Windows Registry Layer
       4             :  *  Copyright (C) Gerald Carter                     2005
       5             :  *
       6             :  *  This program is free software; you can redistribute it and/or modify
       7             :  *  it under the terms of the GNU General Public License as published by
       8             :  *  the Free Software Foundation; either version 3 of the License, or
       9             :  *  (at your option) any later version.
      10             :  *  
      11             :  *  This program is distributed in the hope that it will be useful,
      12             :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             :  *  GNU General Public License for more details.
      15             :  *  
      16             :  *  You should have received a copy of the GNU General Public License
      17             :  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
      18             :  */
      19             : 
      20             : /* Implementation of registry virtual views for printing information */
      21             : 
      22             : #include "includes.h"
      23             : #include "registry.h"
      24             : #include "reg_objects.h"
      25             : 
      26             : #undef DBGC_CLASS
      27             : #define DBGC_CLASS DBGC_REGISTRY
      28             : 
      29             : /**********************************************************************
      30             :  It is safe to assume that every registry path passed into one of
      31             :  the exported functions here begins with KEY_SHARES else
      32             :  these functions would have never been called.  This is a small utility
      33             :  function to strip the beginning of the path and make a copy that the
      34             :  caller can modify.  Note that the caller is responsible for releasing
      35             :  the memory allocated here.
      36             :  **********************************************************************/
      37             : 
      38           0 : static char* trim_reg_path( const char *path )
      39             : {
      40           0 :         const char *p;
      41           0 :         uint16_t key_len = strlen(KEY_SHARES);
      42             : 
      43             :         /* 
      44             :          * sanity check...this really should never be True.
      45             :          * It is only here to prevent us from accessing outside
      46             :          * the path buffer in the extreme case.
      47             :          */
      48             : 
      49           0 :         if ( strlen(path) < key_len ) {
      50           0 :                 DEBUG(0,("trim_reg_path: Registry path too short! [%s]\n", path));
      51           0 :                 return NULL;
      52             :         }
      53             : 
      54           0 :         p = path + strlen( KEY_SHARES );
      55             : 
      56           0 :         if ( *p == '\\' )
      57           0 :                 p++;
      58             : 
      59           0 :         if ( *p )
      60           0 :                 return SMB_STRDUP(p);
      61             :         else
      62           0 :                 return NULL;
      63             : }
      64             : 
      65             : /**********************************************************************
      66             :  Enumerate registry subkey names given a registry path.  
      67             :  Caller is responsible for freeing memory to **subkeys
      68             :  *********************************************************************/
      69             : 
      70           0 : static int shares_subkey_info( const char *key, struct regsubkey_ctr *subkey_ctr )
      71             : {
      72           0 :         char            *path;
      73           0 :         bool            top_level = False;
      74           0 :         int             num_subkeys = 0;
      75             : 
      76           0 :         DEBUG(10, ("shares_subkey_info: key=>[%s]\n", key));
      77             : 
      78           0 :         path = trim_reg_path( key );
      79             : 
      80             :         /* check to see if we are dealing with the top level key */
      81             : 
      82           0 :         if ( !path )
      83           0 :                 top_level = True;
      84             : 
      85           0 :         if ( top_level ) {
      86           0 :                 num_subkeys = 1;
      87           0 :                 regsubkey_ctr_addkey( subkey_ctr, "Security" );
      88             :         }
      89             : #if 0
      90             :         else
      91             :                 num_subkeys = handle_share_subpath( path, subkey_ctr, NULL );
      92             : #endif
      93             : 
      94           0 :         SAFE_FREE( path );
      95             : 
      96           0 :         return num_subkeys;
      97             : }
      98             : 
      99             : /**********************************************************************
     100             :  Enumerate registry values given a registry path.  
     101             :  Caller is responsible for freeing memory 
     102             :  *********************************************************************/
     103             : 
     104           0 : static int shares_value_info(const char *key, struct regval_ctr *val)
     105             : {
     106           0 :         char            *path;
     107           0 :         bool            top_level = False;
     108           0 :         int             num_values = 0;
     109             : 
     110           0 :         DEBUG(10, ("shares_value_info: key=>[%s]\n", key));
     111             : 
     112           0 :         path = trim_reg_path( key );
     113             : 
     114             :         /* check to see if we are dealing with the top level key */
     115             : 
     116           0 :         if ( !path )
     117           0 :                 top_level = True;
     118             : 
     119             :         /* fill in values from the getprinterdata_printer_server() */
     120           0 :         if ( top_level )
     121           0 :                 num_values = 0;
     122             : #if 0
     123             :         else
     124             :                 num_values = handle_printing_subpath( path, NULL, val );
     125             : #endif
     126             : 
     127           0 :         SAFE_FREE(path);
     128             : 
     129           0 :         return num_values;
     130             : }
     131             : 
     132             : /**********************************************************************
     133             :  Stub function which always returns failure since we don't want
     134             :  people storing share information directly via registry calls
     135             :  (for now at least)
     136             :  *********************************************************************/
     137             : 
     138           0 : static bool shares_store_subkey( const char *key, struct regsubkey_ctr *subkeys )
     139             : {
     140           0 :         return False;
     141             : }
     142             : 
     143             : /**********************************************************************
     144             :  Stub function which always returns failure since we don't want
     145             :  people storing share information directly via registry calls
     146             :  (for now at least)
     147             :  *********************************************************************/
     148             : 
     149           0 : static bool shares_store_value(const char *key, struct regval_ctr *val)
     150             : {
     151           0 :         return False;
     152             : }
     153             : 
     154             : /* 
     155             :  * Table of function pointers for accessing printing data
     156             :  */
     157             :  
     158             : struct registry_ops shares_reg_ops = {
     159             :         .fetch_subkeys = shares_subkey_info,
     160             :         .fetch_values = shares_value_info,
     161             :         .store_subkeys = shares_store_subkey,
     162             :         .store_values = shares_store_value,
     163             : };
     164             : 
     165             : 

Generated by: LCOV version 1.14