source: trunk/third/cns/src/admin/kdb_destroy.c @ 8789

Revision 8789, 1.3 KB checked in by ghudson, 28 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r8788, which included commits to RCS files with non-trunk default branches.
Line 
1/*
2 * Copyright 1988 by the Massachusetts Institute of Technology.
3 *
4 * For copying and distribution information, please see the file
5 * <mit-copyright.h>.
6 *
7 * Description.
8 */
9
10#include <mit-copyright.h>
11#include <string.h>
12#include <stdio.h>
13#include "krb.h"
14#include "krb_db.h"
15
16main(argc, argv)
17    int argc;
18    char **argv;
19{
20    char    answer[10];         /* user input */
21    char    dbm[256];           /* database path and name */
22    char    dbm1[256];          /* database path and name */
23    char   *file1, *file2;      /* database file names */
24
25    if (argc > 1) {
26        if (argc > 3) {
27            fprintf(stderr, "Usage: %s [database name]\n", argv[0]);
28            exit(1);
29        }
30        strcpy(dbm, argv[1]);
31        strcpy(dbm1, argv[1]);
32    } else {
33        strcpy(dbm, DBM_FILE);
34        strcpy(dbm1, DBM_FILE);
35    }
36    file1 = strcat(dbm, ".dir");
37    file2 = strcat(dbm1, ".pag");
38
39    printf("You are about to destroy the Kerberos database %s ",file1);
40    printf("on this machine.\n");
41    printf("Are you sure you want to do this (y/n)? ");
42    fgets(answer, sizeof(answer), stdin);
43
44    if (answer[0] == 'y' || answer[0] == 'Y') {
45        if (unlink(file1) == 0 && unlink(file2) == 0)
46            fprintf(stderr, "Database deleted at %s\n", file1);
47        else
48            fprintf(stderr, "Database cannot be deleted at %s\n",
49                    DBM_FILE);
50    } else
51        fprintf(stderr, "Database not deleted.\n");
52}
Note: See TracBrowser for help on using the repository browser.