17c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
37c478bd9Sstevel@tonic-gate /*
47c478bd9Sstevel@tonic-gate  * lib/krb5/ccache/stdio/scc.h
57c478bd9Sstevel@tonic-gate  *
67c478bd9Sstevel@tonic-gate  * Copyright 1990,1991 by the Massachusetts Institute of Technology.
77c478bd9Sstevel@tonic-gate  * All Rights Reserved.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * Export of this software from the United States of America may
107c478bd9Sstevel@tonic-gate  *   require a specific license from the United States Government.
117c478bd9Sstevel@tonic-gate  *   It is the responsibility of any person or organization contemplating
127c478bd9Sstevel@tonic-gate  *   export to obtain such a license before exporting.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
157c478bd9Sstevel@tonic-gate  * distribute this software and its documentation for any purpose and
167c478bd9Sstevel@tonic-gate  * without fee is hereby granted, provided that the above copyright
177c478bd9Sstevel@tonic-gate  * notice appear in all copies and that both that copyright notice and
187c478bd9Sstevel@tonic-gate  * this permission notice appear in supporting documentation, and that
197c478bd9Sstevel@tonic-gate  * the name of M.I.T. not be used in advertising or publicity pertaining
207c478bd9Sstevel@tonic-gate  * 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
257c478bd9Sstevel@tonic-gate  * this software for any purpose.  It is provided "as is" without express
267c478bd9Sstevel@tonic-gate  * or implied warranty.
277c478bd9Sstevel@tonic-gate  *
287c478bd9Sstevel@tonic-gate  *
297c478bd9Sstevel@tonic-gate  * This file contains constant and function declarations used in the
307c478bd9Sstevel@tonic-gate  * file-based credential cache routines.
317c478bd9Sstevel@tonic-gate  */
337c478bd9Sstevel@tonic-gate #ifndef __KRB5_FILE_CCACHE__
347c478bd9Sstevel@tonic-gate #define __KRB5_FILE_CCACHE__
367c478bd9Sstevel@tonic-gate #include "k5-int.h"
377c478bd9Sstevel@tonic-gate #include <stdio.h>
397c478bd9Sstevel@tonic-gate #define KRB5_OK 0
417c478bd9Sstevel@tonic-gate #define KRB5_SCC_MAXLEN 100
437c478bd9Sstevel@tonic-gate /*
447c478bd9Sstevel@tonic-gate  * SCC version 2 contains type information for principals.  SCC
457c478bd9Sstevel@tonic-gate  * version 1 does not.  The code will accept either, and depending on
467c478bd9Sstevel@tonic-gate  * what KRB5_SCC_DEFAULT_FVNO is set to, it will create version 1 or
477c478bd9Sstevel@tonic-gate  * version 2 SCC caches.
487c478bd9Sstevel@tonic-gate  *
497c478bd9Sstevel@tonic-gate  */
517c478bd9Sstevel@tonic-gate #define KRB5_SCC_FVNO_1   0x0501	/* krb v5, scc v1 */
527c478bd9Sstevel@tonic-gate #define KRB5_SCC_FVNO_2   0x0502	/* krb v5, scc v2 */
537c478bd9Sstevel@tonic-gate #define KRB5_SCC_FVNO_3   0x0503	/* krb v5, scc v3 */
547c478bd9Sstevel@tonic-gate #define KRB5_SCC_FVNO_4   0x0504	/* krb v5, scc v4 */
567c478bd9Sstevel@tonic-gate #define	SCC_OPEN_AND_ERASE	1
577c478bd9Sstevel@tonic-gate #define	SCC_OPEN_RDWR		2
587c478bd9Sstevel@tonic-gate #define	SCC_OPEN_RDONLY		3
607c478bd9Sstevel@tonic-gate /* Credential file header tags.
617c478bd9Sstevel@tonic-gate  * The header tags are constructed as:
627c478bd9Sstevel@tonic-gate  *     krb5_ui_2       tag
637c478bd9Sstevel@tonic-gate  *     krb5_ui_2       len
647c478bd9Sstevel@tonic-gate  *     krb5_octet      data[len]
657c478bd9Sstevel@tonic-gate  * This format allows for older versions of the fcc processing code to skip
667c478bd9Sstevel@tonic-gate  * past unrecognized tag formats.
677c478bd9Sstevel@tonic-gate  */
687c478bd9Sstevel@tonic-gate #define SCC_TAG_DELTATIME	1
707c478bd9Sstevel@tonic-gate #ifndef TKT_ROOT
717c478bd9Sstevel@tonic-gate #define TKT_ROOT "/tmp/tkt"
727c478bd9Sstevel@tonic-gate #endif
747c478bd9Sstevel@tonic-gate /* macros to make checking flags easier */
757c478bd9Sstevel@tonic-gate #define OPENCLOSE(id) (((krb5_scc_data *)id->data)->flags & KRB5_TC_OPENCLOSE)
777c478bd9Sstevel@tonic-gate typedef struct _krb5_scc_data {
787c478bd9Sstevel@tonic-gate      char *filename;
797c478bd9Sstevel@tonic-gate      FILE *file;
807c478bd9Sstevel@tonic-gate      krb5_flags flags;
817c478bd9Sstevel@tonic-gate      char stdio_buffer[BUFSIZ];
827c478bd9Sstevel@tonic-gate      int version;
837c478bd9Sstevel@tonic-gate } krb5_scc_data;
857c478bd9Sstevel@tonic-gate /* An off_t can be arbitrarily complex */
867c478bd9Sstevel@tonic-gate typedef struct _krb5_scc_cursor {
877c478bd9Sstevel@tonic-gate     long pos;
887c478bd9Sstevel@tonic-gate } krb5_scc_cursor;
907c478bd9Sstevel@tonic-gate #define MAYBE_OPEN(context, ID, MODE) \
917c478bd9Sstevel@tonic-gate {									\
927c478bd9Sstevel@tonic-gate     if (OPENCLOSE (ID)) {						\
937c478bd9Sstevel@tonic-gate 	krb5_error_code maybe_open_ret = krb5_scc_open_file (context, ID,MODE);	\
947c478bd9Sstevel@tonic-gate 	if (maybe_open_ret) return maybe_open_ret; } }
967c478bd9Sstevel@tonic-gate #define MAYBE_CLOSE(context, ID, RET) \
977c478bd9Sstevel@tonic-gate {									\
987c478bd9Sstevel@tonic-gate     if (OPENCLOSE (ID)) {						\
997c478bd9Sstevel@tonic-gate 	krb5_error_code maybe_close_ret = krb5_scc_close_file (context, ID);	\
1007c478bd9Sstevel@tonic-gate 	if (!(RET)) RET = maybe_close_ret; } }
1027c478bd9Sstevel@tonic-gate /* DO NOT ADD ANYTHING AFTER THIS #endif */
1037c478bd9Sstevel@tonic-gate #endif /* __KRB5_FILE_CCACHE__ */