xref: /onnv-gate/usr/src/lib/krb5/kadm5/adb.h (revision 7934:6aeeafc994de)
10Sstevel@tonic-gate /*
2*7934SMark.Phalan@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
30Sstevel@tonic-gate  * Use is subject to license terms.
40Sstevel@tonic-gate  */
50Sstevel@tonic-gate 
60Sstevel@tonic-gate 
70Sstevel@tonic-gate /*
8*7934SMark.Phalan@Sun.COM  * Data Types for policy and principal information that
9*7934SMark.Phalan@Sun.COM  * exists in the respective databases.
100Sstevel@tonic-gate  *
11*7934SMark.Phalan@Sun.COM  * $Header$
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * This file was originally created with rpcgen.
140Sstevel@tonic-gate  * It has been hacked up since then.
150Sstevel@tonic-gate  */
160Sstevel@tonic-gate 
170Sstevel@tonic-gate #ifndef __ADB_H__
180Sstevel@tonic-gate #define __ADB_H__
190Sstevel@tonic-gate #include <sys/types.h>
200Sstevel@tonic-gate #include <rpc/types.h>	/* SUNWresync121 - no need to change to gssrpc/ */
210Sstevel@tonic-gate #include "k5-int.h"
220Sstevel@tonic-gate #include <krb5/kdb.h>
230Sstevel@tonic-gate #include <db.h>
240Sstevel@tonic-gate #include <kadm5/admin.h>
254960Swillf #include <kdb/adb_err.h>
260Sstevel@tonic-gate #include <com_err.h>
270Sstevel@tonic-gate 
280Sstevel@tonic-gate typedef	long		osa_adb_ret_t;
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #define OSA_ADB_POLICY_DB_MAGIC	0x12345A00
310Sstevel@tonic-gate #define OSA_ADB_PRINC_DB_MAGIC	0x12345B00
320Sstevel@tonic-gate 
330Sstevel@tonic-gate #define OSA_ADB_SHARED		0x7001
340Sstevel@tonic-gate #define OSA_ADB_EXCLUSIVE	0x7002
350Sstevel@tonic-gate #define OSA_ADB_PERMANENT	0x7003
360Sstevel@tonic-gate 
370Sstevel@tonic-gate #define OSA_ADB_PRINC_VERSION_MASK	0x12345C00
380Sstevel@tonic-gate #define OSA_ADB_PRINC_VERSION_1		0x12345C01
390Sstevel@tonic-gate #define OSA_ADB_POLICY_VERSION_MASK	0x12345D00
400Sstevel@tonic-gate #define OSA_ADB_POLICY_VERSION_1	0x12345D01
410Sstevel@tonic-gate 
420Sstevel@tonic-gate typedef struct _osa_adb_db_lock_ent_t {
430Sstevel@tonic-gate      FILE	*lockfile;
440Sstevel@tonic-gate      char	*filename;
450Sstevel@tonic-gate      int	refcnt, lockmode, lockcnt;
460Sstevel@tonic-gate      krb5_context context;
470Sstevel@tonic-gate } osa_adb_lock_ent, *osa_adb_lock_t;
480Sstevel@tonic-gate 
490Sstevel@tonic-gate typedef struct _osa_adb_db_ent_t {
500Sstevel@tonic-gate      int	magic;
510Sstevel@tonic-gate      DB		*db;
520Sstevel@tonic-gate      HASHINFO	info;
532881Smp153739      BTREEINFO	btinfo;
540Sstevel@tonic-gate      char	*filename;
550Sstevel@tonic-gate      osa_adb_lock_t lock;
562881Smp153739      int	opencnt;
570Sstevel@tonic-gate } osa_adb_db_ent, *osa_adb_db_t, *osa_adb_princ_t, *osa_adb_policy_t;
580Sstevel@tonic-gate 
590Sstevel@tonic-gate /* an osa_pw_hist_ent stores all the key_datas for a single password */
600Sstevel@tonic-gate typedef struct _osa_pw_hist_t {
610Sstevel@tonic-gate      int n_key_data;
620Sstevel@tonic-gate      krb5_key_data *key_data;
630Sstevel@tonic-gate } osa_pw_hist_ent, *osa_pw_hist_t;
640Sstevel@tonic-gate 
650Sstevel@tonic-gate typedef struct _osa_princ_ent_t {
660Sstevel@tonic-gate     int				version;
670Sstevel@tonic-gate     char			*policy;
680Sstevel@tonic-gate     long			aux_attributes;
690Sstevel@tonic-gate     unsigned int		old_key_len;
700Sstevel@tonic-gate     unsigned int		old_key_next;
710Sstevel@tonic-gate     krb5_kvno			admin_history_kvno;
720Sstevel@tonic-gate     osa_pw_hist_ent		*old_keys;
730Sstevel@tonic-gate } osa_princ_ent_rec, *osa_princ_ent_t;
740Sstevel@tonic-gate 
750Sstevel@tonic-gate typedef struct _osa_policy_ent_t {
760Sstevel@tonic-gate     int		version;
770Sstevel@tonic-gate     char	*name;
782881Smp153739     uint32_t	pw_min_life;
792881Smp153739     uint32_t	pw_max_life;
802881Smp153739     uint32_t	pw_min_length;
812881Smp153739     uint32_t	pw_min_classes;
822881Smp153739     uint32_t	pw_history_num;
832881Smp153739     uint32_t	policy_refcnt;
840Sstevel@tonic-gate } osa_policy_ent_rec, *osa_policy_ent_t;
850Sstevel@tonic-gate 
860Sstevel@tonic-gate typedef	void	(*osa_adb_iter_princ_func) (void *, osa_princ_ent_t);
870Sstevel@tonic-gate typedef	void	(*osa_adb_iter_policy_func) (void *, osa_policy_ent_t);
88*7934SMark.Phalan@Sun.COM 
890Sstevel@tonic-gate 
900Sstevel@tonic-gate /*
910Sstevel@tonic-gate  * Return Code (the rest are in adb_err.h)
920Sstevel@tonic-gate  */
930Sstevel@tonic-gate 
940Sstevel@tonic-gate #define OSA_ADB_OK		0
950Sstevel@tonic-gate 
960Sstevel@tonic-gate /*
970Sstevel@tonic-gate  * xdr functions
980Sstevel@tonic-gate  */
990Sstevel@tonic-gate bool_t		xdr_osa_princ_ent_rec(XDR *xdrs, osa_princ_ent_t objp);
1000Sstevel@tonic-gate bool_t		xdr_osa_policy_ent_rec(XDR *xdrs, osa_policy_ent_t objp);
1012881Smp153739 bool_t		xdr_osa_pw_hist_ent(XDR *xdrs, osa_pw_hist_ent *objp);
1022881Smp153739 bool_t          xdr_krb5_key_data(XDR *xdrs, krb5_key_data *objp);
1030Sstevel@tonic-gate 
1040Sstevel@tonic-gate /*
1050Sstevel@tonic-gate  * Functions
1060Sstevel@tonic-gate  */
1070Sstevel@tonic-gate 
1080Sstevel@tonic-gate osa_adb_ret_t	osa_adb_create_db(char *filename, char *lockfile, int magic);
1090Sstevel@tonic-gate osa_adb_ret_t	osa_adb_destroy_db(char *filename, char *lockfile, int magic);
1102881Smp153739 osa_adb_ret_t   osa_adb_rename_db(char *filefrom, char *lockfrom,
1112881Smp153739 				  char *fileto, char *lockto, int magic);
1122881Smp153739 osa_adb_ret_t   osa_adb_rename_policy_db(kadm5_config_params *fromparams,
1132881Smp153739 					 kadm5_config_params *toparams);
1140Sstevel@tonic-gate osa_adb_ret_t	osa_adb_init_db(osa_adb_db_t *dbp, char *filename,
1150Sstevel@tonic-gate 				char *lockfile, int magic);
1160Sstevel@tonic-gate osa_adb_ret_t	osa_adb_fini_db(osa_adb_db_t db, int magic);
1170Sstevel@tonic-gate osa_adb_ret_t	osa_adb_get_lock(osa_adb_db_t db, int mode);
1180Sstevel@tonic-gate osa_adb_ret_t	osa_adb_release_lock(osa_adb_db_t db);
1190Sstevel@tonic-gate osa_adb_ret_t	osa_adb_open_and_lock(osa_adb_princ_t db, int locktype);
1200Sstevel@tonic-gate osa_adb_ret_t	osa_adb_close_and_unlock(osa_adb_princ_t db);
1210Sstevel@tonic-gate 
1220Sstevel@tonic-gate osa_adb_ret_t	osa_adb_create_policy_db(kadm5_config_params *params);
1230Sstevel@tonic-gate osa_adb_ret_t	osa_adb_destroy_policy_db(kadm5_config_params *params);
1240Sstevel@tonic-gate osa_adb_ret_t	osa_adb_open_princ(osa_adb_princ_t *db, char *filename);
1250Sstevel@tonic-gate osa_adb_ret_t	osa_adb_open_policy(osa_adb_policy_t *db,
1260Sstevel@tonic-gate 				    kadm5_config_params *rparams);
1270Sstevel@tonic-gate osa_adb_ret_t	osa_adb_close_princ(osa_adb_princ_t db);
1280Sstevel@tonic-gate osa_adb_ret_t	osa_adb_close_policy(osa_adb_policy_t db);
1290Sstevel@tonic-gate osa_adb_ret_t	osa_adb_create_princ(osa_adb_princ_t db,
1300Sstevel@tonic-gate 				 osa_princ_ent_t entry);
1310Sstevel@tonic-gate osa_adb_ret_t	osa_adb_create_policy(osa_adb_policy_t db,
1320Sstevel@tonic-gate 				      osa_policy_ent_t entry);
1330Sstevel@tonic-gate osa_adb_ret_t	osa_adb_destroy_princ(osa_adb_princ_t db,
1340Sstevel@tonic-gate 				      kadm5_princ_t name);
1350Sstevel@tonic-gate osa_adb_ret_t	osa_adb_destroy_policy(osa_adb_policy_t db,
1360Sstevel@tonic-gate 				       kadm5_policy_t name);
1370Sstevel@tonic-gate osa_adb_ret_t	osa_adb_get_princ(osa_adb_princ_t db,
1380Sstevel@tonic-gate 				  kadm5_princ_t name,
1390Sstevel@tonic-gate 				  osa_princ_ent_t *entry);
1400Sstevel@tonic-gate osa_adb_ret_t	osa_adb_get_policy(osa_adb_policy_t db,
1410Sstevel@tonic-gate 				   kadm5_policy_t name,
1420Sstevel@tonic-gate 				   osa_policy_ent_t *entry);
1430Sstevel@tonic-gate osa_adb_ret_t	osa_adb_put_princ(osa_adb_princ_t db,
1440Sstevel@tonic-gate 				  osa_princ_ent_t entry);
1450Sstevel@tonic-gate osa_adb_ret_t	osa_adb_put_policy(osa_adb_policy_t db,
1460Sstevel@tonic-gate 				   osa_policy_ent_t entry);
1470Sstevel@tonic-gate osa_adb_ret_t	osa_adb_iter_policy(osa_adb_policy_t db,
1480Sstevel@tonic-gate 				    osa_adb_iter_policy_func func,
1490Sstevel@tonic-gate 				    void * data);
1500Sstevel@tonic-gate osa_adb_ret_t	osa_adb_iter_princ(osa_adb_princ_t db,
1510Sstevel@tonic-gate 				       osa_adb_iter_princ_func func,
1520Sstevel@tonic-gate 				       void *data);
1530Sstevel@tonic-gate void		osa_free_policy_ent(osa_policy_ent_t val);
1540Sstevel@tonic-gate void		osa_free_princ_ent(osa_princ_ent_t val);
1550Sstevel@tonic-gate #endif /* __ADB_H__ */
156