* adb_openclose.c: Changed to include server_internal.h instead of
adb.h.
(osa_adb_rename_db): Modified to use the new osa_adb_init_db calling
sequence.
(osa_adb_init_db): Now takes a pointer to a struct
_kadm5_server_handle_t, and puts it in the osa db handle.
* adb_policy.c: Changed to include server_internal.h instead of adb.h
(osa_adb_open_policy): Now takes a pointer to a struct
_kadm5_server_handle_t and passes it to osa_adb_init_db.
(osa_adb_create_policy): Now makes a call to update the generation
number.
(osa_adb_destroy_policy): Now makes a call to update the generation
number.
(osa_adb_put_policy): Now makes a call to update the generation number.
* server_kdb.c: Renamed kdb_put_entry to kdb_put_entry_internal and
added parameters to it to specify whether the modprinc info and the
generation number should be updated, wrote a new kdb_put_entry as a
wrapper for kdb_put_entry_internal that specifies both modprinc info
and the generation number should be updated.
(kdb_delete_entry): Now makes a call to update the generation number.
Added a new function kdb_update_generation_number which looks up the
master principal and calls krb5_dbe_update_generation_number_general
to update the generation number.
* server_misc.c: No longer includes adb.h (server_internal.h already
pulls this in).
(adb_policy_init): Modified to use the new osa_adb_open_policy
calling sequence.
* svr_iters.c: No longer includes adb.h (server_internal.h already
pulls this in).
* svr_policy.c: No longer includes adb.h (server_internal.h already
pulls this in).
* svr_principal.c: No longer includes adb.h (server_internal.h already
pulls this in).
* svr_generation.c: Added this new file containing the new function
kadm5_get_generation_number.
git-svn-id: svn://anonsvn.mit.edu/krb5/branches/incremental-propagation-branch@13407
dc483132-0cff-0310-8789-
dd5450dbe970
+2001-06-20 Mitchell Berger <mitchb@mit.edu>
+
+ * Makefile.in: Include svr_generation.[co] in the build.
+
+ * adb_openclose.c: Changed to include server_internal.h instead of
+ adb.h.
+ (osa_adb_rename_db): Modified to use the new osa_adb_init_db calling
+ sequence.
+ (osa_adb_init_db): Now takes a pointer to a struct
+ _kadm5_server_handle_t, and puts it in the osa db handle.
+
+ * adb_policy.c: Changed to include server_internal.h instead of adb.h
+ (osa_adb_open_policy): Now takes a pointer to a struct
+ _kadm5_server_handle_t and passes it to osa_adb_init_db.
+ (osa_adb_create_policy): Now makes a call to update the generation
+ number.
+ (osa_adb_destroy_policy): Now makes a call to update the generation
+ number.
+ (osa_adb_put_policy): Now makes a call to update the generation number.
+
+ * server_kdb.c: Renamed kdb_put_entry to kdb_put_entry_internal and
+ added parameters to it to specify whether the modprinc info and the
+ generation number should be updated, wrote a new kdb_put_entry as a
+ wrapper for kdb_put_entry_internal that specifies both modprinc info
+ and the generation number should be updated.
+ (kdb_delete_entry): Now makes a call to update the generation number.
+ Added a new function kdb_update_generation_number which looks up the
+ master principal and calls krb5_dbe_update_generation_number_general
+ to update the generation number.
+
+ * server_misc.c: No longer includes adb.h (server_internal.h already
+ pulls this in).
+ (adb_policy_init): Modified to use the new osa_adb_open_policy
+ calling sequence.
+
+ * svr_iters.c: No longer includes adb.h (server_internal.h already
+ pulls this in).
+
+ * svr_policy.c: No longer includes adb.h (server_internal.h already
+ pulls this in).
+
+ * svr_principal.c: No longer includes adb.h (server_internal.h already
+ pulls this in).
+
+ * svr_generation.c: Added this new file containing the new function
+ kadm5_get_generation_number.
+
2001-06-20 Mitchell Berger <mitchb@mit.edu>
* server_dict.c: Silly typo fixed.
$(srcdir)/adb_xdr.c \
$(srcdir)/adb_policy.c \
$(srcdir)/adb_free.c \
- $(srcdir)/adb_openclose.c
+ $(srcdir)/adb_openclose.c \
+ $(srcdir)/svr_generation.c
OBJS = svr_policy.$(OBJEXT) \
svr_principal.$(OBJEXT) \
adb_xdr.$(OBJEXT) \
adb_policy.$(OBJEXT) \
adb_free.$(OBJEXT) \
- adb_openclose.$(OBJEXT)
+ adb_openclose.$(OBJEXT) \
+ svr_generation.$(OBJEXT)
STLIBOBJS = \
svr_policy.o \
adb_xdr.o \
adb_policy.o \
adb_free.o \
- adb_openclose.o
+ adb_openclose.o \
+ svr_generation.o
all-unix:: includes
all-unix:: all-liblinks
#include <sys/file.h>
#include <fcntl.h>
#include <unistd.h>
-#include "adb.h"
+#include "server_internal.h"
#include <stdlib.h>
#define MAX_LOCK_TRIES 5
ret != EEXIST)
return ret;
- if ((ret = osa_adb_init_db(&fromdb, filefrom, lockfrom, magic)))
+ if ((ret = osa_adb_init_db(&fromdb, filefrom, lockfrom, magic, NULL)))
return ret;
- if ((ret = osa_adb_init_db(&todb, fileto, lockto, magic))) {
+ if ((ret = osa_adb_init_db(&todb, fileto, lockto, magic, NULL))) {
(void) osa_adb_fini_db(fromdb, magic);
return ret;
}
}
osa_adb_ret_t osa_adb_init_db(osa_adb_db_t *dbp, char *filename,
- char *lockfilename, int magic)
+ char *lockfilename, int magic,
+ struct _kadm5_server_handle_t *kadm5_handle)
{
osa_adb_db_t db;
static struct _locklist *locklist = NULL;
db->filename = strdup(filename);
db->magic = magic;
+ db->kadm5_handle = kadm5_handle;
+
*dbp = db;
return OSA_ADB_OK;
#include <sys/file.h>
#include <fcntl.h>
-#include "adb.h"
+#include "server_internal.h"
#include <stdlib.h>
#include <string.h>
}
osa_adb_ret_t osa_adb_open_policy(osa_adb_princ_t *dbp,
- kadm5_config_params *rparams)
+ kadm5_config_params *rparams,
+ struct _kadm5_server_handle_t *kadm5_handle)
{
return osa_adb_init_db(dbp, rparams->admin_dbname,
rparams->admin_lockfile,
- OSA_ADB_POLICY_DB_MAGIC);
+ OSA_ADB_POLICY_DB_MAGIC,
+ kadm5_handle);
}
osa_adb_ret_t osa_adb_close_policy(osa_adb_princ_t db)
}
xdr_destroy(&xdrs);
+ /* The create succeeded, so we should increment the generation number. */
+ kdb_update_generation_number(db->kadm5_handle);
+
error:
CLOSELOCK(db);
return ret;
goto error;
}
+ /* The destroy succeeded, so we should update the generation number. */
+ kdb_update_generation_number(db->kadm5_handle);
+
error:
CLOSELOCK(db);
return ret;
}
xdr_destroy(&xdrs);
+ /* The update succeeded, so we should update the generation number. */
+ kdb_update_generation_number(db->kadm5_handle);
+
error:
CLOSELOCK(db);
return ret;
krb5_error_code
kdb_put_entry(kadm5_server_handle_t handle,
krb5_db_entry *kdb, osa_princ_ent_rec *adb)
+{
+ return kdb_put_entry_internal(handle, kdb, adb, 1, 1);
+}
+
+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 ret;
krb5_int32 now;
krb5_tl_data tl_data;
int one;
- ret = krb5_timeofday(handle->context, &now);
- if (ret)
- return(ret);
+ if (updatemod) {
+ ret = krb5_timeofday(handle->context, &now);
+ if (ret)
+ return(ret);
- ret = krb5_dbe_update_mod_princ_data(handle->context, kdb, now,
- handle->current_caller);
- if (ret)
- return(ret);
+ ret = krb5_dbe_update_mod_princ_data(handle->context, kdb, now,
+ handle->current_caller);
+ if (ret)
+ return(ret);
+ }
xdralloc_create(&xdrs, XDR_ENCODE);
if(! xdr_osa_princ_ent_rec(&xdrs, adb)) {
if (ret)
return(ret);
+ if (incgen) {
+ /* The update succeeded, so we should change the generation number */
+ ret = kdb_update_generation_number(handle);
+ if (ret)
+ return(ret);
+ }
+
return(0);
}
krb5_error_code ret;
ret = krb5_db_delete_principal(handle->context, name, &one);
+ if (ret)
+ return(ret);
- return ret;
+ /* The deletion succeeded, so we should change the generation number */
+ ret = kdb_update_generation_number(handle);
+ if (ret)
+ return(ret);
+
+ return(0);
}
typedef struct _iter_data {
return(0);
}
+krb5_error_code
+kdb_update_generation_number(kadm5_server_handle_t handle)
+{
+ krb5_error_code ret;
+ krb5_db_entry master_kdb;
+ osa_princ_ent_rec master_adb;
+
+ ret = kdb_get_entry(handle, master_princ, &master_kdb, &master_adb);
+ if (ret)
+ return(ret);
+
+ ret = krb5_dbe_update_generation_number_general(handle->context,
+ &master_kdb, NULL);
+ if (ret)
+ return(ret);
+
+ /* Updating the generation number, while a change to the database,
+ is not one that should result in updating the generation number
+ again to avoid an infinite loop. */
+ ret = kdb_put_entry_internal(handle, &master_kdb, &master_adb, 0, 0);
+ if (ret)
+ return(ret);
+
+ kdb_free_entry(handle->context, &master_kdb, &master_adb);
+
+ return(0);
+}
#include "k5-int.h"
#include <krb5/kdb.h>
#include <ctype.h>
-#include "adb.h"
#include <pwd.h>
/* for strcasecmp */
osa_adb_ret_t ret;
if(handle->policy_db == (osa_adb_policy_t) NULL)
if((ret = osa_adb_open_policy(&handle->policy_db,
- &handle->params)) != OSA_ADB_OK)
+ &handle->params,
+ handle)) != OSA_ADB_OK)
return ret;
return KADM5_OK;
}
--- /dev/null
+/*
+ * lib/kadm5/srv/svr_generation.c
+ *
+ * (C) Copyright 2001 by the Massachusetts Institute of Technology.
+ * All Rights Reserved.
+ *
+ * Export of this software from the United States of America may
+ * require a specific license from the United States Government.
+ * It is the responsibility of any person or organization contemplating
+ * export to obtain such a license before exporting.
+ *
+ * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
+ * distribute this software and its documentation for any purpose and
+ * without fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation, and that
+ * the name of M.I.T. not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Furthermore if you modify this software you must label
+ * your software as modified software and not distribute it in such a
+ * fashion that it might be confused with the original M.I.T. software.
+ * M.I.T. makes no representations about the suitability of
+ * this software for any purpose. It is provided "as is" without express
+ * or implied warranty.
+ *
+ */
+
+#if !defined(lint) && !defined(__CODECENTER__)
+static char *rcsid = "$Header$";
+#endif
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <kadm5/admin.h>
+#include "k5-int.h"
+#include <krb5/kdb.h>
+#include <stdio.h>
+#include <string.h>
+#include "server_internal.h"
+#include <stdarg.h>
+#include <stdlib.h>
+
+kadm5_ret_t
+kadm5_get_generation_number(void *server_handle, krb5_int32 *generation)
+{
+ krb5_principal princ;
+ krb5_db_entry kdb;
+ osa_princ_ent_rec adb;
+ krb5_error_code ret;
+ kadm5_server_handle_t handle = server_handle;
+
+ CHECK_HANDLE(server_handle);
+
+ ret = krb5_db_setup_mkey_name(handle->context, handle->params.mkey_name,
+ handle->params.realm, NULL, &princ);
+ if (ret)
+ return KADM5_FAILURE;
+
+ ret = kdb_get_entry(handle, princ, &kdb, &adb);
+ if (ret)
+ return KADM5_UNK_PRINC;
+
+ ret = krb5_dbe_lookup_generation_number_general(handle->context, &kdb,
+ generation);
+ if (ret)
+ return KADM5_FAILURE;
+
+ ret = kdb_free_entry(handle, &kdb, &adb);
+ /* if (ret), that sucks, but if we've got the generation number, it
+ seems wrong to fail out. */
+
+ krb5_free_principal(handle->context, princ);
+
+ return KADM5_OK;
+}
+
#include <sys/types.h>
#include <string.h>
#include <kadm5/admin.h>
-#include "adb.h"
#include <dyn.h>
#ifdef SOLARIS_REGEXPS
#include <regexpr.h>
#include <sys/types.h>
#include <kadm5/admin.h>
-#include "adb.h"
#include "server_internal.h"
#include <stdlib.h>
#include <sys/types.h>
#include <sys/time.h>
#include <kadm5/admin.h>
-#include "adb.h"
#include "k5-int.h"
#include <krb5/kdb.h>
#include <stdio.h>