1*505d05c7Sgtb #pragma ident "%Z%%M% %I% %E% SMI" 2*505d05c7Sgtb 3*505d05c7Sgtb /* 4*505d05c7Sgtb * lib/krb5/ccache/stdio/scc.h 5*505d05c7Sgtb * 6*505d05c7Sgtb * Copyright 1990,1991 by the Massachusetts Institute of Technology. 7*505d05c7Sgtb * All Rights Reserved. 8*505d05c7Sgtb * 9*505d05c7Sgtb * Export of this software from the United States of America may 10*505d05c7Sgtb * require a specific license from the United States Government. 11*505d05c7Sgtb * It is the responsibility of any person or organization contemplating 12*505d05c7Sgtb * export to obtain such a license before exporting. 13*505d05c7Sgtb * 14*505d05c7Sgtb * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 15*505d05c7Sgtb * distribute this software and its documentation for any purpose and 16*505d05c7Sgtb * without fee is hereby granted, provided that the above copyright 17*505d05c7Sgtb * notice appear in all copies and that both that copyright notice and 18*505d05c7Sgtb * this permission notice appear in supporting documentation, and that 19*505d05c7Sgtb * the name of M.I.T. not be used in advertising or publicity pertaining 20*505d05c7Sgtb * to distribution of the software without specific, written prior 21*505d05c7Sgtb * permission. Furthermore if you modify this software you must label 22*505d05c7Sgtb * your software as modified software and not distribute it in such a 23*505d05c7Sgtb * fashion that it might be confused with the original M.I.T. software. 24*505d05c7Sgtb * M.I.T. makes no representations about the suitability of 25*505d05c7Sgtb * this software for any purpose. It is provided "as is" without express 26*505d05c7Sgtb * or implied warranty. 27*505d05c7Sgtb * 28*505d05c7Sgtb * 29*505d05c7Sgtb * This file contains constant and function declarations used in the 30*505d05c7Sgtb * file-based credential cache routines. 31*505d05c7Sgtb */ 32*505d05c7Sgtb 33*505d05c7Sgtb #ifndef __KRB5_FILE_CCACHE__ 34*505d05c7Sgtb #define __KRB5_FILE_CCACHE__ 35*505d05c7Sgtb 36*505d05c7Sgtb #include "k5-int.h" 37*505d05c7Sgtb #include <stdio.h> 38*505d05c7Sgtb 39*505d05c7Sgtb #define KRB5_OK 0 40*505d05c7Sgtb 41*505d05c7Sgtb #define KRB5_SCC_MAXLEN 100 42*505d05c7Sgtb 43*505d05c7Sgtb /* 44*505d05c7Sgtb * SCC version 2 contains type information for principals. SCC 45*505d05c7Sgtb * version 1 does not. The code will accept either, and depending on 46*505d05c7Sgtb * what KRB5_SCC_DEFAULT_FVNO is set to, it will create version 1 or 47*505d05c7Sgtb * version 2 SCC caches. 48*505d05c7Sgtb * 49*505d05c7Sgtb */ 50*505d05c7Sgtb 51*505d05c7Sgtb #define KRB5_SCC_FVNO_1 0x0501 /* krb v5, scc v1 */ 52*505d05c7Sgtb #define KRB5_SCC_FVNO_2 0x0502 /* krb v5, scc v2 */ 53*505d05c7Sgtb #define KRB5_SCC_FVNO_3 0x0503 /* krb v5, scc v3 */ 54*505d05c7Sgtb #define KRB5_SCC_FVNO_4 0x0504 /* krb v5, scc v4 */ 55*505d05c7Sgtb 56*505d05c7Sgtb #define SCC_OPEN_AND_ERASE 1 57*505d05c7Sgtb #define SCC_OPEN_RDWR 2 58*505d05c7Sgtb #define SCC_OPEN_RDONLY 3 59*505d05c7Sgtb 60*505d05c7Sgtb /* Credential file header tags. 61*505d05c7Sgtb * The header tags are constructed as: 62*505d05c7Sgtb * krb5_ui_2 tag 63*505d05c7Sgtb * krb5_ui_2 len 64*505d05c7Sgtb * krb5_octet data[len] 65*505d05c7Sgtb * This format allows for older versions of the fcc processing code to skip 66*505d05c7Sgtb * past unrecognized tag formats. 67*505d05c7Sgtb */ 68*505d05c7Sgtb #define SCC_TAG_DELTATIME 1 69*505d05c7Sgtb 70*505d05c7Sgtb #ifndef TKT_ROOT 71*505d05c7Sgtb #define TKT_ROOT "/tmp/tkt" 72*505d05c7Sgtb #endif 73*505d05c7Sgtb 74*505d05c7Sgtb /* macros to make checking flags easier */ 75*505d05c7Sgtb #define OPENCLOSE(id) (((krb5_scc_data *)id->data)->flags & KRB5_TC_OPENCLOSE) 76*505d05c7Sgtb 77*505d05c7Sgtb typedef struct _krb5_scc_data { 78*505d05c7Sgtb char *filename; 79*505d05c7Sgtb FILE *file; 80*505d05c7Sgtb krb5_flags flags; 81*505d05c7Sgtb char stdio_buffer[BUFSIZ]; 82*505d05c7Sgtb int version; 83*505d05c7Sgtb } krb5_scc_data; 84*505d05c7Sgtb 85*505d05c7Sgtb /* An off_t can be arbitrarily complex */ 86*505d05c7Sgtb typedef struct _krb5_scc_cursor { 87*505d05c7Sgtb long pos; 88*505d05c7Sgtb } krb5_scc_cursor; 89*505d05c7Sgtb 90*505d05c7Sgtb #define MAYBE_OPEN(context, ID, MODE) \ 91*505d05c7Sgtb { \ 92*505d05c7Sgtb if (OPENCLOSE (ID)) { \ 93*505d05c7Sgtb krb5_error_code maybe_open_ret = krb5_scc_open_file (context, ID,MODE); \ 94*505d05c7Sgtb if (maybe_open_ret) return maybe_open_ret; } } 95*505d05c7Sgtb 96*505d05c7Sgtb #define MAYBE_CLOSE(context, ID, RET) \ 97*505d05c7Sgtb { \ 98*505d05c7Sgtb if (OPENCLOSE (ID)) { \ 99*505d05c7Sgtb krb5_error_code maybe_close_ret = krb5_scc_close_file (context, ID); \ 100*505d05c7Sgtb if (!(RET)) RET = maybe_close_ret; } } 101*505d05c7Sgtb 102*505d05c7Sgtb /* DO NOT ADD ANYTHING AFTER THIS #endif */ 103*505d05c7Sgtb #endif /* __KRB5_FILE_CCACHE__ */ 104