This is my 'Authentication Rewrite' version 1.01, mostly as submitted to
samba-technical a few weeks ago.
The idea here is to standardize the checking of user names and passwords,
thereby ensuring that all authtentications pass the same standards. The
interface currently implemented in as
nt_status = check_password(user_info, server_info)
where user_info contains (mostly) the authentication data, and server_info
contains things like the user-id they got, and their resolved user name.
The current ugliness with the way the structures are created will be killed
the next revision, when they will be created and malloced by creator functions.
This patch also includes the first implementation of NTLMv2 in HEAD, but which
needs some more testing. We also add a hack to allow plaintext passwords to be
compared with smbpasswd, not the system password database.
Finally, this patch probably reintroduces the PAM accounts bug we had in
2.2.0, I'll fix that once this hits the tree. (I've just finished testing
it on a wide variety of platforms, so I want to get this patch in).
(This used to be commit b30b6202f31d339b48d51c0d38174cafd1cfcd42)
2001-08-03 17:09:23 +04:00
/*
2002-01-30 09:08:46 +03:00
Unix SMB / CIFS implementation .
This is my 'Authentication Rewrite' version 1.01, mostly as submitted to
samba-technical a few weeks ago.
The idea here is to standardize the checking of user names and passwords,
thereby ensuring that all authtentications pass the same standards. The
interface currently implemented in as
nt_status = check_password(user_info, server_info)
where user_info contains (mostly) the authentication data, and server_info
contains things like the user-id they got, and their resolved user name.
The current ugliness with the way the structures are created will be killed
the next revision, when they will be created and malloced by creator functions.
This patch also includes the first implementation of NTLMv2 in HEAD, but which
needs some more testing. We also add a hack to allow plaintext passwords to be
compared with smbpasswd, not the system password database.
Finally, this patch probably reintroduces the PAM accounts bug we had in
2.2.0, I'll fix that once this hits the tree. (I've just finished testing
it on a wide variety of platforms, so I want to get this patch in).
(This used to be commit b30b6202f31d339b48d51c0d38174cafd1cfcd42)
2001-08-03 17:09:23 +04:00
Authentication utility functions
Copyright ( C ) Andrew Tridgell 1992 - 1998
Copyright ( C ) Andrew Bartlett 2001
2001-11-04 02:34:24 +03:00
Copyright ( C ) Jeremy Allison 2000 - 2001
2002-09-25 19:19:00 +04:00
Copyright ( C ) Rafal Szczesniak 2002
This is my 'Authentication Rewrite' version 1.01, mostly as submitted to
samba-technical a few weeks ago.
The idea here is to standardize the checking of user names and passwords,
thereby ensuring that all authtentications pass the same standards. The
interface currently implemented in as
nt_status = check_password(user_info, server_info)
where user_info contains (mostly) the authentication data, and server_info
contains things like the user-id they got, and their resolved user name.
The current ugliness with the way the structures are created will be killed
the next revision, when they will be created and malloced by creator functions.
This patch also includes the first implementation of NTLMv2 in HEAD, but which
needs some more testing. We also add a hack to allow plaintext passwords to be
compared with smbpasswd, not the system password database.
Finally, this patch probably reintroduces the PAM accounts bug we had in
2.2.0, I'll fix that once this hits the tree. (I've just finished testing
it on a wide variety of platforms, so I want to get this patch in).
(This used to be commit b30b6202f31d339b48d51c0d38174cafd1cfcd42)
2001-08-03 17:09:23 +04:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 2 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 675 Mass Ave , Cambridge , MA 0213 9 , USA .
*/
2001-10-02 08:29:50 +04:00
# include "includes.h"
This is my 'Authentication Rewrite' version 1.01, mostly as submitted to
samba-technical a few weeks ago.
The idea here is to standardize the checking of user names and passwords,
thereby ensuring that all authtentications pass the same standards. The
interface currently implemented in as
nt_status = check_password(user_info, server_info)
where user_info contains (mostly) the authentication data, and server_info
contains things like the user-id they got, and their resolved user name.
The current ugliness with the way the structures are created will be killed
the next revision, when they will be created and malloced by creator functions.
This patch also includes the first implementation of NTLMv2 in HEAD, but which
needs some more testing. We also add a hack to allow plaintext passwords to be
compared with smbpasswd, not the system password database.
Finally, this patch probably reintroduces the PAM accounts bug we had in
2.2.0, I'll fix that once this hits the tree. (I've just finished testing
it on a wide variety of platforms, so I want to get this patch in).
(This used to be commit b30b6202f31d339b48d51c0d38174cafd1cfcd42)
2001-08-03 17:09:23 +04:00
2002-07-15 14:35:28 +04:00
# undef DBGC_CLASS
# define DBGC_CLASS DBGC_AUTH
2002-09-25 19:19:00 +04:00
extern DOM_SID global_sid_World ;
extern DOM_SID global_sid_Network ;
extern DOM_SID global_sid_Builtin_Guests ;
extern DOM_SID global_sid_Authenticated_Users ;
This is my 'Authentication Rewrite' version 1.01, mostly as submitted to
samba-technical a few weeks ago.
The idea here is to standardize the checking of user names and passwords,
thereby ensuring that all authtentications pass the same standards. The
interface currently implemented in as
nt_status = check_password(user_info, server_info)
where user_info contains (mostly) the authentication data, and server_info
contains things like the user-id they got, and their resolved user name.
The current ugliness with the way the structures are created will be killed
the next revision, when they will be created and malloced by creator functions.
This patch also includes the first implementation of NTLMv2 in HEAD, but which
needs some more testing. We also add a hack to allow plaintext passwords to be
compared with smbpasswd, not the system password database.
Finally, this patch probably reintroduces the PAM accounts bug we had in
2.2.0, I'll fix that once this hits the tree. (I've just finished testing
it on a wide variety of platforms, so I want to get this patch in).
(This used to be commit b30b6202f31d339b48d51c0d38174cafd1cfcd42)
2001-08-03 17:09:23 +04:00
/****************************************************************************
Create a UNIX user on demand .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-05-26 03:56:41 +04:00
static int smb_create_user ( const char * domain , const char * unix_username , const char * homedir )
This is my 'Authentication Rewrite' version 1.01, mostly as submitted to
samba-technical a few weeks ago.
The idea here is to standardize the checking of user names and passwords,
thereby ensuring that all authtentications pass the same standards. The
interface currently implemented in as
nt_status = check_password(user_info, server_info)
where user_info contains (mostly) the authentication data, and server_info
contains things like the user-id they got, and their resolved user name.
The current ugliness with the way the structures are created will be killed
the next revision, when they will be created and malloced by creator functions.
This patch also includes the first implementation of NTLMv2 in HEAD, but which
needs some more testing. We also add a hack to allow plaintext passwords to be
compared with smbpasswd, not the system password database.
Finally, this patch probably reintroduces the PAM accounts bug we had in
2.2.0, I'll fix that once this hits the tree. (I've just finished testing
it on a wide variety of platforms, so I want to get this patch in).
(This used to be commit b30b6202f31d339b48d51c0d38174cafd1cfcd42)
2001-08-03 17:09:23 +04:00
{
pstring add_script ;
int ret ;
pstrcpy ( add_script , lp_adduser_script ( ) ) ;
2001-11-04 02:34:24 +03:00
if ( ! * add_script )
return - 1 ;
2003-05-26 03:56:41 +04:00
all_string_sub ( add_script , " %u " , unix_username , sizeof ( pstring ) ) ;
if ( domain )
all_string_sub ( add_script , " %D " , domain , sizeof ( pstring ) ) ;
This is my 'Authentication Rewrite' version 1.01, mostly as submitted to
samba-technical a few weeks ago.
The idea here is to standardize the checking of user names and passwords,
thereby ensuring that all authtentications pass the same standards. The
interface currently implemented in as
nt_status = check_password(user_info, server_info)
where user_info contains (mostly) the authentication data, and server_info
contains things like the user-id they got, and their resolved user name.
The current ugliness with the way the structures are created will be killed
the next revision, when they will be created and malloced by creator functions.
This patch also includes the first implementation of NTLMv2 in HEAD, but which
needs some more testing. We also add a hack to allow plaintext passwords to be
compared with smbpasswd, not the system password database.
Finally, this patch probably reintroduces the PAM accounts bug we had in
2.2.0, I'll fix that once this hits the tree. (I've just finished testing
it on a wide variety of platforms, so I want to get this patch in).
(This used to be commit b30b6202f31d339b48d51c0d38174cafd1cfcd42)
2001-08-03 17:09:23 +04:00
if ( homedir )
all_string_sub ( add_script , " %H " , homedir , sizeof ( pstring ) ) ;
ret = smbrun ( add_script , NULL ) ;
DEBUG ( 3 , ( " smb_create_user: Running the command `%s' gave %d \n " , add_script , ret ) ) ;
return ret ;
}
/****************************************************************************
2001-09-14 14:38:40 +04:00
Add and Delete UNIX users on demand , based on NTSTATUS codes .
This is my 'Authentication Rewrite' version 1.01, mostly as submitted to
samba-technical a few weeks ago.
The idea here is to standardize the checking of user names and passwords,
thereby ensuring that all authtentications pass the same standards. The
interface currently implemented in as
nt_status = check_password(user_info, server_info)
where user_info contains (mostly) the authentication data, and server_info
contains things like the user-id they got, and their resolved user name.
The current ugliness with the way the structures are created will be killed
the next revision, when they will be created and malloced by creator functions.
This patch also includes the first implementation of NTLMv2 in HEAD, but which
needs some more testing. We also add a hack to allow plaintext passwords to be
compared with smbpasswd, not the system password database.
Finally, this patch probably reintroduces the PAM accounts bug we had in
2.2.0, I'll fix that once this hits the tree. (I've just finished testing
it on a wide variety of platforms, so I want to get this patch in).
(This used to be commit b30b6202f31d339b48d51c0d38174cafd1cfcd42)
2001-08-03 17:09:23 +04:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-05-26 03:56:41 +04:00
void auth_add_user_script ( const char * domain , const char * username )
This is my 'Authentication Rewrite' version 1.01, mostly as submitted to
samba-technical a few weeks ago.
The idea here is to standardize the checking of user names and passwords,
thereby ensuring that all authtentications pass the same standards. The
interface currently implemented in as
nt_status = check_password(user_info, server_info)
where user_info contains (mostly) the authentication data, and server_info
contains things like the user-id they got, and their resolved user name.
The current ugliness with the way the structures are created will be killed
the next revision, when they will be created and malloced by creator functions.
This patch also includes the first implementation of NTLMv2 in HEAD, but which
needs some more testing. We also add a hack to allow plaintext passwords to be
compared with smbpasswd, not the system password database.
Finally, this patch probably reintroduces the PAM accounts bug we had in
2.2.0, I'll fix that once this hits the tree. (I've just finished testing
it on a wide variety of platforms, so I want to get this patch in).
(This used to be commit b30b6202f31d339b48d51c0d38174cafd1cfcd42)
2001-08-03 17:09:23 +04:00
{
struct passwd * pwd = NULL ;
2003-05-26 03:56:41 +04:00
/*
* User validated ok against Domain controller .
* If the admin wants us to try and create a UNIX
* user on the fly , do so .
*/
if ( lp_adduser_script ( ) & & ! ( pwd = Get_Pwnam ( username ) ) ) {
smb_create_user ( domain , username , NULL ) ;
2001-10-31 13:46:25 +03:00
}
}
2003-02-24 05:35:54 +03:00
/****************************************************************************
Create a SAM_ACCOUNT - either by looking in the pdb , or by faking it up from
unix info .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
NTSTATUS auth_get_sam_account ( const char * user , SAM_ACCOUNT * * account )
{
BOOL pdb_ret ;
NTSTATUS nt_status ;
if ( ! NT_STATUS_IS_OK ( nt_status = pdb_init_sam ( account ) ) ) {
return nt_status ;
}
become_root ( ) ;
pdb_ret = pdb_getsampwnam ( * account , user ) ;
unbecome_root ( ) ;
if ( ! pdb_ret ) {
struct passwd * pass = Get_Pwnam ( user ) ;
if ( ! pass )
return NT_STATUS_NO_SUCH_USER ;
if ( ! NT_STATUS_IS_OK ( nt_status = pdb_fill_sam_pw ( * account , pass ) ) ) {
return nt_status ;
}
}
return NT_STATUS_OK ;
}
2001-10-31 13:46:25 +03:00
/****************************************************************************
Create an auth_usersupplied_data structure
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-09-25 19:19:00 +04:00
static NTSTATUS make_user_info ( auth_usersupplied_info * * user_info ,
const char * smb_name ,
const char * internal_username ,
const char * client_domain ,
const char * domain ,
const char * wksta_name ,
DATA_BLOB lm_pwd , DATA_BLOB nt_pwd ,
DATA_BLOB plaintext ,
uint32 auth_flags , BOOL encrypted )
2001-10-31 13:46:25 +03:00
{
DEBUG ( 5 , ( " attempting to make a user_info for %s (%s) \n " , internal_username , smb_name ) ) ;
* user_info = malloc ( sizeof ( * * user_info ) ) ;
if ( ! user_info ) {
DEBUG ( 0 , ( " malloc failed for user_info (size %d) \n " , sizeof ( * user_info ) ) ) ;
2002-09-25 19:19:00 +04:00
return NT_STATUS_NO_MEMORY ;
2001-10-31 13:46:25 +03:00
}
ZERO_STRUCTP ( * user_info ) ;
2002-03-01 04:24:30 +03:00
DEBUG ( 5 , ( " making strings for %s's user_info struct \n " , internal_username ) ) ;
2001-10-31 13:46:25 +03:00
( * user_info ) - > smb_name . str = strdup ( smb_name ) ;
if ( ( * user_info ) - > smb_name . str ) {
( * user_info ) - > smb_name . len = strlen ( smb_name ) ;
} else {
free_user_info ( user_info ) ;
2002-09-25 19:19:00 +04:00
return NT_STATUS_NO_MEMORY ;
2001-10-31 13:46:25 +03:00
}
( * user_info ) - > internal_username . str = strdup ( internal_username ) ;
if ( ( * user_info ) - > internal_username . str ) {
( * user_info ) - > internal_username . len = strlen ( internal_username ) ;
} else {
free_user_info ( user_info ) ;
2002-09-25 19:19:00 +04:00
return NT_STATUS_NO_MEMORY ;
2001-10-31 13:46:25 +03:00
}
( * user_info ) - > domain . str = strdup ( domain ) ;
if ( ( * user_info ) - > domain . str ) {
( * user_info ) - > domain . len = strlen ( domain ) ;
} else {
free_user_info ( user_info ) ;
2002-09-25 19:19:00 +04:00
return NT_STATUS_NO_MEMORY ;
2001-10-31 13:46:25 +03:00
}
( * user_info ) - > client_domain . str = strdup ( client_domain ) ;
if ( ( * user_info ) - > client_domain . str ) {
( * user_info ) - > client_domain . len = strlen ( client_domain ) ;
} else {
free_user_info ( user_info ) ;
2002-09-25 19:19:00 +04:00
return NT_STATUS_NO_MEMORY ;
2001-10-31 13:46:25 +03:00
}
( * user_info ) - > wksta_name . str = strdup ( wksta_name ) ;
if ( ( * user_info ) - > wksta_name . str ) {
( * user_info ) - > wksta_name . len = strlen ( wksta_name ) ;
} else {
free_user_info ( user_info ) ;
2002-09-25 19:19:00 +04:00
return NT_STATUS_NO_MEMORY ;
This is my 'Authentication Rewrite' version 1.01, mostly as submitted to
samba-technical a few weeks ago.
The idea here is to standardize the checking of user names and passwords,
thereby ensuring that all authtentications pass the same standards. The
interface currently implemented in as
nt_status = check_password(user_info, server_info)
where user_info contains (mostly) the authentication data, and server_info
contains things like the user-id they got, and their resolved user name.
The current ugliness with the way the structures are created will be killed
the next revision, when they will be created and malloced by creator functions.
This patch also includes the first implementation of NTLMv2 in HEAD, but which
needs some more testing. We also add a hack to allow plaintext passwords to be
compared with smbpasswd, not the system password database.
Finally, this patch probably reintroduces the PAM accounts bug we had in
2.2.0, I'll fix that once this hits the tree. (I've just finished testing
it on a wide variety of platforms, so I want to get this patch in).
(This used to be commit b30b6202f31d339b48d51c0d38174cafd1cfcd42)
2001-08-03 17:09:23 +04:00
}
2001-10-31 13:46:25 +03:00
2002-07-15 14:35:28 +04:00
DEBUG ( 5 , ( " making blobs for %s's user_info struct \n " , internal_username ) ) ;
2001-10-31 13:46:25 +03:00
( * user_info ) - > lm_resp = data_blob ( lm_pwd . data , lm_pwd . length ) ;
( * user_info ) - > nt_resp = data_blob ( nt_pwd . data , nt_pwd . length ) ;
( * user_info ) - > plaintext_password = data_blob ( plaintext . data , plaintext . length ) ;
( * user_info ) - > encrypted = encrypted ;
2002-01-11 08:29:09 +03:00
( * user_info ) - > auth_flags = auth_flags ;
2001-10-31 13:46:25 +03:00
DEBUG ( 10 , ( " made an %sencrypted user_info for %s (%s) \n " , encrypted ? " " : " un " , internal_username , smb_name ) ) ;
2002-09-25 19:19:00 +04:00
return NT_STATUS_OK ;
This is my 'Authentication Rewrite' version 1.01, mostly as submitted to
samba-technical a few weeks ago.
The idea here is to standardize the checking of user names and passwords,
thereby ensuring that all authtentications pass the same standards. The
interface currently implemented in as
nt_status = check_password(user_info, server_info)
where user_info contains (mostly) the authentication data, and server_info
contains things like the user-id they got, and their resolved user name.
The current ugliness with the way the structures are created will be killed
the next revision, when they will be created and malloced by creator functions.
This patch also includes the first implementation of NTLMv2 in HEAD, but which
needs some more testing. We also add a hack to allow plaintext passwords to be
compared with smbpasswd, not the system password database.
Finally, this patch probably reintroduces the PAM accounts bug we had in
2.2.0, I'll fix that once this hits the tree. (I've just finished testing
it on a wide variety of platforms, so I want to get this patch in).
(This used to be commit b30b6202f31d339b48d51c0d38174cafd1cfcd42)
2001-08-03 17:09:23 +04:00
}
2001-10-31 13:46:25 +03:00
/****************************************************************************
Create an auth_usersupplied_data structure after appropriate mapping .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-09-25 19:19:00 +04:00
NTSTATUS make_user_info_map ( auth_usersupplied_info * * user_info ,
const char * smb_name ,
const char * client_domain ,
const char * wksta_name ,
DATA_BLOB lm_pwd , DATA_BLOB nt_pwd ,
DATA_BLOB plaintext ,
uint32 ntlmssp_flags , BOOL encrypted )
2001-10-31 13:46:25 +03:00
{
2001-11-11 14:34:46 +03:00
const char * domain ;
2001-10-31 13:46:25 +03:00
fstring internal_username ;
fstrcpy ( internal_username , smb_name ) ;
map_username ( internal_username ) ;
2002-09-25 19:19:00 +04:00
2002-03-23 12:01:30 +03:00
DEBUG ( 5 , ( " make_user_info_map: Mapping user [%s] \\ [%s] from workstation [%s] \n " ,
client_domain , smb_name , wksta_name ) ) ;
2001-10-31 13:46:25 +03:00
2003-06-28 12:29:42 +04:00
/* don't allow "" as a domain, fixes a Win9X bug
2002-03-13 04:51:01 +03:00
where it doens ' t supply a domain for logon script
2003-06-28 12:29:42 +04:00
' net use ' commands . */
2002-01-18 11:12:10 +03:00
2003-06-28 12:29:42 +04:00
if ( * client_domain )
2002-01-18 11:12:10 +03:00
domain = client_domain ;
2003-06-28 12:29:42 +04:00
else
domain = lp_workgroup ( ) ;
2002-01-18 11:12:10 +03:00
2003-06-28 12:29:42 +04:00
/* do what win2k does. Always map unknown domains to our own
and let the " passdb backend " handle unknown users */
2003-04-24 15:56:09 +04:00
2003-06-28 12:29:42 +04:00
if ( ! is_trusted_domain ( domain ) )
2001-10-31 13:46:25 +03:00
domain = lp_workgroup ( ) ;
2003-06-28 12:29:42 +04:00
/* we know that it is a trusted domain (and we are allowing them) or it is our domain */
2001-10-31 13:46:25 +03:00
return make_user_info ( user_info ,
smb_name , internal_username ,
client_domain , domain ,
This is another rather major change to the samba authenticaion
subystem.
The particular aim is to modularized the interface - so that we
can have arbitrary password back-ends.
This code adds one such back-end, a 'winbind' module to authenticate
against the winbind_auth_crap functionality. While fully-functional
this code is mainly useful as a demonstration, because we don't get
back the info3 as we would for direct ntdomain authentication.
This commit introduced the new 'auth methods' parameter, in the
spirit of the 'auth order' discussed on the lists. It is renamed
because not all the methods may be consulted, even if previous
methods fail - they may not have a suitable challenge for example.
Also, we have a 'local' authentication method, for old-style
'unix if plaintext, sam if encrypted' authentication and a
'guest' module to handle guest logins in a single place.
While this current design is not ideal, I feel that it does
provide a better infrastructure than the current design, and can
be built upon.
The following parameters have changed:
- use rhosts =
This has been replaced by the 'rhosts' authentication method,
and can be specified like 'auth methods = guest rhosts'
- hosts equiv =
This needs both this parameter and an 'auth methods' entry
to be effective. (auth methods = guest hostsequiv ....)
- plaintext to smbpasswd =
This is replaced by specifying 'sam' rather than 'local'
in the auth methods.
The security = parameter is unchanged, and now provides defaults
for the 'auth methods' parameter.
The available auth methods are:
guest
rhosts
hostsequiv
sam (passdb direct hash access)
unix (PAM, crypt() etc)
local (the combination of the above, based on encryption)
smbserver (old security=server)
ntdomain (old security=domain)
winbind (use winbind to cache DC connections)
Assistance in testing, or the production of new and interesting
authentication modules is always appreciated.
Andrew Bartlett
(This used to be commit 8d31eae52a9757739711dbb82035a4dfe6b40c99)
2001-11-24 15:12:38 +03:00
wksta_name ,
2001-10-31 13:46:25 +03:00
lm_pwd , nt_pwd ,
plaintext ,
ntlmssp_flags , encrypted ) ;
}
/****************************************************************************
Create an auth_usersupplied_data , making the DATA_BLOBs here .
2001-11-22 00:10:13 +03:00
Decrypt and encrypt the passwords .
2001-10-31 13:46:25 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
BOOL make_user_info_netlogon_network ( auth_usersupplied_info * * user_info ,
2002-01-20 11:58:21 +03:00
const char * smb_name ,
const char * client_domain ,
const char * wksta_name ,
const uchar * lm_network_pwd , int lm_pwd_len ,
const uchar * nt_network_pwd , int nt_pwd_len )
2001-10-31 13:46:25 +03:00
{
BOOL ret ;
2002-09-25 19:19:00 +04:00
NTSTATUS nt_status ;
2001-10-31 13:46:25 +03:00
DATA_BLOB lm_blob = data_blob ( lm_network_pwd , lm_pwd_len ) ;
DATA_BLOB nt_blob = data_blob ( nt_network_pwd , nt_pwd_len ) ;
DATA_BLOB plaintext_blob = data_blob ( NULL , 0 ) ;
2002-01-11 08:29:09 +03:00
uint32 auth_flags = AUTH_FLAG_NONE ;
2001-10-31 13:46:25 +03:00
if ( lm_pwd_len )
2002-01-11 08:29:09 +03:00
auth_flags | = AUTH_FLAG_LM_RESP ;
2001-11-01 08:02:41 +03:00
if ( nt_pwd_len = = 24 ) {
2002-01-11 08:29:09 +03:00
auth_flags | = AUTH_FLAG_NTLM_RESP ;
2001-11-01 08:02:41 +03:00
} else if ( nt_pwd_len ! = 0 ) {
2002-01-11 08:29:09 +03:00
auth_flags | = AUTH_FLAG_NTLMv2_RESP ;
2001-11-01 08:02:41 +03:00
}
2002-09-25 19:19:00 +04:00
nt_status = make_user_info_map ( user_info ,
smb_name , client_domain ,
wksta_name ,
lm_blob , nt_blob ,
plaintext_blob ,
auth_flags , True ) ;
ret = NT_STATUS_IS_OK ( nt_status ) ? True : False ;
2001-10-31 13:46:25 +03:00
data_blob_free ( & lm_blob ) ;
data_blob_free ( & nt_blob ) ;
return ret ;
}
/****************************************************************************
Create an auth_usersupplied_data , making the DATA_BLOBs here .
2001-11-22 00:10:13 +03:00
Decrypt and encrypt the passwords .
2001-10-31 13:46:25 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
BOOL make_user_info_netlogon_interactive ( auth_usersupplied_info * * user_info ,
2002-01-05 07:55:41 +03:00
const char * smb_name ,
const char * client_domain ,
const char * wksta_name ,
const uchar chal [ 8 ] ,
const uchar lm_interactive_pwd [ 16 ] ,
const uchar nt_interactive_pwd [ 16 ] ,
const uchar * dc_sess_key )
2001-10-31 13:46:25 +03:00
{
char lm_pwd [ 16 ] ;
2001-11-01 08:02:41 +03:00
char nt_pwd [ 16 ] ;
2001-10-31 13:46:25 +03:00
unsigned char local_lm_response [ 24 ] ;
unsigned char local_nt_response [ 24 ] ;
unsigned char key [ 16 ] ;
2002-01-11 08:29:09 +03:00
uint32 auth_flags = AUTH_FLAG_NONE ;
2001-10-31 13:46:25 +03:00
2001-11-01 08:02:41 +03:00
ZERO_STRUCT ( key ) ;
2001-10-31 13:46:25 +03:00
memcpy ( key , dc_sess_key , 8 ) ;
2001-11-01 08:02:41 +03:00
if ( lm_interactive_pwd ) memcpy ( lm_pwd , lm_interactive_pwd , sizeof ( lm_pwd ) ) ;
if ( nt_interactive_pwd ) memcpy ( nt_pwd , nt_interactive_pwd , sizeof ( nt_pwd ) ) ;
2001-10-31 13:46:25 +03:00
# ifdef DEBUG_PASSWORD
DEBUG ( 100 , ( " key: " ) ) ;
2001-11-01 08:02:41 +03:00
dump_data ( 100 , ( char * ) key , sizeof ( key ) ) ;
2001-10-31 13:46:25 +03:00
DEBUG ( 100 , ( " lm owf password: " ) ) ;
2001-11-01 08:02:41 +03:00
dump_data ( 100 , lm_pwd , sizeof ( lm_pwd ) ) ;
2001-10-31 13:46:25 +03:00
DEBUG ( 100 , ( " nt owf password: " ) ) ;
2001-11-01 08:02:41 +03:00
dump_data ( 100 , nt_pwd , sizeof ( nt_pwd ) ) ;
2001-10-31 13:46:25 +03:00
# endif
2001-11-01 08:02:41 +03:00
SamOEMhash ( ( uchar * ) lm_pwd , key , sizeof ( lm_pwd ) ) ;
SamOEMhash ( ( uchar * ) nt_pwd , key , sizeof ( nt_pwd ) ) ;
2001-10-31 13:46:25 +03:00
# ifdef DEBUG_PASSWORD
DEBUG ( 100 , ( " decrypt of lm owf password: " ) ) ;
2001-11-01 08:02:41 +03:00
dump_data ( 100 , lm_pwd , sizeof ( lm_pwd ) ) ;
2001-10-31 13:46:25 +03:00
DEBUG ( 100 , ( " decrypt of nt owf password: " ) ) ;
2001-11-01 08:02:41 +03:00
dump_data ( 100 , nt_pwd , sizeof ( nt_pwd ) ) ;
2001-10-31 13:46:25 +03:00
# endif
SMBOWFencrypt ( ( const unsigned char * ) lm_pwd , chal , local_lm_response ) ;
SMBOWFencrypt ( ( const unsigned char * ) nt_pwd , chal , local_nt_response ) ;
2002-03-25 02:25:05 +03:00
/* Password info paranoia */
2001-10-31 13:46:25 +03:00
ZERO_STRUCT ( lm_pwd ) ;
ZERO_STRUCT ( nt_pwd ) ;
ZERO_STRUCT ( key ) ;
{
BOOL ret ;
2002-09-25 19:19:00 +04:00
NTSTATUS nt_status ;
2001-10-31 13:46:25 +03:00
DATA_BLOB local_lm_blob = data_blob ( local_lm_response , sizeof ( local_lm_response ) ) ;
DATA_BLOB local_nt_blob = data_blob ( local_nt_response , sizeof ( local_nt_response ) ) ;
DATA_BLOB plaintext_blob = data_blob ( NULL , 0 ) ;
2001-11-01 08:02:41 +03:00
if ( lm_interactive_pwd )
2002-01-11 08:29:09 +03:00
auth_flags | = AUTH_FLAG_LM_RESP ;
2001-11-01 08:02:41 +03:00
if ( nt_interactive_pwd )
2002-01-11 08:29:09 +03:00
auth_flags | = AUTH_FLAG_NTLM_RESP ;
2001-11-01 08:02:41 +03:00
2002-09-25 19:19:00 +04:00
nt_status = make_user_info_map ( user_info ,
smb_name , client_domain ,
wksta_name ,
local_lm_blob ,
local_nt_blob ,
plaintext_blob ,
auth_flags , True ) ;
2001-10-31 13:46:25 +03:00
2002-09-25 19:19:00 +04:00
ret = NT_STATUS_IS_OK ( nt_status ) ? True : False ;
2001-10-31 13:46:25 +03:00
data_blob_free ( & local_lm_blob ) ;
data_blob_free ( & local_nt_blob ) ;
return ret ;
}
}
/****************************************************************************
Create an auth_usersupplied_data structure
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
BOOL make_user_info_for_reply ( auth_usersupplied_info * * user_info ,
2002-01-20 11:58:21 +03:00
const char * smb_name ,
const char * client_domain ,
2002-01-05 07:55:41 +03:00
const uint8 chal [ 8 ] ,
This is another rather major change to the samba authenticaion
subystem.
The particular aim is to modularized the interface - so that we
can have arbitrary password back-ends.
This code adds one such back-end, a 'winbind' module to authenticate
against the winbind_auth_crap functionality. While fully-functional
this code is mainly useful as a demonstration, because we don't get
back the info3 as we would for direct ntdomain authentication.
This commit introduced the new 'auth methods' parameter, in the
spirit of the 'auth order' discussed on the lists. It is renamed
because not all the methods may be consulted, even if previous
methods fail - they may not have a suitable challenge for example.
Also, we have a 'local' authentication method, for old-style
'unix if plaintext, sam if encrypted' authentication and a
'guest' module to handle guest logins in a single place.
While this current design is not ideal, I feel that it does
provide a better infrastructure than the current design, and can
be built upon.
The following parameters have changed:
- use rhosts =
This has been replaced by the 'rhosts' authentication method,
and can be specified like 'auth methods = guest rhosts'
- hosts equiv =
This needs both this parameter and an 'auth methods' entry
to be effective. (auth methods = guest hostsequiv ....)
- plaintext to smbpasswd =
This is replaced by specifying 'sam' rather than 'local'
in the auth methods.
The security = parameter is unchanged, and now provides defaults
for the 'auth methods' parameter.
The available auth methods are:
guest
rhosts
hostsequiv
sam (passdb direct hash access)
unix (PAM, crypt() etc)
local (the combination of the above, based on encryption)
smbserver (old security=server)
ntdomain (old security=domain)
winbind (use winbind to cache DC connections)
Assistance in testing, or the production of new and interesting
authentication modules is always appreciated.
Andrew Bartlett
(This used to be commit 8d31eae52a9757739711dbb82035a4dfe6b40c99)
2001-11-24 15:12:38 +03:00
DATA_BLOB plaintext_password )
2001-10-31 13:46:25 +03:00
{
DATA_BLOB local_lm_blob ;
DATA_BLOB local_nt_blob ;
2002-09-25 19:19:00 +04:00
NTSTATUS ret = NT_STATUS_UNSUCCESSFUL ;
2002-01-11 08:29:09 +03:00
uint32 auth_flags = AUTH_FLAG_NONE ;
2001-10-31 13:46:25 +03:00
/*
* Not encrypted - do so .
*/
This is another rather major change to the samba authenticaion
subystem.
The particular aim is to modularized the interface - so that we
can have arbitrary password back-ends.
This code adds one such back-end, a 'winbind' module to authenticate
against the winbind_auth_crap functionality. While fully-functional
this code is mainly useful as a demonstration, because we don't get
back the info3 as we would for direct ntdomain authentication.
This commit introduced the new 'auth methods' parameter, in the
spirit of the 'auth order' discussed on the lists. It is renamed
because not all the methods may be consulted, even if previous
methods fail - they may not have a suitable challenge for example.
Also, we have a 'local' authentication method, for old-style
'unix if plaintext, sam if encrypted' authentication and a
'guest' module to handle guest logins in a single place.
While this current design is not ideal, I feel that it does
provide a better infrastructure than the current design, and can
be built upon.
The following parameters have changed:
- use rhosts =
This has been replaced by the 'rhosts' authentication method,
and can be specified like 'auth methods = guest rhosts'
- hosts equiv =
This needs both this parameter and an 'auth methods' entry
to be effective. (auth methods = guest hostsequiv ....)
- plaintext to smbpasswd =
This is replaced by specifying 'sam' rather than 'local'
in the auth methods.
The security = parameter is unchanged, and now provides defaults
for the 'auth methods' parameter.
The available auth methods are:
guest
rhosts
hostsequiv
sam (passdb direct hash access)
unix (PAM, crypt() etc)
local (the combination of the above, based on encryption)
smbserver (old security=server)
ntdomain (old security=domain)
winbind (use winbind to cache DC connections)
Assistance in testing, or the production of new and interesting
authentication modules is always appreciated.
Andrew Bartlett
(This used to be commit 8d31eae52a9757739711dbb82035a4dfe6b40c99)
2001-11-24 15:12:38 +03:00
DEBUG ( 5 , ( " make_user_info_for_reply: User passwords not in encrypted format. \n " ) ) ;
2001-10-31 13:46:25 +03:00
if ( plaintext_password . data ) {
unsigned char local_lm_response [ 24 ] ;
This is another rather major change to the samba authenticaion
subystem.
The particular aim is to modularized the interface - so that we
can have arbitrary password back-ends.
This code adds one such back-end, a 'winbind' module to authenticate
against the winbind_auth_crap functionality. While fully-functional
this code is mainly useful as a demonstration, because we don't get
back the info3 as we would for direct ntdomain authentication.
This commit introduced the new 'auth methods' parameter, in the
spirit of the 'auth order' discussed on the lists. It is renamed
because not all the methods may be consulted, even if previous
methods fail - they may not have a suitable challenge for example.
Also, we have a 'local' authentication method, for old-style
'unix if plaintext, sam if encrypted' authentication and a
'guest' module to handle guest logins in a single place.
While this current design is not ideal, I feel that it does
provide a better infrastructure than the current design, and can
be built upon.
The following parameters have changed:
- use rhosts =
This has been replaced by the 'rhosts' authentication method,
and can be specified like 'auth methods = guest rhosts'
- hosts equiv =
This needs both this parameter and an 'auth methods' entry
to be effective. (auth methods = guest hostsequiv ....)
- plaintext to smbpasswd =
This is replaced by specifying 'sam' rather than 'local'
in the auth methods.
The security = parameter is unchanged, and now provides defaults
for the 'auth methods' parameter.
The available auth methods are:
guest
rhosts
hostsequiv
sam (passdb direct hash access)
unix (PAM, crypt() etc)
local (the combination of the above, based on encryption)
smbserver (old security=server)
ntdomain (old security=domain)
winbind (use winbind to cache DC connections)
Assistance in testing, or the production of new and interesting
authentication modules is always appreciated.
Andrew Bartlett
(This used to be commit 8d31eae52a9757739711dbb82035a4dfe6b40c99)
2001-11-24 15:12:38 +03:00
# ifdef DEBUG_PASSWORD
DEBUG ( 10 , ( " Unencrypted password (len %d): \n " , plaintext_password . length ) ) ;
dump_data ( 100 , plaintext_password . data , plaintext_password . length ) ;
# endif
2001-10-31 13:46:25 +03:00
2002-01-05 07:55:41 +03:00
SMBencrypt ( ( const uchar * ) plaintext_password . data , ( const uchar * ) chal , local_lm_response ) ;
2001-10-31 13:46:25 +03:00
local_lm_blob = data_blob ( local_lm_response , 24 ) ;
2001-11-22 00:10:13 +03:00
/* We can't do an NT hash here, as the password needs to be
case insensitive */
2001-10-31 13:46:25 +03:00
local_nt_blob = data_blob ( NULL , 0 ) ;
2002-01-11 08:29:09 +03:00
auth_flags = ( AUTH_FLAG_PLAINTEXT | AUTH_FLAG_LM_RESP ) ;
2001-10-31 13:46:25 +03:00
} else {
local_lm_blob = data_blob ( NULL , 0 ) ;
local_nt_blob = data_blob ( NULL , 0 ) ;
}
ret = make_user_info_map ( user_info , smb_name ,
2002-09-25 19:19:00 +04:00
client_domain ,
get_remote_machine_name ( ) ,
local_lm_blob ,
local_nt_blob ,
plaintext_password ,
auth_flags , False ) ;
2001-10-31 13:46:25 +03:00
data_blob_free ( & local_lm_blob ) ;
2002-09-25 19:19:00 +04:00
return NT_STATUS_IS_OK ( ret ) ? True : False ;
2001-10-31 13:46:25 +03:00
}
This is another rather major change to the samba authenticaion
subystem.
The particular aim is to modularized the interface - so that we
can have arbitrary password back-ends.
This code adds one such back-end, a 'winbind' module to authenticate
against the winbind_auth_crap functionality. While fully-functional
this code is mainly useful as a demonstration, because we don't get
back the info3 as we would for direct ntdomain authentication.
This commit introduced the new 'auth methods' parameter, in the
spirit of the 'auth order' discussed on the lists. It is renamed
because not all the methods may be consulted, even if previous
methods fail - they may not have a suitable challenge for example.
Also, we have a 'local' authentication method, for old-style
'unix if plaintext, sam if encrypted' authentication and a
'guest' module to handle guest logins in a single place.
While this current design is not ideal, I feel that it does
provide a better infrastructure than the current design, and can
be built upon.
The following parameters have changed:
- use rhosts =
This has been replaced by the 'rhosts' authentication method,
and can be specified like 'auth methods = guest rhosts'
- hosts equiv =
This needs both this parameter and an 'auth methods' entry
to be effective. (auth methods = guest hostsequiv ....)
- plaintext to smbpasswd =
This is replaced by specifying 'sam' rather than 'local'
in the auth methods.
The security = parameter is unchanged, and now provides defaults
for the 'auth methods' parameter.
The available auth methods are:
guest
rhosts
hostsequiv
sam (passdb direct hash access)
unix (PAM, crypt() etc)
local (the combination of the above, based on encryption)
smbserver (old security=server)
ntdomain (old security=domain)
winbind (use winbind to cache DC connections)
Assistance in testing, or the production of new and interesting
authentication modules is always appreciated.
Andrew Bartlett
(This used to be commit 8d31eae52a9757739711dbb82035a4dfe6b40c99)
2001-11-24 15:12:38 +03:00
/****************************************************************************
Create an auth_usersupplied_data structure
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-09-25 19:19:00 +04:00
NTSTATUS make_user_info_for_reply_enc ( auth_usersupplied_info * * user_info ,
const char * smb_name ,
const char * client_domain ,
DATA_BLOB lm_resp , DATA_BLOB nt_resp )
This is another rather major change to the samba authenticaion
subystem.
The particular aim is to modularized the interface - so that we
can have arbitrary password back-ends.
This code adds one such back-end, a 'winbind' module to authenticate
against the winbind_auth_crap functionality. While fully-functional
this code is mainly useful as a demonstration, because we don't get
back the info3 as we would for direct ntdomain authentication.
This commit introduced the new 'auth methods' parameter, in the
spirit of the 'auth order' discussed on the lists. It is renamed
because not all the methods may be consulted, even if previous
methods fail - they may not have a suitable challenge for example.
Also, we have a 'local' authentication method, for old-style
'unix if plaintext, sam if encrypted' authentication and a
'guest' module to handle guest logins in a single place.
While this current design is not ideal, I feel that it does
provide a better infrastructure than the current design, and can
be built upon.
The following parameters have changed:
- use rhosts =
This has been replaced by the 'rhosts' authentication method,
and can be specified like 'auth methods = guest rhosts'
- hosts equiv =
This needs both this parameter and an 'auth methods' entry
to be effective. (auth methods = guest hostsequiv ....)
- plaintext to smbpasswd =
This is replaced by specifying 'sam' rather than 'local'
in the auth methods.
The security = parameter is unchanged, and now provides defaults
for the 'auth methods' parameter.
The available auth methods are:
guest
rhosts
hostsequiv
sam (passdb direct hash access)
unix (PAM, crypt() etc)
local (the combination of the above, based on encryption)
smbserver (old security=server)
ntdomain (old security=domain)
winbind (use winbind to cache DC connections)
Assistance in testing, or the production of new and interesting
authentication modules is always appreciated.
Andrew Bartlett
(This used to be commit 8d31eae52a9757739711dbb82035a4dfe6b40c99)
2001-11-24 15:12:38 +03:00
{
2002-01-11 08:29:09 +03:00
uint32 auth_flags = AUTH_FLAG_NONE ;
This is another rather major change to the samba authenticaion
subystem.
The particular aim is to modularized the interface - so that we
can have arbitrary password back-ends.
This code adds one such back-end, a 'winbind' module to authenticate
against the winbind_auth_crap functionality. While fully-functional
this code is mainly useful as a demonstration, because we don't get
back the info3 as we would for direct ntdomain authentication.
This commit introduced the new 'auth methods' parameter, in the
spirit of the 'auth order' discussed on the lists. It is renamed
because not all the methods may be consulted, even if previous
methods fail - they may not have a suitable challenge for example.
Also, we have a 'local' authentication method, for old-style
'unix if plaintext, sam if encrypted' authentication and a
'guest' module to handle guest logins in a single place.
While this current design is not ideal, I feel that it does
provide a better infrastructure than the current design, and can
be built upon.
The following parameters have changed:
- use rhosts =
This has been replaced by the 'rhosts' authentication method,
and can be specified like 'auth methods = guest rhosts'
- hosts equiv =
This needs both this parameter and an 'auth methods' entry
to be effective. (auth methods = guest hostsequiv ....)
- plaintext to smbpasswd =
This is replaced by specifying 'sam' rather than 'local'
in the auth methods.
The security = parameter is unchanged, and now provides defaults
for the 'auth methods' parameter.
The available auth methods are:
guest
rhosts
hostsequiv
sam (passdb direct hash access)
unix (PAM, crypt() etc)
local (the combination of the above, based on encryption)
smbserver (old security=server)
ntdomain (old security=domain)
winbind (use winbind to cache DC connections)
Assistance in testing, or the production of new and interesting
authentication modules is always appreciated.
Andrew Bartlett
(This used to be commit 8d31eae52a9757739711dbb82035a4dfe6b40c99)
2001-11-24 15:12:38 +03:00
DATA_BLOB no_plaintext_blob = data_blob ( NULL , 0 ) ;
if ( lm_resp . length = = 24 ) {
2002-01-11 08:29:09 +03:00
auth_flags | = AUTH_FLAG_LM_RESP ;
This is another rather major change to the samba authenticaion
subystem.
The particular aim is to modularized the interface - so that we
can have arbitrary password back-ends.
This code adds one such back-end, a 'winbind' module to authenticate
against the winbind_auth_crap functionality. While fully-functional
this code is mainly useful as a demonstration, because we don't get
back the info3 as we would for direct ntdomain authentication.
This commit introduced the new 'auth methods' parameter, in the
spirit of the 'auth order' discussed on the lists. It is renamed
because not all the methods may be consulted, even if previous
methods fail - they may not have a suitable challenge for example.
Also, we have a 'local' authentication method, for old-style
'unix if plaintext, sam if encrypted' authentication and a
'guest' module to handle guest logins in a single place.
While this current design is not ideal, I feel that it does
provide a better infrastructure than the current design, and can
be built upon.
The following parameters have changed:
- use rhosts =
This has been replaced by the 'rhosts' authentication method,
and can be specified like 'auth methods = guest rhosts'
- hosts equiv =
This needs both this parameter and an 'auth methods' entry
to be effective. (auth methods = guest hostsequiv ....)
- plaintext to smbpasswd =
This is replaced by specifying 'sam' rather than 'local'
in the auth methods.
The security = parameter is unchanged, and now provides defaults
for the 'auth methods' parameter.
The available auth methods are:
guest
rhosts
hostsequiv
sam (passdb direct hash access)
unix (PAM, crypt() etc)
local (the combination of the above, based on encryption)
smbserver (old security=server)
ntdomain (old security=domain)
winbind (use winbind to cache DC connections)
Assistance in testing, or the production of new and interesting
authentication modules is always appreciated.
Andrew Bartlett
(This used to be commit 8d31eae52a9757739711dbb82035a4dfe6b40c99)
2001-11-24 15:12:38 +03:00
}
if ( nt_resp . length = = 0 ) {
} else if ( nt_resp . length = = 24 ) {
2002-01-11 08:29:09 +03:00
auth_flags | = AUTH_FLAG_NTLM_RESP ;
This is another rather major change to the samba authenticaion
subystem.
The particular aim is to modularized the interface - so that we
can have arbitrary password back-ends.
This code adds one such back-end, a 'winbind' module to authenticate
against the winbind_auth_crap functionality. While fully-functional
this code is mainly useful as a demonstration, because we don't get
back the info3 as we would for direct ntdomain authentication.
This commit introduced the new 'auth methods' parameter, in the
spirit of the 'auth order' discussed on the lists. It is renamed
because not all the methods may be consulted, even if previous
methods fail - they may not have a suitable challenge for example.
Also, we have a 'local' authentication method, for old-style
'unix if plaintext, sam if encrypted' authentication and a
'guest' module to handle guest logins in a single place.
While this current design is not ideal, I feel that it does
provide a better infrastructure than the current design, and can
be built upon.
The following parameters have changed:
- use rhosts =
This has been replaced by the 'rhosts' authentication method,
and can be specified like 'auth methods = guest rhosts'
- hosts equiv =
This needs both this parameter and an 'auth methods' entry
to be effective. (auth methods = guest hostsequiv ....)
- plaintext to smbpasswd =
This is replaced by specifying 'sam' rather than 'local'
in the auth methods.
The security = parameter is unchanged, and now provides defaults
for the 'auth methods' parameter.
The available auth methods are:
guest
rhosts
hostsequiv
sam (passdb direct hash access)
unix (PAM, crypt() etc)
local (the combination of the above, based on encryption)
smbserver (old security=server)
ntdomain (old security=domain)
winbind (use winbind to cache DC connections)
Assistance in testing, or the production of new and interesting
authentication modules is always appreciated.
Andrew Bartlett
(This used to be commit 8d31eae52a9757739711dbb82035a4dfe6b40c99)
2001-11-24 15:12:38 +03:00
} else {
2002-01-11 08:29:09 +03:00
auth_flags | = AUTH_FLAG_NTLMv2_RESP ;
This is another rather major change to the samba authenticaion
subystem.
The particular aim is to modularized the interface - so that we
can have arbitrary password back-ends.
This code adds one such back-end, a 'winbind' module to authenticate
against the winbind_auth_crap functionality. While fully-functional
this code is mainly useful as a demonstration, because we don't get
back the info3 as we would for direct ntdomain authentication.
This commit introduced the new 'auth methods' parameter, in the
spirit of the 'auth order' discussed on the lists. It is renamed
because not all the methods may be consulted, even if previous
methods fail - they may not have a suitable challenge for example.
Also, we have a 'local' authentication method, for old-style
'unix if plaintext, sam if encrypted' authentication and a
'guest' module to handle guest logins in a single place.
While this current design is not ideal, I feel that it does
provide a better infrastructure than the current design, and can
be built upon.
The following parameters have changed:
- use rhosts =
This has been replaced by the 'rhosts' authentication method,
and can be specified like 'auth methods = guest rhosts'
- hosts equiv =
This needs both this parameter and an 'auth methods' entry
to be effective. (auth methods = guest hostsequiv ....)
- plaintext to smbpasswd =
This is replaced by specifying 'sam' rather than 'local'
in the auth methods.
The security = parameter is unchanged, and now provides defaults
for the 'auth methods' parameter.
The available auth methods are:
guest
rhosts
hostsequiv
sam (passdb direct hash access)
unix (PAM, crypt() etc)
local (the combination of the above, based on encryption)
smbserver (old security=server)
ntdomain (old security=domain)
winbind (use winbind to cache DC connections)
Assistance in testing, or the production of new and interesting
authentication modules is always appreciated.
Andrew Bartlett
(This used to be commit 8d31eae52a9757739711dbb82035a4dfe6b40c99)
2001-11-24 15:12:38 +03:00
}
return make_user_info_map ( user_info , smb_name ,
client_domain ,
2002-08-17 21:00:51 +04:00
get_remote_machine_name ( ) ,
This is another rather major change to the samba authenticaion
subystem.
The particular aim is to modularized the interface - so that we
can have arbitrary password back-ends.
This code adds one such back-end, a 'winbind' module to authenticate
against the winbind_auth_crap functionality. While fully-functional
this code is mainly useful as a demonstration, because we don't get
back the info3 as we would for direct ntdomain authentication.
This commit introduced the new 'auth methods' parameter, in the
spirit of the 'auth order' discussed on the lists. It is renamed
because not all the methods may be consulted, even if previous
methods fail - they may not have a suitable challenge for example.
Also, we have a 'local' authentication method, for old-style
'unix if plaintext, sam if encrypted' authentication and a
'guest' module to handle guest logins in a single place.
While this current design is not ideal, I feel that it does
provide a better infrastructure than the current design, and can
be built upon.
The following parameters have changed:
- use rhosts =
This has been replaced by the 'rhosts' authentication method,
and can be specified like 'auth methods = guest rhosts'
- hosts equiv =
This needs both this parameter and an 'auth methods' entry
to be effective. (auth methods = guest hostsequiv ....)
- plaintext to smbpasswd =
This is replaced by specifying 'sam' rather than 'local'
in the auth methods.
The security = parameter is unchanged, and now provides defaults
for the 'auth methods' parameter.
The available auth methods are:
guest
rhosts
hostsequiv
sam (passdb direct hash access)
unix (PAM, crypt() etc)
local (the combination of the above, based on encryption)
smbserver (old security=server)
ntdomain (old security=domain)
winbind (use winbind to cache DC connections)
Assistance in testing, or the production of new and interesting
authentication modules is always appreciated.
Andrew Bartlett
(This used to be commit 8d31eae52a9757739711dbb82035a4dfe6b40c99)
2001-11-24 15:12:38 +03:00
lm_resp ,
nt_resp ,
no_plaintext_blob ,
2002-01-11 08:29:09 +03:00
auth_flags , True ) ;
This is another rather major change to the samba authenticaion
subystem.
The particular aim is to modularized the interface - so that we
can have arbitrary password back-ends.
This code adds one such back-end, a 'winbind' module to authenticate
against the winbind_auth_crap functionality. While fully-functional
this code is mainly useful as a demonstration, because we don't get
back the info3 as we would for direct ntdomain authentication.
This commit introduced the new 'auth methods' parameter, in the
spirit of the 'auth order' discussed on the lists. It is renamed
because not all the methods may be consulted, even if previous
methods fail - they may not have a suitable challenge for example.
Also, we have a 'local' authentication method, for old-style
'unix if plaintext, sam if encrypted' authentication and a
'guest' module to handle guest logins in a single place.
While this current design is not ideal, I feel that it does
provide a better infrastructure than the current design, and can
be built upon.
The following parameters have changed:
- use rhosts =
This has been replaced by the 'rhosts' authentication method,
and can be specified like 'auth methods = guest rhosts'
- hosts equiv =
This needs both this parameter and an 'auth methods' entry
to be effective. (auth methods = guest hostsequiv ....)
- plaintext to smbpasswd =
This is replaced by specifying 'sam' rather than 'local'
in the auth methods.
The security = parameter is unchanged, and now provides defaults
for the 'auth methods' parameter.
The available auth methods are:
guest
rhosts
hostsequiv
sam (passdb direct hash access)
unix (PAM, crypt() etc)
local (the combination of the above, based on encryption)
smbserver (old security=server)
ntdomain (old security=domain)
winbind (use winbind to cache DC connections)
Assistance in testing, or the production of new and interesting
authentication modules is always appreciated.
Andrew Bartlett
(This used to be commit 8d31eae52a9757739711dbb82035a4dfe6b40c99)
2001-11-24 15:12:38 +03:00
}
2001-11-09 01:19:01 +03:00
/****************************************************************************
Create a guest user_info blob , for anonymous authenticaion .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
BOOL make_user_info_guest ( auth_usersupplied_info * * user_info )
{
DATA_BLOB lm_blob = data_blob ( NULL , 0 ) ;
DATA_BLOB nt_blob = data_blob ( NULL , 0 ) ;
DATA_BLOB plaintext_blob = data_blob ( NULL , 0 ) ;
2002-01-11 08:29:09 +03:00
uint32 auth_flags = AUTH_FLAG_NONE ;
2002-09-25 19:19:00 +04:00
NTSTATUS nt_status ;
2001-11-09 01:19:01 +03:00
2002-09-25 19:19:00 +04:00
nt_status = make_user_info ( user_info ,
2001-11-09 01:19:01 +03:00
" " , " " ,
" " , " " ,
This is another rather major change to the samba authenticaion
subystem.
The particular aim is to modularized the interface - so that we
can have arbitrary password back-ends.
This code adds one such back-end, a 'winbind' module to authenticate
against the winbind_auth_crap functionality. While fully-functional
this code is mainly useful as a demonstration, because we don't get
back the info3 as we would for direct ntdomain authentication.
This commit introduced the new 'auth methods' parameter, in the
spirit of the 'auth order' discussed on the lists. It is renamed
because not all the methods may be consulted, even if previous
methods fail - they may not have a suitable challenge for example.
Also, we have a 'local' authentication method, for old-style
'unix if plaintext, sam if encrypted' authentication and a
'guest' module to handle guest logins in a single place.
While this current design is not ideal, I feel that it does
provide a better infrastructure than the current design, and can
be built upon.
The following parameters have changed:
- use rhosts =
This has been replaced by the 'rhosts' authentication method,
and can be specified like 'auth methods = guest rhosts'
- hosts equiv =
This needs both this parameter and an 'auth methods' entry
to be effective. (auth methods = guest hostsequiv ....)
- plaintext to smbpasswd =
This is replaced by specifying 'sam' rather than 'local'
in the auth methods.
The security = parameter is unchanged, and now provides defaults
for the 'auth methods' parameter.
The available auth methods are:
guest
rhosts
hostsequiv
sam (passdb direct hash access)
unix (PAM, crypt() etc)
local (the combination of the above, based on encryption)
smbserver (old security=server)
ntdomain (old security=domain)
winbind (use winbind to cache DC connections)
Assistance in testing, or the production of new and interesting
authentication modules is always appreciated.
Andrew Bartlett
(This used to be commit 8d31eae52a9757739711dbb82035a4dfe6b40c99)
2001-11-24 15:12:38 +03:00
" " ,
2001-11-09 01:19:01 +03:00
nt_blob , lm_blob ,
plaintext_blob ,
2002-01-11 08:29:09 +03:00
auth_flags , True ) ;
2002-09-25 19:19:00 +04:00
return NT_STATUS_IS_OK ( nt_status ) ? True : False ;
}
/****************************************************************************
prints a NT_USER_TOKEN to debug output .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void debug_nt_user_token ( int dbg_class , int dbg_lev , NT_USER_TOKEN * token )
{
fstring sid_str ;
2003-01-14 10:26:12 +03:00
size_t i ;
2002-09-25 19:19:00 +04:00
if ( ! token ) {
DEBUGC ( dbg_class , dbg_lev , ( " NT user token: (NULL) \n " ) ) ;
return ;
}
DEBUGC ( dbg_class , dbg_lev , ( " NT user token of user %s \n " ,
sid_to_string ( sid_str , & token - > user_sids [ 0 ] ) ) ) ;
DEBUGADDC ( dbg_class , dbg_lev , ( " contains %i SIDs \n " , token - > num_sids ) ) ;
for ( i = 0 ; i < token - > num_sids ; i + + )
DEBUGADDC ( dbg_class , dbg_lev , ( " SID[%3i]: %s \n " , i ,
sid_to_string ( sid_str , & token - > user_sids [ i ] ) ) ) ;
}
/****************************************************************************
prints a UNIX ' token ' to debug output .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void debug_unix_user_token ( int dbg_class , int dbg_lev , uid_t uid , gid_t gid , int n_groups , gid_t * groups )
{
int i ;
DEBUGC ( dbg_class , dbg_lev , ( " UNIX token of user %ld \n " , ( long int ) uid ) ) ;
DEBUGADDC ( dbg_class , dbg_lev , ( " Primary group is %ld and contains %i supplementary groups \n " , ( long int ) gid , n_groups ) ) ;
for ( i = 0 ; i < n_groups ; i + + )
DEBUGADDC ( dbg_class , dbg_lev , ( " Group[%3i]: %ld \n " , i ,
( long int ) groups [ i ] ) ) ;
}
/****************************************************************************
Create the SID list for this user .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
static NTSTATUS create_nt_user_token ( const DOM_SID * user_sid , const DOM_SID * group_sid ,
int n_groupSIDs , DOM_SID * groupSIDs ,
BOOL is_guest , NT_USER_TOKEN * * token )
{
NTSTATUS nt_status = NT_STATUS_OK ;
NT_USER_TOKEN * ptoken ;
int i ;
int sid_ndx ;
if ( ( ptoken = malloc ( sizeof ( NT_USER_TOKEN ) ) ) = = NULL ) {
DEBUG ( 0 , ( " create_nt_token: Out of memory allocating token \n " ) ) ;
nt_status = NT_STATUS_NO_MEMORY ;
return nt_status ;
}
ZERO_STRUCTP ( ptoken ) ;
ptoken - > num_sids = n_groupSIDs + 5 ;
if ( ( ptoken - > user_sids = ( DOM_SID * ) malloc ( sizeof ( DOM_SID ) * ptoken - > num_sids ) ) = = NULL ) {
DEBUG ( 0 , ( " create_nt_token: Out of memory allocating SIDs \n " ) ) ;
nt_status = NT_STATUS_NO_MEMORY ;
return nt_status ;
}
memset ( ( char * ) ptoken - > user_sids , 0 , sizeof ( DOM_SID ) * ptoken - > num_sids ) ;
/*
* Note - user SID * MUST * be first in token !
* se_access_check depends on this .
*
* Primary group SID is second in token . Convention .
*/
sid_copy ( & ptoken - > user_sids [ PRIMARY_USER_SID_INDEX ] , user_sid ) ;
if ( group_sid )
sid_copy ( & ptoken - > user_sids [ PRIMARY_GROUP_SID_INDEX ] , group_sid ) ;
/*
* Finally add the " standard " SIDs .
* The only difference between guest and " anonymous " ( which we
* don ' t really support ) is the addition of Authenticated_Users .
*/
sid_copy ( & ptoken - > user_sids [ 2 ] , & global_sid_World ) ;
sid_copy ( & ptoken - > user_sids [ 3 ] , & global_sid_Network ) ;
if ( is_guest )
sid_copy ( & ptoken - > user_sids [ 4 ] , & global_sid_Builtin_Guests ) ;
else
sid_copy ( & ptoken - > user_sids [ 4 ] , & global_sid_Authenticated_Users ) ;
sid_ndx = 5 ; /* next available spot */
for ( i = 0 ; i < n_groupSIDs ; i + + ) {
2003-01-14 10:26:12 +03:00
size_t check_sid_idx ;
2002-09-25 19:19:00 +04:00
for ( check_sid_idx = 1 ; check_sid_idx < ptoken - > num_sids ; check_sid_idx + + ) {
if ( sid_equal ( & ptoken - > user_sids [ check_sid_idx ] ,
& groupSIDs [ i ] ) ) {
break ;
}
}
if ( check_sid_idx > = ptoken - > num_sids ) /* Not found already */ {
sid_copy ( & ptoken - > user_sids [ sid_ndx + + ] , & groupSIDs [ i ] ) ;
} else {
ptoken - > num_sids - - ;
}
}
debug_nt_user_token ( DBGC_AUTH , 10 , ptoken ) ;
* token = ptoken ;
return nt_status ;
}
/****************************************************************************
Create the SID list for this user .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
NT_USER_TOKEN * create_nt_token ( uid_t uid , gid_t gid , int ngroups , gid_t * groups , BOOL is_guest )
{
DOM_SID user_sid ;
DOM_SID group_sid ;
DOM_SID * group_sids ;
NT_USER_TOKEN * token ;
int i ;
2003-06-22 14:09:52 +04:00
if ( ! NT_STATUS_IS_OK ( uid_to_sid ( & user_sid , uid ) ) ) {
2002-09-25 19:19:00 +04:00
return NULL ;
}
2003-06-22 14:09:52 +04:00
if ( ! NT_STATUS_IS_OK ( gid_to_sid ( & group_sid , gid ) ) ) {
2002-09-25 19:19:00 +04:00
return NULL ;
}
2003-05-12 22:12:31 +04:00
group_sids = malloc ( sizeof ( DOM_SID ) * ngroups ) ;
2002-09-25 19:19:00 +04:00
if ( ! group_sids ) {
DEBUG ( 0 , ( " create_nt_token: malloc() failed for DOM_SID list! \n " ) ) ;
return NULL ;
}
for ( i = 0 ; i < ngroups ; i + + ) {
2003-06-22 14:09:52 +04:00
if ( ! NT_STATUS_IS_OK ( gid_to_sid ( & ( group_sids ) [ i ] , ( groups ) [ i ] ) ) ) {
2002-09-25 19:19:00 +04:00
DEBUG ( 1 , ( " create_nt_token: failed to convert gid %ld to a sid! \n " , ( long int ) groups [ i ] ) ) ;
SAFE_FREE ( group_sids ) ;
return NULL ;
}
}
if ( ! NT_STATUS_IS_OK ( create_nt_user_token ( & user_sid , & group_sid ,
ngroups , group_sids , is_guest , & token ) ) ) {
SAFE_FREE ( group_sids ) ;
return NULL ;
}
SAFE_FREE ( group_sids ) ;
return token ;
}
/******************************************************************************
* this function returns the groups ( SIDs ) of the local SAM the user is in .
* If this samba server is a DC of the domain the user belongs to , it returns
* both domain groups and local / builtin groups . If the user is in a trusted
* domain , or samba is a member server of a domain , then this function returns
2003-05-12 22:12:31 +04:00
* local and builtin groups the user is a member of .
2002-09-25 19:19:00 +04:00
*
* currently this is a hack , as there is no sam implementation that is capable
* of groups .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-06-12 18:24:15 +04:00
static NTSTATUS get_user_groups_from_local_sam ( const char * username , uid_t uid , gid_t gid ,
2002-09-25 19:19:00 +04:00
int * n_groups , DOM_SID * * groups , gid_t * * unix_groups )
{
int n_unix_groups ;
int i ;
2003-02-24 05:35:54 +03:00
2002-09-25 19:19:00 +04:00
* n_groups = 0 ;
* groups = NULL ;
n_unix_groups = groups_max ( ) ;
2003-02-10 14:47:21 +03:00
if ( ( * unix_groups = malloc ( sizeof ( gid_t ) * n_unix_groups ) ) = = NULL ) {
2002-09-25 19:19:00 +04:00
DEBUG ( 0 , ( " get_user_groups_from_local_sam: Out of memory allocating unix group list \n " ) ) ;
return NT_STATUS_NO_MEMORY ;
}
2003-06-12 18:24:15 +04:00
if ( sys_getgrouplist ( username , gid , * unix_groups , & n_unix_groups ) = = - 1 ) {
2003-02-10 14:47:21 +03:00
gid_t * groups_tmp ;
groups_tmp = Realloc ( * unix_groups , sizeof ( gid_t ) * n_unix_groups ) ;
if ( ! groups_tmp ) {
SAFE_FREE ( * unix_groups ) ;
return NT_STATUS_NO_MEMORY ;
}
* unix_groups = groups_tmp ;
2003-06-12 18:24:15 +04:00
if ( sys_getgrouplist ( username , gid , * unix_groups , & n_unix_groups ) = = - 1 ) {
2002-09-25 19:19:00 +04:00
DEBUG ( 0 , ( " get_user_groups_from_local_sam: failed to get the unix group list \n " ) ) ;
2003-01-14 02:07:26 +03:00
SAFE_FREE ( * unix_groups ) ;
2002-09-25 19:19:00 +04:00
return NT_STATUS_NO_SUCH_USER ; /* what should this return value be? */
}
}
2003-02-24 05:35:54 +03:00
debug_unix_user_token ( DBGC_CLASS , 5 , uid , gid , n_unix_groups , * unix_groups ) ;
2002-09-25 19:19:00 +04:00
if ( n_unix_groups > 0 ) {
* groups = malloc ( sizeof ( DOM_SID ) * n_unix_groups ) ;
if ( ! * groups ) {
DEBUG ( 0 , ( " get_user_group_from_local_sam: malloc() failed for DOM_SID list! \n " ) ) ;
2003-01-14 02:07:26 +03:00
SAFE_FREE ( * unix_groups ) ;
2002-09-25 19:19:00 +04:00
return NT_STATUS_NO_MEMORY ;
}
}
* n_groups = n_unix_groups ;
for ( i = 0 ; i < * n_groups ; i + + ) {
2003-06-22 14:09:52 +04:00
if ( ! NT_STATUS_IS_OK ( gid_to_sid ( & ( * groups ) [ i ] , ( * unix_groups ) [ i ] ) ) ) {
2003-01-14 02:07:26 +03:00
DEBUG ( 1 , ( " get_user_groups_from_local_sam: failed to convert gid %ld to a sid! \n " , ( long int ) ( * unix_groups ) [ i + 1 ] ) ) ;
SAFE_FREE ( * groups ) ;
SAFE_FREE ( * unix_groups ) ;
2002-09-25 19:19:00 +04:00
return NT_STATUS_NO_SUCH_USER ;
}
}
return NT_STATUS_OK ;
2001-11-09 01:19:01 +03:00
}
2001-11-11 14:34:46 +03:00
/***************************************************************************
Make a user_info struct
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-06-12 18:24:15 +04:00
static NTSTATUS make_server_info ( auth_serversupplied_info * * server_info )
2001-10-31 13:46:25 +03:00
{
* server_info = malloc ( sizeof ( * * server_info ) ) ;
if ( ! * server_info ) {
2001-11-11 14:34:46 +03:00
DEBUG ( 0 , ( " make_server_info: malloc failed! \n " ) ) ;
2002-09-25 19:19:00 +04:00
return NT_STATUS_NO_MEMORY ;
2001-10-31 13:46:25 +03:00
}
ZERO_STRUCTP ( * server_info ) ;
2002-09-25 19:19:00 +04:00
return NT_STATUS_OK ;
2001-10-31 13:46:25 +03:00
}
2001-11-11 14:34:46 +03:00
/***************************************************************************
2003-06-12 18:24:15 +04:00
Fill a server_info struct from a SAM_ACCOUNT with their groups
2001-11-11 14:34:46 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-06-12 18:24:15 +04:00
static NTSTATUS add_user_groups ( auth_serversupplied_info * * server_info ,
SAM_ACCOUNT * sampass ,
uid_t uid , gid_t gid )
2001-10-31 13:46:25 +03:00
{
2003-06-12 18:24:15 +04:00
NTSTATUS nt_status ;
2002-09-25 19:19:00 +04:00
const DOM_SID * user_sid = pdb_get_user_sid ( sampass ) ;
const DOM_SID * group_sid = pdb_get_group_sid ( sampass ) ;
int n_groupSIDs = 0 ;
DOM_SID * groupSIDs = NULL ;
gid_t * unix_groups = NULL ;
NT_USER_TOKEN * token ;
BOOL is_guest ;
uint32 rid ;
2003-06-12 18:24:15 +04:00
nt_status = get_user_groups_from_local_sam ( pdb_get_username ( sampass ) ,
uid , gid ,
& n_groupSIDs , & groupSIDs ,
& unix_groups ) ;
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
2002-09-25 19:19:00 +04:00
DEBUG ( 4 , ( " get_user_groups_from_local_sam failed \n " ) ) ;
free_server_info ( server_info ) ;
return nt_status ;
}
is_guest = ( sid_peek_rid ( user_sid , & rid ) & & rid = = DOMAIN_USER_RID_GUEST ) ;
if ( ! NT_STATUS_IS_OK ( nt_status = create_nt_user_token ( user_sid , group_sid ,
n_groupSIDs , groupSIDs , is_guest ,
& token ) ) )
{
DEBUG ( 4 , ( " create_nt_user_token failed \n " ) ) ;
SAFE_FREE ( groupSIDs ) ;
SAFE_FREE ( unix_groups ) ;
free_server_info ( server_info ) ;
return nt_status ;
2001-10-31 13:46:25 +03:00
}
2002-09-25 19:19:00 +04:00
SAFE_FREE ( groupSIDs ) ;
2001-10-31 13:46:25 +03:00
2002-09-25 19:19:00 +04:00
( * server_info ) - > n_groups = n_groupSIDs ;
( * server_info ) - > groups = unix_groups ;
( * server_info ) - > ptok = token ;
2003-06-12 18:24:15 +04:00
return nt_status ;
}
/***************************************************************************
Make ( and fill ) a user_info struct from a SAM_ACCOUNT
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
NTSTATUS make_server_info_sam ( auth_serversupplied_info * * server_info ,
SAM_ACCOUNT * sampass )
{
NTSTATUS nt_status ;
if ( ! NT_STATUS_IS_OK ( nt_status = make_server_info ( server_info ) ) )
return nt_status ;
( * server_info ) - > sam_account = sampass ;
if ( ! NT_STATUS_IS_OK ( nt_status = sid_to_uid ( pdb_get_user_sid ( sampass ) , & ( ( * server_info ) - > uid ) ) ) )
return nt_status ;
if ( ! NT_STATUS_IS_OK ( nt_status = sid_to_gid ( pdb_get_group_sid ( sampass ) , & ( ( * server_info ) - > gid ) ) ) )
return nt_status ;
if ( ! NT_STATUS_IS_OK ( nt_status = add_user_groups ( server_info , sampass ,
( * server_info ) - > uid , ( * server_info ) - > gid ) ) )
return nt_status ;
( * server_info ) - > sam_fill_level = SAM_FILL_ALL ;
2001-11-11 14:34:46 +03:00
DEBUG ( 5 , ( " make_server_info_sam: made server info for user %s \n " ,
2001-10-31 13:46:25 +03:00
pdb_get_username ( ( * server_info ) - > sam_account ) ) ) ;
2002-09-25 19:19:00 +04:00
return nt_status ;
2001-10-31 13:46:25 +03:00
}
2001-11-11 14:34:46 +03:00
/***************************************************************************
Make ( and fill ) a user_info struct from a ' struct passwd ' by conversion
to a SAM_ACCOUNT
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-09-25 19:19:00 +04:00
NTSTATUS make_server_info_pw ( auth_serversupplied_info * * server_info , const struct passwd * pwd )
2001-10-31 13:46:25 +03:00
{
2002-09-25 19:19:00 +04:00
NTSTATUS nt_status ;
2001-10-31 13:46:25 +03:00
SAM_ACCOUNT * sampass = NULL ;
2002-09-25 19:19:00 +04:00
if ( ! NT_STATUS_IS_OK ( nt_status = pdb_init_sam_pw ( & sampass , pwd ) ) ) {
return nt_status ;
2001-10-31 13:46:25 +03:00
}
2003-06-12 18:24:15 +04:00
if ( ! NT_STATUS_IS_OK ( nt_status = make_server_info ( server_info ) ) ) {
return nt_status ;
}
( * server_info ) - > sam_account = sampass ;
if ( ! NT_STATUS_IS_OK ( nt_status = add_user_groups ( server_info , sampass , pwd - > pw_uid , pwd - > pw_gid ) ) ) {
return nt_status ;
}
( * server_info ) - > sam_fill_level = SAM_FILL_ALL ;
( * server_info ) - > uid = pwd - > pw_uid ;
( * server_info ) - > gid = pwd - > pw_gid ;
return nt_status ;
2001-10-31 13:46:25 +03:00
}
2001-11-11 14:34:46 +03:00
/***************************************************************************
2002-09-25 19:19:00 +04:00
Make ( and fill ) a user_info struct for a guest login .
2001-11-11 14:34:46 +03:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-09-25 19:19:00 +04:00
NTSTATUS make_server_info_guest ( auth_serversupplied_info * * server_info )
2001-10-31 13:46:25 +03:00
{
2002-09-25 19:19:00 +04:00
NTSTATUS nt_status ;
SAM_ACCOUNT * sampass = NULL ;
DOM_SID guest_sid ;
if ( ! NT_STATUS_IS_OK ( nt_status = pdb_init_sam ( & sampass ) ) ) {
return nt_status ;
2001-10-31 13:46:25 +03:00
}
2002-09-25 19:19:00 +04:00
sid_copy ( & guest_sid , get_global_sam_sid ( ) ) ;
sid_append_rid ( & guest_sid , DOMAIN_USER_RID_GUEST ) ;
2001-11-04 02:34:24 +03:00
2002-11-16 00:43:57 +03:00
become_root ( ) ;
2002-09-25 19:19:00 +04:00
if ( ! pdb_getsampwsid ( sampass , & guest_sid ) ) {
2002-11-16 00:43:57 +03:00
unbecome_root ( ) ;
2002-09-25 19:19:00 +04:00
return NT_STATUS_NO_SUCH_USER ;
2001-10-31 13:46:25 +03:00
}
2002-11-16 00:43:57 +03:00
unbecome_root ( ) ;
2001-10-31 13:46:25 +03:00
2002-09-25 19:19:00 +04:00
nt_status = make_server_info_sam ( server_info , sampass ) ;
2001-11-04 02:34:24 +03:00
2003-02-24 05:35:54 +03:00
if ( NT_STATUS_IS_OK ( nt_status ) ) {
( * server_info ) - > guest = True ;
}
2002-09-25 19:19:00 +04:00
return nt_status ;
2001-10-31 13:46:25 +03:00
}
2003-06-12 11:21:26 +04:00
/***************************************************************************
Purely internal function for make_server_info_info3
Fill the sam account from getpwnam
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2003-06-11 20:36:04 +04:00
static NTSTATUS fill_sam_account ( const char * domain ,
const char * username ,
2003-06-12 18:24:15 +04:00
uid_t * uid , gid_t * gid ,
2003-06-11 20:36:04 +04:00
SAM_ACCOUNT * * sam_account )
{
fstring dom_user ;
struct passwd * passwd ;
fstr_sprintf ( dom_user , " %s%s%s " ,
domain , lp_winbind_separator ( ) , username ) ;
passwd = Get_Pwnam ( dom_user ) ;
if ( ( passwd = = NULL ) & & is_myworkgroup ( domain ) ) {
/* For our own domain also try unqualified */
passwd = Get_Pwnam ( username ) ;
}
if ( passwd = = NULL )
return NT_STATUS_NO_SUCH_USER ;
2003-06-12 18:24:15 +04:00
* uid = passwd - > pw_uid ;
* gid = passwd - > pw_gid ;
2003-06-12 11:21:26 +04:00
return pdb_init_sam_pw ( sam_account , passwd ) ;
2003-06-11 20:36:04 +04:00
}
2002-07-15 14:35:28 +04:00
/***************************************************************************
Make a server_info struct from the info3 returned by a domain logon
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
NTSTATUS make_server_info_info3 ( TALLOC_CTX * mem_ctx ,
const char * internal_username ,
const char * sent_nt_username ,
const char * domain ,
auth_serversupplied_info * * server_info ,
NET_USER_INFO_3 * info3 )
{
NTSTATUS nt_status = NT_STATUS_OK ;
const char * nt_domain ;
const char * nt_username ;
SAM_ACCOUNT * sam_account = NULL ;
DOM_SID user_sid ;
DOM_SID group_sid ;
struct passwd * passwd ;
2003-05-12 22:12:31 +04:00
unid_t u_id , g_id ;
2003-06-12 18:24:15 +04:00
uid_t uid ;
gid_t gid ;
2003-05-12 22:12:31 +04:00
int u_type , g_type ;
2002-07-15 14:35:28 +04:00
2002-09-25 19:19:00 +04:00
int n_lgroupSIDs ;
DOM_SID * lgroupSIDs = NULL ;
gid_t * unix_groups = NULL ;
NT_USER_TOKEN * token ;
DOM_SID * all_group_SIDs ;
2003-01-14 10:26:12 +03:00
size_t i ;
2002-09-25 19:19:00 +04:00
2002-07-15 14:35:28 +04:00
/*
Here is where we should check the list of
trusted domains , and verify that the SID
matches .
*/
sid_copy ( & user_sid , & info3 - > dom_sid . sid ) ;
if ( ! sid_append_rid ( & user_sid , info3 - > user_rid ) ) {
return NT_STATUS_INVALID_PARAMETER ;
}
sid_copy ( & group_sid , & info3 - > dom_sid . sid ) ;
if ( ! sid_append_rid ( & group_sid , info3 - > group_rid ) ) {
return NT_STATUS_INVALID_PARAMETER ;
}
if ( ! ( nt_username = unistr2_tdup ( mem_ctx , & ( info3 - > uni_user_name ) ) ) ) {
/* If the server didn't give us one, just use the one we sent them */
nt_username = sent_nt_username ;
}
if ( ! ( nt_domain = unistr2_tdup ( mem_ctx , & ( info3 - > uni_logon_dom ) ) ) ) {
/* If the server didn't give us one, just use the one we sent them */
domain = domain ;
}
2003-05-12 22:12:31 +04:00
u_type = ID_USERID ;
g_type = ID_GROUPID ;
2003-06-12 18:24:15 +04:00
/* we are trying to check that idmap isn't stuffing us over - does this
user actually exist ? */
2003-05-12 22:12:31 +04:00
if ( NT_STATUS_IS_OK ( idmap_get_id_from_sid ( & u_id , & u_type , & user_sid ) )
& & NT_STATUS_IS_OK ( idmap_get_id_from_sid ( & g_id , & g_type , & group_sid ) )
& & ( ( passwd = getpwuid_alloc ( u_id . uid ) ) ) ) {
2003-06-12 18:24:15 +04:00
2002-07-15 14:35:28 +04:00
nt_status = pdb_init_sam_pw ( & sam_account , passwd ) ;
2003-06-12 18:24:15 +04:00
uid = passwd - > pw_uid ;
gid = passwd - > pw_gid ;
/* we should check this is the same name */
2002-07-15 14:35:28 +04:00
passwd_free ( & passwd ) ;
} else {
2003-06-11 20:36:04 +04:00
2003-06-12 18:24:15 +04:00
/* User not from winbind - try and find them by getpwnam() */
2003-06-11 20:36:04 +04:00
nt_status = fill_sam_account ( nt_domain ,
internal_username ,
2003-06-12 18:24:15 +04:00
& uid , & gid ,
2003-06-11 20:36:04 +04:00
& sam_account ) ;
if ( NT_STATUS_EQUAL ( nt_status , NT_STATUS_NO_SUCH_USER ) ) {
DEBUG ( 3 , ( " User %s does not exist, trying to add it \n " ,
internal_username ) ) ;
auth_add_user_script ( nt_domain , internal_username ) ;
nt_status = fill_sam_account ( nt_domain ,
internal_username ,
2003-06-12 18:24:15 +04:00
& uid , & gid ,
2003-06-11 20:36:04 +04:00
& sam_account ) ;
2002-07-15 14:35:28 +04:00
}
}
if ( ! NT_STATUS_IS_OK ( nt_status ) ) {
DEBUG ( 0 , ( " make_server_info_info3: pdb_init_sam failed! \n " ) ) ;
return nt_status ;
}
2002-11-02 06:47:48 +03:00
if ( ! pdb_set_user_sid ( sam_account , & user_sid , PDB_CHANGED ) ) {
2002-07-15 14:35:28 +04:00
pdb_free_sam ( & sam_account ) ;
return NT_STATUS_UNSUCCESSFUL ;
}
2002-11-02 06:47:48 +03:00
if ( ! pdb_set_group_sid ( sam_account , & group_sid , PDB_CHANGED ) ) {
2002-07-15 14:35:28 +04:00
pdb_free_sam ( & sam_account ) ;
return NT_STATUS_UNSUCCESSFUL ;
}
2002-11-02 06:47:48 +03:00
if ( ! pdb_set_nt_username ( sam_account , nt_username , PDB_CHANGED ) ) {
2002-07-15 14:35:28 +04:00
pdb_free_sam ( & sam_account ) ;
return NT_STATUS_NO_MEMORY ;
}
2002-11-02 06:47:48 +03:00
if ( ! pdb_set_domain ( sam_account , nt_domain , PDB_CHANGED ) ) {
2002-07-15 14:35:28 +04:00
pdb_free_sam ( & sam_account ) ;
return NT_STATUS_NO_MEMORY ;
}
2003-01-04 11:57:51 +03:00
if ( ! pdb_set_fullname ( sam_account , unistr2_static ( & ( info3 - > uni_full_name ) ) , PDB_CHANGED ) ) {
2002-07-15 14:35:28 +04:00
pdb_free_sam ( & sam_account ) ;
return NT_STATUS_NO_MEMORY ;
}
2003-01-04 11:57:51 +03:00
if ( ! pdb_set_logon_script ( sam_account , unistr2_static ( & ( info3 - > uni_logon_script ) ) , PDB_CHANGED ) ) {
2002-07-15 14:35:28 +04:00
pdb_free_sam ( & sam_account ) ;
return NT_STATUS_NO_MEMORY ;
}
2003-01-04 11:57:51 +03:00
if ( ! pdb_set_profile_path ( sam_account , unistr2_static ( & ( info3 - > uni_profile_path ) ) , PDB_CHANGED ) ) {
2002-07-15 14:35:28 +04:00
pdb_free_sam ( & sam_account ) ;
return NT_STATUS_NO_MEMORY ;
}
2003-01-04 11:57:51 +03:00
if ( ! pdb_set_homedir ( sam_account , unistr2_static ( & ( info3 - > uni_home_dir ) ) , PDB_CHANGED ) ) {
2002-07-15 14:35:28 +04:00
pdb_free_sam ( & sam_account ) ;
return NT_STATUS_NO_MEMORY ;
}
2003-01-04 11:57:51 +03:00
if ( ! pdb_set_dir_drive ( sam_account , unistr2_static ( & ( info3 - > uni_dir_drive ) ) , PDB_CHANGED ) ) {
2002-07-15 14:35:28 +04:00
pdb_free_sam ( & sam_account ) ;
return NT_STATUS_NO_MEMORY ;
}
2003-06-12 18:24:15 +04:00
/* now that we have a SAM_ACCOUNT that looks real, make a server_info
to wrap it in , and use pass it on down */
if ( ! NT_STATUS_IS_OK ( nt_status = make_server_info ( server_info ) ) ) {
2002-09-25 19:19:00 +04:00
DEBUG ( 4 , ( " make_server_info failed! \n " ) ) ;
2002-07-15 14:35:28 +04:00
pdb_free_sam ( & sam_account ) ;
2002-09-25 19:19:00 +04:00
return nt_status ;
2002-07-15 14:35:28 +04:00
}
2003-06-12 18:24:15 +04:00
/* Fill in the unix info we found on the way */
( * server_info ) - > sam_fill_level = SAM_FILL_ALL ;
( * server_info ) - > uid = uid ;
( * server_info ) - > gid = gid ;
2002-07-15 14:35:28 +04:00
/* Store the user group information in the server_info
returned to the caller . */
2002-09-25 19:19:00 +04:00
if ( ! NT_STATUS_IS_OK ( nt_status
2003-06-12 18:24:15 +04:00
= get_user_groups_from_local_sam ( pdb_get_username ( sam_account ) ,
uid , gid ,
2002-09-25 19:19:00 +04:00
& n_lgroupSIDs ,
& lgroupSIDs ,
& unix_groups ) ) )
{
DEBUG ( 4 , ( " get_user_groups_from_local_sam failed \n " ) ) ;
return nt_status ;
}
( * server_info ) - > groups = unix_groups ;
( * server_info ) - > n_groups = n_lgroupSIDs ;
/* Create a 'combined' list of all SIDs we might want in the SD */
all_group_SIDs = malloc ( sizeof ( DOM_SID ) *
( n_lgroupSIDs + info3 - > num_groups2 +
info3 - > num_other_sids ) ) ;
if ( ! all_group_SIDs ) {
2003-06-12 12:22:55 +04:00
DEBUG ( 0 , ( " malloc() failed for DOM_SID list! \n " ) ) ;
2002-09-25 19:19:00 +04:00
SAFE_FREE ( lgroupSIDs ) ;
return NT_STATUS_NO_MEMORY ;
}
/* Copy the 'local' sids */
memcpy ( all_group_SIDs , lgroupSIDs , sizeof ( DOM_SID ) * n_lgroupSIDs ) ;
SAFE_FREE ( lgroupSIDs ) ;
/* and create (by appending rids) the 'domain' sids */
for ( i = 0 ; i < info3 - > num_groups2 ; i + + ) {
sid_copy ( & all_group_SIDs [ i + n_lgroupSIDs ] , & ( info3 - > dom_sid . sid ) ) ;
if ( ! sid_append_rid ( & all_group_SIDs [ i + n_lgroupSIDs ] , info3 - > gids [ i ] . g_rid ) ) {
nt_status = NT_STATUS_INVALID_PARAMETER ;
2003-06-12 12:22:55 +04:00
DEBUG ( 3 , ( " could not append additional group rid 0x%x \n " ,
2002-09-25 19:19:00 +04:00
info3 - > gids [ i ] . g_rid ) ) ;
SAFE_FREE ( lgroupSIDs ) ;
2002-07-15 14:35:28 +04:00
return nt_status ;
}
}
2002-09-25 19:19:00 +04:00
/* Copy 'other' sids. We need to do sid filtering here to
prevent possible elevation of privileges . See :
http : //www.microsoft.com/windows2000/techinfo/administration/security/sidfilter.asp
*/
for ( i = 0 ; i < info3 - > num_other_sids ; i + + )
sid_copy ( & all_group_SIDs [
n_lgroupSIDs + info3 - > num_groups2 + i ] ,
& info3 - > other_sids [ i ] . sid ) ;
/* Where are the 'global' sids... */
/* can the user be guest? if yes, where is it stored? */
if ( ! NT_STATUS_IS_OK (
nt_status = create_nt_user_token (
& user_sid , & group_sid ,
n_lgroupSIDs + info3 - > num_groups2 + info3 - > num_other_sids ,
all_group_SIDs , False , & token ) ) ) {
DEBUG ( 4 , ( " create_nt_user_token failed \n " ) ) ;
SAFE_FREE ( all_group_SIDs ) ;
return nt_status ;
}
( * server_info ) - > ptok = token ;
SAFE_FREE ( all_group_SIDs ) ;
2003-03-24 12:54:13 +03:00
memcpy ( ( * server_info ) - > session_key , info3 - > user_sess_key , sizeof ( ( * server_info ) - > session_key ) /* 16 */ ) ;
memcpy ( ( * server_info ) - > first_8_lm_hash , info3 - > padding , 8 ) ;
2002-07-15 14:35:28 +04:00
return NT_STATUS_OK ;
}
2002-09-25 19:19:00 +04:00
/***************************************************************************
Free a user_info struct
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void free_user_info ( auth_usersupplied_info * * user_info )
{
DEBUG ( 5 , ( " attempting to free (and zero) a user_info structure \n " ) ) ;
if ( * user_info ! = NULL ) {
if ( ( * user_info ) - > smb_name . str ) {
DEBUG ( 10 , ( " structure was created for %s \n " , ( * user_info ) - > smb_name . str ) ) ;
}
SAFE_FREE ( ( * user_info ) - > smb_name . str ) ;
SAFE_FREE ( ( * user_info ) - > internal_username . str ) ;
SAFE_FREE ( ( * user_info ) - > client_domain . str ) ;
SAFE_FREE ( ( * user_info ) - > domain . str ) ;
SAFE_FREE ( ( * user_info ) - > wksta_name . str ) ;
data_blob_free ( & ( * user_info ) - > lm_resp ) ;
data_blob_free ( & ( * user_info ) - > nt_resp ) ;
SAFE_FREE ( ( * user_info ) - > interactive_password ) ;
data_blob_clear_free ( & ( * user_info ) - > plaintext_password ) ;
ZERO_STRUCT ( * * user_info ) ;
}
SAFE_FREE ( * user_info ) ;
}
/***************************************************************************
Clear out a server_info struct that has been allocated
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void free_server_info ( auth_serversupplied_info * * server_info )
{
DEBUG ( 5 , ( " attempting to free (and zero) a server_info structure \n " ) ) ;
if ( * server_info ! = NULL ) {
pdb_free_sam ( & ( * server_info ) - > sam_account ) ;
/* call pam_end here, unless we know we are keeping it */
delete_nt_token ( & ( * server_info ) - > ptok ) ;
SAFE_FREE ( ( * server_info ) - > groups ) ;
ZERO_STRUCT ( * * server_info ) ;
}
SAFE_FREE ( * server_info ) ;
}
This is another rather major change to the samba authenticaion
subystem.
The particular aim is to modularized the interface - so that we
can have arbitrary password back-ends.
This code adds one such back-end, a 'winbind' module to authenticate
against the winbind_auth_crap functionality. While fully-functional
this code is mainly useful as a demonstration, because we don't get
back the info3 as we would for direct ntdomain authentication.
This commit introduced the new 'auth methods' parameter, in the
spirit of the 'auth order' discussed on the lists. It is renamed
because not all the methods may be consulted, even if previous
methods fail - they may not have a suitable challenge for example.
Also, we have a 'local' authentication method, for old-style
'unix if plaintext, sam if encrypted' authentication and a
'guest' module to handle guest logins in a single place.
While this current design is not ideal, I feel that it does
provide a better infrastructure than the current design, and can
be built upon.
The following parameters have changed:
- use rhosts =
This has been replaced by the 'rhosts' authentication method,
and can be specified like 'auth methods = guest rhosts'
- hosts equiv =
This needs both this parameter and an 'auth methods' entry
to be effective. (auth methods = guest hostsequiv ....)
- plaintext to smbpasswd =
This is replaced by specifying 'sam' rather than 'local'
in the auth methods.
The security = parameter is unchanged, and now provides defaults
for the 'auth methods' parameter.
The available auth methods are:
guest
rhosts
hostsequiv
sam (passdb direct hash access)
unix (PAM, crypt() etc)
local (the combination of the above, based on encryption)
smbserver (old security=server)
ntdomain (old security=domain)
winbind (use winbind to cache DC connections)
Assistance in testing, or the production of new and interesting
authentication modules is always appreciated.
Andrew Bartlett
(This used to be commit 8d31eae52a9757739711dbb82035a4dfe6b40c99)
2001-11-24 15:12:38 +03:00
/***************************************************************************
Make an auth_methods struct
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2002-01-05 07:55:41 +03:00
BOOL make_auth_methods ( struct auth_context * auth_context , auth_methods * * auth_method )
This is another rather major change to the samba authenticaion
subystem.
The particular aim is to modularized the interface - so that we
can have arbitrary password back-ends.
This code adds one such back-end, a 'winbind' module to authenticate
against the winbind_auth_crap functionality. While fully-functional
this code is mainly useful as a demonstration, because we don't get
back the info3 as we would for direct ntdomain authentication.
This commit introduced the new 'auth methods' parameter, in the
spirit of the 'auth order' discussed on the lists. It is renamed
because not all the methods may be consulted, even if previous
methods fail - they may not have a suitable challenge for example.
Also, we have a 'local' authentication method, for old-style
'unix if plaintext, sam if encrypted' authentication and a
'guest' module to handle guest logins in a single place.
While this current design is not ideal, I feel that it does
provide a better infrastructure than the current design, and can
be built upon.
The following parameters have changed:
- use rhosts =
This has been replaced by the 'rhosts' authentication method,
and can be specified like 'auth methods = guest rhosts'
- hosts equiv =
This needs both this parameter and an 'auth methods' entry
to be effective. (auth methods = guest hostsequiv ....)
- plaintext to smbpasswd =
This is replaced by specifying 'sam' rather than 'local'
in the auth methods.
The security = parameter is unchanged, and now provides defaults
for the 'auth methods' parameter.
The available auth methods are:
guest
rhosts
hostsequiv
sam (passdb direct hash access)
unix (PAM, crypt() etc)
local (the combination of the above, based on encryption)
smbserver (old security=server)
ntdomain (old security=domain)
winbind (use winbind to cache DC connections)
Assistance in testing, or the production of new and interesting
authentication modules is always appreciated.
Andrew Bartlett
(This used to be commit 8d31eae52a9757739711dbb82035a4dfe6b40c99)
2001-11-24 15:12:38 +03:00
{
2002-01-05 07:55:41 +03:00
if ( ! auth_context ) {
smb_panic ( " no auth_context supplied to make_auth_methods()! \n " ) ;
}
if ( ! auth_method ) {
smb_panic ( " make_auth_methods: pointer to auth_method pointer is NULL! \n " ) ;
}
* auth_method = talloc ( auth_context - > mem_ctx , sizeof ( * * auth_method ) ) ;
This is another rather major change to the samba authenticaion
subystem.
The particular aim is to modularized the interface - so that we
can have arbitrary password back-ends.
This code adds one such back-end, a 'winbind' module to authenticate
against the winbind_auth_crap functionality. While fully-functional
this code is mainly useful as a demonstration, because we don't get
back the info3 as we would for direct ntdomain authentication.
This commit introduced the new 'auth methods' parameter, in the
spirit of the 'auth order' discussed on the lists. It is renamed
because not all the methods may be consulted, even if previous
methods fail - they may not have a suitable challenge for example.
Also, we have a 'local' authentication method, for old-style
'unix if plaintext, sam if encrypted' authentication and a
'guest' module to handle guest logins in a single place.
While this current design is not ideal, I feel that it does
provide a better infrastructure than the current design, and can
be built upon.
The following parameters have changed:
- use rhosts =
This has been replaced by the 'rhosts' authentication method,
and can be specified like 'auth methods = guest rhosts'
- hosts equiv =
This needs both this parameter and an 'auth methods' entry
to be effective. (auth methods = guest hostsequiv ....)
- plaintext to smbpasswd =
This is replaced by specifying 'sam' rather than 'local'
in the auth methods.
The security = parameter is unchanged, and now provides defaults
for the 'auth methods' parameter.
The available auth methods are:
guest
rhosts
hostsequiv
sam (passdb direct hash access)
unix (PAM, crypt() etc)
local (the combination of the above, based on encryption)
smbserver (old security=server)
ntdomain (old security=domain)
winbind (use winbind to cache DC connections)
Assistance in testing, or the production of new and interesting
authentication modules is always appreciated.
Andrew Bartlett
(This used to be commit 8d31eae52a9757739711dbb82035a4dfe6b40c99)
2001-11-24 15:12:38 +03:00
if ( ! * auth_method ) {
DEBUG ( 0 , ( " make_auth_method: malloc failed! \n " ) ) ;
return False ;
}
ZERO_STRUCTP ( * auth_method ) ;
return True ;
}
2001-11-04 02:34:24 +03:00
/****************************************************************************
Delete a SID token .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
void delete_nt_token ( NT_USER_TOKEN * * pptoken )
{
if ( * pptoken ) {
2002-07-15 14:35:28 +04:00
NT_USER_TOKEN * ptoken = * pptoken ;
SAFE_FREE ( ptoken - > user_sids ) ;
ZERO_STRUCTP ( ptoken ) ;
2001-11-04 02:34:24 +03:00
}
SAFE_FREE ( * pptoken ) ;
}
/****************************************************************************
Duplicate a SID token .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
NT_USER_TOKEN * dup_nt_token ( NT_USER_TOKEN * ptoken )
{
NT_USER_TOKEN * token ;
if ( ! ptoken )
return NULL ;
if ( ( token = ( NT_USER_TOKEN * ) malloc ( sizeof ( NT_USER_TOKEN ) ) ) = = NULL )
return NULL ;
ZERO_STRUCTP ( token ) ;
if ( ( token - > user_sids = ( DOM_SID * ) memdup ( ptoken - > user_sids , sizeof ( DOM_SID ) * ptoken - > num_sids ) ) = = NULL ) {
SAFE_FREE ( token ) ;
return NULL ;
}
token - > num_sids = ptoken - > num_sids ;
return token ;
}
2002-01-05 07:55:41 +03:00
/**
* Squash an NT_STATUS in line with security requirements .
* In an attempt to avoid giving the whole game away when users
* are authenticating , NT replaces both NT_STATUS_NO_SUCH_USER and
* NT_STATUS_WRONG_PASSWORD with NT_STATUS_LOGON_FAILURE in certain situations
* ( session setups in particular ) .
*
* @ param nt_status NTSTATUS input for squashing .
* @ return the ' squashed ' nt_status
* */
NTSTATUS nt_status_squash ( NTSTATUS nt_status )
{
if NT_STATUS_IS_OK ( nt_status ) {
return nt_status ;
} else if NT_STATUS_EQUAL ( nt_status , NT_STATUS_NO_SUCH_USER ) {
/* Match WinXP and don't give the game away */
return NT_STATUS_LOGON_FAILURE ;
} else if NT_STATUS_EQUAL ( nt_status , NT_STATUS_WRONG_PASSWORD ) {
/* Match WinXP and don't give the game away */
return NT_STATUS_LOGON_FAILURE ;
} else {
return nt_status ;
}
}