2003-08-13 05:53:07 +04:00
/*
Unix SMB / CIFS implementation .
Winbind status program .
2004-06-19 12:15:41 +04:00
Copyright ( C ) Tim Potter 2000 - 2003
Copyright ( C ) Andrew Bartlett < abartlet @ samba . org > 2003 - 2004
2003-08-13 05:53:07 +04:00
Copyright ( C ) Francesco Chemolli < kinkie @ kame . usr . dsi . unimi . it > 2000
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-10 06:07:03 +04:00
the Free Software Foundation ; either version 3 of the License , or
2003-08-13 05:53:07 +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 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2003-08-13 05:53:07 +04:00
*/
# include "includes.h"
2005-02-10 08:09:35 +03:00
# include "system/filesys.h"
2004-11-02 05:57:18 +03:00
# include "lib/cmdline/popt_common.h"
2011-02-10 06:12:51 +03:00
# include <ldb.h>
2006-11-07 03:48:36 +03:00
# include "auth/credentials/credentials.h"
# include "auth/gensec/gensec.h"
2013-08-05 09:12:01 +04:00
# include "auth/gensec/gensec_internal.h" /* TODO: remove this */
2004-11-02 05:57:18 +03:00
# include "auth/auth.h"
2006-11-07 03:48:36 +03:00
# include "librpc/gen_ndr/ndr_netlogon.h"
2006-04-30 22:46:14 +04:00
# include "auth/auth_sam.h"
2006-03-14 18:03:25 +03:00
# include "libcli/auth/libcli_auth.h"
2006-04-29 21:34:49 +04:00
# include "libcli/security/security.h"
2006-07-31 18:05:08 +04:00
# include "lib/events/events.h"
# include "lib/messaging/messaging.h"
# include "lib/messaging/irpc.h"
2006-08-17 04:44:29 +04:00
# include "auth/ntlmssp/ntlmssp.h"
2007-09-08 16:42:09 +04:00
# include "param/param.h"
2003-08-13 05:53:07 +04:00
2007-08-30 13:02:40 +04:00
# define INITIAL_BUFFER_SIZE 300
# define MAX_BUFFER_SIZE 63000
2003-08-13 05:53:07 +04:00
2004-06-19 12:15:41 +04:00
enum stdio_helper_mode {
2003-08-13 05:53:07 +04:00
SQUID_2_4_BASIC ,
SQUID_2_5_BASIC ,
2004-06-19 12:15:41 +04:00
SQUID_2_5_NTLMSSP ,
NTLMSSP_CLIENT_1 ,
GSS_SPNEGO_CLIENT ,
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
GSS_SPNEGO_SERVER ,
2004-06-19 12:15:41 +04:00
NTLM_SERVER_1 ,
NUM_HELPER_MODES
2003-08-13 05:53:07 +04:00
} ;
2004-06-19 12:15:41 +04:00
# define NTLM_AUTH_FLAG_USER_SESSION_KEY 0x0004
# define NTLM_AUTH_FLAG_LMKEY 0x0008
2003-08-13 05:53:07 +04:00
2004-06-19 12:15:41 +04:00
typedef void ( * stdio_helper_function ) ( enum stdio_helper_mode stdio_helper_mode ,
2007-12-02 21:27:49 +03:00
struct loadparm_context * lp_ctx ,
2009-02-02 10:42:16 +03:00
char * buf , int length , void * * private1 ,
r6028: A MAJOR update to intergrate the new credentails system fully with
GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'.
GENSEC now no longer has it's own handling of 'set username' etc,
instead it uses cli_credentials calls.
In order to link the credentails code right though Samba, a lot of
interfaces have changed to remove 'username, domain, password'
arguments, and these have been replaced with a single 'struct
cli_credentials'.
In the session setup code, a new parameter 'workgroup' contains the
client/server current workgroup, which seems unrelated to the
authentication exchange (it was being filled in from the auth info).
This allows in particular kerberos to only call back for passwords
when it actually needs to perform the kinit.
The kerberos code has been modified not to use the SPNEGO provided
'principal name' (in the mechListMIC), but to instead use the name the
host was connected to as. This better matches Microsoft behaviour,
is more secure and allows better use of standard kerberos functions.
To achieve this, I made changes to our socket code so that the
hostname (before name resolution) is now recorded on the socket.
In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now
in libcli/auth/schannel.c, and it looks much more like a standard
GENSEC module. The actual sign/seal code moved to
libcli/auth/schannel_sign.c in a previous commit.
The schannel credentails structure is now merged with the rest of the
credentails, as many of the values (username, workstation, domain)
where already present there. This makes handling this in a generic
manner much easier, as there is no longer a custom entry-point.
The auth_domain module continues to be developed, but is now just as
functional as auth_winbind. The changes here are consequential to the
schannel changes.
The only removed function at this point is the RPC-LOGIN test
(simulating the load of a WinXP login), which needs much more work to
clean it up (it contains copies of too much code from all over the
torture suite, and I havn't been able to penetrate its 'structure').
Andrew Bartlett
(This used to be commit 2301a4b38a21aa60917973451687063d83d18d66)
2005-03-24 07:14:06 +03:00
unsigned int mux_id , void * * private2 ) ;
2003-08-13 05:53:07 +04:00
2004-06-19 12:15:41 +04:00
static void manage_squid_basic_request ( enum stdio_helper_mode stdio_helper_mode ,
2007-12-02 21:27:49 +03:00
struct loadparm_context * lp_ctx ,
2009-02-02 10:42:16 +03:00
char * buf , int length , void * * private1 ,
r6028: A MAJOR update to intergrate the new credentails system fully with
GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'.
GENSEC now no longer has it's own handling of 'set username' etc,
instead it uses cli_credentials calls.
In order to link the credentails code right though Samba, a lot of
interfaces have changed to remove 'username, domain, password'
arguments, and these have been replaced with a single 'struct
cli_credentials'.
In the session setup code, a new parameter 'workgroup' contains the
client/server current workgroup, which seems unrelated to the
authentication exchange (it was being filled in from the auth info).
This allows in particular kerberos to only call back for passwords
when it actually needs to perform the kinit.
The kerberos code has been modified not to use the SPNEGO provided
'principal name' (in the mechListMIC), but to instead use the name the
host was connected to as. This better matches Microsoft behaviour,
is more secure and allows better use of standard kerberos functions.
To achieve this, I made changes to our socket code so that the
hostname (before name resolution) is now recorded on the socket.
In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now
in libcli/auth/schannel.c, and it looks much more like a standard
GENSEC module. The actual sign/seal code moved to
libcli/auth/schannel_sign.c in a previous commit.
The schannel credentails structure is now merged with the rest of the
credentails, as many of the values (username, workstation, domain)
where already present there. This makes handling this in a generic
manner much easier, as there is no longer a custom entry-point.
The auth_domain module continues to be developed, but is now just as
functional as auth_winbind. The changes here are consequential to the
schannel changes.
The only removed function at this point is the RPC-LOGIN test
(simulating the load of a WinXP login), which needs much more work to
clean it up (it contains copies of too much code from all over the
torture suite, and I havn't been able to penetrate its 'structure').
Andrew Bartlett
(This used to be commit 2301a4b38a21aa60917973451687063d83d18d66)
2005-03-24 07:14:06 +03:00
unsigned int mux_id , void * * private2 ) ;
2003-08-13 05:53:07 +04:00
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
static void manage_gensec_request ( enum stdio_helper_mode stdio_helper_mode ,
2007-12-02 21:27:49 +03:00
struct loadparm_context * lp_ctx ,
2009-02-02 10:42:16 +03:00
char * buf , int length , void * * private1 ,
r6028: A MAJOR update to intergrate the new credentails system fully with
GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'.
GENSEC now no longer has it's own handling of 'set username' etc,
instead it uses cli_credentials calls.
In order to link the credentails code right though Samba, a lot of
interfaces have changed to remove 'username, domain, password'
arguments, and these have been replaced with a single 'struct
cli_credentials'.
In the session setup code, a new parameter 'workgroup' contains the
client/server current workgroup, which seems unrelated to the
authentication exchange (it was being filled in from the auth info).
This allows in particular kerberos to only call back for passwords
when it actually needs to perform the kinit.
The kerberos code has been modified not to use the SPNEGO provided
'principal name' (in the mechListMIC), but to instead use the name the
host was connected to as. This better matches Microsoft behaviour,
is more secure and allows better use of standard kerberos functions.
To achieve this, I made changes to our socket code so that the
hostname (before name resolution) is now recorded on the socket.
In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now
in libcli/auth/schannel.c, and it looks much more like a standard
GENSEC module. The actual sign/seal code moved to
libcli/auth/schannel_sign.c in a previous commit.
The schannel credentails structure is now merged with the rest of the
credentails, as many of the values (username, workstation, domain)
where already present there. This makes handling this in a generic
manner much easier, as there is no longer a custom entry-point.
The auth_domain module continues to be developed, but is now just as
functional as auth_winbind. The changes here are consequential to the
schannel changes.
The only removed function at this point is the RPC-LOGIN test
(simulating the load of a WinXP login), which needs much more work to
clean it up (it contains copies of too much code from all over the
torture suite, and I havn't been able to penetrate its 'structure').
Andrew Bartlett
(This used to be commit 2301a4b38a21aa60917973451687063d83d18d66)
2005-03-24 07:14:06 +03:00
unsigned int mux_id , void * * private2 ) ;
2003-08-13 05:53:07 +04:00
2004-06-19 12:15:41 +04:00
static void manage_ntlm_server_1_request ( enum stdio_helper_mode stdio_helper_mode ,
2007-12-02 21:27:49 +03:00
struct loadparm_context * lp_ctx ,
2009-02-02 10:42:16 +03:00
char * buf , int length , void * * private1 ,
r6028: A MAJOR update to intergrate the new credentails system fully with
GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'.
GENSEC now no longer has it's own handling of 'set username' etc,
instead it uses cli_credentials calls.
In order to link the credentails code right though Samba, a lot of
interfaces have changed to remove 'username, domain, password'
arguments, and these have been replaced with a single 'struct
cli_credentials'.
In the session setup code, a new parameter 'workgroup' contains the
client/server current workgroup, which seems unrelated to the
authentication exchange (it was being filled in from the auth info).
This allows in particular kerberos to only call back for passwords
when it actually needs to perform the kinit.
The kerberos code has been modified not to use the SPNEGO provided
'principal name' (in the mechListMIC), but to instead use the name the
host was connected to as. This better matches Microsoft behaviour,
is more secure and allows better use of standard kerberos functions.
To achieve this, I made changes to our socket code so that the
hostname (before name resolution) is now recorded on the socket.
In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now
in libcli/auth/schannel.c, and it looks much more like a standard
GENSEC module. The actual sign/seal code moved to
libcli/auth/schannel_sign.c in a previous commit.
The schannel credentails structure is now merged with the rest of the
credentails, as many of the values (username, workstation, domain)
where already present there. This makes handling this in a generic
manner much easier, as there is no longer a custom entry-point.
The auth_domain module continues to be developed, but is now just as
functional as auth_winbind. The changes here are consequential to the
schannel changes.
The only removed function at this point is the RPC-LOGIN test
(simulating the load of a WinXP login), which needs much more work to
clean it up (it contains copies of too much code from all over the
torture suite, and I havn't been able to penetrate its 'structure').
Andrew Bartlett
(This used to be commit 2301a4b38a21aa60917973451687063d83d18d66)
2005-03-24 07:14:06 +03:00
unsigned int mux_id , void * * private2 ) ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
2007-12-10 06:33:16 +03:00
static void manage_squid_request ( struct loadparm_context * lp_ctx ,
enum stdio_helper_mode helper_mode ,
r6028: A MAJOR update to intergrate the new credentails system fully with
GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'.
GENSEC now no longer has it's own handling of 'set username' etc,
instead it uses cli_credentials calls.
In order to link the credentails code right though Samba, a lot of
interfaces have changed to remove 'username, domain, password'
arguments, and these have been replaced with a single 'struct
cli_credentials'.
In the session setup code, a new parameter 'workgroup' contains the
client/server current workgroup, which seems unrelated to the
authentication exchange (it was being filled in from the auth info).
This allows in particular kerberos to only call back for passwords
when it actually needs to perform the kinit.
The kerberos code has been modified not to use the SPNEGO provided
'principal name' (in the mechListMIC), but to instead use the name the
host was connected to as. This better matches Microsoft behaviour,
is more secure and allows better use of standard kerberos functions.
To achieve this, I made changes to our socket code so that the
hostname (before name resolution) is now recorded on the socket.
In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now
in libcli/auth/schannel.c, and it looks much more like a standard
GENSEC module. The actual sign/seal code moved to
libcli/auth/schannel_sign.c in a previous commit.
The schannel credentails structure is now merged with the rest of the
credentails, as many of the values (username, workstation, domain)
where already present there. This makes handling this in a generic
manner much easier, as there is no longer a custom entry-point.
The auth_domain module continues to be developed, but is now just as
functional as auth_winbind. The changes here are consequential to the
schannel changes.
The only removed function at this point is the RPC-LOGIN test
(simulating the load of a WinXP login), which needs much more work to
clean it up (it contains copies of too much code from all over the
torture suite, and I havn't been able to penetrate its 'structure').
Andrew Bartlett
(This used to be commit 2301a4b38a21aa60917973451687063d83d18d66)
2005-03-24 07:14:06 +03:00
stdio_helper_function fn , void * * private2 ) ;
2003-08-13 05:53:07 +04:00
2004-06-19 12:15:41 +04:00
static const struct {
enum stdio_helper_mode mode ;
const char * name ;
stdio_helper_function fn ;
} stdio_helper_protocols [ ] = {
{ SQUID_2_4_BASIC , " squid-2.4-basic " , manage_squid_basic_request } ,
{ SQUID_2_5_BASIC , " squid-2.5-basic " , manage_squid_basic_request } ,
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
{ SQUID_2_5_NTLMSSP , " squid-2.5-ntlmssp " , manage_gensec_request } ,
{ GSS_SPNEGO_CLIENT , " gss-spnego-client " , manage_gensec_request } ,
2004-09-25 06:54:56 +04:00
{ GSS_SPNEGO_SERVER , " gss-spnego " , manage_gensec_request } ,
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
{ NTLMSSP_CLIENT_1 , " ntlmssp-client-1 " , manage_gensec_request } ,
2004-06-19 12:15:41 +04:00
{ NTLM_SERVER_1 , " ntlm-server-1 " , manage_ntlm_server_1_request } ,
{ NUM_HELPER_MODES , NULL , NULL }
} ;
extern int winbindd_fd ;
2003-08-13 05:53:07 +04:00
2005-05-16 00:16:26 +04:00
static const char * opt_username ;
static const char * opt_domain ;
static const char * opt_workstation ;
static const char * opt_password ;
static int opt_multiplex ;
2006-11-04 22:38:08 +03:00
static int use_cached_creds ;
2004-11-05 07:26:48 +03:00
static void mux_printf ( unsigned int mux_id , const char * format , . . . ) PRINTF_ATTRIBUTE ( 2 , 3 ) ;
static void mux_printf ( unsigned int mux_id , const char * format , . . . )
{
va_list ap ;
if ( opt_multiplex ) {
x_fprintf ( x_stdout , " %d " , mux_id ) ;
}
va_start ( ap , format ) ;
x_vfprintf ( x_stdout , format , ap ) ;
va_end ( ap ) ;
}
2003-08-13 05:53:07 +04:00
2004-06-19 12:15:41 +04:00
/* Copy of parse_domain_user from winbindd_util.c. Parse a string of the
form DOMAIN / user into a domain and a user */
2008-10-22 06:25:00 +04:00
static bool parse_ntlm_auth_domain_user ( const char * domuser , char * * domain ,
char * * user , char winbind_separator )
2004-06-19 12:15:41 +04:00
{
2007-12-03 17:53:07 +03:00
char * p = strchr ( domuser , winbind_separator ) ;
2004-06-19 12:15:41 +04:00
if ( ! p ) {
2007-10-02 02:13:02 +04:00
return false ;
2003-08-13 05:53:07 +04:00
}
2004-06-19 12:15:41 +04:00
2008-10-22 06:25:00 +04:00
* user = smb_xstrdup ( p + 1 ) ;
* domain = smb_xstrdup ( domuser ) ;
( * domain ) [ PTR_DIFF ( p , domuser ) ] = 0 ;
2003-08-13 05:53:07 +04:00
2007-10-02 02:13:02 +04:00
return true ;
2004-06-19 12:15:41 +04:00
}
2003-08-13 05:53:07 +04:00
2006-04-27 20:06:18 +04:00
2004-06-19 12:15:41 +04:00
/* Authenticate a user with a plaintext password */
2007-10-02 02:13:02 +04:00
static bool check_plaintext_auth ( const char * user , const char * pass ,
bool stdout_diagnostics )
2004-06-19 12:15:41 +04:00
{
return ( strcmp ( pass , opt_password ) = = 0 ) ;
}
2003-08-13 05:53:07 +04:00
2004-06-19 12:15:41 +04:00
/* authenticate a user with an encrypted username/password */
2007-12-02 19:56:09 +03:00
static NTSTATUS local_pw_check_specified ( struct loadparm_context * lp_ctx ,
const char * username ,
2004-06-19 12:15:41 +04:00
const char * domain ,
const char * workstation ,
const DATA_BLOB * challenge ,
const DATA_BLOB * lm_response ,
const DATA_BLOB * nt_response ,
2005-02-10 08:09:35 +03:00
uint32_t flags ,
2004-06-19 12:15:41 +04:00
DATA_BLOB * lm_session_key ,
DATA_BLOB * user_session_key ,
char * * error_string ,
char * * unix_name )
{
NTSTATUS nt_status ;
2005-07-22 08:30:11 +04:00
struct samr_Password lm_pw , nt_pw ;
struct samr_Password * lm_pwd , * nt_pwd ;
2004-06-19 12:15:41 +04:00
TALLOC_CTX * mem_ctx = talloc_init ( " local_pw_check_specified " ) ;
if ( ! mem_ctx ) {
nt_status = NT_STATUS_NO_MEMORY ;
} else {
2005-07-22 08:30:11 +04:00
E_md4hash ( opt_password , nt_pw . hash ) ;
if ( E_deshash ( opt_password , lm_pw . hash ) ) {
lm_pwd = & lm_pw ;
2004-06-19 12:15:41 +04:00
} else {
lm_pwd = NULL ;
}
2005-07-22 08:30:11 +04:00
nt_pwd = & nt_pw ;
2004-06-19 12:15:41 +04:00
nt_status = ntlm_password_check ( mem_ctx ,
2010-07-16 08:32:42 +04:00
lpcfg_lanman_auth ( lp_ctx ) ,
lpcfg_ntlm_auth ( lp_ctx ) ,
2005-10-28 15:21:33 +04:00
MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT |
MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT ,
2004-06-19 12:15:41 +04:00
challenge ,
lm_response ,
nt_response ,
username ,
username ,
domain ,
lm_pwd , nt_pwd , user_session_key , lm_session_key ) ;
if ( NT_STATUS_IS_OK ( nt_status ) ) {
if ( unix_name ) {
2010-05-27 19:41:39 +04:00
if ( asprintf ( unix_name , " %s%c%s " , domain ,
2010-07-16 08:32:42 +04:00
* lpcfg_winbind_separator ( lp_ctx ) ,
2010-05-27 19:41:39 +04:00
username ) < 0 ) {
nt_status = NT_STATUS_NO_MEMORY ;
}
2004-06-19 12:15:41 +04:00
}
} else {
DEBUG ( 3 , ( " Login for user [%s] \\ [%s]@[%s] failed due to [%s] \n " ,
domain , username , workstation ,
nt_errstr ( nt_status ) ) ) ;
}
2005-01-27 10:08:20 +03:00
talloc_free ( mem_ctx ) ;
2004-06-19 12:15:41 +04:00
}
if ( error_string ) {
* error_string = strdup ( nt_errstr ( nt_status ) ) ;
}
return nt_status ;
2003-08-13 05:53:07 +04:00
}
2004-06-19 12:15:41 +04:00
static void manage_squid_basic_request ( enum stdio_helper_mode stdio_helper_mode ,
2007-12-02 21:27:49 +03:00
struct loadparm_context * lp_ctx ,
2009-02-02 10:42:16 +03:00
char * buf , int length , void * * private1 ,
r6028: A MAJOR update to intergrate the new credentails system fully with
GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'.
GENSEC now no longer has it's own handling of 'set username' etc,
instead it uses cli_credentials calls.
In order to link the credentails code right though Samba, a lot of
interfaces have changed to remove 'username, domain, password'
arguments, and these have been replaced with a single 'struct
cli_credentials'.
In the session setup code, a new parameter 'workgroup' contains the
client/server current workgroup, which seems unrelated to the
authentication exchange (it was being filled in from the auth info).
This allows in particular kerberos to only call back for passwords
when it actually needs to perform the kinit.
The kerberos code has been modified not to use the SPNEGO provided
'principal name' (in the mechListMIC), but to instead use the name the
host was connected to as. This better matches Microsoft behaviour,
is more secure and allows better use of standard kerberos functions.
To achieve this, I made changes to our socket code so that the
hostname (before name resolution) is now recorded on the socket.
In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now
in libcli/auth/schannel.c, and it looks much more like a standard
GENSEC module. The actual sign/seal code moved to
libcli/auth/schannel_sign.c in a previous commit.
The schannel credentails structure is now merged with the rest of the
credentails, as many of the values (username, workstation, domain)
where already present there. This makes handling this in a generic
manner much easier, as there is no longer a custom entry-point.
The auth_domain module continues to be developed, but is now just as
functional as auth_winbind. The changes here are consequential to the
schannel changes.
The only removed function at this point is the RPC-LOGIN test
(simulating the load of a WinXP login), which needs much more work to
clean it up (it contains copies of too much code from all over the
torture suite, and I havn't been able to penetrate its 'structure').
Andrew Bartlett
(This used to be commit 2301a4b38a21aa60917973451687063d83d18d66)
2005-03-24 07:14:06 +03:00
unsigned int mux_id , void * * private2 )
2003-08-13 05:53:07 +04:00
{
char * user , * pass ;
user = buf ;
2007-09-07 19:08:14 +04:00
pass = memchr ( buf , ' ' , length ) ;
2003-08-13 05:53:07 +04:00
if ( ! pass ) {
DEBUG ( 2 , ( " Password not found. Denying access \n " ) ) ;
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " ERR \n " ) ;
2003-08-13 05:53:07 +04:00
return ;
}
* pass = ' \0 ' ;
pass + + ;
2004-06-19 12:15:41 +04:00
if ( stdio_helper_mode = = SQUID_2_5_BASIC ) {
2003-08-13 05:53:07 +04:00
rfc1738_unescape ( user ) ;
rfc1738_unescape ( pass ) ;
}
2007-10-02 02:13:02 +04:00
if ( check_plaintext_auth ( user , pass , false ) ) {
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " OK \n " ) ;
2003-08-13 05:53:07 +04:00
} else {
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " ERR \n " ) ;
2003-08-13 05:53:07 +04:00
}
}
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
/* This is a bit hairy, but the basic idea is to do a password callback
to the calling application . The callback comes from within gensec */
static void manage_gensec_get_pw_request ( enum stdio_helper_mode stdio_helper_mode ,
2007-12-02 21:27:49 +03:00
struct loadparm_context * lp_ctx ,
2009-02-02 10:42:16 +03:00
char * buf , int length , void * * private1 ,
r6028: A MAJOR update to intergrate the new credentails system fully with
GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'.
GENSEC now no longer has it's own handling of 'set username' etc,
instead it uses cli_credentials calls.
In order to link the credentails code right though Samba, a lot of
interfaces have changed to remove 'username, domain, password'
arguments, and these have been replaced with a single 'struct
cli_credentials'.
In the session setup code, a new parameter 'workgroup' contains the
client/server current workgroup, which seems unrelated to the
authentication exchange (it was being filled in from the auth info).
This allows in particular kerberos to only call back for passwords
when it actually needs to perform the kinit.
The kerberos code has been modified not to use the SPNEGO provided
'principal name' (in the mechListMIC), but to instead use the name the
host was connected to as. This better matches Microsoft behaviour,
is more secure and allows better use of standard kerberos functions.
To achieve this, I made changes to our socket code so that the
hostname (before name resolution) is now recorded on the socket.
In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now
in libcli/auth/schannel.c, and it looks much more like a standard
GENSEC module. The actual sign/seal code moved to
libcli/auth/schannel_sign.c in a previous commit.
The schannel credentails structure is now merged with the rest of the
credentails, as many of the values (username, workstation, domain)
where already present there. This makes handling this in a generic
manner much easier, as there is no longer a custom entry-point.
The auth_domain module continues to be developed, but is now just as
functional as auth_winbind. The changes here are consequential to the
schannel changes.
The only removed function at this point is the RPC-LOGIN test
(simulating the load of a WinXP login), which needs much more work to
clean it up (it contains copies of too much code from all over the
torture suite, and I havn't been able to penetrate its 'structure').
Andrew Bartlett
(This used to be commit 2301a4b38a21aa60917973451687063d83d18d66)
2005-03-24 07:14:06 +03:00
unsigned int mux_id , void * * password )
2004-06-19 12:15:41 +04:00
{
2004-06-20 04:58:09 +04:00
DATA_BLOB in ;
2004-06-19 12:15:41 +04:00
if ( strlen ( buf ) < 2 ) {
2004-06-20 04:58:09 +04:00
DEBUG ( 1 , ( " query [%s] invalid " , buf ) ) ;
2008-03-20 02:42:42 +03:00
mux_printf ( mux_id , " BH Query invalid \n " ) ;
2004-06-19 12:15:41 +04:00
return ;
}
2004-06-20 04:58:09 +04:00
if ( strlen ( buf ) > 3 ) {
2011-03-30 10:49:01 +04:00
in = base64_decode_data_blob ( buf + 3 ) ;
2004-06-19 12:15:41 +04:00
} else {
2004-06-20 04:58:09 +04:00
in = data_blob ( NULL , 0 ) ;
2004-06-19 12:15:41 +04:00
}
if ( strncmp ( buf , " PW " , 3 ) = = 0 ) {
2009-02-02 10:42:16 +03:00
* password = talloc_strndup ( * private1 /* hopefully the right gensec context, useful to use for talloc */ ,
r6028: A MAJOR update to intergrate the new credentails system fully with
GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'.
GENSEC now no longer has it's own handling of 'set username' etc,
instead it uses cli_credentials calls.
In order to link the credentails code right though Samba, a lot of
interfaces have changed to remove 'username, domain, password'
arguments, and these have been replaced with a single 'struct
cli_credentials'.
In the session setup code, a new parameter 'workgroup' contains the
client/server current workgroup, which seems unrelated to the
authentication exchange (it was being filled in from the auth info).
This allows in particular kerberos to only call back for passwords
when it actually needs to perform the kinit.
The kerberos code has been modified not to use the SPNEGO provided
'principal name' (in the mechListMIC), but to instead use the name the
host was connected to as. This better matches Microsoft behaviour,
is more secure and allows better use of standard kerberos functions.
To achieve this, I made changes to our socket code so that the
hostname (before name resolution) is now recorded on the socket.
In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now
in libcli/auth/schannel.c, and it looks much more like a standard
GENSEC module. The actual sign/seal code moved to
libcli/auth/schannel_sign.c in a previous commit.
The schannel credentails structure is now merged with the rest of the
credentails, as many of the values (username, workstation, domain)
where already present there. This makes handling this in a generic
manner much easier, as there is no longer a custom entry-point.
The auth_domain module continues to be developed, but is now just as
functional as auth_winbind. The changes here are consequential to the
schannel changes.
The only removed function at this point is the RPC-LOGIN test
(simulating the load of a WinXP login), which needs much more work to
clean it up (it contains copies of too much code from all over the
torture suite, and I havn't been able to penetrate its 'structure').
Andrew Bartlett
(This used to be commit 2301a4b38a21aa60917973451687063d83d18d66)
2005-03-24 07:14:06 +03:00
( const char * ) in . data , in . length ) ;
2004-06-19 12:15:41 +04:00
r6028: A MAJOR update to intergrate the new credentails system fully with
GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'.
GENSEC now no longer has it's own handling of 'set username' etc,
instead it uses cli_credentials calls.
In order to link the credentails code right though Samba, a lot of
interfaces have changed to remove 'username, domain, password'
arguments, and these have been replaced with a single 'struct
cli_credentials'.
In the session setup code, a new parameter 'workgroup' contains the
client/server current workgroup, which seems unrelated to the
authentication exchange (it was being filled in from the auth info).
This allows in particular kerberos to only call back for passwords
when it actually needs to perform the kinit.
The kerberos code has been modified not to use the SPNEGO provided
'principal name' (in the mechListMIC), but to instead use the name the
host was connected to as. This better matches Microsoft behaviour,
is more secure and allows better use of standard kerberos functions.
To achieve this, I made changes to our socket code so that the
hostname (before name resolution) is now recorded on the socket.
In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now
in libcli/auth/schannel.c, and it looks much more like a standard
GENSEC module. The actual sign/seal code moved to
libcli/auth/schannel_sign.c in a previous commit.
The schannel credentails structure is now merged with the rest of the
credentails, as many of the values (username, workstation, domain)
where already present there. This makes handling this in a generic
manner much easier, as there is no longer a custom entry-point.
The auth_domain module continues to be developed, but is now just as
functional as auth_winbind. The changes here are consequential to the
schannel changes.
The only removed function at this point is the RPC-LOGIN test
(simulating the load of a WinXP login), which needs much more work to
clean it up (it contains copies of too much code from all over the
torture suite, and I havn't been able to penetrate its 'structure').
Andrew Bartlett
(This used to be commit 2301a4b38a21aa60917973451687063d83d18d66)
2005-03-24 07:14:06 +03:00
if ( * password = = NULL ) {
2004-06-19 12:15:41 +04:00
DEBUG ( 1 , ( " Out of memory \n " ) ) ;
2008-03-20 02:42:42 +03:00
mux_printf ( mux_id , " BH Out of memory \n " ) ;
2004-06-20 04:58:09 +04:00
data_blob_free ( & in ) ;
2004-06-19 12:15:41 +04:00
return ;
}
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " OK \n " ) ;
2004-06-20 04:58:09 +04:00
data_blob_free ( & in ) ;
2004-06-19 12:15:41 +04:00
return ;
}
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
DEBUG ( 1 , ( " Asked for (and expected) a password \n " ) ) ;
2008-03-20 02:42:42 +03:00
mux_printf ( mux_id , " BH Expected a password \n " ) ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
data_blob_free ( & in ) ;
}
r6028: A MAJOR update to intergrate the new credentails system fully with
GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'.
GENSEC now no longer has it's own handling of 'set username' etc,
instead it uses cli_credentials calls.
In order to link the credentails code right though Samba, a lot of
interfaces have changed to remove 'username, domain, password'
arguments, and these have been replaced with a single 'struct
cli_credentials'.
In the session setup code, a new parameter 'workgroup' contains the
client/server current workgroup, which seems unrelated to the
authentication exchange (it was being filled in from the auth info).
This allows in particular kerberos to only call back for passwords
when it actually needs to perform the kinit.
The kerberos code has been modified not to use the SPNEGO provided
'principal name' (in the mechListMIC), but to instead use the name the
host was connected to as. This better matches Microsoft behaviour,
is more secure and allows better use of standard kerberos functions.
To achieve this, I made changes to our socket code so that the
hostname (before name resolution) is now recorded on the socket.
In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now
in libcli/auth/schannel.c, and it looks much more like a standard
GENSEC module. The actual sign/seal code moved to
libcli/auth/schannel_sign.c in a previous commit.
The schannel credentails structure is now merged with the rest of the
credentails, as many of the values (username, workstation, domain)
where already present there. This makes handling this in a generic
manner much easier, as there is no longer a custom entry-point.
The auth_domain module continues to be developed, but is now just as
functional as auth_winbind. The changes here are consequential to the
schannel changes.
The only removed function at this point is the RPC-LOGIN test
(simulating the load of a WinXP login), which needs much more work to
clean it up (it contains copies of too much code from all over the
torture suite, and I havn't been able to penetrate its 'structure').
Andrew Bartlett
(This used to be commit 2301a4b38a21aa60917973451687063d83d18d66)
2005-03-24 07:14:06 +03:00
/**
2007-12-02 21:31:14 +03:00
* Callback for password credentials . This is not async , and when
* GENSEC and the credentials code is made async , it will look rather
r6028: A MAJOR update to intergrate the new credentails system fully with
GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'.
GENSEC now no longer has it's own handling of 'set username' etc,
instead it uses cli_credentials calls.
In order to link the credentails code right though Samba, a lot of
interfaces have changed to remove 'username, domain, password'
arguments, and these have been replaced with a single 'struct
cli_credentials'.
In the session setup code, a new parameter 'workgroup' contains the
client/server current workgroup, which seems unrelated to the
authentication exchange (it was being filled in from the auth info).
This allows in particular kerberos to only call back for passwords
when it actually needs to perform the kinit.
The kerberos code has been modified not to use the SPNEGO provided
'principal name' (in the mechListMIC), but to instead use the name the
host was connected to as. This better matches Microsoft behaviour,
is more secure and allows better use of standard kerberos functions.
To achieve this, I made changes to our socket code so that the
hostname (before name resolution) is now recorded on the socket.
In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now
in libcli/auth/schannel.c, and it looks much more like a standard
GENSEC module. The actual sign/seal code moved to
libcli/auth/schannel_sign.c in a previous commit.
The schannel credentails structure is now merged with the rest of the
credentails, as many of the values (username, workstation, domain)
where already present there. This makes handling this in a generic
manner much easier, as there is no longer a custom entry-point.
The auth_domain module continues to be developed, but is now just as
functional as auth_winbind. The changes here are consequential to the
schannel changes.
The only removed function at this point is the RPC-LOGIN test
(simulating the load of a WinXP login), which needs much more work to
clean it up (it contains copies of too much code from all over the
torture suite, and I havn't been able to penetrate its 'structure').
Andrew Bartlett
(This used to be commit 2301a4b38a21aa60917973451687063d83d18d66)
2005-03-24 07:14:06 +03:00
* different .
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
*/
r6028: A MAJOR update to intergrate the new credentails system fully with
GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'.
GENSEC now no longer has it's own handling of 'set username' etc,
instead it uses cli_credentials calls.
In order to link the credentails code right though Samba, a lot of
interfaces have changed to remove 'username, domain, password'
arguments, and these have been replaced with a single 'struct
cli_credentials'.
In the session setup code, a new parameter 'workgroup' contains the
client/server current workgroup, which seems unrelated to the
authentication exchange (it was being filled in from the auth info).
This allows in particular kerberos to only call back for passwords
when it actually needs to perform the kinit.
The kerberos code has been modified not to use the SPNEGO provided
'principal name' (in the mechListMIC), but to instead use the name the
host was connected to as. This better matches Microsoft behaviour,
is more secure and allows better use of standard kerberos functions.
To achieve this, I made changes to our socket code so that the
hostname (before name resolution) is now recorded on the socket.
In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now
in libcli/auth/schannel.c, and it looks much more like a standard
GENSEC module. The actual sign/seal code moved to
libcli/auth/schannel_sign.c in a previous commit.
The schannel credentails structure is now merged with the rest of the
credentails, as many of the values (username, workstation, domain)
where already present there. This makes handling this in a generic
manner much easier, as there is no longer a custom entry-point.
The auth_domain module continues to be developed, but is now just as
functional as auth_winbind. The changes here are consequential to the
schannel changes.
The only removed function at this point is the RPC-LOGIN test
(simulating the load of a WinXP login), which needs much more work to
clean it up (it contains copies of too much code from all over the
torture suite, and I havn't been able to penetrate its 'structure').
Andrew Bartlett
(This used to be commit 2301a4b38a21aa60917973451687063d83d18d66)
2005-03-24 07:14:06 +03:00
static const char * get_password ( struct cli_credentials * credentials )
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
{
r6028: A MAJOR update to intergrate the new credentails system fully with
GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'.
GENSEC now no longer has it's own handling of 'set username' etc,
instead it uses cli_credentials calls.
In order to link the credentails code right though Samba, a lot of
interfaces have changed to remove 'username, domain, password'
arguments, and these have been replaced with a single 'struct
cli_credentials'.
In the session setup code, a new parameter 'workgroup' contains the
client/server current workgroup, which seems unrelated to the
authentication exchange (it was being filled in from the auth info).
This allows in particular kerberos to only call back for passwords
when it actually needs to perform the kinit.
The kerberos code has been modified not to use the SPNEGO provided
'principal name' (in the mechListMIC), but to instead use the name the
host was connected to as. This better matches Microsoft behaviour,
is more secure and allows better use of standard kerberos functions.
To achieve this, I made changes to our socket code so that the
hostname (before name resolution) is now recorded on the socket.
In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now
in libcli/auth/schannel.c, and it looks much more like a standard
GENSEC module. The actual sign/seal code moved to
libcli/auth/schannel_sign.c in a previous commit.
The schannel credentails structure is now merged with the rest of the
credentails, as many of the values (username, workstation, domain)
where already present there. This makes handling this in a generic
manner much easier, as there is no longer a custom entry-point.
The auth_domain module continues to be developed, but is now just as
functional as auth_winbind. The changes here are consequential to the
schannel changes.
The only removed function at this point is the RPC-LOGIN test
(simulating the load of a WinXP login), which needs much more work to
clean it up (it contains copies of too much code from all over the
torture suite, and I havn't been able to penetrate its 'structure').
Andrew Bartlett
(This used to be commit 2301a4b38a21aa60917973451687063d83d18d66)
2005-03-24 07:14:06 +03:00
char * password = NULL ;
2013-07-31 15:24:21 +04:00
void * cb = cli_credentials_callback_data_void ( credentials ) ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
/* Ask for a password */
2013-07-31 15:24:21 +04:00
mux_printf ( ( unsigned int ) ( uintptr_t ) cb , " PW \n " ) ;
cli_credentials_set_callback_data ( credentials , NULL ) ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
2007-12-10 06:33:16 +03:00
manage_squid_request ( cmdline_lp_ctx , NUM_HELPER_MODES /* bogus */ , manage_gensec_get_pw_request , ( void * * ) & password ) ;
r6028: A MAJOR update to intergrate the new credentails system fully with
GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'.
GENSEC now no longer has it's own handling of 'set username' etc,
instead it uses cli_credentials calls.
In order to link the credentails code right though Samba, a lot of
interfaces have changed to remove 'username, domain, password'
arguments, and these have been replaced with a single 'struct
cli_credentials'.
In the session setup code, a new parameter 'workgroup' contains the
client/server current workgroup, which seems unrelated to the
authentication exchange (it was being filled in from the auth info).
This allows in particular kerberos to only call back for passwords
when it actually needs to perform the kinit.
The kerberos code has been modified not to use the SPNEGO provided
'principal name' (in the mechListMIC), but to instead use the name the
host was connected to as. This better matches Microsoft behaviour,
is more secure and allows better use of standard kerberos functions.
To achieve this, I made changes to our socket code so that the
hostname (before name resolution) is now recorded on the socket.
In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now
in libcli/auth/schannel.c, and it looks much more like a standard
GENSEC module. The actual sign/seal code moved to
libcli/auth/schannel_sign.c in a previous commit.
The schannel credentails structure is now merged with the rest of the
credentails, as many of the values (username, workstation, domain)
where already present there. This makes handling this in a generic
manner much easier, as there is no longer a custom entry-point.
The auth_domain module continues to be developed, but is now just as
functional as auth_winbind. The changes here are consequential to the
schannel changes.
The only removed function at this point is the RPC-LOGIN test
(simulating the load of a WinXP login), which needs much more work to
clean it up (it contains copies of too much code from all over the
torture suite, and I havn't been able to penetrate its 'structure').
Andrew Bartlett
(This used to be commit 2301a4b38a21aa60917973451687063d83d18d66)
2005-03-24 07:14:06 +03:00
return password ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
}
2007-09-07 20:54:39 +04:00
/**
Check if a string is part of a list .
* */
static bool in_list ( const char * s , const char * list , bool casesensitive )
{
2007-12-16 01:15:18 +03:00
char * tok ;
size_t tok_len = 1024 ;
2007-09-07 20:54:39 +04:00
const char * p = list ;
if ( ! list )
return false ;
2007-12-16 01:15:18 +03:00
tok = ( char * ) malloc ( tok_len ) ;
if ( ! tok ) {
return false ;
}
while ( next_token ( & p , tok , LIST_SEP , tok_len ) ) {
if ( ( casesensitive ? strcmp : strcasecmp_m ) ( tok , s ) = = 0 ) {
free ( tok ) ;
2007-09-07 20:54:39 +04:00
return true ;
2007-12-16 01:15:18 +03:00
}
2007-09-07 20:54:39 +04:00
}
2007-12-16 01:15:18 +03:00
free ( tok ) ;
2007-09-07 20:54:39 +04:00
return false ;
}
2006-08-17 04:44:29 +04:00
static void gensec_want_feature_list ( struct gensec_security * state , char * feature_list )
{
2007-10-02 02:13:02 +04:00
if ( in_list ( " NTLMSSP_FEATURE_SESSION_KEY " , feature_list , true ) ) {
2006-08-17 04:44:29 +04:00
DEBUG ( 10 , ( " want GENSEC_FEATURE_SESSION_KEY \n " ) ) ;
gensec_want_feature ( state , GENSEC_FEATURE_SESSION_KEY ) ;
}
2007-10-02 02:13:02 +04:00
if ( in_list ( " NTLMSSP_FEATURE_SIGN " , feature_list , true ) ) {
2006-08-17 04:44:29 +04:00
DEBUG ( 10 , ( " want GENSEC_FEATURE_SIGN \n " ) ) ;
gensec_want_feature ( state , GENSEC_FEATURE_SIGN ) ;
}
2007-10-02 02:13:02 +04:00
if ( in_list ( " NTLMSSP_FEATURE_SEAL " , feature_list , true ) ) {
2006-08-17 04:44:29 +04:00
DEBUG ( 10 , ( " want GENSEC_FEATURE_SEAL \n " ) ) ;
gensec_want_feature ( state , GENSEC_FEATURE_SEAL ) ;
}
}
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
static void manage_gensec_request ( enum stdio_helper_mode stdio_helper_mode ,
2007-12-02 21:27:49 +03:00
struct loadparm_context * lp_ctx ,
2009-02-02 10:42:16 +03:00
char * buf , int length , void * * private1 ,
r6028: A MAJOR update to intergrate the new credentails system fully with
GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'.
GENSEC now no longer has it's own handling of 'set username' etc,
instead it uses cli_credentials calls.
In order to link the credentails code right though Samba, a lot of
interfaces have changed to remove 'username, domain, password'
arguments, and these have been replaced with a single 'struct
cli_credentials'.
In the session setup code, a new parameter 'workgroup' contains the
client/server current workgroup, which seems unrelated to the
authentication exchange (it was being filled in from the auth info).
This allows in particular kerberos to only call back for passwords
when it actually needs to perform the kinit.
The kerberos code has been modified not to use the SPNEGO provided
'principal name' (in the mechListMIC), but to instead use the name the
host was connected to as. This better matches Microsoft behaviour,
is more secure and allows better use of standard kerberos functions.
To achieve this, I made changes to our socket code so that the
hostname (before name resolution) is now recorded on the socket.
In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now
in libcli/auth/schannel.c, and it looks much more like a standard
GENSEC module. The actual sign/seal code moved to
libcli/auth/schannel_sign.c in a previous commit.
The schannel credentails structure is now merged with the rest of the
credentails, as many of the values (username, workstation, domain)
where already present there. This makes handling this in a generic
manner much easier, as there is no longer a custom entry-point.
The auth_domain module continues to be developed, but is now just as
functional as auth_winbind. The changes here are consequential to the
schannel changes.
The only removed function at this point is the RPC-LOGIN test
(simulating the load of a WinXP login), which needs much more work to
clean it up (it contains copies of too much code from all over the
torture suite, and I havn't been able to penetrate its 'structure').
Andrew Bartlett
(This used to be commit 2301a4b38a21aa60917973451687063d83d18d66)
2005-03-24 07:14:06 +03:00
unsigned int mux_id , void * * private2 )
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
{
DATA_BLOB in ;
DATA_BLOB out = data_blob ( NULL , 0 ) ;
char * out_base64 = NULL ;
const char * reply_arg = NULL ;
2005-08-30 05:19:41 +04:00
struct gensec_ntlm_state {
struct gensec_security * gensec_state ;
const char * set_password ;
} ;
struct gensec_ntlm_state * state ;
2008-12-29 22:24:57 +03:00
struct tevent_context * ev ;
2011-05-03 04:40:33 +04:00
struct imessaging_context * msg ;
2005-08-30 05:19:41 +04:00
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
NTSTATUS nt_status ;
2007-10-02 02:13:02 +04:00
bool first = false ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
const char * reply_code ;
r6028: A MAJOR update to intergrate the new credentails system fully with
GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'.
GENSEC now no longer has it's own handling of 'set username' etc,
instead it uses cli_credentials calls.
In order to link the credentails code right though Samba, a lot of
interfaces have changed to remove 'username, domain, password'
arguments, and these have been replaced with a single 'struct
cli_credentials'.
In the session setup code, a new parameter 'workgroup' contains the
client/server current workgroup, which seems unrelated to the
authentication exchange (it was being filled in from the auth info).
This allows in particular kerberos to only call back for passwords
when it actually needs to perform the kinit.
The kerberos code has been modified not to use the SPNEGO provided
'principal name' (in the mechListMIC), but to instead use the name the
host was connected to as. This better matches Microsoft behaviour,
is more secure and allows better use of standard kerberos functions.
To achieve this, I made changes to our socket code so that the
hostname (before name resolution) is now recorded on the socket.
In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now
in libcli/auth/schannel.c, and it looks much more like a standard
GENSEC module. The actual sign/seal code moved to
libcli/auth/schannel_sign.c in a previous commit.
The schannel credentails structure is now merged with the rest of the
credentails, as many of the values (username, workstation, domain)
where already present there. This makes handling this in a generic
manner much easier, as there is no longer a custom entry-point.
The auth_domain module continues to be developed, but is now just as
functional as auth_winbind. The changes here are consequential to the
schannel changes.
The only removed function at this point is the RPC-LOGIN test
(simulating the load of a WinXP login), which needs much more work to
clean it up (it contains copies of too much code from all over the
torture suite, and I havn't been able to penetrate its 'structure').
Andrew Bartlett
(This used to be commit 2301a4b38a21aa60917973451687063d83d18d66)
2005-03-24 07:14:06 +03:00
struct cli_credentials * creds ;
2005-08-02 02:04:25 +04:00
2006-08-17 04:44:29 +04:00
static char * want_feature_list = NULL ;
static DATA_BLOB session_key ;
2005-08-02 02:04:25 +04:00
TALLOC_CTX * mem_ctx ;
2005-08-30 05:19:41 +04:00
2009-02-02 10:42:16 +03:00
if ( * private1 ) {
state = ( struct gensec_ntlm_state * ) * private1 ;
2005-08-30 05:19:41 +04:00
} else {
state = talloc_zero ( NULL , struct gensec_ntlm_state ) ;
if ( ! state ) {
mux_printf ( mux_id , " BH No Memory \n " ) ;
exit ( 1 ) ;
}
2009-02-02 10:42:16 +03:00
* private1 = state ;
2005-08-30 05:19:41 +04:00
if ( opt_password ) {
state - > set_password = opt_password ;
}
}
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
if ( strlen ( buf ) < 2 ) {
DEBUG ( 1 , ( " query [%s] invalid " , buf ) ) ;
2008-03-20 02:42:42 +03:00
mux_printf ( mux_id , " BH Query invalid \n " ) ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
return ;
}
if ( strlen ( buf ) > 3 ) {
2006-08-17 04:44:29 +04:00
if ( strncmp ( buf , " SF " , 3 ) = = 0 ) {
DEBUG ( 10 , ( " Setting flags to negotiate \n " ) ) ;
talloc_free ( want_feature_list ) ;
want_feature_list = talloc_strndup ( state , buf + 3 , strlen ( buf ) - 3 ) ;
mux_printf ( mux_id , " OK \n " ) ;
return ;
}
2011-03-30 10:49:01 +04:00
in = base64_decode_data_blob ( buf + 3 ) ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
} else {
in = data_blob ( NULL , 0 ) ;
}
2004-06-20 04:58:09 +04:00
if ( strncmp ( buf , " YR " , 2 ) = = 0 ) {
2005-08-30 05:19:41 +04:00
if ( state - > gensec_state ) {
talloc_free ( state - > gensec_state ) ;
state - > gensec_state = NULL ;
2004-06-20 04:58:09 +04:00
}
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
} else if ( ( strncmp ( buf , " OK " , 2 ) = = 0 ) ) {
2006-11-04 23:57:32 +03:00
/* Just return BH, like ntlm_auth from Samba 3 does. */
2008-03-20 02:42:42 +03:00
mux_printf ( mux_id , " BH Command expected \n " ) ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
data_blob_free ( & in ) ;
return ;
2004-06-20 04:58:09 +04:00
} else if ( ( strncmp ( buf , " TT " , 3 ) ! = 0 ) & &
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
( strncmp ( buf , " KK " , 3 ) ! = 0 ) & &
( strncmp ( buf , " AF " , 3 ) ! = 0 ) & &
( strncmp ( buf , " NA " , 3 ) ! = 0 ) & &
2004-11-06 04:20:28 +03:00
( strncmp ( buf , " UG " , 2 ) ! = 0 ) & &
2006-08-17 04:44:29 +04:00
( strncmp ( buf , " PW " , 3 ) ! = 0 ) & &
( strncmp ( buf , " GK " , 2 ) ! = 0 ) & &
( strncmp ( buf , " GF " , 2 ) ! = 0 ) ) {
2004-06-19 12:15:41 +04:00
DEBUG ( 1 , ( " SPNEGO request [%s] invalid \n " , buf ) ) ;
2008-03-20 02:42:42 +03:00
mux_printf ( mux_id , " BH SPNEGO request invalid \n " ) ;
2004-06-20 04:58:09 +04:00
data_blob_free ( & in ) ;
2004-06-19 12:15:41 +04:00
return ;
}
2008-06-14 21:00:53 +04:00
ev = s4_event_context_init ( state ) ;
2008-04-22 01:58:23 +04:00
if ( ! ev ) {
exit ( 1 ) ;
}
2009-06-18 13:16:16 +04:00
mem_ctx = talloc_named ( NULL , 0 , " manage_gensec_request internal mem_ctx " ) ;
2004-06-20 04:58:09 +04:00
/* setup gensec */
2005-08-30 05:19:41 +04:00
if ( ! ( state - > gensec_state ) ) {
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
switch ( stdio_helper_mode ) {
case GSS_SPNEGO_CLIENT :
case NTLMSSP_CLIENT_1 :
/* setup the client side */
2005-06-16 15:36:09 +04:00
2011-10-17 11:22:33 +04:00
nt_status = gensec_client_start ( NULL , & state - > gensec_state ,
2010-07-16 08:32:42 +04:00
lpcfg_gensec_settings ( NULL , lp_ctx ) ) ;
2005-06-16 15:36:09 +04:00
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
2009-06-18 13:16:16 +04:00
talloc_free ( mem_ctx ) ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
exit ( 1 ) ;
}
r6028: A MAJOR update to intergrate the new credentails system fully with
GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'.
GENSEC now no longer has it's own handling of 'set username' etc,
instead it uses cli_credentials calls.
In order to link the credentails code right though Samba, a lot of
interfaces have changed to remove 'username, domain, password'
arguments, and these have been replaced with a single 'struct
cli_credentials'.
In the session setup code, a new parameter 'workgroup' contains the
client/server current workgroup, which seems unrelated to the
authentication exchange (it was being filled in from the auth info).
This allows in particular kerberos to only call back for passwords
when it actually needs to perform the kinit.
The kerberos code has been modified not to use the SPNEGO provided
'principal name' (in the mechListMIC), but to instead use the name the
host was connected to as. This better matches Microsoft behaviour,
is more secure and allows better use of standard kerberos functions.
To achieve this, I made changes to our socket code so that the
hostname (before name resolution) is now recorded on the socket.
In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now
in libcli/auth/schannel.c, and it looks much more like a standard
GENSEC module. The actual sign/seal code moved to
libcli/auth/schannel_sign.c in a previous commit.
The schannel credentails structure is now merged with the rest of the
credentails, as many of the values (username, workstation, domain)
where already present there. This makes handling this in a generic
manner much easier, as there is no longer a custom entry-point.
The auth_domain module continues to be developed, but is now just as
functional as auth_winbind. The changes here are consequential to the
schannel changes.
The only removed function at this point is the RPC-LOGIN test
(simulating the load of a WinXP login), which needs much more work to
clean it up (it contains copies of too much code from all over the
torture suite, and I havn't been able to penetrate its 'structure').
Andrew Bartlett
(This used to be commit 2301a4b38a21aa60917973451687063d83d18d66)
2005-03-24 07:14:06 +03:00
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
break ;
case GSS_SPNEGO_SERVER :
case SQUID_2_5_NTLMSSP :
2009-02-13 02:24:16 +03:00
{
const char * winbind_method [ ] = { " winbind " , NULL } ;
2011-05-07 10:14:06 +04:00
struct auth4_context * auth_context ;
2009-02-13 02:24:16 +03:00
2011-10-13 13:01:56 +04:00
msg = imessaging_client_init ( state , lp_ctx , ev ) ;
2006-07-31 18:05:08 +04:00
if ( ! msg ) {
2009-06-18 13:16:16 +04:00
talloc_free ( mem_ctx ) ;
2006-07-31 18:05:08 +04:00
exit ( 1 ) ;
}
2009-02-13 02:24:16 +03:00
nt_status = auth_context_create_methods ( mem_ctx ,
winbind_method ,
ev ,
msg ,
lp_ctx ,
2010-04-15 05:58:05 +04:00
NULL ,
2009-02-13 02:24:16 +03:00
& auth_context ) ;
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
2009-06-18 13:16:16 +04:00
talloc_free ( mem_ctx ) ;
2009-02-13 02:24:16 +03:00
exit ( 1 ) ;
}
2011-10-17 11:22:33 +04:00
if ( ! NT_STATUS_IS_OK ( gensec_server_start ( state ,
2010-07-16 08:32:42 +04:00
lpcfg_gensec_settings ( state , lp_ctx ) ,
2009-02-13 02:24:16 +03:00
auth_context , & state - > gensec_state ) ) ) {
2009-06-18 13:16:16 +04:00
talloc_free ( mem_ctx ) ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
exit ( 1 ) ;
}
break ;
2009-02-13 02:24:16 +03:00
}
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
default :
2009-06-18 13:16:16 +04:00
talloc_free ( mem_ctx ) ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
abort ( ) ;
}
2005-08-30 05:19:41 +04:00
creds = cli_credentials_init ( state - > gensec_state ) ;
2007-12-03 17:53:07 +03:00
cli_credentials_set_conf ( creds , lp_ctx ) ;
2005-08-30 05:19:41 +04:00
if ( opt_username ) {
cli_credentials_set_username ( creds , opt_username , CRED_SPECIFIED ) ;
}
if ( opt_domain ) {
cli_credentials_set_domain ( creds , opt_domain , CRED_SPECIFIED ) ;
}
if ( state - > set_password ) {
cli_credentials_set_password ( creds , state - > set_password , CRED_SPECIFIED ) ;
} else {
2013-07-31 15:24:21 +04:00
void * cb = ( void * ) ( uintptr_t ) mux_id ;
cli_credentials_set_callback_data ( creds , cb ) ;
2005-08-30 05:19:41 +04:00
cli_credentials_set_password_callback ( creds , get_password ) ;
}
if ( opt_workstation ) {
cli_credentials_set_workstation ( creds , opt_workstation , CRED_SPECIFIED ) ;
}
2005-10-20 07:47:55 +04:00
switch ( stdio_helper_mode ) {
case GSS_SPNEGO_SERVER :
case SQUID_2_5_NTLMSSP :
2007-12-14 00:46:17 +03:00
cli_credentials_set_machine_account ( creds , lp_ctx ) ;
2005-10-20 07:47:55 +04:00
break ;
default :
break ;
}
2005-08-30 05:19:41 +04:00
gensec_set_credentials ( state - > gensec_state , creds ) ;
2006-08-17 04:44:29 +04:00
gensec_want_feature_list ( state - > gensec_state , want_feature_list ) ;
2005-08-30 05:19:41 +04:00
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
switch ( stdio_helper_mode ) {
case GSS_SPNEGO_CLIENT :
case GSS_SPNEGO_SERVER :
2005-08-30 05:19:41 +04:00
nt_status = gensec_start_mech_by_oid ( state - > gensec_state , GENSEC_OID_SPNEGO ) ;
2004-11-05 07:26:48 +03:00
if ( ! in . length ) {
2007-10-02 02:13:02 +04:00
first = true ;
2004-11-05 07:26:48 +03:00
}
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
break ;
case NTLMSSP_CLIENT_1 :
2004-11-05 07:26:48 +03:00
if ( ! in . length ) {
2007-10-02 02:13:02 +04:00
first = true ;
2004-11-05 07:26:48 +03:00
}
2006-04-08 06:58:54 +04:00
/* fall through */
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
case SQUID_2_5_NTLMSSP :
2005-08-30 05:19:41 +04:00
nt_status = gensec_start_mech_by_oid ( state - > gensec_state , GENSEC_OID_NTLMSSP ) ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
break ;
default :
2009-06-18 13:16:16 +04:00
talloc_free ( mem_ctx ) ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
abort ( ) ;
2004-06-19 12:15:41 +04:00
}
2004-06-20 04:58:09 +04:00
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
r6028: A MAJOR update to intergrate the new credentails system fully with
GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'.
GENSEC now no longer has it's own handling of 'set username' etc,
instead it uses cli_credentials calls.
In order to link the credentails code right though Samba, a lot of
interfaces have changed to remove 'username, domain, password'
arguments, and these have been replaced with a single 'struct
cli_credentials'.
In the session setup code, a new parameter 'workgroup' contains the
client/server current workgroup, which seems unrelated to the
authentication exchange (it was being filled in from the auth info).
This allows in particular kerberos to only call back for passwords
when it actually needs to perform the kinit.
The kerberos code has been modified not to use the SPNEGO provided
'principal name' (in the mechListMIC), but to instead use the name the
host was connected to as. This better matches Microsoft behaviour,
is more secure and allows better use of standard kerberos functions.
To achieve this, I made changes to our socket code so that the
hostname (before name resolution) is now recorded on the socket.
In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now
in libcli/auth/schannel.c, and it looks much more like a standard
GENSEC module. The actual sign/seal code moved to
libcli/auth/schannel_sign.c in a previous commit.
The schannel credentails structure is now merged with the rest of the
credentails, as many of the values (username, workstation, domain)
where already present there. This makes handling this in a generic
manner much easier, as there is no longer a custom entry-point.
The auth_domain module continues to be developed, but is now just as
functional as auth_winbind. The changes here are consequential to the
schannel changes.
The only removed function at this point is the RPC-LOGIN test
(simulating the load of a WinXP login), which needs much more work to
clean it up (it contains copies of too much code from all over the
torture suite, and I havn't been able to penetrate its 'structure').
Andrew Bartlett
(This used to be commit 2301a4b38a21aa60917973451687063d83d18d66)
2005-03-24 07:14:06 +03:00
DEBUG ( 1 , ( " GENSEC mech failed to start: %s \n " , nt_errstr ( nt_status ) ) ) ;
2008-03-20 02:42:42 +03:00
mux_printf ( mux_id , " BH GENSEC mech failed to start \n " ) ;
2009-06-18 13:16:16 +04:00
talloc_free ( mem_ctx ) ;
2004-06-20 04:58:09 +04:00
return ;
}
2005-08-30 05:19:41 +04:00
2004-06-19 12:15:41 +04:00
}
2005-08-30 05:19:41 +04:00
/* update */
2009-06-18 13:16:16 +04:00
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
if ( strncmp ( buf , " PW " , 3 ) = = 0 ) {
2005-08-30 05:19:41 +04:00
state - > set_password = talloc_strndup ( state ,
( const char * ) in . data ,
in . length ) ;
cli_credentials_set_password ( gensec_get_credentials ( state - > gensec_state ) ,
state - > set_password ,
r6028: A MAJOR update to intergrate the new credentails system fully with
GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'.
GENSEC now no longer has it's own handling of 'set username' etc,
instead it uses cli_credentials calls.
In order to link the credentails code right though Samba, a lot of
interfaces have changed to remove 'username, domain, password'
arguments, and these have been replaced with a single 'struct
cli_credentials'.
In the session setup code, a new parameter 'workgroup' contains the
client/server current workgroup, which seems unrelated to the
authentication exchange (it was being filled in from the auth info).
This allows in particular kerberos to only call back for passwords
when it actually needs to perform the kinit.
The kerberos code has been modified not to use the SPNEGO provided
'principal name' (in the mechListMIC), but to instead use the name the
host was connected to as. This better matches Microsoft behaviour,
is more secure and allows better use of standard kerberos functions.
To achieve this, I made changes to our socket code so that the
hostname (before name resolution) is now recorded on the socket.
In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now
in libcli/auth/schannel.c, and it looks much more like a standard
GENSEC module. The actual sign/seal code moved to
libcli/auth/schannel_sign.c in a previous commit.
The schannel credentails structure is now merged with the rest of the
credentails, as many of the values (username, workstation, domain)
where already present there. This makes handling this in a generic
manner much easier, as there is no longer a custom entry-point.
The auth_domain module continues to be developed, but is now just as
functional as auth_winbind. The changes here are consequential to the
schannel changes.
The only removed function at this point is the RPC-LOGIN test
(simulating the load of a WinXP login), which needs much more work to
clean it up (it contains copies of too much code from all over the
torture suite, and I havn't been able to penetrate its 'structure').
Andrew Bartlett
(This used to be commit 2301a4b38a21aa60917973451687063d83d18d66)
2005-03-24 07:14:06 +03:00
CRED_SPECIFIED ) ;
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " OK \n " ) ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
data_blob_free ( & in ) ;
2005-08-30 05:19:41 +04:00
talloc_free ( mem_ctx ) ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
return ;
}
2004-11-06 04:20:28 +03:00
if ( strncmp ( buf , " UG " , 2 ) = = 0 ) {
int i ;
char * grouplist = NULL ;
struct auth_session_info * session_info ;
2011-08-01 09:39:01 +04:00
nt_status = gensec_session_info ( state - > gensec_state , mem_ctx , & session_info ) ;
2006-04-02 15:18:34 +04:00
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
2004-11-06 04:20:28 +03:00
DEBUG ( 1 , ( " gensec_session_info failed: %s \n " , nt_errstr ( nt_status ) ) ) ;
mux_printf ( mux_id , " BH %s \n " , nt_errstr ( nt_status ) ) ;
data_blob_free ( & in ) ;
2005-08-30 05:19:41 +04:00
talloc_free ( mem_ctx ) ;
2004-11-06 04:20:28 +03:00
return ;
}
/* get the string onto the context */
2005-08-02 02:04:25 +04:00
grouplist = talloc_strdup ( mem_ctx , " " ) ;
2004-11-06 04:20:28 +03:00
2004-12-11 08:41:19 +03:00
for ( i = 0 ; i < session_info - > security_token - > num_sids ; i + + ) {
struct security_token * token = session_info - > security_token ;
const char * sidstr = dom_sid_string ( session_info ,
2010-08-20 06:15:15 +04:00
& token - > sids [ i ] ) ;
2007-09-15 03:21:00 +04:00
grouplist = talloc_asprintf_append_buffer ( grouplist , " %s, " , sidstr ) ;
2004-11-06 04:20:28 +03:00
}
mux_printf ( mux_id , " GL %s \n " , grouplist ) ;
2005-01-09 15:55:25 +03:00
talloc_free ( session_info ) ;
2004-11-06 04:20:28 +03:00
data_blob_free ( & in ) ;
2005-08-02 02:04:25 +04:00
talloc_free ( mem_ctx ) ;
2004-11-06 04:20:28 +03:00
return ;
}
2006-08-17 04:44:29 +04:00
if ( strncmp ( buf , " GK " , 2 ) = = 0 ) {
char * base64_key ;
DEBUG ( 10 , ( " Requested session key \n " ) ) ;
2011-08-01 09:39:01 +04:00
nt_status = gensec_session_key ( state - > gensec_state , mem_ctx , & session_key ) ;
2006-08-17 04:44:29 +04:00
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
DEBUG ( 1 , ( " gensec_session_key failed: %s \n " , nt_errstr ( nt_status ) ) ) ;
mux_printf ( mux_id , " BH No session key \n " ) ;
talloc_free ( mem_ctx ) ;
return ;
} else {
base64_key = base64_encode_data_blob ( state , session_key ) ;
mux_printf ( mux_id , " GK %s \n " , base64_key ) ;
talloc_free ( base64_key ) ;
}
talloc_free ( mem_ctx ) ;
return ;
}
if ( strncmp ( buf , " GF " , 2 ) = = 0 ) {
2009-12-30 19:57:54 +03:00
struct ntlmssp_state * ntlmssp_state ;
2006-08-17 04:44:29 +04:00
uint32_t neg_flags ;
2009-12-30 19:57:54 +03:00
ntlmssp_state = talloc_get_type ( state - > gensec_state - > private_data ,
struct ntlmssp_state ) ;
neg_flags = ntlmssp_state - > neg_flags ;
2006-08-17 04:44:29 +04:00
DEBUG ( 10 , ( " Requested negotiated feature flags \n " ) ) ;
mux_printf ( mux_id , " GF 0x%08x \n " , neg_flags ) ;
return ;
}
2013-12-13 22:37:32 +04:00
nt_status = gensec_update_ev ( state - > gensec_state , mem_ctx , ev , in , & out ) ;
2004-06-20 04:58:09 +04:00
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
/* don't leak 'bad password'/'no such user' info to the network client */
2011-03-03 03:05:33 +03:00
nt_status = nt_status_squash ( nt_status ) ;
2004-06-19 12:15:41 +04:00
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
if ( out . length ) {
2005-08-02 02:04:25 +04:00
out_base64 = base64_encode_data_blob ( mem_ctx , out ) ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
} else {
out_base64 = NULL ;
}
2005-08-02 02:04:25 +04:00
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
if ( NT_STATUS_EQUAL ( nt_status , NT_STATUS_MORE_PROCESSING_REQUIRED ) ) {
reply_arg = " * " ;
2004-06-20 04:58:09 +04:00
if ( first ) {
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
reply_code = " YR " ;
2005-08-30 05:19:41 +04:00
} else if ( state - > gensec_state - > gensec_role = = GENSEC_CLIENT ) {
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
reply_code = " KK " ;
2005-08-30 05:19:41 +04:00
} else if ( state - > gensec_state - > gensec_role = = GENSEC_SERVER ) {
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
reply_code = " TT " ;
} else {
abort ( ) ;
2004-06-19 12:15:41 +04:00
}
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
} else if ( NT_STATUS_EQUAL ( nt_status , NT_STATUS_ACCESS_DENIED ) ) {
2008-03-20 02:42:42 +03:00
reply_code = " BH NT_STATUS_ACCESS_DENIED " ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
reply_arg = nt_errstr ( nt_status ) ;
DEBUG ( 1 , ( " GENSEC login failed: %s \n " , nt_errstr ( nt_status ) ) ) ;
} else if ( NT_STATUS_EQUAL ( nt_status , NT_STATUS_UNSUCCESSFUL ) ) {
2008-03-20 02:42:42 +03:00
reply_code = " BH NT_STATUS_UNSUCCESSFUL " ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
reply_arg = nt_errstr ( nt_status ) ;
DEBUG ( 1 , ( " GENSEC login failed: %s \n " , nt_errstr ( nt_status ) ) ) ;
2004-06-20 04:58:09 +04:00
} else if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
reply_code = " NA " ;
reply_arg = nt_errstr ( nt_status ) ;
DEBUG ( 1 , ( " GENSEC login failed: %s \n " , nt_errstr ( nt_status ) ) ) ;
2005-08-30 05:19:41 +04:00
} else if /* OK */ ( state - > gensec_state - > gensec_role = = GENSEC_SERVER ) {
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
struct auth_session_info * session_info ;
2011-08-01 09:39:01 +04:00
nt_status = gensec_session_info ( state - > gensec_state , mem_ctx , & session_info ) ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
2008-03-20 02:42:42 +03:00
reply_code = " BH Failed to retrive session info " ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
reply_arg = nt_errstr ( nt_status ) ;
2010-02-21 09:35:11 +03:00
DEBUG ( 1 , ( " GENSEC failed to retrieve the session info: %s \n " , nt_errstr ( nt_status ) ) ) ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
} else {
reply_code = " AF " ;
2005-08-30 05:19:41 +04:00
reply_arg = talloc_asprintf ( state - > gensec_state ,
2011-02-08 08:53:13 +03:00
" %s%s%s " , session_info - > info - > domain_name ,
lpcfg_winbind_separator ( lp_ctx ) , session_info - > info - > account_name ) ;
2004-09-26 05:43:05 +04:00
talloc_free ( session_info ) ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
}
2005-08-30 05:19:41 +04:00
} else if ( state - > gensec_state - > gensec_role = = GENSEC_CLIENT ) {
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
reply_code = " AF " ;
2005-08-19 02:36:12 +04:00
reply_arg = out_base64 ;
2004-06-20 04:58:09 +04:00
} else {
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
abort ( ) ;
2004-06-19 12:15:41 +04:00
}
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
switch ( stdio_helper_mode ) {
case GSS_SPNEGO_SERVER :
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " %s %s %s \n " , reply_code ,
2004-09-25 06:54:56 +04:00
out_base64 ? out_base64 : " * " ,
reply_arg ? reply_arg : " * " ) ;
2004-09-25 07:39:35 +04:00
break ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
default :
if ( out_base64 ) {
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " %s %s \n " , reply_code , out_base64 ) ;
2004-07-06 06:56:26 +04:00
} else if ( reply_arg ) {
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " %s %s \n " , reply_code , reply_arg ) ;
2004-07-06 06:56:26 +04:00
} else {
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " %s \n " , reply_code ) ;
r1294: A nice, large, commit...
This implements gensec for Samba's server side, and brings gensec up
to the standards of a full subsystem.
This means that use of the subsystem is by gensec_* functions, not
function pointers in structures (this is internal). This causes
changes in all the existing gensec users.
Our RPC server no longer contains it's own generalised security
scheme, and now calls gensec directly.
Gensec has also taken over the role of auth/auth_ntlmssp.c
An important part of gensec, is the output of the 'session_info'
struct. This is now reference counted, so that we can correctly free
it when a pipe is closed, no matter if it was inherited, or created by
per-pipe authentication.
The schannel code is reworked, to be in the same file for client and
server.
ntlm_auth is reworked to use gensec.
The major problem with this code is the way it relies on subsystem
auto-initialisation. The primary reason for this commit now.is to
allow these problems to be looked at, and fixed.
There are problems with the new code:
- I've tested it with smbtorture, but currently don't have VMware and
valgrind working (this I'll fix soon).
- The SPNEGO code is client-only at this point.
- We still do not do kerberos.
Andrew Bartlett
(This used to be commit 07fd885fd488fd1051eacc905a2d4962f8a018ec)
2004-06-29 13:40:10 +04:00
}
}
2005-08-02 02:04:25 +04:00
talloc_free ( mem_ctx ) ;
2004-06-19 12:15:41 +04:00
return ;
}
static void manage_ntlm_server_1_request ( enum stdio_helper_mode stdio_helper_mode ,
2007-12-02 21:27:49 +03:00
struct loadparm_context * lp_ctx ,
2009-02-02 10:42:16 +03:00
char * buf , int length , void * * private1 ,
r6028: A MAJOR update to intergrate the new credentails system fully with
GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'.
GENSEC now no longer has it's own handling of 'set username' etc,
instead it uses cli_credentials calls.
In order to link the credentails code right though Samba, a lot of
interfaces have changed to remove 'username, domain, password'
arguments, and these have been replaced with a single 'struct
cli_credentials'.
In the session setup code, a new parameter 'workgroup' contains the
client/server current workgroup, which seems unrelated to the
authentication exchange (it was being filled in from the auth info).
This allows in particular kerberos to only call back for passwords
when it actually needs to perform the kinit.
The kerberos code has been modified not to use the SPNEGO provided
'principal name' (in the mechListMIC), but to instead use the name the
host was connected to as. This better matches Microsoft behaviour,
is more secure and allows better use of standard kerberos functions.
To achieve this, I made changes to our socket code so that the
hostname (before name resolution) is now recorded on the socket.
In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now
in libcli/auth/schannel.c, and it looks much more like a standard
GENSEC module. The actual sign/seal code moved to
libcli/auth/schannel_sign.c in a previous commit.
The schannel credentails structure is now merged with the rest of the
credentails, as many of the values (username, workstation, domain)
where already present there. This makes handling this in a generic
manner much easier, as there is no longer a custom entry-point.
The auth_domain module continues to be developed, but is now just as
functional as auth_winbind. The changes here are consequential to the
schannel changes.
The only removed function at this point is the RPC-LOGIN test
(simulating the load of a WinXP login), which needs much more work to
clean it up (it contains copies of too much code from all over the
torture suite, and I havn't been able to penetrate its 'structure').
Andrew Bartlett
(This used to be commit 2301a4b38a21aa60917973451687063d83d18d66)
2005-03-24 07:14:06 +03:00
unsigned int mux_id , void * * private2 )
2004-06-19 12:15:41 +04:00
{
char * request , * parameter ;
static DATA_BLOB challenge ;
static DATA_BLOB lm_response ;
static DATA_BLOB nt_response ;
static char * full_username ;
static char * username ;
static char * domain ;
static char * plaintext_password ;
2007-10-02 02:13:02 +04:00
static bool ntlm_server_1_user_session_key ;
static bool ntlm_server_1_lm_session_key ;
2004-06-19 12:15:41 +04:00
if ( strequal ( buf , " . " ) ) {
if ( ! full_username & & ! username ) {
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " Error: No username supplied! \n " ) ;
2004-06-19 12:15:41 +04:00
} else if ( plaintext_password ) {
/* handle this request as plaintext */
if ( ! full_username ) {
2010-07-16 08:32:42 +04:00
if ( asprintf ( & full_username , " %s%c%s " , domain , * lpcfg_winbind_separator ( lp_ctx ) , username ) < 0 ) {
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " Error: Out of memory in asprintf! \n . \n " ) ;
2004-06-19 12:15:41 +04:00
return ;
}
}
2007-10-02 02:13:02 +04:00
if ( check_plaintext_auth ( full_username , plaintext_password , false ) ) {
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " Authenticated: Yes \n " ) ;
2004-06-19 12:15:41 +04:00
} else {
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " Authenticated: No \n " ) ;
2004-06-19 12:15:41 +04:00
}
} else if ( ! lm_response . data & & ! nt_response . data ) {
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " Error: No password supplied! \n " ) ;
2004-06-19 12:15:41 +04:00
} else if ( ! challenge . data ) {
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " Error: No lanman-challenge supplied! \n " ) ;
2004-06-19 12:15:41 +04:00
} else {
char * error_string = NULL ;
DATA_BLOB lm_key ;
DATA_BLOB user_session_key ;
2005-02-10 08:09:35 +03:00
uint32_t flags = 0 ;
2004-06-19 12:15:41 +04:00
if ( full_username & & ! username ) {
2008-10-22 06:25:00 +04:00
SAFE_FREE ( username ) ;
SAFE_FREE ( domain ) ;
if ( ! parse_ntlm_auth_domain_user ( full_username , & username ,
& domain ,
2010-07-16 08:32:42 +04:00
* lpcfg_winbind_separator ( lp_ctx ) ) ) {
2004-06-19 12:15:41 +04:00
/* username might be 'tainted', don't print into our new-line deleimianted stream */
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " Error: Could not parse into domain and username \n " ) ;
2004-06-19 12:15:41 +04:00
}
}
if ( ! domain ) {
2010-07-16 08:32:42 +04:00
domain = smb_xstrdup ( lpcfg_workgroup ( lp_ctx ) ) ;
2004-06-19 12:15:41 +04:00
}
if ( ntlm_server_1_lm_session_key )
flags | = NTLM_AUTH_FLAG_LMKEY ;
if ( ntlm_server_1_user_session_key )
flags | = NTLM_AUTH_FLAG_USER_SESSION_KEY ;
if ( ! NT_STATUS_IS_OK (
2007-12-02 21:27:49 +03:00
local_pw_check_specified ( lp_ctx ,
2007-12-02 19:56:09 +03:00
username ,
2004-06-19 12:15:41 +04:00
domain ,
2010-07-16 08:32:42 +04:00
lpcfg_netbios_name ( lp_ctx ) ,
2004-06-19 12:15:41 +04:00
& challenge ,
& lm_response ,
& nt_response ,
flags ,
& lm_key ,
& user_session_key ,
& error_string ,
NULL ) ) ) {
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " Authenticated: No \n " ) ;
mux_printf ( mux_id , " Authentication-Error: %s \n . \n " , error_string ) ;
2004-06-19 12:15:41 +04:00
SAFE_FREE ( error_string ) ;
} else {
static char zeros [ 16 ] ;
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " Authenticated: Yes \n " ) ;
2004-06-19 12:15:41 +04:00
if ( ntlm_server_1_lm_session_key
& & lm_key . length
& & ( memcmp ( zeros , lm_key . data ,
lm_key . length ) ! = 0 ) ) {
2015-05-08 13:12:21 +03:00
char hex_lm_key [ lm_key . length * 2 + 1 ] ;
hex_encode_buf ( hex_lm_key , lm_key . data ,
lm_key . length ) ;
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " LANMAN-Session-Key: %s \n " , hex_lm_key ) ;
2004-06-19 12:15:41 +04:00
}
if ( ntlm_server_1_user_session_key
& & user_session_key . length
& & ( memcmp ( zeros , user_session_key . data ,
user_session_key . length ) ! = 0 ) ) {
2015-05-08 13:12:21 +03:00
char hex_user_session_key [
user_session_key . length * 2 + 1 ] ;
hex_encode_buf ( hex_user_session_key ,
user_session_key . data ,
user_session_key . length ) ;
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " User-Session-Key: %s \n " , hex_user_session_key ) ;
2004-06-19 12:15:41 +04:00
}
}
}
/* clear out the state */
challenge = data_blob ( NULL , 0 ) ;
nt_response = data_blob ( NULL , 0 ) ;
lm_response = data_blob ( NULL , 0 ) ;
SAFE_FREE ( full_username ) ;
SAFE_FREE ( username ) ;
SAFE_FREE ( domain ) ;
SAFE_FREE ( plaintext_password ) ;
2007-10-02 02:13:02 +04:00
ntlm_server_1_user_session_key = false ;
ntlm_server_1_lm_session_key = false ;
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " . \n " ) ;
2004-06-19 12:15:41 +04:00
return ;
}
request = buf ;
/* Indicates a base64 encoded structure */
parameter = strstr ( request , " :: " ) ;
if ( ! parameter ) {
parameter = strstr ( request , " : " ) ;
if ( ! parameter ) {
DEBUG ( 0 , ( " Parameter not found! \n " ) ) ;
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " Error: Parameter not found! \n . \n " ) ;
2004-06-19 12:15:41 +04:00
return ;
}
parameter [ 0 ] = ' \0 ' ;
parameter + + ;
parameter [ 0 ] = ' \0 ' ;
parameter + + ;
} else {
parameter [ 0 ] = ' \0 ' ;
parameter + + ;
parameter [ 0 ] = ' \0 ' ;
parameter + + ;
parameter [ 0 ] = ' \0 ' ;
parameter + + ;
base64_decode_inplace ( parameter ) ;
}
if ( strequal ( request , " LANMAN-Challenge " ) ) {
2008-10-18 20:09:04 +04:00
challenge = strhex_to_data_blob ( NULL , parameter ) ;
2004-06-19 12:15:41 +04:00
if ( challenge . length ! = 8 ) {
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " Error: hex decode of %s failed! (got %d bytes, expected 8) \n . \n " ,
2004-06-19 12:15:41 +04:00
parameter ,
( int ) challenge . length ) ;
challenge = data_blob ( NULL , 0 ) ;
}
} else if ( strequal ( request , " NT-Response " ) ) {
2008-10-18 20:09:04 +04:00
nt_response = strhex_to_data_blob ( NULL , parameter ) ;
2004-06-19 12:15:41 +04:00
if ( nt_response . length < 24 ) {
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " Error: hex decode of %s failed! (only got %d bytes, needed at least 24) \n . \n " ,
2004-06-19 12:15:41 +04:00
parameter ,
( int ) nt_response . length ) ;
nt_response = data_blob ( NULL , 0 ) ;
}
} else if ( strequal ( request , " LANMAN-Response " ) ) {
2008-10-18 20:09:04 +04:00
lm_response = strhex_to_data_blob ( NULL , parameter ) ;
2004-06-19 12:15:41 +04:00
if ( lm_response . length ! = 24 ) {
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " Error: hex decode of %s failed! (got %d bytes, expected 24) \n . \n " ,
2004-06-19 12:15:41 +04:00
parameter ,
( int ) lm_response . length ) ;
lm_response = data_blob ( NULL , 0 ) ;
}
} else if ( strequal ( request , " Password " ) ) {
plaintext_password = smb_xstrdup ( parameter ) ;
} else if ( strequal ( request , " NT-Domain " ) ) {
domain = smb_xstrdup ( parameter ) ;
} else if ( strequal ( request , " Username " ) ) {
username = smb_xstrdup ( parameter ) ;
} else if ( strequal ( request , " Full-Username " ) ) {
full_username = smb_xstrdup ( parameter ) ;
} else if ( strequal ( request , " Request-User-Session-Key " ) ) {
ntlm_server_1_user_session_key = strequal ( parameter , " Yes " ) ;
} else if ( strequal ( request , " Request-LanMan-Session-Key " ) ) {
ntlm_server_1_lm_session_key = strequal ( parameter , " Yes " ) ;
} else {
2004-11-05 07:26:48 +03:00
mux_printf ( mux_id , " Error: Unknown request %s \n . \n " , request ) ;
2004-06-19 12:15:41 +04:00
}
}
2010-07-16 08:32:42 +04:00
static void manage_squid_request ( struct loadparm_context * lp_ctx , enum stdio_helper_mode helper_mode ,
r6028: A MAJOR update to intergrate the new credentails system fully with
GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'.
GENSEC now no longer has it's own handling of 'set username' etc,
instead it uses cli_credentials calls.
In order to link the credentails code right though Samba, a lot of
interfaces have changed to remove 'username, domain, password'
arguments, and these have been replaced with a single 'struct
cli_credentials'.
In the session setup code, a new parameter 'workgroup' contains the
client/server current workgroup, which seems unrelated to the
authentication exchange (it was being filled in from the auth info).
This allows in particular kerberos to only call back for passwords
when it actually needs to perform the kinit.
The kerberos code has been modified not to use the SPNEGO provided
'principal name' (in the mechListMIC), but to instead use the name the
host was connected to as. This better matches Microsoft behaviour,
is more secure and allows better use of standard kerberos functions.
To achieve this, I made changes to our socket code so that the
hostname (before name resolution) is now recorded on the socket.
In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now
in libcli/auth/schannel.c, and it looks much more like a standard
GENSEC module. The actual sign/seal code moved to
libcli/auth/schannel_sign.c in a previous commit.
The schannel credentails structure is now merged with the rest of the
credentails, as many of the values (username, workstation, domain)
where already present there. This makes handling this in a generic
manner much easier, as there is no longer a custom entry-point.
The auth_domain module continues to be developed, but is now just as
functional as auth_winbind. The changes here are consequential to the
schannel changes.
The only removed function at this point is the RPC-LOGIN test
(simulating the load of a WinXP login), which needs much more work to
clean it up (it contains copies of too much code from all over the
torture suite, and I havn't been able to penetrate its 'structure').
Andrew Bartlett
(This used to be commit 2301a4b38a21aa60917973451687063d83d18d66)
2005-03-24 07:14:06 +03:00
stdio_helper_function fn , void * * private2 )
2003-08-13 05:53:07 +04:00
{
2007-08-30 10:45:11 +04:00
char * buf ;
char tmp [ INITIAL_BUFFER_SIZE + 1 ] ;
2006-04-02 15:18:34 +04:00
unsigned int mux_id = 0 ;
2007-08-30 13:02:40 +04:00
int length , buf_size = 0 ;
2003-08-13 05:53:07 +04:00
char * c ;
2004-11-05 07:26:48 +03:00
struct mux_private {
unsigned int max_mux ;
void * * private_pointers ;
} ;
2007-08-30 10:45:11 +04:00
2004-11-05 07:26:48 +03:00
static struct mux_private * mux_private ;
static void * normal_private ;
2009-02-02 10:42:16 +03:00
void * * private1 ;
2004-06-19 12:15:41 +04:00
2007-09-18 17:31:55 +04:00
buf = talloc_strdup ( NULL , " " ) ;
2007-08-30 10:45:11 +04:00
if ( buf = = NULL ) {
DEBUG ( 0 , ( " Failed to allocate memory for reading the input "
" buffer. \n " ) ) ;
2004-11-05 07:26:48 +03:00
x_fprintf ( x_stdout , " ERR \n " ) ;
2003-08-13 05:53:07 +04:00
return ;
}
2007-08-30 10:45:11 +04:00
do {
/* this is not a typo - x_fgets doesn't work too well under
* squid */
if ( fgets ( tmp , INITIAL_BUFFER_SIZE , stdin ) = = NULL ) {
if ( ferror ( stdin ) ) {
DEBUG ( 1 , ( " fgets() failed! dying..... errno=%d "
" (%s) \n " , ferror ( stdin ) ,
strerror ( ferror ( stdin ) ) ) ) ;
exit ( 1 ) ; /* BIIG buffer */
}
exit ( 0 ) ;
}
2007-09-18 17:31:55 +04:00
buf = talloc_strdup_append_buffer ( buf , tmp ) ;
2007-08-30 13:02:40 +04:00
buf_size + = INITIAL_BUFFER_SIZE ;
if ( buf_size > MAX_BUFFER_SIZE ) {
DEBUG ( 0 , ( " Invalid Request (too large) \n " ) ) ;
x_fprintf ( x_stdout , " ERR \n " ) ;
talloc_free ( buf ) ;
return ;
}
2007-08-30 10:45:11 +04:00
c = strchr ( buf , ' \n ' ) ;
} while ( c = = NULL ) ;
* c = ' \0 ' ;
length = c - buf ;
2003-08-13 05:53:07 +04:00
DEBUG ( 10 , ( " Got '%s' from squid (length: %d). \n " , buf , length ) ) ;
if ( buf [ 0 ] = = ' \0 ' ) {
2004-11-05 07:26:48 +03:00
DEBUG ( 0 , ( " Invalid Request (empty) \n " ) ) ;
x_fprintf ( x_stdout , " ERR \n " ) ;
2007-08-30 10:45:11 +04:00
talloc_free ( buf ) ;
2003-08-13 05:53:07 +04:00
return ;
}
2004-11-05 07:26:48 +03:00
if ( opt_multiplex ) {
if ( sscanf ( buf , " %u " , & mux_id ) ! = 1 ) {
DEBUG ( 0 , ( " Invalid Request - no multiplex id \n " ) ) ;
x_fprintf ( x_stdout , " ERR \n " ) ;
2007-08-30 10:45:11 +04:00
talloc_free ( buf ) ;
2004-11-05 07:26:48 +03:00
return ;
}
if ( ! mux_private ) {
2005-01-27 10:08:20 +03:00
mux_private = talloc ( NULL , struct mux_private ) ;
2004-11-05 07:26:48 +03:00
mux_private - > max_mux = 0 ;
mux_private - > private_pointers = NULL ;
}
r6028: A MAJOR update to intergrate the new credentails system fully with
GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'.
GENSEC now no longer has it's own handling of 'set username' etc,
instead it uses cli_credentials calls.
In order to link the credentails code right though Samba, a lot of
interfaces have changed to remove 'username, domain, password'
arguments, and these have been replaced with a single 'struct
cli_credentials'.
In the session setup code, a new parameter 'workgroup' contains the
client/server current workgroup, which seems unrelated to the
authentication exchange (it was being filled in from the auth info).
This allows in particular kerberos to only call back for passwords
when it actually needs to perform the kinit.
The kerberos code has been modified not to use the SPNEGO provided
'principal name' (in the mechListMIC), but to instead use the name the
host was connected to as. This better matches Microsoft behaviour,
is more secure and allows better use of standard kerberos functions.
To achieve this, I made changes to our socket code so that the
hostname (before name resolution) is now recorded on the socket.
In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now
in libcli/auth/schannel.c, and it looks much more like a standard
GENSEC module. The actual sign/seal code moved to
libcli/auth/schannel_sign.c in a previous commit.
The schannel credentails structure is now merged with the rest of the
credentails, as many of the values (username, workstation, domain)
where already present there. This makes handling this in a generic
manner much easier, as there is no longer a custom entry-point.
The auth_domain module continues to be developed, but is now just as
functional as auth_winbind. The changes here are consequential to the
schannel changes.
The only removed function at this point is the RPC-LOGIN test
(simulating the load of a WinXP login), which needs much more work to
clean it up (it contains copies of too much code from all over the
torture suite, and I havn't been able to penetrate its 'structure').
Andrew Bartlett
(This used to be commit 2301a4b38a21aa60917973451687063d83d18d66)
2005-03-24 07:14:06 +03:00
c = strchr ( buf , ' ' ) ;
if ( ! c ) {
DEBUG ( 0 , ( " Invalid Request - no data after multiplex id \n " ) ) ;
x_fprintf ( x_stdout , " ERR \n " ) ;
2007-08-30 10:45:11 +04:00
talloc_free ( buf ) ;
r6028: A MAJOR update to intergrate the new credentails system fully with
GENSEC, and to pull SCHANNEL into GENSEC, by making it less 'special'.
GENSEC now no longer has it's own handling of 'set username' etc,
instead it uses cli_credentials calls.
In order to link the credentails code right though Samba, a lot of
interfaces have changed to remove 'username, domain, password'
arguments, and these have been replaced with a single 'struct
cli_credentials'.
In the session setup code, a new parameter 'workgroup' contains the
client/server current workgroup, which seems unrelated to the
authentication exchange (it was being filled in from the auth info).
This allows in particular kerberos to only call back for passwords
when it actually needs to perform the kinit.
The kerberos code has been modified not to use the SPNEGO provided
'principal name' (in the mechListMIC), but to instead use the name the
host was connected to as. This better matches Microsoft behaviour,
is more secure and allows better use of standard kerberos functions.
To achieve this, I made changes to our socket code so that the
hostname (before name resolution) is now recorded on the socket.
In schannel, most of the code from librpc/rpc/dcerpc_schannel.c is now
in libcli/auth/schannel.c, and it looks much more like a standard
GENSEC module. The actual sign/seal code moved to
libcli/auth/schannel_sign.c in a previous commit.
The schannel credentails structure is now merged with the rest of the
credentails, as many of the values (username, workstation, domain)
where already present there. This makes handling this in a generic
manner much easier, as there is no longer a custom entry-point.
The auth_domain module continues to be developed, but is now just as
functional as auth_winbind. The changes here are consequential to the
schannel changes.
The only removed function at this point is the RPC-LOGIN test
(simulating the load of a WinXP login), which needs much more work to
clean it up (it contains copies of too much code from all over the
torture suite, and I havn't been able to penetrate its 'structure').
Andrew Bartlett
(This used to be commit 2301a4b38a21aa60917973451687063d83d18d66)
2005-03-24 07:14:06 +03:00
return ;
}
2004-11-05 07:26:48 +03:00
c + + ;
if ( mux_id > = mux_private - > max_mux ) {
unsigned int prev_max = mux_private - > max_mux ;
mux_private - > max_mux = mux_id + 1 ;
mux_private - > private_pointers
2005-01-27 10:08:20 +03:00
= talloc_realloc ( mux_private ,
2004-11-05 07:26:48 +03:00
mux_private - > private_pointers ,
void * , mux_private - > max_mux ) ;
memset ( & mux_private - > private_pointers [ prev_max ] , ' \0 ' ,
( sizeof ( * mux_private - > private_pointers ) * ( mux_private - > max_mux - prev_max ) ) ) ;
} ;
2009-02-02 10:42:16 +03:00
private1 = & mux_private - > private_pointers [ mux_id ] ;
2004-11-05 07:26:48 +03:00
} else {
c = buf ;
2009-02-02 10:42:16 +03:00
private1 = & normal_private ;
2004-11-05 07:26:48 +03:00
}
2007-08-30 10:45:11 +04:00
2009-02-02 10:42:16 +03:00
fn ( helper_mode , lp_ctx , c , length , private1 , mux_id , private2 ) ;
2007-08-30 10:45:11 +04:00
talloc_free ( buf ) ;
2003-08-13 05:53:07 +04:00
}
2010-07-16 08:32:42 +04:00
static void squid_stream ( struct loadparm_context * lp_ctx ,
2007-12-10 06:33:16 +03:00
enum stdio_helper_mode stdio_mode ,
2004-11-05 07:26:48 +03:00
stdio_helper_function fn ) {
2003-08-13 05:53:07 +04:00
/* initialize FDescs */
x_setbuf ( x_stdout , NULL ) ;
x_setbuf ( x_stderr , NULL ) ;
while ( 1 ) {
2007-12-10 06:33:16 +03:00
manage_squid_request ( lp_ctx , stdio_mode , fn , NULL ) ;
2003-08-13 05:53:07 +04:00
}
}
/* Main program */
enum {
OPT_USERNAME = 1000 ,
OPT_DOMAIN ,
OPT_WORKSTATION ,
OPT_CHALLENGE ,
OPT_RESPONSE ,
OPT_LM ,
OPT_NT ,
2004-06-19 12:15:41 +04:00
OPT_PASSWORD ,
OPT_LM_KEY ,
OPT_USER_SESSION_KEY ,
OPT_DIAGNOSTICS ,
2004-11-05 07:26:48 +03:00
OPT_REQUIRE_MEMBERSHIP ,
OPT_MULTIPLEX ,
2006-11-04 22:38:08 +03:00
OPT_USE_CACHED_CREDS ,
2003-08-13 05:53:07 +04:00
} ;
2005-12-27 17:28:01 +03:00
int main ( int argc , const char * * argv )
2003-08-13 05:53:07 +04:00
{
2007-12-20 02:02:15 +03:00
static const char * helper_protocol ;
2004-06-19 12:15:41 +04:00
int opt ;
2003-08-13 05:53:07 +04:00
2004-06-19 12:15:41 +04:00
poptContext pc ;
2003-08-13 05:53:07 +04:00
2004-06-19 12:15:41 +04:00
/* NOTE: DO NOT change this interface without considering the implications!
This is an external interface , which other programs will use to interact
with this helper .
*/
2003-08-13 05:53:07 +04:00
2004-06-19 12:15:41 +04:00
/* We do not use single-letter command abbreviations, because they harm future
interface stability . */
2003-08-13 05:53:07 +04:00
struct poptOption long_options [ ] = {
POPT_AUTOHELP
{ " helper-protocol " , 0 , POPT_ARG_STRING , & helper_protocol , OPT_DOMAIN , " operate as a stdio-based helper " , " helper protocol to use " } ,
2004-06-19 12:15:41 +04:00
{ " domain " , 0 , POPT_ARG_STRING , & opt_domain , OPT_DOMAIN , " domain name " } ,
{ " workstation " , 0 , POPT_ARG_STRING , & opt_workstation , OPT_WORKSTATION , " workstation " } ,
2004-06-20 04:58:09 +04:00
{ " username " , 0 , POPT_ARG_STRING , & opt_username , OPT_PASSWORD , " Username " } ,
2004-06-19 12:15:41 +04:00
{ " password " , 0 , POPT_ARG_STRING , & opt_password , OPT_PASSWORD , " User's plaintext password " } ,
2004-11-05 07:26:48 +03:00
{ " multiplex " , 0 , POPT_ARG_NONE , & opt_multiplex , OPT_MULTIPLEX , " Multiplex Mode " } ,
2006-11-04 22:38:08 +03:00
{ " use-cached-creds " , 0 , POPT_ARG_NONE , & use_cached_creds , OPT_USE_CACHED_CREDS , " silently ignored for compatibility reasons " } ,
2004-06-19 12:15:41 +04:00
POPT_COMMON_SAMBA
2005-08-19 02:36:12 +04:00
POPT_COMMON_VERSION
2006-09-06 16:28:01 +04:00
{ NULL }
2003-08-13 05:53:07 +04:00
} ;
/* Samba client initialisation */
2005-06-13 12:12:39 +04:00
setup_logging ( NULL , DEBUG_STDERR ) ;
2004-06-19 12:15:41 +04:00
2003-08-13 05:53:07 +04:00
/* Parse options */
pc = poptGetContext ( " ntlm_auth " , argc , argv , long_options , 0 ) ;
/* Parse command line options */
if ( argc = = 1 ) {
poptPrintHelp ( pc , stderr , 0 ) ;
return 1 ;
}
pc = poptGetContext ( NULL , argc , ( const char * * ) argv , long_options ,
POPT_CONTEXT_KEEP_FIRST ) ;
while ( ( opt = poptGetNextOpt ( pc ) ) ! = - 1 ) {
2004-06-19 12:15:41 +04:00
if ( opt < - 1 ) {
2003-08-13 05:53:07 +04:00
break ;
}
}
2004-06-19 12:15:41 +04:00
if ( opt < - 1 ) {
fprintf ( stderr , " %s: %s \n " ,
poptBadOption ( pc , POPT_BADOPTION_NOALIAS ) ,
poptStrerror ( opt ) ) ;
return 1 ;
}
2003-08-13 05:53:07 +04:00
2011-06-06 08:58:28 +04:00
gensec_init ( ) ;
2004-11-09 12:26:47 +03:00
2004-06-20 04:58:09 +04:00
if ( opt_domain = = NULL ) {
2010-07-16 08:32:42 +04:00
opt_domain = lpcfg_workgroup ( cmdline_lp_ctx ) ;
2004-06-20 04:58:09 +04:00
}
2003-08-13 05:53:07 +04:00
if ( helper_protocol ) {
2004-06-19 12:15:41 +04:00
int i ;
for ( i = 0 ; i < NUM_HELPER_MODES ; i + + ) {
if ( strcmp ( helper_protocol , stdio_helper_protocols [ i ] . name ) = = 0 ) {
2007-12-10 06:33:16 +03:00
squid_stream ( cmdline_lp_ctx , stdio_helper_protocols [ i ] . mode , stdio_helper_protocols [ i ] . fn ) ;
2004-06-19 12:15:41 +04:00
exit ( 0 ) ;
}
2003-08-13 05:53:07 +04:00
}
2004-06-19 12:15:41 +04:00
x_fprintf ( x_stderr , " unknown helper protocol [%s] \n \n Valid helper protools: \n \n " , helper_protocol ) ;
for ( i = 0 ; i < NUM_HELPER_MODES ; i + + ) {
x_fprintf ( x_stderr , " %s \n " , stdio_helper_protocols [ i ] . name ) ;
}
exit ( 1 ) ;
2003-08-13 05:53:07 +04:00
}
2004-06-19 12:15:41 +04:00
if ( ! opt_username ) {
x_fprintf ( x_stderr , " username must be specified! \n \n " ) ;
poptPrintHelp ( pc , stderr , 0 ) ;
exit ( 1 ) ;
2003-08-13 05:53:07 +04:00
}
2004-06-19 12:15:41 +04:00
if ( opt_workstation = = NULL ) {
2010-07-16 08:32:42 +04:00
opt_workstation = lpcfg_netbios_name ( cmdline_lp_ctx ) ;
2004-06-19 12:15:41 +04:00
}
if ( ! opt_password ) {
2012-11-23 17:55:48 +04:00
char pwd [ 256 ] = { 0 } ;
int rc ;
rc = samba_getpass ( " Password: " , pwd , sizeof ( pwd ) , false , false ) ;
if ( rc = = 0 ) {
opt_password = smb_xstrdup ( pwd ) ;
}
2004-06-19 12:15:41 +04:00
}
{
char * user ;
2010-05-27 19:41:39 +04:00
if ( asprintf ( & user , " %s%c%s " , opt_domain ,
2010-07-16 08:32:42 +04:00
* lpcfg_winbind_separator ( cmdline_lp_ctx ) ,
2010-05-27 19:41:39 +04:00
opt_username ) < 0 ) {
return 1 ;
}
2007-10-02 02:13:02 +04:00
if ( ! check_plaintext_auth ( user , opt_password , true ) ) {
2004-06-19 12:15:41 +04:00
return 1 ;
2003-08-13 05:53:07 +04:00
}
}
/* Exit code */
poptFreeContext ( pc ) ;
return 0 ;
}