2 * Copyright (c) 1997-2007 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Portions Copyright (c) 2009 Apple Inc. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * 3. Neither the name of the Institute nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #include "kuser_locl.h"
39 #include <Security/Security.h>
42 struct krb5_dh_moduli
;
43 struct AlgorithmIdentifier
;
44 struct _krb5_krb_auth_data
;
45 struct hx509_certs_data
;
46 #include <krb5-private.h>
52 int forwardable_flag
= -1;
53 int proxiable_flag
= -1;
54 int renewable_flag
= -1;
57 int validate_flag
= 0;
61 struct getarg_strings extra_addresses
;
62 int anonymous_flag
= 0;
63 char *lifetime
= NULL
;
64 char *renew_life
= NULL
;
65 char *server_str
= NULL
;
66 char *cred_cache
= NULL
;
67 char *start_str
= NULL
;
68 static int switch_cache_flags
= 1;
69 struct getarg_strings etype_str
;
71 char *keytab_str
= NULL
;
74 char *password_file
= NULL
;
75 char *pk_user_id
= NULL
;
76 int pk_enterprise_flag
= 0;
77 struct hx509_certs_data
*ent_user_id
= NULL
;
78 char *pk_x509_anchors
= NULL
;
79 int pk_use_enckey
= 0;
80 static int canonicalize_flag
= 0;
81 static int enterprise_flag
= 0;
82 static int ok_as_delegate_flag
= 0;
83 static int use_referrals_flag
= 0;
84 static int windows_flag
= 0;
86 static char *ntlm_domain
;
90 static struct getargs args
[] = {
104 { "afslog", 0 , arg_flag
, &do_afslog
,
105 NP_("obtain afs tokens", "") },
107 { "cache", 'c', arg_string
, &cred_cache
,
108 NP_("credentials cache", ""), "cachename" },
110 { "forwardable", 'f', arg_negative_flag
, &forwardable_flag
,
111 NP_("get forwardable tickets", "")},
113 { "keytab", 't', arg_string
, &keytab_str
,
114 NP_("keytab to use", ""), "keytabname" },
116 { "lifetime", 'l', arg_string
, &lifetime
,
117 NP_("lifetime of tickets", ""), "time"},
119 { "proxiable", 'p', arg_flag
, &proxiable_flag
,
120 NP_("get proxiable tickets", "") },
122 { "renew", 'R', arg_flag
, &renew_flag
,
123 NP_("renew TGT", "") },
125 { "renewable", 0, arg_flag
, &renewable_flag
,
126 NP_("get renewable tickets", "") },
128 { "renewable-life", 'r', arg_string
, &renew_life
,
129 NP_("renewable lifetime of tickets", ""), "time" },
131 { "server", 'S', arg_string
, &server_str
,
132 NP_("server to get ticket for", ""), "principal" },
134 { "start-time", 's', arg_string
, &start_str
,
135 NP_("when ticket gets valid", ""), "time" },
137 { "use-keytab", 'k', arg_flag
, &use_keytab
,
138 NP_("get key from keytab", "") },
140 { "validate", 'v', arg_flag
, &validate_flag
,
141 NP_("validate TGT", "") },
143 { "enctypes", 'e', arg_strings
, &etype_str
,
144 NP_("encryption types to use", ""), "enctypes" },
146 { "fcache-version", 0, arg_integer
, &fcache_version
,
147 NP_("file cache version to create", "") },
149 { "addresses", 'A', arg_negative_flag
, &addrs_flag
,
150 NP_("request a ticket with no addresses", "") },
152 { "extra-addresses",'a', arg_strings
, &extra_addresses
,
153 NP_("include these extra addresses", ""), "addresses" },
155 { "anonymous", 0, arg_flag
, &anonymous_flag
,
156 NP_("request an anonymous ticket", "") },
158 { "request-pac", 0, arg_flag
, &pac_flag
,
159 NP_("request a Windows PAC", "") },
161 { "password-file", 0, arg_string
, &password_file
,
162 NP_("read the password from a file", "") },
164 { "canonicalize",0, arg_flag
, &canonicalize_flag
,
165 NP_("canonicalize client principal", "") },
167 { "enterprise",0, arg_flag
, &enterprise_flag
,
168 NP_("parse principal as a KRB5-NT-ENTERPRISE name", "") },
170 { "pk-enterprise", 0, arg_flag
, &pk_enterprise_flag
,
171 NP_("use enterprise name from certificate", "") },
173 { "pk-user", 'C', arg_string
, &pk_user_id
,
174 NP_("principal's public/private/certificate identifier", ""), "id" },
176 { "x509-anchors", 'D', arg_string
, &pk_x509_anchors
,
177 NP_("directory with CA certificates", ""), "directory" },
179 { "pk-use-enckey", 0, arg_flag
, &pk_use_enckey
,
180 NP_("Use RSA encrypted reply (instead of DH)", "") },
183 { "ntlm-domain", 0, arg_string
, &ntlm_domain
,
184 NP_("NTLM domain", ""), "domain" },
187 { "change-default", 0, arg_negative_flag
, &switch_cache_flags
,
188 NP_("switch the default cache to the new credentials cache", "") },
190 { "ok-as-delegate", 0, arg_flag
, &ok_as_delegate_flag
,
191 NP_("honor ok-as-delegate on tickets", "") },
193 { "use-referrals", 0, arg_flag
, &use_referrals_flag
,
194 NP_("only use referrals, no dns canalisation", "") },
196 { "windows", 0, arg_flag
, &windows_flag
,
197 NP_("get windows behavior", "") },
199 { "version", 0, arg_flag
, &version_flag
},
200 { "help", 0, arg_flag
, &help_flag
}
206 arg_printusage_i18n (args
,
207 sizeof(args
)/sizeof(*args
),
210 "[principal [command]]",
215 static krb5_error_code
216 get_server(krb5_context context
,
217 krb5_principal client
,
219 krb5_principal
*princ
)
221 krb5_const_realm realm
;
223 return krb5_parse_name(context
, server
, princ
);
225 realm
= krb5_principal_get_realm(context
, client
);
226 return krb5_make_principal(context
, princ
, realm
,
227 KRB5_TGS_NAME
, realm
, NULL
);
231 renew_validate(krb5_context context
,
239 krb5_creds in
, *out
= NULL
;
240 krb5_kdc_flags flags
;
242 memset(&in
, 0, sizeof(in
));
244 ret
= krb5_cc_get_principal(context
, cache
, &in
.client
);
246 krb5_warn(context
, ret
, "krb5_cc_get_principal");
249 ret
= get_server(context
, in
.client
, server
, &in
.server
);
251 krb5_warn(context
, ret
, "get_server");
257 * no need to check the error here, it's only to be
258 * friendly to the user
260 krb5_get_credentials(context
, KRB5_GC_CACHED
, cache
, &in
, &out
);
264 flags
.b
.renewable
= flags
.b
.renew
= renew
;
265 flags
.b
.validate
= validate
;
267 if (forwardable_flag
!= -1)
268 flags
.b
.forwardable
= forwardable_flag
;
270 flags
.b
.forwardable
= out
->flags
.b
.forwardable
;
272 if (proxiable_flag
!= -1)
273 flags
.b
.proxiable
= proxiable_flag
;
275 flags
.b
.proxiable
= out
->flags
.b
.proxiable
;
278 flags
.b
.request_anonymous
= anonymous_flag
;
280 in
.times
.endtime
= time(NULL
) + life
;
283 krb5_free_creds (context
, out
);
288 ret
= krb5_get_kdc_cred(context
,
296 krb5_warn(context
, ret
, "krb5_get_kdc_cred");
299 ret
= krb5_cc_initialize(context
, cache
, in
.client
);
301 krb5_free_creds (context
, out
);
302 krb5_warn(context
, ret
, "krb5_cc_initialize");
305 ret
= krb5_cc_store_cred(context
, cache
, out
);
307 if(ret
== 0 && server
== NULL
) {
308 /* only do this if it's a general renew-my-tgt request */
310 if(do_afslog
&& k_hasafs())
311 krb5_afslog(context
, cache
, NULL
, NULL
);
315 krb5_free_creds (context
, out
);
317 krb5_warn(context
, ret
, "krb5_cc_store_cred");
321 krb5_free_cred_contents(context
, &in
);
327 static krb5_error_code
328 store_ntlmkey(krb5_context context
, krb5_ccache id
,
329 const char *domain
, struct ntlm_buf
*buf
)
335 asprintf(&name
, "ntlm-key-%s", domain
);
337 krb5_clear_error_message(context
);
341 data
.length
= buf
->length
;
342 data
.data
= buf
->data
;
344 ret
= krb5_cc_set_config(context
, id
, NULL
, name
, &data
);
350 static krb5_error_code
351 get_new_tickets(krb5_context context
,
352 krb5_principal principal
,
354 krb5_deltat ticket_life
,
358 krb5_get_init_creds_opt
*opt
;
361 krb5_deltat start_time
= 0;
362 krb5_deltat renew
= 0;
363 char *renewstr
= NULL
;
364 krb5_enctype
*enctype
= NULL
;
365 krb5_ccache tempccache
;
367 struct ntlm_buf ntlmkey
;
368 memset(&ntlmkey
, 0, sizeof(ntlmkey
));
375 if (strcasecmp("STDIN", password_file
) == 0)
378 f
= fopen(password_file
, "r");
380 krb5_errx(context
, 1, "Failed to open the password file %s",
383 if (fgets(passwd
, sizeof(passwd
), f
) == NULL
)
384 krb5_errx(context
, 1,
385 N_("Failed to read password from file %s", ""),
389 passwd
[strcspn(passwd
, "\n")] = '\0';
393 if (passwd
[0] == '\0') {
400 realm
= krb5_principal_get_realm(context
, principal
);
402 ret
= krb5_unparse_name_flags(context
, principal
,
403 KRB5_PRINCIPAL_UNPARSE_NO_REALM
, &name
);
407 osret
= SecKeychainFindGenericPassword(NULL
, strlen(realm
), realm
,
409 &length
, &buffer
, NULL
);
411 if (osret
== noErr
&& length
< sizeof(passwd
) - 1) {
412 memcpy(passwd
, buffer
, length
);
413 passwd
[length
] = '\0';
420 memset(&cred
, 0, sizeof(cred
));
422 ret
= krb5_get_init_creds_opt_alloc (context
, &opt
);
424 krb5_err(context
, 1, ret
, "krb5_get_init_creds_opt_alloc");
426 krb5_get_init_creds_opt_set_default_flags(context
, "kinit",
427 krb5_principal_get_realm(context
, principal
), opt
);
429 if(forwardable_flag
!= -1)
430 krb5_get_init_creds_opt_set_forwardable (opt
, forwardable_flag
);
431 if(proxiable_flag
!= -1)
432 krb5_get_init_creds_opt_set_proxiable (opt
, proxiable_flag
);
434 krb5_get_init_creds_opt_set_anonymous (opt
, anonymous_flag
);
436 krb5_get_init_creds_opt_set_pac_request(context
, opt
,
437 pac_flag
? TRUE
: FALSE
);
438 if (canonicalize_flag
)
439 krb5_get_init_creds_opt_set_canonicalize(context
, opt
, TRUE
);
440 if ((pk_enterprise_flag
|| enterprise_flag
|| canonicalize_flag
) && windows_flag
)
441 krb5_get_init_creds_opt_set_win2k(context
, opt
, TRUE
);
442 if (pk_user_id
|| ent_user_id
|| anonymous_flag
) {
443 ret
= krb5_get_init_creds_opt_set_pkinit(context
, opt
,
449 pk_use_enckey
? 2 : 0 |
450 anonymous_flag
? 4 : 0,
455 krb5_err(context
, 1, ret
, "krb5_get_init_creds_opt_set_pkinit");
457 _krb5_get_init_creds_opt_set_pkinit_user_certs(context
, opt
, ent_user_id
);
460 if (addrs_flag
!= -1)
461 krb5_get_init_creds_opt_set_addressless(context
, opt
,
462 addrs_flag
? FALSE
: TRUE
);
464 if (renew_life
== NULL
&& renewable_flag
)
465 renewstr
= "1 month";
467 renewstr
= renew_life
;
469 renew
= parse_time (renewstr
, "s");
471 errx (1, "unparsable time: %s", renewstr
);
473 krb5_get_init_creds_opt_set_renew_life (opt
, renew
);
477 krb5_get_init_creds_opt_set_tkt_life (opt
, ticket_life
);
480 int tmp
= parse_time (start_str
, "s");
482 errx (1, N_("unparsable time: %s", ""), start_str
);
487 if(etype_str
.num_strings
) {
490 enctype
= malloc(etype_str
.num_strings
* sizeof(*enctype
));
492 errx(1, "out of memory");
493 for(i
= 0; i
< etype_str
.num_strings
; i
++) {
494 ret
= krb5_string_to_enctype(context
,
495 etype_str
.strings
[i
],
498 errx(1, "unrecognized enctype: %s", etype_str
.strings
[i
]);
500 krb5_get_init_creds_opt_set_etype_list(opt
, enctype
,
501 etype_str
.num_strings
);
504 if(use_keytab
|| keytab_str
) {
507 ret
= krb5_kt_resolve(context
, keytab_str
, &kt
);
509 ret
= krb5_kt_default(context
, &kt
);
511 krb5_err (context
, 1, ret
, "resolving keytab");
512 ret
= krb5_get_init_creds_keytab (context
,
519 krb5_kt_close(context
, kt
);
520 } else if (pk_user_id
|| ent_user_id
|| anonymous_flag
) {
521 ret
= krb5_get_init_creds_password (context
,
530 } else if (!interactive
) {
531 krb5_warnx(context
, "Not interactive, failed to get initial ticket");
532 krb5_get_init_creds_opt_free(context
, opt
);
536 if (passwd
[0] == '\0') {
539 krb5_unparse_name (context
, principal
, &p
);
540 asprintf (&prompt
, N_("%s's Password: ", ""), p
);
543 if (UI_UTIL_read_pw_string(passwd
, sizeof(passwd
)-1, prompt
, 0)){
544 memset(passwd
, 0, sizeof(passwd
));
551 ret
= krb5_get_init_creds_password (context
,
561 krb5_get_init_creds_opt_free(context
, opt
);
563 if (ntlm_domain
&& passwd
[0])
564 heim_ntlm_nt_key(passwd
, &ntlmkey
);
566 memset(passwd
, 0, sizeof(passwd
));
571 case KRB5_LIBOS_PWDINTR
: /* don't print anything if it was just C-c:ed */
573 case KRB5KRB_AP_ERR_BAD_INTEGRITY
:
574 case KRB5KRB_AP_ERR_MODIFIED
:
575 case KRB5KDC_ERR_PREAUTH_FAILED
:
576 krb5_errx(context
, 1, N_("Password incorrect", ""));
578 case KRB5KRB_AP_ERR_V4_REPLY
:
579 krb5_errx(context
, 1, N_("Looks like a Kerberos 4 reply", ""));
582 krb5_err(context
, 1, ret
, "krb5_get_init_creds");
585 if(ticket_life
!= 0) {
586 if(abs(cred
.times
.endtime
- cred
.times
.starttime
- ticket_life
) > 30) {
588 unparse_time_approx(cred
.times
.endtime
- cred
.times
.starttime
,
590 krb5_warnx(context
, N_("NOTICE: ticket lifetime is %s", ""), life
);
594 if(abs(cred
.times
.renew_till
- cred
.times
.starttime
- renew
) > 30) {
596 unparse_time_approx(cred
.times
.renew_till
- cred
.times
.starttime
,
599 N_("NOTICE: ticket renewable lifetime is %s", ""),
604 ret
= krb5_cc_new_unique(context
, krb5_cc_get_type(context
, ccache
),
607 krb5_err (context
, 1, ret
, "krb5_cc_new_unique");
609 ret
= krb5_cc_initialize (context
, tempccache
, cred
.client
);
611 krb5_err (context
, 1, ret
, "krb5_cc_initialize");
613 ret
= krb5_cc_store_cred (context
, tempccache
, &cred
);
615 krb5_err (context
, 1, ret
, "krb5_cc_store_cred");
617 krb5_free_cred_contents (context
, &cred
);
619 ret
= krb5_cc_move(context
, tempccache
, ccache
);
621 krb5_err (context
, 1, ret
, "krb5_cc_move");
623 if (switch_cache_flags
)
624 krb5_cc_switch(context
, ccache
);
627 if (ntlm_domain
&& ntlmkey
.data
)
628 store_ntlmkey(context
, ccache
, ntlm_domain
, &ntlmkey
);
631 if (ok_as_delegate_flag
|| windows_flag
|| use_referrals_flag
) {
635 if (ok_as_delegate_flag
|| windows_flag
)
637 if (use_referrals_flag
|| windows_flag
)
643 krb5_cc_set_config(context
, ccache
, NULL
, "realm-config", &data
);
654 ticket_lifetime(krb5_context context
, krb5_ccache cache
,
655 krb5_principal client
, const char *server
)
657 krb5_creds in_cred
, *cred
;
661 memset(&in_cred
, 0, sizeof(in_cred
));
663 ret
= krb5_cc_get_principal(context
, cache
, &in_cred
.client
);
665 krb5_warn(context
, ret
, "krb5_cc_get_principal");
668 ret
= get_server(context
, in_cred
.client
, server
, &in_cred
.server
);
670 krb5_free_principal(context
, in_cred
.client
);
671 krb5_warn(context
, ret
, "get_server");
675 ret
= krb5_get_credentials(context
, KRB5_GC_CACHED
,
676 cache
, &in_cred
, &cred
);
677 krb5_free_principal(context
, in_cred
.client
);
678 krb5_free_principal(context
, in_cred
.server
);
680 krb5_warn(context
, ret
, "krb5_get_credentials");
683 timeout
= cred
->times
.endtime
- cred
->times
.starttime
;
686 krb5_free_creds(context
, cred
);
691 krb5_context context
;
693 krb5_principal principal
;
694 krb5_deltat ticket_life
;
698 renew_func(void *ptr
)
700 struct renew_ctx
*ctx
= ptr
;
705 if (renewable_flag
) {
706 ret
= renew_validate(ctx
->context
, renewable_flag
, validate_flag
,
707 ctx
->ccache
, server_str
, ctx
->ticket_life
);
714 get_new_tickets(ctx
->context
, ctx
->principal
,
715 ctx
->ccache
, ctx
->ticket_life
, 0);
718 if(do_afslog
&& k_hasafs())
719 krb5_afslog(ctx
->context
, ctx
->ccache
, NULL
, NULL
);
722 expire
= ticket_lifetime(ctx
->context
, ctx
->ccache
, ctx
->principal
,
728 main (int argc
, char **argv
)
731 krb5_context context
;
733 krb5_principal principal
;
735 krb5_deltat ticket_life
= 0;
738 setprogname (argv
[0]);
740 setlocale (LC_ALL
, "");
741 bindtextdomain ("heimdal_kuser", HEIMDAL_LOCALEDIR
);
742 textdomain("heimdal_kuser");
744 ret
= krb5_init_context (&context
);
745 if (ret
== KRB5_CONFIG_BADFORMAT
)
746 errx (1, "krb5_init_context failed to parse configuration file");
748 errx(1, "krb5_init_context failed: %d", ret
);
750 if(getarg(args
, sizeof(args
) / sizeof(args
[0]), argc
, argv
, &optidx
))
764 if (canonicalize_flag
|| enterprise_flag
)
765 parseflags
|= KRB5_PRINCIPAL_PARSE_ENTERPRISE
;
767 if (pk_enterprise_flag
) {
768 ret
= _krb5_pk_enterprise_cert(context
, pk_user_id
,
772 krb5_err(context
, 1, ret
, "krb5_pk_enterprise_certs");
776 } else if (anonymous_flag
) {
778 ret
= krb5_make_principal(context
, &principal
, argv
[0],
779 KRB5_WELLKNOWN_NAME
, KRB5_ANON_NAME
,
782 krb5_err(context
, 1, ret
, "krb5_make_principal");
783 krb5_principal_set_type(context
, principal
, KRB5_NT_WELLKNOWN
);
787 ret
= krb5_parse_name_flags (context
, argv
[0], parseflags
,
790 krb5_err (context
, 1, ret
, "krb5_parse_name");
792 ret
= krb5_get_default_principal (context
, &principal
);
794 krb5_err (context
, 1, ret
, "krb5_get_default_principal");
799 krb5_set_fcache_version(context
, fcache_version
);
801 if(renewable_flag
== -1)
802 /* this seems somewhat pointless, but whatever */
803 krb5_appdefault_boolean(context
, "kinit",
804 krb5_principal_get_realm(context
, principal
),
805 "renewable", FALSE
, &renewable_flag
);
807 krb5_appdefault_boolean(context
, "kinit",
808 krb5_principal_get_realm(context
, principal
),
809 "afslog", TRUE
, &do_afslog
);
812 ret
= krb5_cc_resolve(context
, cred_cache
, &ccache
);
816 ret
= krb5_cc_new_unique(context
, NULL
, NULL
, &ccache
);
818 krb5_err(context
, 1, ret
, "creating cred cache");
819 snprintf(s
, sizeof(s
), "%s:%s",
820 krb5_cc_get_type(context
, ccache
),
821 krb5_cc_get_name(context
, ccache
));
822 setenv("KRB5CCNAME", s
, 1);
824 ret
= krb5_cc_cache_match(context
, principal
, &ccache
);
827 ret
= krb5_cc_default (context
, &ccache
);
829 krb5_err (context
, 1, ret
, N_("resolving credentials cache", ""));
832 * Check if the type support switching, and we do,
833 * then do that instead over overwriting the current
836 type
= krb5_cc_get_type(context
, ccache
);
837 if (krb5_cc_support_switch(context
, type
)) {
838 krb5_cc_close(context
, ccache
);
839 ret
= krb5_cc_new_unique(context
, type
, NULL
, &ccache
);
845 krb5_err (context
, 1, ret
, N_("resolving credentials cache", ""));
848 if(argc
> 1 && k_hasafs ())
853 int tmp
= parse_time (lifetime
, "s");
855 errx (1, N_("unparsable time: %s", ""), lifetime
);
860 if(addrs_flag
== 0 && extra_addresses
.num_strings
> 0)
861 krb5_errx(context
, 1,
862 N_("specifying both extra addresses and "
863 "no addresses makes no sense", ""));
866 krb5_addresses addresses
;
867 memset(&addresses
, 0, sizeof(addresses
));
868 for(i
= 0; i
< extra_addresses
.num_strings
; i
++) {
869 ret
= krb5_parse_address(context
, extra_addresses
.strings
[i
],
872 krb5_add_extra_addresses(context
, &addresses
);
873 krb5_free_addresses(context
, &addresses
);
876 free_getarg_strings(&extra_addresses
);
879 if(renew_flag
|| validate_flag
) {
880 ret
= renew_validate(context
, renew_flag
, validate_flag
,
881 ccache
, server_str
, ticket_life
);
885 get_new_tickets(context
, principal
, ccache
, ticket_life
, 1);
888 if(do_afslog
&& k_hasafs())
889 krb5_afslog(context
, ccache
, NULL
, NULL
);
892 struct renew_ctx ctx
;
895 timeout
= ticket_lifetime(context
, ccache
, principal
, server_str
) / 2;
897 ctx
.context
= context
;
899 ctx
.principal
= principal
;
900 ctx
.ticket_life
= ticket_life
;
902 ret
= simple_execvp_timed(argv
[1], argv
+1,
903 renew_func
, &ctx
, timeout
);
904 #define EX_NOEXEC 126
905 #define EX_NOTFOUND 127
907 krb5_warnx(context
, N_("permission denied: %s", ""), argv
[1]);
908 else if(ret
== EX_NOTFOUND
)
909 krb5_warnx(context
, N_("command not found: %s", ""), argv
[1]);
911 krb5_cc_destroy(context
, ccache
);
917 krb5_cc_close (context
, ccache
);
920 krb5_free_principal(context
, principal
);
921 krb5_free_context (context
);