1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 */
26
27 #pragma ident "%Z%%M% %I% %E% SMI"
28
29 #include <errno.h>
30 #include <fcntl.h>
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <strings.h>
34 #include <time.h>
35 #include <unistd.h>
36 #include <locale.h>
37 #include <sys/types.h>
38 #include <sys/stat.h>
39 #include "cryptoadm.h"
40
41 static int err; /* To store errno which may be overwritten by gettext() */
42 static int build_entrylist(entry_t *, entrylist_t **);
43 static entry_t *dup_entry(entry_t *);
44 static mechlist_t *dup_mechlist(mechlist_t *);
45 static entry_t *getent(char *, entrylist_t *);
46 static int interpret(char *, entry_t **);
47 static int parse_dislist(char *, entry_t *);
48
1176 * numbers. The flag has_mechs is set by the caller to B_TRUE if the provider
1177 * has some mechanisms.
1178 */
1179 void
1180 print_kef_policy(entry_t *pent, boolean_t has_random, boolean_t has_mechs)
1181 {
1182 mechlist_t *ptr;
1183 boolean_t rnd_disabled = B_FALSE;
1184
1185 if (pent == NULL) {
1186 return;
1187 }
1188
1189 rnd_disabled = filter_mechlist(&pent->dislist, RANDOM);
1190 ptr = pent->dislist;
1191
1192 (void) printf("%s:", pent->name);
1193
1194 if (has_mechs == B_TRUE) {
1195 /*
1196 * TRANSLATION_NOTE:
1197 * This code block may need to be modified a bit to avoid
1198 * constructing the text message on the fly.
1199 */
1200 (void) printf(gettext(" all mechanisms are enabled"));
1201 if (ptr != NULL)
1202 (void) printf(gettext(", except "));
1203 while (ptr != NULL) {
1204 (void) printf("%s", ptr->name);
1205 ptr = ptr->next;
1206 if (ptr != NULL)
1207 (void) printf(",");
1208 }
1209 if (ptr == NULL)
1210 (void) printf(".");
1211 }
1212
1213 /*
1214 * TRANSLATION_NOTE:
1215 * "random" is a keyword and not to be translated.
1216 */
1217 if (rnd_disabled)
1218 (void) printf(gettext(" %s is disabled."), "random");
1219 else if (has_random)
1220 (void) printf(gettext(" %s is enabled."), "random");
1221 (void) printf("\n");
1222 }
1223
1224 /*
1225 * Check if a kernel software provider is in the kernel.
1226 */
1227 int
1228 check_active_for_soft(char *provname, boolean_t *is_active)
1229 {
1230 crypto_get_soft_list_t *psoftlist_kernel = NULL;
1231 char *ptr;
1232 int i;
1233
1234 if (provname == NULL) {
|
1 /*
2 * CDDL HEADER START
3 *
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.
7 *
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.
12 *
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]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #include <errno.h>
27 #include <fcntl.h>
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <strings.h>
31 #include <time.h>
32 #include <unistd.h>
33 #include <locale.h>
34 #include <sys/types.h>
35 #include <sys/stat.h>
36 #include "cryptoadm.h"
37
38 static int err; /* To store errno which may be overwritten by gettext() */
39 static int build_entrylist(entry_t *, entrylist_t **);
40 static entry_t *dup_entry(entry_t *);
41 static mechlist_t *dup_mechlist(mechlist_t *);
42 static entry_t *getent(char *, entrylist_t *);
43 static int interpret(char *, entry_t **);
44 static int parse_dislist(char *, entry_t *);
45
1173 * numbers. The flag has_mechs is set by the caller to B_TRUE if the provider
1174 * has some mechanisms.
1175 */
1176 void
1177 print_kef_policy(entry_t *pent, boolean_t has_random, boolean_t has_mechs)
1178 {
1179 mechlist_t *ptr;
1180 boolean_t rnd_disabled = B_FALSE;
1181
1182 if (pent == NULL) {
1183 return;
1184 }
1185
1186 rnd_disabled = filter_mechlist(&pent->dislist, RANDOM);
1187 ptr = pent->dislist;
1188
1189 (void) printf("%s:", pent->name);
1190
1191 if (has_mechs == B_TRUE) {
1192 /*
1193 * TRANSLATION_NOTE
1194 * This code block may need to be modified a bit to avoid
1195 * constructing the text message on the fly.
1196 */
1197 (void) printf(gettext(" all mechanisms are enabled"));
1198 if (ptr != NULL)
1199 (void) printf(gettext(", except "));
1200 while (ptr != NULL) {
1201 (void) printf("%s", ptr->name);
1202 ptr = ptr->next;
1203 if (ptr != NULL)
1204 (void) printf(",");
1205 }
1206 if (ptr == NULL)
1207 (void) printf(".");
1208 }
1209
1210 /*
1211 * TRANSLATION_NOTE
1212 * "random" is a keyword and not to be translated.
1213 */
1214 if (rnd_disabled)
1215 (void) printf(gettext(" %s is disabled."), "random");
1216 else if (has_random)
1217 (void) printf(gettext(" %s is enabled."), "random");
1218 (void) printf("\n");
1219 }
1220
1221 /*
1222 * Check if a kernel software provider is in the kernel.
1223 */
1224 int
1225 check_active_for_soft(char *provname, boolean_t *is_active)
1226 {
1227 crypto_get_soft_list_t *psoftlist_kernel = NULL;
1228 char *ptr;
1229 int i;
1230
1231 if (provname == NULL) {
|