]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
* Makefile.in: Include svr_generation.[co] in the build
authorMitchell Berger <mitchb@mit.edu>
Wed, 20 Jun 2001 08:13:20 +0000 (08:13 +0000)
committerMitchell Berger <mitchb@mit.edu>
Wed, 20 Jun 2001 08:13:20 +0000 (08:13 +0000)
* 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

src/lib/kadm5/srv/ChangeLog
src/lib/kadm5/srv/Makefile.in
src/lib/kadm5/srv/adb_openclose.c
src/lib/kadm5/srv/adb_policy.c
src/lib/kadm5/srv/server_kdb.c
src/lib/kadm5/srv/server_misc.c
src/lib/kadm5/srv/svr_generation.c [new file with mode: 0644]
src/lib/kadm5/srv/svr_iters.c
src/lib/kadm5/srv/svr_policy.c
src/lib/kadm5/srv/svr_principal.c

index 5db7ffacbb09cc2cb43bcdc394ea65fa7eab2630..300dad945acbdcbd3e16677ad33a0aff8398c2f4 100644 (file)
@@ -1,3 +1,50 @@
+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.
index 40da944793a4b4629461edcfbe9536df8effe5d0..6c21260e24132b505fa94b318c90fc24fa3028d7 100644 (file)
@@ -39,7 +39,8 @@ SRCS =        $(srcdir)/svr_policy.c \
        $(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) \
@@ -53,7 +54,8 @@ OBJS =        svr_policy.$(OBJEXT) \
        adb_xdr.$(OBJEXT) \
        adb_policy.$(OBJEXT) \
        adb_free.$(OBJEXT) \
-       adb_openclose.$(OBJEXT)
+       adb_openclose.$(OBJEXT) \
+       svr_generation.$(OBJEXT)
 
 STLIBOBJS = \
        svr_policy.o \
@@ -68,7 +70,8 @@ STLIBOBJS = \
        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
index 12219cdabe08a728e5bbf278e2280a4dd323d995..9f165bd8d4bb75bbc8176bae518ead757c889ce0 100644 (file)
@@ -11,7 +11,7 @@ static char *rcsid = "$Header$";
 #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
@@ -72,9 +72,9 @@ osa_adb_ret_t osa_adb_rename_db(char *filefrom, char *lockfrom,
         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;
      }
@@ -109,7 +109,8 @@ osa_adb_ret_t osa_adb_rename_db(char *filefrom, char *lockfrom,
 }
 
 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;
@@ -217,6 +218,8 @@ osa_adb_ret_t osa_adb_init_db(osa_adb_db_t *dbp, char *filename,
      db->filename = strdup(filename);
      db->magic = magic;
 
+     db->kadm5_handle = kadm5_handle;
+
      *dbp = db;
      
      return OSA_ADB_OK;
index 7403d31a790ac04074e7cc410d6fc4483304af4d..c44b7ba325959ed45ae4813f81af42f8ace695fd 100644 (file)
@@ -10,7 +10,7 @@ static char *rcsid = "$Header$";
 
 #include       <sys/file.h>
 #include       <fcntl.h>
-#include       "adb.h"
+#include       "server_internal.h"
 #include       <stdlib.h>
 #include       <string.h>
 
@@ -59,11 +59,13 @@ osa_adb_ret_t osa_adb_destroy_policy_db(kadm5_config_params *params)
 }
 
 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)
@@ -140,6 +142,9 @@ osa_adb_create_policy(osa_adb_policy_t db, osa_policy_ent_t entry)
     }
     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;
@@ -197,6 +202,9 @@ osa_adb_destroy_policy(osa_adb_policy_t db, kadm5_policy_t name)
         goto error;
     }
 
+    /* The destroy succeeded, so we should update the generation number. */
+    kdb_update_generation_number(db->kadm5_handle);
+
 error:
     CLOSELOCK(db);
     return ret;
@@ -336,6 +344,9 @@ osa_adb_put_policy(osa_adb_policy_t db, osa_policy_ent_t entry)
     }
     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;
index 231fcb3ef976e48cbf472b4fede99900f55761c3..980bcff157370fbcde3d4388ba56da3504efd310 100644 (file)
@@ -323,6 +323,14 @@ kdb_free_entry(kadm5_server_handle_t handle,
 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;
@@ -330,14 +338,16 @@ kdb_put_entry(kadm5_server_handle_t handle,
     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)) {
@@ -361,6 +371,13 @@ kdb_put_entry(kadm5_server_handle_t handle,
     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);
 }
 
@@ -371,8 +388,15 @@ kdb_delete_entry(kadm5_server_handle_t handle, krb5_principal name)
     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 {
@@ -407,4 +431,31 @@ kdb_iter_entry(kadm5_server_handle_t handle,
     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);
+}
 
index 02c7dced6961fbc6eb4982a42298e768e2088d23..7da6a1a26122765bf34b46c10966d32917531bc3 100644 (file)
@@ -11,7 +11,6 @@ static char *rcsid = "$Header$";
 #include    "k5-int.h"
 #include    <krb5/kdb.h>
 #include    <ctype.h>
-#include    "adb.h"
 #include    <pwd.h>
 
 /* for strcasecmp */
@@ -25,7 +24,8 @@ adb_policy_init(kadm5_server_handle_t handle)
     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;
 }
diff --git a/src/lib/kadm5/srv/svr_generation.c b/src/lib/kadm5/srv/svr_generation.c
new file mode 100644 (file)
index 0000000..eb0fd7e
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * 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;
+}
+
index 1397254e58c3023f37ff1a3a0391b7a5727fcf59..78bc12f34485bbbb59e185be2cb8063b5a3e3f99 100644 (file)
@@ -21,7 +21,6 @@ static char *rcsid = "$Header$";
 #include       <sys/types.h>
 #include       <string.h>
 #include       <kadm5/admin.h>
-#include       "adb.h"
 #include       <dyn.h>
 #ifdef SOLARIS_REGEXPS
 #include       <regexpr.h>
index d03cfd0b67910f8c0efdf0777170ef72841f779d..b828f48a4500b5ce36552e6f9bfd96333b4e0063 100644 (file)
@@ -10,7 +10,6 @@ static char *rcsid = "$Header$";
 
 #include       <sys/types.h>
 #include       <kadm5/admin.h>
-#include       "adb.h"
 #include       "server_internal.h"
 #include       <stdlib.h>
 
index 7552993b10cd9b2f8bdedd34c906670c567d6179..428f76a6a46bd4da63a6fec268e47dbfdc4dd29b 100644 (file)
@@ -11,7 +11,6 @@ static char *rcsid = "$Header$";
 #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>