LCOV - code coverage report
Current view: top level - source3/lib - smbd_shim.c (source / functions) Hit Total Coverage
Test: coverage report for abartlet/fix-coverage dd10fb34 Lines: 36 43 83.7 %
Date: 2021-09-23 10:06:22 Functions: 10 11 90.9 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             :    Runtime plugin adapter for various "smbd"-functions.
       4             : 
       5             :    Copyright (C) Gerald (Jerry) Carter          2004.
       6             :    Copyright (C) Andrew Bartlett                2011.
       7             : 
       8             :    This program is free software; you can redistribute it and/or modify
       9             :    it under the terms of the GNU General Public License as published by
      10             :    the Free Software Foundation; either version 3 of the License, or
      11             :    (at your option) any later version.
      12             : 
      13             :    This program is distributed in the hope that it will be useful,
      14             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16             :    GNU General Public License for more details.
      17             : 
      18             :    You should have received a copy of the GNU General Public License
      19             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      20             : */
      21             : 
      22             : /* Shim functions required due to the horrible dependency mess
      23             :    in Samba. */
      24             : 
      25             : #include "includes.h"
      26             : #include "smbd_shim.h"
      27             : 
      28             : static struct smbd_shim shim;
      29             : 
      30         117 : void set_smbd_shim(const struct smbd_shim *shim_functions)
      31             : {
      32         117 :         shim = *shim_functions;
      33         117 : }
      34             : 
      35       10199 : void send_stat_cache_delete_message(struct messaging_context *msg_ctx,
      36             :                                     const char *name)
      37             : {
      38       10199 :         if (shim.send_stat_cache_delete_message) {
      39       10199 :                 shim.send_stat_cache_delete_message(msg_ctx, name);
      40             :         }
      41       10199 : }
      42             : 
      43      734714 : bool change_to_root_user(void)
      44             : {
      45      734714 :         if (shim.change_to_root_user) {
      46      734597 :                 return shim.change_to_root_user();
      47             :         }
      48         117 :         return false;
      49             : }
      50             : 
      51      182158 : bool become_authenticated_pipe_user(struct auth_session_info *session_info)
      52             : {
      53      182158 :         if (shim.become_authenticated_pipe_user) {
      54      182158 :                 return shim.become_authenticated_pipe_user(session_info);
      55             :         }
      56             : 
      57           0 :         return false;
      58             : }
      59             : 
      60      182100 : bool unbecome_authenticated_pipe_user(void)
      61             : {
      62      182100 :         if (shim.unbecome_authenticated_pipe_user) {
      63      182100 :                 return shim.unbecome_authenticated_pipe_user();
      64             :         }
      65             : 
      66           0 :         return false;
      67             : }
      68             : 
      69             : /**
      70             :  * The following two functions need to be called from inside the low-level BRL
      71             :  * code for oplocks correctness in smbd.  Since other utility binaries also
      72             :  * link in some of the brl code directly, these dummy functions are necessary
      73             :  * to avoid needing to link in the oplocks code and its dependencies to all of
      74             :  * the utility binaries.
      75             :  */
      76      175985 : void contend_level2_oplocks_begin(files_struct *fsp,
      77             :                                   enum level2_contention_type type)
      78             : {
      79      175985 :         if (shim.contend_level2_oplocks_begin) {
      80      175985 :                 shim.contend_level2_oplocks_begin(fsp, type);
      81             :         }
      82      175985 :         return;
      83             : }
      84             : 
      85      175577 : void contend_level2_oplocks_end(files_struct *fsp,
      86             :                                 enum level2_contention_type type)
      87             : {
      88      175577 :         if (shim.contend_level2_oplocks_end) {
      89      175577 :                 shim.contend_level2_oplocks_end(fsp, type);
      90             :         }
      91      175577 :         return;
      92             : }
      93             : 
      94     4967908 : void become_root(void)
      95             : {
      96     4967908 :         if (shim.become_root) {
      97     4894212 :                 shim.become_root();
      98             :         }
      99     4967908 :         return;
     100             : }
     101             : 
     102     4967860 : void unbecome_root(void)
     103             : {
     104     4967860 :         if (shim.unbecome_root) {
     105     4894164 :                 shim.unbecome_root();
     106             :         }
     107     4967860 :         return;
     108             : }
     109             : 
     110           0 : void exit_server(const char *reason)
     111             : {
     112           0 :         if (shim.exit_server) {
     113           0 :                 shim.exit_server(reason);
     114             :         }
     115           0 :         exit(1);
     116             : }
     117             : 
     118       27245 : void exit_server_cleanly(const char *const reason)
     119             : {
     120       27245 :         if (shim.exit_server_cleanly) {
     121       27245 :                 shim.exit_server_cleanly(reason);
     122             :         }
     123           0 :         exit(0);
     124             : }

Generated by: LCOV version 1.13