LCOV - code coverage report
Current view: top level - source3/smbd - globals.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 18 19 94.7 %
Date: 2024-04-21 15:09:00 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/Netbios implementation.
       3             :    smbd globals
       4             :    Copyright (C) Stefan Metzmacher 2009
       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             : #include "includes.h"
      21             : #include "smbd/smbd.h"
      22             : #include "smbd/globals.h"
      23             : #include "../lib/util/memcache.h"
      24             : #include "messages.h"
      25             : #include <tdb.h>
      26             : 
      27             : #ifdef USE_DMAPI
      28             : struct smbd_dmapi_context *dmapi_ctx = NULL;
      29             : #endif
      30             : 
      31             : const struct mangle_fns *mangle_fns = NULL;
      32             : 
      33             : unsigned char *chartest = NULL;
      34             : TDB_CONTEXT *tdb_mangled_cache = NULL;
      35             : 
      36             : /*
      37             :   this determines how many characters are used from the original filename
      38             :   in the 8.3 mangled name. A larger value leads to a weaker hash and more collisions.
      39             :   The largest possible value is 6.
      40             : */
      41             : unsigned mangle_prefix = 0;
      42             : 
      43             : bool logged_ioctl_message = false;
      44             : 
      45             : time_t last_smb_conf_reload_time = 0;
      46             : pid_t background_lpq_updater_pid = -1;
      47             : 
      48             : /****************************************************************************
      49             :  structure to hold a linked list of queued messages.
      50             :  for processing.
      51             : ****************************************************************************/
      52             : uint32_t common_flags2 = FLAGS2_LONG_PATH_COMPONENTS|FLAGS2_32_BIT_ERROR_CODES|FLAGS2_EXTENDED_ATTRIBUTES;
      53             : 
      54             : struct smb_trans_enc_state *partial_srv_trans_enc_ctx = NULL;
      55             : struct smb_trans_enc_state *srv_trans_enc_ctx = NULL;
      56             : 
      57             : /* A stack of security contexts.  We include the current context as being
      58             :    the first one, so there is room for another MAX_SEC_CTX_DEPTH more. */
      59             : struct sec_ctx sec_ctx_stack[MAX_SEC_CTX_DEPTH + 1];
      60             : int sec_ctx_stack_ndx = 0;
      61             : bool become_uid_done = false;
      62             : bool become_gid_done = false;
      63             : 
      64             : uint32_t global_client_caps = 0;
      65             : 
      66             : uint16_t fnf_handle = 257;
      67             : 
      68             : /* A stack of current_user connection contexts. */
      69             : struct conn_ctx conn_ctx_stack[MAX_SEC_CTX_DEPTH];
      70             : int conn_ctx_stack_ndx = 0;
      71             : 
      72             : struct vfs_init_function_entry *backends = NULL;
      73             : char *sparse_buf = NULL;
      74             : char *LastDir = NULL;
      75             : 
      76             : struct smbd_parent_context *am_parent = NULL;
      77             : struct memcache *smbd_memcache_ctx = NULL;
      78             : bool exit_firsttime = true;
      79             : 
      80             : struct smbXsrv_client *global_smbXsrv_client = NULL;
      81             : 
      82     2543313 : struct memcache *smbd_memcache(void)
      83             : {
      84     2543313 :         if (!smbd_memcache_ctx) {
      85             :                 /*
      86             :                  * Note we MUST use the NULL context here, not the
      87             :                  * autofree context, to avoid side effects in forked
      88             :                  * children exiting.
      89             :                  */
      90         227 :                 smbd_memcache_ctx = memcache_init(NULL,
      91         227 :                                                   lp_max_stat_cache_size()*1024);
      92             :         }
      93     2543313 :         if (!smbd_memcache_ctx) {
      94           0 :                 smb_panic("Could not init smbd memcache");
      95             :         }
      96             : 
      97     2543313 :         return smbd_memcache_ctx;
      98             : }
      99             : 
     100          50 : void smbd_init_globals(void)
     101             : {
     102          50 :         ZERO_STRUCT(conn_ctx_stack);
     103             : 
     104          50 :         ZERO_STRUCT(sec_ctx_stack);
     105          50 : }
     106             : 
     107      490425 : struct GUID smbd_request_guid(struct smb_request *smb1req, uint16_t idx)
     108             : {
     109      490425 :         struct GUID v = {
     110      490425 :                 .time_low = (uint32_t)smb1req->mid,
     111             :                 .time_hi_and_version = idx,
     112             :         };
     113             : 
     114      490425 :         if (smb1req->smb2req != NULL) {
     115      484565 :                 v.time_mid = (uint16_t)smb1req->smb2req->current_idx;
     116             :         } else {
     117        5860 :                 v.time_mid = (uint16_t)(uintptr_t)smb1req->vwv;
     118             :         }
     119             : 
     120      490425 :         SBVAL((uint8_t *)&v, 8, smb1req->xconn->channel_id);
     121             : 
     122      490425 :         return v;
     123             : }

Generated by: LCOV version 1.14