Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/crypto/krb5/src/kadmin/dbutil/kdb5_destroy.c
34889 views
1
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
/* kadmin/dbutil/kdb5_destroy.c - Destroy a KDC database */
3
/*
4
* Copyright 1990, 2008 by the Massachusetts Institute of Technology.
5
* All Rights Reserved.
6
*
7
* Export of this software from the United States of America may
8
* require a specific license from the United States Government.
9
* It is the responsibility of any person or organization contemplating
10
* export to obtain such a license before exporting.
11
*
12
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
13
* distribute this software and its documentation for any purpose and
14
* without fee is hereby granted, provided that the above copyright
15
* notice appear in all copies and that both that copyright notice and
16
* this permission notice appear in supporting documentation, and that
17
* the name of M.I.T. not be used in advertising or publicity pertaining
18
* to distribution of the software without specific, written prior
19
* permission. Furthermore if you modify this software you must label
20
* your software as modified software and not distribute it in such a
21
* fashion that it might be confused with the original M.I.T. software.
22
* M.I.T. makes no representations about the suitability of
23
* this software for any purpose. It is provided "as is" without express
24
* or implied warranty.
25
*/
26
27
#include "k5-int.h"
28
#include <stdio.h>
29
#include "com_err.h"
30
#include <kadm5/admin.h>
31
#include <kdb.h>
32
#include "kdb5_util.h"
33
34
extern int exit_status;
35
extern krb5_boolean dbactive;
36
extern kadm5_config_params global_params;
37
38
char *yes = "yes\n"; /* \n to compare against result of
39
fgets */
40
41
void
42
kdb5_destroy(int argc, char *argv[])
43
{
44
extern int optind;
45
int optchar;
46
char *dbname;
47
char buf[5];
48
krb5_error_code retval1;
49
int force = 0;
50
51
dbname = global_params.dbname;
52
53
optind = 1;
54
while ((optchar = getopt(argc, argv, "f")) != -1) {
55
switch(optchar) {
56
case 'f':
57
force++;
58
break;
59
case '?':
60
default:
61
usage();
62
return;
63
/*NOTREACHED*/
64
}
65
}
66
if (!force) {
67
printf(_("Deleting KDC database stored in '%s', are you sure?\n"),
68
dbname);
69
printf(_("(type 'yes' to confirm)? "));
70
if (fgets(buf, sizeof(buf), stdin) == NULL) {
71
exit_status++; return;
72
}
73
if (strcmp(buf, yes)) {
74
exit_status++; return;
75
}
76
printf(_("OK, deleting database '%s'...\n"), dbname);
77
}
78
79
retval1 = krb5_db_destroy(util_context, db5util_db_args);
80
if (retval1) {
81
com_err(progname, retval1, _("deleting database '%s'"), dbname);
82
exit_status++; return;
83
}
84
85
if (global_params.iprop_enabled) {
86
(void) unlink(global_params.iprop_logfile);
87
}
88
89
dbactive = FALSE;
90
printf(_("** Database '%s' destroyed.\n"), dbname);
91
return;
92
}
93
94