/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*/
#include <stdio.h>
#include <strings.h>
#include <ctype.h>
#include <libgen.h>
#include <libintl.h>
#include <errno.h>
#include <kmfapiP.h>
#include <cryptoutil.h>
#include "util.h"
}
int
{
int opt;
extern int optind_av;
extern char *optarg_av;
int ocsp_set_attr = 0;
int crl_set_attr = 0;
"i:(dbfile)"
"p:(policy)"
"d:(ignore-date)"
"e:(ignore-unknown-eku)"
"a:(ignore-trust-anchor)"
"v:(validity-adjusttime)"
"t:(ta-name)"
"s:(ta-serial)"
"o:(ocsp-responder)"
"P:(ocsp-proxy)"
"r:(ocsp-use-cert-responder)"
"T:(ocsp-response-lifetime)"
"R:(ocsp-ignore-response-sign)"
"n:(ocsp-responder-cert-name)"
"A:(ocsp-responder-cert-serial)"
"y:(ocsp-none)"
"c:(crl-basefilename)"
"I:(crl-directory)"
"g:(crl-get-crl-uri)"
"X:(crl-proxy)"
"S:(crl-ignore-crl-sign)"
"D:(crl-ignore-crl-date)"
"z:(crl-none)"
"u:(keyusage)"
"Y:(keyusage-none)"
"E:(ekunames)"
"O:(ekuoids)"
"m:(mapper-name)"
"M:(mapper-directory)"
"Q:(mapper-pathname)"
"q:(mapper-options)"
"Z:(eku-none)")) != EOF) {
switch (opt) {
case 'i':
gettext("Error dbfile input.\n"));
}
break;
case 'p':
gettext("Error policy name.\n"));
}
break;
case 'd':
gettext("Error boolean input.\n"));
rv = KC_ERR_USAGE;
} else {
flags |= KC_IGNORE_DATE;
}
break;
case 'e':
gettext("Error boolean input.\n"));
rv = KC_ERR_USAGE;
} else {
}
break;
case 'a':
gettext("Error boolean input.\n"));
rv = KC_ERR_USAGE;
} else {
}
break;
case 'v':
gettext("Error time input.\n"));
} else {
/* for syntax checking */
if (str2lifetime(
&adj) < 0) {
gettext("Error time "
"input.\n"));
rv = KC_ERR_USAGE;
} else {
}
}
break;
case 't':
gettext("Error name input.\n"));
/* for syntax checking */
gettext("Error name "
"input.\n"));
rv = KC_ERR_USAGE;
} else {
kmf_free_dn(&taDN);
flags |= KC_TA_NAME;
}
} else {
flags |= KC_TA_NAME;
}
break;
case 's':
gettext("Error serial input.\n"));
} else {
gettext("serial number "
"must be specified as a "
"hex number "
"(ex: 0x0102030405"
"ffeeddee)\n"));
rv = KC_ERR_USAGE;
break;
}
flags |= KC_TA_SERIAL;
}
break;
case 'o':
gettext("Error responder "
"input.\n"));
} else {
}
break;
case 'P':
gettext("Error proxy input.\n"));
} else {
flags |= KC_OCSP_PROXY;
}
break;
case 'r':
gettext("Error boolean input.\n"));
rv = KC_ERR_USAGE;
} else {
}
break;
case 'T':
gettext("Error time input.\n"));
} else {
/* for syntax checking */
if (str2lifetime(
&adj) < 0) {
gettext("Error time "
"input.\n"));
rv = KC_ERR_USAGE;
} else {
}
}
break;
case 'R':
gettext("Error boolean input.\n"));
rv = KC_ERR_USAGE;
} else {
}
break;
case 'n':
gettext("Error name input.\n"));
} else {
/* for syntax checking */
if (kmf_dn_parser(
gettext("Error name "
"input.\n"));
rv = KC_ERR_USAGE;
} else {
}
}
break;
case 'A':
gettext("Error serial input.\n"));
} else {
gettext("serial number "
"must be specified as a "
"hex number "
"(ex: 0x0102030405"
"ffeeddee)\n"));
rv = KC_ERR_USAGE;
break;
}
}
break;
case 'y':
if (ocsp_none_opt == -1) {
gettext("Error boolean input.\n"));
rv = KC_ERR_USAGE;
} else {
flags |= KC_OCSP_NONE;
}
break;
case 'c':
"Error basefilename input.\n"));
} else {
crl_set_attr++;
}
break;
case 'I':
gettext("Error boolean input.\n"));
} else {
crl_set_attr++;
}
break;
case 'g':
gettext("Error boolean input.\n"));
rv = KC_ERR_USAGE;
} else {
flags |= KC_CRL_GET_URI;
crl_set_attr++;
}
break;
case 'X':
gettext("Error proxy input.\n"));
} else {
flags |= KC_CRL_PROXY;
crl_set_attr++;
}
break;
case 'S':
gettext("Error boolean input.\n"));
rv = KC_ERR_USAGE;
} else {
crl_set_attr++;
}
break;
case 'D':
gettext("Error boolean input.\n"));
rv = KC_ERR_USAGE;
} else {
crl_set_attr++;
}
break;
case 'z':
if (crl_none_opt == -1) {
gettext("Error boolean input.\n"));
rv = KC_ERR_USAGE;
} else {
flags |= KC_CRL_NONE;
}
break;
case 'u':
"Error keyusage input.\n"));
rv = KC_ERR_USAGE;
} else {
flags |= KC_KEYUSAGE;
}
break;
case 'Y':
if (ku_none_opt == -1) {
gettext("Error boolean input.\n"));
rv = KC_ERR_USAGE;
} else {
}
break;
case 'E':
gettext("Error EKU input.\n"));
rv = KC_ERR_USAGE;
} else {
}
break;
case 'O':
gettext("Error EKU OID input.\n"));
rv = KC_ERR_USAGE;
} else {
}
break;
case 'Z':
if (eku_none_opt == -1) {
gettext("Error boolean input.\n"));
rv = KC_ERR_USAGE;
} else {
flags |= KC_EKUS_NONE;
}
break;
case 'm':
if (mapper_name == NULL) {
gettext("Error mapper-name "
"input.\n"));
}
break;
case 'M':
if (mapper_dir == NULL) {
gettext("Error mapper-directory "
"input.\n"));
}
break;
case 'Q':
if (mapper_pathname == NULL) {
gettext("Error mapper-pathname "
"input.\n"));
}
break;
case 'q':
rv = 0; /* its ok for this to be NULL */
break;
default:
gettext("Error input option.\n"));
rv = KC_ERR_USAGE;
break;
}
goto out;
}
/* No additional args allowed. */
if (argc) {
gettext("Error input option\n"));
rv = KC_ERR_USAGE;
goto out;
}
rv = KC_ERR_MEMORY;
goto out;
}
}
/*
* Must have a policy name. The policy name can not be default
* if using the default policy file.
*/
gettext("You must specify a policy name.\n"));
rv = KC_ERR_USAGE;
goto out;
gettext("Can not modify the default policy in the default "
"policy file.\n"));
rv = KC_ERR_USAGE;
goto out;
}
/* Check the access permission of the policy DB */
gettext("Cannot access \"%s\" for modify - %s\n"),
rv = KC_ERR_ACCESS;
goto out;
}
/* Try to load the named policy from the DB */
return (KC_ERR_FIND_POLICY);
}
/* Update the general policy attributes. */
if (flags & KC_IGNORE_DATE)
if (flags & KC_IGNORE_UNKNOWN_EKUS)
if (flags & KC_IGNORE_TRUST_ANCHOR)
if (flags & KC_VALIDITY_ADJUSTTIME) {
if (oplc.validity_adjusttime)
}
if (flags & KC_TA_NAME) {
}
if (flags & KC_TA_SERIAL) {
}
/*
* There are some combinations of attributes that are not valid.
*
* First, setting mapper-name (with optional mapper-directory) and
* mapper-pathname is mutually exclusive.
*/
/* Mapper directory can be set only if mapper name is set. */
/* Options can be set only if mapper name or pathname is set. */
gettext("Error in mapper input options\n"));
if (mapper_name != NULL)
if (mapper_pathname != NULL)
if (mapper_dir != NULL)
rv = KC_ERR_USAGE;
goto out;
} else {
if (mapper_name != NULL)
if (mapper_pathname != NULL)
if (mapper_dir != NULL)
}
if (flags & KC_MAPPER_OPTIONS) {
}
/* Update the OCSP policy */
if (ocsp_none_opt == B_TRUE) {
if (ocsp_set_attr > 0) {
gettext("Can not set ocsp-none=true and other "
"OCSP attributes at the same time.\n"));
rv = KC_ERR_USAGE;
goto out;
}
/*
* If the original policy does not have OCSP checking,
* then we do not need to do anything. If the original
* policy has the OCSP checking, then we need to release the
* space of OCSP attributes and turn the OCSP checking off.
*/
}
}
}
if (flags & KC_OCSP_RESP_CERT_NAME) {
}
if (flags & KC_OCSP_RESP_CERT_SERIAL) {
}
/* Turn off the OCSP checking */
}
} else {
/*
* If the "ocsp-none" option is not set or is set to false,
* then we only need to do the modification if there is at
* least one OCSP attribute is specified.
*/
if (ocsp_set_attr > 0) {
if (flags & KC_OCSP_RESPONDER_URI) {
}
if (flags & KC_OCSP_PROXY) {
if (oplc.VAL_OCSP_PROXY)
}
if (flags & KC_OCSP_URI_FROM_CERT)
if (flags & KC_OCSP_RESP_LIFETIME) {
}
if (flags & KC_OCSP_IGNORE_RESP_SIGN)
if (flags & KC_OCSP_RESP_CERT_NAME) {
}
if (flags & KC_OCSP_RESP_CERT_SERIAL) {
}
else
/* Turn on the OCSP checking */
}
}
/* Update the CRL policy */
if (crl_none_opt == B_TRUE) {
if (crl_set_attr > 0) {
gettext("Can not set crl-none=true and other CRL "
"attributes at the same time.\n"));
rv = KC_ERR_USAGE;
goto out;
}
/*
* If the original policy does not have CRL checking,
* then we do not need to do anything. If the original
* policy has the CRL checking, then we need to release the
* space of CRL attributes and turn the CRL checking off.
*/
if (oplc.VAL_CRL_BASEFILENAME) {
}
if (oplc.VAL_CRL_DIRECTORY) {
}
if (oplc.VAL_CRL_PROXY) {
}
/* Turn off the CRL checking */
}
} else {
/*
* If the "ocsp-none" option is not set or is set to false,
* then we only need to do the modification if there is at
* least one CRL attribute is specified.
*/
if (crl_set_attr > 0) {
if (flags & KC_CRL_BASEFILENAME) {
if (oplc.VAL_CRL_BASEFILENAME)
}
if (flags & KC_CRL_DIRECTORY) {
if (oplc.VAL_CRL_DIRECTORY)
}
if (flags & KC_CRL_GET_URI) {
}
if (flags & KC_CRL_PROXY) {
if (oplc.VAL_CRL_PROXY)
}
if (flags & KC_CRL_IGNORE_SIGN) {
}
if (flags & KC_CRL_IGNORE_DATE) {
}
/* Turn on the CRL checking */
}
}
/* Update the Key Usage */
if (ku_none_opt == B_TRUE) {
if (flags & KC_KEYUSAGE) {
gettext("Can not set keyusage-none=true and "
"modify the keyusage value at the same time.\n"));
rv = KC_ERR_USAGE;
goto out;
}
} else {
/*
* If the "keyusage-none" option is not set or is set to
* false, then we only need to do the modification if
* the keyusage value is specified.
*/
if (flags & KC_KEYUSAGE)
}
/* Update the Extended Key Usage */
if (eku_none_opt == B_TRUE) {
gettext("Can not set eku-none=true and modify "
"EKU values at the same time.\n"));
rv = KC_ERR_USAGE;
goto out;
}
/* Release current EKU list (if any) */
}
} else {
/*
* If the "eku-none" option is not set or is set to false,
* then we only need to do the modification if either
* "ekuname" or "ekuoids" is specified.
*/
/* Release current EKU list (if any) */
}
}
/* Do a sanity check on the modified policy */
goto out;
}
/* The modify operation is a delete followed by an add */
goto out;
}
/*
* Now add the modified policy back to the DB.
*/
goto out;
}
out:
return (rv);
}
static int
{
int opt;
extern int optind_av;
extern char *optarg_av;
!= EOF) {
switch (opt) {
case 'p':
if (modify_plugin) {
gettext("duplicate plugin input.\n"));
rv = KC_ERR_USAGE;
} else {
}
break;
case 'k':
if (keystore_name != NULL)
rv = KC_ERR_USAGE;
else {
if (keystore_name == NULL) {
"Error keystore input.\n"));
rv = KC_ERR_USAGE;
}
}
break;
case 'o':
if (has_option_arg) {
gettext("duplicate option input.\n"));
rv = KC_ERR_USAGE;
} else {
}
break;
default:
gettext("Error input option.\n"));
rv = KC_ERR_USAGE;
break;
}
goto out;
}
/* No additional args allowed. */
if (argc) {
gettext("Error input option\n"));
rv = KC_ERR_USAGE;
goto out;
}
gettext("Error input option\n"));
rv = KC_ERR_USAGE;
goto out;
}
gettext("Can not modify the built-in keystore %s\n"),
rv = KC_ERR_USAGE;
goto out;
}
rv = KC_ERR_USAGE;
goto out;
}
"the new option is same as the old option.\n"));
goto out;
}
gettext("failed to update the configuration - %s\n"),
rv = KC_ERR_ACCESS;
goto out;
}
gettext("failed to lock the configuration - %s\n"),
goto out;
}
/*
*/
gettext("failed to create a temporary file - %s\n"),
goto out;
}
gettext("failed to open %s - %s\n"),
goto out;
}
/*
* Loop thru the config file and update the entry.
*/
char *name;
int len;
if (buffer[0] == '#') {
goto out;
} else {
continue;
}
}
/*
* make a copy of the original buffer to buffer2. Also get
* rid of the trailing '\n' from buffer2.
*/
len--;
}
goto out;
}
/* found the entry */
"%s:%s%s\n", keystore_name,
else
"%s:%s%s;%s%s\n", keystore_name,
"failed to write to %s: %s\n"),
goto out;
}
} else {
goto out;
}
}
}
goto out;
}
if (chmod(_PATH_KMF_CONF,
"failed to update the configuration - %s\n"),
goto out;
}
out:
(void) unlink(tmpfile_name);
return (rv);
}
int
{
if (argc > 2 &&
} else {
}
}