2007-08-21 06:04:24 +04:00
/*
2002-01-30 09:08:46 +03:00
Unix SMB / CIFS implementation .
1996-05-04 11:50:46 +04:00
Password and authentication handling
1998-01-22 16:27:43 +03:00
Copyright ( C ) Andrew Tridgell 1992 - 1998
2007-08-21 06:04:24 +04:00
Copyright ( C ) Jeremy Allison 2007.
1996-05-04 11:50:46 +04: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 23:25:36 +04:00
the Free Software Foundation ; either version 3 of the License , or
1996-05-04 11:50:46 +04:00
( at your option ) any later version .
2007-08-21 06:04:24 +04:00
1996-05-04 11:50:46 +04: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 06:04:24 +04:00
1996-05-04 11:50:46 +04:00
You should have received a copy of the GNU General Public License
2007-07-10 04:52:41 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
1996-05-04 11:50:46 +04:00
*/
# include "includes.h"
2011-02-25 19:14:22 +03:00
# include "system/passwd.h"
2011-03-22 18:57:01 +03:00
# include "smbd/smbd.h"
2009-01-08 14:03:45 +03:00
# include "smbd/globals.h"
2010-08-05 17:14:04 +04:00
# include "../librpc/gen_ndr/netlogon.h"
2011-03-24 15:46:20 +03:00
# include "auth.h"
2011-07-19 05:57:05 +04:00
# include "../libcli/security/security.h"
1999-12-13 16:27:58 +03:00
/****************************************************************************
2003-07-17 22:55:40 +04:00
Invalidate a uid .
1999-12-13 16:27:58 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-07-17 22:55:40 +04:00
2012-06-05 20:17:15 +04:00
void invalidate_vuid ( struct smbd_server_connection * sconn , uint64_t vuid )
1999-12-13 16:27:58 +03:00
{
2020-01-06 10:20:14 +03:00
struct smbXsrv_session * session = NULL ;
NTSTATUS status ;
2007-08-21 05:43:22 +04:00
2020-01-06 10:20:14 +03:00
status = get_valid_smbXsrv_session ( sconn - > client , vuid , & session ) ;
if ( ! NT_STATUS_IS_OK ( status ) ) {
return ;
}
session_yield ( session ) ;
2003-02-24 05:35:54 +03:00
2012-03-03 08:41:43 +04:00
SMB_ASSERT ( sconn - > num_users > 0 ) ;
sconn - > num_users - - ;
2000-06-09 07:30:54 +04:00
2002-09-25 19:19:00 +04:00
/* clear the vuid from the 'cache' on each connection, and
from the vuid ' owner ' of connections */
2009-05-27 13:15:44 +04:00
conn_clear_vuid_caches ( sconn , vuid ) ;
1999-12-13 16:27:58 +03:00
}
2010-05-18 05:22:19 +04:00
int register_homes_share ( const char * username )
2008-04-29 15:23:47 +04:00
{
2019-10-31 21:14:02 +03:00
const struct loadparm_substitution * lp_sub =
loadparm_s3_global_substitution ( ) ;
2008-04-29 15:23:47 +04: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 21:14:02 +03:00
lp_path ( talloc_tos ( ) , lp_sub , result ) ) ) ;
2008-04-29 15:23:47 +04:00
return result ;
}
2010-10-20 19:16:23 +04:00
pwd = Get_Pwnam_alloc ( talloc_tos ( ) , username ) ;
2008-04-29 15:23:47 +04: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 20:23:24 +03: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 15:23:47 +04: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 ;
}