author | Alan Coopersmith <Alan.Coopersmith@Oracle.COM> |
Sun, 26 Mar 2017 13:26:42 -0700 | |
changeset 7803 | bab5480f2396 |
parent 7246 | b3414fa83399 |
permissions | -rw-r--r-- |
7246
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1 |
# |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
2 |
# This patch cherry-picks Password history in LDAP KDB plugin feature from |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
3 |
# MIT krb5 1.15. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
4 |
# |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
5 |
# It is 1-1 port of the following changesets: |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
6 |
# 44ad57d8d38efc944f64536354435f5b721c0ee0 |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
7 |
# d7f91ac2f6655e77bb3658c2c8cc6132f958a340 |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
8 |
# b46cce2ea8c0841f7f93db73eefcd180c87a3eae |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
9 |
# 9526953f36b39323ec07448a5f218d27c6f1c76f |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
10 |
# |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
11 |
# Patch source: upstream |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
12 |
# |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
13 |
# When upgrading to MIT krb5 1.15 this patch will be dropped. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
14 |
# |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
15 |
--- a/src/include/kdb.h |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
16 |
+++ b/src/include/kdb.h |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
17 |
@@ -1,6 +1,6 @@ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
18 |
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
19 |
/* |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
20 |
- * Copyright 1990,1991 by the Massachusetts Institute of Technology. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
21 |
+ * Copyright 1990, 1991, 2016 by the Massachusetts Institute of Technology. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
22 |
* All Rights Reserved. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
23 |
* |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
24 |
* Export of this software from the United States of America may |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
25 |
@@ -209,6 +209,8 @@ typedef struct _krb5_db_entry_new { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
26 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
27 |
krb5_principal princ; /* Length, data */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
28 |
krb5_tl_data * tl_data; /* Linked list */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
29 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
30 |
+ /* key_data must be sorted by kvno in descending order. */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
31 |
krb5_key_data * key_data; /* Array */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
32 |
} krb5_db_entry; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
33 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
34 |
@@ -683,6 +685,19 @@ krb5_error_code krb5_db_check_allowed_to |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
35 |
const krb5_db_entry *server, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
36 |
krb5_const_principal proxy); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
37 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
38 |
+/** |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
39 |
+ * Sort an array of @a krb5_key_data keys in descending order by their kvno. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
40 |
+ * Key data order within a kvno is preserved. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
41 |
+ * |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
42 |
+ * @param key_data |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
43 |
+ * The @a krb5_key_data array to sort. This is sorted in place so the |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
44 |
+ * array will be modified. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
45 |
+ * @param key_data_length |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
46 |
+ * The length of @a key_data. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
47 |
+ */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
48 |
+void |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
49 |
+krb5_dbe_sort_key_data(krb5_key_data *key_data, size_t key_data_length); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
50 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
51 |
/* default functions. Should not be directly called */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
52 |
/* |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
53 |
* Default functions prototype |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
54 |
--- a/src/lib/kadm5/admin.h |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
55 |
+++ b/src/lib/kadm5/admin.h |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
56 |
@@ -113,7 +113,7 @@ typedef long kadm5_ret_t; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
57 |
#define KADM5_RANDKEY_USED 0x100000 |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
58 |
#endif |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
59 |
#define KADM5_LOAD 0x200000 |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
60 |
-#define KADM5_NOKEY 0x400000 |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
61 |
+#define KADM5_KEY_HIST 0x400000 |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
62 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
63 |
/* all but KEY_DATA, TL_DATA, LOAD */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
64 |
#define KADM5_PRINCIPAL_NORMAL_MASK 0x41ffff |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
65 |
--- a/src/lib/kadm5/srv/svr_principal.c |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
66 |
+++ b/src/lib/kadm5/srv/svr_principal.c |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
67 |
@@ -1084,6 +1084,16 @@ check_pw_reuse(krb5_context context, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
68 |
return(0); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
69 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
70 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
71 |
+static void |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
72 |
+free_history_entry(krb5_context context, osa_pw_hist_ent *hist) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
73 |
+{ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
74 |
+ int i; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
75 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
76 |
+ for (i = 0; i < hist->n_key_data; i++) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
77 |
+ krb5_free_key_data_contents(context, &hist->key_data[i]); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
78 |
+ free(hist->key_data); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
79 |
+} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
80 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
81 |
/* |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
82 |
* Function: create_history_entry |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
83 |
* |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
84 |
@@ -1097,7 +1107,7 @@ check_pw_reuse(krb5_context context, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
85 |
* hist_key (r) history keyblock to encrypt key data with |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
86 |
* n_key_data (r) number of elements in key_data |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
87 |
* key_data (r) keys to add to the history entry |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
88 |
- * hist (w) history entry to fill in |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
89 |
+ * hist_out (w) history entry to fill in |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
90 |
* |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
91 |
* Effects: |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
92 |
* |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
93 |
@@ -1109,45 +1119,62 @@ check_pw_reuse(krb5_context context, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
94 |
static |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
95 |
int create_history_entry(krb5_context context, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
96 |
krb5_keyblock *hist_key, int n_key_data, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
97 |
- krb5_key_data *key_data, osa_pw_hist_ent *hist) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
98 |
+ krb5_key_data *key_data, osa_pw_hist_ent *hist_out) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
99 |
{ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
100 |
- krb5_error_code ret; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
101 |
+ int i; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
102 |
+ krb5_error_code ret = 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
103 |
krb5_keyblock key; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
104 |
krb5_keysalt salt; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
105 |
- int i; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
106 |
+ krb5_ui_2 kvno; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
107 |
+ osa_pw_hist_ent hist; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
108 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
109 |
+ hist_out->key_data = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
110 |
+ hist_out->n_key_data = 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
111 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
112 |
+ if (n_key_data < 0) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
113 |
+ return EINVAL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
114 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
115 |
+ memset(&key, 0, sizeof(key)); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
116 |
+ memset(&hist, 0, sizeof(hist)); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
117 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
118 |
+ if (n_key_data == 0) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
119 |
+ goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
120 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
121 |
- hist->key_data = k5calloc(n_key_data, sizeof(krb5_key_data), &ret); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
122 |
- if (hist->key_data == NULL) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
123 |
- return ret; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
124 |
+ hist.key_data = k5calloc(n_key_data, sizeof(krb5_key_data), &ret); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
125 |
+ if (hist.key_data == NULL) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
126 |
+ goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
127 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
128 |
+ /* We only want to store the most recent kvno, and key_data should already |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
129 |
+ * be sorted in descending order by kvno. */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
130 |
+ kvno = key_data[0].key_data_kvno; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
131 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
132 |
for (i = 0; i < n_key_data; i++) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
133 |
- ret = krb5_dbe_decrypt_key_data(context, NULL, &key_data[i], &key, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
134 |
+ if (key_data[i].key_data_kvno < kvno) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
135 |
+ break; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
136 |
+ ret = krb5_dbe_decrypt_key_data(context, NULL, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
137 |
+ &key_data[i], &key, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
138 |
&salt); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
139 |
if (ret) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
140 |
- return ret; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
141 |
+ goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
142 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
143 |
ret = krb5_dbe_encrypt_key_data(context, hist_key, &key, &salt, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
144 |
key_data[i].key_data_kvno, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
145 |
- &hist->key_data[i]); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
146 |
+ &hist.key_data[hist.n_key_data]); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
147 |
if (ret) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
148 |
- return ret; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
149 |
- |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
150 |
+ goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
151 |
+ hist.n_key_data++; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
152 |
krb5_free_keyblock_contents(context, &key); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
153 |
/* krb5_free_keysalt(context, &salt); */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
154 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
155 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
156 |
- hist->n_key_data = n_key_data; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
157 |
- return 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
158 |
-} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
159 |
- |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
160 |
-static |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
161 |
-void free_history_entry(krb5_context context, osa_pw_hist_ent *hist) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
162 |
-{ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
163 |
- int i; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
164 |
- |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
165 |
- for (i = 0; i < hist->n_key_data; i++) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
166 |
- krb5_free_key_data_contents(context, &hist->key_data[i]); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
167 |
- free(hist->key_data); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
168 |
+ *hist_out = hist; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
169 |
+ hist.n_key_data = 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
170 |
+ hist.key_data = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
171 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
172 |
+cleanup: |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
173 |
+ krb5_free_keyblock_contents(context, &key); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
174 |
+ free_history_entry(context, &hist); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
175 |
+ return ret; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
176 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
177 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
178 |
/* |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
179 |
@@ -1526,11 +1553,14 @@ kadm5_chpass_principal_3(void *server_ha |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
180 |
goto done; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
181 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
182 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
183 |
- ret = add_to_history(handle->context, hist_kvno, &adb, &pol, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
184 |
- &hist); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
185 |
- if (ret) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
186 |
- goto done; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
187 |
- hist_added = 1; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
188 |
+ /* Don't save empty history. */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
189 |
+ if (hist.n_key_data > 0) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
190 |
+ ret = add_to_history(handle->context, hist_kvno, &adb, &pol, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
191 |
+ &hist); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
192 |
+ if (ret) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
193 |
+ goto done; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
194 |
+ hist_added = 1; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
195 |
+ } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
196 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
197 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
198 |
if (pol.pw_max_life) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
199 |
@@ -1582,6 +1612,9 @@ kadm5_chpass_principal_3(void *server_ha |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
200 |
KADM5_FAIL_AUTH_COUNT; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
201 |
/* | KADM5_CPW_FUNCTION */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
202 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
203 |
+ if (hist_added) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
204 |
+ kdb->mask |= KADM5_KEY_HIST; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
205 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
206 |
ret = k5_kadm5_hook_chpass(handle->context, handle->hook_handles, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
207 |
KADM5_HOOK_STAGE_PRECOMMIT, principal, keepold, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
208 |
new_n_ks_tuple, new_ks_tuple, password); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
209 |
--- a/src/lib/kdb/kdb5.c |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
210 |
+++ b/src/lib/kdb/kdb5.c |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
211 |
@@ -1,6 +1,7 @@ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
212 |
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
213 |
/* |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
214 |
- * Copyright 2006, 2009, 2010 by the Massachusetts Institute of Technology. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
215 |
+ * Copyright 2006, 2009, 2010, 2016 by the Massachusetts Institute of |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
216 |
+ * Technology. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
217 |
* All Rights Reserved. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
218 |
* |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
219 |
* Export of this software from the United States of America may |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
220 |
@@ -758,7 +759,15 @@ krb5_db_get_principal(krb5_context kcont |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
221 |
return status; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
222 |
if (v->get_principal == NULL) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
223 |
return KRB5_PLUGIN_OP_NOTSUPP; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
224 |
- return v->get_principal(kcontext, search_for, flags, entry); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
225 |
+ status = v->get_principal(kcontext, search_for, flags, entry); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
226 |
+ if (status) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
227 |
+ return status; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
228 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
229 |
+ /* Sort the keys in the db entry as some parts of krb5 expect it to be. */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
230 |
+ if ((*entry)->key_data != NULL) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
231 |
+ krb5_dbe_sort_key_data((*entry)->key_data, (*entry)->n_key_data); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
232 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
233 |
+ return 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
234 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
235 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
236 |
void |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
237 |
@@ -948,6 +957,26 @@ krb5_db_delete_principal(krb5_context kc |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
238 |
return status; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
239 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
240 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
241 |
+/* |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
242 |
+ * Use a proxy function for iterate so that we can sort the keys before sending |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
243 |
+ * them to the callback. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
244 |
+ */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
245 |
+struct callback_proxy_args { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
246 |
+ int (*func)(krb5_pointer, krb5_db_entry *); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
247 |
+ krb5_pointer func_arg; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
248 |
+}; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
249 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
250 |
+static int |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
251 |
+sort_entry_callback_proxy(krb5_pointer func_arg, krb5_db_entry *entry) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
252 |
+{ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
253 |
+ struct callback_proxy_args *args = (struct callback_proxy_args *)func_arg; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
254 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
255 |
+ /* Sort the keys in the db entry as some parts of krb5 expect it to be. */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
256 |
+ if (entry && entry->key_data) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
257 |
+ krb5_dbe_sort_key_data(entry->key_data, entry->n_key_data); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
258 |
+ return args->func(args->func_arg, entry); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
259 |
+} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
260 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
261 |
krb5_error_code |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
262 |
krb5_db_iterate(krb5_context kcontext, char *match_entry, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
263 |
int (*func)(krb5_pointer, krb5_db_entry *), |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
264 |
@@ -955,13 +984,20 @@ krb5_db_iterate(krb5_context kcontext, c |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
265 |
{ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
266 |
krb5_error_code status = 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
267 |
kdb_vftabl *v; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
268 |
+ struct callback_proxy_args proxy_args; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
269 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
270 |
status = get_vftabl(kcontext, &v); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
271 |
if (status) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
272 |
return status; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
273 |
if (v->iterate == NULL) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
274 |
return KRB5_PLUGIN_OP_NOTSUPP; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
275 |
- return v->iterate(kcontext, match_entry, func, func_arg, iterflags); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
276 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
277 |
+ /* Use the proxy function to sort key data before passing entries to |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
278 |
+ * callback. */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
279 |
+ proxy_args.func = func; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
280 |
+ proxy_args.func_arg = func_arg; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
281 |
+ return v->iterate(kcontext, match_entry, sort_entry_callback_proxy, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
282 |
+ &proxy_args, iterflags); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
283 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
284 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
285 |
/* Return a read only pointer alias to mkey list. Do not free this! */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
286 |
@@ -2570,3 +2606,22 @@ krb5_db_check_allowed_to_delegate(krb5_c |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
287 |
return KRB5_PLUGIN_OP_NOTSUPP; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
288 |
return v->check_allowed_to_delegate(kcontext, client, server, proxy); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
289 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
290 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
291 |
+void |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
292 |
+krb5_dbe_sort_key_data(krb5_key_data *key_data, size_t key_data_length) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
293 |
+{ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
294 |
+ size_t i, j; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
295 |
+ krb5_key_data tmp; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
296 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
297 |
+ /* Use insertion sort as a stable sort. */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
298 |
+ for (i = 1; i < key_data_length; i++) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
299 |
+ j = i; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
300 |
+ while (j > 0 && |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
301 |
+ key_data[j - 1].key_data_kvno < key_data[j].key_data_kvno) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
302 |
+ tmp = key_data[j]; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
303 |
+ key_data[j] = key_data[j - 1]; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
304 |
+ key_data[j - 1] = tmp; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
305 |
+ j--; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
306 |
+ } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
307 |
+ } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
308 |
+} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
309 |
--- a/src/lib/kdb/libkdb5.exports |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
310 |
+++ b/src/lib/kdb/libkdb5.exports |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
311 |
@@ -99,3 +99,4 @@ ulog_get_sno_status |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
312 |
ulog_replay |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
313 |
ulog_set_last |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
314 |
xdr_kdb_incr_update_t |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
315 |
+krb5_dbe_sort_key_data |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
316 |
--- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
317 |
+++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_misc.c |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
318 |
@@ -40,6 +40,7 @@ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
319 |
#include "ldap_pwd_policy.h" |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
320 |
#include <time.h> |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
321 |
#include <ctype.h> |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
322 |
+#include <kadm5/admin.h> |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
323 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
324 |
#ifdef NEED_STRPTIME_PROTO |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
325 |
extern char *strptime(const char *, const char *, struct tm *); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
326 |
@@ -1324,6 +1325,22 @@ remove_overlapping_subtrees(char **list, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
327 |
*subtcount = count; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
328 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
329 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
330 |
+static void |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
331 |
+free_princ_ent_contents(osa_princ_ent_t princ_ent) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
332 |
+{ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
333 |
+ unsigned int i; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
334 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
335 |
+ for (i = 0; i < princ_ent->old_key_len; i++) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
336 |
+ k5_free_key_data(princ_ent->old_keys[i].n_key_data, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
337 |
+ princ_ent->old_keys[i].key_data); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
338 |
+ princ_ent->old_keys[i].n_key_data = 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
339 |
+ princ_ent->old_keys[i].key_data = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
340 |
+ } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
341 |
+ free(princ_ent->old_keys); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
342 |
+ princ_ent->old_keys = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
343 |
+ princ_ent->old_key_len = 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
344 |
+} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
345 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
346 |
/* |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
347 |
* Fill out a krb5_db_entry princ entry struct given a LDAP message containing |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
348 |
* the results of a principal search of the directory. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
349 |
@@ -1344,6 +1361,9 @@ populate_krb5_db_entry(krb5_context cont |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
350 |
char **pnvalues = NULL, **ocvalues = NULL, **a2d2 = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
351 |
struct berval **ber_key_data = NULL, **ber_tl_data = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
352 |
krb5_tl_data userinfo_tl_data = { NULL }, **endp, *tl; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
353 |
+ osa_princ_ent_rec princ_ent; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
354 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
355 |
+ memset(&princ_ent, 0, sizeof(princ_ent)); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
356 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
357 |
ret = krb5_copy_principal(context, princ, &entry->princ); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
358 |
if (ret) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
359 |
@@ -1462,8 +1482,21 @@ populate_krb5_db_entry(krb5_context cont |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
360 |
ret = krb5_ldap_policydn_to_name(context, pwdpolicydn, &polname); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
361 |
if (ret) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
362 |
goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
363 |
+ princ_ent.policy = polname; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
364 |
+ princ_ent.aux_attributes |= KADM5_POLICY; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
365 |
+ } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
366 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
367 |
+ ber_key_data = ldap_get_values_len(ld, ent, "krbpwdhistory"); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
368 |
+ if (ber_key_data != NULL) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
369 |
+ mask |= KDB_PWD_HISTORY_ATTR; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
370 |
+ ret = krb5_decode_histkey(context, ber_key_data, &princ_ent); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
371 |
+ if (ret) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
372 |
+ goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
373 |
+ ldap_value_free_len(ber_key_data); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
374 |
+ } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
375 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
376 |
- ret = krb5_update_tl_kadm_data(context, entry, polname); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
377 |
+ if (princ_ent.aux_attributes) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
378 |
+ ret = krb5_update_tl_kadm_data(context, entry, &princ_ent); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
379 |
if (ret) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
380 |
goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
381 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
382 |
@@ -1471,8 +1504,7 @@ populate_krb5_db_entry(krb5_context cont |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
383 |
ber_key_data = ldap_get_values_len(ld, ent, "krbprincipalkey"); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
384 |
if (ber_key_data != NULL) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
385 |
mask |= KDB_SECRET_KEY_ATTR; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
386 |
- ret = krb5_decode_krbsecretkey(context, entry, ber_key_data, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
387 |
- &userinfo_tl_data, &mkvno); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
388 |
+ ret = krb5_decode_krbsecretkey(context, entry, ber_key_data, &mkvno); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
389 |
if (ret) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
390 |
goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
391 |
if (mkvno != 0) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
392 |
@@ -1578,6 +1610,7 @@ cleanup: |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
393 |
free(tktpolname); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
394 |
free(policydn); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
395 |
krb5_free_unparsed_name(context, user); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
396 |
+ free_princ_ent_contents(&princ_ent); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
397 |
return ret; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
398 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
399 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
400 |
--- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal.c |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
401 |
+++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal.c |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
402 |
@@ -59,6 +59,7 @@ char *principal_attributes[] = { "kr |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
403 |
"krbExtraData", |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
404 |
"krbObjectReferences", |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
405 |
"krbAllowedToDelegateTo", |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
406 |
+ "krbPwdHistory", |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
407 |
NULL }; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
408 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
409 |
/* Must match KDB_*_ATTR macros in ldap_principal.h. */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
410 |
@@ -77,14 +78,38 @@ static char *attributes_set[] = { "krbma |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
411 |
"krbLastFailedAuth", |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
412 |
"krbLoginFailedCount", |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
413 |
"krbLastAdminUnlock", |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
414 |
+ "krbPwdHistory", |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
415 |
NULL }; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
416 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
417 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
418 |
+static void |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
419 |
+k5_free_key_data_contents(krb5_key_data *key) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
420 |
+{ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
421 |
+ int16_t i; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
422 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
423 |
+ for (i = 0; i < key->key_data_ver; i++) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
424 |
+ zapfree(key->key_data_contents[i], key->key_data_length[i]); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
425 |
+ key->key_data_contents[i] = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
426 |
+ } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
427 |
+} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
428 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
429 |
+void |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
430 |
+k5_free_key_data(krb5_int16 n_key_data, krb5_key_data *key_data) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
431 |
+{ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
432 |
+ int16_t i; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
433 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
434 |
+ if (key_data == NULL) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
435 |
+ return; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
436 |
+ for (i = 0; i < n_key_data; i++) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
437 |
+ k5_free_key_data_contents(&key_data[i]); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
438 |
+ free(key_data); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
439 |
+} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
440 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
441 |
void |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
442 |
krb5_dbe_free_contents(krb5_context context, krb5_db_entry *entry) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
443 |
{ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
444 |
krb5_tl_data *tl_data_next=NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
445 |
krb5_tl_data *tl_data=NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
446 |
- int i, j; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
447 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
448 |
if (entry->e_data) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
449 |
free(entry->e_data); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
450 |
@@ -96,24 +121,7 @@ krb5_dbe_free_contents(krb5_context cont |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
451 |
free(tl_data->tl_data_contents); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
452 |
free(tl_data); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
453 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
454 |
- if (entry->key_data) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
455 |
- for (i = 0; i < entry->n_key_data; i++) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
456 |
- for (j = 0; j < entry->key_data[i].key_data_ver; j++) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
457 |
- if (entry->key_data[i].key_data_length[j]) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
458 |
- if (entry->key_data[i].key_data_contents[j]) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
459 |
- memset(entry->key_data[i].key_data_contents[j], |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
460 |
- 0, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
461 |
- (unsigned) entry->key_data[i].key_data_length[j]); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
462 |
- free (entry->key_data[i].key_data_contents[j]); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
463 |
- } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
464 |
- } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
465 |
- entry->key_data[i].key_data_contents[j] = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
466 |
- entry->key_data[i].key_data_length[j] = 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
467 |
- entry->key_data[i].key_data_type[j] = 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
468 |
- } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
469 |
- } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
470 |
- free(entry->key_data); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
471 |
- } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
472 |
+ k5_free_key_data(entry->n_key_data, entry->key_data); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
473 |
memset(entry, 0, sizeof(*entry)); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
474 |
return; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
475 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
476 |
--- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal.h |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
477 |
+++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal.h |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
478 |
@@ -32,6 +32,7 @@ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
479 |
#define _LDAP_PRINCIPAL_H 1 |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
480 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
481 |
#include "ldap_tkt_policy.h" |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
482 |
+#include "princ_xdr.h" |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
483 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
484 |
#define KEYHEADER 12 |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
485 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
486 |
@@ -82,6 +83,7 @@ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
487 |
#define KDB_LAST_FAILED_ATTR 0x001000 |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
488 |
#define KDB_FAIL_AUTH_COUNT_ATTR 0x002000 |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
489 |
#define KDB_LAST_ADMIN_UNLOCK_ATTR 0x004000 |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
490 |
+#define KDB_PWD_HISTORY_ATTR 0x008000 |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
491 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
492 |
/* |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
493 |
* This is a private contract between krb5_ldap_lockout_audit() |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
494 |
@@ -112,6 +114,12 @@ krb5_ldap_iterate(krb5_context, char *, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
495 |
krb5_pointer, krb5_flags); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
496 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
497 |
void |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
498 |
+k5_free_key_data(krb5_int16 n_key_data, krb5_key_data *key_data); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
499 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
500 |
+void |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
501 |
+krb5_dbe_free_contents(krb5_context context, krb5_db_entry *entry); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
502 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
503 |
+void |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
504 |
krb5_dbe_free_contents(krb5_context, krb5_db_entry *); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
505 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
506 |
krb5_error_code |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
507 |
@@ -121,8 +129,11 @@ krb5_error_code |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
508 |
krb5_ldap_parse_principal_name(char *, char **); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
509 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
510 |
krb5_error_code |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
511 |
+krb5_decode_histkey(krb5_context, struct berval **, osa_princ_ent_rec *); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
512 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
513 |
+krb5_error_code |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
514 |
krb5_decode_krbsecretkey(krb5_context, krb5_db_entry *, struct berval **, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
515 |
- krb5_tl_data *, krb5_kvno *); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
516 |
+ krb5_kvno *); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
517 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
518 |
krb5_error_code |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
519 |
berval2tl_data(struct berval *in, krb5_tl_data **out); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
520 |
--- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
521 |
+++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
522 |
@@ -1,6 +1,35 @@ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
523 |
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
524 |
/* plugins/kdb/ldap/libkdb_ldap/ldap_principal2.c */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
525 |
/* |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
526 |
+ * Copyright (C) 2016 by the Massachusetts Institute of Technology. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
527 |
+ * All rights reserved. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
528 |
+ * |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
529 |
+ * Redistribution and use in source and binary forms, with or without |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
530 |
+ * modification, are permitted provided that the following conditions |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
531 |
+ * are met: |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
532 |
+ * |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
533 |
+ * * Redistributions of source code must retain the above copyright |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
534 |
+ * notice, this list of conditions and the following disclaimer. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
535 |
+ * |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
536 |
+ * * Redistributions in binary form must reproduce the above copyright |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
537 |
+ * notice, this list of conditions and the following disclaimer in |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
538 |
+ * the documentation and/or other materials provided with the |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
539 |
+ * distribution. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
540 |
+ * |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
541 |
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
542 |
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
543 |
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
544 |
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
545 |
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
546 |
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
547 |
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
548 |
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
549 |
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
550 |
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
551 |
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
552 |
+ * OF THE POSSIBILITY OF SUCH DAMAGE. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
553 |
+ */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
554 |
+/* |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
555 |
* Copyright (c) 2004-2005, Novell, Inc. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
556 |
* All rights reserved. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
557 |
* |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
558 |
@@ -362,13 +391,14 @@ asn1_encode_sequence_of_keys(krb5_key_da |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
559 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
560 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
561 |
static krb5_error_code |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
562 |
-asn1_decode_sequence_of_keys(krb5_data *in, krb5_key_data **out, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
563 |
- krb5_int16 *n_key_data, krb5_kvno *mkvno) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
564 |
+asn1_decode_sequence_of_keys(krb5_data *in, ldap_seqof_key_data *out) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
565 |
{ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
566 |
krb5_error_code err; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
567 |
ldap_seqof_key_data *p; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
568 |
int i; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
569 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
570 |
+ memset(out, 0, sizeof(*out)); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
571 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
572 |
/* |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
573 |
* This should be pushed back into other library initialization |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
574 |
* code. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
575 |
@@ -390,9 +420,7 @@ asn1_decode_sequence_of_keys(krb5_data * |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
576 |
p->key_data[i].key_data_ver = 2; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
577 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
578 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
579 |
- *out = p->key_data; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
580 |
- *n_key_data = p->n_key_data; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
581 |
- *mkvno = p->mkvno; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
582 |
+ *out = *p; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
583 |
free(p); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
584 |
return 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
585 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
586 |
@@ -416,19 +444,24 @@ free_berdata(struct berval **array) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
587 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
588 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
589 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
590 |
-/* Decoding ASN.1 encoded key */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
591 |
-static struct berval ** |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
592 |
-krb5_encode_krbsecretkey(krb5_key_data *key_data_in, int n_key_data, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
593 |
- krb5_kvno mkvno) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
594 |
- struct berval **ret = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
595 |
- int currkvno; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
596 |
- int num_versions = 1; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
597 |
- int i, j, last; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
598 |
+/* |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
599 |
+ * Encode krb5_key_data into a berval struct for insertion into LDAP. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
600 |
+ */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
601 |
+static krb5_error_code |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
602 |
+encode_keys(krb5_key_data *key_data_in, int n_key_data, krb5_kvno mkvno, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
603 |
+ struct berval **bval_out) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
604 |
+{ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
605 |
krb5_error_code err = 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
606 |
+ int i; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
607 |
krb5_key_data *key_data = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
608 |
+ struct berval *bval = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
609 |
+ krb5_data *code; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
610 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
611 |
- if (n_key_data < 0) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
612 |
- return NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
613 |
+ *bval_out = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
614 |
+ if (n_key_data <= 0) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
615 |
+ err = EINVAL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
616 |
+ goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
617 |
+ } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
618 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
619 |
/* Make a shallow copy of the key data so we can alter it. */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
620 |
key_data = k5calloc(n_key_data, sizeof(*key_data), &err); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
621 |
@@ -447,31 +480,68 @@ krb5_encode_krbsecretkey(krb5_key_data * |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
622 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
623 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
624 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
625 |
+ bval = k5alloc(sizeof(struct berval), &err); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
626 |
+ if (bval == NULL) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
627 |
+ goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
628 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
629 |
+ err = asn1_encode_sequence_of_keys(key_data, n_key_data, mkvno, &code); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
630 |
+ if (err) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
631 |
+ goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
632 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
633 |
+ /* Steal the data pointer from code for bval and discard code. */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
634 |
+ bval->bv_len = code->length; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
635 |
+ bval->bv_val = code->data; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
636 |
+ free(code); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
637 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
638 |
+ *bval_out = bval; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
639 |
+ bval = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
640 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
641 |
+cleanup: |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
642 |
+ free(key_data); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
643 |
+ free(bval); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
644 |
+ return err; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
645 |
+} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
646 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
647 |
+/* Decoding ASN.1 encoded key */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
648 |
+static struct berval ** |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
649 |
+krb5_encode_krbsecretkey(krb5_key_data *key_data, int n_key_data, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
650 |
+ krb5_kvno mkvno) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
651 |
+{ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
652 |
+ struct berval **ret = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
653 |
+ int currkvno; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
654 |
+ int num_versions = 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
655 |
+ int i, j, last; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
656 |
+ krb5_error_code err = 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
657 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
658 |
+ if (n_key_data < 0) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
659 |
+ return NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
660 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
661 |
/* Find the number of key versions */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
662 |
- for (i = 0; i < n_key_data - 1; i++) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
663 |
- if (key_data[i].key_data_kvno != key_data[i + 1].key_data_kvno) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
664 |
- num_versions++; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
665 |
+ if (n_key_data > 0) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
666 |
+ for (i = 0, num_versions = 1; i < n_key_data - 1; i++) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
667 |
+ if (key_data[i].key_data_kvno != key_data[i + 1].key_data_kvno) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
668 |
+ num_versions++; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
669 |
+ } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
670 |
+ } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
671 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
672 |
- ret = (struct berval **) calloc (num_versions + 1, sizeof (struct berval *)); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
673 |
+ ret = calloc(num_versions + 1, sizeof(struct berval *)); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
674 |
if (ret == NULL) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
675 |
err = ENOMEM; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
676 |
goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
677 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
678 |
- for (i = 0, last = 0, j = 0, currkvno = key_data[0].key_data_kvno; i < n_key_data; i++) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
679 |
- krb5_data *code; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
680 |
+ ret[num_versions] = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
681 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
682 |
+ /* n_key_data may be 0 if a principal is created without a key. */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
683 |
+ if (n_key_data == 0) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
684 |
+ goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
685 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
686 |
+ currkvno = key_data[0].key_data_kvno; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
687 |
+ for (i = 0, last = 0, j = 0; i < n_key_data; i++) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
688 |
if (i == n_key_data - 1 || key_data[i + 1].key_data_kvno != currkvno) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
689 |
- ret[j] = k5alloc(sizeof(struct berval), &err); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
690 |
- if (ret[j] == NULL) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
691 |
- goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
692 |
- err = asn1_encode_sequence_of_keys(key_data + last, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
693 |
- (krb5_int16)i - last + 1, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
694 |
- mkvno, &code); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
695 |
+ err = encode_keys(key_data + last, (krb5_int16)i - last + 1, mkvno, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
696 |
+ &ret[j]); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
697 |
if (err) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
698 |
goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
699 |
- /*CHECK_NULL(ret[j]); */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
700 |
- ret[j]->bv_len = code->length; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
701 |
- ret[j]->bv_val = code->data; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
702 |
- free(code); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
703 |
j++; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
704 |
last = i + 1; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
705 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
706 |
@@ -479,11 +549,48 @@ krb5_encode_krbsecretkey(krb5_key_data * |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
707 |
currkvno = key_data[i + 1].key_data_kvno; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
708 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
709 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
710 |
- ret[num_versions] = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
711 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
712 |
cleanup: |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
713 |
+ if (err != 0) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
714 |
+ free_berdata(ret); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
715 |
+ ret = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
716 |
+ } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
717 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
718 |
- free(key_data); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
719 |
+ return ret; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
720 |
+} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
721 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
722 |
+/* |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
723 |
+ * Encode a principal's key history for insertion into ldap. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
724 |
+ */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
725 |
+static struct berval ** |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
726 |
+krb5_encode_histkey(osa_princ_ent_rec *princ_ent) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
727 |
+{ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
728 |
+ unsigned int i; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
729 |
+ krb5_error_code err = 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
730 |
+ struct berval **ret = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
731 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
732 |
+ if (princ_ent->old_key_len <= 0) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
733 |
+ return NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
734 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
735 |
+ ret = k5calloc(princ_ent->old_key_len + 1, sizeof(struct berval *), &err); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
736 |
+ if (ret == NULL) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
737 |
+ goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
738 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
739 |
+ for (i = 0; i < princ_ent->old_key_len; i++) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
740 |
+ if (princ_ent->old_keys[i].n_key_data <= 0) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
741 |
+ err = EINVAL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
742 |
+ goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
743 |
+ } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
744 |
+ err = encode_keys(princ_ent->old_keys[i].key_data, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
745 |
+ princ_ent->old_keys[i].n_key_data, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
746 |
+ princ_ent->admin_history_kvno, &ret[i]); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
747 |
+ if (err) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
748 |
+ goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
749 |
+ } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
750 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
751 |
+ ret[princ_ent->old_key_len] = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
752 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
753 |
+cleanup: |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
754 |
if (err != 0) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
755 |
free_berdata(ret); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
756 |
ret = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
757 |
@@ -1004,7 +1111,7 @@ krb5_ldap_put_principal(krb5_context con |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
758 |
free (strval[0]); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
759 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
760 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
761 |
- if (entry->mask & KADM5_POLICY) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
762 |
+ if (entry->mask & KADM5_POLICY || entry->mask & KADM5_KEY_HIST) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
763 |
memset(&princ_ent, 0, sizeof(princ_ent)); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
764 |
for (tl_data=entry->tl_data; tl_data; tl_data=tl_data->tl_data_next) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
765 |
if (tl_data->tl_data_type == KRB5_TL_KADM_DATA) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
766 |
@@ -1014,7 +1121,9 @@ krb5_ldap_put_principal(krb5_context con |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
767 |
break; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
768 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
769 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
770 |
+ } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
771 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
772 |
+ if (entry->mask & KADM5_POLICY) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
773 |
if (princ_ent.aux_attributes & KADM5_POLICY) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
774 |
memset(strval, 0, sizeof(strval)); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
775 |
if ((st = krb5_ldap_name_to_policydn (context, princ_ent.policy, &polname)) != 0) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
776 |
@@ -1042,6 +1151,22 @@ krb5_ldap_put_principal(krb5_context con |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
777 |
goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
778 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
779 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
780 |
+ if (entry->mask & KADM5_KEY_HIST) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
781 |
+ bersecretkey = krb5_encode_histkey(&princ_ent); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
782 |
+ if (bersecretkey == NULL) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
783 |
+ st = ENOMEM; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
784 |
+ goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
785 |
+ } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
786 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
787 |
+ st = krb5_add_ber_mem_ldap_mod(&mods, "krbpwdhistory", |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
788 |
+ LDAP_MOD_REPLACE | LDAP_MOD_BVALUES, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
789 |
+ bersecretkey); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
790 |
+ if (st != 0) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
791 |
+ goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
792 |
+ free_berdata(bersecretkey); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
793 |
+ bersecretkey = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
794 |
+ } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
795 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
796 |
if (entry->mask & KADM5_KEY_DATA || entry->mask & KADM5_KVNO) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
797 |
krb5_kvno mkvno; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
798 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
799 |
@@ -1376,22 +1501,62 @@ cleanup: |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
800 |
return st; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
801 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
802 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
803 |
-krb5_error_code |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
804 |
-krb5_decode_krbsecretkey(krb5_context context, krb5_db_entry *entries, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
805 |
- struct berval **bvalues, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
806 |
- krb5_tl_data *userinfo_tl_data, krb5_kvno *mkvno) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
807 |
+static void |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
808 |
+free_ldap_seqof_key_data(ldap_seqof_key_data *keysets, krb5_int16 n_keysets) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
809 |
{ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
810 |
- char *user=NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
811 |
- int i=0, j=0, noofkeys=0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
812 |
- krb5_key_data *key_data=NULL, *tmp; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
813 |
- krb5_error_code st=0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
814 |
+ int i; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
815 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
816 |
- if ((st=krb5_unparse_name(context, entries->princ, &user)) != 0) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
817 |
+ if (keysets == NULL) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
818 |
+ return; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
819 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
820 |
+ for (i = 0; i < n_keysets; i++) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
821 |
+ k5_free_key_data(keysets[i].n_key_data, keysets[i].key_data); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
822 |
+ free(keysets); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
823 |
+} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
824 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
825 |
+/* |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
826 |
+ * Decode keys from ldap search results. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
827 |
+ * |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
828 |
+ * Arguments: |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
829 |
+ * - bvalues |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
830 |
+ * The ldap search results containing the key data. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
831 |
+ * - mkvno |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
832 |
+ * The master kvno that the keys were encrypted with. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
833 |
+ * - keysets_out |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
834 |
+ * The decoded keys in a ldap_seqof_key_data struct. Must be freed using |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
835 |
+ * free_ldap_seqof_key_data. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
836 |
+ * - n_keysets_out |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
837 |
+ * The number of entries in keys_out. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
838 |
+ * - total_keys_out |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
839 |
+ * An optional argument that if given will be set to the total number of |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
840 |
+ * keys found throughout all the entries: sum(keys_out.n_key_data) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
841 |
+ * May be NULL. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
842 |
+ */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
843 |
+static krb5_error_code |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
844 |
+decode_keys(struct berval **bvalues, ldap_seqof_key_data **keysets_out, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
845 |
+ krb5_int16 *n_keysets_out, krb5_int16 *total_keys_out) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
846 |
+{ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
847 |
+ krb5_error_code err = 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
848 |
+ krb5_int16 n_keys, i, ki, total_keys; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
849 |
+ ldap_seqof_key_data *keysets = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
850 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
851 |
+ *keysets_out = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
852 |
+ *n_keysets_out = 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
853 |
+ if (total_keys_out) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
854 |
+ *total_keys_out = 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
855 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
856 |
+ /* Precount the number of keys. */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
857 |
+ for (n_keys = 0, i = 0; bvalues[i] != NULL; i++) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
858 |
+ if (bvalues[i]->bv_len > 0) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
859 |
+ n_keys++; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
860 |
+ } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
861 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
862 |
+ keysets = k5calloc(n_keys, sizeof(ldap_seqof_key_data), &err); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
863 |
+ if (keysets == NULL) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
864 |
goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
865 |
+ memset(keysets, 0, n_keys * sizeof(ldap_seqof_key_data)); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
866 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
867 |
- for (i=0; bvalues[i] != NULL; ++i) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
868 |
- krb5_int16 n_kd; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
869 |
- krb5_key_data *kd; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
870 |
+ for (i = 0, ki = 0, total_keys = 0; bvalues[i] != NULL; i++) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
871 |
krb5_data in; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
872 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
873 |
if (bvalues[i]->bv_len == 0) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
874 |
@@ -1399,39 +1564,131 @@ krb5_decode_krbsecretkey(krb5_context co |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
875 |
in.length = bvalues[i]->bv_len; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
876 |
in.data = bvalues[i]->bv_val; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
877 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
878 |
- st = asn1_decode_sequence_of_keys (&in, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
879 |
- &kd, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
880 |
- &n_kd, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
881 |
- mkvno); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
882 |
- |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
883 |
- if (st != 0) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
884 |
- const char *msg = error_message(st); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
885 |
- st = -1; /* Something more appropriate ? */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
886 |
- k5_setmsg(context, st, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
887 |
- _("unable to decode stored principal key data (%s)"), |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
888 |
- msg); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
889 |
- goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
890 |
- } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
891 |
- noofkeys += n_kd; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
892 |
- tmp = key_data; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
893 |
- /* Allocate an extra key data to avoid allocating zero bytes. */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
894 |
- key_data = realloc(key_data, (noofkeys + 1) * sizeof (krb5_key_data)); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
895 |
- if (key_data == NULL) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
896 |
- key_data = tmp; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
897 |
- st = ENOMEM; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
898 |
+ err = asn1_decode_sequence_of_keys(&in, &keysets[ki]); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
899 |
+ if (err) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
900 |
goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
901 |
- } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
902 |
- for (j = 0; j < n_kd; j++) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
903 |
- key_data[noofkeys - n_kd + j] = kd[j]; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
904 |
- free (kd); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
905 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
906 |
+ if (total_keys_out) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
907 |
+ total_keys += keysets[ki].n_key_data; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
908 |
+ ki++; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
909 |
+ } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
910 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
911 |
+ if (total_keys_out) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
912 |
+ *total_keys_out = total_keys; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
913 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
914 |
+ *n_keysets_out = n_keys; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
915 |
+ *keysets_out = keysets; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
916 |
+ keysets = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
917 |
+ n_keys = 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
918 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
919 |
+cleanup: |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
920 |
+ free_ldap_seqof_key_data(keysets, n_keys); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
921 |
+ return err; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
922 |
+} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
923 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
924 |
+krb5_error_code |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
925 |
+krb5_decode_krbsecretkey(krb5_context context, krb5_db_entry *entries, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
926 |
+ struct berval **bvalues, krb5_kvno *mkvno) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
927 |
+{ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
928 |
+ krb5_key_data *key_data = NULL, *tmp; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
929 |
+ krb5_error_code err = 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
930 |
+ ldap_seqof_key_data *keysets = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
931 |
+ krb5_int16 i, n_keysets = 0, total_keys = 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
932 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
933 |
+ err = decode_keys(bvalues, &keysets, &n_keysets, &total_keys); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
934 |
+ if (err != 0) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
935 |
+ k5_prependmsg(context, err, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
936 |
+ _("unable to decode stored principal key data")); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
937 |
+ goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
938 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
939 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
940 |
- entries->n_key_data = noofkeys; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
941 |
+ key_data = k5calloc(total_keys, sizeof(krb5_key_data), &err); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
942 |
+ if (key_data == NULL) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
943 |
+ goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
944 |
+ memset(key_data, 0, total_keys * sizeof(krb5_key_data)); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
945 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
946 |
+ if (n_keysets > 0) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
947 |
+ *mkvno = keysets[0].mkvno; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
948 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
949 |
+ /* Transfer key data values from keysets to a flat list in entries. */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
950 |
+ tmp = key_data; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
951 |
+ for (i = 0; i < n_keysets; i++) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
952 |
+ memcpy(tmp, keysets[i].key_data, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
953 |
+ sizeof(krb5_key_data) * keysets[i].n_key_data); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
954 |
+ tmp += keysets[i].n_key_data; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
955 |
+ keysets[i].n_key_data = 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
956 |
+ } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
957 |
+ entries->n_key_data = total_keys; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
958 |
entries->key_data = key_data; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
959 |
+ key_data = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
960 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
961 |
cleanup: |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
962 |
- free (user); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
963 |
- return st; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
964 |
+ free_ldap_seqof_key_data(keysets, n_keysets); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
965 |
+ k5_free_key_data(total_keys, key_data); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
966 |
+ return err; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
967 |
+} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
968 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
969 |
+static int |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
970 |
+compare_osa_pw_hist_ent(const void *left_in, const void *right_in) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
971 |
+{ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
972 |
+ int kvno_left, kvno_right; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
973 |
+ osa_pw_hist_ent *left = (osa_pw_hist_ent *)left_in; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
974 |
+ osa_pw_hist_ent *right = (osa_pw_hist_ent *)right_in; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
975 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
976 |
+ kvno_left = left->n_key_data ? left->key_data[0].key_data_kvno : 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
977 |
+ kvno_right = right->n_key_data ? right->key_data[0].key_data_kvno : 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
978 |
+ return kvno_left - kvno_right; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
979 |
+} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
980 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
981 |
+/* |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
982 |
+ * Decode the key history entries from an LDAP search. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
983 |
+ * |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
984 |
+ * NOTE: the caller must free princ_ent->old_keys even on error. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
985 |
+ */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
986 |
+krb5_error_code |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
987 |
+krb5_decode_histkey(krb5_context context, struct berval **bvalues, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
988 |
+ osa_princ_ent_rec *princ_ent) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
989 |
+{ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
990 |
+ krb5_error_code err = 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
991 |
+ krb5_int16 i, n_keysets = 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
992 |
+ ldap_seqof_key_data *keysets = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
993 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
994 |
+ err = decode_keys(bvalues, &keysets, &n_keysets, NULL); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
995 |
+ if (err != 0) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
996 |
+ k5_prependmsg(context, err, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
997 |
+ _("unable to decode stored principal pw history")); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
998 |
+ goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
999 |
+ } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1000 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1001 |
+ princ_ent->old_keys = k5calloc(n_keysets, sizeof(osa_pw_hist_ent), &err); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1002 |
+ if (princ_ent->old_keys == NULL) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1003 |
+ goto cleanup; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1004 |
+ princ_ent->old_key_len = n_keysets; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1005 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1006 |
+ if (n_keysets > 0) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1007 |
+ princ_ent->admin_history_kvno = keysets[0].mkvno; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1008 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1009 |
+ /* Transfer key data pointers from keysets to princ_ent. */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1010 |
+ for (i = 0; i < n_keysets; i++) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1011 |
+ princ_ent->old_keys[i].n_key_data = keysets[i].n_key_data; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1012 |
+ princ_ent->old_keys[i].key_data = keysets[i].key_data; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1013 |
+ keysets[i].n_key_data = 0; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1014 |
+ keysets[i].key_data = NULL; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1015 |
+ } |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1016 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1017 |
+ /* Sort the principal entries by kvno in ascending order. */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1018 |
+ qsort(princ_ent->old_keys, princ_ent->old_key_len, sizeof(osa_pw_hist_ent), |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1019 |
+ &compare_osa_pw_hist_ent); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1020 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1021 |
+ princ_ent->aux_attributes |= KADM5_KEY_HIST; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1022 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1023 |
+ /* Set the next key to the end of the list. The queue will be lengthened |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1024 |
+ * if it isn't full yet; the first entry will be replaced if it is full. */ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1025 |
+ princ_ent->old_key_next = princ_ent->old_key_len; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1026 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1027 |
+cleanup: |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1028 |
+ free_ldap_seqof_key_data(keysets, n_keysets); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1029 |
+ return err; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1030 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1031 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1032 |
static char * |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1033 |
--- a/src/plugins/kdb/ldap/libkdb_ldap/princ_xdr.c |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1034 |
+++ b/src/plugins/kdb/ldap/libkdb_ldap/princ_xdr.c |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1035 |
@@ -204,20 +204,14 @@ krb5_lookup_tl_kadm_data(krb5_tl_data *t |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1036 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1037 |
krb5_error_code |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1038 |
krb5_update_tl_kadm_data(krb5_context context, krb5_db_entry *entry, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1039 |
- char *policy_dn) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1040 |
+ osa_princ_ent_rec *princ_entry) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1041 |
{ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1042 |
XDR xdrs; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1043 |
- osa_princ_ent_rec princ_entry; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1044 |
krb5_tl_data tl_data; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1045 |
krb5_error_code retval; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1046 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1047 |
- memset(&princ_entry, 0, sizeof(osa_princ_ent_rec)); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1048 |
- princ_entry.admin_history_kvno = 2; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1049 |
- princ_entry.aux_attributes = KADM5_POLICY; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1050 |
- princ_entry.policy = policy_dn; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1051 |
- |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1052 |
xdralloc_create(&xdrs, XDR_ENCODE); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1053 |
- if (! ldap_xdr_osa_princ_ent_rec(&xdrs, &princ_entry)) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1054 |
+ if (! ldap_xdr_osa_princ_ent_rec(&xdrs, princ_entry)) { |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1055 |
xdr_destroy(&xdrs); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1056 |
return KADM5_XDR_FAILURE; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1057 |
} |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1058 |
--- a/src/plugins/kdb/ldap/libkdb_ldap/princ_xdr.h |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1059 |
+++ b/src/plugins/kdb/ldap/libkdb_ldap/princ_xdr.h |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1060 |
@@ -57,6 +57,6 @@ krb5_lookup_tl_kadm_data(krb5_tl_data *t |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1061 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1062 |
krb5_error_code |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1063 |
krb5_update_tl_kadm_data(krb5_context context, krb5_db_entry *entry, |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1064 |
- char *policy_dn); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1065 |
+ osa_princ_ent_rec *princ_entry); |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1066 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1067 |
#endif |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1068 |
--- a/src/tests/kdbtest.c |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1069 |
+++ b/src/tests/kdbtest.c |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1070 |
@@ -97,7 +97,7 @@ static krb5_tl_data tl3 = { &tl4, KRB5_T |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1071 |
U("\x12\x34\x5C\x01\x00\x00\x00\x08" |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1072 |
"\x3C\x74\x65\x73\x74\x2A\x3E\x00" |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1073 |
"\x00\x00\x08\x00\x00\x00\x00\x00" |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1074 |
- "\x00\x00\x00\x02\x00\x00\x00\x00") }; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1075 |
+ "\x00\x00\x00\x00\x00\x00\x00\x00") }; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1076 |
static krb5_tl_data tl2 = { &tl3, KRB5_TL_MOD_PRINC, 8, U("\5\6\7\0x@Y\0") }; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1077 |
static krb5_tl_data tl1 = { &tl2, KRB5_TL_LAST_PWD_CHANGE, 4, U("\1\2\3\4") }; |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1078 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1079 |
--- a/src/tests/t_kdb.py |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1080 |
+++ b/src/tests/t_kdb.py |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1081 |
@@ -337,6 +337,31 @@ realm.run([kadminl, 'modprinc', '+requir |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1082 |
realm.kinit('canon', password('canon')) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1083 |
realm.kinit('alias', password('canon'), ['-C']) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1084 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1085 |
+# Test password history. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1086 |
+def test_pwhist(nhist): |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1087 |
+ def cpw(n, **kwargs): |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1088 |
+ realm.run([kadminl, 'cpw', '-pw', str(n), princ], **kwargs) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1089 |
+ def cpw_fail(n): |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1090 |
+ cpw(n, expected_code=1) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1091 |
+ output('*** Testing password history of size %d\n' % nhist) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1092 |
+ princ = 'pwhistprinc' + str(nhist) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1093 |
+ pol = 'pwhistpol' + str(nhist) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1094 |
+ realm.run([kadminl, 'addpol', '-history', str(nhist), pol]) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1095 |
+ realm.run([kadminl, 'addprinc', '-policy', pol, '-nokey', princ]) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1096 |
+ for i in range(nhist): |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1097 |
+ # Set a password, then check that all previous passwords fail. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1098 |
+ cpw(i) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1099 |
+ for j in range(i + 1): |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1100 |
+ cpw_fail(j) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1101 |
+ # Set one more new password, and make sure the oldest key is |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1102 |
+ # rotated out. |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1103 |
+ cpw(nhist) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1104 |
+ cpw_fail(1) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1105 |
+ cpw(0) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1106 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1107 |
+for n in (1, 2, 3, 4, 5): |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1108 |
+ test_pwhist(n) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1109 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1110 |
# Regression test for #7980 (fencepost when dividing keys up by kvno). |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1111 |
realm.run([kadminl, 'addprinc', '-randkey', '-e', 'aes256-cts,aes128-cts', |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1112 |
'kvnoprinc']) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1113 |
@@ -368,6 +393,13 @@ out = realm.run([kadminl, 'getprinc', 'k |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1114 |
if 'Number of keys: 0' not in out: |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1115 |
fail('After purgekeys -all, keys remain') |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1116 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1117 |
+# Test for 8354 (old password history entries when -keepold is used) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1118 |
+realm.run([kadminl, 'addpol', '-history', '2', 'keepoldpasspol']) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1119 |
+realm.run([kadminl, 'addprinc', '-policy', 'keepoldpasspol', '-pw', 'aaaa', |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1120 |
+ 'keepoldpassprinc']) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1121 |
+for p in ('bbbb', 'cccc', 'aaaa'): |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1122 |
+ realm.run([kadminl, 'cpw', '-keepold', '-pw', p, 'keepoldpassprinc']) |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1123 |
+ |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1124 |
realm.stop() |
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1125 |
|
b3414fa83399
18794793 MIT 1.8.3 resync removed pw history when using LDAP as a backend
Tomas Kuthan <tomas.kuthan@oracle.com>
parents:
diff
changeset
|
1126 |
# Briefly test dump and load. |