2 * Copyright (c) 1997 - 2008 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 "krb5_locl.h"
38 typedef struct krb5_fcache
{
48 #define KRB5_FCC_FVNO_1 1
49 #define KRB5_FCC_FVNO_2 2
50 #define KRB5_FCC_FVNO_3 3
51 #define KRB5_FCC_FVNO_4 4
53 #define FCC_TAG_DELTATIME 1
55 #define FCACHE(X) ((krb5_fcache*)(X)->data.data)
57 #define FILENAME(X) (FCACHE(X)->filename)
59 #define FCC_CURSOR(C) ((struct fcc_cursor*)(C))
61 static const char* KRB5_CALLCONV
62 fcc_get_name(krb5_context context
,
65 if (FCACHE(id
) == NULL
)
72 _krb5_xlock(krb5_context context
, int fd
, krb5_boolean exclusive
,
81 l
.l_type
= exclusive
? F_WRLCK
: F_RDLCK
;
82 l
.l_whence
= SEEK_SET
;
83 ret
= fcntl(fd
, F_SETLKW
, &l
);
85 ret
= flock(fd
, exclusive
? LOCK_EX
: LOCK_SH
);
89 if(ret
== EACCES
) /* fcntl can return EACCES instead of EAGAIN */
95 case EINVAL
: /* filesystem doesn't support locking, let the user have it */
99 krb5_set_error_message(context
, ret
,
100 N_("timed out locking cache file %s", "file"),
105 rk_strerror_r(ret
, buf
, sizeof(buf
));
106 krb5_set_error_message(context
, ret
,
107 N_("error locking cache file %s: %s",
108 "file, error"), filename
, buf
);
116 _krb5_xunlock(krb5_context context
, int fd
)
124 l
.l_whence
= SEEK_SET
;
125 ret
= fcntl(fd
, F_SETLKW
, &l
);
127 ret
= flock(fd
, LOCK_UN
);
134 case EINVAL
: /* filesystem doesn't support locking, let the user have it */
139 rk_strerror_r(ret
, buf
, sizeof(buf
));
140 krb5_set_error_message(context
, ret
,
141 N_("Failed to unlock file: %s", ""), buf
);
148 static krb5_error_code
149 write_storage(krb5_context context
, krb5_storage
*sp
, int fd
)
155 ret
= krb5_storage_to_data(sp
, &data
);
157 krb5_set_error_message(context
, ret
, N_("malloc: out of memory", ""));
160 sret
= write(fd
, data
.data
, data
.length
);
161 ret
= (sret
!= (ssize_t
)data
.length
);
162 krb5_data_free(&data
);
165 krb5_set_error_message(context
, ret
,
166 N_("Failed to write FILE credential data", ""));
173 static krb5_error_code KRB5_CALLCONV
174 fcc_lock(krb5_context context
, krb5_ccache id
,
175 int fd
, krb5_boolean exclusive
)
177 return _krb5_xlock(context
, fd
, exclusive
, fcc_get_name(context
, id
));
180 static krb5_error_code KRB5_CALLCONV
181 fcc_unlock(krb5_context context
, int fd
)
183 return _krb5_xunlock(context
, fd
);
186 static krb5_error_code KRB5_CALLCONV
187 fcc_resolve(krb5_context context
, krb5_ccache
*id
, const char *res
)
190 f
= malloc(sizeof(*f
));
192 krb5_set_error_message(context
, KRB5_CC_NOMEM
,
193 N_("malloc: out of memory", ""));
194 return KRB5_CC_NOMEM
;
196 f
->filename
= strdup(res
);
197 if(f
->filename
== NULL
){
199 krb5_set_error_message(context
, KRB5_CC_NOMEM
,
200 N_("malloc: out of memory", ""));
201 return KRB5_CC_NOMEM
;
204 (*id
)->data
.data
= f
;
205 (*id
)->data
.length
= sizeof(*f
);
210 * Try to scrub the contents of `filename' safely.
219 pos
= lseek(fd
, 0, SEEK_END
);
222 if (lseek(fd
, 0, SEEK_SET
) < 0)
224 memset(buf
, 0, sizeof(buf
));
226 ssize_t tmp
= write(fd
, buf
, min((off_t
)sizeof(buf
), pos
));
241 * Erase `filename' if it exists, trying to remove the contents if
242 * it's `safe'. We always try to remove the file, it it exists. It's
243 * only overwritten if it's a regular file (not a symlink and not a
248 _krb5_erase_file(krb5_context context
, const char *filename
)
251 struct stat sb1
, sb2
;
254 ret
= lstat (filename
, &sb1
);
258 fd
= open(filename
, O_RDWR
| O_BINARY
);
266 ret
= _krb5_xlock(context
, fd
, 1, filename
);
271 if (unlink(filename
) < 0) {
272 _krb5_xunlock(context
, fd
);
276 ret
= fstat (fd
, &sb2
);
278 _krb5_xunlock(context
, fd
);
283 /* check if someone was playing with symlinks */
285 if (sb1
.st_dev
!= sb2
.st_dev
|| sb1
.st_ino
!= sb2
.st_ino
) {
286 _krb5_xunlock(context
, fd
);
291 /* there are still hard links to this file */
293 if (sb2
.st_nlink
!= 0) {
294 _krb5_xunlock(context
, fd
);
299 ret
= scrub_file (fd
);
301 _krb5_xunlock(context
, fd
);
305 ret
= _krb5_xunlock(context
, fd
);
310 static krb5_error_code KRB5_CALLCONV
311 fcc_gen_new(krb5_context context
, krb5_ccache
*id
)
313 char *file
= NULL
, *exp_file
= NULL
;
318 f
= malloc(sizeof(*f
));
320 krb5_set_error_message(context
, KRB5_CC_NOMEM
,
321 N_("malloc: out of memory", ""));
322 return KRB5_CC_NOMEM
;
324 ret
= asprintf (&file
, "%sXXXXXX", KRB5_DEFAULT_CCFILE_ROOT
);
325 if(ret
< 0 || file
== NULL
) {
327 krb5_set_error_message(context
, KRB5_CC_NOMEM
,
328 N_("malloc: out of memory", ""));
329 return KRB5_CC_NOMEM
;
331 ret
= _krb5_expand_path_tokens(context
, file
, &exp_file
);
338 fd
= mkstemp(exp_file
);
341 krb5_set_error_message(context
, xret
, N_("mkstemp %s failed", ""), exp_file
);
347 f
->filename
= exp_file
;
349 (*id
)->data
.data
= f
;
350 (*id
)->data
.length
= sizeof(*f
);
355 storage_set_flags(krb5_context context
, krb5_storage
*sp
, int vno
)
359 case KRB5_FCC_FVNO_1
:
360 flags
|= KRB5_STORAGE_PRINCIPAL_WRONG_NUM_COMPONENTS
;
361 flags
|= KRB5_STORAGE_PRINCIPAL_NO_NAME_TYPE
;
362 flags
|= KRB5_STORAGE_HOST_BYTEORDER
;
364 case KRB5_FCC_FVNO_2
:
365 flags
|= KRB5_STORAGE_HOST_BYTEORDER
;
367 case KRB5_FCC_FVNO_3
:
368 flags
|= KRB5_STORAGE_KEYBLOCK_KEYTYPE_TWICE
;
370 case KRB5_FCC_FVNO_4
:
374 "storage_set_flags called with bad vno (%x)", vno
);
376 krb5_storage_set_flags(sp
, flags
);
379 static krb5_error_code KRB5_CALLCONV
380 fcc_open(krb5_context context
,
386 krb5_boolean exclusive
= ((flags
| O_WRONLY
) == flags
||
387 (flags
| O_RDWR
) == flags
);
389 const char *filename
;
392 if (FCACHE(id
) == NULL
)
393 return krb5_einval(context
, 2);
395 filename
= FILENAME(id
);
397 fd
= open(filename
, flags
, mode
);
401 rk_strerror_r(ret
, buf
, sizeof(buf
));
402 krb5_set_error_message(context
, ret
, N_("open(%s): %s", "file, error"),
408 if((ret
= fcc_lock(context
, id
, fd
, exclusive
)) != 0) {
416 static krb5_error_code KRB5_CALLCONV
417 fcc_initialize(krb5_context context
,
419 krb5_principal primary_principal
)
421 krb5_fcache
*f
= FCACHE(id
);
426 return krb5_einval(context
, 2);
428 unlink (f
->filename
);
430 ret
= fcc_open(context
, id
, &fd
, O_RDWR
| O_CREAT
| O_EXCL
| O_BINARY
| O_CLOEXEC
, 0600);
435 sp
= krb5_storage_emem();
436 krb5_storage_set_eof_code(sp
, KRB5_CC_END
);
437 if(context
->fcache_vno
!= 0)
438 f
->version
= context
->fcache_vno
;
440 f
->version
= KRB5_FCC_FVNO_4
;
441 ret
|= krb5_store_int8(sp
, 5);
442 ret
|= krb5_store_int8(sp
, f
->version
);
443 storage_set_flags(context
, sp
, f
->version
);
444 if(f
->version
== KRB5_FCC_FVNO_4
&& ret
== 0) {
446 if (context
->kdc_sec_offset
) {
447 ret
|= krb5_store_int16 (sp
, 12); /* length */
448 ret
|= krb5_store_int16 (sp
, FCC_TAG_DELTATIME
); /* Tag */
449 ret
|= krb5_store_int16 (sp
, 8); /* length of data */
450 ret
|= krb5_store_int32 (sp
, context
->kdc_sec_offset
);
451 ret
|= krb5_store_int32 (sp
, context
->kdc_usec_offset
);
453 ret
|= krb5_store_int16 (sp
, 0);
456 ret
|= krb5_store_principal(sp
, primary_principal
);
458 ret
|= write_storage(context
, sp
, fd
);
460 krb5_storage_free(sp
);
462 fcc_unlock(context
, fd
);
467 rk_strerror_r(ret
, buf
, sizeof(buf
));
468 krb5_set_error_message (context
, ret
, N_("close %s: %s", ""),
474 static krb5_error_code KRB5_CALLCONV
475 fcc_close(krb5_context context
,
478 if (FCACHE(id
) == NULL
)
479 return krb5_einval(context
, 2);
482 krb5_data_free(&id
->data
);
486 static krb5_error_code KRB5_CALLCONV
487 fcc_destroy(krb5_context context
,
490 if (FCACHE(id
) == NULL
)
491 return krb5_einval(context
, 2);
493 _krb5_erase_file(context
, FILENAME(id
));
497 static krb5_error_code KRB5_CALLCONV
498 fcc_store_cred(krb5_context context
,
505 ret
= fcc_open(context
, id
, &fd
, O_WRONLY
| O_APPEND
| O_BINARY
| O_CLOEXEC
, 0);
511 sp
= krb5_storage_emem();
512 krb5_storage_set_eof_code(sp
, KRB5_CC_END
);
513 storage_set_flags(context
, sp
, FCACHE(id
)->version
);
514 if (!krb5_config_get_bool_default(context
, NULL
, TRUE
,
516 "fcc-mit-ticketflags",
518 krb5_storage_set_flags(sp
, KRB5_STORAGE_CREDS_FLAGS_WRONG_BITORDER
);
519 ret
= krb5_store_creds(sp
, creds
);
521 ret
= write_storage(context
, sp
, fd
);
522 krb5_storage_free(sp
);
524 fcc_unlock(context
, fd
);
528 rk_strerror_r(ret
, buf
, sizeof(buf
));
530 krb5_set_error_message (context
, ret
, N_("close %s: %s", ""),
537 static krb5_error_code
538 init_fcc (krb5_context context
,
540 krb5_storage
**ret_sp
,
542 krb5_deltat
*kdc_offset
)
552 ret
= fcc_open(context
, id
, &fd
, O_RDONLY
| O_BINARY
| O_CLOEXEC
, 0);
556 sp
= krb5_storage_from_fd(fd
);
558 ret
= krb5_enomem(context
);
561 krb5_storage_set_eof_code(sp
, KRB5_CC_END
);
562 ret
= krb5_ret_int8(sp
, &pvno
);
564 if(ret
== KRB5_CC_END
) {
566 krb5_set_error_message(context
, ret
,
567 N_("Empty credential cache file: %s", ""),
570 krb5_set_error_message(context
, ret
, N_("Error reading pvno "
571 "in cache file: %s", ""),
576 ret
= KRB5_CCACHE_BADVNO
;
577 krb5_set_error_message(context
, ret
, N_("Bad version number in credential "
578 "cache file: %s", ""),
582 ret
= krb5_ret_int8(sp
, &tag
); /* should not be host byte order */
584 ret
= KRB5_CC_FORMAT
;
585 krb5_set_error_message(context
, ret
, "Error reading tag in "
586 "cache file: %s", FILENAME(id
));
589 FCACHE(id
)->version
= tag
;
590 storage_set_flags(context
, sp
, FCACHE(id
)->version
);
592 case KRB5_FCC_FVNO_4
: {
595 ret
= krb5_ret_int16 (sp
, &length
);
597 ret
= KRB5_CC_FORMAT
;
598 krb5_set_error_message(context
, ret
,
599 N_("Error reading tag length in "
600 "cache file: %s", ""), FILENAME(id
));
604 int16_t dtag
, data_len
;
608 ret
= krb5_ret_int16 (sp
, &dtag
);
610 ret
= KRB5_CC_FORMAT
;
611 krb5_set_error_message(context
, ret
, N_("Error reading dtag in "
612 "cache file: %s", ""),
616 ret
= krb5_ret_int16 (sp
, &data_len
);
618 ret
= KRB5_CC_FORMAT
;
619 krb5_set_error_message(context
, ret
,
620 N_("Error reading dlength "
621 "in cache file: %s",""),
626 case FCC_TAG_DELTATIME
: {
629 ret
= krb5_ret_int32 (sp
, &offset
);
630 ret
|= krb5_ret_int32 (sp
, &context
->kdc_usec_offset
);
632 ret
= KRB5_CC_FORMAT
;
633 krb5_set_error_message(context
, ret
,
634 N_("Error reading kdc_sec in "
635 "cache file: %s", ""),
639 context
->kdc_sec_offset
= offset
;
641 *kdc_offset
= offset
;
645 for (i
= 0; i
< data_len
; ++i
) {
646 ret
= krb5_ret_int8 (sp
, &dummy
);
648 ret
= KRB5_CC_FORMAT
;
649 krb5_set_error_message(context
, ret
,
650 N_("Error reading unknown "
651 "tag in cache file: %s", ""),
658 length
-= 4 + data_len
;
662 case KRB5_FCC_FVNO_3
:
663 case KRB5_FCC_FVNO_2
:
664 case KRB5_FCC_FVNO_1
:
667 ret
= KRB5_CCACHE_BADVNO
;
668 krb5_set_error_message(context
, ret
,
669 N_("Unknown version number (%d) in "
670 "credential cache file: %s", ""),
671 (int)tag
, FILENAME(id
));
680 krb5_storage_free(sp
);
681 fcc_unlock(context
, fd
);
686 static krb5_error_code KRB5_CALLCONV
687 fcc_get_principal(krb5_context context
,
689 krb5_principal
*principal
)
695 ret
= init_fcc (context
, id
, &sp
, &fd
, NULL
);
698 ret
= krb5_ret_principal(sp
, principal
);
700 krb5_clear_error_message(context
);
701 krb5_storage_free(sp
);
702 fcc_unlock(context
, fd
);
707 static krb5_error_code KRB5_CALLCONV
708 fcc_end_get (krb5_context context
,
710 krb5_cc_cursor
*cursor
);
712 static krb5_error_code KRB5_CALLCONV
713 fcc_get_first (krb5_context context
,
715 krb5_cc_cursor
*cursor
)
718 krb5_principal principal
;
720 if (FCACHE(id
) == NULL
)
721 return krb5_einval(context
, 2);
723 *cursor
= malloc(sizeof(struct fcc_cursor
));
725 return krb5_enomem(context
);
726 memset(*cursor
, 0, sizeof(struct fcc_cursor
));
728 ret
= init_fcc (context
, id
, &FCC_CURSOR(*cursor
)->sp
,
729 &FCC_CURSOR(*cursor
)->fd
, NULL
);
735 ret
= krb5_ret_principal (FCC_CURSOR(*cursor
)->sp
, &principal
);
737 krb5_clear_error_message(context
);
738 fcc_end_get(context
, id
, cursor
);
741 krb5_free_principal (context
, principal
);
742 fcc_unlock(context
, FCC_CURSOR(*cursor
)->fd
);
746 static krb5_error_code KRB5_CALLCONV
747 fcc_get_next (krb5_context context
,
749 krb5_cc_cursor
*cursor
,
754 if (FCACHE(id
) == NULL
)
755 return krb5_einval(context
, 2);
757 if (FCC_CURSOR(*cursor
) == NULL
)
758 return krb5_einval(context
, 3);
760 if((ret
= fcc_lock(context
, id
, FCC_CURSOR(*cursor
)->fd
, FALSE
)) != 0)
763 ret
= krb5_ret_creds(FCC_CURSOR(*cursor
)->sp
, creds
);
765 krb5_clear_error_message(context
);
767 fcc_unlock(context
, FCC_CURSOR(*cursor
)->fd
);
771 static krb5_error_code KRB5_CALLCONV
772 fcc_end_get (krb5_context context
,
774 krb5_cc_cursor
*cursor
)
777 if (FCACHE(id
) == NULL
)
778 return krb5_einval(context
, 2);
780 if (FCC_CURSOR(*cursor
) == NULL
)
781 return krb5_einval(context
, 3);
783 krb5_storage_free(FCC_CURSOR(*cursor
)->sp
);
784 close (FCC_CURSOR(*cursor
)->fd
);
790 static krb5_error_code KRB5_CALLCONV
791 fcc_remove_cred(krb5_context context
,
797 krb5_ccache copy
, newfile
;
798 char *newname
= NULL
;
801 if (FCACHE(id
) == NULL
)
802 return krb5_einval(context
, 2);
804 ret
= krb5_cc_new_unique(context
, krb5_cc_type_memory
, NULL
, ©
);
808 ret
= krb5_cc_copy_cache(context
, id
, copy
);
810 krb5_cc_destroy(context
, copy
);
814 ret
= krb5_cc_remove_cred(context
, copy
, which
, cred
);
816 krb5_cc_destroy(context
, copy
);
820 ret
= asprintf(&newname
, "FILE:%s.XXXXXX", FILENAME(id
));
821 if (ret
< 0 || newname
== NULL
) {
822 krb5_cc_destroy(context
, copy
);
823 return krb5_enomem(context
);
826 fd
= mkstemp(&newname
[5]);
829 krb5_cc_destroy(context
, copy
);
834 ret
= krb5_cc_resolve(context
, newname
, &newfile
);
838 krb5_cc_destroy(context
, copy
);
842 ret
= krb5_cc_copy_cache(context
, copy
, newfile
);
843 krb5_cc_destroy(context
, copy
);
846 krb5_cc_destroy(context
, newfile
);
850 ret
= rk_rename(&newname
[5], FILENAME(id
));
854 krb5_cc_close(context
, newfile
);
859 static krb5_error_code KRB5_CALLCONV
860 fcc_set_flags(krb5_context context
,
864 if (FCACHE(id
) == NULL
)
865 return krb5_einval(context
, 2);
870 static int KRB5_CALLCONV
871 fcc_get_version(krb5_context context
,
874 if (FCACHE(id
) == NULL
)
877 return FCACHE(id
)->version
;
884 static krb5_error_code KRB5_CALLCONV
885 fcc_get_cache_first(krb5_context context
, krb5_cc_cursor
*cursor
)
887 struct fcache_iter
*iter
;
889 iter
= calloc(1, sizeof(*iter
));
891 return krb5_enomem(context
);
897 static krb5_error_code KRB5_CALLCONV
898 fcc_get_cache_next(krb5_context context
, krb5_cc_cursor cursor
, krb5_ccache
*id
)
900 struct fcache_iter
*iter
= cursor
;
903 char *expandedfn
= NULL
;
906 return krb5_einval(context
, 2);
909 krb5_clear_error_message(context
);
914 fn
= krb5_cc_default_name(context
);
915 if (fn
== NULL
|| strncasecmp(fn
, "FILE:", 5) != 0) {
916 ret
= _krb5_expand_default_cc_name(context
,
917 KRB5_DEFAULT_CCNAME_FILE
,
923 /* check if file exists, don't return a non existant "next" */
924 if (strncasecmp(fn
, "FILE:", 5) == 0) {
926 ret
= stat(fn
+ 5, &sb
);
932 ret
= krb5_cc_resolve(context
, fn
, id
);
940 static krb5_error_code KRB5_CALLCONV
941 fcc_end_cache_get(krb5_context context
, krb5_cc_cursor cursor
)
943 struct fcache_iter
*iter
= cursor
;
946 return krb5_einval(context
, 2);
952 static krb5_error_code KRB5_CALLCONV
953 fcc_move(krb5_context context
, krb5_ccache from
, krb5_ccache to
)
955 krb5_error_code ret
= 0;
957 ret
= rk_rename(FILENAME(from
), FILENAME(to
));
959 if (ret
&& errno
!= EXDEV
) {
962 rk_strerror_r(ret
, buf
, sizeof(buf
));
963 krb5_set_error_message(context
, ret
,
964 N_("Rename of file from %s "
965 "to %s failed: %s", ""),
966 FILENAME(from
), FILENAME(to
), buf
);
968 } else if (ret
&& errno
== EXDEV
) {
969 /* make a copy and delete the orignal */
970 krb5_ssize_t sz1
, sz2
;
974 ret
= fcc_open(context
, from
, &fd1
, O_RDONLY
| O_BINARY
| O_CLOEXEC
, 0);
978 unlink(FILENAME(to
));
980 ret
= fcc_open(context
, to
, &fd2
,
981 O_WRONLY
| O_CREAT
| O_EXCL
| O_BINARY
| O_CLOEXEC
, 0600);
985 while((sz1
= read(fd1
, buf
, sizeof(buf
))) > 0) {
986 sz2
= write(fd2
, buf
, sz1
);
989 krb5_set_error_message(context
, ret
,
990 N_("Failed to write data from one file "
991 "credential cache to the other", ""));
997 krb5_set_error_message(context
, ret
,
998 N_("Failed to read data from one file "
999 "credential cache to the other", ""));
1003 fcc_unlock(context
, fd2
);
1007 fcc_unlock(context
, fd1
);
1010 _krb5_erase_file(context
, FILENAME(from
));
1013 _krb5_erase_file(context
, FILENAME(to
));
1018 /* make sure ->version is uptodate */
1022 if ((ret
= init_fcc (context
, to
, &sp
, &fd
, NULL
)) == 0) {
1024 krb5_storage_free(sp
);
1025 fcc_unlock(context
, fd
);
1030 fcc_close(context
, from
);
1035 static krb5_error_code KRB5_CALLCONV
1036 fcc_get_default_name(krb5_context context
, char **str
)
1038 return _krb5_expand_default_cc_name(context
,
1039 KRB5_DEFAULT_CCNAME_FILE
,
1043 static krb5_error_code KRB5_CALLCONV
1044 fcc_lastchange(krb5_context context
, krb5_ccache id
, krb5_timestamp
*mtime
)
1046 krb5_error_code ret
;
1050 ret
= fcc_open(context
, id
, &fd
, O_RDONLY
| O_BINARY
| O_CLOEXEC
, 0);
1053 ret
= fstat(fd
, &sb
);
1057 krb5_set_error_message(context
, ret
, N_("Failed to stat cache file", ""));
1060 *mtime
= sb
.st_mtime
;
1064 static krb5_error_code KRB5_CALLCONV
1065 fcc_set_kdc_offset(krb5_context context
, krb5_ccache id
, krb5_deltat kdc_offset
)
1070 static krb5_error_code KRB5_CALLCONV
1071 fcc_get_kdc_offset(krb5_context context
, krb5_ccache id
, krb5_deltat
*kdc_offset
)
1073 krb5_error_code ret
;
1074 krb5_storage
*sp
= NULL
;
1076 ret
= init_fcc(context
, id
, &sp
, &fd
, kdc_offset
);
1078 krb5_storage_free(sp
);
1079 fcc_unlock(context
, fd
);
1087 * Variable containing the FILE based credential cache implemention.
1089 * @ingroup krb5_ccache
1092 KRB5_LIB_VARIABLE
const krb5_cc_ops krb5_fcc_ops
= {
1093 KRB5_CC_OPS_VERSION
,
1102 NULL
, /* fcc_retrieve */
1110 fcc_get_cache_first
,
1114 fcc_get_default_name
,