delete functions in '#if 0'
authorKen Raeburn <raeburn@mit.edu>
Sat, 2 Jul 2005 01:53:58 +0000 (01:53 +0000)
committerKen Raeburn <raeburn@mit.edu>
Sat, 2 Jul 2005 01:53:58 +0000 (01:53 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@17285 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/kdb/kdb_db2/kdb_db2.c

index 6f29326b0d02df319488c41d7aa7d373594e1f1f..2bcfae1aad167b02435519ffacfb434d669e6a39 100644 (file)
@@ -382,26 +382,6 @@ krb5_db2_db_fini(krb5_context context)
     return retval;
 }
 
-#if 0                          /* pradx */
-
-krb5_error_code
-krb5_db2_db_open_database(krb5_context context)
-{
-    if (!k5db2_inited(context))
-       return KRB5_KDB_DBNOTINITED;
-    return 0;
-}
-
-krb5_error_code
-krb5_db2_db_close_database(krb5_context context)
-{
-    if (!k5db2_inited(context))
-       return KRB5_KDB_DBNOTINITED;
-    return 0;
-}
-
-#endif /* 0 -pradx */
-
 /*
  * Set/Get the master key associated with the database
  */
@@ -860,114 +840,6 @@ krb5_db2_db_destroy(krb5_context context, char *dbname)
     return retval1;
 }
 
-#if 0                          /* -pradx */
-
-/*
- * "Atomically" rename the database in a way that locks out read
- * access in the middle of the rename.
- *
- * Not perfect; if we crash in the middle of an update, we don't
- * necessarily know to complete the transaction the rename, but...
- *
- * Since the rename operation happens outside the init/fini bracket, we
- * have to go through the same stuff that we went through up in db_destroy.
- */
-krb5_error_code
-krb5_db2_db_rename(krb5_context context, char *from, char *to)
-{
-    DB     *db;
-    char   *fromok;
-    krb5_error_code retval;
-    kdb5_dal_handle *dal_handle;
-    krb5_db2_context *s_context, *db_ctx;
-
-    dal_handle = (kdb5_dal_handle *) context->db_context;
-    s_context = dal_handle->db_context;
-    dal_handle->db_context = NULL;
-    if ((retval = k5db2_init_context(context)))
-       return retval;
-    db_ctx =
-       (krb5_db2_context *) ((kdb5_dal_handle *) context->db_context)->
-       db_context;
-
-    /*
-     * Create the database if it does not already exist; the
-     * files must exist because krb5_db2_db_lock, called below,
-     * will fail otherwise.
-     */
-    db = k5db2_dbopen(db_ctx, to, O_RDWR | O_CREAT, 0600);
-    if (db == NULL) {
-       retval = errno;
-       goto errout;
-    } else
-       (*db->close) (db);
-    /*
-     * Set the database to the target, so that other processes sharing
-     * the target will stop their activity, and notice the new database.
-     */
-    retval = krb5_db2_db_set_name(context, to);
-    if (retval)
-       goto errout;
-
-    db_ctx->db_lf_name = gen_dbsuffix(db_ctx->db_name, KDB2_LOCK_EXT);
-    if (db_ctx->db_lf_name == NULL) {
-       retval = ENOMEM;
-       goto errout;
-    }
-    db_ctx->db_lf_file = open(db_ctx->db_lf_name, O_RDWR | O_CREAT, 0600);
-    if (db_ctx->db_lf_file < 0) {
-       retval = errno;
-       goto errout;
-    }
-
-    db_ctx->db_inited = 1;
-
-    retval = krb5_db2_db_get_age(context, NULL, &db_ctx->db_lf_time);
-    if (retval)
-       goto errout;
-
-    fromok = gen_dbsuffix(from, KDB2_LOCK_EXT);
-    if (fromok == NULL) {
-       retval = ENOMEM;
-       goto errout;
-    }
-
-    if ((retval = krb5_db2_db_lock(context, KRB5_LOCKMODE_EXCLUSIVE)))
-       goto errfromok;
-
-    if ((retval = krb5_db2_db_start_update(context)))
-       goto errfromok;
-
-    if (rename(from, to)) {
-       retval = errno;
-       goto errfromok;
-    }
-    if (unlink(fromok)) {
-       retval = errno;
-       goto errfromok;
-    }
-    retval = krb5_db2_db_end_update(context);
-  errfromok:
-    free_dbsuffix(fromok);
-  errout:
-    if (((kdb5_dal_handle *) context->db_context)->db_context) {
-       if (db_ctx->db_lf_file >= 0) {
-           krb5_db2_db_unlock(context);
-           close(db_ctx->db_lf_file);
-       }
-       k5db2_clear_context((krb5_db2_context *) ((kdb5_dal_handle *) context->
-                                                 db_context)->db_context);
-       free(((kdb5_dal_handle *) context->db_context)->db_context);
-    }
-
-    ((kdb5_dal_handle *) context->db_context)->db_context = s_context;
-    (void) krb5_db2_db_unlock(context);        /* unlock saved context db */
-
-    return retval;
-}
-
-#endif /* 0 - pradx */
-
 /*
  * look up a principal in the data base.
  * returns number of entries found, and whether there were
@@ -1326,210 +1198,6 @@ krb5_db2_db_set_lockmode(krb5_context context, krb5_boolean mode)
     return old;
 }
 
-#if 0                          /* -pradx */
-/*
- * Context serialization operations.
- *
- * Ick, this is really gross. --- tlyu
- */
-
-/*
- * kdb5_context_size() - Determine size required to serialize.
- */
-static krb5_error_code
-kdb5_context_size(krb5_context kcontext, krb5_pointer arg, size_t *sizep)
-{
-    krb5_error_code kret;
-    size_t  required;
-    krb5_db2_context *dbctx;
-
-    /*
-     * The database context requires at minimum:
-     *  krb5_int32      for KV5M_DB_CONTEXT
-     *  krb5_int32      for db_inited
-     *  krb5_int32      for database lockfile non-blocking flag
-     *  krb5_int32      for database lockfile lock count
-     *  krb5_int32      for database lockfile lock mode
-     *  krb5_int32      for length of database name.
-     *  krb5_int32      for KV5M_DB_CONTEXT
-     */
-    kret = EINVAL;
-    if ((dbctx = (krb5_db2_context *) arg)) {
-       required = (sizeof(krb5_int32) * 7);
-       if (dbctx->db_inited && dbctx->db_name)
-           required += strlen(dbctx->db_name);
-       kret = 0;
-       *sizep += required;
-    }
-    return (kret);
-}
-\f
-/*
- * kdb5_context_externalize()  - Externalize the database context.
- */
-static krb5_error_code
-kdb5_context_externalize(krb5_context kcontext, krb5_pointer arg,
-                        krb5_octet **buffer, size_t *lenremain)
-{
-    krb5_error_code kret;
-    krb5_db2_context *dbctx;
-    size_t  required;
-    krb5_octet *bp;
-    size_t  remain;
-
-    required = 0;
-    bp = *buffer;
-    remain = *lenremain;
-    kret = EINVAL;
-    if ((dbctx = (krb5_db2_context *) arg)) {
-       kret = ENOMEM;
-       if (!kdb5_context_size(kcontext, arg, &required) &&
-           (required <= remain)) {
-           /* Write magic number */
-           (void) krb5_ser_pack_int32(KV5M_DB_CONTEXT, &bp, &remain);
-
-           /* Write inited flag */
-           (void) krb5_ser_pack_int32((krb5_int32) dbctx->db_inited,
-                                      &bp, &remain);
-
-           /* Write blocking lock lockmode */
-           (void) krb5_ser_pack_int32((krb5_int32) dbctx->db_nb_locks,
-                                      &bp, &remain);
-
-           /* Write lock count */
-           (void) krb5_ser_pack_int32((krb5_int32)
-                                      (dbctx->db_inited) ?
-                                      dbctx->db_locks_held : 0, &bp, &remain);
-
-           /* Write lock mode */
-           (void) krb5_ser_pack_int32((krb5_int32)
-                                      (dbctx->db_inited) ?
-                                      dbctx->db_lock_mode : 0, &bp, &remain);
-
-           /* Write length of database name */
-           (void) krb5_ser_pack_int32((dbctx->db_inited && dbctx->db_name) ?
-                                      (krb5_int32) strlen(dbctx->db_name) : 0,
-                                      &bp, &remain);
-           if (dbctx->db_inited && dbctx->db_name)
-               (void) krb5_ser_pack_bytes((krb5_octet *) dbctx->db_name,
-                                          strlen(dbctx->db_name),
-                                          &bp, &remain);
-
-           /* Write trailer */
-           (void) krb5_ser_pack_int32(KV5M_DB_CONTEXT, &bp, &remain);
-           kret = 0;
-           *buffer = bp;
-           *lenremain = remain;
-       }
-    }
-    return (kret);
-}
-\f
-/*
- * kdb5_context_internalize()  - Internalize the database context.
- */
-static krb5_error_code
-kdb5_context_internalize(krb5_context kcontext,
-                        krb5_pointer *argp,
-                        krb5_octet **buffer,
-                        size_t *lenremain)
-{
-    krb5_error_code kret;
-    krb5_context tmpctx;
-    krb5_db2_context *dbctx;
-    krb5_int32 ibuf;
-    krb5_octet *bp;
-    size_t  remain;
-    krb5_int32 iflag;
-    krb5_int32 nb_lockmode;
-    krb5_int32 lockcount;
-    krb5_int32 lockmode;
-    krb5_int32 dbnamelen;
-    krb5_boolean nb_lock;
-    char   *dbname;
-
-    bp = *buffer;
-    remain = *lenremain;
-    kret = EINVAL;
-    dbctx = (krb5_db2_context *) NULL;
-    /* Read our magic number */
-    if (krb5_ser_unpack_int32(&ibuf, &bp, &remain))
-       ibuf = 0;
-    if (ibuf == KV5M_DB_CONTEXT) {
-       kret = ENOMEM;
-
-       if (!(kret = krb5_ser_unpack_int32(&iflag, &bp, &remain)) &&
-           !(kret = krb5_ser_unpack_int32(&nb_lockmode, &bp, &remain)) &&
-           !(kret = krb5_ser_unpack_int32(&lockcount, &bp, &remain)) &&
-           !(kret = krb5_ser_unpack_int32(&lockmode, &bp, &remain)) &&
-           !(kret = krb5_ser_unpack_int32(&dbnamelen, &bp, &remain)) &&
-           !(kret = krb5_init_context(&tmpctx))) {
-           if (iflag) {
-               dbname = (char *) NULL;
-               if (dbnamelen &&
-                   (dbname = (char *) malloc((size_t) (dbnamelen + 1)))) {
-                   kret = krb5_ser_unpack_bytes((krb5_octet *) dbname,
-                                                (size_t) dbnamelen,
-                                                &bp, &remain);
-                   if (!kret)
-                       dbname[dbnamelen] = '\0';
-               }
-               if (!kret &&
-                   (!dbname || !(kret = krb5_db_set_name(tmpctx, dbname))) &&
-                   !(kret = krb5_db_init(tmpctx))) {
-                   dbctx = (krb5_db2_context *) tmpctx->db_context;
-                   (void) krb5_db2_db_set_lockmode(tmpctx, 0);
-                   if (lockmode)
-                       kret = krb5_db2_db_lock(tmpctx, lockmode);
-                   if (!kret && lockmode)
-                       dbctx->db_locks_held = lockcount;
-                   nb_lock = nb_lockmode & 0xff;
-                   (void) krb5_db2_db_set_lockmode(tmpctx, nb_lock);
-               }
-               if (dbname)
-                   krb5_xfree(dbname);
-           }
-           if (!kret)
-               kret = krb5_ser_unpack_int32(&ibuf, &bp, &remain);
-           if (kret || (ibuf != KV5M_DB_CONTEXT))
-               kret = EINVAL;
-
-           if (kret) {
-               if (dbctx)
-                   krb5_db_fini(tmpctx);
-           } else
-               tmpctx->db_context = NULL;
-           krb5_free_context(tmpctx);
-       }
-    }
-    if (!kret) {
-       *buffer = bp;
-       *lenremain = remain;
-       *argp = (krb5_pointer) dbctx;
-    }
-    return (kret);
-}
-
-/* Dispatch entry */
-static const krb5_ser_entry kdb5_context_ser_entry = {
-    KV5M_DB_CONTEXT,           /* Type                 */
-    kdb5_context_size,         /* Sizer routine        */
-    kdb5_context_externalize,  /* Externalize routine  */
-    kdb5_context_internalize   /* Externalize routine  */
-};
-
-/*
- * Register serializer.
- */
-krb5_error_code
-krb5_ser_db_context_init(kcontext)
-    krb5_context kcontext;
-{
-    return (krb5_register_serializer(kcontext, &kdb5_context_ser_entry));
-}
-
-#endif /* 0 - pradx */
-
 /*
  *     DAL API functions
  */