From: John Kohl Date: Fri, 27 Apr 1990 15:38:25 +0000 (+0000) Subject: add .ok file X-Git-Tag: krb5-1.0-alpha2~784 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e84b187a7069bfcec4f9977cf0d0043ca0e67ca0;p=krb5.git add .ok file clean up & make work git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@612 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/admin/destroy/kdb5_destroy.c b/src/admin/destroy/kdb5_destroy.c index 936aaceee..2ce668245 100644 --- a/src/admin/destroy/kdb5_destroy.c +++ b/src/admin/destroy/kdb5_destroy.c @@ -24,10 +24,14 @@ static char rcsid_kdb_dest_c[] = #include #include +#include +#include +#include #include +#include /* for unlink() */ -#include /* XXX */ +#include /* XXX for MAXPATHLEN */ extern int errno; @@ -39,10 +43,11 @@ usage(who, status) char *who; int status; { - fprintf(stderr, "usage: %s [-n dbname]\n", who); + fprintf(stderr, "usage: %s [-d dbpathname]\n", who); exit(status); } +void main(argc, argv) int argc; char *argv[]; @@ -54,9 +59,16 @@ char *argv[]; char dbfilename[MAXPATHLEN]; krb5_error_code retval; + initialize_krb5_error_table(); + initialize_kdb5_error_table(); + initialize_isod_error_table(); + + if (rindex(argv[0], '/')) + argv[0] = rindex(argv[0], '/')+1; + while ((optchar = getopt(argc, argv, "n:")) != EOF) { switch(optchar) { - case 'n': /* set db name */ + case 'd': /* set db name */ dbname = optarg; break; case '?': @@ -89,6 +101,15 @@ char *argv[]; "Database partially deleted--inspect files manually!\n"); exit(1); } + (void) strcpy(dbfilename, dbname); + (void) strcat(dbfilename, ".ok"); + if (unlink(dbfilename) == -1) { + retval = errno; + com_err(argv[0], retval, "deleting database file '%s'",dbfilename); + fprintf(stderr, + "Database partially deleted--inspect files manually!\n"); + exit(1); + } printf("** Database '%s' destroyed.\n", dbname); exit(0); }