1998-08-17 11:15:54 +04:00
/*
2002-01-30 09:08:46 +03:00
Unix SMB / CIFS implementation .
1998-08-17 11:15:54 +04:00
negprot reply code
Copyright ( C ) Andrew Tridgell 1992 - 1998
2007-08-02 22:28:41 +04:00
Copyright ( C ) Volker Lendecke 2007
1998-08-17 11:15:54 +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
1998-08-17 11:15:54 +04:00
( 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
2007-07-10 04:52:41 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
1998-08-17 11:15:54 +04:00
*/
# include "includes.h"
2005-04-06 20:28:04 +04:00
extern fstring remote_proto ;
2004-11-25 03:07:01 +03:00
extern enum protocol_types Protocol ;
1998-08-17 11:15:54 +04:00
extern int max_recv ;
2005-11-05 07:21:55 +03:00
2007-10-19 04:40:25 +04:00
bool global_encrypted_passwords_negotiated = False ;
bool global_spnego_negotiated = False ;
2002-01-05 07:55:41 +03:00
struct auth_context * negprot_global_auth_context = NULL ;
2007-07-23 15:18:20 +04:00
static void get_challenge ( uint8 buff [ 8 ] )
2002-01-05 07:55:41 +03:00
{
NTSTATUS nt_status ;
const uint8 * cryptkey ;
2006-09-21 04:30:47 +04:00
/* We might be called more than once, multiple negprots are
* permitted */
2002-01-05 07:55:41 +03:00
if ( negprot_global_auth_context ) {
2002-01-21 01:50:23 +03:00
DEBUG ( 3 , ( " get challenge: is this a secondary negprot? negprot_global_auth_context is non-NULL! \n " ) ) ;
2002-01-09 10:52:51 +03:00
( negprot_global_auth_context - > free ) ( & negprot_global_auth_context ) ;
2002-01-05 07:55:41 +03:00
}
2002-01-21 01:50:23 +03:00
DEBUG ( 10 , ( " get challenge: creating negprot_global_auth_context \n " ) ) ;
2002-01-05 07:55:41 +03:00
if ( ! NT_STATUS_IS_OK ( nt_status = make_auth_context_subsystem ( & negprot_global_auth_context ) ) ) {
2002-03-17 07:36:35 +03:00
DEBUG ( 0 , ( " make_auth_context_subsystem returned %s " , nt_errstr ( nt_status ) ) ) ;
2007-06-16 01:58:49 +04:00
smb_panic ( " cannot make_negprot_global_auth_context! " ) ;
2002-01-05 07:55:41 +03:00
}
2002-01-21 01:50:23 +03:00
DEBUG ( 10 , ( " get challenge: getting challenge \n " ) ) ;
2002-01-05 07:55:41 +03:00
cryptkey = negprot_global_auth_context - > get_ntlm_challenge ( negprot_global_auth_context ) ;
memcpy ( buff , cryptkey , 8 ) ;
}
1998-08-17 11:15:54 +04:00
/****************************************************************************
2002-07-15 14:35:28 +04:00
Reply for the core protocol .
1998-08-17 11:15:54 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-07-15 14:35:28 +04:00
2007-07-23 15:18:20 +04:00
static void reply_corep ( struct smb_request * req , uint16 choice )
1998-08-17 11:15:54 +04:00
{
2007-07-23 15:18:20 +04:00
reply_outbuf ( req , 1 , 0 ) ;
SSVAL ( req - > outbuf , smb_vwv0 , choice ) ;
1998-08-17 11:15:54 +04:00
Protocol = PROTOCOL_CORE ;
}
/****************************************************************************
2002-07-15 14:35:28 +04:00
Reply for the coreplus protocol .
1998-08-17 11:15:54 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-07-15 14:35:28 +04:00
2007-07-23 15:18:20 +04:00
static void reply_coreplus ( struct smb_request * req , uint16 choice )
1998-08-17 11:15:54 +04:00
{
2002-07-15 14:35:28 +04:00
int raw = ( lp_readraw ( ) ? 1 : 0 ) | ( lp_writeraw ( ) ? 2 : 0 ) ;
2007-07-23 15:18:20 +04:00
reply_outbuf ( req , 13 , 0 ) ;
SSVAL ( req - > outbuf , smb_vwv0 , choice ) ;
SSVAL ( req - > outbuf , smb_vwv5 , raw ) ; /* tell redirector we support
2002-07-15 14:35:28 +04:00
readbraw and writebraw ( possibly ) */
/* Reply, SMBlockread, SMBwritelock supported. */
2007-07-23 15:18:20 +04:00
SCVAL ( req - > outbuf , smb_flg , FLAG_REPLY | FLAG_SUPPORT_LOCKREAD ) ;
SSVAL ( req - > outbuf , smb_vwv1 , 0x1 ) ; /* user level security, don't
* encrypt */
2002-07-15 14:35:28 +04:00
Protocol = PROTOCOL_COREPLUS ;
1998-08-17 11:15:54 +04:00
}
/****************************************************************************
2002-07-15 14:35:28 +04:00
Reply for the lanman 1.0 protocol .
1998-08-17 11:15:54 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-07-15 14:35:28 +04:00
2007-07-23 15:18:20 +04:00
static void reply_lanman1 ( struct smb_request * req , uint16 choice )
1998-08-17 11:15:54 +04:00
{
2002-07-15 14:35:28 +04:00
int raw = ( lp_readraw ( ) ? 1 : 0 ) | ( lp_writeraw ( ) ? 2 : 0 ) ;
int secword = 0 ;
time_t t = time ( NULL ) ;
1998-08-17 11:15:54 +04:00
2002-07-15 14:35:28 +04:00
global_encrypted_passwords_negotiated = lp_encrypted_passwords ( ) ;
2001-09-26 17:55:59 +04:00
2002-07-15 14:35:28 +04:00
if ( lp_security ( ) > = SEC_USER )
secword | = NEGOTIATE_SECURITY_USER_LEVEL ;
if ( global_encrypted_passwords_negotiated )
secword | = NEGOTIATE_SECURITY_CHALLENGE_RESPONSE ;
1998-08-17 11:15:54 +04:00
2007-07-23 15:18:20 +04:00
reply_outbuf ( req , 13 , global_encrypted_passwords_negotiated ? 8 : 0 ) ;
SSVAL ( req - > outbuf , smb_vwv0 , choice ) ;
SSVAL ( req - > outbuf , smb_vwv1 , secword ) ;
2002-07-15 14:35:28 +04:00
/* Create a token value and add it to the outgoing packet. */
if ( global_encrypted_passwords_negotiated ) {
2007-07-23 15:18:20 +04:00
get_challenge ( ( uint8 * ) smb_buf ( req - > outbuf ) ) ;
SSVAL ( req - > outbuf , smb_vwv11 , 8 ) ;
2002-07-15 14:35:28 +04:00
}
1998-08-17 11:15:54 +04:00
2002-07-15 14:35:28 +04:00
Protocol = PROTOCOL_LANMAN1 ;
1998-08-17 11:15:54 +04:00
2002-07-15 14:35:28 +04:00
/* Reply, SMBlockread, SMBwritelock supported. */
2007-07-23 15:18:20 +04:00
SCVAL ( req - > outbuf , smb_flg , FLAG_REPLY | FLAG_SUPPORT_LOCKREAD ) ;
SSVAL ( req - > outbuf , smb_vwv2 , max_recv ) ;
SSVAL ( req - > outbuf , smb_vwv3 , lp_maxmux ( ) ) ; /* maxmux */
SSVAL ( req - > outbuf , smb_vwv4 , 1 ) ;
SSVAL ( req - > outbuf , smb_vwv5 , raw ) ; /* tell redirector we support
2002-07-15 14:35:28 +04:00
readbraw writebraw ( possibly ) */
2007-07-23 15:18:20 +04:00
SIVAL ( req - > outbuf , smb_vwv6 , sys_getpid ( ) ) ;
SSVAL ( req - > outbuf , smb_vwv10 , set_server_zone_offset ( t ) / 60 ) ;
1998-08-17 11:15:54 +04:00
2007-07-23 15:18:20 +04:00
srv_put_dos_date ( ( char * ) req - > outbuf , smb_vwv8 , t ) ;
1998-08-17 11:15:54 +04:00
2007-07-23 15:18:20 +04:00
return ;
1998-08-17 11:15:54 +04:00
}
/****************************************************************************
2002-07-15 14:35:28 +04:00
Reply for the lanman 2.0 protocol .
1998-08-17 11:15:54 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-07-15 14:35:28 +04:00
2007-07-23 15:18:20 +04:00
static void reply_lanman2 ( struct smb_request * req , uint16 choice )
1998-08-17 11:15:54 +04:00
{
2002-07-15 14:35:28 +04:00
int raw = ( lp_readraw ( ) ? 1 : 0 ) | ( lp_writeraw ( ) ? 2 : 0 ) ;
int secword = 0 ;
time_t t = time ( NULL ) ;
1998-08-17 11:15:54 +04:00
2002-07-15 14:35:28 +04:00
global_encrypted_passwords_negotiated = lp_encrypted_passwords ( ) ;
This is another rather major change to the samba authenticaion
subystem.
The particular aim is to modularized the interface - so that we
can have arbitrary password back-ends.
This code adds one such back-end, a 'winbind' module to authenticate
against the winbind_auth_crap functionality. While fully-functional
this code is mainly useful as a demonstration, because we don't get
back the info3 as we would for direct ntdomain authentication.
This commit introduced the new 'auth methods' parameter, in the
spirit of the 'auth order' discussed on the lists. It is renamed
because not all the methods may be consulted, even if previous
methods fail - they may not have a suitable challenge for example.
Also, we have a 'local' authentication method, for old-style
'unix if plaintext, sam if encrypted' authentication and a
'guest' module to handle guest logins in a single place.
While this current design is not ideal, I feel that it does
provide a better infrastructure than the current design, and can
be built upon.
The following parameters have changed:
- use rhosts =
This has been replaced by the 'rhosts' authentication method,
and can be specified like 'auth methods = guest rhosts'
- hosts equiv =
This needs both this parameter and an 'auth methods' entry
to be effective. (auth methods = guest hostsequiv ....)
- plaintext to smbpasswd =
This is replaced by specifying 'sam' rather than 'local'
in the auth methods.
The security = parameter is unchanged, and now provides defaults
for the 'auth methods' parameter.
The available auth methods are:
guest
rhosts
hostsequiv
sam (passdb direct hash access)
unix (PAM, crypt() etc)
local (the combination of the above, based on encryption)
smbserver (old security=server)
ntdomain (old security=domain)
winbind (use winbind to cache DC connections)
Assistance in testing, or the production of new and interesting
authentication modules is always appreciated.
Andrew Bartlett
(This used to be commit 8d31eae52a9757739711dbb82035a4dfe6b40c99)
2001-11-24 15:12:38 +03:00
2002-07-15 14:35:28 +04:00
if ( lp_security ( ) > = SEC_USER )
secword | = NEGOTIATE_SECURITY_USER_LEVEL ;
if ( global_encrypted_passwords_negotiated )
secword | = NEGOTIATE_SECURITY_CHALLENGE_RESPONSE ;
1998-08-17 11:15:54 +04:00
2007-07-23 15:18:20 +04:00
reply_outbuf ( req , 13 , global_encrypted_passwords_negotiated ? 8 : 0 ) ;
SSVAL ( req - > outbuf , smb_vwv0 , choice ) ;
SSVAL ( req - > outbuf , smb_vwv1 , secword ) ;
SIVAL ( req - > outbuf , smb_vwv6 , sys_getpid ( ) ) ;
1998-08-17 11:15:54 +04:00
2002-07-15 14:35:28 +04:00
/* Create a token value and add it to the outgoing packet. */
if ( global_encrypted_passwords_negotiated ) {
2007-07-23 15:18:20 +04:00
get_challenge ( ( uint8 * ) smb_buf ( req - > outbuf ) ) ;
SSVAL ( req - > outbuf , smb_vwv11 , 8 ) ;
2002-07-15 14:35:28 +04:00
}
Protocol = PROTOCOL_LANMAN2 ;
/* Reply, SMBlockread, SMBwritelock supported. */
2007-07-23 15:18:20 +04:00
SCVAL ( req - > outbuf , smb_flg , FLAG_REPLY | FLAG_SUPPORT_LOCKREAD ) ;
SSVAL ( req - > outbuf , smb_vwv2 , max_recv ) ;
SSVAL ( req - > outbuf , smb_vwv3 , lp_maxmux ( ) ) ;
SSVAL ( req - > outbuf , smb_vwv4 , 1 ) ;
SSVAL ( req - > outbuf , smb_vwv5 , raw ) ; /* readbraw and/or writebraw */
SSVAL ( req - > outbuf , smb_vwv10 , set_server_zone_offset ( t ) / 60 ) ;
srv_put_dos_date ( ( char * ) req - > outbuf , smb_vwv8 , t ) ;
2002-07-15 14:35:28 +04:00
}
/****************************************************************************
Generate the spnego negprot reply blob . Return the number of bytes used .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2001-10-17 12:54:19 +04:00
2006-09-21 09:29:07 +04:00
static DATA_BLOB negprot_spnego ( void )
2001-10-17 12:54:19 +04:00
{
DATA_BLOB blob ;
2004-03-13 05:16:21 +03:00
nstring dos_name ;
fstring unix_name ;
2006-12-28 02:52:47 +03:00
# ifdef DEVELOPER
size_t slen ;
# endif
2005-10-18 07:24:00 +04:00
char guid [ 17 ] ;
2002-09-25 19:19:00 +04:00
const char * OIDs_krb5 [ ] = { OID_KERBEROS5 ,
2001-11-28 02:41:14 +03:00
OID_KERBEROS5_OLD ,
2002-09-25 19:19:00 +04:00
OID_NTLMSSP ,
2001-11-28 02:41:14 +03:00
NULL } ;
2006-02-23 04:53:26 +03:00
const char * OIDs_plain [ ] = { OID_NTLMSSP , NULL } ;
2001-10-17 12:54:19 +04:00
2001-10-30 16:54:54 +03:00
global_spnego_negotiated = True ;
2006-12-28 02:52:47 +03:00
memset ( guid , ' \0 ' , sizeof ( guid ) ) ;
2004-03-13 05:16:21 +03:00
safe_strcpy ( unix_name , global_myname ( ) , sizeof ( unix_name ) - 1 ) ;
strlower_m ( unix_name ) ;
push_ascii_nstring ( dos_name , unix_name ) ;
2005-10-18 07:24:00 +04:00
safe_strcpy ( guid , dos_name , sizeof ( guid ) - 1 ) ;
2003-05-31 05:48:59 +04:00
2006-12-28 02:52:47 +03:00
# ifdef DEVELOPER
/* Fix valgrind 'uninitialized bytes' issue. */
slen = strlen ( dos_name ) ;
if ( slen < sizeof ( guid ) ) {
memset ( guid + slen , ' \0 ' , sizeof ( guid ) - slen ) ;
}
# endif
2001-11-26 02:05:13 +03:00
/* strangely enough, NT does not sent the single OID NTLMSSP when
2001-11-28 02:41:14 +03:00
not a ADS member , it sends no OIDs at all
2005-10-13 03:08:49 +04:00
OLD COMMENT : " we can't do this until we teach our sesssion setup parser to know
about raw NTLMSSP ( clients send no ASN .1 wrapping if we do this ) "
Our sessionsetup code now handles raw NTLMSSP connects , so we can go
back to doing what W2K3 does here . This is needed to make PocketPC 2003
CIFS connections work with SPNEGO . See bugzilla bugs # 1828 and # 3133
for details . JRA .
2001-11-28 02:41:14 +03:00
*/
2005-10-13 03:08:49 +04:00
if ( lp_security ( ) ! = SEC_ADS & & ! lp_use_kerberos_keytab ( ) ) {
2006-02-23 04:53:26 +03:00
#if 0
/* Code for PocketPC client */
blob = data_blob ( guid , 16 ) ;
# else
/* Code for standalone WXP client */
blob = spnego_gen_negTokenInit ( guid , OIDs_plain , " NONE " ) ;
# endif
2002-02-22 06:14:58 +03:00
} else {
2005-06-08 18:57:37 +04:00
fstring myname ;
char * host_princ_s = NULL ;
name_to_fqdn ( myname , global_myname ( ) ) ;
strlower_m ( myname ) ;
2007-08-25 23:47:57 +04:00
if ( asprintf ( & host_princ_s , " cifs/%s@%s " , myname , lp_realm ( ) )
= = - 1 ) {
return data_blob_null ;
2007-03-27 04:50:53 +04:00
}
2005-06-08 18:57:37 +04:00
blob = spnego_gen_negTokenInit ( guid , OIDs_krb5 , host_princ_s ) ;
SAFE_FREE ( host_princ_s ) ;
2001-11-29 09:21:56 +03:00
}
2006-02-23 04:53:26 +03:00
2006-09-21 09:29:07 +04:00
return blob ;
2001-10-17 12:54:19 +04:00
}
1998-08-17 11:15:54 +04:00
/****************************************************************************
2002-07-15 14:35:28 +04:00
Reply for the nt protocol .
1998-08-17 11:15:54 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-07-15 14:35:28 +04:00
2007-07-23 15:18:20 +04:00
static void reply_nt1 ( struct smb_request * req , uint16 choice )
1998-08-17 11:15:54 +04:00
{
2001-08-27 12:19:43 +04:00
/* dual names + lock_and_read + nt SMBs + remote API calls */
int capabilities = CAP_NT_FIND | CAP_LOCK_AND_READ |
2002-02-28 00:46:53 +03:00
CAP_LEVEL_II_OPLOCKS ;
2001-08-27 12:19:43 +04:00
int secword = 0 ;
char * p , * q ;
2007-10-19 04:40:25 +04:00
bool negotiate_spnego = False ;
2005-11-05 07:21:55 +03:00
time_t t = time ( NULL ) ;
2007-07-23 15:18:20 +04:00
ssize_t ret ;
2001-10-17 12:54:19 +04:00
2001-09-26 17:55:59 +04:00
global_encrypted_passwords_negotiated = lp_encrypted_passwords ( ) ;
2007-02-09 00:48:09 +03:00
/* Check the flags field to see if this is Vista.
WinXP sets it and Vista does not . But we have to
distinguish from NT which doesn ' t set it either . */
2007-07-23 15:18:20 +04:00
if ( ( req - > flags2 & FLAGS2_EXTENDED_SECURITY ) & &
( ( req - > flags2 & FLAGS2_UNKNOWN_BIT4 ) = = 0 ) )
2007-02-09 00:48:09 +03:00
{
2007-03-16 19:21:38 +03:00
if ( get_remote_arch ( ) ! = RA_SAMBA ) {
2007-03-16 19:20:47 +03:00
set_remote_arch ( RA_VISTA ) ;
}
2007-02-09 00:48:09 +03:00
}
2007-07-23 15:18:20 +04:00
reply_outbuf ( req , 17 , 0 ) ;
This is another rather major change to the samba authenticaion
subystem.
The particular aim is to modularized the interface - so that we
can have arbitrary password back-ends.
This code adds one such back-end, a 'winbind' module to authenticate
against the winbind_auth_crap functionality. While fully-functional
this code is mainly useful as a demonstration, because we don't get
back the info3 as we would for direct ntdomain authentication.
This commit introduced the new 'auth methods' parameter, in the
spirit of the 'auth order' discussed on the lists. It is renamed
because not all the methods may be consulted, even if previous
methods fail - they may not have a suitable challenge for example.
Also, we have a 'local' authentication method, for old-style
'unix if plaintext, sam if encrypted' authentication and a
'guest' module to handle guest logins in a single place.
While this current design is not ideal, I feel that it does
provide a better infrastructure than the current design, and can
be built upon.
The following parameters have changed:
- use rhosts =
This has been replaced by the 'rhosts' authentication method,
and can be specified like 'auth methods = guest rhosts'
- hosts equiv =
This needs both this parameter and an 'auth methods' entry
to be effective. (auth methods = guest hostsequiv ....)
- plaintext to smbpasswd =
This is replaced by specifying 'sam' rather than 'local'
in the auth methods.
The security = parameter is unchanged, and now provides defaults
for the 'auth methods' parameter.
The available auth methods are:
guest
rhosts
hostsequiv
sam (passdb direct hash access)
unix (PAM, crypt() etc)
local (the combination of the above, based on encryption)
smbserver (old security=server)
ntdomain (old security=domain)
winbind (use winbind to cache DC connections)
Assistance in testing, or the production of new and interesting
authentication modules is always appreciated.
Andrew Bartlett
(This used to be commit 8d31eae52a9757739711dbb82035a4dfe6b40c99)
2001-11-24 15:12:38 +03:00
/* do spnego in user level security if the client
supports it and we can do encrypted passwords */
2001-08-27 12:19:43 +04:00
This is another rather major change to the samba authenticaion
subystem.
The particular aim is to modularized the interface - so that we
can have arbitrary password back-ends.
This code adds one such back-end, a 'winbind' module to authenticate
against the winbind_auth_crap functionality. While fully-functional
this code is mainly useful as a demonstration, because we don't get
back the info3 as we would for direct ntdomain authentication.
This commit introduced the new 'auth methods' parameter, in the
spirit of the 'auth order' discussed on the lists. It is renamed
because not all the methods may be consulted, even if previous
methods fail - they may not have a suitable challenge for example.
Also, we have a 'local' authentication method, for old-style
'unix if plaintext, sam if encrypted' authentication and a
'guest' module to handle guest logins in a single place.
While this current design is not ideal, I feel that it does
provide a better infrastructure than the current design, and can
be built upon.
The following parameters have changed:
- use rhosts =
This has been replaced by the 'rhosts' authentication method,
and can be specified like 'auth methods = guest rhosts'
- hosts equiv =
This needs both this parameter and an 'auth methods' entry
to be effective. (auth methods = guest hostsequiv ....)
- plaintext to smbpasswd =
This is replaced by specifying 'sam' rather than 'local'
in the auth methods.
The security = parameter is unchanged, and now provides defaults
for the 'auth methods' parameter.
The available auth methods are:
guest
rhosts
hostsequiv
sam (passdb direct hash access)
unix (PAM, crypt() etc)
local (the combination of the above, based on encryption)
smbserver (old security=server)
ntdomain (old security=domain)
winbind (use winbind to cache DC connections)
Assistance in testing, or the production of new and interesting
authentication modules is always appreciated.
Andrew Bartlett
(This used to be commit 8d31eae52a9757739711dbb82035a4dfe6b40c99)
2001-11-24 15:12:38 +03:00
if ( global_encrypted_passwords_negotiated & &
( lp_security ( ) ! = SEC_SHARE ) & &
2001-12-07 04:01:10 +03:00
lp_use_spnego ( ) & &
2007-07-23 15:18:20 +04:00
( req - > flags2 & FLAGS2_EXTENDED_SECURITY ) ) {
This is another rather major change to the samba authenticaion
subystem.
The particular aim is to modularized the interface - so that we
can have arbitrary password back-ends.
This code adds one such back-end, a 'winbind' module to authenticate
against the winbind_auth_crap functionality. While fully-functional
this code is mainly useful as a demonstration, because we don't get
back the info3 as we would for direct ntdomain authentication.
This commit introduced the new 'auth methods' parameter, in the
spirit of the 'auth order' discussed on the lists. It is renamed
because not all the methods may be consulted, even if previous
methods fail - they may not have a suitable challenge for example.
Also, we have a 'local' authentication method, for old-style
'unix if plaintext, sam if encrypted' authentication and a
'guest' module to handle guest logins in a single place.
While this current design is not ideal, I feel that it does
provide a better infrastructure than the current design, and can
be built upon.
The following parameters have changed:
- use rhosts =
This has been replaced by the 'rhosts' authentication method,
and can be specified like 'auth methods = guest rhosts'
- hosts equiv =
This needs both this parameter and an 'auth methods' entry
to be effective. (auth methods = guest hostsequiv ....)
- plaintext to smbpasswd =
This is replaced by specifying 'sam' rather than 'local'
in the auth methods.
The security = parameter is unchanged, and now provides defaults
for the 'auth methods' parameter.
The available auth methods are:
guest
rhosts
hostsequiv
sam (passdb direct hash access)
unix (PAM, crypt() etc)
local (the combination of the above, based on encryption)
smbserver (old security=server)
ntdomain (old security=domain)
winbind (use winbind to cache DC connections)
Assistance in testing, or the production of new and interesting
authentication modules is always appreciated.
Andrew Bartlett
(This used to be commit 8d31eae52a9757739711dbb82035a4dfe6b40c99)
2001-11-24 15:12:38 +03:00
negotiate_spnego = True ;
capabilities | = CAP_EXTENDED_SECURITY ;
2004-08-20 00:03:41 +04:00
add_to_common_flags2 ( FLAGS2_EXTENDED_SECURITY ) ;
2007-07-23 15:18:20 +04:00
/* Ensure FLAGS2_EXTENDED_SECURITY gets set in this reply
( already partially constructed . */
SSVAL ( req - > outbuf , smb_flg2 ,
req - > flags2 | FLAGS2_EXTENDED_SECURITY ) ;
2001-08-27 12:19:43 +04:00
}
2004-03-27 08:38:20 +03:00
capabilities | = CAP_NT_SMBS | CAP_RPC_REMOTE_APIS | CAP_UNICODE ;
2002-09-25 19:19:00 +04:00
if ( lp_unix_extensions ( ) ) {
capabilities | = CAP_UNIX ;
}
2001-08-27 12:19:43 +04:00
2002-02-28 00:46:53 +03:00
if ( lp_large_readwrite ( ) & & ( SMB_OFF_T_BITS = = 64 ) )
2001-08-27 12:19:43 +04:00
capabilities | = CAP_LARGE_READX | CAP_LARGE_WRITEX | CAP_W2K_SMBS ;
2002-02-28 00:46:53 +03:00
if ( SMB_OFF_T_BITS = = 64 )
2001-08-27 12:19:43 +04:00
capabilities | = CAP_LARGE_FILES ;
2002-02-28 00:46:53 +03:00
if ( lp_readraw ( ) & & lp_writeraw ( ) )
2001-08-27 12:19:43 +04:00
capabilities | = CAP_RAW_MODE ;
2002-02-28 00:46:53 +03:00
if ( lp_nt_status_support ( ) )
capabilities | = CAP_STATUS32 ;
2001-08-27 12:19:43 +04:00
2001-09-12 07:08:51 +04:00
if ( lp_host_msdfs ( ) )
2001-08-27 12:19:43 +04:00
capabilities | = CAP_DFS ;
2002-02-28 00:46:53 +03:00
if ( lp_security ( ) > = SEC_USER )
2002-07-15 14:35:28 +04:00
secword | = NEGOTIATE_SECURITY_USER_LEVEL ;
2002-02-28 00:46:53 +03:00
if ( global_encrypted_passwords_negotiated )
2002-07-15 14:35:28 +04:00
secword | = NEGOTIATE_SECURITY_CHALLENGE_RESPONSE ;
2001-08-27 12:19:43 +04:00
2003-07-17 04:48:21 +04:00
if ( lp_server_signing ( ) ) {
2003-07-18 04:53:34 +04:00
if ( lp_security ( ) > = SEC_USER ) {
secword | = NEGOTIATE_SECURITY_SIGNATURES_ENABLED ;
/* No raw mode with smb signing. */
capabilities & = ~ CAP_RAW_MODE ;
if ( lp_server_signing ( ) = = Required )
secword | = NEGOTIATE_SECURITY_SIGNATURES_REQUIRED ;
srv_set_signing_negotiated ( ) ;
} else {
DEBUG ( 0 , ( " reply_nt1: smb signing is incompatible with share level security ! \n " ) ) ;
if ( lp_server_signing ( ) = = Required ) {
2006-12-18 07:25:21 +03:00
exit_server_cleanly ( " reply_nt1: smb signing required and share level security selected. " ) ;
2003-07-18 04:53:34 +04:00
}
}
2003-07-17 04:48:21 +04:00
}
2007-07-23 15:18:20 +04:00
SSVAL ( req - > outbuf , smb_vwv0 , choice ) ;
SCVAL ( req - > outbuf , smb_vwv1 , secword ) ;
2001-08-27 12:19:43 +04:00
Protocol = PROTOCOL_NT1 ;
2007-07-23 15:18:20 +04:00
SSVAL ( req - > outbuf , smb_vwv1 + 1 , lp_maxmux ( ) ) ; /* maxmpx */
SSVAL ( req - > outbuf , smb_vwv2 + 1 , 1 ) ; /* num vcs */
SIVAL ( req - > outbuf , smb_vwv3 + 1 , max_recv ) ; /* max buffer. LOTS! */
SIVAL ( req - > outbuf , smb_vwv5 + 1 , 0x10000 ) ; /* raw size. full 64k */
SIVAL ( req - > outbuf , smb_vwv7 + 1 , sys_getpid ( ) ) ; /* session key */
SIVAL ( req - > outbuf , smb_vwv9 + 1 , capabilities ) ; /* capabilities */
put_long_date ( ( char * ) req - > outbuf + smb_vwv11 + 1 , t ) ;
SSVALS ( req - > outbuf , smb_vwv15 + 1 , set_server_zone_offset ( t ) / 60 ) ;
2001-08-27 12:19:43 +04:00
2007-07-23 15:18:20 +04:00
p = q = smb_buf ( req - > outbuf ) ;
2001-10-17 12:54:19 +04:00
if ( ! negotiate_spnego ) {
2002-01-05 07:55:41 +03:00
/* Create a token value and add it to the outgoing packet. */
if ( global_encrypted_passwords_negotiated ) {
2007-07-23 15:18:20 +04:00
uint8 chal [ 8 ] ;
2002-08-17 19:27:10 +04:00
/* note that we do not send a challenge at all if
we are using plaintext */
2007-07-23 15:18:20 +04:00
get_challenge ( chal ) ;
ret = message_push_blob (
& req - > outbuf , data_blob_const ( chal , sizeof ( chal ) ) ) ;
if ( ret = = - 1 ) {
DEBUG ( 0 , ( " Could not push challenge \n " ) ) ;
reply_nterror ( req , NT_STATUS_NO_MEMORY ) ;
return ;
}
SCVAL ( req - > outbuf , smb_vwv16 + 1 , ret ) ;
p + = ret ;
}
ret = message_push_string ( & req - > outbuf , lp_workgroup ( ) ,
STR_UNICODE | STR_TERMINATE
| STR_NOALIGN ) ;
if ( ret = = - 1 ) {
DEBUG ( 0 , ( " Could not push challenge \n " ) ) ;
reply_nterror ( req , NT_STATUS_NO_MEMORY ) ;
return ;
This is another rather major change to the samba authenticaion
subystem.
The particular aim is to modularized the interface - so that we
can have arbitrary password back-ends.
This code adds one such back-end, a 'winbind' module to authenticate
against the winbind_auth_crap functionality. While fully-functional
this code is mainly useful as a demonstration, because we don't get
back the info3 as we would for direct ntdomain authentication.
This commit introduced the new 'auth methods' parameter, in the
spirit of the 'auth order' discussed on the lists. It is renamed
because not all the methods may be consulted, even if previous
methods fail - they may not have a suitable challenge for example.
Also, we have a 'local' authentication method, for old-style
'unix if plaintext, sam if encrypted' authentication and a
'guest' module to handle guest logins in a single place.
While this current design is not ideal, I feel that it does
provide a better infrastructure than the current design, and can
be built upon.
The following parameters have changed:
- use rhosts =
This has been replaced by the 'rhosts' authentication method,
and can be specified like 'auth methods = guest rhosts'
- hosts equiv =
This needs both this parameter and an 'auth methods' entry
to be effective. (auth methods = guest hostsequiv ....)
- plaintext to smbpasswd =
This is replaced by specifying 'sam' rather than 'local'
in the auth methods.
The security = parameter is unchanged, and now provides defaults
for the 'auth methods' parameter.
The available auth methods are:
guest
rhosts
hostsequiv
sam (passdb direct hash access)
unix (PAM, crypt() etc)
local (the combination of the above, based on encryption)
smbserver (old security=server)
ntdomain (old security=domain)
winbind (use winbind to cache DC connections)
Assistance in testing, or the production of new and interesting
authentication modules is always appreciated.
Andrew Bartlett
(This used to be commit 8d31eae52a9757739711dbb82035a4dfe6b40c99)
2001-11-24 15:12:38 +03:00
}
2001-10-31 09:24:25 +03:00
DEBUG ( 3 , ( " not using SPNEGO \n " ) ) ;
2001-10-17 12:54:19 +04:00
} else {
2006-09-21 09:29:07 +04:00
DATA_BLOB spnego_blob = negprot_spnego ( ) ;
if ( spnego_blob . data = = NULL ) {
2007-07-23 15:18:20 +04:00
reply_nterror ( req , NT_STATUS_NO_MEMORY ) ;
return ;
2006-09-21 09:29:07 +04:00
}
2007-07-23 15:18:20 +04:00
ret = message_push_blob ( & req - > outbuf , spnego_blob ) ;
if ( ret = = - 1 ) {
DEBUG ( 0 , ( " Could not push spnego blob \n " ) ) ;
reply_nterror ( req , NT_STATUS_NO_MEMORY ) ;
return ;
}
p + = ret ;
2006-09-21 09:29:07 +04:00
data_blob_free ( & spnego_blob ) ;
2007-07-23 15:18:20 +04:00
SCVAL ( req - > outbuf , smb_vwv16 + 1 , 0 ) ;
2001-10-31 09:24:25 +03:00
DEBUG ( 3 , ( " using SPNEGO \n " ) ) ;
2001-10-17 12:54:19 +04:00
}
2001-08-27 12:19:43 +04:00
2007-07-23 15:18:20 +04:00
SSVAL ( req - > outbuf , smb_vwv17 , p - q ) ; /* length of challenge+domain
* strings */
return ;
1998-08-17 11:15:54 +04:00
}
/* these are the protocol lists used for auto architecture detection:
WinNT 3.51 :
protocol [ PC NETWORK PROGRAM 1.0 ]
protocol [ XENIX CORE ]
protocol [ MICROSOFT NETWORKS 1.03 ]
protocol [ LANMAN1 .0 ]
protocol [ Windows for Workgroups 3.1 a ]
protocol [ LM1 .2 X002 ]
protocol [ LANMAN2 .1 ]
protocol [ NT LM 0.12 ]
Win95 :
protocol [ PC NETWORK PROGRAM 1.0 ]
protocol [ XENIX CORE ]
protocol [ MICROSOFT NETWORKS 1.03 ]
protocol [ LANMAN1 .0 ]
protocol [ Windows for Workgroups 3.1 a ]
protocol [ LM1 .2 X002 ]
protocol [ LANMAN2 .1 ]
protocol [ NT LM 0.12 ]
1999-12-13 16:27:58 +03:00
Win2K :
protocol [ PC NETWORK PROGRAM 1.0 ]
protocol [ LANMAN1 .0 ]
protocol [ Windows for Workgroups 3.1 a ]
protocol [ LM1 .2 X002 ]
protocol [ LANMAN2 .1 ]
protocol [ NT LM 0.12 ]
2007-02-09 00:48:09 +03:00
Vista :
protocol [ PC NETWORK PROGRAM 1.0 ]
protocol [ LANMAN1 .0 ]
protocol [ Windows for Workgroups 3.1 a ]
protocol [ LM1 .2 X002 ]
protocol [ LANMAN2 .1 ]
protocol [ NT LM 0.12 ]
protocol [ SMB 2.001 ]
1998-08-17 11:15:54 +04:00
OS / 2 :
protocol [ PC NETWORK PROGRAM 1.0 ]
protocol [ XENIX CORE ]
protocol [ LANMAN1 .0 ]
protocol [ LM1 .2 X002 ]
protocol [ LANMAN2 .1 ]
*/
/*
* Modified to recognize the architecture of the remote machine better .
*
* This appears to be the matrix of which protocol is used by which
* MS product .
2007-02-09 00:48:09 +03:00
Protocol WfWg Win95 WinNT Win2K OS / 2 Vista
PC NETWORK PROGRAM 1.0 1 1 1 1 1 1
1999-12-13 16:27:58 +03:00
XENIX CORE 2 2
1998-08-17 11:15:54 +04:00
MICROSOFT NETWORKS 3.0 2 2
DOS LM1 .2 X002 3 3
MICROSOFT NETWORKS 1.03 3
DOS LANMAN2 .1 4 4
2007-02-09 00:48:09 +03:00
LANMAN1 .0 4 2 3 2
Windows for Workgroups 3.1 a 5 5 5 3 3
LM1 .2 X002 6 4 4 4
LANMAN2 .1 7 5 5 5
NT LM 0.12 6 8 6 6
SMB 2.001 7
1998-08-17 11:15:54 +04:00
*
* tim @ fsg . com 09 / 29 / 95
1999-12-13 16:27:58 +03:00
* Win2K added by matty 17 / 7 / 99
1998-08-17 11:15:54 +04:00
*/
# define ARCH_WFWG 0x3 /* This is a fudge because WfWg is like Win95 */
# define ARCH_WIN95 0x2
1999-12-13 16:27:58 +03:00
# define ARCH_WINNT 0x4
# define ARCH_WIN2K 0xC /* Win2K is like NT */
# define ARCH_OS2 0x14 /* Again OS/2 is like NT */
# define ARCH_SAMBA 0x20
2004-06-15 22:36:45 +04:00
# define ARCH_CIFSFS 0x40
2007-02-09 00:48:09 +03:00
# define ARCH_VISTA 0x8C /* Vista is like XP/2K */
1998-08-17 11:15:54 +04:00
2004-06-15 22:36:45 +04:00
# define ARCH_ALL 0x7F
1998-08-17 11:15:54 +04:00
/* List of supported protocols, most desired first */
2003-01-03 11:28:12 +03:00
static const struct {
const char * proto_name ;
const char * short_name ;
2007-07-23 15:18:20 +04:00
void ( * proto_reply_fn ) ( struct smb_request * req , uint16 choice ) ;
2002-07-15 14:35:28 +04:00
int protocol_level ;
1998-08-17 11:15:54 +04:00
} supported_protocols [ ] = {
2002-07-15 14:35:28 +04:00
{ " NT LANMAN 1.0 " , " NT1 " , reply_nt1 , PROTOCOL_NT1 } ,
{ " NT LM 0.12 " , " NT1 " , reply_nt1 , PROTOCOL_NT1 } ,
2004-06-15 22:36:45 +04:00
{ " POSIX 2 " , " NT1 " , reply_nt1 , PROTOCOL_NT1 } ,
2005-03-26 03:44:46 +03:00
{ " LANMAN2.1 " , " LANMAN2 " , reply_lanman2 , PROTOCOL_LANMAN2 } ,
2002-07-15 14:35:28 +04:00
{ " LM1.2X002 " , " LANMAN2 " , reply_lanman2 , PROTOCOL_LANMAN2 } ,
{ " Samba " , " LANMAN2 " , reply_lanman2 , PROTOCOL_LANMAN2 } ,
{ " DOS LM1.2X002 " , " LANMAN2 " , reply_lanman2 , PROTOCOL_LANMAN2 } ,
{ " LANMAN1.0 " , " LANMAN1 " , reply_lanman1 , PROTOCOL_LANMAN1 } ,
{ " MICROSOFT NETWORKS 3.0 " , " LANMAN1 " , reply_lanman1 , PROTOCOL_LANMAN1 } ,
{ " MICROSOFT NETWORKS 1.03 " , " COREPLUS " , reply_coreplus , PROTOCOL_COREPLUS } ,
{ " PC NETWORK PROGRAM 1.0 " , " CORE " , reply_corep , PROTOCOL_CORE } ,
{ NULL , NULL , NULL , 0 } ,
1998-08-17 11:15:54 +04:00
} ;
/****************************************************************************
2002-07-15 14:35:28 +04:00
Reply to a negprot .
2006-06-20 06:38:28 +04:00
conn POINTER CAN BE NULL HERE !
1998-08-17 11:15:54 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-07-15 14:35:28 +04:00
2008-01-05 02:37:24 +03:00
void reply_negprot ( struct smb_request * req )
1998-08-17 11:15:54 +04:00
{
2007-07-23 15:18:20 +04:00
size_t size = smb_len ( req - > inbuf ) + 4 ;
2002-07-15 14:35:28 +04:00
int choice = - 1 ;
int protocol ;
char * p ;
2007-07-23 23:46:48 +04:00
int bcc = SVAL ( smb_buf ( req - > inbuf ) , - 2 ) ;
2002-07-15 14:35:28 +04:00
int arch = ARCH_ALL ;
2007-07-23 15:08:43 +04:00
int num_cliprotos ;
char * * cliprotos ;
int i ;
2008-04-30 01:36:24 +04:00
size_t converted_size ;
2002-08-17 19:27:10 +04:00
2007-10-19 04:40:25 +04:00
static bool done_negprot = False ;
2002-08-17 19:27:10 +04:00
2002-07-15 14:35:28 +04:00
START_PROFILE ( SMBnegprot ) ;
2002-08-17 19:27:10 +04:00
if ( done_negprot ) {
END_PROFILE ( SMBnegprot ) ;
2006-12-18 07:25:21 +03:00
exit_server_cleanly ( " multiple negprot's are not permitted " ) ;
2002-08-17 19:27:10 +04:00
}
done_negprot = True ;
2007-07-23 15:18:20 +04:00
if ( req - > inbuf [ size - 1 ] ! = ' \0 ' ) {
2007-07-23 15:08:43 +04:00
DEBUG ( 0 , ( " negprot protocols not 0-terminated \n " ) ) ;
2007-07-23 15:18:20 +04:00
reply_nterror ( req , NT_STATUS_INVALID_PARAMETER ) ;
2007-07-23 15:08:43 +04:00
END_PROFILE ( SMBnegprot ) ;
2007-07-23 15:18:20 +04:00
return ;
2007-07-23 15:08:43 +04:00
}
2007-07-23 23:46:48 +04:00
p = smb_buf ( req - > inbuf ) + 1 ;
2007-07-23 15:08:43 +04:00
num_cliprotos = 0 ;
cliprotos = NULL ;
2007-08-25 23:47:57 +04:00
while ( p < ( smb_buf ( req - > inbuf ) + bcc ) ) {
2007-07-23 18:36:54 +04:00
2007-07-23 23:46:48 +04:00
char * * tmp ;
2007-07-23 18:36:54 +04:00
2007-08-30 23:48:31 +04:00
tmp = TALLOC_REALLOC_ARRAY ( talloc_tos ( ) , cliprotos , char * ,
2007-07-23 15:08:43 +04:00
num_cliprotos + 1 ) ;
if ( tmp = = NULL ) {
DEBUG ( 0 , ( " talloc failed \n " ) ) ;
TALLOC_FREE ( cliprotos ) ;
2007-07-23 15:18:20 +04:00
reply_nterror ( req , NT_STATUS_NO_MEMORY ) ;
2007-07-23 15:08:43 +04:00
END_PROFILE ( SMBnegprot ) ;
2007-07-23 15:18:20 +04:00
return ;
2007-07-23 15:08:43 +04:00
}
cliprotos = tmp ;
2008-04-30 01:36:24 +04:00
if ( ! pull_ascii_talloc ( cliprotos , & cliprotos [ num_cliprotos ] , p ,
& converted_size ) ) {
2007-07-23 15:08:43 +04:00
DEBUG ( 0 , ( " pull_ascii_talloc failed \n " ) ) ;
TALLOC_FREE ( cliprotos ) ;
2007-07-23 15:18:20 +04:00
reply_nterror ( req , NT_STATUS_NO_MEMORY ) ;
2007-07-23 15:08:43 +04:00
END_PROFILE ( SMBnegprot ) ;
2007-07-23 15:18:20 +04:00
return ;
2007-07-23 15:08:43 +04:00
}
DEBUG ( 3 , ( " Requested protocol [%s] \n " ,
cliprotos [ num_cliprotos ] ) ) ;
num_cliprotos + = 1 ;
2007-07-23 23:46:48 +04:00
p + = strlen ( p ) + 2 ;
2007-07-23 15:08:43 +04:00
}
for ( i = 0 ; i < num_cliprotos ; i + + ) {
if ( strcsequal ( cliprotos [ i ] , " Windows for Workgroups 3.1a " ) )
arch & = ( ARCH_WFWG | ARCH_WIN95 | ARCH_WINNT
| ARCH_WIN2K ) ;
else if ( strcsequal ( cliprotos [ i ] , " DOS LM1.2X002 " ) )
2002-07-15 14:35:28 +04:00
arch & = ( ARCH_WFWG | ARCH_WIN95 ) ;
2007-07-23 15:08:43 +04:00
else if ( strcsequal ( cliprotos [ i ] , " DOS LANMAN2.1 " ) )
2002-07-15 14:35:28 +04:00
arch & = ( ARCH_WFWG | ARCH_WIN95 ) ;
2007-07-23 15:08:43 +04:00
else if ( strcsequal ( cliprotos [ i ] , " NT LM 0.12 " ) )
arch & = ( ARCH_WIN95 | ARCH_WINNT | ARCH_WIN2K
| ARCH_CIFSFS ) ;
else if ( strcsequal ( cliprotos [ i ] , " SMB 2.001 " ) )
2007-02-09 00:48:09 +03:00
arch = ARCH_VISTA ;
2007-07-23 15:08:43 +04:00
else if ( strcsequal ( cliprotos [ i ] , " LANMAN2.1 " ) )
2002-07-15 14:35:28 +04:00
arch & = ( ARCH_WINNT | ARCH_WIN2K | ARCH_OS2 ) ;
2007-07-23 15:08:43 +04:00
else if ( strcsequal ( cliprotos [ i ] , " LM1.2X002 " ) )
2002-07-15 14:35:28 +04:00
arch & = ( ARCH_WINNT | ARCH_WIN2K | ARCH_OS2 ) ;
2007-07-23 15:08:43 +04:00
else if ( strcsequal ( cliprotos [ i ] , " MICROSOFT NETWORKS 1.03 " ) )
2002-07-15 14:35:28 +04:00
arch & = ARCH_WINNT ;
2007-07-23 15:08:43 +04:00
else if ( strcsequal ( cliprotos [ i ] , " XENIX CORE " ) )
2002-07-15 14:35:28 +04:00
arch & = ( ARCH_WINNT | ARCH_OS2 ) ;
2007-07-23 15:08:43 +04:00
else if ( strcsequal ( cliprotos [ i ] , " Samba " ) ) {
2002-07-15 14:35:28 +04:00
arch = ARCH_SAMBA ;
break ;
2007-07-23 15:08:43 +04:00
} else if ( strcsequal ( cliprotos [ i ] , " POSIX 2 " ) ) {
2004-06-15 22:36:45 +04:00
arch = ARCH_CIFSFS ;
break ;
2002-07-15 14:35:28 +04:00
}
}
2004-06-15 22:36:45 +04:00
/* CIFSFS can send one arch only, NT LM 0.12. */
2007-07-23 15:08:43 +04:00
if ( i = = 1 & & ( arch & ARCH_CIFSFS ) ) {
2004-06-15 22:36:45 +04:00
arch = ARCH_CIFSFS ;
}
2002-07-15 14:35:28 +04:00
switch ( arch ) {
2004-06-15 22:36:45 +04:00
case ARCH_CIFSFS :
set_remote_arch ( RA_CIFSFS ) ;
break ;
2002-07-15 14:35:28 +04:00
case ARCH_SAMBA :
set_remote_arch ( RA_SAMBA ) ;
break ;
case ARCH_WFWG :
set_remote_arch ( RA_WFWG ) ;
break ;
case ARCH_WIN95 :
set_remote_arch ( RA_WIN95 ) ;
break ;
case ARCH_WINNT :
2007-07-23 15:18:20 +04:00
if ( req - > flags2 = = FLAGS2_WIN2K_SIGNATURE )
2002-07-15 14:35:28 +04:00
set_remote_arch ( RA_WIN2K ) ;
else
set_remote_arch ( RA_WINNT ) ;
break ;
case ARCH_WIN2K :
2007-02-09 00:48:09 +03:00
/* Vista may have been set in the negprot so don't
override it here */
if ( get_remote_arch ( ) ! = RA_VISTA )
set_remote_arch ( RA_WIN2K ) ;
break ;
case ARCH_VISTA :
set_remote_arch ( RA_VISTA ) ;
2002-07-15 14:35:28 +04:00
break ;
case ARCH_OS2 :
set_remote_arch ( RA_OS2 ) ;
break ;
default :
set_remote_arch ( RA_UNKNOWN ) ;
break ;
}
1998-08-17 11:15:54 +04:00
2002-07-15 14:35:28 +04:00
/* possibly reload - change of architecture */
reload_services ( True ) ;
2004-11-30 18:52:46 +03:00
/* moved from the netbios session setup code since we don't have that
when the client connects to port 445. Of course there is a small
window where we are listening to messages - - jerry */
2007-05-27 20:34:49 +04:00
claim_connection (
NULL , " " , FLAG_MSG_GENERAL | FLAG_MSG_SMBD | FLAG_MSG_PRINT_GENERAL ) ;
1998-08-17 11:15:54 +04:00
2002-07-15 14:35:28 +04:00
/* Check for protocols, most desirable first */
for ( protocol = 0 ; supported_protocols [ protocol ] . proto_name ; protocol + + ) {
2007-07-23 15:08:43 +04:00
i = 0 ;
2002-07-15 14:35:28 +04:00
if ( ( supported_protocols [ protocol ] . protocol_level < = lp_maxprotocol ( ) ) & &
( supported_protocols [ protocol ] . protocol_level > = lp_minprotocol ( ) ) )
2007-07-23 15:08:43 +04:00
while ( i < num_cliprotos ) {
if ( strequal ( cliprotos [ i ] , supported_protocols [ protocol ] . proto_name ) )
choice = i ;
i + + ;
2002-07-15 14:35:28 +04:00
}
if ( choice ! = - 1 )
break ;
}
1998-08-17 11:15:54 +04:00
2002-07-15 14:35:28 +04:00
if ( choice ! = - 1 ) {
fstrcpy ( remote_proto , supported_protocols [ protocol ] . short_name ) ;
reload_services ( True ) ;
2007-07-23 15:18:20 +04:00
supported_protocols [ protocol ] . proto_reply_fn ( req , choice ) ;
2002-07-15 14:35:28 +04:00
DEBUG ( 3 , ( " Selected protocol %s \n " , supported_protocols [ protocol ] . proto_name ) ) ;
} else {
DEBUG ( 0 , ( " No protocol supported ! \n " ) ) ;
2007-08-10 14:11:40 +04:00
reply_outbuf ( req , 1 , 0 ) ;
SSVAL ( req - > outbuf , smb_vwv0 , choice ) ;
2002-07-15 14:35:28 +04:00
}
1998-08-17 11:15:54 +04:00
2002-07-15 14:35:28 +04:00
DEBUG ( 5 , ( " negprot index=%d \n " , choice ) ) ;
1998-08-17 11:15:54 +04:00
2003-07-17 04:48:21 +04:00
if ( ( lp_server_signing ( ) = = Required ) & & ( Protocol < PROTOCOL_NT1 ) ) {
2006-12-18 07:25:21 +03:00
exit_server_cleanly ( " SMB signing is required and "
" client negotiated a downlevel protocol " ) ;
2003-07-17 04:48:21 +04:00
}
2007-07-23 15:08:43 +04:00
TALLOC_FREE ( cliprotos ) ;
2002-07-15 14:35:28 +04:00
END_PROFILE ( SMBnegprot ) ;
2007-07-23 15:18:20 +04:00
return ;
1998-08-17 11:15:54 +04:00
}