1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * Copyright 2002 Sun Microsystems, Inc. All rights reserved. 3*0Sstevel@tonic-gate * Use is subject to license terms. 4*0Sstevel@tonic-gate */ 5*0Sstevel@tonic-gate 6*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 7*0Sstevel@tonic-gate 8*0Sstevel@tonic-gate /* 9*0Sstevel@tonic-gate * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING 10*0Sstevel@tonic-gate * 11*0Sstevel@tonic-gate * Openvision retains the copyright to derivative works of 12*0Sstevel@tonic-gate * this source code. Do *NOT* create a derivative of this 13*0Sstevel@tonic-gate * source code before consulting with your legal department. 14*0Sstevel@tonic-gate * Do *NOT* integrate *ANY* of this source code into another 15*0Sstevel@tonic-gate * product before consulting with your legal department. 16*0Sstevel@tonic-gate * 17*0Sstevel@tonic-gate * For further information, read the top-level Openvision 18*0Sstevel@tonic-gate * copyright which is contained in the top-level MIT Kerberos 19*0Sstevel@tonic-gate * copyright. 20*0Sstevel@tonic-gate * 21*0Sstevel@tonic-gate * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING 22*0Sstevel@tonic-gate * 23*0Sstevel@tonic-gate */ 24*0Sstevel@tonic-gate 25*0Sstevel@tonic-gate 26*0Sstevel@tonic-gate /* 27*0Sstevel@tonic-gate * Data Types for policys, and principal information that 28*0Sstevel@tonic-gate * exist in the respective databases. 29*0Sstevel@tonic-gate * 30*0Sstevel@tonic-gate * $Header: /cvs/krbdev/krb5/src/lib/kadm5/adb.h,v 1.21 1998/02/14 02:34:09 tlyu Exp $ 31*0Sstevel@tonic-gate * 32*0Sstevel@tonic-gate * This file was originally created with rpcgen. 33*0Sstevel@tonic-gate * It has been hacked up since then. 34*0Sstevel@tonic-gate */ 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate #ifndef __ADB_H__ 37*0Sstevel@tonic-gate #define __ADB_H__ 38*0Sstevel@tonic-gate #include <sys/types.h> 39*0Sstevel@tonic-gate #include <rpc/types.h> /* SUNWresync121 - no need to change to gssrpc/ */ 40*0Sstevel@tonic-gate #include "k5-int.h" 41*0Sstevel@tonic-gate #include <krb5/kdb.h> 42*0Sstevel@tonic-gate #include <db.h> 43*0Sstevel@tonic-gate #include <kadm5/admin.h> 44*0Sstevel@tonic-gate #include <kadm5/adb_err.h> 45*0Sstevel@tonic-gate #include <com_err.h> 46*0Sstevel@tonic-gate 47*0Sstevel@tonic-gate typedef long osa_adb_ret_t; 48*0Sstevel@tonic-gate 49*0Sstevel@tonic-gate #define OSA_ADB_POLICY_DB_MAGIC 0x12345A00 50*0Sstevel@tonic-gate #define OSA_ADB_PRINC_DB_MAGIC 0x12345B00 51*0Sstevel@tonic-gate 52*0Sstevel@tonic-gate #define OSA_ADB_SHARED 0x7001 53*0Sstevel@tonic-gate #define OSA_ADB_EXCLUSIVE 0x7002 54*0Sstevel@tonic-gate #define OSA_ADB_PERMANENT 0x7003 55*0Sstevel@tonic-gate 56*0Sstevel@tonic-gate #define OSA_ADB_PRINC_VERSION_MASK 0x12345C00 57*0Sstevel@tonic-gate #define OSA_ADB_PRINC_VERSION_1 0x12345C01 58*0Sstevel@tonic-gate #define OSA_ADB_POLICY_VERSION_MASK 0x12345D00 59*0Sstevel@tonic-gate #define OSA_ADB_POLICY_VERSION_1 0x12345D01 60*0Sstevel@tonic-gate 61*0Sstevel@tonic-gate typedef struct _osa_adb_db_lock_ent_t { 62*0Sstevel@tonic-gate FILE *lockfile; 63*0Sstevel@tonic-gate char *filename; 64*0Sstevel@tonic-gate int refcnt, lockmode, lockcnt; 65*0Sstevel@tonic-gate krb5_context context; 66*0Sstevel@tonic-gate } osa_adb_lock_ent, *osa_adb_lock_t; 67*0Sstevel@tonic-gate 68*0Sstevel@tonic-gate typedef struct _osa_adb_db_ent_t { 69*0Sstevel@tonic-gate int magic; 70*0Sstevel@tonic-gate DB *db; 71*0Sstevel@tonic-gate HASHINFO info; 72*0Sstevel@tonic-gate char *filename; 73*0Sstevel@tonic-gate osa_adb_lock_t lock; 74*0Sstevel@tonic-gate } osa_adb_db_ent, *osa_adb_db_t, *osa_adb_princ_t, *osa_adb_policy_t; 75*0Sstevel@tonic-gate 76*0Sstevel@tonic-gate /* an osa_pw_hist_ent stores all the key_datas for a single password */ 77*0Sstevel@tonic-gate typedef struct _osa_pw_hist_t { 78*0Sstevel@tonic-gate int n_key_data; 79*0Sstevel@tonic-gate krb5_key_data *key_data; 80*0Sstevel@tonic-gate } osa_pw_hist_ent, *osa_pw_hist_t; 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate typedef struct _osa_princ_ent_t { 83*0Sstevel@tonic-gate int version; 84*0Sstevel@tonic-gate char *policy; 85*0Sstevel@tonic-gate long aux_attributes; 86*0Sstevel@tonic-gate unsigned int old_key_len; 87*0Sstevel@tonic-gate unsigned int old_key_next; 88*0Sstevel@tonic-gate krb5_kvno admin_history_kvno; 89*0Sstevel@tonic-gate osa_pw_hist_ent *old_keys; 90*0Sstevel@tonic-gate } osa_princ_ent_rec, *osa_princ_ent_t; 91*0Sstevel@tonic-gate 92*0Sstevel@tonic-gate typedef struct _osa_policy_ent_t { 93*0Sstevel@tonic-gate int version; 94*0Sstevel@tonic-gate char *name; 95*0Sstevel@tonic-gate rpc_u_int32 pw_min_life; 96*0Sstevel@tonic-gate rpc_u_int32 pw_max_life; 97*0Sstevel@tonic-gate rpc_u_int32 pw_min_length; 98*0Sstevel@tonic-gate rpc_u_int32 pw_min_classes; 99*0Sstevel@tonic-gate rpc_u_int32 pw_history_num; 100*0Sstevel@tonic-gate rpc_u_int32 policy_refcnt; 101*0Sstevel@tonic-gate } osa_policy_ent_rec, *osa_policy_ent_t; 102*0Sstevel@tonic-gate 103*0Sstevel@tonic-gate typedef void (*osa_adb_iter_princ_func) (void *, osa_princ_ent_t); 104*0Sstevel@tonic-gate typedef void (*osa_adb_iter_policy_func) (void *, osa_policy_ent_t); 105*0Sstevel@tonic-gate 106*0Sstevel@tonic-gate 107*0Sstevel@tonic-gate /* 108*0Sstevel@tonic-gate * Return Code (the rest are in adb_err.h) 109*0Sstevel@tonic-gate */ 110*0Sstevel@tonic-gate 111*0Sstevel@tonic-gate #define OSA_ADB_OK 0 112*0Sstevel@tonic-gate 113*0Sstevel@tonic-gate /* 114*0Sstevel@tonic-gate * xdr functions 115*0Sstevel@tonic-gate */ 116*0Sstevel@tonic-gate bool_t xdr_osa_princ_ent_rec(XDR *xdrs, osa_princ_ent_t objp); 117*0Sstevel@tonic-gate bool_t xdr_osa_policy_ent_rec(XDR *xdrs, osa_policy_ent_t objp); 118*0Sstevel@tonic-gate 119*0Sstevel@tonic-gate /* 120*0Sstevel@tonic-gate * Functions 121*0Sstevel@tonic-gate */ 122*0Sstevel@tonic-gate 123*0Sstevel@tonic-gate osa_adb_ret_t osa_adb_create_db(char *filename, char *lockfile, int magic); 124*0Sstevel@tonic-gate osa_adb_ret_t osa_adb_destroy_db(char *filename, char *lockfile, int magic); 125*0Sstevel@tonic-gate osa_adb_ret_t osa_adb_init_db(osa_adb_db_t *dbp, char *filename, 126*0Sstevel@tonic-gate char *lockfile, int magic); 127*0Sstevel@tonic-gate osa_adb_ret_t osa_adb_fini_db(osa_adb_db_t db, int magic); 128*0Sstevel@tonic-gate osa_adb_ret_t osa_adb_get_lock(osa_adb_db_t db, int mode); 129*0Sstevel@tonic-gate osa_adb_ret_t osa_adb_release_lock(osa_adb_db_t db); 130*0Sstevel@tonic-gate osa_adb_ret_t osa_adb_open_and_lock(osa_adb_princ_t db, int locktype); 131*0Sstevel@tonic-gate osa_adb_ret_t osa_adb_close_and_unlock(osa_adb_princ_t db); 132*0Sstevel@tonic-gate 133*0Sstevel@tonic-gate osa_adb_ret_t osa_adb_create_policy_db(kadm5_config_params *params); 134*0Sstevel@tonic-gate osa_adb_ret_t osa_adb_destroy_policy_db(kadm5_config_params *params); 135*0Sstevel@tonic-gate osa_adb_ret_t osa_adb_open_princ(osa_adb_princ_t *db, char *filename); 136*0Sstevel@tonic-gate osa_adb_ret_t osa_adb_open_policy(osa_adb_policy_t *db, 137*0Sstevel@tonic-gate kadm5_config_params *rparams); 138*0Sstevel@tonic-gate osa_adb_ret_t osa_adb_close_princ(osa_adb_princ_t db); 139*0Sstevel@tonic-gate osa_adb_ret_t osa_adb_close_policy(osa_adb_policy_t db); 140*0Sstevel@tonic-gate osa_adb_ret_t osa_adb_create_princ(osa_adb_princ_t db, 141*0Sstevel@tonic-gate osa_princ_ent_t entry); 142*0Sstevel@tonic-gate osa_adb_ret_t osa_adb_create_policy(osa_adb_policy_t db, 143*0Sstevel@tonic-gate osa_policy_ent_t entry); 144*0Sstevel@tonic-gate osa_adb_ret_t osa_adb_destroy_princ(osa_adb_princ_t db, 145*0Sstevel@tonic-gate kadm5_princ_t name); 146*0Sstevel@tonic-gate osa_adb_ret_t osa_adb_destroy_policy(osa_adb_policy_t db, 147*0Sstevel@tonic-gate kadm5_policy_t name); 148*0Sstevel@tonic-gate osa_adb_ret_t osa_adb_get_princ(osa_adb_princ_t db, 149*0Sstevel@tonic-gate kadm5_princ_t name, 150*0Sstevel@tonic-gate osa_princ_ent_t *entry); 151*0Sstevel@tonic-gate osa_adb_ret_t osa_adb_get_policy(osa_adb_policy_t db, 152*0Sstevel@tonic-gate kadm5_policy_t name, 153*0Sstevel@tonic-gate osa_policy_ent_t *entry); 154*0Sstevel@tonic-gate osa_adb_ret_t osa_adb_put_princ(osa_adb_princ_t db, 155*0Sstevel@tonic-gate osa_princ_ent_t entry); 156*0Sstevel@tonic-gate osa_adb_ret_t osa_adb_put_policy(osa_adb_policy_t db, 157*0Sstevel@tonic-gate osa_policy_ent_t entry); 158*0Sstevel@tonic-gate osa_adb_ret_t osa_adb_iter_policy(osa_adb_policy_t db, 159*0Sstevel@tonic-gate osa_adb_iter_policy_func func, 160*0Sstevel@tonic-gate void * data); 161*0Sstevel@tonic-gate osa_adb_ret_t osa_adb_iter_princ(osa_adb_princ_t db, 162*0Sstevel@tonic-gate osa_adb_iter_princ_func func, 163*0Sstevel@tonic-gate void *data); 164*0Sstevel@tonic-gate void osa_free_policy_ent(osa_policy_ent_t val); 165*0Sstevel@tonic-gate void osa_free_princ_ent(osa_princ_ent_t val); 166*0Sstevel@tonic-gate #endif /* __ADB_H__ */ 167