xref: /titanic_44/usr/src/lib/krb5/kadm5/adb.h (revision 159d09a20817016f09b3ea28d1bdada4a336bb91)
17c478bd9Sstevel@tonic-gate /*
2*159d09a2SMark Phalan  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
37c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
47c478bd9Sstevel@tonic-gate  */
57c478bd9Sstevel@tonic-gate 
67c478bd9Sstevel@tonic-gate 
77c478bd9Sstevel@tonic-gate /*
8*159d09a2SMark Phalan  * Data Types for policy and principal information that
9*159d09a2SMark Phalan  * exists in the respective databases.
107c478bd9Sstevel@tonic-gate  *
11*159d09a2SMark Phalan  * $Header$
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * This file was originally created with rpcgen.
147c478bd9Sstevel@tonic-gate  * It has been hacked up since then.
157c478bd9Sstevel@tonic-gate  */
167c478bd9Sstevel@tonic-gate 
177c478bd9Sstevel@tonic-gate #ifndef __ADB_H__
187c478bd9Sstevel@tonic-gate #define __ADB_H__
197c478bd9Sstevel@tonic-gate #include <sys/types.h>
207c478bd9Sstevel@tonic-gate #include <rpc/types.h>	/* SUNWresync121 - no need to change to gssrpc/ */
217c478bd9Sstevel@tonic-gate #include "k5-int.h"
227c478bd9Sstevel@tonic-gate #include <krb5/kdb.h>
237c478bd9Sstevel@tonic-gate #include <db.h>
247c478bd9Sstevel@tonic-gate #include <kadm5/admin.h>
2554925bf6Swillf #include <kdb/adb_err.h>
267c478bd9Sstevel@tonic-gate #include <com_err.h>
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate typedef	long		osa_adb_ret_t;
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #define OSA_ADB_POLICY_DB_MAGIC	0x12345A00
317c478bd9Sstevel@tonic-gate #define OSA_ADB_PRINC_DB_MAGIC	0x12345B00
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #define OSA_ADB_SHARED		0x7001
347c478bd9Sstevel@tonic-gate #define OSA_ADB_EXCLUSIVE	0x7002
357c478bd9Sstevel@tonic-gate #define OSA_ADB_PERMANENT	0x7003
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #define OSA_ADB_PRINC_VERSION_MASK	0x12345C00
387c478bd9Sstevel@tonic-gate #define OSA_ADB_PRINC_VERSION_1		0x12345C01
397c478bd9Sstevel@tonic-gate #define OSA_ADB_POLICY_VERSION_MASK	0x12345D00
407c478bd9Sstevel@tonic-gate #define OSA_ADB_POLICY_VERSION_1	0x12345D01
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate typedef struct _osa_adb_db_lock_ent_t {
437c478bd9Sstevel@tonic-gate      FILE	*lockfile;
447c478bd9Sstevel@tonic-gate      char	*filename;
457c478bd9Sstevel@tonic-gate      int	refcnt, lockmode, lockcnt;
467c478bd9Sstevel@tonic-gate      krb5_context context;
477c478bd9Sstevel@tonic-gate } osa_adb_lock_ent, *osa_adb_lock_t;
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate typedef struct _osa_adb_db_ent_t {
507c478bd9Sstevel@tonic-gate      int	magic;
517c478bd9Sstevel@tonic-gate      DB		*db;
527c478bd9Sstevel@tonic-gate      HASHINFO	info;
5356a424ccSmp153739      BTREEINFO	btinfo;
547c478bd9Sstevel@tonic-gate      char	*filename;
557c478bd9Sstevel@tonic-gate      osa_adb_lock_t lock;
5656a424ccSmp153739      int	opencnt;
577c478bd9Sstevel@tonic-gate } osa_adb_db_ent, *osa_adb_db_t, *osa_adb_princ_t, *osa_adb_policy_t;
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate /* an osa_pw_hist_ent stores all the key_datas for a single password */
607c478bd9Sstevel@tonic-gate typedef struct _osa_pw_hist_t {
617c478bd9Sstevel@tonic-gate      int n_key_data;
627c478bd9Sstevel@tonic-gate      krb5_key_data *key_data;
637c478bd9Sstevel@tonic-gate } osa_pw_hist_ent, *osa_pw_hist_t;
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate typedef struct _osa_princ_ent_t {
667c478bd9Sstevel@tonic-gate     int				version;
677c478bd9Sstevel@tonic-gate     char			*policy;
687c478bd9Sstevel@tonic-gate     long			aux_attributes;
697c478bd9Sstevel@tonic-gate     unsigned int		old_key_len;
707c478bd9Sstevel@tonic-gate     unsigned int		old_key_next;
717c478bd9Sstevel@tonic-gate     krb5_kvno			admin_history_kvno;
727c478bd9Sstevel@tonic-gate     osa_pw_hist_ent		*old_keys;
737c478bd9Sstevel@tonic-gate } osa_princ_ent_rec, *osa_princ_ent_t;
747c478bd9Sstevel@tonic-gate 
757c478bd9Sstevel@tonic-gate typedef struct _osa_policy_ent_t {
767c478bd9Sstevel@tonic-gate     int		version;
777c478bd9Sstevel@tonic-gate     char	*name;
7856a424ccSmp153739     uint32_t	pw_min_life;
7956a424ccSmp153739     uint32_t	pw_max_life;
8056a424ccSmp153739     uint32_t	pw_min_length;
8156a424ccSmp153739     uint32_t	pw_min_classes;
8256a424ccSmp153739     uint32_t	pw_history_num;
8356a424ccSmp153739     uint32_t	policy_refcnt;
847c478bd9Sstevel@tonic-gate } osa_policy_ent_rec, *osa_policy_ent_t;
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate typedef	void	(*osa_adb_iter_princ_func) (void *, osa_princ_ent_t);
877c478bd9Sstevel@tonic-gate typedef	void	(*osa_adb_iter_policy_func) (void *, osa_policy_ent_t);
887c478bd9Sstevel@tonic-gate 
89*159d09a2SMark Phalan 
907c478bd9Sstevel@tonic-gate /*
917c478bd9Sstevel@tonic-gate  * Return Code (the rest are in adb_err.h)
927c478bd9Sstevel@tonic-gate  */
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate #define OSA_ADB_OK		0
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate /*
977c478bd9Sstevel@tonic-gate  * xdr functions
987c478bd9Sstevel@tonic-gate  */
997c478bd9Sstevel@tonic-gate bool_t		xdr_osa_princ_ent_rec(XDR *xdrs, osa_princ_ent_t objp);
1007c478bd9Sstevel@tonic-gate bool_t		xdr_osa_policy_ent_rec(XDR *xdrs, osa_policy_ent_t objp);
10156a424ccSmp153739 bool_t		xdr_osa_pw_hist_ent(XDR *xdrs, osa_pw_hist_ent *objp);
10256a424ccSmp153739 bool_t          xdr_krb5_key_data(XDR *xdrs, krb5_key_data *objp);
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate /*
1057c478bd9Sstevel@tonic-gate  * Functions
1067c478bd9Sstevel@tonic-gate  */
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate osa_adb_ret_t	osa_adb_create_db(char *filename, char *lockfile, int magic);
1097c478bd9Sstevel@tonic-gate osa_adb_ret_t	osa_adb_destroy_db(char *filename, char *lockfile, int magic);
11056a424ccSmp153739 osa_adb_ret_t   osa_adb_rename_db(char *filefrom, char *lockfrom,
11156a424ccSmp153739 				  char *fileto, char *lockto, int magic);
11256a424ccSmp153739 osa_adb_ret_t   osa_adb_rename_policy_db(kadm5_config_params *fromparams,
11356a424ccSmp153739 					 kadm5_config_params *toparams);
1147c478bd9Sstevel@tonic-gate osa_adb_ret_t	osa_adb_init_db(osa_adb_db_t *dbp, char *filename,
1157c478bd9Sstevel@tonic-gate 				char *lockfile, int magic);
1167c478bd9Sstevel@tonic-gate osa_adb_ret_t	osa_adb_fini_db(osa_adb_db_t db, int magic);
1177c478bd9Sstevel@tonic-gate osa_adb_ret_t	osa_adb_get_lock(osa_adb_db_t db, int mode);
1187c478bd9Sstevel@tonic-gate osa_adb_ret_t	osa_adb_release_lock(osa_adb_db_t db);
1197c478bd9Sstevel@tonic-gate osa_adb_ret_t	osa_adb_open_and_lock(osa_adb_princ_t db, int locktype);
1207c478bd9Sstevel@tonic-gate osa_adb_ret_t	osa_adb_close_and_unlock(osa_adb_princ_t db);
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate osa_adb_ret_t	osa_adb_create_policy_db(kadm5_config_params *params);
1237c478bd9Sstevel@tonic-gate osa_adb_ret_t	osa_adb_destroy_policy_db(kadm5_config_params *params);
1247c478bd9Sstevel@tonic-gate osa_adb_ret_t	osa_adb_open_princ(osa_adb_princ_t *db, char *filename);
1257c478bd9Sstevel@tonic-gate osa_adb_ret_t	osa_adb_open_policy(osa_adb_policy_t *db,
1267c478bd9Sstevel@tonic-gate 				    kadm5_config_params *rparams);
1277c478bd9Sstevel@tonic-gate osa_adb_ret_t	osa_adb_close_princ(osa_adb_princ_t db);
1287c478bd9Sstevel@tonic-gate osa_adb_ret_t	osa_adb_close_policy(osa_adb_policy_t db);
1297c478bd9Sstevel@tonic-gate osa_adb_ret_t	osa_adb_create_princ(osa_adb_princ_t db,
1307c478bd9Sstevel@tonic-gate 				 osa_princ_ent_t entry);
1317c478bd9Sstevel@tonic-gate osa_adb_ret_t	osa_adb_create_policy(osa_adb_policy_t db,
1327c478bd9Sstevel@tonic-gate 				      osa_policy_ent_t entry);
1337c478bd9Sstevel@tonic-gate osa_adb_ret_t	osa_adb_destroy_princ(osa_adb_princ_t db,
1347c478bd9Sstevel@tonic-gate 				      kadm5_princ_t name);
1357c478bd9Sstevel@tonic-gate osa_adb_ret_t	osa_adb_destroy_policy(osa_adb_policy_t db,
1367c478bd9Sstevel@tonic-gate 				       kadm5_policy_t name);
1377c478bd9Sstevel@tonic-gate osa_adb_ret_t	osa_adb_get_princ(osa_adb_princ_t db,
1387c478bd9Sstevel@tonic-gate 				  kadm5_princ_t name,
1397c478bd9Sstevel@tonic-gate 				  osa_princ_ent_t *entry);
1407c478bd9Sstevel@tonic-gate osa_adb_ret_t	osa_adb_get_policy(osa_adb_policy_t db,
1417c478bd9Sstevel@tonic-gate 				   kadm5_policy_t name,
1427c478bd9Sstevel@tonic-gate 				   osa_policy_ent_t *entry);
1437c478bd9Sstevel@tonic-gate osa_adb_ret_t	osa_adb_put_princ(osa_adb_princ_t db,
1447c478bd9Sstevel@tonic-gate 				  osa_princ_ent_t entry);
1457c478bd9Sstevel@tonic-gate osa_adb_ret_t	osa_adb_put_policy(osa_adb_policy_t db,
1467c478bd9Sstevel@tonic-gate 				   osa_policy_ent_t entry);
1477c478bd9Sstevel@tonic-gate osa_adb_ret_t	osa_adb_iter_policy(osa_adb_policy_t db,
1487c478bd9Sstevel@tonic-gate 				    osa_adb_iter_policy_func func,
1497c478bd9Sstevel@tonic-gate 				    void * data);
1507c478bd9Sstevel@tonic-gate osa_adb_ret_t	osa_adb_iter_princ(osa_adb_princ_t db,
1517c478bd9Sstevel@tonic-gate 				       osa_adb_iter_princ_func func,
1527c478bd9Sstevel@tonic-gate 				       void *data);
1537c478bd9Sstevel@tonic-gate void		osa_free_policy_ent(osa_policy_ent_t val);
1547c478bd9Sstevel@tonic-gate void		osa_free_princ_ent(osa_princ_ent_t val);
1557c478bd9Sstevel@tonic-gate #endif /* __ADB_H__ */
156