summaryrefslogtreecommitdiff
path: root/usr/src/lib/krb5/kdb/kdb_hdr.h
blob: d27e0ddb1a3e8ae439638d981d58b717b17827f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef _KDB_HDR_H
#define	_KDB_HDR_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"

#include <krb5.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * This header is required to solve a conflict with
 * usr/src/lib/gss_mechs/mech_krb5/include/krb5/kdb_dbm.h
 * which creates numerous defines like ....
 * #define krb5_dbm_db_fini krb5_db_fini
 * that break the spec file creation and resolution process.
 *
 * lib/kdb/kdb_hdr.h
 */

#ifndef __KADM5_ADMIN_H__
struct _kadm5_config_params; 
typedef struct _kadm5_config_params kadm5_config_params;
#endif

#if defined(KRB5_NO_CONST) || (defined(__ultrix) && !defined(__GNUC__))
#define krb5_const
#else
#define krb5_const const
#endif

typedef struct _krb5_keysalt {
    krb5_int16            type;
    krb5_data             data;                 /* Length, data */
} krb5_keysalt;

typedef struct _krb5_tl_data {
    struct _krb5_tl_data* tl_data_next;         /* NOT saved */
    krb5_int16            tl_data_type;
    krb5_int16            tl_data_length;
    krb5_octet          * tl_data_contents;
} krb5_tl_data;

typedef struct _krb5_key_data {
    krb5_int16            key_data_ver;         /* Version */
    krb5_int16            key_data_kvno;        /* Key Version */
    krb5_int16            key_data_type[2];     /* Array of types */
    krb5_int16            key_data_length[2];   /* Array of lengths */
    krb5_octet          * key_data_contents[2]; /* Array of pointers */
} krb5_key_data;

typedef struct _krb5_db_entry_new {
    krb5_magic            magic;                /* NOT saved */
    krb5_int16            len;
    krb5_flags            attributes;
    krb5_deltat           max_life;
    krb5_deltat           max_renewable_life;
    krb5_timestamp        expiration;           /* When the client expires */
    krb5_timestamp        pw_expiration;        /* When its passwd expires */
    krb5_timestamp        last_success;         /* Last successful passwd */
    krb5_timestamp        last_failed;          /* Last failed passwd attempt */
    krb5_kvno             fail_auth_count;      /* # of failed passwd attempt */
    krb5_int16            n_tl_data;
    krb5_int16            n_key_data;
    krb5_int16            e_length;             /* Length of extra data */
    krb5_octet          * e_data;               /* Extra data to be saved */

    krb5_principal        princ;                /* Length, data */
    krb5_tl_data        * tl_data;              /* Linked list */
    krb5_key_data       * key_data;             /* Array */
} krb5_db_entry;

#include "krb5/adm.h"
#include "db-ndbm.h"

#ifndef __P
#if defined(__STDC__) || defined(__cplusplus)
#define __P(protos)     protos          /* full-blown ANSI C */
#else   /* !(__STDC__ || __cplusplus) */
#define __P(protos)     ()              /* traditional C preprocessor */
#endif
#endif /* no __P from system */

#ifndef __P
#if defined(__STDC__) || defined(__cplusplus)
#define __P(protos)     protos          /* full-blown ANSI C */
#else   /* !(__STDC__ || __cplusplus) */
#define __P(protos)     ()              /* traditional C preprocessor */
#endif
#endif /* no __P from system */

typedef struct _kdb5_dispatch_table {
    char *      kdb5_db_mech_name;
    char *      kdb5_db_index_ext;
    char *      kdb5_db_data_ext;
    char *      kdb5_db_lock_ext;
    DBM *       (*kdb5_dbm_open) KRB5_NPROTOTYPE((const char *, int, int));
    void        (*kdb5_dbm_close) KRB5_NPROTOTYPE((DBM *));
    datum       (*kdb5_dbm_fetch) KRB5_NPROTOTYPE((DBM *, datum));
    datum       (*kdb5_dbm_firstkey) KRB5_NPROTOTYPE((DBM *));
    datum       (*kdb5_dbm_nextkey) KRB5_NPROTOTYPE((DBM *));
    int         (*kdb5_dbm_delete) KRB5_NPROTOTYPE((DBM *, datum));
    int         (*kdb5_dbm_store) KRB5_NPROTOTYPE((DBM *, datum, datum, int));
    int         (*kdb5_dbm_dirfno) KRB5_NPROTOTYPE((DBM *));
    int         (*kdb5_dbm_pagfno) KRB5_NPROTOTYPE((DBM *));
} kdb5_dispatch_table;

/* Per-database context. */
typedef struct __krb5_db_context {
    krb5_boolean        db_inited;      /* Context initialized          */
    char *              db_name;        /* Name of database             */
    DBM *               db_dbm_ctx;     /* DBM context for database     */
    char *              db_lf_name;     /* Name of lock file            */
    int                 db_lf_file;     /* File descriptor of lock file */
    time_t              db_lf_time;     /* Time last updated            */
    int                 db_locks_held;  /* Number of times locked       */
    int                 db_lock_mode;   /* Last lock mode, e.g. greatest*/
    krb5_boolean        db_nb_locks;    /* [Non]Blocking lock modes     */
    krb5_encrypt_block *db_master_key;  /* Master key of database       */
    kdb5_dispatch_table *db_dispatch;   /* Dispatch table               */
} krb5_db_context;

#ifdef	__cplusplus
}
#endif

#endif	/* !_KDB_HDR_H */