LCOV - code coverage report
Current view: top level - source3/lib - util_names.c (source / functions) Hit Total Coverage
Test: coverage report for master 2b515b7d Lines: 19 24 79.2 %
Date: 2024-02-28 12:06:22 Functions: 2 3 66.7 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             :    Samba utility functions
       4             :    Copyright (C) Andrew Tridgell 1992-1998
       5             :    Copyright (C) Jeremy Allison 2001-2007
       6             :    Copyright (C) Simo Sorce 2001
       7             :    Copyright (C) Jim McDonough <jmcd@us.ibm.com> 2003
       8             :    Copyright (C) James Peach 2006
       9             :    Copyright (C) Andrew Bartlett 2010-2011
      10             : 
      11             :    This program is free software; you can redistribute it and/or modify
      12             :    it under the terms of the GNU General Public License as published by
      13             :    the Free Software Foundation; either version 3 of the License, or
      14             :    (at your option) any later version.
      15             : 
      16             :    This program is distributed in the hope that it will be useful,
      17             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      18             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19             :    GNU General Public License for more details.
      20             : 
      21             :    You should have received a copy of the GNU General Public License
      22             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      23             : */
      24             : 
      25             : #include "includes.h"
      26             : 
      27             : /******************************************************************
      28             :  get the default domain/netbios name to be used when dealing
      29             :  with our passdb list of accounts
      30             : ******************************************************************/
      31             : 
      32      384854 : const char *get_global_sam_name(void)
      33             : {
      34      384854 :         if (IS_DC) {
      35       51719 :                 return lp_workgroup();
      36             :         }
      37      333135 :         return lp_netbios_name();
      38             : }
      39             : 
      40             : 
      41             : /******************************************************************
      42             :  Get the default domain/netbios name to be used when
      43             :  testing authentication.
      44             : ******************************************************************/
      45             : 
      46           0 : const char *my_sam_name(void)
      47             : {
      48           0 :         if (lp_server_role() == ROLE_STANDALONE) {
      49           0 :                 return lp_netbios_name();
      50             :         }
      51             : 
      52           0 :         return lp_workgroup();
      53             : }
      54             : 
      55       28865 : bool is_allowed_domain(const char *domain_name)
      56             : {
      57       28865 :         const char **ignored_domains = NULL;
      58       28865 :         const char **dom = NULL;
      59             : 
      60       28865 :         ignored_domains = lp_parm_string_list(-1,
      61             :                                               "winbind",
      62             :                                               "ignore domains",
      63             :                                               NULL);
      64             : 
      65       28865 :         for (dom = ignored_domains; dom != NULL && *dom != NULL; dom++) {
      66           2 :                 if (gen_fnmatch(*dom, domain_name) == 0) {
      67           2 :                         DBG_NOTICE("Ignoring domain '%s'\n", domain_name);
      68           2 :                         return false;
      69             :                 }
      70             :         }
      71             : 
      72       28863 :         if (lp_allow_trusted_domains()) {
      73       28590 :                 return true;
      74             :         }
      75             : 
      76         273 :         if (strequal(lp_workgroup(), domain_name)) {
      77           0 :                 return true;
      78             :         }
      79             : 
      80         273 :         if (is_myname(domain_name)) {
      81         269 :                 return true;
      82             :         }
      83             : 
      84           4 :         DBG_NOTICE("Not trusted domain '%s'\n", domain_name);
      85           4 :         return false;
      86             : }

Generated by: LCOV version 1.14