1*0a6a1f1dSLionel Sambuc /* $NetBSD: init_creds.c,v 1.1.1.2 2014/04/24 12:45:50 pettai Exp $ */
2ebfedea0SLionel Sambuc
3ebfedea0SLionel Sambuc /*
4ebfedea0SLionel Sambuc * Copyright (c) 1997 - 2004 Kungliga Tekniska Högskolan
5ebfedea0SLionel Sambuc * (Royal Institute of Technology, Stockholm, Sweden).
6ebfedea0SLionel Sambuc * All rights reserved.
7ebfedea0SLionel Sambuc *
8ebfedea0SLionel Sambuc * Portions Copyright (c) 2009 Apple Inc. All rights reserved.
9ebfedea0SLionel Sambuc *
10ebfedea0SLionel Sambuc * Redistribution and use in source and binary forms, with or without
11ebfedea0SLionel Sambuc * modification, are permitted provided that the following conditions
12ebfedea0SLionel Sambuc * are met:
13ebfedea0SLionel Sambuc *
14ebfedea0SLionel Sambuc * 1. Redistributions of source code must retain the above copyright
15ebfedea0SLionel Sambuc * notice, this list of conditions and the following disclaimer.
16ebfedea0SLionel Sambuc *
17ebfedea0SLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright
18ebfedea0SLionel Sambuc * notice, this list of conditions and the following disclaimer in the
19ebfedea0SLionel Sambuc * documentation and/or other materials provided with the distribution.
20ebfedea0SLionel Sambuc *
21ebfedea0SLionel Sambuc * 3. Neither the name of the Institute nor the names of its contributors
22ebfedea0SLionel Sambuc * may be used to endorse or promote products derived from this software
23ebfedea0SLionel Sambuc * without specific prior written permission.
24ebfedea0SLionel Sambuc *
25ebfedea0SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
26ebfedea0SLionel Sambuc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27ebfedea0SLionel Sambuc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28ebfedea0SLionel Sambuc * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
29ebfedea0SLionel Sambuc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30ebfedea0SLionel Sambuc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31ebfedea0SLionel Sambuc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32ebfedea0SLionel Sambuc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33ebfedea0SLionel Sambuc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34ebfedea0SLionel Sambuc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35ebfedea0SLionel Sambuc * SUCH DAMAGE.
36ebfedea0SLionel Sambuc */
37ebfedea0SLionel Sambuc
38ebfedea0SLionel Sambuc #include "krb5_locl.h"
39ebfedea0SLionel Sambuc
40ebfedea0SLionel Sambuc #undef __attribute__
41ebfedea0SLionel Sambuc #define __attribute__(x)
42ebfedea0SLionel Sambuc
43ebfedea0SLionel Sambuc /**
44ebfedea0SLionel Sambuc * @page krb5_init_creds_intro The initial credential handing functions
45ebfedea0SLionel Sambuc * @section section_krb5_init_creds Initial credential
46ebfedea0SLionel Sambuc *
47ebfedea0SLionel Sambuc * Functions to get initial credentials: @ref krb5_credential .
48ebfedea0SLionel Sambuc */
49ebfedea0SLionel Sambuc
50ebfedea0SLionel Sambuc /**
51ebfedea0SLionel Sambuc * Allocate a new krb5_get_init_creds_opt structure, free with
52ebfedea0SLionel Sambuc * krb5_get_init_creds_opt_free().
53ebfedea0SLionel Sambuc *
54ebfedea0SLionel Sambuc * @ingroup krb5_credential
55ebfedea0SLionel Sambuc */
56ebfedea0SLionel Sambuc
57ebfedea0SLionel Sambuc KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_get_init_creds_opt_alloc(krb5_context context,krb5_get_init_creds_opt ** opt)58ebfedea0SLionel Sambuc krb5_get_init_creds_opt_alloc(krb5_context context,
59ebfedea0SLionel Sambuc krb5_get_init_creds_opt **opt)
60ebfedea0SLionel Sambuc {
61ebfedea0SLionel Sambuc krb5_get_init_creds_opt *o;
62ebfedea0SLionel Sambuc
63ebfedea0SLionel Sambuc *opt = NULL;
64ebfedea0SLionel Sambuc o = calloc(1, sizeof(*o));
65ebfedea0SLionel Sambuc if (o == NULL) {
66ebfedea0SLionel Sambuc krb5_set_error_message(context, ENOMEM,
67ebfedea0SLionel Sambuc N_("malloc: out of memory", ""));
68ebfedea0SLionel Sambuc return ENOMEM;
69ebfedea0SLionel Sambuc }
70ebfedea0SLionel Sambuc
71ebfedea0SLionel Sambuc o->opt_private = calloc(1, sizeof(*o->opt_private));
72ebfedea0SLionel Sambuc if (o->opt_private == NULL) {
73ebfedea0SLionel Sambuc krb5_set_error_message(context, ENOMEM,
74ebfedea0SLionel Sambuc N_("malloc: out of memory", ""));
75ebfedea0SLionel Sambuc free(o);
76ebfedea0SLionel Sambuc return ENOMEM;
77ebfedea0SLionel Sambuc }
78ebfedea0SLionel Sambuc o->opt_private->refcount = 1;
79ebfedea0SLionel Sambuc *opt = o;
80ebfedea0SLionel Sambuc return 0;
81ebfedea0SLionel Sambuc }
82ebfedea0SLionel Sambuc
83ebfedea0SLionel Sambuc /**
84ebfedea0SLionel Sambuc * Free krb5_get_init_creds_opt structure.
85ebfedea0SLionel Sambuc *
86ebfedea0SLionel Sambuc * @ingroup krb5_credential
87ebfedea0SLionel Sambuc */
88ebfedea0SLionel Sambuc
89ebfedea0SLionel Sambuc KRB5_LIB_FUNCTION void KRB5_LIB_CALL
krb5_get_init_creds_opt_free(krb5_context context,krb5_get_init_creds_opt * opt)90ebfedea0SLionel Sambuc krb5_get_init_creds_opt_free(krb5_context context,
91ebfedea0SLionel Sambuc krb5_get_init_creds_opt *opt)
92ebfedea0SLionel Sambuc {
93ebfedea0SLionel Sambuc if (opt == NULL || opt->opt_private == NULL)
94ebfedea0SLionel Sambuc return;
95ebfedea0SLionel Sambuc if (opt->opt_private->refcount < 1) /* abort ? */
96ebfedea0SLionel Sambuc return;
97ebfedea0SLionel Sambuc if (--opt->opt_private->refcount == 0) {
98ebfedea0SLionel Sambuc _krb5_get_init_creds_opt_free_pkinit(opt);
99ebfedea0SLionel Sambuc free(opt->opt_private);
100ebfedea0SLionel Sambuc }
101ebfedea0SLionel Sambuc memset(opt, 0, sizeof(*opt));
102ebfedea0SLionel Sambuc free(opt);
103ebfedea0SLionel Sambuc }
104ebfedea0SLionel Sambuc
105ebfedea0SLionel Sambuc static int
get_config_time(krb5_context context,const char * realm,const char * name,int def)106ebfedea0SLionel Sambuc get_config_time (krb5_context context,
107ebfedea0SLionel Sambuc const char *realm,
108ebfedea0SLionel Sambuc const char *name,
109ebfedea0SLionel Sambuc int def)
110ebfedea0SLionel Sambuc {
111ebfedea0SLionel Sambuc int ret;
112ebfedea0SLionel Sambuc
113ebfedea0SLionel Sambuc ret = krb5_config_get_time (context, NULL,
114ebfedea0SLionel Sambuc "realms",
115ebfedea0SLionel Sambuc realm,
116ebfedea0SLionel Sambuc name,
117ebfedea0SLionel Sambuc NULL);
118ebfedea0SLionel Sambuc if (ret >= 0)
119ebfedea0SLionel Sambuc return ret;
120ebfedea0SLionel Sambuc ret = krb5_config_get_time (context, NULL,
121ebfedea0SLionel Sambuc "libdefaults",
122ebfedea0SLionel Sambuc name,
123ebfedea0SLionel Sambuc NULL);
124ebfedea0SLionel Sambuc if (ret >= 0)
125ebfedea0SLionel Sambuc return ret;
126ebfedea0SLionel Sambuc return def;
127ebfedea0SLionel Sambuc }
128ebfedea0SLionel Sambuc
129ebfedea0SLionel Sambuc static krb5_boolean
get_config_bool(krb5_context context,krb5_boolean def_value,const char * realm,const char * name)130ebfedea0SLionel Sambuc get_config_bool (krb5_context context,
131ebfedea0SLionel Sambuc krb5_boolean def_value,
132ebfedea0SLionel Sambuc const char *realm,
133ebfedea0SLionel Sambuc const char *name)
134ebfedea0SLionel Sambuc {
135ebfedea0SLionel Sambuc krb5_boolean b;
136ebfedea0SLionel Sambuc
137ebfedea0SLionel Sambuc b = krb5_config_get_bool_default(context, NULL, def_value,
138ebfedea0SLionel Sambuc "realms", realm, name, NULL);
139ebfedea0SLionel Sambuc if (b != def_value)
140ebfedea0SLionel Sambuc return b;
141ebfedea0SLionel Sambuc b = krb5_config_get_bool_default (context, NULL, def_value,
142ebfedea0SLionel Sambuc "libdefaults", name, NULL);
143ebfedea0SLionel Sambuc if (b != def_value)
144ebfedea0SLionel Sambuc return b;
145ebfedea0SLionel Sambuc return def_value;
146ebfedea0SLionel Sambuc }
147ebfedea0SLionel Sambuc
148ebfedea0SLionel Sambuc /*
149ebfedea0SLionel Sambuc * set all the values in `opt' to the appropriate values for
150ebfedea0SLionel Sambuc * application `appname' (default to getprogname() if NULL), and realm
151ebfedea0SLionel Sambuc * `realm'. First looks in [appdefaults] but falls back to
152ebfedea0SLionel Sambuc * [realms] or [libdefaults] for some of the values.
153ebfedea0SLionel Sambuc */
154ebfedea0SLionel Sambuc
155ebfedea0SLionel Sambuc KRB5_LIB_FUNCTION void KRB5_LIB_CALL
krb5_get_init_creds_opt_set_default_flags(krb5_context context,const char * appname,krb5_const_realm realm,krb5_get_init_creds_opt * opt)156ebfedea0SLionel Sambuc krb5_get_init_creds_opt_set_default_flags(krb5_context context,
157ebfedea0SLionel Sambuc const char *appname,
158ebfedea0SLionel Sambuc krb5_const_realm realm,
159ebfedea0SLionel Sambuc krb5_get_init_creds_opt *opt)
160ebfedea0SLionel Sambuc {
161ebfedea0SLionel Sambuc krb5_boolean b;
162ebfedea0SLionel Sambuc time_t t;
163ebfedea0SLionel Sambuc
164ebfedea0SLionel Sambuc b = get_config_bool (context, KRB5_FORWARDABLE_DEFAULT,
165ebfedea0SLionel Sambuc realm, "forwardable");
166ebfedea0SLionel Sambuc krb5_appdefault_boolean(context, appname, realm, "forwardable", b, &b);
167ebfedea0SLionel Sambuc krb5_get_init_creds_opt_set_forwardable(opt, b);
168ebfedea0SLionel Sambuc
169ebfedea0SLionel Sambuc b = get_config_bool (context, FALSE, realm, "proxiable");
170ebfedea0SLionel Sambuc krb5_appdefault_boolean(context, appname, realm, "proxiable", b, &b);
171ebfedea0SLionel Sambuc krb5_get_init_creds_opt_set_proxiable (opt, b);
172ebfedea0SLionel Sambuc
173ebfedea0SLionel Sambuc krb5_appdefault_time(context, appname, realm, "ticket_lifetime", 0, &t);
174ebfedea0SLionel Sambuc if (t == 0)
175ebfedea0SLionel Sambuc t = get_config_time (context, realm, "ticket_lifetime", 0);
176ebfedea0SLionel Sambuc if(t != 0)
177ebfedea0SLionel Sambuc krb5_get_init_creds_opt_set_tkt_life(opt, t);
178ebfedea0SLionel Sambuc
179ebfedea0SLionel Sambuc krb5_appdefault_time(context, appname, realm, "renew_lifetime", 0, &t);
180ebfedea0SLionel Sambuc if (t == 0)
181ebfedea0SLionel Sambuc t = get_config_time (context, realm, "renew_lifetime", 0);
182ebfedea0SLionel Sambuc if(t != 0)
183ebfedea0SLionel Sambuc krb5_get_init_creds_opt_set_renew_life(opt, t);
184ebfedea0SLionel Sambuc
185ebfedea0SLionel Sambuc krb5_appdefault_boolean(context, appname, realm, "no-addresses",
186ebfedea0SLionel Sambuc KRB5_ADDRESSLESS_DEFAULT, &b);
187ebfedea0SLionel Sambuc krb5_get_init_creds_opt_set_addressless (context, opt, b);
188ebfedea0SLionel Sambuc
189ebfedea0SLionel Sambuc #if 0
190ebfedea0SLionel Sambuc krb5_appdefault_boolean(context, appname, realm, "anonymous", FALSE, &b);
191ebfedea0SLionel Sambuc krb5_get_init_creds_opt_set_anonymous (opt, b);
192ebfedea0SLionel Sambuc
193ebfedea0SLionel Sambuc krb5_get_init_creds_opt_set_etype_list(opt, enctype,
194ebfedea0SLionel Sambuc etype_str.num_strings);
195ebfedea0SLionel Sambuc
196ebfedea0SLionel Sambuc krb5_get_init_creds_opt_set_salt(krb5_get_init_creds_opt *opt,
197ebfedea0SLionel Sambuc krb5_data *salt);
198ebfedea0SLionel Sambuc
199ebfedea0SLionel Sambuc krb5_get_init_creds_opt_set_preauth_list(krb5_get_init_creds_opt *opt,
200ebfedea0SLionel Sambuc krb5_preauthtype *preauth_list,
201ebfedea0SLionel Sambuc int preauth_list_length);
202ebfedea0SLionel Sambuc #endif
203ebfedea0SLionel Sambuc }
204ebfedea0SLionel Sambuc
205ebfedea0SLionel Sambuc
206ebfedea0SLionel Sambuc KRB5_LIB_FUNCTION void KRB5_LIB_CALL
krb5_get_init_creds_opt_set_tkt_life(krb5_get_init_creds_opt * opt,krb5_deltat tkt_life)207ebfedea0SLionel Sambuc krb5_get_init_creds_opt_set_tkt_life(krb5_get_init_creds_opt *opt,
208ebfedea0SLionel Sambuc krb5_deltat tkt_life)
209ebfedea0SLionel Sambuc {
210ebfedea0SLionel Sambuc opt->flags |= KRB5_GET_INIT_CREDS_OPT_TKT_LIFE;
211ebfedea0SLionel Sambuc opt->tkt_life = tkt_life;
212ebfedea0SLionel Sambuc }
213ebfedea0SLionel Sambuc
214ebfedea0SLionel Sambuc KRB5_LIB_FUNCTION void KRB5_LIB_CALL
krb5_get_init_creds_opt_set_renew_life(krb5_get_init_creds_opt * opt,krb5_deltat renew_life)215ebfedea0SLionel Sambuc krb5_get_init_creds_opt_set_renew_life(krb5_get_init_creds_opt *opt,
216ebfedea0SLionel Sambuc krb5_deltat renew_life)
217ebfedea0SLionel Sambuc {
218ebfedea0SLionel Sambuc opt->flags |= KRB5_GET_INIT_CREDS_OPT_RENEW_LIFE;
219ebfedea0SLionel Sambuc opt->renew_life = renew_life;
220ebfedea0SLionel Sambuc }
221ebfedea0SLionel Sambuc
222ebfedea0SLionel Sambuc KRB5_LIB_FUNCTION void KRB5_LIB_CALL
krb5_get_init_creds_opt_set_forwardable(krb5_get_init_creds_opt * opt,int forwardable)223ebfedea0SLionel Sambuc krb5_get_init_creds_opt_set_forwardable(krb5_get_init_creds_opt *opt,
224ebfedea0SLionel Sambuc int forwardable)
225ebfedea0SLionel Sambuc {
226ebfedea0SLionel Sambuc opt->flags |= KRB5_GET_INIT_CREDS_OPT_FORWARDABLE;
227ebfedea0SLionel Sambuc opt->forwardable = forwardable;
228ebfedea0SLionel Sambuc }
229ebfedea0SLionel Sambuc
230ebfedea0SLionel Sambuc KRB5_LIB_FUNCTION void KRB5_LIB_CALL
krb5_get_init_creds_opt_set_proxiable(krb5_get_init_creds_opt * opt,int proxiable)231ebfedea0SLionel Sambuc krb5_get_init_creds_opt_set_proxiable(krb5_get_init_creds_opt *opt,
232ebfedea0SLionel Sambuc int proxiable)
233ebfedea0SLionel Sambuc {
234ebfedea0SLionel Sambuc opt->flags |= KRB5_GET_INIT_CREDS_OPT_PROXIABLE;
235ebfedea0SLionel Sambuc opt->proxiable = proxiable;
236ebfedea0SLionel Sambuc }
237ebfedea0SLionel Sambuc
238ebfedea0SLionel Sambuc KRB5_LIB_FUNCTION void KRB5_LIB_CALL
krb5_get_init_creds_opt_set_etype_list(krb5_get_init_creds_opt * opt,krb5_enctype * etype_list,int etype_list_length)239ebfedea0SLionel Sambuc krb5_get_init_creds_opt_set_etype_list(krb5_get_init_creds_opt *opt,
240ebfedea0SLionel Sambuc krb5_enctype *etype_list,
241ebfedea0SLionel Sambuc int etype_list_length)
242ebfedea0SLionel Sambuc {
243ebfedea0SLionel Sambuc opt->flags |= KRB5_GET_INIT_CREDS_OPT_ETYPE_LIST;
244ebfedea0SLionel Sambuc opt->etype_list = etype_list;
245ebfedea0SLionel Sambuc opt->etype_list_length = etype_list_length;
246ebfedea0SLionel Sambuc }
247ebfedea0SLionel Sambuc
248ebfedea0SLionel Sambuc KRB5_LIB_FUNCTION void KRB5_LIB_CALL
krb5_get_init_creds_opt_set_address_list(krb5_get_init_creds_opt * opt,krb5_addresses * addresses)249ebfedea0SLionel Sambuc krb5_get_init_creds_opt_set_address_list(krb5_get_init_creds_opt *opt,
250ebfedea0SLionel Sambuc krb5_addresses *addresses)
251ebfedea0SLionel Sambuc {
252ebfedea0SLionel Sambuc opt->flags |= KRB5_GET_INIT_CREDS_OPT_ADDRESS_LIST;
253ebfedea0SLionel Sambuc opt->address_list = addresses;
254ebfedea0SLionel Sambuc }
255ebfedea0SLionel Sambuc
256ebfedea0SLionel Sambuc KRB5_LIB_FUNCTION void KRB5_LIB_CALL
krb5_get_init_creds_opt_set_preauth_list(krb5_get_init_creds_opt * opt,krb5_preauthtype * preauth_list,int preauth_list_length)257ebfedea0SLionel Sambuc krb5_get_init_creds_opt_set_preauth_list(krb5_get_init_creds_opt *opt,
258ebfedea0SLionel Sambuc krb5_preauthtype *preauth_list,
259ebfedea0SLionel Sambuc int preauth_list_length)
260ebfedea0SLionel Sambuc {
261ebfedea0SLionel Sambuc opt->flags |= KRB5_GET_INIT_CREDS_OPT_PREAUTH_LIST;
262ebfedea0SLionel Sambuc opt->preauth_list_length = preauth_list_length;
263ebfedea0SLionel Sambuc opt->preauth_list = preauth_list;
264ebfedea0SLionel Sambuc }
265ebfedea0SLionel Sambuc
266ebfedea0SLionel Sambuc KRB5_LIB_FUNCTION void KRB5_LIB_CALL
krb5_get_init_creds_opt_set_salt(krb5_get_init_creds_opt * opt,krb5_data * salt)267ebfedea0SLionel Sambuc krb5_get_init_creds_opt_set_salt(krb5_get_init_creds_opt *opt,
268ebfedea0SLionel Sambuc krb5_data *salt)
269ebfedea0SLionel Sambuc {
270ebfedea0SLionel Sambuc opt->flags |= KRB5_GET_INIT_CREDS_OPT_SALT;
271ebfedea0SLionel Sambuc opt->salt = salt;
272ebfedea0SLionel Sambuc }
273ebfedea0SLionel Sambuc
274ebfedea0SLionel Sambuc KRB5_LIB_FUNCTION void KRB5_LIB_CALL
krb5_get_init_creds_opt_set_anonymous(krb5_get_init_creds_opt * opt,int anonymous)275ebfedea0SLionel Sambuc krb5_get_init_creds_opt_set_anonymous(krb5_get_init_creds_opt *opt,
276ebfedea0SLionel Sambuc int anonymous)
277ebfedea0SLionel Sambuc {
278ebfedea0SLionel Sambuc opt->flags |= KRB5_GET_INIT_CREDS_OPT_ANONYMOUS;
279ebfedea0SLionel Sambuc opt->anonymous = anonymous;
280ebfedea0SLionel Sambuc }
281ebfedea0SLionel Sambuc
282ebfedea0SLionel Sambuc static krb5_error_code
require_ext_opt(krb5_context context,krb5_get_init_creds_opt * opt,const char * type)283ebfedea0SLionel Sambuc require_ext_opt(krb5_context context,
284ebfedea0SLionel Sambuc krb5_get_init_creds_opt *opt,
285ebfedea0SLionel Sambuc const char *type)
286ebfedea0SLionel Sambuc {
287ebfedea0SLionel Sambuc if (opt->opt_private == NULL) {
288ebfedea0SLionel Sambuc krb5_set_error_message(context, EINVAL,
289ebfedea0SLionel Sambuc N_("%s on non extendable opt", ""), type);
290ebfedea0SLionel Sambuc return EINVAL;
291ebfedea0SLionel Sambuc }
292ebfedea0SLionel Sambuc return 0;
293ebfedea0SLionel Sambuc }
294ebfedea0SLionel Sambuc
295ebfedea0SLionel Sambuc KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_get_init_creds_opt_set_pa_password(krb5_context context,krb5_get_init_creds_opt * opt,const char * password,krb5_s2k_proc key_proc)296ebfedea0SLionel Sambuc krb5_get_init_creds_opt_set_pa_password(krb5_context context,
297ebfedea0SLionel Sambuc krb5_get_init_creds_opt *opt,
298ebfedea0SLionel Sambuc const char *password,
299ebfedea0SLionel Sambuc krb5_s2k_proc key_proc)
300ebfedea0SLionel Sambuc {
301ebfedea0SLionel Sambuc krb5_error_code ret;
302ebfedea0SLionel Sambuc ret = require_ext_opt(context, opt, "init_creds_opt_set_pa_password");
303ebfedea0SLionel Sambuc if (ret)
304ebfedea0SLionel Sambuc return ret;
305ebfedea0SLionel Sambuc opt->opt_private->password = password;
306ebfedea0SLionel Sambuc opt->opt_private->key_proc = key_proc;
307ebfedea0SLionel Sambuc return 0;
308ebfedea0SLionel Sambuc }
309ebfedea0SLionel Sambuc
310ebfedea0SLionel Sambuc KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_get_init_creds_opt_set_pac_request(krb5_context context,krb5_get_init_creds_opt * opt,krb5_boolean req_pac)311ebfedea0SLionel Sambuc krb5_get_init_creds_opt_set_pac_request(krb5_context context,
312ebfedea0SLionel Sambuc krb5_get_init_creds_opt *opt,
313ebfedea0SLionel Sambuc krb5_boolean req_pac)
314ebfedea0SLionel Sambuc {
315ebfedea0SLionel Sambuc krb5_error_code ret;
316ebfedea0SLionel Sambuc ret = require_ext_opt(context, opt, "init_creds_opt_set_pac_req");
317ebfedea0SLionel Sambuc if (ret)
318ebfedea0SLionel Sambuc return ret;
319ebfedea0SLionel Sambuc opt->opt_private->req_pac = req_pac ?
320ebfedea0SLionel Sambuc KRB5_INIT_CREDS_TRISTATE_TRUE :
321ebfedea0SLionel Sambuc KRB5_INIT_CREDS_TRISTATE_FALSE;
322ebfedea0SLionel Sambuc return 0;
323ebfedea0SLionel Sambuc }
324ebfedea0SLionel Sambuc
325ebfedea0SLionel Sambuc KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_get_init_creds_opt_set_addressless(krb5_context context,krb5_get_init_creds_opt * opt,krb5_boolean addressless)326ebfedea0SLionel Sambuc krb5_get_init_creds_opt_set_addressless(krb5_context context,
327ebfedea0SLionel Sambuc krb5_get_init_creds_opt *opt,
328ebfedea0SLionel Sambuc krb5_boolean addressless)
329ebfedea0SLionel Sambuc {
330ebfedea0SLionel Sambuc krb5_error_code ret;
331ebfedea0SLionel Sambuc ret = require_ext_opt(context, opt, "init_creds_opt_set_pac_req");
332ebfedea0SLionel Sambuc if (ret)
333ebfedea0SLionel Sambuc return ret;
334ebfedea0SLionel Sambuc if (addressless)
335ebfedea0SLionel Sambuc opt->opt_private->addressless = KRB5_INIT_CREDS_TRISTATE_TRUE;
336ebfedea0SLionel Sambuc else
337ebfedea0SLionel Sambuc opt->opt_private->addressless = KRB5_INIT_CREDS_TRISTATE_FALSE;
338ebfedea0SLionel Sambuc return 0;
339ebfedea0SLionel Sambuc }
340ebfedea0SLionel Sambuc
341ebfedea0SLionel Sambuc KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_get_init_creds_opt_set_canonicalize(krb5_context context,krb5_get_init_creds_opt * opt,krb5_boolean req)342ebfedea0SLionel Sambuc krb5_get_init_creds_opt_set_canonicalize(krb5_context context,
343ebfedea0SLionel Sambuc krb5_get_init_creds_opt *opt,
344ebfedea0SLionel Sambuc krb5_boolean req)
345ebfedea0SLionel Sambuc {
346ebfedea0SLionel Sambuc krb5_error_code ret;
347ebfedea0SLionel Sambuc ret = require_ext_opt(context, opt, "init_creds_opt_set_canonicalize");
348ebfedea0SLionel Sambuc if (ret)
349ebfedea0SLionel Sambuc return ret;
350ebfedea0SLionel Sambuc if (req)
351ebfedea0SLionel Sambuc opt->opt_private->flags |= KRB5_INIT_CREDS_CANONICALIZE;
352ebfedea0SLionel Sambuc else
353ebfedea0SLionel Sambuc opt->opt_private->flags &= ~KRB5_INIT_CREDS_CANONICALIZE;
354ebfedea0SLionel Sambuc return 0;
355ebfedea0SLionel Sambuc }
356ebfedea0SLionel Sambuc
357ebfedea0SLionel Sambuc KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_get_init_creds_opt_set_win2k(krb5_context context,krb5_get_init_creds_opt * opt,krb5_boolean req)358ebfedea0SLionel Sambuc krb5_get_init_creds_opt_set_win2k(krb5_context context,
359ebfedea0SLionel Sambuc krb5_get_init_creds_opt *opt,
360ebfedea0SLionel Sambuc krb5_boolean req)
361ebfedea0SLionel Sambuc {
362ebfedea0SLionel Sambuc krb5_error_code ret;
363ebfedea0SLionel Sambuc ret = require_ext_opt(context, opt, "init_creds_opt_set_win2k");
364ebfedea0SLionel Sambuc if (ret)
365ebfedea0SLionel Sambuc return ret;
366ebfedea0SLionel Sambuc if (req) {
367ebfedea0SLionel Sambuc opt->opt_private->flags |= KRB5_INIT_CREDS_NO_C_CANON_CHECK;
368ebfedea0SLionel Sambuc opt->opt_private->flags |= KRB5_INIT_CREDS_NO_C_NO_EKU_CHECK;
369ebfedea0SLionel Sambuc } else {
370ebfedea0SLionel Sambuc opt->opt_private->flags &= ~KRB5_INIT_CREDS_NO_C_CANON_CHECK;
371ebfedea0SLionel Sambuc opt->opt_private->flags &= ~KRB5_INIT_CREDS_NO_C_NO_EKU_CHECK;
372ebfedea0SLionel Sambuc }
373ebfedea0SLionel Sambuc return 0;
374ebfedea0SLionel Sambuc }
375ebfedea0SLionel Sambuc
376ebfedea0SLionel Sambuc
377ebfedea0SLionel Sambuc KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_get_init_creds_opt_set_process_last_req(krb5_context context,krb5_get_init_creds_opt * opt,krb5_gic_process_last_req func,void * ctx)378ebfedea0SLionel Sambuc krb5_get_init_creds_opt_set_process_last_req(krb5_context context,
379ebfedea0SLionel Sambuc krb5_get_init_creds_opt *opt,
380ebfedea0SLionel Sambuc krb5_gic_process_last_req func,
381ebfedea0SLionel Sambuc void *ctx)
382ebfedea0SLionel Sambuc {
383ebfedea0SLionel Sambuc krb5_error_code ret;
384ebfedea0SLionel Sambuc ret = require_ext_opt(context, opt, "init_creds_opt_set_win2k");
385ebfedea0SLionel Sambuc if (ret)
386ebfedea0SLionel Sambuc return ret;
387ebfedea0SLionel Sambuc
388ebfedea0SLionel Sambuc opt->opt_private->lr.func = func;
389ebfedea0SLionel Sambuc opt->opt_private->lr.ctx = ctx;
390ebfedea0SLionel Sambuc
391ebfedea0SLionel Sambuc return 0;
392ebfedea0SLionel Sambuc }
393ebfedea0SLionel Sambuc
394ebfedea0SLionel Sambuc
395ebfedea0SLionel Sambuc #ifndef HEIMDAL_SMALLER
396ebfedea0SLionel Sambuc
397ebfedea0SLionel Sambuc /**
398ebfedea0SLionel Sambuc * Deprecated: use krb5_get_init_creds_opt_alloc().
399ebfedea0SLionel Sambuc *
400ebfedea0SLionel Sambuc * The reason krb5_get_init_creds_opt_init() is deprecated is that
401ebfedea0SLionel Sambuc * krb5_get_init_creds_opt is a static structure and for ABI reason it
402ebfedea0SLionel Sambuc * can't grow, ie can't add new functionality.
403ebfedea0SLionel Sambuc *
404ebfedea0SLionel Sambuc * @ingroup krb5_deprecated
405ebfedea0SLionel Sambuc */
406ebfedea0SLionel Sambuc
407ebfedea0SLionel Sambuc KRB5_LIB_FUNCTION void KRB5_LIB_CALL
krb5_get_init_creds_opt_init(krb5_get_init_creds_opt * opt)408ebfedea0SLionel Sambuc krb5_get_init_creds_opt_init(krb5_get_init_creds_opt *opt)
409*0a6a1f1dSLionel Sambuc KRB5_DEPRECATED_FUNCTION("Use X instead")
410ebfedea0SLionel Sambuc {
411ebfedea0SLionel Sambuc memset (opt, 0, sizeof(*opt));
412ebfedea0SLionel Sambuc }
413ebfedea0SLionel Sambuc
414ebfedea0SLionel Sambuc /**
415ebfedea0SLionel Sambuc * Deprecated: use the new krb5_init_creds_init() and
416ebfedea0SLionel Sambuc * krb5_init_creds_get_error().
417ebfedea0SLionel Sambuc *
418ebfedea0SLionel Sambuc * @ingroup krb5_deprecated
419ebfedea0SLionel Sambuc */
420ebfedea0SLionel Sambuc
421ebfedea0SLionel Sambuc KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_get_init_creds_opt_get_error(krb5_context context,krb5_get_init_creds_opt * opt,KRB_ERROR ** error)422ebfedea0SLionel Sambuc krb5_get_init_creds_opt_get_error(krb5_context context,
423ebfedea0SLionel Sambuc krb5_get_init_creds_opt *opt,
424ebfedea0SLionel Sambuc KRB_ERROR **error)
425*0a6a1f1dSLionel Sambuc KRB5_DEPRECATED_FUNCTION("Use X instead")
426ebfedea0SLionel Sambuc {
427ebfedea0SLionel Sambuc *error = calloc(1, sizeof(**error));
428ebfedea0SLionel Sambuc if (*error == NULL) {
429ebfedea0SLionel Sambuc krb5_set_error_message(context, ENOMEM, N_("malloc: out of memory", ""));
430ebfedea0SLionel Sambuc return ENOMEM;
431ebfedea0SLionel Sambuc }
432ebfedea0SLionel Sambuc
433ebfedea0SLionel Sambuc return 0;
434ebfedea0SLionel Sambuc }
435ebfedea0SLionel Sambuc
436ebfedea0SLionel Sambuc #endif /* HEIMDAL_SMALLER */
437