2007-08-21 02:04:24 +00:00
/*
2002-01-30 06:08:46 +00:00
Unix SMB / CIFS implementation .
1996-05-04 07:50:46 +00:00
Password and authentication handling
1998-01-22 13:27:43 +00:00
Copyright ( C ) Andrew Tridgell 1992 - 1998
2007-08-21 02:04:24 +00:00
Copyright ( C ) Jeremy Allison 2007.
1996-05-04 07:50:46 +00:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-09 19:25:36 +00:00
the Free Software Foundation ; either version 3 of the License , or
1996-05-04 07:50:46 +00:00
( at your option ) any later version .
2007-08-21 02:04:24 +00:00
1996-05-04 07:50:46 +00:00
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
2007-08-21 02:04:24 +00:00
1996-05-04 07:50:46 +00:00
You should have received a copy of the GNU General Public License
2007-07-10 00:52:41 +00:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
1996-05-04 07:50:46 +00:00
*/
# include "includes.h"
2011-02-25 17:14:22 +01:00
# include "system/passwd.h"
2011-03-22 16:57:01 +01:00
# include "smbd/smbd.h"
2009-01-08 12:03:45 +01:00
# include "smbd/globals.h"
2010-08-05 15:14:04 +02:00
# include "../librpc/gen_ndr/netlogon.h"
2011-03-24 13:46:20 +01:00
# include "auth.h"
2011-07-19 11:57:05 +10:00
# include "../libcli/security/security.h"
1999-12-13 13:27:58 +00:00
/****************************************************************************
2003-07-17 18:55:40 +00:00
Invalidate a uid .
1999-12-13 13:27:58 +00:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-07-17 18:55:40 +00:00
2012-06-05 18:17:15 +02:00
void invalidate_vuid ( struct smbd_server_connection * sconn , uint64_t vuid )
1999-12-13 13:27:58 +00:00
{
2020-01-06 08:20:14 +01:00
struct smbXsrv_session * session = NULL ;
NTSTATUS status ;
2007-08-21 01:43:22 +00:00
2020-01-06 08:20:14 +01:00
status = get_valid_smbXsrv_session ( sconn - > client , vuid , & session ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return ;
}
session_yield ( session ) ;
2003-02-24 02:35:54 +00:00
2012-03-03 05:41:43 +01:00
SMB_ASSERT ( sconn - > num_users > 0 ) ;
sconn - > num_users - - ;
2000-06-09 03:30:54 +00:00
2002-09-25 15:19:00 +00:00
/* clear the vuid from the 'cache' on each connection, and
from the vuid ' owner ' of connections */
2009-05-27 11:15:44 +02:00
conn_clear_vuid_caches ( sconn , vuid ) ;
1999-12-13 13:27:58 +00:00
}
2010-05-17 18:22:19 -07:00
int register_homes_share ( const char * username )
2008-04-29 13:23:47 +02:00
{
2019-10-31 19:14:02 +01:00
const struct loadparm_substitution * lp_sub =
loadparm_s3_global_substitution ( ) ;
2008-04-29 13:23:47 +02:00
int result ;
struct passwd * pwd ;
result = lp_servicenumber ( username ) ;
if ( result ! = - 1 ) {
DEBUG ( 3 , ( " Using static (or previously created) service for "
" user '%s'; path = '%s' \n " , username ,
2019-10-31 19:14:02 +01:00
lp_path ( talloc_tos ( ) , lp_sub , result ) ) ) ;
2008-04-29 13:23:47 +02:00
return result ;
}
2010-10-20 08:16:23 -07:00
pwd = Get_Pwnam_alloc ( talloc_tos ( ) , username ) ;
2008-04-29 13:23:47 +02:00
if ( ( pwd = = NULL ) | | ( pwd - > pw_dir [ 0 ] = = ' \0 ' ) ) {
DEBUG ( 3 , ( " No home directory defined for user '%s' \n " ,
username ) ) ;
TALLOC_FREE ( pwd ) ;
return - 1 ;
}
2018-11-22 18:23:24 +01:00
if ( strequal ( pwd - > pw_dir , " / " ) ) {
DBG_NOTICE ( " Invalid home directory defined for user '%s' \n " ,
username ) ;
TALLOC_FREE ( pwd ) ;
return - 1 ;
}
2008-04-29 13:23:47 +02:00
DEBUG ( 3 , ( " Adding homes service for user '%s' using home directory: "
" '%s' \n " , username , pwd - > pw_dir ) ) ;
result = add_home_service ( username , username , pwd - > pw_dir ) ;
TALLOC_FREE ( pwd ) ;
return result ;
}