summaryrefslogtreecommitdiff
path: root/source4/auth/gensec/gensec_gssapi.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2005-12-01 05:20:39 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:46:56 -0500
commit9c6b7f2d62e134a4bc15efc04e05be25e4a53dc7 (patch)
tree8ef389a528fdc2caca79f279c086b4f8bea7afeb /source4/auth/gensec/gensec_gssapi.c
parent22f1de0998ee34be4c032b16e4a6d30c9f8e6b85 (diff)
downloadsamba-9c6b7f2d62e134a4bc15efc04e05be25e4a53dc7.tar.gz
samba-9c6b7f2d62e134a4bc15efc04e05be25e4a53dc7.tar.bz2
samba-9c6b7f2d62e134a4bc15efc04e05be25e4a53dc7.zip
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)
Diffstat (limited to 'source4/auth/gensec/gensec_gssapi.c')
-rw-r--r--source4/auth/gensec/gensec_gssapi.c61
1 files changed, 7 insertions, 54 deletions
diff --git a/source4/auth/gensec/gensec_gssapi.c b/source4/auth/gensec/gensec_gssapi.c
index b5a2dadd35..68da2567da 100644
--- a/source4/auth/gensec/gensec_gssapi.c
+++ b/source4/auth/gensec/gensec_gssapi.c
@@ -41,12 +41,9 @@ struct gensec_gssapi_state {
DATA_BLOB pac;
struct smb_krb5_context *smb_krb5_context;
- krb5_ccache ccache;
- const char *ccache_name;
- struct keytab_container *keytab;
struct gssapi_creds_container *client_cred;
+ struct gssapi_creds_container *server_cred;
- gss_cred_id_t cred;
gss_cred_id_t delegated_cred_handle;
};
@@ -81,10 +78,6 @@ static int gensec_gssapi_destory(void *ptr)
struct gensec_gssapi_state *gensec_gssapi_state = ptr;
OM_uint32 maj_stat, min_stat;
- if (gensec_gssapi_state->cred != GSS_C_NO_CREDENTIAL) {
- maj_stat = gss_release_cred(&min_stat,
- &gensec_gssapi_state->cred);
- }
if (gensec_gssapi_state->delegated_cred_handle != GSS_C_NO_CREDENTIAL) {
maj_stat = gss_release_cred(&min_stat,
&gensec_gssapi_state->delegated_cred_handle);
@@ -137,7 +130,6 @@ static NTSTATUS gensec_gssapi_start(struct gensec_security *gensec_security)
gensec_gssapi_state->session_key = data_blob(NULL, 0);
gensec_gssapi_state->pac = data_blob(NULL, 0);
- gensec_gssapi_state->cred = GSS_C_NO_CREDENTIAL;
gensec_gssapi_state->delegated_cred_handle = GSS_C_NO_CREDENTIAL;
talloc_set_destructor(gensec_gssapi_state, gensec_gssapi_destory);
@@ -167,11 +159,10 @@ static NTSTATUS gensec_gssapi_start(struct gensec_security *gensec_security)
static NTSTATUS gensec_gssapi_server_start(struct gensec_security *gensec_security)
{
NTSTATUS nt_status;
- OM_uint32 maj_stat, min_stat;
int ret;
- const char *principal;
struct gensec_gssapi_state *gensec_gssapi_state;
struct cli_credentials *machine_account;
+ struct gssapi_creds_container *gcc;
nt_status = gensec_gssapi_start(gensec_security);
if (!NT_STATUS_IS_OK(nt_status)) {
@@ -186,53 +177,15 @@ static NTSTATUS gensec_gssapi_server_start(struct gensec_security *gensec_securi
DEBUG(3, ("No machine account credentials specified\n"));
return NT_STATUS_INVALID_PARAMETER;
} else {
- ret = cli_credentials_get_keytab(machine_account, &gensec_gssapi_state->keytab);
+ ret = cli_credentials_get_server_gss_creds(machine_account, &gcc);
if (ret) {
- DEBUG(3, ("Could not create memory keytab!\n"));
+ DEBUG(1, ("Aquiring acceptor credentials failed: %s\n",
+ error_message(ret)));
return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
}
}
- principal = cli_credentials_get_principal(machine_account,
- machine_account);
-
- /* This might have been explicity set to NULL, ie use what the client calls us */
- if (principal) {
- gss_buffer_desc name_token;
-
- name_token.value = discard_const_p(uint8_t, principal);
- name_token.length = strlen(principal);
-
- maj_stat = gss_import_name (&min_stat,
- &name_token,
- GSS_C_NT_USER_NAME,
- &gensec_gssapi_state->server_name);
-
- if (maj_stat) {
- DEBUG(2, ("GSS Import name of %s failed: %s\n",
- (char *)name_token.value,
- gssapi_error_string(gensec_gssapi_state, maj_stat, min_stat)));
- return NT_STATUS_UNSUCCESSFUL;
- }
- } else {
- gensec_gssapi_state->server_name = GSS_C_NO_NAME;
- }
-
- maj_stat = gsskrb5_acquire_cred(&min_stat,
- gensec_gssapi_state->keytab->keytab,
- gensec_gssapi_state->server_name,
- GSS_C_INDEFINITE,
- GSS_C_NULL_OID_SET,
- GSS_C_ACCEPT,
- &gensec_gssapi_state->cred,
- NULL,
- NULL);
- if (maj_stat) {
- DEBUG(1, ("Aquiring acceptor credentails failed: %s\n",
- gssapi_error_string(gensec_gssapi_state, maj_stat, min_stat)));
- return NT_STATUS_CANT_ACCESS_DOMAIN_INFO;
- }
-
+ gensec_gssapi_state->server_cred = gcc;
return NT_STATUS_OK;
}
@@ -382,7 +335,7 @@ static NTSTATUS gensec_gssapi_update(struct gensec_security *gensec_security,
{
maj_stat = gss_accept_sec_context(&min_stat,
&gensec_gssapi_state->gssapi_context,
- gensec_gssapi_state->cred,
+ gensec_gssapi_state->server_cred->creds,
&input_token,
gensec_gssapi_state->input_chan_bindings,
&gensec_gssapi_state->client_name,