2001-08-12 15:19:57 +04:00
/*
2002-01-30 09:08:46 +03:00
Unix SMB / CIFS implementation .
2001-08-12 15:19:57 +04:00
Password and authentication handling
Copyright ( C ) Andrew Bartlett 2001
2010-04-11 13:50:55 +04:00
2001-08-12 15:19:57 +04:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-09 23:25:36 +04:00
the Free Software Foundation ; either version 3 of the License , or
2001-08-12 15:19:57 +04:00
( at your option ) any later version .
2010-04-11 13:50:55 +04:00
2001-08-12 15:19:57 +04:00
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 .
2010-04-11 13:50:55 +04:00
2001-08-12 15:19:57 +04:00
You should have received a copy of the GNU General Public License
2007-07-10 04:52:41 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2001-08-12 15:19:57 +04:00
*/
# include "includes.h"
2011-03-25 04:28:05 +03:00
# include "auth.h"
2011-02-25 19:14:22 +03:00
# include "system/passwd.h"
2011-06-15 13:32:12 +04:00
# include "../lib/tsocket/tsocket.h"
2001-08-12 15:19:57 +04:00
2002-07-15 14:35:28 +04:00
# undef DBGC_CLASS
# define DBGC_CLASS DBGC_AUTH
2001-12-30 13:54:58 +03:00
/** Check a plaintext username/password
*
* Cannot deal with an encrupted password in any manner whatsoever ,
* unless the account has a null password .
* */
2001-08-12 15:19:57 +04:00
2002-01-05 07:55:41 +03:00
static NTSTATUS check_unix_security ( const struct auth_context * auth_context ,
void * my_private_data ,
2002-01-01 06:10:32 +03:00
TALLOC_CTX * mem_ctx ,
2010-01-10 16:16:04 +03:00
const struct auth_usersupplied_info * user_info ,
2010-01-10 16:24:22 +03:00
struct auth_serversupplied_info * * server_info )
2001-08-12 15:19:57 +04:00
{
2001-09-04 11:13:01 +04:00
NTSTATUS nt_status ;
2001-09-19 09:26:11 +04:00
struct passwd * pass = NULL ;
2011-07-12 14:23:08 +04:00
const char * rhost ;
2001-09-19 09:26:11 +04:00
2010-06-01 14:30:56 +04:00
DEBUG ( 10 , ( " Check auth for: [%s] \n " , user_info - > mapped . account_name ) ) ;
2010-05-30 00:49:37 +04:00
2011-07-12 14:23:08 +04:00
if ( tsocket_address_is_inet ( user_info - > remote_host , " ip " ) ) {
rhost = tsocket_address_inet_addr_string ( user_info - > remote_host ,
talloc_tos ( ) ) ;
if ( rhost = = NULL ) {
return NT_STATUS_NO_MEMORY ;
}
} else {
rhost = " 127.0.0.1 " ;
2011-06-15 13:32:12 +04:00
}
2001-08-12 15:19:57 +04:00
become_root ( ) ;
2010-06-01 14:30:56 +04:00
pass = Get_Pwnam_alloc ( talloc_tos ( ) , user_info - > mapped . account_name ) ;
2001-09-19 09:26:11 +04:00
2002-01-17 11:45:58 +03:00
/** @todo This call assumes a ASCII password, no charset transformation is
2001-12-30 13:54:58 +03:00
done . We may need to revisit this * */
2001-09-20 17:15:35 +04:00
nt_status = pass_check ( pass ,
2010-06-01 14:30:56 +04:00
pass ? pass - > pw_name : user_info - > mapped . account_name ,
2011-06-15 13:32:12 +04:00
rhost ,
2010-06-01 15:52:01 +04:00
user_info - > password . plaintext ,
2010-07-29 15:16:09 +04:00
true ) ;
2010-04-11 13:50:55 +04:00
2001-11-01 08:02:41 +03:00
unbecome_root ( ) ;
2003-02-10 14:47:21 +03:00
if ( NT_STATUS_IS_OK ( nt_status ) ) {
2013-12-13 22:11:01 +04:00
if ( pass ! = NULL ) {
nt_status = make_server_info_pw ( mem_ctx ,
pass - > pw_name ,
pass ,
server_info ) ;
2001-11-01 08:02:41 +03:00
} else {
2017-02-17 22:59:42 +03:00
/* we need to do something more useful here */
2001-11-01 08:02:41 +03:00
nt_status = NT_STATUS_NO_SUCH_USER ;
2001-10-31 13:46:25 +03:00
}
}
2001-09-20 17:15:35 +04:00
2007-12-19 17:02:59 +03:00
TALLOC_FREE ( pass ) ;
2001-08-12 15:19:57 +04:00
return nt_status ;
}
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
/* module initialisation */
2003-06-04 20:40:50 +04:00
static NTSTATUS auth_init_unix ( struct auth_context * auth_context , const char * param , 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
{
2010-04-11 14:37:48 +04:00
struct auth_methods * result ;
2011-06-07 05:44:43 +04:00
result = talloc_zero ( auth_context , struct auth_methods ) ;
2010-04-11 14:37:48 +04:00
if ( result = = NULL ) {
2002-07-15 14:35:28 +04:00
return NT_STATUS_NO_MEMORY ;
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
}
2010-04-11 14:37:48 +04:00
result - > name = " unix " ;
result - > auth = check_unix_security ;
2002-01-05 07:55:41 +03:00
2010-04-11 14:37:48 +04:00
* auth_method = result ;
2002-07-15 14:35:28 +04:00
return NT_STATUS_OK ;
This is another rather major change to the samba authenticaion
subystem.
The particular aim is to modularized the interface - so that we
can have arbitrary password back-ends.
This code adds one such back-end, a 'winbind' module to authenticate
against the winbind_auth_crap functionality. While fully-functional
this code is mainly useful as a demonstration, because we don't get
back the info3 as we would for direct ntdomain authentication.
This commit introduced the new 'auth methods' parameter, in the
spirit of the 'auth order' discussed on the lists. It is renamed
because not all the methods may be consulted, even if previous
methods fail - they may not have a suitable challenge for example.
Also, we have a 'local' authentication method, for old-style
'unix if plaintext, sam if encrypted' authentication and a
'guest' module to handle guest logins in a single place.
While this current design is not ideal, I feel that it does
provide a better infrastructure than the current design, and can
be built upon.
The following parameters have changed:
- use rhosts =
This has been replaced by the 'rhosts' authentication method,
and can be specified like 'auth methods = guest rhosts'
- hosts equiv =
This needs both this parameter and an 'auth methods' entry
to be effective. (auth methods = guest hostsequiv ....)
- plaintext to smbpasswd =
This is replaced by specifying 'sam' rather than 'local'
in the auth methods.
The security = parameter is unchanged, and now provides defaults
for the 'auth methods' parameter.
The available auth methods are:
guest
rhosts
hostsequiv
sam (passdb direct hash access)
unix (PAM, crypt() etc)
local (the combination of the above, based on encryption)
smbserver (old security=server)
ntdomain (old security=domain)
winbind (use winbind to cache DC connections)
Assistance in testing, or the production of new and interesting
authentication modules is always appreciated.
Andrew Bartlett
(This used to be commit 8d31eae52a9757739711dbb82035a4dfe6b40c99)
2001-11-24 15:12:38 +03:00
}
2002-07-15 14:35:28 +04:00
2017-04-20 22:24:43 +03:00
NTSTATUS auth_unix_init ( TALLOC_CTX * mem_ctx )
2003-04-16 16:13:07 +04:00
{
2003-04-28 21:48:48 +04:00
return smb_register_auth ( AUTH_INTERFACE_VERSION , " unix " , auth_init_unix ) ;
2003-04-16 16:13:07 +04:00
}