summaryrefslogtreecommitdiffstats
path: root/eBones/usr.sbin/kdb_destroy/kdb_destroy.c
blob: 57e1a80a6b9c95053a8cedb468382fc6738cfdc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * 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 $
 *	$Id: kdb_destroy.c,v 1.5 1995/08/04 06:35:45 mark Exp $
 */

#if 0
#ifndef	lint
static char rcsid[] =
"$Id: kdb_destroy.c,v 1.5 1995/08/04 06:35:45 mark Exp $";
#endif	lint
#endif

#include <unistd.h>
#include <strings.h>
#include <stdio.h>
#include <krb.h>
#include <krb_db.h>

#if defined(__FreeBSD__) || defined(__NetBSD__)
#define	_DBM_
#endif

void
main()
{
    char    answer[10];		/* user input */
#ifdef _DBM_
    char    dbm[256];		/* database path and name */
    char   *file;               /* database file names */
#else
    char    dbm[256];		/* database path and name */
    char    dbm1[256];		/* database path and name */
    char   *file1, *file2;	/* database file names */
#endif

    strcpy(dbm, DBM_FILE);
#ifdef _DBM_
    file = strcat(dbm, ".db");
#else
    strcpy(dbm1, DBM_FILE);
    file1 = strcat(dbm, ".dir");
    file2 = strcat(dbm1, ".pag");
#endif

    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') {
#ifdef _DBM_
	if (unlink(file) == 0)
#else
	if (unlink(file1) == 0 && unlink(file2) == 0)
#endif
	    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");
}
OpenPOWER on IntegriCloud