s4:kdc: split out a sdb_keys_free() helper function
[Samba.git] / source4 / kdc / sdb.h
blob5d49769a95bf740be7a21133a639726fa2220e73
1 /*
2 Unix SMB/CIFS implementation.
4 Database Glue between Samba and the KDC
6 Copyright (C) Guenther Deschner <gd@samba.org> 2014
7 Copyright (C) Andreas Schneider <asn@samba.org> 2014
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #ifndef _KDC_SDB_H_
25 #define _KDC_SDB_H_
27 struct sdb_salt {
28 unsigned int type;
29 krb5_data salt;
32 struct sdb_key {
33 krb5_keyblock key;
34 struct sdb_salt *salt;
37 struct sdb_keys {
38 unsigned int len;
39 struct sdb_key *val;
42 struct sdb_event {
43 krb5_principal principal;
44 time_t time;
47 struct SDBFlags {
48 unsigned int initial:1;
49 unsigned int forwardable:1;
50 unsigned int proxiable:1;
51 unsigned int renewable:1;
52 unsigned int postdate:1;
53 unsigned int server:1;
54 unsigned int client:1;
55 unsigned int invalid:1;
56 unsigned int require_preauth:1;
57 unsigned int change_pw:1;
58 unsigned int require_hwauth:1;
59 unsigned int ok_as_delegate:1;
60 unsigned int user_to_user:1;
61 unsigned int immutable:1;
62 unsigned int trusted_for_delegation:1;
63 unsigned int allow_kerberos4:1;
64 unsigned int allow_digest:1;
65 unsigned int locked_out:1;
66 unsigned int require_pwchange:1;
67 unsigned int materialize:1;
68 unsigned int virtual_keys:1;
69 unsigned int virtual:1;
70 unsigned int synthetic:1;
71 unsigned int no_auth_data_reqd:1;
72 unsigned int _unused24:1;
73 unsigned int _unused25:1;
74 unsigned int _unused26:1;
75 unsigned int _unused27:1;
76 unsigned int _unused28:1;
77 unsigned int _unused29:1;
78 unsigned int force_canonicalize:1;
79 unsigned int do_not_store:1;
82 struct sdb_entry {
83 krb5_principal principal;
84 unsigned int kvno;
85 struct sdb_keys keys;
86 struct sdb_event created_by;
87 struct sdb_event *modified_by;
88 time_t *valid_start;
89 time_t *valid_end;
90 time_t *pw_end;
91 unsigned int *max_life;
92 unsigned int *max_renew;
93 struct SDBFlags flags;
96 struct sdb_entry_ex {
97 void *ctx;
98 struct sdb_entry entry;
101 #define SDB_ERR_NOENTRY 36150275
102 #define SDB_ERR_NOT_FOUND_HERE 36150287
103 #define SDB_ERR_WRONG_REALM 36150289
105 /* These must match the values in hdb.h */
107 #define SDB_F_DECRYPT 1 /* decrypt keys */
108 #define SDB_F_GET_CLIENT 4 /* fetch client */
109 #define SDB_F_GET_SERVER 8 /* fetch server */
110 #define SDB_F_GET_KRBTGT 16 /* fetch krbtgt */
111 #define SDB_F_GET_ANY 28 /* fetch any of client,server,krbtgt */
112 #define SDB_F_CANON 32 /* want canonicalition */
113 #define SDB_F_ADMIN_DATA 64 /* want data that kdc don't use */
114 #define SDB_F_KVNO_SPECIFIED 128 /* we want a particular KVNO */
115 #define SDB_F_FOR_AS_REQ 4096 /* fetch is for a AS REQ */
116 #define SDB_F_FOR_TGS_REQ 8192 /* fetch is for a TGS REQ */
118 #define SDB_F_HDB_MASK (SDB_F_DECRYPT | \
119 SDB_F_GET_CLIENT| \
120 SDB_F_GET_SERVER | \
121 SDB_F_GET_KRBTGT | \
122 SDB_F_CANON | \
123 SDB_F_ADMIN_DATA | \
124 SDB_F_KVNO_SPECIFIED | \
125 SDB_F_FOR_AS_REQ | \
126 SDB_F_FOR_TGS_REQ)
128 /* This is not supported by HDB */
129 #define SDB_F_FORCE_CANON 16384 /* force canonicalition */
131 void sdb_free_entry(struct sdb_entry_ex *e);
132 void sdb_key_free(struct sdb_key *key);
133 void sdb_keys_free(struct sdb_keys *keys);
134 struct SDBFlags int2SDBFlags(unsigned n);
136 #endif /* _KDC_SDB_H_ */