2 * Copyright (c) 1997-2007 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the Institute nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 #include <parse_bytes.h>
42 krb5_kdc_get_config(krb5_context context
, krb5_kdc_configuration
**config
)
44 krb5_kdc_configuration
*c
;
46 c
= calloc(1, sizeof(*c
));
48 krb5_set_error_message(context
, ENOMEM
, "malloc: out of memory");
52 c
->require_preauth
= TRUE
;
53 c
->kdc_warn_pwexpire
= 0;
54 c
->encode_as_rep_as_tgs_rep
= FALSE
;
55 c
->check_ticket_addresses
= TRUE
;
56 c
->allow_null_ticket_addresses
= TRUE
;
57 c
->allow_anonymous
= FALSE
;
58 c
->trpolicy
= TRPOLICY_ALWAYS_CHECK
;
60 c
->enable_kaserver
= FALSE
;
61 c
->enable_524
= FALSE
;
62 c
->enable_v4_cross_realm
= FALSE
;
63 c
->enable_pkinit
= FALSE
;
64 c
->pkinit_princ_in_cert
= TRUE
;
65 c
->pkinit_require_binding
= TRUE
;
71 krb5_config_get_bool_default(context
, NULL
,
73 "kdc", "require-preauth", NULL
);
75 krb5_config_get_bool_default(context
, NULL
,
77 "kdc", "enable-kerberos4", NULL
);
78 c
->enable_v4_cross_realm
=
79 krb5_config_get_bool_default(context
, NULL
,
80 c
->enable_v4_cross_realm
,
82 "enable-kerberos4-cross-realm", NULL
);
84 krb5_config_get_bool_default(context
, NULL
,
86 "kdc", "enable-524", NULL
);
89 krb5_config_get_bool_default(context
, NULL
,
91 "kdc", "enable-digest", NULL
);
96 digests
= krb5_config_get_string(context
, NULL
,
98 "digests_allowed", NULL
);
101 c
->digests_allowed
= parse_flags(digests
,_kdc_digestunits
, 0);
102 if (c
->digests_allowed
== -1) {
103 kdc_log(context
, c
, 0,
104 "unparsable digest units (%s), turning off digest",
106 c
->enable_digest
= 0;
107 } else if (c
->digests_allowed
== 0) {
108 kdc_log(context
, c
, 0,
109 "no digest enable, turning digest off",
111 c
->enable_digest
= 0;
118 krb5_config_get_bool_default(context
, NULL
,
120 "kdc", "enable-kx509", NULL
);
122 if (c
->enable_kx509
) {
124 krb5_config_get_string(context
, NULL
,
125 "kdc", "kx509_template", NULL
);
127 krb5_config_get_string(context
, NULL
,
128 "kdc", "kx509_ca", NULL
);
129 if (c
->kx509_ca
== NULL
|| c
->kx509_template
== NULL
) {
130 kdc_log(context
, c
, 0,
131 "missing kx509 configuration, turning off");
132 c
->enable_kx509
= FALSE
;
137 c
->check_ticket_addresses
=
138 krb5_config_get_bool_default(context
, NULL
,
139 c
->check_ticket_addresses
,
141 "check-ticket-addresses", NULL
);
142 c
->allow_null_ticket_addresses
=
143 krb5_config_get_bool_default(context
, NULL
,
144 c
->allow_null_ticket_addresses
,
146 "allow-null-ticket-addresses", NULL
);
149 krb5_config_get_bool_default(context
, NULL
,
152 "allow-anonymous", NULL
);
154 c
->max_datagram_reply_length
=
155 krb5_config_get_int_default(context
,
159 "max-kdc-datagram-reply-length",
163 const char *trpolicy_str
;
166 krb5_config_get_string_default(context
, NULL
, "DEFAULT", "kdc",
167 "transited-policy", NULL
);
168 if(strcasecmp(trpolicy_str
, "always-check") == 0) {
169 c
->trpolicy
= TRPOLICY_ALWAYS_CHECK
;
170 } else if(strcasecmp(trpolicy_str
, "allow-per-principal") == 0) {
171 c
->trpolicy
= TRPOLICY_ALLOW_PER_PRINCIPAL
;
172 } else if(strcasecmp(trpolicy_str
, "always-honour-request") == 0) {
173 c
->trpolicy
= TRPOLICY_ALWAYS_HONOUR_REQUEST
;
174 } else if(strcasecmp(trpolicy_str
, "DEFAULT") == 0) {
177 kdc_log(context
, c
, 0,
178 "unknown transited-policy: %s, "
179 "reverting to default (always-check)",
186 p
= krb5_config_get_string (context
, NULL
,
191 c
->v4_realm
= strdup(p
);
192 if (c
->v4_realm
== NULL
)
193 krb5_errx(context
, 1, "out of memory");
200 krb5_config_get_bool_default(context
,
203 "kdc", "enable-kaserver", NULL
);
206 c
->encode_as_rep_as_tgs_rep
=
207 krb5_config_get_bool_default(context
, NULL
,
208 c
->encode_as_rep_as_tgs_rep
,
210 "encode_as_rep_as_tgs_rep", NULL
);
212 c
->kdc_warn_pwexpire
=
213 krb5_config_get_time_default (context
, NULL
,
214 c
->kdc_warn_pwexpire
,
215 "kdc", "kdc_warn_pwexpire", NULL
);
220 krb5_config_get_bool_default(context
,
226 if (c
->enable_pkinit
) {
227 const char *user_id
, *anchors
, *file
;
228 char **pool_list
, **revoke_list
;
231 krb5_config_get_string(context
, NULL
,
232 "kdc", "pkinit_identity", NULL
);
234 krb5_errx(context
, 1, "pkinit enabled but no identity");
236 anchors
= krb5_config_get_string(context
, NULL
,
237 "kdc", "pkinit_anchors", NULL
);
239 krb5_errx(context
, 1, "pkinit enabled but no X509 anchors");
242 krb5_config_get_strings(context
, NULL
,
243 "kdc", "pkinit_pool", NULL
);
246 krb5_config_get_strings(context
, NULL
,
247 "kdc", "pkinit_revoke", NULL
);
249 file
= krb5_config_get_string(context
, NULL
,
250 "kdc", "pkinit_kdc_ocsp", NULL
);
252 c
->pkinit_kdc_ocsp_file
= strdup(file
);
253 if (c
->pkinit_kdc_ocsp_file
== NULL
)
254 krb5_errx(context
, 1, "out of memory");
257 file
= krb5_config_get_string(context
, NULL
,
258 "kdc", "pkinit_kdc_friendly_name", NULL
);
260 c
->pkinit_kdc_friendly_name
= strdup(file
);
261 if (c
->pkinit_kdc_friendly_name
== NULL
)
262 krb5_errx(context
, 1, "out of memory");
266 _kdc_pk_initialize(context
, c
, user_id
, anchors
,
267 pool_list
, revoke_list
);
269 krb5_config_free_strings(pool_list
);
270 krb5_config_free_strings(revoke_list
);
272 c
->pkinit_princ_in_cert
=
273 krb5_config_get_bool_default(context
, NULL
,
274 c
->pkinit_princ_in_cert
,
276 "pkinit_principal_in_certificate",
279 c
->pkinit_require_binding
=
280 krb5_config_get_bool_default(context
, NULL
,
281 c
->pkinit_require_binding
,
283 "pkinit_win2k_require_binding",
287 c
->pkinit_dh_min_bits
=
288 krb5_config_get_int_default(context
, NULL
,
290 "kdc", "pkinit_dh_min_bits", NULL
);