summaryrefslogtreecommitdiff
path: root/source3/libads
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2002-04-15 04:55:37 +0000
committerAndrew Tridgell <tridge@samba.org>2002-04-15 04:55:37 +0000
commitf6929068a19ef65fad5928982fd4ac4434e1763e (patch)
treef8f2f13ed76f132893320182374fa8ab6ffe9d3e /source3/libads
parent1667a821060b8bbc1cef3db473f6967cd02f5886 (diff)
downloadsamba-f6929068a19ef65fad5928982fd4ac4434e1763e.tar.gz
samba-f6929068a19ef65fad5928982fd4ac4434e1763e.tar.bz2
samba-f6929068a19ef65fad5928982fd4ac4434e1763e.zip
by using a prompter function we can avoid the bug in the MIT kerberos
libraries with handling blank passwords. (This used to be commit 59d755ffb57c322a104ff8f52819956cafff1bac)
Diffstat (limited to 'source3/libads')
-rw-r--r--source3/libads/kerberos.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/source3/libads/kerberos.c b/source3/libads/kerberos.c
index 194a71275e..85518a6769 100644
--- a/source3/libads/kerberos.c
+++ b/source3/libads/kerberos.c
@@ -25,6 +25,28 @@
#ifdef HAVE_KRB5
/*
+ we use a prompter to avoid a crash bug in the kerberos libs when
+ dealing with empty passwords
+ this prompter is just a string copy ...
+*/
+static krb5_error_code
+kerb_prompter(krb5_context ctx, void *data,
+ const char *name,
+ const char *banner,
+ int num_prompts,
+ krb5_prompt prompts[])
+{
+ if (num_prompts == 0) return 0;
+
+ memset(prompts[0].reply->data, 0, prompts[0].reply->length);
+ if (prompts[0].reply->length > 0) {
+ strncpy(prompts[0].reply->data, data, prompts[0].reply->length-1);
+ prompts[0].reply->length = strlen(prompts[0].reply->data);
+ }
+ return 0;
+}
+
+/*
simulate a kinit, putting the tgt in the default cache location
remus@snapserver.com
*/
@@ -36,11 +58,6 @@ int kerberos_kinit_password(const char *principal, const char *password)
krb5_principal me;
krb5_creds my_creds;
- if (! *password) {
- /* kerberos dies on an empty password! */
- return KRB5_PARSE_MALFORMED;
- }
-
if ((code = krb5_init_context(&ctx)))
return code;
@@ -54,8 +71,9 @@ int kerberos_kinit_password(const char *principal, const char *password)
return code;
}
- if ((code = krb5_get_init_creds_password(ctx, &my_creds, me, (char*)password, NULL,
- NULL, 0, NULL, NULL))) {
+ if ((code = krb5_get_init_creds_password(ctx, &my_creds, me, NULL,
+ kerb_prompter,
+ password, 0, NULL, NULL))) {
krb5_free_principal(ctx, me);
krb5_free_context(ctx);
return code;