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>
39 __RCSID("$Heimdal: default_config.c 21405 2007-07-04 10:35:45Z lha $"
43 krb5_kdc_get_config(krb5_context context
, krb5_kdc_configuration
**config
)
45 krb5_kdc_configuration
*c
;
47 c
= calloc(1, sizeof(*c
));
49 krb5_set_error_string(context
, "malloc: out of memory");
53 c
->require_preauth
= TRUE
;
54 c
->kdc_warn_pwexpire
= 0;
55 c
->encode_as_rep_as_tgs_rep
= FALSE
;
56 c
->check_ticket_addresses
= TRUE
;
57 c
->allow_null_ticket_addresses
= TRUE
;
58 c
->allow_anonymous
= FALSE
;
59 c
->trpolicy
= TRPOLICY_ALWAYS_CHECK
;
61 c
->enable_kaserver
= FALSE
;
62 c
->enable_524
= FALSE
;
63 c
->enable_v4_cross_realm
= FALSE
;
64 c
->enable_pkinit
= FALSE
;
65 c
->pkinit_princ_in_cert
= TRUE
;
66 c
->pkinit_require_binding
= TRUE
;
72 krb5_config_get_bool_default(context
, NULL
,
74 "kdc", "require-preauth", NULL
);
76 krb5_config_get_bool_default(context
, NULL
,
78 "kdc", "enable-kerberos4", NULL
);
79 c
->enable_v4_cross_realm
=
80 krb5_config_get_bool_default(context
, NULL
,
81 c
->enable_v4_cross_realm
,
83 "enable-kerberos4-cross-realm", NULL
);
85 krb5_config_get_bool_default(context
, NULL
,
87 "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;
116 krb5_config_get_bool_default(context
, NULL
,
118 "kdc", "enable-kx509", NULL
);
120 if (c
->enable_kx509
) {
122 krb5_config_get_string(context
, NULL
,
123 "kdc", "kx509_template", NULL
);
125 krb5_config_get_string(context
, NULL
,
126 "kdc", "kx509_ca", NULL
);
127 if (c
->kx509_ca
== NULL
|| c
->kx509_template
== NULL
) {
128 kdc_log(context
, c
, 0,
129 "missing kx509 configuration, turning off");
130 c
->enable_kx509
= FALSE
;
134 c
->check_ticket_addresses
=
135 krb5_config_get_bool_default(context
, NULL
,
136 c
->check_ticket_addresses
,
138 "check-ticket-addresses", NULL
);
139 c
->allow_null_ticket_addresses
=
140 krb5_config_get_bool_default(context
, NULL
,
141 c
->allow_null_ticket_addresses
,
143 "allow-null-ticket-addresses", NULL
);
146 krb5_config_get_bool_default(context
, NULL
,
149 "allow-anonymous", NULL
);
151 c
->max_datagram_reply_length
=
152 krb5_config_get_int_default(context
,
156 "max-kdc-datagram-reply-length",
160 const char *trpolicy_str
;
163 krb5_config_get_string_default(context
, NULL
, "DEFAULT", "kdc",
164 "transited-policy", NULL
);
165 if(strcasecmp(trpolicy_str
, "always-check") == 0) {
166 c
->trpolicy
= TRPOLICY_ALWAYS_CHECK
;
167 } else if(strcasecmp(trpolicy_str
, "allow-per-principal") == 0) {
168 c
->trpolicy
= TRPOLICY_ALLOW_PER_PRINCIPAL
;
169 } else if(strcasecmp(trpolicy_str
, "always-honour-request") == 0) {
170 c
->trpolicy
= TRPOLICY_ALWAYS_HONOUR_REQUEST
;
171 } else if(strcasecmp(trpolicy_str
, "DEFAULT") == 0) {
174 kdc_log(context
, c
, 0,
175 "unknown transited-policy: %s, "
176 "reverting to default (always-check)",
183 p
= krb5_config_get_string (context
, NULL
,
188 c
->v4_realm
= strdup(p
);
189 if (c
->v4_realm
== NULL
)
190 krb5_errx(context
, 1, "out of memory");
197 krb5_config_get_bool_default(context
,
200 "kdc", "enable-kaserver", NULL
);
203 c
->encode_as_rep_as_tgs_rep
=
204 krb5_config_get_bool_default(context
, NULL
,
205 c
->encode_as_rep_as_tgs_rep
,
207 "encode_as_rep_as_tgs_rep", NULL
);
209 c
->kdc_warn_pwexpire
=
210 krb5_config_get_time_default (context
, NULL
,
211 c
->kdc_warn_pwexpire
,
212 "kdc", "kdc_warn_pwexpire", NULL
);
217 krb5_config_get_bool_default(context
,
223 if (c
->enable_pkinit
) {
224 const char *user_id
, *anchors
, *ocsp_file
;
225 char **pool_list
, **revoke_list
;
228 krb5_config_get_string(context
, NULL
,
229 "kdc", "pkinit_identity", NULL
);
231 krb5_errx(context
, 1, "pkinit enabled but no identity");
233 anchors
= krb5_config_get_string(context
, NULL
,
234 "kdc", "pkinit_anchors", NULL
);
236 krb5_errx(context
, 1, "pkinit enabled but no X509 anchors");
239 krb5_config_get_strings(context
, NULL
,
240 "kdc", "pkinit_pool", NULL
);
243 krb5_config_get_strings(context
, NULL
,
244 "kdc", "pkinit_revoke", NULL
);
247 krb5_config_get_string(context
, NULL
,
248 "kdc", "pkinit_kdc_ocsp", NULL
);
250 c
->pkinit_kdc_ocsp_file
= strdup(ocsp_file
);
251 if (c
->pkinit_kdc_ocsp_file
== NULL
)
252 krb5_errx(context
, 1, "out of memory");
255 _kdc_pk_initialize(context
, c
, user_id
, anchors
,
256 pool_list
, revoke_list
);
258 krb5_config_free_strings(pool_list
);
259 krb5_config_free_strings(revoke_list
);
261 c
->pkinit_princ_in_cert
=
262 krb5_config_get_bool_default(context
, NULL
,
263 c
->pkinit_princ_in_cert
,
265 "pkinit_principal_in_certificate",
268 c
->pkinit_require_binding
=
269 krb5_config_get_bool_default(context
, NULL
,
270 c
->pkinit_require_binding
,
272 "pkinit_win2k_require_binding",
276 c
->pkinit_dh_min_bits
=
277 krb5_config_get_int_default(context
, NULL
,
279 "kdc", "pkinit_dh_min_bits", NULL
);