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