From f81d3b6805418c49323ff79c3d1ad347b4048fa2 Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Tue, 5 Feb 1991 13:25:46 +0000 Subject: [PATCH] Changed so that kdb5_edit can be run even if there is no valid database. (Needed for slave propagation to do the load_db request). Added backout code to load_db so that if there is an error, the newly created database will be deleted. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1649 dc483132-0cff-0310-8789-dd5450dbe970 --- src/admin/edit/dump.c | 59 ++++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 17 deletions(-) diff --git a/src/admin/edit/dump.c b/src/admin/edit/dump.c index 465f7b98f..234034462 100644 --- a/src/admin/edit/dump.c +++ b/src/admin/edit/dump.c @@ -1,19 +1,19 @@ /* - * $Source$ - * $Author$ + * $source: /afs/athena.mit.edu/astaff/project/krb5/src/admin/edit/rcs/dump.c,v $ + * $author: tytso $ * - * Copyright 1990 by the Massachusetts Institute of Technology. + * copyright 1990 by the massachusetts institute of technology. * - * For copying and distribution information, please see the file + * for copying and distribution information, please see the file * . * - * Dump a KDC database + * dump a kdc database */ -#if !defined(lint) && !defined(SABER) +#if !defined(lint) && !defined(saber) static char rcsid_kdb_edit_c[] = -"$Id$"; -#endif /* !lint & !SABER */ +"$id: dump.c,v 1.6 91/01/15 18:25:41 tytso exp locker: tytso $"; +#endif /* !lint & !saber */ #include #include @@ -22,7 +22,7 @@ static char rcsid_kdb_edit_c[] = #include #include #include -#include /* for MAXPATHLEN */ +#include /* for maxpathlen */ #include #include @@ -31,10 +31,7 @@ static char rcsid_kdb_edit_c[] = #include extern char *progname; - - -#define REALM_SEP '@' -#define REALM_SEP_STR "@" +extern char *Err_no_database; struct mblock { krb5_deltat max_life; @@ -99,6 +96,10 @@ void dump_db(argc, argv) com_err(argv[0], 0, "Usage: %s filename", argv[0]); return; } + if (!dbactive) { + com_err(argv[0], 0, Err_no_database); + return; + } if (argc == 2) { /* * Make sure that we don't open and truncate on the fopen, @@ -166,6 +167,7 @@ void load_db(argc, argv) int name_len, mod_name_len,i,one; char *name, *mod_name; char *new_dbname; + int load_error = 0; if (argc != 3) { com_err(argv[0], 0, "Usage: %s filename dbname", argv[0]); @@ -215,12 +217,14 @@ void load_db(argc, argv) if (!(name = malloc(name_len+1))) { com_err(argv[0], errno, "While allocating speace for name"); + load_error++; break; } if (!(mod_name = malloc(mod_name_len+1))) { free(name); com_err(argv[0], errno, "While allocating speace for name"); + load_error++; break; } fscanf(f, "%s\t%d\t%d\t", name, &entry.key.keytype, @@ -230,6 +234,7 @@ void load_db(argc, argv) free(mod_name); com_err(argv[0], errno, "While allocating speace for name"); + load_error++; break; } for (i=0; i