1994-09-30 14:50:09 +00:00
|
|
|
/*
|
|
|
|
* Copyright 1988 by the Massachusetts Institute of Technology.
|
|
|
|
* For copying and distribution information, please see the file
|
|
|
|
* <Copyright.MIT>.
|
|
|
|
*
|
|
|
|
* from: kdb_destroy.c,v 4.0 89/01/24 21:49:02 jtkohl Exp $
|
1995-08-25 22:52:32 +00:00
|
|
|
* $Id: kdb_destroy.c,v 1.5 1995/08/04 06:35:45 mark Exp $
|
1994-09-30 14:50:09 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef lint
|
|
|
|
static char rcsid[] =
|
1995-08-25 22:52:32 +00:00
|
|
|
"$Id: kdb_destroy.c,v 1.5 1995/08/04 06:35:45 mark Exp $";
|
1994-09-30 14:50:09 +00:00
|
|
|
#endif lint
|
|
|
|
|
|
|
|
#include <strings.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "krb.h"
|
|
|
|
#include "krb_db.h"
|
|
|
|
|
1995-08-25 22:52:32 +00:00
|
|
|
#if defined(__FreeBSD__) || defined(__NetBSD__)
|
1995-08-02 23:08:18 +00:00
|
|
|
#define DB
|
|
|
|
#endif
|
|
|
|
|
1995-08-25 22:52:32 +00:00
|
|
|
|
1994-09-30 14:50:09 +00:00
|
|
|
main()
|
|
|
|
{
|
|
|
|
char answer[10]; /* user input */
|
|
|
|
char dbm[256]; /* database path and name */
|
|
|
|
char dbm1[256]; /* database path and name */
|
1995-08-02 23:08:18 +00:00
|
|
|
#ifdef DB
|
1995-01-25 19:57:27 +00:00
|
|
|
char *file; /* database file names */
|
1995-08-02 23:08:18 +00:00
|
|
|
#else
|
|
|
|
char *file1, *file2; /* database file names */
|
1995-01-25 19:57:27 +00:00
|
|
|
#endif
|
1994-09-30 14:50:09 +00:00
|
|
|
|
|
|
|
strcpy(dbm, DBM_FILE);
|
1995-08-04 03:02:30 +00:00
|
|
|
#ifdef DB
|
1995-08-02 23:08:18 +00:00
|
|
|
file = strcat(dbm, ".db");
|
|
|
|
#else
|
1994-09-30 14:50:09 +00:00
|
|
|
strcpy(dbm1, DBM_FILE);
|
|
|
|
file1 = strcat(dbm, ".dir");
|
|
|
|
file2 = strcat(dbm1, ".pag");
|
1995-01-25 19:57:27 +00:00
|
|
|
#endif
|
1994-09-30 14:50:09 +00:00
|
|
|
|
|
|
|
printf("You are about to destroy the Kerberos database ");
|
|
|
|
printf("on this machine.\n");
|
|
|
|
printf("Are you sure you want to do this (y/n)? ");
|
|
|
|
fgets(answer, sizeof(answer), stdin);
|
|
|
|
|
|
|
|
if (answer[0] == 'y' || answer[0] == 'Y') {
|
1995-08-02 23:08:18 +00:00
|
|
|
#ifdef DB
|
1995-01-25 19:57:27 +00:00
|
|
|
if (unlink(file) == 0)
|
1995-08-02 23:08:18 +00:00
|
|
|
#else
|
|
|
|
if (unlink(file1) == 0 && unlink(file2) == 0)
|
1995-01-25 19:57:27 +00:00
|
|
|
#endif
|
1994-09-30 14:50:09 +00:00
|
|
|
fprintf(stderr, "Database deleted at %s\n", DBM_FILE);
|
|
|
|
else
|
|
|
|
fprintf(stderr, "Database cannot be deleted at %s\n",
|
|
|
|
DBM_FILE);
|
|
|
|
} else
|
|
|
|
fprintf(stderr, "Database not deleted.\n");
|
|
|
|
}
|