4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
21 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
22 * Use is subject to license terms.
35 kc_delete(int argc
, char *argv
[])
38 KMF_RETURN kmfrv
= KMF_OK
;
41 extern char *optarg_av
;
42 char *filename
= NULL
;
43 char *policyname
= NULL
;
45 while ((opt
= getopt_av(argc
, argv
, "i:(dbfile)p:(policy)")) != EOF
) {
48 filename
= get_string(optarg_av
, &rv
);
49 if (filename
== NULL
) {
50 (void) fprintf(stderr
,
51 gettext("Error dbfile input.\n"));
55 policyname
= get_string(optarg_av
, &rv
);
56 if (policyname
== NULL
) {
57 (void) fprintf(stderr
,
58 gettext("Error policy name.\n"));
62 (void) fprintf(stderr
,
63 gettext("Error input option.\n"));
73 /* No additional args allowed. */
76 (void) fprintf(stderr
,
77 gettext("Error input option\n"));
82 if (filename
== NULL
) {
83 filename
= strdup(KMF_DEFAULT_POLICY_FILE
);
84 if (filename
== NULL
) {
91 * Must have a policy name. The policy name can not be default
92 * if using the default policy file.
94 if (policyname
== NULL
) {
95 (void) fprintf(stderr
,
96 gettext("You must specify a policy name\n"));
99 } else if (strcmp(filename
, KMF_DEFAULT_POLICY_FILE
) == 0 &&
100 strcmp(policyname
, KMF_DEFAULT_POLICY_NAME
) == 0) {
101 (void) fprintf(stderr
,
102 gettext("Can not delete the default policy in the default "
108 /* Check the access permission of the policy DB */
109 if (access(filename
, W_OK
) < 0) {
111 (void) fprintf(stderr
,
112 gettext("Cannot access \"%s\" for delete - %s\n"),
113 filename
, strerror(err
));
118 kmfrv
= kmf_delete_policy_from_db(policyname
, filename
);
120 rv
= KC_ERR_DELETE_POLICY
;