1 /* $NetBSD: kinit.c,v 1.1.1.2 2014/04/24 12:45:28 pettai Exp $ */
4 * Copyright (c) 1997-2007 Kungliga Tekniska Högskolan
5 * (Royal Institute of Technology, Stockholm, Sweden).
8 * Portions Copyright (c) 2009 Apple Inc. All rights reserved.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
21 * 3. Neither the name of the Institute nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 #include "kuser_locl.h"
41 #include <Security/Security.h>
45 #include <krb5/heimntlm.h>
48 int forwardable_flag
= -1;
49 int proxiable_flag
= -1;
50 int renewable_flag
= -1;
53 int validate_flag
= 0;
57 struct getarg_strings extra_addresses
;
58 int anonymous_flag
= 0;
59 char *lifetime
= NULL
;
60 char *renew_life
= NULL
;
61 char *server_str
= NULL
;
62 char *cred_cache
= NULL
;
63 char *start_str
= NULL
;
64 static int switch_cache_flags
= 1;
65 struct getarg_strings etype_str
;
67 char *keytab_str
= NULL
;
70 char *password_file
= NULL
;
71 char *pk_user_id
= NULL
;
72 int pk_enterprise_flag
= 0;
73 struct hx509_certs_data
*ent_user_id
= NULL
;
74 char *pk_x509_anchors
= NULL
;
75 int pk_use_enckey
= 0;
76 static int canonicalize_flag
= 0;
77 static int enterprise_flag
= 0;
78 static int ok_as_delegate_flag
= 0;
79 static int use_referrals_flag
= 0;
80 static int windows_flag
= 0;
82 static char *ntlm_domain
;
86 static struct getargs args
[] = {
100 { "afslog", 0 , arg_flag
, &do_afslog
,
101 NP_("obtain afs tokens", ""), NULL
},
103 { "cache", 'c', arg_string
, &cred_cache
,
104 NP_("credentials cache", ""), "cachename" },
106 { "forwardable", 0, arg_negative_flag
, &forwardable_flag
,
107 NP_("get tickets not forwardable", ""), NULL
},
109 { NULL
, 'f', arg_flag
, &forwardable_flag
,
110 NP_("get forwardable tickets", ""), NULL
},
112 { "keytab", 't', arg_string
, &keytab_str
,
113 NP_("keytab to use", ""), "keytabname" },
115 { "lifetime", 'l', arg_string
, &lifetime
,
116 NP_("lifetime of tickets", ""), "time" },
118 { "proxiable", 'p', arg_flag
, &proxiable_flag
,
119 NP_("get proxiable tickets", ""), NULL
},
121 { "renew", 'R', arg_flag
, &renew_flag
,
122 NP_("renew TGT", ""), NULL
},
124 { "renewable", 0, arg_flag
, &renewable_flag
,
125 NP_("get renewable tickets", ""), NULL
},
127 { "renewable-life", 'r', arg_string
, &renew_life
,
128 NP_("renewable lifetime of tickets", ""), "time" },
130 { "server", 'S', arg_string
, &server_str
,
131 NP_("server to get ticket for", ""), "principal" },
133 { "start-time", 's', arg_string
, &start_str
,
134 NP_("when ticket gets valid", ""), "time" },
136 { "use-keytab", 'k', arg_flag
, &use_keytab
,
137 NP_("get key from keytab", ""), NULL
},
139 { "validate", 'v', arg_flag
, &validate_flag
,
140 NP_("validate TGT", ""), NULL
},
142 { "enctypes", 'e', arg_strings
, &etype_str
,
143 NP_("encryption types to use", ""), "enctypes" },
145 { "fcache-version", 0, arg_integer
, &fcache_version
,
146 NP_("file cache version to create", ""), NULL
},
148 { "addresses", 'A', arg_negative_flag
, &addrs_flag
,
149 NP_("request a ticket with no addresses", ""), NULL
},
151 { "extra-addresses",'a', arg_strings
, &extra_addresses
,
152 NP_("include these extra addresses", ""), "addresses" },
154 { "anonymous", 0, arg_flag
, &anonymous_flag
,
155 NP_("request an anonymous ticket", ""), NULL
},
157 { "request-pac", 0, arg_flag
, &pac_flag
,
158 NP_("request a Windows PAC", ""), NULL
},
160 { "password-file", 0, arg_string
, &password_file
,
161 NP_("read the password from a file", ""), NULL
},
163 { "canonicalize",0, arg_flag
, &canonicalize_flag
,
164 NP_("canonicalize client principal", ""), NULL
},
166 { "enterprise",0, arg_flag
, &enterprise_flag
,
167 NP_("parse principal as a KRB5-NT-ENTERPRISE name", ""), NULL
},
169 { "pk-enterprise", 0, arg_flag
, &pk_enterprise_flag
,
170 NP_("use enterprise name from certificate", ""), NULL
},
172 { "pk-user", 'C', arg_string
, &pk_user_id
,
173 NP_("principal's public/private/certificate identifier", ""), "id" },
175 { "x509-anchors", 'D', arg_string
, &pk_x509_anchors
,
176 NP_("directory with CA certificates", ""), "directory" },
178 { "pk-use-enckey", 0, arg_flag
, &pk_use_enckey
,
179 NP_("Use RSA encrypted reply (instead of DH)", ""), NULL
},
182 { "ntlm-domain", 0, arg_string
, &ntlm_domain
,
183 NP_("NTLM domain", ""), "domain" },
186 { "change-default", 0, arg_negative_flag
, &switch_cache_flags
,
187 NP_("switch the default cache to the new credentials cache", ""), NULL
},
189 { "ok-as-delegate", 0, arg_flag
, &ok_as_delegate_flag
,
190 NP_("honor ok-as-delegate on tickets", ""), NULL
},
192 { "use-referrals", 0, arg_flag
, &use_referrals_flag
,
193 NP_("only use referrals, no dns canalisation", ""), NULL
},
195 { "windows", 0, arg_flag
, &windows_flag
,
196 NP_("get windows behavior", ""), NULL
},
198 { "version", 0, arg_flag
, &version_flag
, NULL
, NULL
},
199 { "help", 0, arg_flag
, &help_flag
, NULL
, NULL
}
205 arg_printusage_i18n (args
,
206 sizeof(args
)/sizeof(*args
),
209 "[principal [command]]",
214 static krb5_error_code
215 get_server(krb5_context context
,
216 krb5_principal client
,
218 krb5_principal
*princ
)
220 krb5_const_realm realm
;
222 return krb5_parse_name(context
, server
, princ
);
224 realm
= krb5_principal_get_realm(context
, client
);
225 return krb5_make_principal(context
, princ
, realm
,
226 KRB5_TGS_NAME
, realm
, NULL
);
230 renew_validate(krb5_context context
,
238 krb5_creds in
, *out
= NULL
;
239 krb5_kdc_flags flags
;
241 memset(&in
, 0, sizeof(in
));
243 ret
= krb5_cc_get_principal(context
, cache
, &in
.client
);
245 krb5_warn(context
, ret
, "krb5_cc_get_principal");
248 ret
= get_server(context
, in
.client
, server
, &in
.server
);
250 krb5_warn(context
, ret
, "get_server");
256 * no need to check the error here, it's only to be
257 * friendly to the user
259 krb5_get_credentials(context
, KRB5_GC_CACHED
, cache
, &in
, &out
);
263 flags
.b
.renewable
= flags
.b
.renew
= renew
;
264 flags
.b
.validate
= validate
;
266 if (forwardable_flag
!= -1)
267 flags
.b
.forwardable
= forwardable_flag
;
269 flags
.b
.forwardable
= out
->flags
.b
.forwardable
;
271 if (proxiable_flag
!= -1)
272 flags
.b
.proxiable
= proxiable_flag
;
274 flags
.b
.proxiable
= out
->flags
.b
.proxiable
;
277 flags
.b
.request_anonymous
= anonymous_flag
;
279 in
.times
.endtime
= time(NULL
) + life
;
282 krb5_free_creds (context
, out
);
287 ret
= krb5_get_kdc_cred(context
,
295 krb5_warn(context
, ret
, "krb5_get_kdc_cred");
298 ret
= krb5_cc_initialize(context
, cache
, in
.client
);
300 krb5_free_creds (context
, out
);
301 krb5_warn(context
, ret
, "krb5_cc_initialize");
304 ret
= krb5_cc_store_cred(context
, cache
, out
);
306 if(ret
== 0 && server
== NULL
) {
307 /* only do this if it's a general renew-my-tgt request */
309 if(do_afslog
&& k_hasafs())
310 krb5_afslog(context
, cache
, NULL
, NULL
);
314 krb5_free_creds (context
, out
);
316 krb5_warn(context
, ret
, "krb5_cc_store_cred");
320 krb5_free_cred_contents(context
, &in
);
326 static krb5_error_code
327 store_ntlmkey(krb5_context context
, krb5_ccache id
,
328 const char *domain
, struct ntlm_buf
*buf
)
334 asprintf(&name
, "ntlm-key-%s", domain
);
336 krb5_clear_error_message(context
);
340 data
.length
= buf
->length
;
341 data
.data
= buf
->data
;
343 ret
= krb5_cc_set_config(context
, id
, NULL
, name
, &data
);
349 static krb5_error_code
350 get_new_tickets(krb5_context context
,
351 krb5_principal principal
,
353 krb5_deltat ticket_life
,
357 krb5_get_init_creds_opt
*opt
;
360 krb5_deltat start_time
= 0;
361 krb5_deltat renew
= 0;
362 const char *renewstr
= NULL
;
363 krb5_enctype
*enctype
= NULL
;
364 krb5_ccache tempccache
;
366 struct ntlm_buf ntlmkey
;
367 memset(&ntlmkey
, 0, sizeof(ntlmkey
));
374 if (strcasecmp("STDIN", password_file
) == 0)
377 f
= fopen(password_file
, "r");
379 krb5_errx(context
, 1, "Failed to open the password file %s",
382 if (fgets(passwd
, sizeof(passwd
), f
) == NULL
)
383 krb5_errx(context
, 1,
384 N_("Failed to read password from file %s", ""),
388 passwd
[strcspn(passwd
, "\n")] = '\0';
392 if (passwd
[0] == '\0') {
399 realm
= krb5_principal_get_realm(context
, principal
);
401 ret
= krb5_unparse_name_flags(context
, principal
,
402 KRB5_PRINCIPAL_UNPARSE_NO_REALM
, &name
);
406 osret
= SecKeychainFindGenericPassword(NULL
, strlen(realm
), realm
,
408 &length
, &buffer
, NULL
);
410 if (osret
== noErr
&& length
< sizeof(passwd
) - 1) {
411 memcpy(passwd
, buffer
, length
);
412 passwd
[length
] = '\0';
419 memset(&cred
, 0, sizeof(cred
));
421 ret
= krb5_get_init_creds_opt_alloc (context
, &opt
);
423 krb5_err(context
, 1, ret
, "krb5_get_init_creds_opt_alloc");
425 krb5_get_init_creds_opt_set_default_flags(context
, "kinit",
426 krb5_principal_get_realm(context
, principal
), opt
);
428 if(forwardable_flag
!= -1)
429 krb5_get_init_creds_opt_set_forwardable (opt
, forwardable_flag
);
430 if(proxiable_flag
!= -1)
431 krb5_get_init_creds_opt_set_proxiable (opt
, proxiable_flag
);
433 krb5_get_init_creds_opt_set_anonymous (opt
, anonymous_flag
);
435 krb5_get_init_creds_opt_set_pac_request(context
, opt
,
436 pac_flag
? TRUE
: FALSE
);
437 if (canonicalize_flag
)
438 krb5_get_init_creds_opt_set_canonicalize(context
, opt
, TRUE
);
439 if (pk_enterprise_flag
|| enterprise_flag
|| canonicalize_flag
|| windows_flag
)
440 krb5_get_init_creds_opt_set_win2k(context
, opt
, TRUE
);
441 if (pk_user_id
|| ent_user_id
|| anonymous_flag
) {
442 ret
= krb5_get_init_creds_opt_set_pkinit(context
, opt
,
448 pk_use_enckey
? 2 : 0 |
449 anonymous_flag
? 4 : 0,
454 krb5_err(context
, 1, ret
, "krb5_get_init_creds_opt_set_pkinit");
456 krb5_get_init_creds_opt_set_pkinit_user_certs(context
, opt
, ent_user_id
);
459 if (addrs_flag
!= -1)
460 krb5_get_init_creds_opt_set_addressless(context
, opt
,
461 addrs_flag
? FALSE
: TRUE
);
463 if (renew_life
== NULL
&& renewable_flag
)
464 renewstr
= "1 month";
466 renewstr
= renew_life
;
468 renew
= parse_time (renewstr
, "s");
470 errx (1, "unparsable time: %s", renewstr
);
472 krb5_get_init_creds_opt_set_renew_life (opt
, renew
);
476 krb5_get_init_creds_opt_set_tkt_life (opt
, ticket_life
);
479 int tmp
= parse_time (start_str
, "s");
481 errx (1, N_("unparsable time: %s", ""), start_str
);
486 if(etype_str
.num_strings
) {
489 enctype
= malloc(etype_str
.num_strings
* sizeof(*enctype
));
491 errx(1, "out of memory");
492 for(i
= 0; i
< etype_str
.num_strings
; i
++) {
493 ret
= krb5_string_to_enctype(context
,
494 etype_str
.strings
[i
],
497 errx(1, "unrecognized enctype: %s", etype_str
.strings
[i
]);
499 krb5_get_init_creds_opt_set_etype_list(opt
, enctype
,
500 etype_str
.num_strings
);
503 if(use_keytab
|| keytab_str
) {
506 ret
= krb5_kt_resolve(context
, keytab_str
, &kt
);
508 ret
= krb5_kt_default(context
, &kt
);
510 krb5_err (context
, 1, ret
, "resolving keytab");
511 ret
= krb5_get_init_creds_keytab (context
,
518 krb5_kt_close(context
, kt
);
519 } else if (pk_user_id
|| ent_user_id
|| anonymous_flag
) {
520 ret
= krb5_get_init_creds_password (context
,
529 } else if (!interactive
) {
530 krb5_warnx(context
, "Not interactive, failed to get initial ticket");
531 krb5_get_init_creds_opt_free(context
, opt
);
535 if (passwd
[0] == '\0') {
538 krb5_unparse_name (context
, principal
, &p
);
539 asprintf (&prompt
, N_("%s's Password: ", ""), p
);
542 if (UI_UTIL_read_pw_string(passwd
, sizeof(passwd
)-1, prompt
, 0)){
543 memset(passwd
, 0, sizeof(passwd
));
550 ret
= krb5_get_init_creds_password (context
,
560 krb5_get_init_creds_opt_free(context
, opt
);
562 if (ntlm_domain
&& passwd
[0])
563 heim_ntlm_nt_key(passwd
, &ntlmkey
);
565 memset(passwd
, 0, sizeof(passwd
));
570 case KRB5_LIBOS_PWDINTR
: /* don't print anything if it was just C-c:ed */
572 case KRB5KRB_AP_ERR_BAD_INTEGRITY
:
573 case KRB5KRB_AP_ERR_MODIFIED
:
574 case KRB5KDC_ERR_PREAUTH_FAILED
:
575 krb5_errx(context
, 1, N_("Password incorrect", ""));
577 case KRB5KRB_AP_ERR_V4_REPLY
:
578 krb5_errx(context
, 1, N_("Looks like a Kerberos 4 reply", ""));
581 krb5_err(context
, 1, ret
, "krb5_get_init_creds");
584 if(ticket_life
!= 0) {
585 if(abs(cred
.times
.endtime
- cred
.times
.starttime
- ticket_life
) > 30) {
587 unparse_time_approx(cred
.times
.endtime
- cred
.times
.starttime
,
589 krb5_warnx(context
, N_("NOTICE: ticket lifetime is %s", ""), life
);
593 if(abs(cred
.times
.renew_till
- cred
.times
.starttime
- renew
) > 30) {
595 unparse_time_approx(cred
.times
.renew_till
- cred
.times
.starttime
,
598 N_("NOTICE: ticket renewable lifetime is %s", ""),
603 ret
= krb5_cc_new_unique(context
, krb5_cc_get_type(context
, ccache
),
606 krb5_err (context
, 1, ret
, "krb5_cc_new_unique");
608 ret
= krb5_cc_initialize (context
, tempccache
, cred
.client
);
610 krb5_err (context
, 1, ret
, "krb5_cc_initialize");
612 ret
= krb5_cc_store_cred (context
, tempccache
, &cred
);
614 krb5_err (context
, 1, ret
, "krb5_cc_store_cred");
616 krb5_free_cred_contents (context
, &cred
);
618 ret
= krb5_cc_move(context
, tempccache
, ccache
);
620 krb5_err (context
, 1, ret
, "krb5_cc_move");
622 if (switch_cache_flags
)
623 krb5_cc_switch(context
, ccache
);
626 if (ntlm_domain
&& ntlmkey
.data
)
627 store_ntlmkey(context
, ccache
, ntlm_domain
, &ntlmkey
);
630 if (ok_as_delegate_flag
|| windows_flag
|| use_referrals_flag
) {
634 if (ok_as_delegate_flag
|| windows_flag
)
636 if (use_referrals_flag
|| windows_flag
)
642 krb5_cc_set_config(context
, ccache
, NULL
, "realm-config", &data
);
653 ticket_lifetime(krb5_context context
, krb5_ccache cache
,
654 krb5_principal client
, const char *server
)
656 krb5_creds in_cred
, *cred
;
660 memset(&in_cred
, 0, sizeof(in_cred
));
662 ret
= krb5_cc_get_principal(context
, cache
, &in_cred
.client
);
664 krb5_warn(context
, ret
, "krb5_cc_get_principal");
667 ret
= get_server(context
, in_cred
.client
, server
, &in_cred
.server
);
669 krb5_free_principal(context
, in_cred
.client
);
670 krb5_warn(context
, ret
, "get_server");
674 ret
= krb5_get_credentials(context
, KRB5_GC_CACHED
,
675 cache
, &in_cred
, &cred
);
676 krb5_free_principal(context
, in_cred
.client
);
677 krb5_free_principal(context
, in_cred
.server
);
679 krb5_warn(context
, ret
, "krb5_get_credentials");
682 timeout
= cred
->times
.endtime
- cred
->times
.starttime
;
685 krb5_free_creds(context
, cred
);
690 krb5_context context
;
692 krb5_principal principal
;
693 krb5_deltat ticket_life
;
697 renew_func(void *ptr
)
699 struct renew_ctx
*ctx
= ptr
;
704 if (renewable_flag
) {
705 ret
= renew_validate(ctx
->context
, renewable_flag
, validate_flag
,
706 ctx
->ccache
, server_str
, ctx
->ticket_life
);
713 get_new_tickets(ctx
->context
, ctx
->principal
,
714 ctx
->ccache
, ctx
->ticket_life
, 0);
717 if(do_afslog
&& k_hasafs())
718 krb5_afslog(ctx
->context
, ctx
->ccache
, NULL
, NULL
);
721 expire
= ticket_lifetime(ctx
->context
, ctx
->ccache
, ctx
->principal
,
727 main (int argc
, char **argv
)
730 krb5_context context
;
732 krb5_principal principal
;
734 krb5_deltat ticket_life
= 0;
737 setprogname (argv
[0]);
739 setlocale (LC_ALL
, "");
740 bindtextdomain ("heimdal_kuser", HEIMDAL_LOCALEDIR
);
741 textdomain("heimdal_kuser");
743 ret
= krb5_init_context (&context
);
744 if (ret
== KRB5_CONFIG_BADFORMAT
)
745 errx (1, "krb5_init_context failed to parse configuration file");
747 errx(1, "krb5_init_context failed: %d", ret
);
749 if(getarg(args
, sizeof(args
) / sizeof(args
[0]), argc
, argv
, &optidx
))
763 if (canonicalize_flag
|| enterprise_flag
)
764 parseflags
|= KRB5_PRINCIPAL_PARSE_ENTERPRISE
;
766 if (pk_enterprise_flag
) {
767 ret
= krb5_pk_enterprise_cert(context
, pk_user_id
,
771 krb5_err(context
, 1, ret
, "krb5_pk_enterprise_certs");
775 } else if (anonymous_flag
) {
777 ret
= krb5_make_principal(context
, &principal
, argv
[0],
778 KRB5_WELLKNOWN_NAME
, KRB5_ANON_NAME
,
781 krb5_err(context
, 1, ret
, "krb5_make_principal");
782 krb5_principal_set_type(context
, principal
, KRB5_NT_WELLKNOWN
);
786 ret
= krb5_parse_name_flags (context
, argv
[0], parseflags
,
789 krb5_err (context
, 1, ret
, "krb5_parse_name");
791 ret
= krb5_get_default_principal (context
, &principal
);
793 krb5_err (context
, 1, ret
, "krb5_get_default_principal");
798 krb5_set_fcache_version(context
, fcache_version
);
800 if(renewable_flag
== -1)
801 /* this seems somewhat pointless, but whatever */
802 krb5_appdefault_boolean(context
, "kinit",
803 krb5_principal_get_realm(context
, principal
),
804 "renewable", FALSE
, &renewable_flag
);
806 krb5_appdefault_boolean(context
, "kinit",
807 krb5_principal_get_realm(context
, principal
),
808 "afslog", TRUE
, &do_afslog
);
811 ret
= krb5_cc_resolve(context
, cred_cache
, &ccache
);
815 ret
= krb5_cc_new_unique(context
, NULL
, NULL
, &ccache
);
817 krb5_err(context
, 1, ret
, "creating cred cache");
818 snprintf(s
, sizeof(s
), "%s:%s",
819 krb5_cc_get_type(context
, ccache
),
820 krb5_cc_get_name(context
, ccache
));
821 setenv("KRB5CCNAME", s
, 1);
823 ret
= krb5_cc_cache_match(context
, principal
, &ccache
);
826 ret
= krb5_cc_default (context
, &ccache
);
828 krb5_err (context
, 1, ret
, N_("resolving credentials cache", ""));
831 * Check if the type support switching, and we do,
832 * then do that instead over overwriting the current
835 type
= krb5_cc_get_type(context
, ccache
);
836 if (krb5_cc_support_switch(context
, type
)) {
837 krb5_cc_close(context
, ccache
);
838 ret
= krb5_cc_new_unique(context
, type
, NULL
, &ccache
);
844 krb5_err (context
, 1, ret
, N_("resolving credentials cache", ""));
847 if(argc
> 1 && k_hasafs ())
852 int tmp
= parse_time (lifetime
, "s");
854 errx (1, N_("unparsable time: %s", ""), lifetime
);
859 if(addrs_flag
== 0 && extra_addresses
.num_strings
> 0)
860 krb5_errx(context
, 1,
861 N_("specifying both extra addresses and "
862 "no addresses makes no sense", ""));
865 krb5_addresses addresses
;
866 memset(&addresses
, 0, sizeof(addresses
));
867 for(i
= 0; i
< extra_addresses
.num_strings
; i
++) {
868 ret
= krb5_parse_address(context
, extra_addresses
.strings
[i
],
871 krb5_add_extra_addresses(context
, &addresses
);
872 krb5_free_addresses(context
, &addresses
);
875 free_getarg_strings(&extra_addresses
);
878 if(renew_flag
|| validate_flag
) {
879 ret
= renew_validate(context
, renew_flag
, validate_flag
,
880 ccache
, server_str
, ticket_life
);
884 get_new_tickets(context
, principal
, ccache
, ticket_life
, 1);
887 if(do_afslog
&& k_hasafs())
888 krb5_afslog(context
, ccache
, NULL
, NULL
);
891 struct renew_ctx ctx
;
894 timeout
= ticket_lifetime(context
, ccache
, principal
, server_str
) / 2;
896 ctx
.context
= context
;
898 ctx
.principal
= principal
;
899 ctx
.ticket_life
= ticket_life
;
901 ret
= simple_execvp_timed(argv
[1], argv
+1,
902 renew_func
, &ctx
, timeout
);
903 #define EX_NOEXEC 126
904 #define EX_NOTFOUND 127
906 krb5_warnx(context
, N_("permission denied: %s", ""), argv
[1]);
907 else if(ret
== EX_NOTFOUND
)
908 krb5_warnx(context
, N_("command not found: %s", ""), argv
[1]);
910 krb5_cc_destroy(context
, ccache
);
916 krb5_cc_close (context
, ccache
);
919 krb5_free_principal(context
, principal
);
920 krb5_free_context (context
);