|
|
2fc102 |
From bbe47ea8ebe6373d0b05181eb27bb65432a9cc97 Mon Sep 17 00:00:00 2001
|
|
|
2fc102 |
From: Nathaniel McCallum <npmccallum@redhat.com>
|
|
|
2fc102 |
Date: Fri, 7 Mar 2014 12:21:11 -0500
|
|
|
2fc102 |
Subject: [PATCH 106/107] Fix krb5 changepw when FAST-only preauth methods are
|
|
|
2fc102 |
used (like OTP)
|
|
|
2fc102 |
|
|
|
2fc102 |
Before this patch, a different set of options was used when calling
|
|
|
2fc102 |
krb5_get_init_creds_password() for the changepw principal. Because
|
|
|
2fc102 |
this set of options did not contain the same FAST settings as the
|
|
|
2fc102 |
options for normal requests, all authentication would fail when the
|
|
|
2fc102 |
password of a FAST-only account would expire.
|
|
|
2fc102 |
|
|
|
2fc102 |
The two sets approach was cargo-cult from kinit where multiple
|
|
|
2fc102 |
requests could be issued using the same options set. However, in the
|
|
|
2fc102 |
case of krb5_child, only one request (or occasionally a well-defined
|
|
|
2fc102 |
second request) will be issued. Two option sets are therefore not
|
|
|
2fc102 |
required.
|
|
|
2fc102 |
|
|
|
2fc102 |
To fix this problem we removed the second option set used for changepw
|
|
|
2fc102 |
requests. All requests now use a single option set which is modified,
|
|
|
2fc102 |
if needed, for well-defined subsequent requests.
|
|
|
2fc102 |
|
|
|
2fc102 |
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
2fc102 |
Reviewed-by: Sumit Bose <sbose@redhat.com>
|
|
|
2fc102 |
---
|
|
|
2fc102 |
src/providers/krb5/krb5_child.c | 40 ++++++----------------------------------
|
|
|
2fc102 |
1 file changed, 6 insertions(+), 34 deletions(-)
|
|
|
2fc102 |
|
|
|
2fc102 |
diff --git a/src/providers/krb5/krb5_child.c b/src/providers/krb5/krb5_child.c
|
|
|
2fc102 |
index aa29de0cb4e14ea4804ba660b4b8e9b64e9e340e..461a27464f4fea09d4ca430b53aff072b29de141 100644
|
|
|
2fc102 |
--- a/src/providers/krb5/krb5_child.c
|
|
|
2fc102 |
+++ b/src/providers/krb5/krb5_child.c
|
|
|
2fc102 |
@@ -65,27 +65,14 @@ struct krb5_req {
|
|
|
2fc102 |
static krb5_context krb5_error_ctx;
|
|
|
2fc102 |
#define KRB5_CHILD_DEBUG(level, error) KRB5_DEBUG(level, krb5_error_ctx, error)
|
|
|
2fc102 |
|
|
|
2fc102 |
-static krb5_error_code get_changepw_options(krb5_context ctx,
|
|
|
2fc102 |
- krb5_get_init_creds_opt **_options)
|
|
|
2fc102 |
+static void set_changepw_options(krb5_context ctx,
|
|
|
2fc102 |
+ krb5_get_init_creds_opt *options)
|
|
|
2fc102 |
{
|
|
|
2fc102 |
- krb5_get_init_creds_opt *options;
|
|
|
2fc102 |
- krb5_error_code kerr;
|
|
|
2fc102 |
-
|
|
|
2fc102 |
- kerr = sss_krb5_get_init_creds_opt_alloc(ctx, &options);
|
|
|
2fc102 |
- if (kerr != 0) {
|
|
|
2fc102 |
- KRB5_CHILD_DEBUG(SSSDBG_CRIT_FAILURE, kerr);
|
|
|
2fc102 |
- return kerr;
|
|
|
2fc102 |
- }
|
|
|
2fc102 |
-
|
|
|
2fc102 |
sss_krb5_get_init_creds_opt_set_canonicalize(options, 0);
|
|
|
2fc102 |
krb5_get_init_creds_opt_set_forwardable(options, 0);
|
|
|
2fc102 |
krb5_get_init_creds_opt_set_proxiable(options, 0);
|
|
|
2fc102 |
krb5_get_init_creds_opt_set_renew_life(options, 0);
|
|
|
2fc102 |
krb5_get_init_creds_opt_set_tkt_life(options, 5*60);
|
|
|
2fc102 |
-
|
|
|
2fc102 |
- *_options = options;
|
|
|
2fc102 |
-
|
|
|
2fc102 |
- return 0;
|
|
|
2fc102 |
}
|
|
|
2fc102 |
|
|
|
2fc102 |
static errno_t sss_send_pac(krb5_authdata **pac_authdata)
|
|
|
2fc102 |
@@ -1023,7 +1010,6 @@ static errno_t changepw_child(struct krb5_req *kr, bool prelim)
|
|
|
2fc102 |
krb5_prompter_fct prompter = NULL;
|
|
|
2fc102 |
const char *realm_name;
|
|
|
2fc102 |
int realm_length;
|
|
|
2fc102 |
- krb5_get_init_creds_opt *chagepw_options;
|
|
|
2fc102 |
size_t msg_len;
|
|
|
2fc102 |
uint8_t *msg;
|
|
|
2fc102 |
|
|
|
2fc102 |
@@ -1041,12 +1027,7 @@ static errno_t changepw_child(struct krb5_req *kr, bool prelim)
|
|
|
2fc102 |
prompter = sss_krb5_prompter;
|
|
|
2fc102 |
}
|
|
|
2fc102 |
|
|
|
2fc102 |
- kerr = get_changepw_options(kr->ctx, &chagepw_options);
|
|
|
2fc102 |
- if (kerr != 0) {
|
|
|
2fc102 |
- DEBUG(SSSDBG_OP_FAILURE, ("get_changepw_options failed.\n"));
|
|
|
2fc102 |
- return kerr;
|
|
|
2fc102 |
- }
|
|
|
2fc102 |
-
|
|
|
2fc102 |
+ set_changepw_options(kr->ctx, kr->options);
|
|
|
2fc102 |
sss_krb5_princ_realm(kr->ctx, kr->princ, &realm_name, &realm_length);
|
|
|
2fc102 |
|
|
|
2fc102 |
DEBUG(SSSDBG_TRACE_FUNC,
|
|
|
2fc102 |
@@ -1055,8 +1036,7 @@ static errno_t changepw_child(struct krb5_req *kr, bool prelim)
|
|
|
2fc102 |
discard_const(password),
|
|
|
2fc102 |
prompter, kr, 0,
|
|
|
2fc102 |
SSSD_KRB5_CHANGEPW_PRINCIPAL,
|
|
|
2fc102 |
- chagepw_options);
|
|
|
2fc102 |
- sss_krb5_get_init_creds_opt_free(kr->ctx, chagepw_options);
|
|
|
2fc102 |
+ kr->options);
|
|
|
2fc102 |
if (kerr != 0) {
|
|
|
2fc102 |
ret = pack_user_info_chpass_error(kr->pd, "Old password not accepted.",
|
|
|
2fc102 |
&msg_len, &msg;;
|
|
|
2fc102 |
@@ -1164,7 +1144,6 @@ static errno_t changepw_child(struct krb5_req *kr, bool prelim)
|
|
|
2fc102 |
|
|
|
2fc102 |
static errno_t tgt_req_child(struct krb5_req *kr)
|
|
|
2fc102 |
{
|
|
|
2fc102 |
- krb5_get_init_creds_opt *chagepw_options;
|
|
|
2fc102 |
const char *password = NULL;
|
|
|
2fc102 |
krb5_error_code kerr;
|
|
|
2fc102 |
int ret;
|
|
|
2fc102 |
@@ -1210,19 +1189,12 @@ static errno_t tgt_req_child(struct krb5_req *kr)
|
|
|
2fc102 |
DEBUG(1, ("Failed to unset expire callback, continue ...\n"));
|
|
|
2fc102 |
}
|
|
|
2fc102 |
|
|
|
2fc102 |
- kerr = get_changepw_options(kr->ctx, &chagepw_options);
|
|
|
2fc102 |
- if (kerr != 0) {
|
|
|
2fc102 |
- DEBUG(SSSDBG_OP_FAILURE, ("get_changepw_options failed.\n"));
|
|
|
2fc102 |
- return kerr;
|
|
|
2fc102 |
- }
|
|
|
2fc102 |
-
|
|
|
2fc102 |
+ set_changepw_options(kr->ctx, kr->options);
|
|
|
2fc102 |
kerr = krb5_get_init_creds_password(kr->ctx, kr->creds, kr->princ,
|
|
|
2fc102 |
discard_const(password),
|
|
|
2fc102 |
sss_krb5_prompter, kr, 0,
|
|
|
2fc102 |
SSSD_KRB5_CHANGEPW_PRINCIPAL,
|
|
|
2fc102 |
- chagepw_options);
|
|
|
2fc102 |
-
|
|
|
2fc102 |
- sss_krb5_get_init_creds_opt_free(kr->ctx, chagepw_options);
|
|
|
2fc102 |
+ kr->options);
|
|
|
2fc102 |
|
|
|
2fc102 |
krb5_free_cred_contents(kr->ctx, kr->creds);
|
|
|
2fc102 |
if (kerr == 0) {
|
|
|
2fc102 |
--
|
|
|
2fc102 |
1.8.5.3
|
|
|
2fc102 |
|