17c478bd9Sstevel@tonic-gate /* 2*56a424ccSmp153739 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 37c478bd9Sstevel@tonic-gate * Use is subject to license terms. 47c478bd9Sstevel@tonic-gate */ 57c478bd9Sstevel@tonic-gate 67c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 77c478bd9Sstevel@tonic-gate 87c478bd9Sstevel@tonic-gate /* 97c478bd9Sstevel@tonic-gate * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING 107c478bd9Sstevel@tonic-gate * 117c478bd9Sstevel@tonic-gate * Openvision retains the copyright to derivative works of 127c478bd9Sstevel@tonic-gate * this source code. Do *NOT* create a derivative of this 137c478bd9Sstevel@tonic-gate * source code before consulting with your legal department. 147c478bd9Sstevel@tonic-gate * Do *NOT* integrate *ANY* of this source code into another 157c478bd9Sstevel@tonic-gate * product before consulting with your legal department. 167c478bd9Sstevel@tonic-gate * 177c478bd9Sstevel@tonic-gate * For further information, read the top-level Openvision 187c478bd9Sstevel@tonic-gate * copyright which is contained in the top-level MIT Kerberos 197c478bd9Sstevel@tonic-gate * copyright. 207c478bd9Sstevel@tonic-gate * 217c478bd9Sstevel@tonic-gate * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING 227c478bd9Sstevel@tonic-gate * 237c478bd9Sstevel@tonic-gate */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate /* 277c478bd9Sstevel@tonic-gate * Data Types for policys, and principal information that 287c478bd9Sstevel@tonic-gate * exist in the respective databases. 297c478bd9Sstevel@tonic-gate * 307c478bd9Sstevel@tonic-gate * $Header: /cvs/krbdev/krb5/src/lib/kadm5/adb.h,v 1.21 1998/02/14 02:34:09 tlyu Exp $ 317c478bd9Sstevel@tonic-gate * 327c478bd9Sstevel@tonic-gate * This file was originally created with rpcgen. 337c478bd9Sstevel@tonic-gate * It has been hacked up since then. 347c478bd9Sstevel@tonic-gate */ 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #ifndef __ADB_H__ 377c478bd9Sstevel@tonic-gate #define __ADB_H__ 387c478bd9Sstevel@tonic-gate #include <sys/types.h> 397c478bd9Sstevel@tonic-gate #include <rpc/types.h> /* SUNWresync121 - no need to change to gssrpc/ */ 407c478bd9Sstevel@tonic-gate #include "k5-int.h" 417c478bd9Sstevel@tonic-gate #include <krb5/kdb.h> 427c478bd9Sstevel@tonic-gate #include <db.h> 437c478bd9Sstevel@tonic-gate #include <kadm5/admin.h> 447c478bd9Sstevel@tonic-gate #include <kadm5/adb_err.h> 457c478bd9Sstevel@tonic-gate #include <com_err.h> 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate typedef long osa_adb_ret_t; 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate #define OSA_ADB_POLICY_DB_MAGIC 0x12345A00 507c478bd9Sstevel@tonic-gate #define OSA_ADB_PRINC_DB_MAGIC 0x12345B00 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate #define OSA_ADB_SHARED 0x7001 537c478bd9Sstevel@tonic-gate #define OSA_ADB_EXCLUSIVE 0x7002 547c478bd9Sstevel@tonic-gate #define OSA_ADB_PERMANENT 0x7003 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate #define OSA_ADB_PRINC_VERSION_MASK 0x12345C00 577c478bd9Sstevel@tonic-gate #define OSA_ADB_PRINC_VERSION_1 0x12345C01 587c478bd9Sstevel@tonic-gate #define OSA_ADB_POLICY_VERSION_MASK 0x12345D00 597c478bd9Sstevel@tonic-gate #define OSA_ADB_POLICY_VERSION_1 0x12345D01 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate typedef struct _osa_adb_db_lock_ent_t { 627c478bd9Sstevel@tonic-gate FILE *lockfile; 637c478bd9Sstevel@tonic-gate char *filename; 647c478bd9Sstevel@tonic-gate int refcnt, lockmode, lockcnt; 657c478bd9Sstevel@tonic-gate krb5_context context; 667c478bd9Sstevel@tonic-gate } osa_adb_lock_ent, *osa_adb_lock_t; 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate typedef struct _osa_adb_db_ent_t { 697c478bd9Sstevel@tonic-gate int magic; 707c478bd9Sstevel@tonic-gate DB *db; 717c478bd9Sstevel@tonic-gate HASHINFO info; 72*56a424ccSmp153739 BTREEINFO btinfo; 737c478bd9Sstevel@tonic-gate char *filename; 747c478bd9Sstevel@tonic-gate osa_adb_lock_t lock; 75*56a424ccSmp153739 int opencnt; 767c478bd9Sstevel@tonic-gate } osa_adb_db_ent, *osa_adb_db_t, *osa_adb_princ_t, *osa_adb_policy_t; 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate /* an osa_pw_hist_ent stores all the key_datas for a single password */ 797c478bd9Sstevel@tonic-gate typedef struct _osa_pw_hist_t { 807c478bd9Sstevel@tonic-gate int n_key_data; 817c478bd9Sstevel@tonic-gate krb5_key_data *key_data; 827c478bd9Sstevel@tonic-gate } osa_pw_hist_ent, *osa_pw_hist_t; 837c478bd9Sstevel@tonic-gate 847c478bd9Sstevel@tonic-gate typedef struct _osa_princ_ent_t { 857c478bd9Sstevel@tonic-gate int version; 867c478bd9Sstevel@tonic-gate char *policy; 877c478bd9Sstevel@tonic-gate long aux_attributes; 887c478bd9Sstevel@tonic-gate unsigned int old_key_len; 897c478bd9Sstevel@tonic-gate unsigned int old_key_next; 907c478bd9Sstevel@tonic-gate krb5_kvno admin_history_kvno; 917c478bd9Sstevel@tonic-gate osa_pw_hist_ent *old_keys; 927c478bd9Sstevel@tonic-gate } osa_princ_ent_rec, *osa_princ_ent_t; 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate typedef struct _osa_policy_ent_t { 957c478bd9Sstevel@tonic-gate int version; 967c478bd9Sstevel@tonic-gate char *name; 97*56a424ccSmp153739 uint32_t pw_min_life; 98*56a424ccSmp153739 uint32_t pw_max_life; 99*56a424ccSmp153739 uint32_t pw_min_length; 100*56a424ccSmp153739 uint32_t pw_min_classes; 101*56a424ccSmp153739 uint32_t pw_history_num; 102*56a424ccSmp153739 uint32_t policy_refcnt; 1037c478bd9Sstevel@tonic-gate } osa_policy_ent_rec, *osa_policy_ent_t; 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate typedef void (*osa_adb_iter_princ_func) (void *, osa_princ_ent_t); 1067c478bd9Sstevel@tonic-gate typedef void (*osa_adb_iter_policy_func) (void *, osa_policy_ent_t); 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate /* 1107c478bd9Sstevel@tonic-gate * Return Code (the rest are in adb_err.h) 1117c478bd9Sstevel@tonic-gate */ 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate #define OSA_ADB_OK 0 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate /* 1167c478bd9Sstevel@tonic-gate * xdr functions 1177c478bd9Sstevel@tonic-gate */ 1187c478bd9Sstevel@tonic-gate bool_t xdr_osa_princ_ent_rec(XDR *xdrs, osa_princ_ent_t objp); 1197c478bd9Sstevel@tonic-gate bool_t xdr_osa_policy_ent_rec(XDR *xdrs, osa_policy_ent_t objp); 120*56a424ccSmp153739 bool_t xdr_osa_pw_hist_ent(XDR *xdrs, osa_pw_hist_ent *objp); 121*56a424ccSmp153739 bool_t xdr_krb5_key_data(XDR *xdrs, krb5_key_data *objp); 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate /* 1247c478bd9Sstevel@tonic-gate * Functions 1257c478bd9Sstevel@tonic-gate */ 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate osa_adb_ret_t osa_adb_create_db(char *filename, char *lockfile, int magic); 1287c478bd9Sstevel@tonic-gate osa_adb_ret_t osa_adb_destroy_db(char *filename, char *lockfile, int magic); 129*56a424ccSmp153739 osa_adb_ret_t osa_adb_rename_db(char *filefrom, char *lockfrom, 130*56a424ccSmp153739 char *fileto, char *lockto, int magic); 131*56a424ccSmp153739 osa_adb_ret_t osa_adb_rename_policy_db(kadm5_config_params *fromparams, 132*56a424ccSmp153739 kadm5_config_params *toparams); 1337c478bd9Sstevel@tonic-gate osa_adb_ret_t osa_adb_init_db(osa_adb_db_t *dbp, char *filename, 1347c478bd9Sstevel@tonic-gate char *lockfile, int magic); 1357c478bd9Sstevel@tonic-gate osa_adb_ret_t osa_adb_fini_db(osa_adb_db_t db, int magic); 1367c478bd9Sstevel@tonic-gate osa_adb_ret_t osa_adb_get_lock(osa_adb_db_t db, int mode); 1377c478bd9Sstevel@tonic-gate osa_adb_ret_t osa_adb_release_lock(osa_adb_db_t db); 1387c478bd9Sstevel@tonic-gate osa_adb_ret_t osa_adb_open_and_lock(osa_adb_princ_t db, int locktype); 1397c478bd9Sstevel@tonic-gate osa_adb_ret_t osa_adb_close_and_unlock(osa_adb_princ_t db); 1407c478bd9Sstevel@tonic-gate 1417c478bd9Sstevel@tonic-gate osa_adb_ret_t osa_adb_create_policy_db(kadm5_config_params *params); 1427c478bd9Sstevel@tonic-gate osa_adb_ret_t osa_adb_destroy_policy_db(kadm5_config_params *params); 1437c478bd9Sstevel@tonic-gate osa_adb_ret_t osa_adb_open_princ(osa_adb_princ_t *db, char *filename); 1447c478bd9Sstevel@tonic-gate osa_adb_ret_t osa_adb_open_policy(osa_adb_policy_t *db, 1457c478bd9Sstevel@tonic-gate kadm5_config_params *rparams); 1467c478bd9Sstevel@tonic-gate osa_adb_ret_t osa_adb_close_princ(osa_adb_princ_t db); 1477c478bd9Sstevel@tonic-gate osa_adb_ret_t osa_adb_close_policy(osa_adb_policy_t db); 1487c478bd9Sstevel@tonic-gate osa_adb_ret_t osa_adb_create_princ(osa_adb_princ_t db, 1497c478bd9Sstevel@tonic-gate osa_princ_ent_t entry); 1507c478bd9Sstevel@tonic-gate osa_adb_ret_t osa_adb_create_policy(osa_adb_policy_t db, 1517c478bd9Sstevel@tonic-gate osa_policy_ent_t entry); 1527c478bd9Sstevel@tonic-gate osa_adb_ret_t osa_adb_destroy_princ(osa_adb_princ_t db, 1537c478bd9Sstevel@tonic-gate kadm5_princ_t name); 1547c478bd9Sstevel@tonic-gate osa_adb_ret_t osa_adb_destroy_policy(osa_adb_policy_t db, 1557c478bd9Sstevel@tonic-gate kadm5_policy_t name); 1567c478bd9Sstevel@tonic-gate osa_adb_ret_t osa_adb_get_princ(osa_adb_princ_t db, 1577c478bd9Sstevel@tonic-gate kadm5_princ_t name, 1587c478bd9Sstevel@tonic-gate osa_princ_ent_t *entry); 1597c478bd9Sstevel@tonic-gate osa_adb_ret_t osa_adb_get_policy(osa_adb_policy_t db, 1607c478bd9Sstevel@tonic-gate kadm5_policy_t name, 1617c478bd9Sstevel@tonic-gate osa_policy_ent_t *entry); 1627c478bd9Sstevel@tonic-gate osa_adb_ret_t osa_adb_put_princ(osa_adb_princ_t db, 1637c478bd9Sstevel@tonic-gate osa_princ_ent_t entry); 1647c478bd9Sstevel@tonic-gate osa_adb_ret_t osa_adb_put_policy(osa_adb_policy_t db, 1657c478bd9Sstevel@tonic-gate osa_policy_ent_t entry); 1667c478bd9Sstevel@tonic-gate osa_adb_ret_t osa_adb_iter_policy(osa_adb_policy_t db, 1677c478bd9Sstevel@tonic-gate osa_adb_iter_policy_func func, 1687c478bd9Sstevel@tonic-gate void * data); 1697c478bd9Sstevel@tonic-gate osa_adb_ret_t osa_adb_iter_princ(osa_adb_princ_t db, 1707c478bd9Sstevel@tonic-gate osa_adb_iter_princ_func func, 1717c478bd9Sstevel@tonic-gate void *data); 1727c478bd9Sstevel@tonic-gate void osa_free_policy_ent(osa_policy_ent_t val); 1737c478bd9Sstevel@tonic-gate void osa_free_princ_ent(osa_princ_ent_t val); 1747c478bd9Sstevel@tonic-gate #endif /* __ADB_H__ */ 175