LCOV - code coverage report
Current view: top level - source3/smbd - password.c (source / functions) Hit Total Coverage
Test: coverage report for support-claim-type-attributes 6b5c566e Lines: 32 32 100.0 %
Date: 2023-11-21 12:31:41 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             :    Password and authentication handling
       4             :    Copyright (C) Andrew Tridgell 1992-1998
       5             :    Copyright (C) Jeremy Allison 2007.
       6             : 
       7             :    This program is free software; you can redistribute it and/or modify
       8             :    it under the terms of the GNU General Public License as published by
       9             :    the Free Software Foundation; either version 3 of the License, or
      10             :    (at your option) any later version.
      11             : 
      12             :    This program is distributed in the hope that it will be useful,
      13             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      15             :    GNU General Public License for more details.
      16             : 
      17             :    You should have received a copy of the GNU General Public License
      18             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      19             : */
      20             : 
      21             : #include "includes.h"
      22             : #include "system/passwd.h"
      23             : #include "smbd/smbd.h"
      24             : #include "smbd/globals.h"
      25             : #include "../librpc/gen_ndr/netlogon.h"
      26             : #include "auth.h"
      27             : #include "../libcli/security/security.h"
      28             : 
      29             : /****************************************************************************
      30             :  Invalidate a uid.
      31             : ****************************************************************************/
      32             : 
      33       32297 : void invalidate_vuid(struct smbd_server_connection *sconn, uint64_t vuid)
      34             : {
      35       32297 :         struct smbXsrv_session *session = NULL;
      36         760 :         NTSTATUS status;
      37             : 
      38       32297 :         status = get_valid_smbXsrv_session(sconn->client, vuid, &session);
      39       32297 :         if (!NT_STATUS_IS_OK(status)) {
      40        3455 :                 return;
      41             :         }
      42             : 
      43       28842 :         session_yield(session);
      44             : 
      45       28842 :         SMB_ASSERT(sconn->num_users > 0);
      46       28842 :         sconn->num_users--;
      47             : 
      48             :         /* clear the vuid from the 'cache' on each connection, and
      49             :            from the vuid 'owner' of connections */
      50       28842 :         conn_clear_vuid_caches(sconn, vuid);
      51             : }
      52             : 
      53       28365 : int register_homes_share(const char *username)
      54             : {
      55         780 :         const struct loadparm_substitution *lp_sub =
      56       28365 :                 loadparm_s3_global_substitution();
      57         780 :         int result;
      58         780 :         struct passwd *pwd;
      59             : 
      60       28365 :         result = lp_servicenumber(username);
      61       28365 :         if (result != -1) {
      62           4 :                 DEBUG(3, ("Using static (or previously created) service for "
      63             :                           "user '%s'; path = '%s'\n", username,
      64             :                           lp_path(talloc_tos(), lp_sub, result)));
      65           4 :                 return result;
      66             :         }
      67             : 
      68       28361 :         pwd = Get_Pwnam_alloc(talloc_tos(), username);
      69             : 
      70       28361 :         if ((pwd == NULL) || (pwd->pw_dir[0] == '\0')) {
      71          41 :                 DEBUG(3, ("No home directory defined for user '%s'\n",
      72             :                           username));
      73          41 :                 TALLOC_FREE(pwd);
      74          41 :                 return -1;
      75             :         }
      76             : 
      77       28320 :         if (strequal(pwd->pw_dir, "/")) {
      78          14 :                 DBG_NOTICE("Invalid home directory defined for user '%s'\n",
      79             :                            username);
      80          14 :                 TALLOC_FREE(pwd);
      81          14 :                 return -1;
      82             :         }
      83             : 
      84       28306 :         DEBUG(3, ("Adding homes service for user '%s' using home directory: "
      85             :                   "'%s'\n", username, pwd->pw_dir));
      86             : 
      87       28306 :         result = add_home_service(username, username, pwd->pw_dir);
      88             : 
      89       28306 :         TALLOC_FREE(pwd);
      90       28306 :         return result;
      91             : }

Generated by: LCOV version 1.14