2003-08-13 01:53:07 +00:00
/*
Unix SMB / CIFS implementation .
Standardised Authentication types
2005-01-09 12:55:25 +00:00
Copyright ( C ) Andrew Bartlett 2001
Copyright ( C ) Stefan Metzmacher 2005
2003-08-13 01:53:07 +00:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-10 02:07:03 +00:00
the Free Software Foundation ; either version 3 of the License , or
2003-08-13 01:53:07 +00: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 02:07:03 +00:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2003-08-13 01:53:07 +00:00
*/
2004-02-03 11:10:56 +00:00
# ifndef _SAMBA_AUTH_H
# define _SAMBA_AUTH_H
2007-07-27 06:31:12 +00:00
extern const char * user_attrs [ ] ;
2006-11-07 00:48:36 +00:00
union netr_Validation ;
2006-11-07 12:42:51 +00:00
struct netr_SamBaseInfo ;
struct netr_SamInfo3 ;
2007-12-02 16:20:18 +01:00
struct loadparm_context ;
2004-11-02 02:57:18 +00:00
2004-02-03 11:10:56 +00:00
/* modules can use the following to determine if the interface has changed
* please increment the version number after each interface change
* with a comment and maybe update struct auth_critical_sizes .
*/
/* version 1 - version from samba 3.0 - metze */
/* version 2 - initial samba4 version - metze */
2004-05-02 08:45:00 +00:00
/* version 3 - subsequent samba4 version - abartlet */
2005-01-09 12:55:25 +00:00
/* version 4 - subsequent samba4 version - metze */
2006-07-27 11:24:18 +00:00
/* version 0 - till samba4 is stable - metze */
# define AUTH_INTERFACE_VERSION 0
2003-08-13 01:53:07 +00:00
2005-06-03 12:13:33 +00:00
# define USER_INFO_CASE_INSENSITIVE_USERNAME 0x01 /* username may be in any case */
# define USER_INFO_CASE_INSENSITIVE_PASSWORD 0x02 /* password may be in any case */
# define USER_INFO_DONT_CHECK_UNIX_ACCOUNT 0x04 /* dont check unix account status */
2005-10-28 11:20:48 +00:00
# define USER_INFO_INTERACTIVE_LOGON 0x08 /* dont check unix account status */
2005-06-03 12:13:33 +00:00
2005-07-22 04:10:07 +00:00
enum auth_password_state {
AUTH_PASSWORD_RESPONSE ,
AUTH_PASSWORD_HASH ,
AUTH_PASSWORD_PLAIN
} ;
2004-06-05 01:39:08 +00:00
struct auth_usersupplied_info
2003-08-13 01:53:07 +00:00
{
2005-01-09 12:55:25 +00:00
const char * workstation_name ;
2006-01-09 22:12:53 +00:00
struct socket_address * remote_host ;
2005-01-09 12:55:25 +00:00
2005-10-28 08:54:37 +00:00
uint32_t logon_parameters ;
2007-08-27 18:10:19 +00:00
bool mapped_state ;
2005-01-09 12:55:25 +00:00
/* the values the client gives us */
struct {
const char * account_name ;
const char * domain_name ;
2005-07-22 04:10:07 +00:00
} client , mapped ;
enum auth_password_state password_state ;
union {
struct {
DATA_BLOB lanman ;
DATA_BLOB nt ;
} response ;
struct {
struct samr_Password * lanman ;
struct samr_Password * nt ;
} hash ;
char * plaintext ;
} password ;
2005-06-03 12:13:33 +00:00
uint32_t flags ;
2004-06-05 01:39:08 +00:00
} ;
2003-08-13 01:53:07 +00:00
2004-06-05 01:39:08 +00:00
struct auth_serversupplied_info
2003-08-13 01:53:07 +00:00
{
2005-01-09 12:55:25 +00:00
struct dom_sid * account_sid ;
2004-06-05 01:39:08 +00:00
struct dom_sid * primary_group_sid ;
size_t n_domain_groups ;
struct dom_sid * * domain_groups ;
2005-01-09 12:55:25 +00:00
2004-05-02 08:45:00 +00:00
DATA_BLOB user_session_key ;
2003-12-14 10:45:50 +00:00
DATA_BLOB lm_session_key ;
2004-06-05 03:09:38 +00:00
2004-06-07 03:46:32 +00:00
const char * account_name ;
2005-01-09 12:55:25 +00:00
const char * domain_name ;
2004-06-07 03:46:32 +00:00
const char * full_name ;
const char * logon_script ;
const char * profile_path ;
const char * home_directory ;
const char * home_drive ;
2005-10-24 07:11:40 +00:00
const char * logon_server ;
2004-06-07 03:46:32 +00:00
NTTIME last_logon ;
NTTIME last_logoff ;
NTTIME acct_expiry ;
NTTIME last_password_change ;
NTTIME allow_password_change ;
NTTIME force_password_change ;
2005-01-09 12:55:25 +00:00
2005-01-31 16:06:21 +00:00
uint16_t logon_count ;
uint16_t bad_password_count ;
2005-01-09 12:55:25 +00:00
2005-01-31 16:06:21 +00:00
uint32_t acct_flags ;
2005-01-09 12:55:25 +00:00
2007-08-27 18:10:19 +00:00
bool authenticated ;
2004-06-05 01:39:08 +00:00
} ;
2005-01-09 12:55:25 +00:00
struct auth_method_context ;
2006-07-27 13:02:27 +00:00
struct auth_check_password_request ;
2003-08-13 01:53:07 +00:00
2005-01-09 12:55:25 +00:00
struct auth_operations {
const char * name ;
2003-12-14 10:45:50 +00:00
2005-04-27 00:48:39 +00:00
/* If you are using this interface, then you are probably
* getting something wrong . This interface is only for
* security = server , and makes a number of compromises to allow
* that . It is not compatible with being a PDC . */
2005-01-09 12:55:25 +00:00
NTSTATUS ( * get_challenge ) ( struct auth_method_context * ctx , TALLOC_CTX * mem_ctx , DATA_BLOB * challenge ) ;
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 09:40:10 +00:00
2006-07-27 11:24:18 +00:00
/* Given the user supplied info, check if this backend want to handle the password checking */
NTSTATUS ( * want_check ) ( struct auth_method_context * ctx , TALLOC_CTX * mem_ctx ,
const struct auth_usersupplied_info * user_info ) ;
2005-04-27 00:48:39 +00:00
/* Given the user supplied info, check a password */
2005-01-09 12:55:25 +00:00
NTSTATUS ( * check_password ) ( struct auth_method_context * ctx , TALLOC_CTX * mem_ctx ,
const struct auth_usersupplied_info * user_info ,
struct auth_serversupplied_info * * server_info ) ;
2003-08-13 01:53:07 +00:00
} ;
2005-01-09 12:55:25 +00:00
struct auth_method_context {
struct auth_method_context * prev , * next ;
struct auth_context * auth_ctx ;
const struct auth_operations * ops ;
int depth ;
2003-08-13 01:53:07 +00:00
void * private_data ;
2005-01-09 12:55:25 +00:00
} ;
2003-08-13 01:53:07 +00:00
2005-01-09 12:55:25 +00:00
struct auth_context {
struct {
/* Who set this up in the first place? */
const char * set_by ;
2004-05-02 08:45:00 +00:00
2007-08-27 18:10:19 +00:00
bool may_be_modified ;
2003-08-13 01:53:07 +00:00
2005-01-09 12:55:25 +00:00
DATA_BLOB data ;
} challenge ;
2004-02-03 11:10:56 +00:00
2005-01-09 12:55:25 +00:00
/* methods, in the order they should be called */
struct auth_method_context * methods ;
2005-06-16 11:36:09 +00:00
/* the event context to use for calls that can block */
struct event_context * event_ctx ;
2006-07-31 14:05:08 +00:00
/* the messaging context which can be used by backends */
struct messaging_context * msg_ctx ;
2007-12-02 17:56:09 +01:00
/* loadparm context */
struct loadparm_context * lp_ctx ;
2004-02-03 11:10:56 +00:00
} ;
/* this structure is used by backends to determine the size of some critical types */
struct auth_critical_sizes {
int interface_version ;
int sizeof_auth_operations ;
int sizeof_auth_methods ;
int sizeof_auth_context ;
int sizeof_auth_usersupplied_info ;
int sizeof_auth_serversupplied_info ;
} ;
2005-07-22 04:10:07 +00:00
NTSTATUS encrypt_user_info ( TALLOC_CTX * mem_ctx , struct auth_context * auth_context ,
enum auth_password_state to_state ,
const struct auth_usersupplied_info * user_info_in ,
const struct auth_usersupplied_info * * user_info_encrypted ) ;
2007-11-26 02:25:20 +01:00
# include "auth/session.h"
# include "auth/system_session_proto.h"
2008-04-02 04:53:27 +02:00
struct ldb_message ;
struct ldb_context ;
NTSTATUS auth_get_challenge ( struct auth_context * auth_ctx , const uint8_t * * _chal ) ;
NTSTATUS authsam_account_ok ( TALLOC_CTX * mem_ctx ,
struct ldb_context * sam_ctx ,
uint32_t logon_parameters ,
struct ldb_message * msg ,
struct ldb_message * msg_domain_ref ,
const char * logon_workstation ,
const char * name_for_logs ) ;
struct auth_session_info * system_session ( TALLOC_CTX * mem_ctx , struct loadparm_context * lp_ctx ) ;
NTSTATUS authsam_make_server_info ( TALLOC_CTX * mem_ctx , struct ldb_context * sam_ctx ,
const char * netbios_name ,
struct ldb_message * msg ,
struct ldb_message * msg_domain_ref ,
DATA_BLOB user_sess_key , DATA_BLOB lm_sess_key ,
struct auth_serversupplied_info * * _server_info ) ;
NTSTATUS auth_system_session_info ( TALLOC_CTX * parent_ctx ,
struct loadparm_context * lp_ctx ,
struct auth_session_info * * _session_info ) ;
NTSTATUS auth_nt_status_squash ( NTSTATUS nt_status ) ;
NTSTATUS auth_context_create_methods ( TALLOC_CTX * mem_ctx , const char * * methods ,
struct event_context * ev ,
struct messaging_context * msg ,
struct loadparm_context * lp_ctx ,
struct auth_context * * auth_ctx ) ;
NTSTATUS auth_context_create ( TALLOC_CTX * mem_ctx ,
struct event_context * ev ,
struct messaging_context * msg ,
struct loadparm_context * lp_ctx ,
struct auth_context * * auth_ctx ) ;
NTSTATUS auth_check_password ( struct auth_context * auth_ctx ,
TALLOC_CTX * mem_ctx ,
const struct auth_usersupplied_info * user_info ,
struct auth_serversupplied_info * * server_info ) ;
NTSTATUS auth_init ( void ) ;
NTSTATUS auth_register ( const struct auth_operations * ops ) ;
NTSTATUS authenticate_username_pw ( TALLOC_CTX * mem_ctx ,
struct event_context * ev ,
struct messaging_context * msg ,
struct loadparm_context * lp_ctx ,
const char * nt4_domain ,
const char * nt4_username ,
const char * password ,
struct auth_session_info * * session_info ) ;
NTSTATUS auth_check_password_recv ( struct auth_check_password_request * req ,
TALLOC_CTX * mem_ctx ,
struct auth_serversupplied_info * * server_info ) ;
void auth_check_password_send ( struct auth_context * auth_ctx ,
const struct auth_usersupplied_info * user_info ,
void ( * callback ) ( struct auth_check_password_request * req , void * private_data ) ,
void * private_data ) ;
NTSTATUS auth_context_set_challenge ( struct auth_context * auth_ctx , const uint8_t chal [ 8 ] , const char * set_by ) ;
2005-07-22 04:10:07 +00:00
2004-05-02 08:45:00 +00:00
# endif /* _SMBAUTH_H_ */