if (errcode == KRB5KDC_ERR_PREAUTH_FAILED)
get_preauth_hint_list(request, &client, &server, &e_data);
-#ifdef KRBCONF_KDC_MODIFIES_KDB
- /*
- * Note: this doesn't work if you're using slave servers!!!
- * It also causes the database to be modified (and thus
- * need to be locked) frequently.
- */
- if (client.fail_auth_count < KRB5_MAX_FAIL_COUNT) {
- client.fail_auth_count = client.fail_auth_count + 1;
- if (client.fail_auth_count == KRB5_MAX_FAIL_COUNT) {
- client.attributes |= KRB5_KDB_DISALLOW_ALL_TIX;
+ if (kdc_modifies_kdb) {
+ /*
+ * Note: this doesn't work if you're using slave servers!!!
+ * It also causes the database to be modified (and thus
+ * need to be locked) frequently.
+ */
+ if (client.fail_auth_count < KRB5_MAX_FAIL_COUNT) {
+ client.fail_auth_count = client.fail_auth_count + 1;
+ if (client.fail_auth_count == KRB5_MAX_FAIL_COUNT) {
+ client.attributes |= KRB5_KDB_DISALLOW_ALL_TIX;
+ }
}
+ client.last_failed = kdc_time;
}
- client.last_failed = kdc_time;
-#endif
update_client = 1;
status = "PREAUTH_FAILED";
#ifdef KRBCONF_VAGUE_ERRORS
memset(reply.enc_part.ciphertext.data, 0, reply.enc_part.ciphertext.length);
free(reply.enc_part.ciphertext.data);
-#ifdef KRBCONF_KDC_MODIFIES_KDB
- /*
- * If we get this far, we successfully did the AS_REQ.
- */
- client.last_success = kdc_time;
- client.fail_auth_count = 0;
-#endif /* KRBCONF_KDC_MODIFIES_KDB */
+ if (kdc_modifies_kdb) {
+ /*
+ * If we get this far, we successfully did the AS_REQ.
+ */
+ client.last_success = kdc_time;
+ client.fail_auth_count = 0;
+ }
update_client = 1;
log_as_req(from, request, &reply, &client, cname, &server, sname,
if (sname != NULL)
free(sname);
if (c_nprincs) {
-#ifdef KRBCONF_KDC_MODIFIES_KDB
- if (update_client) {
- krb5_db_put_principal(kdc_context, &client, &c_nprincs);
- /*
- * ptooey. We want krb5_db_sync() or something like that.
- */
- krb5_db_fini(kdc_context);
- if (kdc_active_realm->realm_dbname)
- krb5_db_set_name(kdc_active_realm->realm_context,
- kdc_active_realm->realm_dbname);
- krb5_db_init(kdc_context);
- /* Reset master key */
- krb5_db_set_mkey(kdc_context, &kdc_active_realm->realm_mkey);
+ if (kdc_modifies_kdb) {
+ if (update_client) {
+ krb5_error_code errcode2;
+
+ krb5_db_put_principal(kdc_context, &client, &c_nprincs);
+ /*
+ * ptooey. We want krb5_db_sync() or something like that.
+ */
+ errcode2 = krb5_db_fini(kdc_context);
+ if (errcode2 == 0)
+ errcode2 = krb5_db_open(kdc_context, db_args,
+ KRB5_KDB_OPEN_RW|KRB5_KDB_SRV_TYPE_KDC);
+ /* Reset master key */
+ krb5_db_set_mkey(kdc_context, &kdc_active_realm->realm_mkey);
+ }
}
-#endif /* KRBCONF_KDC_MODIFIES_KDB */
krb5_db_free_principal(kdc_context, &client, c_nprincs);
}
if (s_nprincs)
}
/* first open the database before doing anything */
-#ifdef KRBCONF_KDC_MODIFIES_KDB
- kdb_open_flags = KRB5_KDB_OPEN_RW | KRB5_KDB_SRV_TYPE_KDC;
-#else
- kdb_open_flags = KRB5_KDB_OPEN_RO | KRB5_KDB_SRV_TYPE_KDC;
-#endif
+ if (kdc_modifies_kdb)
+ kdb_open_flags = KRB5_KDB_OPEN_RW | KRB5_KDB_SRV_TYPE_KDC;
+ else
+ kdb_open_flags = KRB5_KDB_OPEN_RO | KRB5_KDB_SRV_TYPE_KDC;
if ((kret = krb5_db_open(rdp->realm_context, db_args, kdb_open_flags))) {
kdc_err(rdp->realm_context, kret,
"while initializing database for realm %s", realm);
return;
}
+char **db_args = NULL;
void
initialize_realms(krb5_context kcontext, int argc, char **argv)
{
char *default_tcp_ports = 0;
krb5_pointer aprof;
const char *hierarchy[3];
- char **db_args = NULL;
char *no_refrls = NULL;
char *host_based_srvcs = NULL;
int db_args_size = 0;
}
}
+proc kinit_wrong_pw { name badpass } {
+ global REALMNAME
+ global KINIT
+ global spawn_id
+
+ # Use kinit to get a ticket.
+ #
+ # For now always get forwardable tickets. Later when we need to make
+ # tests that distiguish between forwardable tickets and otherwise
+ # we should but another option to this proc. --proven
+ #
+ spawn $KINIT -5 -f $name@$REALMNAME
+ expect {
+ "Password for $name@$REALMNAME:" {
+ verbose "kinit started"
+ }
+ timeout {
+ fail "kinit bad pw"
+ return 0
+ }
+ eof {
+ fail "kinit bad pw"
+ return 0
+ }
+ }
+ send "$badpass\r"
+ expect {
+ "Password incorrect while getting initial credentials" {
+ }
+ timeout {
+ fail "kinit bad pw"
+ # kill it?
+ }
+ eof {
+ fail "kinit bad pw"
+ return
+ }
+ }
+ expect eof
+
+ set status_list [wait -i $spawn_id]
+ catch "close -i $spawn_id"
+ verbose -log "exit status: $status_list"
+ if { [lindex $status_list 2] != 0 || [lindex $status_list 3] != 0 } {
+ pass "kinit bad pw"
+ } else {
+ fail "kinit bad pw"
+ }
+}
+
proc doit { } {
global REALMNAME
global KLIST
verbose "wait -i $spawn_id returned $k_stat (kadmin addpol)"
catch "close -i $spawn_id"
+ # Test use of wrong password.
+ kinit_wrong_pw krbtest/admin wrongpassword
+
setup_kerberos_env client
# Use kinit to get a ticket.
if ![kinit krbtest/admin adminpass$KEY 1] {