1 /*
2 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
5
6 #pragma ident "@(#)kdb5_destroy.c 1.8 04/09/08 SMI"
7
8 /*
9 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
10 *
11 * Openvision retains the copyright to derivative works of
12 * this source code. Do *NOT* create a derivative of this
13 * source code before consulting with your legal department.
14 * Do *NOT* integrate *ANY* of this source code into another
15 * product before consulting with your legal department.
16 *
17 * For further information, read the top-level Openvision
18 * copyright which is contained in the top-level MIT Kerberos
19 * copyright.
20 *
21 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
22 *
23 */
24
25
26 /*
63 #define krb5_dbm_db_set_nonblocking krb5_db_set_nonblocking
64 #define krb5_dbm_db_init krb5_db_init
65 #define krb5_dbm_db_get_age krb5_db_get_age
66 #define krb5_dbm_db_create krb5_db_create
67 #define krb5_dbm_db_rename krb5_db_rename
68 #define krb5_dbm_db_get_principal krb5_db_get_principal
69 #define krb5_dbm_db_free_principal krb5_db_free_principal
70 #define krb5_dbm_db_put_principal krb5_db_put_principal
71 #define krb5_dbm_db_delete_principal krb5_db_delete_principal
72 #define krb5_dbm_db_lock krb5_db_lock
73 #define krb5_dbm_db_unlock krb5_db_unlock
74 #define krb5_dbm_db_set_lockmode krb5_db_set_lockmode
75 #define krb5_dbm_db_close_database krb5_db_close_database
76 #define krb5_dbm_db_open_database krb5_db_open_database
77
78 #include <stdio.h>
79 #include "com_err.h"
80 #include <kadm5/admin.h>
81 #include <kadm5/adb.h>
82 #include <libintl.h>
83
84 extern int errno;
85 extern int exit_status;
86 extern krb5_boolean dbactive;
87 extern kadm5_config_params global_params;
88
89
90 void
91 kdb5_destroy(argc, argv)
92 int argc;
93 char *argv[];
94 {
95 extern char *optarg;
96 extern int optind;
97 int optchar;
98 char *dbname;
99 char buf[5];
100 char dbfilename[MAXPATHLEN];
101 krb5_error_code retval, retval1, retval2;
102 krb5_context context;
103
104 krb5_init_context(&context);
105
106 if (strrchr(argv[0], '/'))
107 argv[0] = strrchr(argv[0], '/')+1;
108
109 dbname = global_params.dbname;
110
111 printf(gettext("Deleting KDC database stored in '%s', "
112 "are you sure?\n"), dbname);
113 printf(gettext("(type 'yes' or 'y' to confirm)? "));
114
115 if (fgets(buf, sizeof (buf), stdin) == NULL) {
116 exit_status++;
117 return;
118 }
119 if ((strncmp(buf, gettext("yes\n"),
120 strlen(gettext("yes\n"))) != 0) &&
121 (strncmp(buf, gettext("y\n"),
122 strlen(gettext("y\n"))) != 0)) {
151 MAXPATHLEN-strlen(stash)));
152 global_params.stash_file = (char *)strdup(stash);
153 }
154 if (!access(global_params.stash_file, F_OK))
155 (void)unlink(global_params.stash_file);
156
157 retval2 = osa_adb_destroy_policy_db(&global_params);
158 if (retval1) {
159 com_err(argv[0], retval1,
160 gettext("deleting database '%s'"), dbname);
161 exit_status++;
162 return;
163 }
164 if (retval2) {
165 com_err(argv[0], retval2,
166 gettext("destroying policy database"));
167 exit_status++;
168 return;
169 }
170
171 dbactive = FALSE;
172 printf(gettext("** Database '%s' destroyed.\n"), dbname);
173 }
|
1 /*
2 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
5
6 #pragma ident "@(#)kdb5_destroy.c 1.7 04/05/04 SMI"
7
8 /*
9 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
10 *
11 * Openvision retains the copyright to derivative works of
12 * this source code. Do *NOT* create a derivative of this
13 * source code before consulting with your legal department.
14 * Do *NOT* integrate *ANY* of this source code into another
15 * product before consulting with your legal department.
16 *
17 * For further information, read the top-level Openvision
18 * copyright which is contained in the top-level MIT Kerberos
19 * copyright.
20 *
21 * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
22 *
23 */
24
25
26 /*
63 #define krb5_dbm_db_set_nonblocking krb5_db_set_nonblocking
64 #define krb5_dbm_db_init krb5_db_init
65 #define krb5_dbm_db_get_age krb5_db_get_age
66 #define krb5_dbm_db_create krb5_db_create
67 #define krb5_dbm_db_rename krb5_db_rename
68 #define krb5_dbm_db_get_principal krb5_db_get_principal
69 #define krb5_dbm_db_free_principal krb5_db_free_principal
70 #define krb5_dbm_db_put_principal krb5_db_put_principal
71 #define krb5_dbm_db_delete_principal krb5_db_delete_principal
72 #define krb5_dbm_db_lock krb5_db_lock
73 #define krb5_dbm_db_unlock krb5_db_unlock
74 #define krb5_dbm_db_set_lockmode krb5_db_set_lockmode
75 #define krb5_dbm_db_close_database krb5_db_close_database
76 #define krb5_dbm_db_open_database krb5_db_open_database
77
78 #include <stdio.h>
79 #include "com_err.h"
80 #include <kadm5/admin.h>
81 #include <kadm5/adb.h>
82 #include <libintl.h>
83 #include "kdb5_util.h"
84
85 extern int errno;
86 extern int exit_status;
87 extern krb5_boolean dbactive;
88 extern kadm5_config_params global_params;
89
90
91 void
92 kdb5_destroy(argc, argv)
93 int argc;
94 char *argv[];
95 {
96 extern char *optarg;
97 extern int optind;
98 int optchar;
99 char *dbname;
100 char buf[5];
101 char dbfilename[MAXPATHLEN];
102 krb5_error_code retval, retval1, retval2;
103 krb5_context context;
104 char ufilename[MAX_FILENAME];
105
106 krb5_init_context(&context);
107
108 if (strrchr(argv[0], '/'))
109 argv[0] = strrchr(argv[0], '/')+1;
110
111 dbname = global_params.dbname;
112
113 printf(gettext("Deleting KDC database stored in '%s', "
114 "are you sure?\n"), dbname);
115 printf(gettext("(type 'yes' or 'y' to confirm)? "));
116
117 if (fgets(buf, sizeof (buf), stdin) == NULL) {
118 exit_status++;
119 return;
120 }
121 if ((strncmp(buf, gettext("yes\n"),
122 strlen(gettext("yes\n"))) != 0) &&
123 (strncmp(buf, gettext("y\n"),
124 strlen(gettext("y\n"))) != 0)) {
153 MAXPATHLEN-strlen(stash)));
154 global_params.stash_file = (char *)strdup(stash);
155 }
156 if (!access(global_params.stash_file, F_OK))
157 (void)unlink(global_params.stash_file);
158
159 retval2 = osa_adb_destroy_policy_db(&global_params);
160 if (retval1) {
161 com_err(argv[0], retval1,
162 gettext("deleting database '%s'"), dbname);
163 exit_status++;
164 return;
165 }
166 if (retval2) {
167 com_err(argv[0], retval2,
168 gettext("destroying policy database"));
169 exit_status++;
170 return;
171 }
172
173 if (global_params.iprop_enabled) {
174 if (strlcpy(ufilename, dbname, MAX_FILENAME) >= MAX_FILENAME) {
175 exit_status++;
176 return;
177 }
178 if (strlcat(ufilename, ".ulog", MAX_FILENAME) >= MAX_FILENAME) {
179 exit_status++;
180 return;
181 }
182
183 (void) unlink(ufilename);
184 }
185
186 dbactive = FALSE;
187 printf(gettext("** Database '%s' destroyed.\n"), dbname);
188 }
|