2005-09-29 04:02:38 +04:00
/*
Unix SMB / CIFS implementation .
Handle user credentials ( as regards krb5 )
Copyright ( C ) Jelmer Vernooij 2005
Copyright ( C ) Tim Potter 2001
Copyright ( C ) Andrew Bartlett < abartlet @ samba . org > 2005
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-10 06:07:03 +04:00
the Free Software Foundation ; either version 3 of the License , or
2005-09-29 04:02:38 +04:00
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
2007-07-10 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2005-09-29 04:02:38 +04:00
*/
# include "includes.h"
# include "system/kerberos.h"
# include "auth/kerberos/kerberos.h"
2006-11-07 03:48:36 +03:00
# include "auth/credentials/credentials.h"
# include "auth/credentials/credentials_krb5.h"
2007-12-02 22:56:26 +03:00
# include "param/param.h"
2005-09-29 04:02:38 +04:00
2005-10-20 07:47:55 +04:00
int cli_credentials_get_krb5_context ( struct cli_credentials * cred ,
2007-12-02 22:56:26 +03:00
struct loadparm_context * lp_ctx ,
2005-10-20 07:47:55 +04:00
struct smb_krb5_context * * smb_krb5_context )
{
int ret ;
if ( cred - > smb_krb5_context ) {
* smb_krb5_context = cred - > smb_krb5_context ;
return 0 ;
}
2007-05-17 12:47:04 +04:00
ret = smb_krb5_init_context ( cred , cli_credentials_get_event_context ( cred ) ,
2007-12-02 22:56:26 +03:00
lp_ctx , & cred - > smb_krb5_context ) ;
2005-10-20 07:47:55 +04:00
if ( ret ) {
return ret ;
}
* smb_krb5_context = cred - > smb_krb5_context ;
return 0 ;
}
2005-09-29 04:02:38 +04:00
2006-01-24 08:31:08 +03:00
/* This needs to be called directly after the cli_credentials_init(),
* otherwise we might have problems with the krb5 context already
* being here .
*/
NTSTATUS cli_credentials_set_krb5_context ( struct cli_credentials * cred ,
struct smb_krb5_context * smb_krb5_context )
{
if ( ! talloc_reference ( cred , smb_krb5_context ) ) {
return NT_STATUS_NO_MEMORY ;
}
cred - > smb_krb5_context = smb_krb5_context ;
return NT_STATUS_OK ;
}
2007-05-25 09:19:02 +04:00
static int cli_credentials_set_from_ccache ( struct cli_credentials * cred ,
struct ccache_container * ccache ,
2005-09-29 04:02:38 +04:00
enum credentials_obtained obtained )
{
krb5_principal princ ;
krb5_error_code ret ;
char * name ;
char * * realm ;
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
if ( cred - > ccache_obtained > obtained ) {
return 0 ;
}
2007-05-25 09:19:02 +04:00
ret = krb5_cc_get_principal ( ccache - > smb_krb5_context - > krb5_context ,
ccache - > ccache , & princ ) ;
2005-09-29 04:02:38 +04:00
if ( ret ) {
2007-05-25 09:19:02 +04:00
char * err_mess = smb_get_krb5_error_message ( ccache - > smb_krb5_context - > krb5_context ,
ret , cred ) ;
2005-09-29 04:02:38 +04:00
DEBUG ( 1 , ( " failed to get principal from ccache: %s \n " ,
err_mess ) ) ;
talloc_free ( err_mess ) ;
return ret ;
}
2007-05-25 09:19:02 +04:00
ret = krb5_unparse_name ( ccache - > smb_krb5_context - > krb5_context , princ , & name ) ;
2005-09-29 04:02:38 +04:00
if ( ret ) {
2007-05-25 09:19:02 +04:00
char * err_mess = smb_get_krb5_error_message ( ccache - > smb_krb5_context - > krb5_context , ret , cred ) ;
2005-09-29 04:02:38 +04:00
DEBUG ( 1 , ( " failed to unparse principal from ccache: %s \n " ,
err_mess ) ) ;
talloc_free ( err_mess ) ;
return ret ;
}
2007-05-25 09:19:02 +04:00
realm = krb5_princ_realm ( ccache - > smb_krb5_context - > krb5_context , princ ) ;
2005-09-29 04:02:38 +04:00
cli_credentials_set_principal ( cred , name , obtained ) ;
free ( name ) ;
2007-05-25 09:19:02 +04:00
krb5_free_principal ( ccache - > smb_krb5_context - > krb5_context , princ ) ;
2005-09-29 04:02:38 +04:00
2007-05-22 09:21:59 +04:00
/* set the ccache_obtained here, as it just got set to UNINITIALISED by the calls above */
2005-09-29 04:02:38 +04:00
cred - > ccache_obtained = obtained ;
return 0 ;
}
2005-11-02 03:31:22 +03:00
/* Free a memory ccache */
2006-05-24 11:32:17 +04:00
static int free_mccache ( struct ccache_container * ccc )
{
2005-09-29 04:02:38 +04:00
krb5_cc_destroy ( ccc - > smb_krb5_context - > krb5_context , ccc - > ccache ) ;
return 0 ;
}
2005-11-02 03:31:22 +03:00
/* Free a disk-based ccache */
2006-05-24 11:32:17 +04:00
static int free_dccache ( struct ccache_container * ccc ) {
2005-09-29 04:02:38 +04:00
krb5_cc_close ( ccc - > smb_krb5_context - > krb5_context , ccc - > ccache ) ;
return 0 ;
}
int cli_credentials_set_ccache ( struct cli_credentials * cred ,
const char * name ,
enum credentials_obtained obtained )
{
krb5_error_code ret ;
krb5_principal princ ;
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
struct ccache_container * ccc ;
if ( cred - > ccache_obtained > obtained ) {
return 0 ;
}
ccc = talloc ( cred , struct ccache_container ) ;
2005-09-29 04:02:38 +04:00
if ( ! ccc ) {
return ENOMEM ;
}
2007-12-04 01:33:16 +03:00
ret = cli_credentials_get_krb5_context ( cred , global_loadparm ,
& ccc - > smb_krb5_context ) ;
2005-09-29 04:02:38 +04:00
if ( ret ) {
talloc_free ( ccc ) ;
return ret ;
}
2007-04-28 20:38:06 +04:00
if ( ! talloc_reference ( ccc , ccc - > smb_krb5_context ) ) {
talloc_free ( ccc ) ;
return ENOMEM ;
}
2005-10-20 07:47:55 +04:00
2005-09-29 04:02:38 +04:00
if ( name ) {
ret = krb5_cc_resolve ( ccc - > smb_krb5_context - > krb5_context , name , & ccc - > ccache ) ;
if ( ret ) {
DEBUG ( 1 , ( " failed to read krb5 ccache: %s: %s \n " ,
name ,
smb_get_krb5_error_message ( ccc - > smb_krb5_context - > krb5_context , ret , ccc ) ) ) ;
talloc_free ( ccc ) ;
return ret ;
}
} else {
ret = krb5_cc_default ( ccc - > smb_krb5_context - > krb5_context , & ccc - > ccache ) ;
if ( ret ) {
DEBUG ( 3 , ( " failed to read default krb5 ccache: %s \n " ,
smb_get_krb5_error_message ( ccc - > smb_krb5_context - > krb5_context , ret , ccc ) ) ) ;
talloc_free ( ccc ) ;
return ret ;
}
}
talloc_set_destructor ( ccc , free_dccache ) ;
ret = krb5_cc_get_principal ( ccc - > smb_krb5_context - > krb5_context , ccc - > ccache , & princ ) ;
if ( ret ) {
DEBUG ( 3 , ( " failed to get principal from default ccache: %s \n " ,
smb_get_krb5_error_message ( ccc - > smb_krb5_context - > krb5_context , ret , ccc ) ) ) ;
talloc_free ( ccc ) ;
return ret ;
}
krb5_free_principal ( ccc - > smb_krb5_context - > krb5_context , princ ) ;
2007-05-25 09:19:02 +04:00
ret = cli_credentials_set_from_ccache ( cred , ccc , obtained ) ;
2005-09-29 04:02:38 +04:00
if ( ret ) {
return ret ;
}
2007-05-25 09:19:02 +04:00
cred - > ccache = ccc ;
cred - > ccache_obtained = obtained ;
talloc_steal ( cred , ccc ) ;
cli_credentials_invalidate_client_gss_creds ( cred , cred - > ccache_obtained ) ;
2005-09-29 04:02:38 +04:00
return 0 ;
}
2007-05-25 09:19:02 +04:00
static int cli_credentials_new_ccache ( struct cli_credentials * cred , struct ccache_container * * _ccc )
2005-09-29 04:02:38 +04:00
{
krb5_error_code ret ;
struct ccache_container * ccc = talloc ( cred , struct ccache_container ) ;
char * ccache_name ;
if ( ! ccc ) {
return ENOMEM ;
}
2007-10-19 07:41:32 +04:00
ccache_name = talloc_asprintf ( ccc , " MEMORY:%p " ,
ccc ) ;
2005-09-29 04:02:38 +04:00
if ( ! ccache_name ) {
talloc_free ( ccc ) ;
return ENOMEM ;
}
2007-12-04 01:33:16 +03:00
ret = cli_credentials_get_krb5_context ( cred , global_loadparm ,
& ccc - > smb_krb5_context ) ;
2005-09-29 04:02:38 +04:00
if ( ret ) {
talloc_free ( ccc ) ;
return ret ;
}
2007-04-28 20:38:06 +04:00
if ( ! talloc_reference ( ccc , ccc - > smb_krb5_context ) ) {
talloc_free ( ccc ) ;
return ENOMEM ;
}
2005-09-29 04:02:38 +04:00
2007-12-04 01:33:16 +03:00
ret = krb5_cc_resolve ( ccc - > smb_krb5_context - > krb5_context , ccache_name ,
& ccc - > ccache ) ;
2005-09-29 04:02:38 +04:00
if ( ret ) {
DEBUG ( 1 , ( " failed to generate a new krb5 ccache (%s): %s \n " ,
ccache_name ,
smb_get_krb5_error_message ( ccc - > smb_krb5_context - > krb5_context , ret , ccc ) ) ) ;
talloc_free ( ccache_name ) ;
talloc_free ( ccc ) ;
return ret ;
}
talloc_set_destructor ( ccc , free_mccache ) ;
talloc_free ( ccache_name ) ;
2007-05-25 09:19:02 +04:00
* _ccc = ccc ;
2005-11-02 03:31:22 +03:00
2005-09-29 04:02:38 +04:00
return ret ;
}
int cli_credentials_get_ccache ( struct cli_credentials * cred ,
struct ccache_container * * ccc )
{
krb5_error_code ret ;
2007-04-12 14:25:01 +04:00
if ( cred - > machine_account_pending ) {
cli_credentials_set_machine_account ( cred ) ;
}
2007-08-09 10:26:19 +04:00
if ( cred - > ccache_obtained > = cred - > ccache_threshold & &
cred - > ccache_obtained > CRED_UNINITIALISED ) {
2005-09-29 04:02:38 +04:00
* ccc = cred - > ccache ;
return 0 ;
}
if ( cli_credentials_is_anonymous ( cred ) ) {
return EINVAL ;
}
2007-05-25 09:19:02 +04:00
ret = cli_credentials_new_ccache ( cred , ccc ) ;
2005-09-29 04:02:38 +04:00
if ( ret ) {
return ret ;
}
2007-05-25 09:19:02 +04:00
ret = kinit_to_ccache ( cred , cred , ( * ccc ) - > smb_krb5_context , ( * ccc ) - > ccache ) ;
2005-09-29 04:02:38 +04:00
if ( ret ) {
return ret ;
}
2007-05-25 09:19:02 +04:00
ret = cli_credentials_set_from_ccache ( cred , * ccc ,
( MAX ( MAX ( cred - > principal_obtained ,
cred - > username_obtained ) ,
cred - > password_obtained ) ) ) ;
cred - > ccache = * ccc ;
cred - > ccache_obtained = cred - > principal_obtained ;
2005-09-29 04:02:38 +04:00
if ( ret ) {
return ret ;
}
2007-05-25 09:19:02 +04:00
cli_credentials_invalidate_client_gss_creds ( cred , cred - > ccache_obtained ) ;
2005-09-29 04:02:38 +04:00
return ret ;
}
2007-05-22 09:21:59 +04:00
void cli_credentials_invalidate_client_gss_creds ( struct cli_credentials * cred ,
enum credentials_obtained obtained )
{
/* If the caller just changed the username/password etc, then
* any cached credentials are now invalid */
if ( obtained > = cred - > client_gss_creds_obtained ) {
if ( cred - > client_gss_creds_obtained > CRED_UNINITIALISED ) {
2007-08-09 10:26:19 +04:00
talloc_unlink ( cred , cred - > client_gss_creds ) ;
2007-05-25 09:19:02 +04:00
cred - > client_gss_creds = NULL ;
2007-05-22 09:21:59 +04:00
}
cred - > client_gss_creds_obtained = CRED_UNINITIALISED ;
}
/* Now that we know that the data is 'this specified', then
* don ' t allow something less ' known ' to be returned as a
* ccache . Ie , if the username is on the commmand line , we
* don ' t want to later guess to use a file - based ccache */
if ( obtained > cred - > client_gss_creds_threshold ) {
cred - > client_gss_creds_threshold = obtained ;
}
}
void cli_credentials_invalidate_ccache ( struct cli_credentials * cred ,
enum credentials_obtained obtained )
{
/* If the caller just changed the username/password etc, then
* any cached credentials are now invalid */
if ( obtained > = cred - > ccache_obtained ) {
if ( cred - > ccache_obtained > CRED_UNINITIALISED ) {
2007-08-09 10:26:19 +04:00
talloc_unlink ( cred , cred - > ccache ) ;
2007-05-25 09:19:02 +04:00
cred - > ccache = NULL ;
2007-05-22 09:21:59 +04:00
}
cred - > ccache_obtained = CRED_UNINITIALISED ;
}
/* Now that we know that the data is 'this specified', then
* don ' t allow something less ' known ' to be returned as a
* ccache . Ie , if the username is on the commmand line , we
* don ' t want to later guess to use a file - based ccache */
if ( obtained > cred - > ccache_threshold ) {
cred - > ccache_threshold = obtained ;
}
cli_credentials_invalidate_client_gss_creds ( cred ,
obtained ) ;
}
2006-05-24 11:32:17 +04:00
static int free_gssapi_creds ( struct gssapi_creds_container * gcc )
{
2005-11-02 03:31:22 +03:00
OM_uint32 min_stat , maj_stat ;
2006-05-24 11:32:17 +04:00
maj_stat = gss_release_cred ( & min_stat , & gcc - > creds ) ;
2005-11-02 03:31:22 +03:00
return 0 ;
}
int cli_credentials_get_client_gss_creds ( struct cli_credentials * cred ,
struct gssapi_creds_container * * _gcc )
{
int ret = 0 ;
OM_uint32 maj_stat , min_stat ;
struct gssapi_creds_container * gcc ;
struct ccache_container * ccache ;
2007-08-09 10:26:19 +04:00
if ( cred - > client_gss_creds_obtained > = cred - > client_gss_creds_threshold & &
cred - > client_gss_creds_obtained > CRED_UNINITIALISED ) {
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
* _gcc = cred - > client_gss_creds ;
2005-11-02 03:31:22 +03:00
return 0 ;
}
ret = cli_credentials_get_ccache ( cred ,
& ccache ) ;
if ( ret ) {
DEBUG ( 1 , ( " Failed to get CCACHE for GSSAPI client: %s \n " , error_message ( ret ) ) ) ;
return ret ;
}
gcc = talloc ( cred , struct gssapi_creds_container ) ;
if ( ! gcc ) {
return ENOMEM ;
}
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
maj_stat = gss_krb5_import_cred ( & min_stat , ccache - > ccache , NULL , NULL ,
& gcc - > creds ) ;
2005-11-02 03:31:22 +03:00
if ( maj_stat ) {
if ( min_stat ) {
ret = min_stat ;
} else {
ret = EINVAL ;
}
}
if ( ret = = 0 ) {
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
cred - > client_gss_creds_obtained = cred - > ccache_obtained ;
2005-11-02 03:31:22 +03:00
talloc_set_destructor ( gcc , free_gssapi_creds ) ;
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
cred - > client_gss_creds = gcc ;
2005-11-02 03:31:22 +03:00
* _gcc = gcc ;
}
return ret ;
}
/**
2007-12-02 21:31:14 +03:00
Set a gssapi cred_id_t into the credentials system . ( Client case )
2005-11-02 03:31:22 +03:00
This grabs the credentials both ' intact ' and getting the krb5
ccache out of it . This routine can be generalised in future for
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
the case where we deal with GSSAPI mechs other than krb5 .
2005-11-02 03:31:22 +03:00
On sucess , the caller must not free gssapi_cred , as it now belongs
to the credentials system .
*/
2006-11-07 03:48:36 +03:00
int cli_credentials_set_client_gss_creds ( struct cli_credentials * cred ,
gss_cred_id_t gssapi_cred ,
enum credentials_obtained obtained )
2005-11-02 03:31:22 +03:00
{
int ret ;
OM_uint32 maj_stat , min_stat ;
struct ccache_container * ccc ;
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
struct gssapi_creds_container * gcc ;
if ( cred - > client_gss_creds_obtained > obtained ) {
return 0 ;
}
gcc = talloc ( cred , struct gssapi_creds_container ) ;
2005-11-02 03:31:22 +03:00
if ( ! gcc ) {
return ENOMEM ;
}
ret = cli_credentials_new_ccache ( cred , & ccc ) ;
if ( ret ! = 0 ) {
return ret ;
}
maj_stat = gss_krb5_copy_ccache ( & min_stat ,
gssapi_cred , ccc - > ccache ) ;
if ( maj_stat ) {
if ( min_stat ) {
ret = min_stat ;
} else {
ret = EINVAL ;
}
}
if ( ret = = 0 ) {
2007-05-25 09:19:02 +04:00
ret = cli_credentials_set_from_ccache ( cred , ccc , obtained ) ;
2005-11-02 03:31:22 +03:00
}
2007-05-25 09:19:02 +04:00
cred - > ccache = ccc ;
cred - > ccache_obtained = obtained ;
2005-11-02 03:31:22 +03:00
if ( ret = = 0 ) {
gcc - > creds = gssapi_cred ;
talloc_set_destructor ( gcc , free_gssapi_creds ) ;
2007-05-22 09:21:59 +04:00
/* set the clinet_gss_creds_obtained here, as it just
got set to UNINITIALISED by the calls above */
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
cred - > client_gss_creds_obtained = obtained ;
cred - > client_gss_creds = gcc ;
2005-11-02 03:31:22 +03:00
}
return ret ;
}
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
/* Get the keytab (actually, a container containing the krb5_keytab)
* attached to this context . If this hasn ' t been done or set before ,
* it will be generated from the password .
*/
2005-10-20 07:47:55 +04:00
int cli_credentials_get_keytab ( struct cli_credentials * cred ,
struct keytab_container * * _ktc )
{
krb5_error_code ret ;
struct keytab_container * ktc ;
struct smb_krb5_context * smb_krb5_context ;
2007-04-28 20:38:06 +04:00
const char * * enctype_strings ;
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
TALLOC_CTX * mem_ctx ;
2005-10-20 07:47:55 +04:00
if ( cred - > keytab_obtained > = ( MAX ( cred - > principal_obtained ,
cred - > username_obtained ) ) ) {
* _ktc = cred - > keytab ;
return 0 ;
}
if ( cli_credentials_is_anonymous ( cred ) ) {
return EINVAL ;
}
2007-12-02 22:56:26 +03:00
ret = cli_credentials_get_krb5_context ( cred , global_loadparm , & smb_krb5_context ) ;
2005-10-20 07:47:55 +04:00
if ( ret ) {
return ret ;
}
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
mem_ctx = talloc_new ( cred ) ;
if ( ! mem_ctx ) {
return ENOMEM ;
}
2007-04-28 20:38:06 +04:00
enctype_strings = cli_credentials_get_enctype_strings ( cred ) ;
ret = smb_krb5_create_memory_keytab ( mem_ctx , cred ,
smb_krb5_context ,
enctype_strings , & ktc ) ;
2005-10-20 07:47:55 +04:00
if ( ret ) {
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
talloc_free ( mem_ctx ) ;
2005-10-20 07:47:55 +04:00
return ret ;
}
cred - > keytab_obtained = ( MAX ( cred - > principal_obtained ,
cred - > username_obtained ) ) ;
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
talloc_steal ( cred , ktc ) ;
2005-10-20 07:47:55 +04:00
cred - > keytab = ktc ;
* _ktc = cred - > keytab ;
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
talloc_free ( mem_ctx ) ;
return ret ;
}
/* Given the name of a keytab (presumably in the format
* FILE : / etc / krb5 . keytab ) , open it and attach it */
2005-12-22 01:02:52 +03:00
int cli_credentials_set_keytab_name ( struct cli_credentials * cred ,
const char * keytab_name ,
enum credentials_obtained obtained )
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
{
krb5_error_code ret ;
struct keytab_container * ktc ;
struct smb_krb5_context * smb_krb5_context ;
TALLOC_CTX * mem_ctx ;
if ( cred - > keytab_obtained > = obtained ) {
return 0 ;
}
2007-12-02 22:56:26 +03:00
ret = cli_credentials_get_krb5_context ( cred , global_loadparm , & smb_krb5_context ) ;
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
if ( ret ) {
return ret ;
}
mem_ctx = talloc_new ( cred ) ;
if ( ! mem_ctx ) {
return ENOMEM ;
}
2005-12-22 01:02:52 +03:00
ret = smb_krb5_open_keytab ( mem_ctx , smb_krb5_context ,
keytab_name , & ktc ) ;
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
if ( ret ) {
return ret ;
}
cred - > keytab_obtained = obtained ;
talloc_steal ( cred , ktc ) ;
cred - > keytab = ktc ;
talloc_free ( mem_ctx ) ;
return ret ;
}
int cli_credentials_update_keytab ( struct cli_credentials * cred )
{
krb5_error_code ret ;
struct keytab_container * ktc ;
struct smb_krb5_context * smb_krb5_context ;
2007-04-28 20:38:06 +04:00
const char * * enctype_strings ;
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
TALLOC_CTX * mem_ctx ;
mem_ctx = talloc_new ( cred ) ;
if ( ! mem_ctx ) {
return ENOMEM ;
}
2007-12-02 22:56:26 +03:00
ret = cli_credentials_get_krb5_context ( cred , global_loadparm , & smb_krb5_context ) ;
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
if ( ret ) {
talloc_free ( mem_ctx ) ;
return ret ;
}
2007-04-28 20:38:06 +04:00
enctype_strings = cli_credentials_get_enctype_strings ( cred ) ;
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
ret = cli_credentials_get_keytab ( cred , & ktc ) ;
if ( ret ! = 0 ) {
talloc_free ( mem_ctx ) ;
return ret ;
}
2007-04-28 20:38:06 +04:00
ret = smb_krb5_update_keytab ( mem_ctx , cred , smb_krb5_context , enctype_strings , ktc ) ;
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
talloc_free ( mem_ctx ) ;
return ret ;
}
/* Get server gss credentials (in gsskrb5, this means the keytab) */
int cli_credentials_get_server_gss_creds ( struct cli_credentials * cred ,
struct gssapi_creds_container * * _gcc )
{
int ret = 0 ;
OM_uint32 maj_stat , min_stat ;
struct gssapi_creds_container * gcc ;
struct keytab_container * ktc ;
struct smb_krb5_context * smb_krb5_context ;
TALLOC_CTX * mem_ctx ;
krb5_principal princ ;
if ( cred - > server_gss_creds_obtained > = ( MAX ( cred - > keytab_obtained ,
MAX ( cred - > principal_obtained ,
cred - > username_obtained ) ) ) ) {
* _gcc = cred - > server_gss_creds ;
return 0 ;
}
2007-12-02 22:56:26 +03:00
ret = cli_credentials_get_krb5_context ( cred , global_loadparm , & smb_krb5_context ) ;
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00
if ( ret ) {
return ret ;
}
ret = cli_credentials_get_keytab ( cred ,
& ktc ) ;
if ( ret ) {
DEBUG ( 1 , ( " Failed to get keytab for GSSAPI server: %s \n " , error_message ( ret ) ) ) ;
return ret ;
}
mem_ctx = talloc_new ( cred ) ;
if ( ! mem_ctx ) {
return ENOMEM ;
}
ret = principal_from_credentials ( mem_ctx , cred , smb_krb5_context , & princ ) ;
if ( ret ) {
DEBUG ( 1 , ( " cli_credentials_get_server_gss_creds: makeing krb5 principal failed (%s) \n " ,
smb_get_krb5_error_message ( smb_krb5_context - > krb5_context ,
ret , mem_ctx ) ) ) ;
talloc_free ( mem_ctx ) ;
return ret ;
}
gcc = talloc ( cred , struct gssapi_creds_container ) ;
if ( ! gcc ) {
talloc_free ( mem_ctx ) ;
return ENOMEM ;
}
/* This creates a GSSAPI cred_id_t with the principal and keytab set */
maj_stat = gss_krb5_import_cred ( & min_stat , NULL , princ , ktc - > keytab ,
& gcc - > creds ) ;
if ( maj_stat ) {
if ( min_stat ) {
ret = min_stat ;
} else {
ret = EINVAL ;
}
}
if ( ret = = 0 ) {
cred - > server_gss_creds_obtained = cred - > keytab_obtained ;
talloc_set_destructor ( gcc , free_gssapi_creds ) ;
cred - > server_gss_creds = gcc ;
* _gcc = gcc ;
}
talloc_free ( mem_ctx ) ;
2005-10-20 07:47:55 +04:00
return ret ;
}
2005-09-29 04:02:38 +04:00
/**
* Set Kerberos KVNO
*/
void cli_credentials_set_kvno ( struct cli_credentials * cred ,
int kvno )
{
cred - > kvno = kvno ;
}
/**
* Return Kerberos KVNO
*/
int cli_credentials_get_kvno ( struct cli_credentials * cred )
{
return cred - > kvno ;
}
2007-04-28 20:38:06 +04:00
const char * * cli_credentials_get_enctype_strings ( struct cli_credentials * cred )
{
/* If this is ever made user-configurable, we need to add code
* to remove / hide the other entries from the generated
* keytab */
static const char * default_enctypes [ ] = {
" des-cbc-md5 " ,
" aes256-cts-hmac-sha1-96 " ,
" des3-cbc-sha1 " ,
" arcfour-hmac-md5 " ,
NULL
} ;
return default_enctypes ;
}
2005-10-20 14:28:16 +04:00
const char * cli_credentials_get_salt_principal ( struct cli_credentials * cred )
{
return cred - > salt_principal ;
}
void cli_credentials_set_salt_principal ( struct cli_credentials * cred , const char * principal )
{
cred - > salt_principal = talloc_strdup ( cred , principal ) ;
}
r11995: A big kerberos-related update.
This merges Samba4 up to current lorikeet-heimdal, which includes a
replacement for some Samba-specific hacks.
In particular, the credentials system now supplies GSS client and
server credentials. These are imported into GSS with
gss_krb5_import_creds(). Unfortunetly this can't take an MEMORY
keytab, so we now create a FILE based keytab as provision and join
time.
Because the keytab is now created in advance, we don't spend .4s at
negprot doing sha1 s2k calls. Also, because the keytab is read in
real time, any change in the server key will be correctly picked up by
the the krb5 code.
To mark entries in the secrets which should be exported to a keytab,
there is a new kerberosSecret objectClass. The new routine
cli_credentials_update_all_keytabs() searches for these, and updates
the keytabs.
This is called in the provision.js via the ejs wrapper
credentials_update_all_keytabs().
We can now (in theory) use a system-provided /etc/krb5.keytab, if
krb5Keytab: FILE:/etc/krb5.keytab
is added to the secrets.ldb record. By default the attribute
privateKeytab: secrets.keytab
is set, pointing to allow the whole private directory to be moved
without breaking the internal links.
(This used to be commit 6b75573df49c6210e1b9d71e108a9490976bd41d)
2005-12-01 08:20:39 +03:00