From: Mitchell Berger Date: Wed, 20 Jun 2001 08:17:07 +0000 (+0000) Subject: * adb.h: Forward declaration of struct _kadm5_server_handle_t added X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18f8d94a3e2111375760ae6082fd511f59e3ab98;p=thirdparty%2Fkrb5.git * adb.h: Forward declaration of struct _kadm5_server_handle_t added (had to be this way because simply having it include server_internal.h and using the typedef found there causes inclusion in the wrong order). A pointer to a _kadm5_server_handle_t structure has been added to the _osa_adb_db_ent_t structure. This was needed for a frustrating and non-ideal reason, and it's a bit of a kludge. Read the lengthy comment in the file for an explanation of why this was done. A struct _kadm5_server_handle_t pointer was added to the prototypes of osa_adb_init_db and osa_adb_open_policy. * admin.h: Prototype added for kadm5_get_generation_number. * admin_xdr.h: Prototypes added for xdr_getgeneration_arg and xdr_getgeneration_ret. * kadm_rpc.h: Added struct getgeneration_arg and struct getgeneration_ret and typedefs for them, defined GET_GENERATION_NUMBER, added prototypes for getgeneration_4_svc and getgeneration_4. * kadm_rpc_xdr.c: Added new functions xdr_getgeneration_arg and xdr_getgeneration_ret. * server_internal.h: Added prototypes for kdb_put_entry_internal and kdb_update_generation_number. git-svn-id: svn://anonsvn.mit.edu/krb5/branches/incremental-propagation-branch@13409 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/kadm5/ChangeLog b/src/lib/kadm5/ChangeLog index 1a1e13f2b4..9ce9c9baa7 100644 --- a/src/lib/kadm5/ChangeLog +++ b/src/lib/kadm5/ChangeLog @@ -1,3 +1,30 @@ +2001-06-20 Mitchell Berger + + * adb.h: Forward declaration of struct _kadm5_server_handle_t added + (had to be this way because simply having it include server_internal.h + and using the typedef found there causes inclusion in the wrong order). + A pointer to a _kadm5_server_handle_t structure has been added to the + _osa_adb_db_ent_t structure. This was needed for a frustrating and + non-ideal reason, and it's a bit of a kludge. Read the lengthy comment + in the file for an explanation of why this was done. A struct + _kadm5_server_handle_t pointer was added to the prototypes of + osa_adb_init_db and osa_adb_open_policy. + + * admin.h: Prototype added for kadm5_get_generation_number. + + * admin_xdr.h: Prototypes added for xdr_getgeneration_arg and + xdr_getgeneration_ret. + + * kadm_rpc.h: Added struct getgeneration_arg and struct + getgeneration_ret and typedefs for them, defined GET_GENERATION_NUMBER, + added prototypes for getgeneration_4_svc and getgeneration_4. + + * kadm_rpc_xdr.c: Added new functions xdr_getgeneration_arg and + xdr_getgeneration_ret. + + * server_internal.h: Added prototypes for kdb_put_entry_internal and + kdb_update_generation_number. + 2001-06-18 Ezra Peisach diff --git a/src/lib/kadm5/adb.h b/src/lib/kadm5/adb.h index 0277aba075..dd8f642c6a 100644 --- a/src/lib/kadm5/adb.h +++ b/src/lib/kadm5/adb.h @@ -33,6 +33,13 @@ typedef long osa_adb_ret_t; #define OSA_ADB_POLICY_VERSION_MASK 0x12345D00 #define OSA_ADB_POLICY_VERSION_1 0x12345D01 +/* This structure is really defined in server_internal.h, but that file + * includes this file, and if this file includes that file, though they are + * protected against multiple inclusion, the definition of this structure + * and the structure in this file that uses it happen in the wrong order. + */ +struct _kadm5_server_handle_t; + typedef struct _osa_adb_db_lock_ent_t { FILE *lockfile; char *filename; @@ -47,6 +54,18 @@ typedef struct _osa_adb_db_ent_t { BTREEINFO btinfo; char *filename; osa_adb_lock_t lock; + /* XXX Ewww - The handle to the policy db needs a handle to the principal + * db because in order to get generation numbers to increase when policies + * get added, changed, or deleted, we need to be able to do a kdb_get_entry + * on the master principal, and that call takes a handle. Alternatives + * included changing the format of the database (inconvenient to + * upgraders), keeping the policy and principal databases in sync + * separately (seems wrong since they're dumped together, and really want + * to be one database in the future), or reengineering the database + * structure right now (seems unreasonable to get done before dinner 8-) ). + * --mitchb + */ + struct _kadm5_server_handle_t *kadm5_handle; } osa_adb_db_ent, *osa_adb_db_t, *osa_adb_princ_t, *osa_adb_policy_t; /* an osa_pw_hist_ent stores all the key_datas for a single password */ @@ -105,7 +124,8 @@ osa_adb_ret_t osa_adb_rename_db(char *filefrom, char *lockfrom, osa_adb_ret_t osa_adb_rename_policy_db(kadm5_config_params *fromparams, kadm5_config_params *toparams); osa_adb_ret_t osa_adb_init_db(osa_adb_db_t *dbp, char *filename, - char *lockfile, int magic); + char *lockfile, int magic, + struct _kadm5_server_handle_t *kadm5_handle); osa_adb_ret_t osa_adb_fini_db(osa_adb_db_t db, int magic); osa_adb_ret_t osa_adb_get_lock(osa_adb_db_t db, int mode); osa_adb_ret_t osa_adb_release_lock(osa_adb_db_t db); @@ -116,7 +136,8 @@ osa_adb_ret_t osa_adb_create_policy_db(kadm5_config_params *params); osa_adb_ret_t osa_adb_destroy_policy_db(kadm5_config_params *params); osa_adb_ret_t osa_adb_open_princ(osa_adb_princ_t *db, char *filename); osa_adb_ret_t osa_adb_open_policy(osa_adb_policy_t *db, - kadm5_config_params *rparams); + kadm5_config_params *rparams, + struct _kadm5_server_handle_t *kadm5_handle); osa_adb_ret_t osa_adb_close_princ(osa_adb_princ_t db); osa_adb_ret_t osa_adb_close_policy(osa_adb_policy_t db); osa_adb_ret_t osa_adb_create_princ(osa_adb_princ_t db, diff --git a/src/lib/kadm5/admin.h b/src/lib/kadm5/admin.h index 5df8f8ef9e..cd0d43247a 100644 --- a/src/lib/kadm5/admin.h +++ b/src/lib/kadm5/admin.h @@ -447,6 +447,11 @@ kadm5_ret_t kadm5_free_key_data(void *server_handle, kadm5_ret_t kadm5_free_name_list(void *server_handle, char **names, int count); +#if USE_KADM5_API_VERSION > 1 +kadm5_ret_t kadm5_get_generation_number(void *server_handle, + krb5_int32 *generation); +#endif + #if USE_KADM5_API_VERSION == 1 /* * OVSEC_KADM_API_VERSION_1 should be, if possible, compile-time diff --git a/src/lib/kadm5/admin_xdr.h b/src/lib/kadm5/admin_xdr.h index 5a2566ef94..1e49ac53fa 100644 --- a/src/lib/kadm5/admin_xdr.h +++ b/src/lib/kadm5/admin_xdr.h @@ -4,7 +4,34 @@ * $Header$ * * $Log$ + * Revision 1.6.2.1 2001/06/20 08:17:06 mitchb + * * adb.h: Forward declaration of struct _kadm5_server_handle_t added + * (had to be this way because simply having it include server_internal.h + * and using the typedef found there causes inclusion in the wrong order). + * A pointer to a _kadm5_server_handle_t structure has been added to the + * _osa_adb_db_ent_t structure. This was needed for a frustrating and + * non-ideal reason, and it's a bit of a kludge. Read the lengthy comment + * in the file for an explanation of why this was done. A struct + * _kadm5_server_handle_t pointer was added to the prototypes of + * osa_adb_init_db and osa_adb_open_policy. + * + * * admin.h: Prototype added for kadm5_get_generation_number. + * + * * admin_xdr.h: Prototypes added for xdr_getgeneration_arg and + * xdr_getgeneration_ret. + * + * * kadm_rpc.h: Added struct getgeneration_arg and struct + * getgeneration_ret and typedefs for them, defined GET_GENERATION_NUMBER, + * added prototypes for getgeneration_4_svc and getgeneration_4. + * + * * kadm_rpc_xdr.c: Added new functions xdr_getgeneration_arg and + * xdr_getgeneration_ret. + * + * * server_internal.h: Added prototypes for kdb_put_entry_internal and + * kdb_update_generation_number. + * * Revision 1.6 2001/02/18 23:00:08 epeisach + * * * server_internal.h: Add prototype for * krb5_free_key_data_contents() which really should be in libkdb. * @@ -108,6 +135,8 @@ bool_t xdr_gpol_ret(XDR *xdrs, gpol_ret *objp); bool_t xdr_gpols_arg(XDR *xdrs, gpols_arg *objp); bool_t xdr_gpols_ret(XDR *xdrs, gpols_ret *objp); bool_t xdr_getprivs_ret(XDR *xdrs, getprivs_ret *objp); +bool_t xdr_getgeneration_arg(XDR *xdrs, getgeneration_arg *objp); +bool_t xdr_getgeneration_ret(XDR *xdrs, getgeneration_ret *objp); bool_t xdr_krb5_principal(XDR *xdrs, krb5_principal *objp); bool_t xdr_krb5_octet(XDR *xdrs, krb5_octet *objp); bool_t xdr_krb5_int32(XDR *xdrs, krb5_int32 *objp); diff --git a/src/lib/kadm5/kadm_rpc.h b/src/lib/kadm5/kadm_rpc.h index d546c9472b..3ac7a863e5 100644 --- a/src/lib/kadm5/kadm_rpc.h +++ b/src/lib/kadm5/kadm_rpc.h @@ -234,6 +234,20 @@ struct getprivs_ret { typedef struct getprivs_ret getprivs_ret; bool_t xdr_getprivs_ret(); +struct getgeneration_arg { + krb5_ui_4 api_version; +}; +typedef struct getgeneration_arg getgeneration_arg; +bool_t xdr_getgeneration_arg(); + +struct getgeneration_ret { + krb5_ui_4 api_version; + kadm5_ret_t code; + krb5_int32 generation; +}; +typedef struct getgeneration_ret getgeneration_ret; +bool_t xdr_getgeneration_ret(); + #define KADM ((krb5_ui_4)2112) #define KADMVERS ((krb5_ui_4)2) #define CREATE_PRINCIPAL ((krb5_ui_4)1) @@ -332,4 +346,10 @@ extern generic_ret *setkey_principal3_1_svc(setkey3_arg *arg, struct svc_req *rqstp); extern generic_ret *setkey_principal3_1(setkey3_arg *argp, CLIENT *clnt); +#define GET_GENERATION_NUMBER ((krb5_ui_4) 22) +extern getgeneration_ret *getgeneration_4_svc(getgeneration_arg *arg, + struct svc_req *rqstp); +extern getgeneration_ret *getgeneration_4(getgeneration_arg *argp, + CLIENT *clnt); + #endif /* __KADM_RPC_H__ */ diff --git a/src/lib/kadm5/kadm_rpc_xdr.c b/src/lib/kadm5/kadm_rpc_xdr.c index 4424fc0eb9..63e7b26f0a 100644 --- a/src/lib/kadm5/kadm_rpc_xdr.c +++ b/src/lib/kadm5/kadm_rpc_xdr.c @@ -920,6 +920,30 @@ bool_t xdr_getprivs_ret(XDR *xdrs, getprivs_ret *objp) return TRUE; } +bool_t xdr_getgeneration_arg(XDR *xdrs, getgeneration_arg *objp) +{ + if (!xdr_ui_4(xdrs, &objp->api_version)) { + return (FALSE); + } + return (TRUE); +} + +bool_t xdr_getgeneration_ret(XDR *xdrs, getgeneration_ret *objp) +{ + if (!xdr_ui_4(xdrs, &objp->api_version)) { + return (FALSE); + } + if (!xdr_kadm5_ret_t(xdrs, &objp->code)) { + return (FALSE); + } + if (objp->code == KADM5_OK) { + if (!xdr_int32(xdrs, &objp->generation)) { + return (FALSE); + } + } + return (TRUE); +} + bool_t xdr_krb5_principal(XDR *xdrs, krb5_principal *objp) { diff --git a/src/lib/kadm5/server_internal.h b/src/lib/kadm5/server_internal.h index 4a99d267df..a9fbca1ba5 100644 --- a/src/lib/kadm5/server_internal.h +++ b/src/lib/kadm5/server_internal.h @@ -52,8 +52,13 @@ krb5_error_code kdb_free_entry(kadm5_server_handle_t handle, krb5_db_entry *kdb, osa_princ_ent_rec *adb); krb5_error_code kdb_put_entry(kadm5_server_handle_t handle, krb5_db_entry *kdb, osa_princ_ent_rec *adb); +krb5_error_code kdb_put_entry_internal(kadm5_server_handle_t handle, + krb5_db_entry *kdb, + osa_princ_ent_rec *adb, int incgen, + int updatemod); krb5_error_code kdb_delete_entry(kadm5_server_handle_t handle, krb5_principal name); +krb5_error_code kdb_update_generation_number(kadm5_server_handle_t handle); int init_dict(kadm5_config_params *); int find_word(const char *word);