LCOV - code coverage report
Current view: top level - source3/smbd - password.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 32 32 100.0 %
Date: 2024-04-21 15:09:00 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 "source3/smbd/smbXsrv_session.h"
      26             : #include "../librpc/gen_ndr/netlogon.h"
      27             : #include "auth.h"
      28             : #include "../libcli/security/security.h"
      29             : 
      30             : /****************************************************************************
      31             :  Invalidate a uid.
      32             : ****************************************************************************/
      33             : 
      34       32243 : void invalidate_vuid(struct smbd_server_connection *sconn, uint64_t vuid)
      35             : {
      36       32243 :         struct smbXsrv_session *session = NULL;
      37         760 :         NTSTATUS status;
      38             : 
      39       32243 :         status = get_valid_smbXsrv_session(sconn->client, vuid, &session);
      40       32243 :         if (!NT_STATUS_IS_OK(status)) {
      41        3034 :                 return;
      42             :         }
      43             : 
      44       29209 :         session_yield(session);
      45             : 
      46       29209 :         SMB_ASSERT(sconn->num_users > 0);
      47       29209 :         sconn->num_users--;
      48             : 
      49             :         /* clear the vuid from the 'cache' on each connection, and
      50             :            from the vuid 'owner' of connections */
      51       29209 :         conn_clear_vuid_caches(sconn, vuid);
      52             : }
      53             : 
      54       28625 : int register_homes_share(const char *username)
      55             : {
      56         780 :         const struct loadparm_substitution *lp_sub =
      57       28625 :                 loadparm_s3_global_substitution();
      58         780 :         int result;
      59         780 :         struct passwd *pwd;
      60             : 
      61       28625 :         result = lp_servicenumber(username);
      62       28625 :         if (result != -1) {
      63           4 :                 DEBUG(3, ("Using static (or previously created) service for "
      64             :                           "user '%s'; path = '%s'\n", username,
      65             :                           lp_path(talloc_tos(), lp_sub, result)));
      66           4 :                 return result;
      67             :         }
      68             : 
      69       28621 :         pwd = Get_Pwnam_alloc(talloc_tos(), username);
      70             : 
      71       28621 :         if ((pwd == NULL) || (pwd->pw_dir[0] == '\0')) {
      72          41 :                 DEBUG(3, ("No home directory defined for user '%s'\n",
      73             :                           username));
      74          41 :                 TALLOC_FREE(pwd);
      75          41 :                 return -1;
      76             :         }
      77             : 
      78       28580 :         if (strequal(pwd->pw_dir, "/")) {
      79          14 :                 DBG_NOTICE("Invalid home directory defined for user '%s'\n",
      80             :                            username);
      81          14 :                 TALLOC_FREE(pwd);
      82          14 :                 return -1;
      83             :         }
      84             : 
      85       28566 :         DEBUG(3, ("Adding homes service for user '%s' using home directory: "
      86             :                   "'%s'\n", username, pwd->pw_dir));
      87             : 
      88       28566 :         result = add_home_service(username, username, pwd->pw_dir);
      89             : 
      90       28566 :         TALLOC_FREE(pwd);
      91       28566 :         return result;
      92             : }

Generated by: LCOV version 1.14