From a6985818378387da012a32898ee50054c48da06b Mon Sep 17 00:00:00 2001 From: John Kohl Date: Fri, 4 Jan 1991 14:51:45 +0000 Subject: [PATCH] some better error interpretation and sequencing when a database exists already git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1616 dc483132-0cff-0310-8789-dd5450dbe970 --- src/admin/create/kdb5_create.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/admin/create/kdb5_create.c b/src/admin/create/kdb5_create.c index a4d436bd9..e0e2de6d2 100644 --- a/src/admin/create/kdb5_create.c +++ b/src/admin/create/kdb5_create.c @@ -173,13 +173,12 @@ char *argv[]; if (!dbname) dbname = DEFAULT_DBM_FILE; /* XXX? */ - if (retval = krb5_db_create(dbname)) { - com_err(argv[0], retval, "while creating database '%s'", - dbname); - exit(1); - } - if (retval = krb5_db_set_name(dbname)) { - com_err(argv[0], retval, "while setting active database to '%s'", + retval = krb5_db_set_name(dbname); + if (!retval) retval = EEXIST; + + if (retval == EEXIST || retval == EACCES || retval == EPERM) { + /* it exists ! */ + com_err(argv[0], 0, "The database '%s' appears to already exist", dbname); exit(1); } @@ -228,6 +227,20 @@ master key name '%s'\n", (void) krb5_finish_key(&master_encblock); exit(1); } + if (retval = krb5_db_create(dbname)) { + (void) krb5_finish_key(&master_encblock); + (void) krb5_finish_random_key(&master_encblock, &rblock.rseed); + com_err(argv[0], retval, "while creating database '%s'", + dbname); + exit(1); + } + if (retval = krb5_db_set_name(dbname)) { + (void) krb5_finish_key(&master_encblock); + (void) krb5_finish_random_key(&master_encblock, &rblock.rseed); + com_err(argv[0], retval, "while setting active database to '%s'", + dbname); + exit(1); + } if (retval = krb5_db_init()) { (void) krb5_finish_key(&master_encblock); (void) krb5_finish_random_key(&master_encblock, &rblock.rseed); -- 2.26.2