1996-05-04 11:50:46 +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
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
the Free Software Foundation ; either version 2 of the License , or
( at your option ) any later version .
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 .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
# include "includes.h"
/* users from session setup */
2004-04-15 02:35:28 +04:00
static char * session_userlist = NULL ;
static int len_session_userlist = 0 ;
1996-05-04 11:50:46 +04:00
1999-12-13 16:27:58 +03:00
/* this holds info on user ids that are already validated for this VC */
2000-11-29 01:17:44 +03:00
static user_struct * validated_users ;
static int next_vuid = VUID_OFFSET ;
static int num_validated_vuids ;
1999-12-13 16:27:58 +03:00
2003-09-05 09:32:32 +04:00
extern userdom_struct current_user_info ;
1999-12-13 16:27:58 +03:00
/****************************************************************************
2003-07-17 22:55:40 +04:00
Check if a uid has been validated , and return an pointer to the user_struct
if it has . NULL if not . vuid is biased by an offset . This allows us to
tell random client vuid ' s ( normally zero ) from valid vuids .
1999-12-13 16:27:58 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-07-17 22:55:40 +04:00
1999-12-13 16:27:58 +03:00
user_struct * get_valid_user_struct ( uint16 vuid )
{
2000-11-29 01:17:44 +03:00
user_struct * usp ;
int count = 0 ;
if ( vuid = = UID_FIELD_INVALID )
return NULL ;
for ( usp = validated_users ; usp ; usp = usp - > next , count + + ) {
if ( vuid = = usp - > vuid ) {
2001-04-18 20:41:04 +04:00
if ( count > 10 ) {
DLIST_PROMOTE ( validated_users , usp ) ;
}
2000-11-29 01:17:44 +03:00
return usp ;
}
}
return NULL ;
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
1999-12-13 16:27:58 +03:00
void invalidate_vuid ( uint16 vuid )
{
2000-06-09 22:45:31 +04:00
user_struct * vuser = get_valid_user_struct ( vuid ) ;
1999-12-13 16:27:58 +03:00
2000-06-09 22:45:31 +04:00
if ( vuser = = NULL )
return ;
2003-02-24 05:35:54 +03:00
2002-01-17 11:45:58 +03:00
SAFE_FREE ( vuser - > homedir ) ;
2003-02-24 05:35:54 +03:00
SAFE_FREE ( vuser - > unix_homedir ) ;
SAFE_FREE ( vuser - > logon_script ) ;
2001-11-09 01:19:01 +03:00
session_yield ( vuser ) ;
2003-05-13 19:29:23 +04:00
SAFE_FREE ( vuser - > session_keystr ) ;
2001-04-18 20:41:04 +04:00
2003-02-24 05:35:54 +03:00
free_server_info ( & vuser - > server_info ) ;
Changes all over the shop, but all towards:
- NTLM2 support in the server
- KEY_EXCH support in the server
- variable length session keys.
In detail:
- NTLM2 is an extension of NTLMv1, that is compatible with existing
domain controllers (unlike NTLMv2, which requires a DC upgrade).
* This is known as 'NTLMv2 session security' *
(This is not yet implemented on the RPC pipes however, so there may
well still be issues for PDC setups, particuarly around password
changes. We do not fully understand the sign/seal implications of
NTLM2 on RPC pipes.)
This requires modifications to our authentication subsystem, as we
must handle the 'challege' input into the challenge-response algorithm
being changed. This also needs to be turned off for
'security=server', which does not support this.
- KEY_EXCH is another 'security' mechanism, whereby the session key
actually used by the server is sent by the client, rather than being
the shared-secret directly or indirectly.
- As both these methods change the session key, the auth subsystem
needed to be changed, to 'override' session keys provided by the
backend.
- There has also been a major overhaul of the NTLMSSP subsystem, to merge the 'client' and 'server' functions, so they both operate on a single structure. This should help the SPNEGO implementation.
- The 'names blob' in NTLMSSP is always in unicode - never in ascii.
Don't make an ascii version ever.
- The other big change is to allow variable length session keys. We
have always assumed that session keys are 16 bytes long - and padded
to this length if shorter. However, Kerberos session keys are 8 bytes
long, when the krb5 login uses DES.
* This fix allows SMB signging on machines not yet running MIT KRB5 1.3.1. *
- Add better DEBUG() messages to ntlm_auth, warning administrators of
misconfigurations that prevent access to the privileged pipe. This
should help reduce some of the 'it just doesn't work' issues.
- Fix data_blob_talloc() to behave the same way data_blob() does when
passed a NULL data pointer. (just allocate)
REMEMBER to make clean after this commit - I have changed plenty of data structures...
(This used to be commit f3bbc87b0dac63426cda6fac7a295d3aad810ecc)
2003-11-22 16:19:38 +03:00
data_blob_free ( & vuser - > session_key ) ;
2000-11-29 01:17:44 +03:00
DLIST_REMOVE ( validated_users , vuser ) ;
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 */
conn_clear_vuid_cache ( vuid ) ;
2001-09-17 15:25:41 +04:00
SAFE_FREE ( vuser - > groups ) ;
2000-08-02 06:11:55 +04:00
delete_nt_token ( & vuser - > nt_user_token ) ;
2001-09-17 15:25:41 +04:00
SAFE_FREE ( vuser ) ;
2000-11-29 01:17:44 +03:00
num_validated_vuids - - ;
1999-12-13 16:27:58 +03:00
}
2001-04-18 20:41:04 +04:00
/****************************************************************************
2003-07-17 22:55:40 +04:00
Invalidate all vuid entries for this process .
2001-04-18 20:41:04 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-07-17 22:55:40 +04:00
2001-04-18 20:41:04 +04:00
void invalidate_all_vuids ( void )
{
user_struct * usp , * next = NULL ;
for ( usp = validated_users ; usp ; usp = next ) {
next = usp - > next ;
invalidate_vuid ( usp - > vuid ) ;
}
}
2003-02-24 05:35:54 +03:00
/**
* register that a valid login has been performed , establish ' session ' .
* @ param server_info The token returned from the authentication process .
* ( now ' owned ' by register_vuid )
*
Changes all over the shop, but all towards:
- NTLM2 support in the server
- KEY_EXCH support in the server
- variable length session keys.
In detail:
- NTLM2 is an extension of NTLMv1, that is compatible with existing
domain controllers (unlike NTLMv2, which requires a DC upgrade).
* This is known as 'NTLMv2 session security' *
(This is not yet implemented on the RPC pipes however, so there may
well still be issues for PDC setups, particuarly around password
changes. We do not fully understand the sign/seal implications of
NTLM2 on RPC pipes.)
This requires modifications to our authentication subsystem, as we
must handle the 'challege' input into the challenge-response algorithm
being changed. This also needs to be turned off for
'security=server', which does not support this.
- KEY_EXCH is another 'security' mechanism, whereby the session key
actually used by the server is sent by the client, rather than being
the shared-secret directly or indirectly.
- As both these methods change the session key, the auth subsystem
needed to be changed, to 'override' session keys provided by the
backend.
- There has also been a major overhaul of the NTLMSSP subsystem, to merge the 'client' and 'server' functions, so they both operate on a single structure. This should help the SPNEGO implementation.
- The 'names blob' in NTLMSSP is always in unicode - never in ascii.
Don't make an ascii version ever.
- The other big change is to allow variable length session keys. We
have always assumed that session keys are 16 bytes long - and padded
to this length if shorter. However, Kerberos session keys are 8 bytes
long, when the krb5 login uses DES.
* This fix allows SMB signging on machines not yet running MIT KRB5 1.3.1. *
- Add better DEBUG() messages to ntlm_auth, warning administrators of
misconfigurations that prevent access to the privileged pipe. This
should help reduce some of the 'it just doesn't work' issues.
- Fix data_blob_talloc() to behave the same way data_blob() does when
passed a NULL data pointer. (just allocate)
REMEMBER to make clean after this commit - I have changed plenty of data structures...
(This used to be commit f3bbc87b0dac63426cda6fac7a295d3aad810ecc)
2003-11-22 16:19:38 +03:00
* @ param session_key The User session key for the login session ( now also ' owned ' by register_vuid )
*
* @ param respose_blob The NT challenge - response , if available . ( May be freed after this call )
*
* @ param smb_name The untranslated name of the user
*
2003-02-24 05:35:54 +03:00
* @ return Newly allocated vuid , biased by an offset . ( This allows us to
* tell random client vuid ' s ( normally zero ) from valid vuids . )
*
*/
2000-08-02 06:11:55 +04:00
Changes all over the shop, but all towards:
- NTLM2 support in the server
- KEY_EXCH support in the server
- variable length session keys.
In detail:
- NTLM2 is an extension of NTLMv1, that is compatible with existing
domain controllers (unlike NTLMv2, which requires a DC upgrade).
* This is known as 'NTLMv2 session security' *
(This is not yet implemented on the RPC pipes however, so there may
well still be issues for PDC setups, particuarly around password
changes. We do not fully understand the sign/seal implications of
NTLM2 on RPC pipes.)
This requires modifications to our authentication subsystem, as we
must handle the 'challege' input into the challenge-response algorithm
being changed. This also needs to be turned off for
'security=server', which does not support this.
- KEY_EXCH is another 'security' mechanism, whereby the session key
actually used by the server is sent by the client, rather than being
the shared-secret directly or indirectly.
- As both these methods change the session key, the auth subsystem
needed to be changed, to 'override' session keys provided by the
backend.
- There has also been a major overhaul of the NTLMSSP subsystem, to merge the 'client' and 'server' functions, so they both operate on a single structure. This should help the SPNEGO implementation.
- The 'names blob' in NTLMSSP is always in unicode - never in ascii.
Don't make an ascii version ever.
- The other big change is to allow variable length session keys. We
have always assumed that session keys are 16 bytes long - and padded
to this length if shorter. However, Kerberos session keys are 8 bytes
long, when the krb5 login uses DES.
* This fix allows SMB signging on machines not yet running MIT KRB5 1.3.1. *
- Add better DEBUG() messages to ntlm_auth, warning administrators of
misconfigurations that prevent access to the privileged pipe. This
should help reduce some of the 'it just doesn't work' issues.
- Fix data_blob_talloc() to behave the same way data_blob() does when
passed a NULL data pointer. (just allocate)
REMEMBER to make clean after this commit - I have changed plenty of data structures...
(This used to be commit f3bbc87b0dac63426cda6fac7a295d3aad810ecc)
2003-11-22 16:19:38 +03:00
int register_vuid ( auth_serversupplied_info * server_info , DATA_BLOB session_key , DATA_BLOB response_blob , const char * smb_name )
1999-12-13 16:27:58 +03:00
{
2000-11-29 01:17:44 +03:00
user_struct * vuser = NULL ;
/* Ensure no vuid gets registered in share level security. */
Changes all over the shop, but all towards:
- NTLM2 support in the server
- KEY_EXCH support in the server
- variable length session keys.
In detail:
- NTLM2 is an extension of NTLMv1, that is compatible with existing
domain controllers (unlike NTLMv2, which requires a DC upgrade).
* This is known as 'NTLMv2 session security' *
(This is not yet implemented on the RPC pipes however, so there may
well still be issues for PDC setups, particuarly around password
changes. We do not fully understand the sign/seal implications of
NTLM2 on RPC pipes.)
This requires modifications to our authentication subsystem, as we
must handle the 'challege' input into the challenge-response algorithm
being changed. This also needs to be turned off for
'security=server', which does not support this.
- KEY_EXCH is another 'security' mechanism, whereby the session key
actually used by the server is sent by the client, rather than being
the shared-secret directly or indirectly.
- As both these methods change the session key, the auth subsystem
needed to be changed, to 'override' session keys provided by the
backend.
- There has also been a major overhaul of the NTLMSSP subsystem, to merge the 'client' and 'server' functions, so they both operate on a single structure. This should help the SPNEGO implementation.
- The 'names blob' in NTLMSSP is always in unicode - never in ascii.
Don't make an ascii version ever.
- The other big change is to allow variable length session keys. We
have always assumed that session keys are 16 bytes long - and padded
to this length if shorter. However, Kerberos session keys are 8 bytes
long, when the krb5 login uses DES.
* This fix allows SMB signging on machines not yet running MIT KRB5 1.3.1. *
- Add better DEBUG() messages to ntlm_auth, warning administrators of
misconfigurations that prevent access to the privileged pipe. This
should help reduce some of the 'it just doesn't work' issues.
- Fix data_blob_talloc() to behave the same way data_blob() does when
passed a NULL data pointer. (just allocate)
REMEMBER to make clean after this commit - I have changed plenty of data structures...
(This used to be commit f3bbc87b0dac63426cda6fac7a295d3aad810ecc)
2003-11-22 16:19:38 +03:00
if ( lp_security ( ) = = SEC_SHARE ) {
data_blob_free ( & session_key ) ;
2000-11-29 01:17:44 +03:00
return UID_FIELD_INVALID ;
Changes all over the shop, but all towards:
- NTLM2 support in the server
- KEY_EXCH support in the server
- variable length session keys.
In detail:
- NTLM2 is an extension of NTLMv1, that is compatible with existing
domain controllers (unlike NTLMv2, which requires a DC upgrade).
* This is known as 'NTLMv2 session security' *
(This is not yet implemented on the RPC pipes however, so there may
well still be issues for PDC setups, particuarly around password
changes. We do not fully understand the sign/seal implications of
NTLM2 on RPC pipes.)
This requires modifications to our authentication subsystem, as we
must handle the 'challege' input into the challenge-response algorithm
being changed. This also needs to be turned off for
'security=server', which does not support this.
- KEY_EXCH is another 'security' mechanism, whereby the session key
actually used by the server is sent by the client, rather than being
the shared-secret directly or indirectly.
- As both these methods change the session key, the auth subsystem
needed to be changed, to 'override' session keys provided by the
backend.
- There has also been a major overhaul of the NTLMSSP subsystem, to merge the 'client' and 'server' functions, so they both operate on a single structure. This should help the SPNEGO implementation.
- The 'names blob' in NTLMSSP is always in unicode - never in ascii.
Don't make an ascii version ever.
- The other big change is to allow variable length session keys. We
have always assumed that session keys are 16 bytes long - and padded
to this length if shorter. However, Kerberos session keys are 8 bytes
long, when the krb5 login uses DES.
* This fix allows SMB signging on machines not yet running MIT KRB5 1.3.1. *
- Add better DEBUG() messages to ntlm_auth, warning administrators of
misconfigurations that prevent access to the privileged pipe. This
should help reduce some of the 'it just doesn't work' issues.
- Fix data_blob_talloc() to behave the same way data_blob() does when
passed a NULL data pointer. (just allocate)
REMEMBER to make clean after this commit - I have changed plenty of data structures...
(This used to be commit f3bbc87b0dac63426cda6fac7a295d3aad810ecc)
2003-11-22 16:19:38 +03:00
}
2000-11-29 01:17:44 +03:00
/* Limit allowed vuids to 16bits - VUID_OFFSET. */
Changes all over the shop, but all towards:
- NTLM2 support in the server
- KEY_EXCH support in the server
- variable length session keys.
In detail:
- NTLM2 is an extension of NTLMv1, that is compatible with existing
domain controllers (unlike NTLMv2, which requires a DC upgrade).
* This is known as 'NTLMv2 session security' *
(This is not yet implemented on the RPC pipes however, so there may
well still be issues for PDC setups, particuarly around password
changes. We do not fully understand the sign/seal implications of
NTLM2 on RPC pipes.)
This requires modifications to our authentication subsystem, as we
must handle the 'challege' input into the challenge-response algorithm
being changed. This also needs to be turned off for
'security=server', which does not support this.
- KEY_EXCH is another 'security' mechanism, whereby the session key
actually used by the server is sent by the client, rather than being
the shared-secret directly or indirectly.
- As both these methods change the session key, the auth subsystem
needed to be changed, to 'override' session keys provided by the
backend.
- There has also been a major overhaul of the NTLMSSP subsystem, to merge the 'client' and 'server' functions, so they both operate on a single structure. This should help the SPNEGO implementation.
- The 'names blob' in NTLMSSP is always in unicode - never in ascii.
Don't make an ascii version ever.
- The other big change is to allow variable length session keys. We
have always assumed that session keys are 16 bytes long - and padded
to this length if shorter. However, Kerberos session keys are 8 bytes
long, when the krb5 login uses DES.
* This fix allows SMB signging on machines not yet running MIT KRB5 1.3.1. *
- Add better DEBUG() messages to ntlm_auth, warning administrators of
misconfigurations that prevent access to the privileged pipe. This
should help reduce some of the 'it just doesn't work' issues.
- Fix data_blob_talloc() to behave the same way data_blob() does when
passed a NULL data pointer. (just allocate)
REMEMBER to make clean after this commit - I have changed plenty of data structures...
(This used to be commit f3bbc87b0dac63426cda6fac7a295d3aad810ecc)
2003-11-22 16:19:38 +03:00
if ( num_validated_vuids > = 0xFFFF - VUID_OFFSET ) {
data_blob_free ( & session_key ) ;
2000-11-29 01:17:44 +03:00
return UID_FIELD_INVALID ;
Changes all over the shop, but all towards:
- NTLM2 support in the server
- KEY_EXCH support in the server
- variable length session keys.
In detail:
- NTLM2 is an extension of NTLMv1, that is compatible with existing
domain controllers (unlike NTLMv2, which requires a DC upgrade).
* This is known as 'NTLMv2 session security' *
(This is not yet implemented on the RPC pipes however, so there may
well still be issues for PDC setups, particuarly around password
changes. We do not fully understand the sign/seal implications of
NTLM2 on RPC pipes.)
This requires modifications to our authentication subsystem, as we
must handle the 'challege' input into the challenge-response algorithm
being changed. This also needs to be turned off for
'security=server', which does not support this.
- KEY_EXCH is another 'security' mechanism, whereby the session key
actually used by the server is sent by the client, rather than being
the shared-secret directly or indirectly.
- As both these methods change the session key, the auth subsystem
needed to be changed, to 'override' session keys provided by the
backend.
- There has also been a major overhaul of the NTLMSSP subsystem, to merge the 'client' and 'server' functions, so they both operate on a single structure. This should help the SPNEGO implementation.
- The 'names blob' in NTLMSSP is always in unicode - never in ascii.
Don't make an ascii version ever.
- The other big change is to allow variable length session keys. We
have always assumed that session keys are 16 bytes long - and padded
to this length if shorter. However, Kerberos session keys are 8 bytes
long, when the krb5 login uses DES.
* This fix allows SMB signging on machines not yet running MIT KRB5 1.3.1. *
- Add better DEBUG() messages to ntlm_auth, warning administrators of
misconfigurations that prevent access to the privileged pipe. This
should help reduce some of the 'it just doesn't work' issues.
- Fix data_blob_talloc() to behave the same way data_blob() does when
passed a NULL data pointer. (just allocate)
REMEMBER to make clean after this commit - I have changed plenty of data structures...
(This used to be commit f3bbc87b0dac63426cda6fac7a295d3aad810ecc)
2003-11-22 16:19:38 +03:00
}
2000-11-29 01:17:44 +03:00
if ( ( vuser = ( user_struct * ) malloc ( sizeof ( user_struct ) ) ) = = NULL ) {
DEBUG ( 0 , ( " Failed to malloc users struct! \n " ) ) ;
Changes all over the shop, but all towards:
- NTLM2 support in the server
- KEY_EXCH support in the server
- variable length session keys.
In detail:
- NTLM2 is an extension of NTLMv1, that is compatible with existing
domain controllers (unlike NTLMv2, which requires a DC upgrade).
* This is known as 'NTLMv2 session security' *
(This is not yet implemented on the RPC pipes however, so there may
well still be issues for PDC setups, particuarly around password
changes. We do not fully understand the sign/seal implications of
NTLM2 on RPC pipes.)
This requires modifications to our authentication subsystem, as we
must handle the 'challege' input into the challenge-response algorithm
being changed. This also needs to be turned off for
'security=server', which does not support this.
- KEY_EXCH is another 'security' mechanism, whereby the session key
actually used by the server is sent by the client, rather than being
the shared-secret directly or indirectly.
- As both these methods change the session key, the auth subsystem
needed to be changed, to 'override' session keys provided by the
backend.
- There has also been a major overhaul of the NTLMSSP subsystem, to merge the 'client' and 'server' functions, so they both operate on a single structure. This should help the SPNEGO implementation.
- The 'names blob' in NTLMSSP is always in unicode - never in ascii.
Don't make an ascii version ever.
- The other big change is to allow variable length session keys. We
have always assumed that session keys are 16 bytes long - and padded
to this length if shorter. However, Kerberos session keys are 8 bytes
long, when the krb5 login uses DES.
* This fix allows SMB signging on machines not yet running MIT KRB5 1.3.1. *
- Add better DEBUG() messages to ntlm_auth, warning administrators of
misconfigurations that prevent access to the privileged pipe. This
should help reduce some of the 'it just doesn't work' issues.
- Fix data_blob_talloc() to behave the same way data_blob() does when
passed a NULL data pointer. (just allocate)
REMEMBER to make clean after this commit - I have changed plenty of data structures...
(This used to be commit f3bbc87b0dac63426cda6fac7a295d3aad810ecc)
2003-11-22 16:19:38 +03:00
data_blob_free ( & session_key ) ;
2000-11-29 01:17:44 +03:00
return UID_FIELD_INVALID ;
}
ZERO_STRUCTP ( vuser ) ;
/* Allocate a free vuid. Yes this is a linear search... :-) */
2000-12-08 22:21:09 +03:00
while ( get_valid_user_struct ( next_vuid ) ! = NULL ) {
2000-11-29 01:17:44 +03:00
next_vuid + + ;
/* Check for vuid wrap. */
if ( next_vuid = = UID_FIELD_INVALID )
next_vuid = VUID_OFFSET ;
}
DEBUG ( 10 , ( " register_vuid: allocated vuid = %u \n " , ( unsigned int ) next_vuid ) ) ;
vuser - > vuid = next_vuid ;
2002-09-25 19:19:00 +04:00
/* the next functions should be done by a SID mapping system (SMS) as
* the new real sam db won ' t have reference to unix uids or gids
*/
2003-05-12 22:12:31 +04:00
vuser - > uid = server_info - > uid ;
vuser - > gid = server_info - > gid ;
2002-09-25 19:19:00 +04:00
vuser - > n_groups = server_info - > n_groups ;
if ( vuser - > n_groups ) {
if ( ! ( vuser - > groups = memdup ( server_info - > groups , sizeof ( gid_t ) * vuser - > n_groups ) ) ) {
DEBUG ( 0 , ( " register_vuid: failed to memdup vuser->groups \n " ) ) ;
Changes all over the shop, but all towards:
- NTLM2 support in the server
- KEY_EXCH support in the server
- variable length session keys.
In detail:
- NTLM2 is an extension of NTLMv1, that is compatible with existing
domain controllers (unlike NTLMv2, which requires a DC upgrade).
* This is known as 'NTLMv2 session security' *
(This is not yet implemented on the RPC pipes however, so there may
well still be issues for PDC setups, particuarly around password
changes. We do not fully understand the sign/seal implications of
NTLM2 on RPC pipes.)
This requires modifications to our authentication subsystem, as we
must handle the 'challege' input into the challenge-response algorithm
being changed. This also needs to be turned off for
'security=server', which does not support this.
- KEY_EXCH is another 'security' mechanism, whereby the session key
actually used by the server is sent by the client, rather than being
the shared-secret directly or indirectly.
- As both these methods change the session key, the auth subsystem
needed to be changed, to 'override' session keys provided by the
backend.
- There has also been a major overhaul of the NTLMSSP subsystem, to merge the 'client' and 'server' functions, so they both operate on a single structure. This should help the SPNEGO implementation.
- The 'names blob' in NTLMSSP is always in unicode - never in ascii.
Don't make an ascii version ever.
- The other big change is to allow variable length session keys. We
have always assumed that session keys are 16 bytes long - and padded
to this length if shorter. However, Kerberos session keys are 8 bytes
long, when the krb5 login uses DES.
* This fix allows SMB signging on machines not yet running MIT KRB5 1.3.1. *
- Add better DEBUG() messages to ntlm_auth, warning administrators of
misconfigurations that prevent access to the privileged pipe. This
should help reduce some of the 'it just doesn't work' issues.
- Fix data_blob_talloc() to behave the same way data_blob() does when
passed a NULL data pointer. (just allocate)
REMEMBER to make clean after this commit - I have changed plenty of data structures...
(This used to be commit f3bbc87b0dac63426cda6fac7a295d3aad810ecc)
2003-11-22 16:19:38 +03:00
data_blob_free ( & session_key ) ;
2002-09-25 19:19:00 +04:00
free ( vuser ) ;
2003-02-24 05:35:54 +03:00
free_server_info ( & server_info ) ;
2002-09-25 19:19:00 +04:00
return UID_FIELD_INVALID ;
}
}
2001-11-09 01:19:01 +03:00
vuser - > guest = server_info - > guest ;
2003-07-03 18:56:04 +04:00
fstrcpy ( vuser - > user . unix_name , server_info - > unix_name ) ;
2003-02-24 05:35:54 +03:00
/* This is a potentially untrusted username */
alpha_strcpy ( vuser - > user . smb_name , smb_name , " . _-$ " , sizeof ( vuser - > user . smb_name ) ) ;
2001-10-31 13:46:25 +03:00
fstrcpy ( vuser - > user . domain , pdb_get_domain ( server_info - > sam_account ) ) ;
fstrcpy ( vuser - > user . full_name , pdb_get_fullname ( server_info - > sam_account ) ) ;
2002-01-17 11:45:58 +03:00
{
/* Keep the homedir handy */
const char * homedir = pdb_get_homedir ( server_info - > sam_account ) ;
2002-07-15 14:35:28 +04:00
const char * logon_script = pdb_get_logon_script ( server_info - > sam_account ) ;
2003-06-07 07:20:09 +04:00
if ( ! IS_SAM_DEFAULT ( server_info - > sam_account , PDB_UNIXHOMEDIR ) ) {
const char * unix_homedir = pdb_get_unix_homedir ( server_info - > sam_account ) ;
if ( unix_homedir ) {
vuser - > unix_homedir = smb_xstrdup ( unix_homedir ) ;
}
} else {
struct passwd * passwd = getpwnam_alloc ( vuser - > user . unix_name ) ;
if ( passwd ) {
vuser - > unix_homedir = smb_xstrdup ( passwd - > pw_dir ) ;
passwd_free ( & passwd ) ;
}
}
2002-01-17 11:45:58 +03:00
if ( homedir ) {
vuser - > homedir = smb_xstrdup ( homedir ) ;
}
2002-07-15 14:35:28 +04:00
if ( logon_script ) {
vuser - > logon_script = smb_xstrdup ( logon_script ) ;
}
2002-01-17 11:45:58 +03:00
}
Changes all over the shop, but all towards:
- NTLM2 support in the server
- KEY_EXCH support in the server
- variable length session keys.
In detail:
- NTLM2 is an extension of NTLMv1, that is compatible with existing
domain controllers (unlike NTLMv2, which requires a DC upgrade).
* This is known as 'NTLMv2 session security' *
(This is not yet implemented on the RPC pipes however, so there may
well still be issues for PDC setups, particuarly around password
changes. We do not fully understand the sign/seal implications of
NTLM2 on RPC pipes.)
This requires modifications to our authentication subsystem, as we
must handle the 'challege' input into the challenge-response algorithm
being changed. This also needs to be turned off for
'security=server', which does not support this.
- KEY_EXCH is another 'security' mechanism, whereby the session key
actually used by the server is sent by the client, rather than being
the shared-secret directly or indirectly.
- As both these methods change the session key, the auth subsystem
needed to be changed, to 'override' session keys provided by the
backend.
- There has also been a major overhaul of the NTLMSSP subsystem, to merge the 'client' and 'server' functions, so they both operate on a single structure. This should help the SPNEGO implementation.
- The 'names blob' in NTLMSSP is always in unicode - never in ascii.
Don't make an ascii version ever.
- The other big change is to allow variable length session keys. We
have always assumed that session keys are 16 bytes long - and padded
to this length if shorter. However, Kerberos session keys are 8 bytes
long, when the krb5 login uses DES.
* This fix allows SMB signging on machines not yet running MIT KRB5 1.3.1. *
- Add better DEBUG() messages to ntlm_auth, warning administrators of
misconfigurations that prevent access to the privileged pipe. This
should help reduce some of the 'it just doesn't work' issues.
- Fix data_blob_talloc() to behave the same way data_blob() does when
passed a NULL data pointer. (just allocate)
REMEMBER to make clean after this commit - I have changed plenty of data structures...
(This used to be commit f3bbc87b0dac63426cda6fac7a295d3aad810ecc)
2003-11-22 16:19:38 +03:00
vuser - > session_key = session_key ;
2002-01-20 16:26:31 +03:00
2001-10-31 13:46:25 +03:00
DEBUG ( 10 , ( " register_vuid: (%u,%u) %s %s %s guest=%d \n " ,
( unsigned int ) vuser - > uid ,
( unsigned int ) vuser - > gid ,
2001-11-09 01:19:01 +03:00
vuser - > user . unix_name , vuser - > user . smb_name , vuser - > user . domain , vuser - > guest ) ) ;
2001-10-31 13:46:25 +03:00
2001-08-17 09:38:44 +04:00
DEBUG ( 3 , ( " User name: %s \t Real name: %s \n " , vuser - > user . unix_name , vuser - > user . full_name ) ) ;
2000-11-29 01:17:44 +03:00
2002-09-25 19:19:00 +04:00
if ( server_info - > ptok ) {
vuser - > nt_user_token = dup_nt_token ( server_info - > ptok ) ;
} else {
DEBUG ( 1 , ( " server_info does not contain a user_token - cannot continue \n " ) ) ;
2003-02-24 05:35:54 +03:00
free_server_info ( & server_info ) ;
Changes all over the shop, but all towards:
- NTLM2 support in the server
- KEY_EXCH support in the server
- variable length session keys.
In detail:
- NTLM2 is an extension of NTLMv1, that is compatible with existing
domain controllers (unlike NTLMv2, which requires a DC upgrade).
* This is known as 'NTLMv2 session security' *
(This is not yet implemented on the RPC pipes however, so there may
well still be issues for PDC setups, particuarly around password
changes. We do not fully understand the sign/seal implications of
NTLM2 on RPC pipes.)
This requires modifications to our authentication subsystem, as we
must handle the 'challege' input into the challenge-response algorithm
being changed. This also needs to be turned off for
'security=server', which does not support this.
- KEY_EXCH is another 'security' mechanism, whereby the session key
actually used by the server is sent by the client, rather than being
the shared-secret directly or indirectly.
- As both these methods change the session key, the auth subsystem
needed to be changed, to 'override' session keys provided by the
backend.
- There has also been a major overhaul of the NTLMSSP subsystem, to merge the 'client' and 'server' functions, so they both operate on a single structure. This should help the SPNEGO implementation.
- The 'names blob' in NTLMSSP is always in unicode - never in ascii.
Don't make an ascii version ever.
- The other big change is to allow variable length session keys. We
have always assumed that session keys are 16 bytes long - and padded
to this length if shorter. However, Kerberos session keys are 8 bytes
long, when the krb5 login uses DES.
* This fix allows SMB signging on machines not yet running MIT KRB5 1.3.1. *
- Add better DEBUG() messages to ntlm_auth, warning administrators of
misconfigurations that prevent access to the privileged pipe. This
should help reduce some of the 'it just doesn't work' issues.
- Fix data_blob_talloc() to behave the same way data_blob() does when
passed a NULL data pointer. (just allocate)
REMEMBER to make clean after this commit - I have changed plenty of data structures...
(This used to be commit f3bbc87b0dac63426cda6fac7a295d3aad810ecc)
2003-11-22 16:19:38 +03:00
data_blob_free ( & session_key ) ;
2003-02-24 05:35:54 +03:00
SAFE_FREE ( vuser - > homedir ) ;
SAFE_FREE ( vuser - > unix_homedir ) ;
SAFE_FREE ( vuser - > logon_script ) ;
SAFE_FREE ( vuser ) ;
2002-09-25 19:19:00 +04:00
return UID_FIELD_INVALID ;
}
2000-11-29 01:17:44 +03:00
2003-02-24 05:35:54 +03:00
/* use this to keep tabs on all our info from the authentication */
vuser - > server_info = server_info ;
2002-08-17 19:27:10 +04:00
DEBUG ( 3 , ( " UNIX uid %d is UNIX user %s, and will be vuid %u \n " , ( int ) vuser - > uid , vuser - > user . unix_name , vuser - > vuid ) ) ;
2001-08-17 11:47:10 +04:00
2000-11-29 01:17:44 +03:00
next_vuid + + ;
num_validated_vuids + + ;
DLIST_ADD ( validated_users , vuser ) ;
2001-11-09 01:19:01 +03:00
if ( ! session_claim ( vuser ) ) {
2001-04-18 20:41:04 +04:00
DEBUG ( 1 , ( " Failed to claim session for vuid=%d \n " , vuser - > vuid ) ) ;
invalidate_vuid ( vuser - > vuid ) ;
return - 1 ;
2000-11-29 01:17:44 +03:00
}
1999-12-13 16:27:58 +03:00
2004-01-31 17:44:27 +03:00
/* Register a home dir service for this user iff
2004-08-27 00:47:58 +04:00
2004-01-31 17:44:27 +03:00
( a ) This is not a guest connection ,
2004-07-15 04:58:35 +04:00
( b ) we have a home directory defined
2004-08-27 00:47:58 +04:00
( c ) there s not an existing static share by that name
If a share exists by this name ( autoloaded or not ) reuse it . */
vuser - > homes_snum = - 1 ;
2004-07-15 04:58:35 +04:00
2004-08-27 00:47:58 +04:00
if ( ( ! vuser - > guest ) & & vuser - > unix_homedir & & * ( vuser - > unix_homedir ) )
{
2004-07-15 04:58:35 +04:00
int servicenumber = lp_servicenumber ( vuser - > user . unix_name ) ;
2004-08-27 00:47:58 +04:00
2004-07-15 04:58:35 +04:00
if ( servicenumber = = - 1 ) {
DEBUG ( 3 , ( " Adding homes service for user '%s' using home directory: '%s' \n " ,
2004-01-31 17:44:27 +03:00
vuser - > user . unix_name , vuser - > unix_homedir ) ) ;
2004-01-27 18:28:33 +03:00
vuser - > homes_snum = add_home_service ( vuser - > user . unix_name ,
2004-07-15 04:58:35 +04:00
vuser - > user . unix_name , vuser - > unix_homedir ) ;
2004-08-27 00:47:58 +04:00
} else {
DEBUG ( 3 , ( " Using static (or previously created) service for user '%s'; path = '%s' \n " ,
2004-08-27 01:39:10 +04:00
vuser - > user . unix_name , lp_pathname ( servicenumber ) ) ) ;
2004-07-15 04:58:35 +04:00
vuser - > homes_snum = servicenumber ;
}
2004-08-27 00:47:58 +04:00
}
2002-01-17 11:45:58 +03:00
2004-03-27 10:33:59 +03:00
if ( srv_is_signing_negotiated ( ) & & ! vuser - > guest & & ! srv_signing_started ( ) ) {
2003-07-17 22:55:40 +04:00
/* Try and turn on server signing on the first non-guest sessionsetup. */
2003-07-18 04:53:34 +04:00
srv_set_signing ( vuser - > session_key , response_blob ) ;
2003-07-17 22:55:40 +04:00
}
2004-03-20 01:06:54 +03:00
/* fill in the current_user_info struct */
set_current_user_info ( & vuser - > user ) ;
2003-07-17 22:55:40 +04:00
2000-11-29 01:17:44 +03:00
return vuser - > vuid ;
1999-12-13 16:27:58 +03:00
}
1996-05-04 11:50:46 +04:00
/****************************************************************************
2003-07-17 22:55:40 +04:00
Add a name to the session users list .
1996-05-04 11:50:46 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-07-17 22:55:40 +04:00
2002-08-17 19:27:10 +04:00
void add_session_user ( const char * user )
1996-05-04 11:50:46 +04:00
{
2003-07-17 22:55:40 +04:00
fstring suser ;
struct passwd * passwd ;
2002-09-25 19:19:00 +04:00
2003-07-17 22:55:40 +04:00
if ( ! ( passwd = Get_Pwnam ( user ) ) )
return ;
1996-05-04 11:50:46 +04:00
2003-07-17 22:55:40 +04:00
fstrcpy ( suser , passwd - > pw_name ) ;
1996-05-04 11:50:46 +04:00
2004-04-15 02:35:28 +04:00
if ( ! * suser )
return ;
if ( session_userlist & & in_list ( suser , session_userlist , False ) )
return ;
if ( ! session_userlist | | ( strlen ( suser ) + strlen ( session_userlist ) + 2 > = len_session_userlist ) ) {
char * newlist ;
if ( len_session_userlist > 128 * PSTRING_LEN ) {
DEBUG ( 3 , ( " add_session_user: session userlist already too large. \n " ) ) ;
return ;
}
newlist = Realloc ( session_userlist , len_session_userlist + PSTRING_LEN ) ;
if ( newlist = = NULL ) {
DEBUG ( 1 , ( " Unable to resize session_userlist \n " ) ) ;
return ;
2003-07-17 22:55:40 +04:00
}
2004-04-15 02:35:28 +04:00
if ( ! session_userlist ) {
* newlist = ' \0 ' ;
}
session_userlist = newlist ;
len_session_userlist + = PSTRING_LEN ;
1996-05-04 11:50:46 +04:00
}
2004-04-15 02:35:28 +04:00
safe_strcat ( session_userlist , " " , len_session_userlist - 1 ) ;
safe_strcat ( session_userlist , suser , len_session_userlist - 1 ) ;
1996-05-04 11:50:46 +04:00
}
1999-12-13 16:27:58 +03:00
/****************************************************************************
2003-07-17 22:55:40 +04:00
Check if a username is valid .
1999-12-13 16:27:58 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-07-17 22:55:40 +04:00
2003-02-24 05:35:54 +03:00
BOOL user_ok ( const char * user , int snum , gid_t * groups , size_t n_groups )
1999-12-13 16:27:58 +03:00
{
2001-07-25 00:02:48 +04:00
char * * valid , * * invalid ;
1999-12-13 16:27:58 +03:00
BOOL ret ;
2001-07-25 00:02:48 +04:00
valid = invalid = NULL ;
ret = True ;
1999-12-13 16:27:58 +03:00
2001-07-25 00:02:48 +04:00
if ( lp_invalid_users ( snum ) ) {
2002-07-15 14:35:28 +04:00
str_list_copy ( & invalid , lp_invalid_users ( snum ) ) ;
if ( invalid & & str_list_substitute ( invalid , " %S " , lp_servicename ( snum ) ) ) {
2003-09-26 23:28:20 +04:00
if ( invalid & & str_list_sub_basic ( invalid , current_user_info . smb_name ) ) {
ret = ! user_in_list ( user , ( const char * * ) invalid , groups , n_groups ) ;
}
2001-07-25 00:02:48 +04:00
}
1999-12-13 16:27:58 +03:00
}
2002-11-13 02:20:50 +03:00
if ( invalid )
str_list_free ( & invalid ) ;
2001-07-25 00:02:48 +04:00
if ( ret & & lp_valid_users ( snum ) ) {
2002-07-15 14:35:28 +04:00
str_list_copy ( & valid , lp_valid_users ( snum ) ) ;
2003-09-26 23:28:20 +04:00
if ( valid & & str_list_substitute ( valid , " %S " , lp_servicename ( snum ) ) ) {
if ( valid & & str_list_sub_basic ( valid , current_user_info . smb_name ) ) {
ret = user_in_list ( user , ( const char * * ) valid , groups , n_groups ) ;
}
2001-07-25 00:02:48 +04:00
}
}
2002-11-13 02:20:50 +03:00
if ( valid )
str_list_free ( & valid ) ;
1999-12-13 16:27:58 +03:00
if ( ret & & lp_onlyuser ( snum ) ) {
2002-08-17 19:27:10 +04:00
char * * user_list = str_list_make ( lp_username ( snum ) , NULL ) ;
2002-07-15 14:35:28 +04:00
if ( user_list & & str_list_substitute ( user_list , " %S " , lp_servicename ( snum ) ) ) {
2003-02-24 05:35:54 +03:00
ret = user_in_list ( user , ( const char * * ) user_list , groups , n_groups ) ;
2001-07-25 00:02:48 +04:00
}
2002-07-15 14:35:28 +04:00
if ( user_list ) str_list_free ( & user_list ) ;
1999-12-13 16:27:58 +03:00
}
return ( ret ) ;
}
1996-05-04 11:50:46 +04:00
/****************************************************************************
2003-07-17 22:55:40 +04:00
Validate a group username entry . Return the username or NULL .
1996-05-04 11:50:46 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-07-17 22:55:40 +04:00
2001-10-31 13:46:25 +03:00
static char * validate_group ( char * group , DATA_BLOB password , int snum )
1996-05-04 11:50:46 +04:00
{
1999-12-13 16:27:58 +03:00
# ifdef HAVE_NETGROUP
{
char * host , * user , * domain ;
setnetgrent ( group ) ;
while ( getnetgrent ( & host , & user , & domain ) ) {
if ( user ) {
2003-02-24 05:35:54 +03:00
if ( user_ok ( user , snum , NULL , 0 ) & &
2001-10-31 13:46:25 +03:00
password_ok ( user , password ) ) {
1999-12-13 16:27:58 +03:00
endnetgrent ( ) ;
return ( user ) ;
}
}
}
endnetgrent ( ) ;
1996-05-04 11:50:46 +04:00
}
# endif
1999-12-13 16:27:58 +03:00
# ifdef HAVE_GETGRENT
1996-05-04 11:50:46 +04:00
{
1999-12-13 16:27:58 +03:00
struct group * gptr ;
setgrent ( ) ;
while ( ( gptr = ( struct group * ) getgrent ( ) ) ) {
2000-01-04 04:01:27 +03:00
if ( strequal ( gptr - > gr_name , group ) )
break ;
}
/*
* As user_ok can recurse doing a getgrent ( ) , we must
* copy the member list into a pstring on the stack before
* use . Bug pointed out by leon @ eatworms . swmed . edu .
*/
if ( gptr ) {
pstring member_list ;
char * member ;
size_t copied_len = 0 ;
int i ;
* member_list = ' \0 ' ;
member = member_list ;
for ( i = 0 ; gptr - > gr_mem & & gptr - > gr_mem [ i ] ; i + + ) {
size_t member_len = strlen ( gptr - > gr_mem [ i ] ) + 1 ;
if ( copied_len + member_len < sizeof ( pstring ) ) {
DEBUG ( 10 , ( " validate_group: = gr_mem = %s \n " , gptr - > gr_mem [ i ] ) ) ;
safe_strcpy ( member , gptr - > gr_mem [ i ] , sizeof ( pstring ) - copied_len - 1 ) ;
copied_len + = member_len ;
member + = copied_len ;
} else {
* member = ' \0 ' ;
}
}
endgrent ( ) ;
member = member_list ;
while ( * member ) {
1999-12-13 16:27:58 +03:00
static fstring name ;
2000-01-04 04:01:27 +03:00
fstrcpy ( name , member ) ;
2003-02-24 05:35:54 +03:00
if ( user_ok ( name , snum , NULL , 0 ) & &
2001-10-31 13:46:25 +03:00
password_ok ( name , password ) ) {
1999-12-13 16:27:58 +03:00
endgrent ( ) ;
return ( & name [ 0 ] ) ;
}
2000-01-04 04:01:27 +03:00
DEBUG ( 10 , ( " validate_group = member = %s \n " , member ) ) ;
member + = strlen ( member ) + 1 ;
1999-12-13 16:27:58 +03:00
}
2000-01-04 04:01:27 +03:00
} else {
endgrent ( ) ;
return NULL ;
1999-12-13 16:27:58 +03:00
}
1996-05-04 11:50:46 +04:00
}
# endif
1999-12-13 16:27:58 +03:00
return ( NULL ) ;
1996-05-04 11:50:46 +04:00
}
/****************************************************************************
2001-06-22 04:57:59 +04:00
Check for authority to login to a service with a given username / password .
Note this is * NOT * used when logging on using sessionsetup_and_X .
1996-05-04 11:50:46 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-06-22 04:57:59 +04:00
2002-09-25 19:19:00 +04:00
BOOL authorise_login ( int snum , fstring user , DATA_BLOB password ,
2002-07-15 14:35:28 +04:00
BOOL * guest )
1996-05-04 11:50:46 +04:00
{
2001-06-22 04:57:59 +04:00
BOOL ok = False ;
2002-07-15 14:35:28 +04:00
2004-10-11 04:32:31 +04:00
# ifdef DEBUG_PASSWORD
2002-07-15 14:35:28 +04:00
DEBUG ( 100 , ( " authorise_login: checking authorisation on user=%s pass=%s \n " ,
user , password . data ) ) ;
1996-05-04 11:50:46 +04:00
# endif
2001-06-22 04:57:59 +04:00
* guest = False ;
/* there are several possibilities:
1 ) login as the given user with given password
2 ) login as a previously registered username with the given password
3 ) login as a session list username with the given password
4 ) login as a previously validated user / password pair
5 ) login as the " user = " user with given password
6 ) login as the " user = " user with no password ( guest connection )
7 ) login as guest user with no password
if the service is guest_only then steps 1 to 5 are skipped
*/
2002-07-15 14:35:28 +04:00
/* now check the list of session users */
if ( ! ok ) {
char * auser ;
2004-05-05 06:58:43 +04:00
char * user_list = NULL ;
if ( session_userlist )
user_list = strdup ( session_userlist ) ;
2004-05-06 19:29:02 +04:00
else
user_list = strdup ( " " ) ;
2004-05-05 06:58:43 +04:00
2002-07-15 14:35:28 +04:00
if ( ! user_list )
return ( False ) ;
for ( auser = strtok ( user_list , LIST_SEP ) ; ! ok & & auser ;
auser = strtok ( NULL , LIST_SEP ) ) {
fstring user2 ;
fstrcpy ( user2 , auser ) ;
2003-02-24 05:35:54 +03:00
if ( ! user_ok ( user2 , snum , NULL , 0 ) )
2002-07-15 14:35:28 +04:00
continue ;
if ( password_ok ( user2 , password ) ) {
2001-06-22 04:57:59 +04:00
ok = True ;
2002-07-15 14:35:28 +04:00
fstrcpy ( user , user2 ) ;
DEBUG ( 3 , ( " authorise_login: ACCEPTED: session list username (%s) \
and given password ok \ n " , user));
2001-06-22 04:57:59 +04:00
}
}
2002-07-15 14:35:28 +04:00
SAFE_FREE ( user_list ) ;
}
/* check the user= fields and the given password */
if ( ! ok & & lp_username ( snum ) ) {
char * auser ;
pstring user_list ;
2003-04-23 17:27:35 +04:00
pstrcpy ( user_list , lp_username ( snum ) ) ;
2002-07-15 14:35:28 +04:00
pstring_sub ( user_list , " %S " , lp_servicename ( snum ) ) ;
for ( auser = strtok ( user_list , LIST_SEP ) ; auser & & ! ok ;
auser = strtok ( NULL , LIST_SEP ) ) {
if ( * auser = = ' @ ' ) {
auser = validate_group ( auser + 1 , password , snum ) ;
if ( auser ) {
ok = True ;
fstrcpy ( user , auser ) ;
DEBUG ( 3 , ( " authorise_login: ACCEPTED: group username \
and given password ok ( % s ) \ n " , user)) ;
}
} else {
2001-06-22 04:57:59 +04:00
fstring user2 ;
fstrcpy ( user2 , auser ) ;
2003-02-24 05:35:54 +03:00
if ( user_ok ( user2 , snum , NULL , 0 ) & & password_ok ( user2 , password ) ) {
2001-06-22 04:57:59 +04:00
ok = True ;
fstrcpy ( user , user2 ) ;
2002-07-15 14:35:28 +04:00
DEBUG ( 3 , ( " authorise_login: ACCEPTED: user list username \
2001-06-22 04:57:59 +04:00
and given password ok ( % s ) \ n " , user)) ;
}
}
}
2002-07-15 14:35:28 +04:00
}
2001-06-22 04:57:59 +04:00
/* check for a normal guest connection */
if ( ! ok & & GUEST_OK ( snum ) ) {
fstring guestname ;
2003-04-23 17:27:35 +04:00
fstrcpy ( guestname , lp_guestaccount ( ) ) ;
2001-10-29 10:28:32 +03:00
if ( Get_Pwnam ( guestname ) ) {
2001-06-22 04:57:59 +04:00
fstrcpy ( user , guestname ) ;
ok = True ;
DEBUG ( 3 , ( " authorise_login: ACCEPTED: guest account and guest ok (%s) \n " ,
user ) ) ;
} else {
DEBUG ( 0 , ( " authorise_login: Invalid guest account %s?? \n " , guestname ) ) ;
}
* guest = True ;
1996-05-04 11:50:46 +04:00
}
2003-02-24 05:35:54 +03:00
if ( ok & & ! user_ok ( user , snum , NULL , 0 ) ) {
2001-06-22 04:57:59 +04:00
DEBUG ( 0 , ( " authorise_login: rejected invalid user %s \n " , user ) ) ;
ok = False ;
}
1996-05-04 11:50:46 +04:00
2001-06-22 04:57:59 +04:00
return ( ok ) ;
1996-05-04 11:50:46 +04:00
}