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.
25 #pragma ident "%Z%%M% %I% %E% SMI"
37 kc_delete(int argc
, char *argv
[])
40 KMF_RETURN kmfrv
= KMF_OK
;
43 extern char *optarg_av
;
44 char *filename
= NULL
;
45 char *policyname
= NULL
;
47 while ((opt
= getopt_av(argc
, argv
, "i:(dbfile)p:(policy)")) != EOF
) {
50 filename
= get_string(optarg_av
, &rv
);
51 if (filename
== NULL
) {
52 (void) fprintf(stderr
,
53 gettext("Error dbfile input.\n"));
57 policyname
= get_string(optarg_av
, &rv
);
58 if (policyname
== NULL
) {
59 (void) fprintf(stderr
,
60 gettext("Error policy name.\n"));
64 (void) fprintf(stderr
,
65 gettext("Error input option.\n"));
75 /* No additional args allowed. */
78 (void) fprintf(stderr
,
79 gettext("Error input option\n"));
84 if (filename
== NULL
) {
85 filename
= strdup(KMF_DEFAULT_POLICY_FILE
);
86 if (filename
== NULL
) {
93 * Must have a policy name. The policy name can not be default
94 * if using the default policy file.
96 if (policyname
== NULL
) {
97 (void) fprintf(stderr
,
98 gettext("You must specify a policy name\n"));
101 } else if (strcmp(filename
, KMF_DEFAULT_POLICY_FILE
) == 0 &&
102 strcmp(policyname
, KMF_DEFAULT_POLICY_NAME
) == 0) {
103 (void) fprintf(stderr
,
104 gettext("Can not delete the default policy in the default "
110 /* Check the access permission of the policy DB */
111 if (access(filename
, W_OK
) < 0) {
113 (void) fprintf(stderr
,
114 gettext("Cannot access \"%s\" for delete - %s\n"),
115 filename
, strerror(err
));
120 kmfrv
= kmf_delete_policy_from_db(policyname
, filename
);
122 rv
= KC_ERR_DELETE_POLICY
;
125 if (filename
!= NULL
)
128 if (policyname
!= NULL
)