/*
* 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
*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#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 found_count = 0;
char *ptr;
"o:(option)")) != EOF) {
switch (opt) {
case 'k':
if (keystore_name != NULL)
rv = KC_ERR_USAGE;
else {
if (keystore_name == NULL) {
"Error keystore input.\n"));
}
}
break;
case 'm':
if (modulepath != NULL)
rv = KC_ERR_USAGE;
else {
if (modulepath == NULL) {
gettext("Error modulepath.\n"));
}
}
break;
case 'o':
if (option_str != NULL) {
rv = KC_ERR_USAGE;
} else {
if (option_str == NULL) {
gettext("Error option input.\n"));
}
}
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_USAGE;
goto out;
}
gettext("Can not use the built-in keystore name %s\n"),
rv = KC_ERR_USAGE;
goto out;
}
rv = KC_ERR_USAGE;
goto out;
}
/*
* Find the absolute path of the module and check if it exists in
* the system. If $ISA is in the path, will check the 32bit version
* only.
*/
/*
* Only contain the base name; prepand it with
* KMF_PLUGIN_PATH
*/
} else {
char *isa;
} else {
}
}
realpath);
rv = KC_ERR_ACCESS;
goto out;
}
gettext("failed to update the configuration - %s\n"),
rv = KC_ERR_ACCESS;
goto out;
}
gettext("failed to lock the configuration - %s\n"),
rv = KC_ERR_INSTALL;
goto out;
}
/*
*/
gettext("failed to create a temporary file - %s\n"),
rv = KC_ERR_INSTALL;
goto out;
}
gettext("failed to open %s - %s\n"),
rv = KC_ERR_INSTALL;
goto out;
}
/*
* Loop thru the config file. If the file was reserved within a
* package bracket, just uncomment it. Other wise, append it at
* the end. The resulting file will be saved in the temp file first.
*/
if (buffer[0] == '#') {
ptr++;
ptr++;
== 0) {
found_count++;
}
}
rv = KC_ERR_INSTALL;
goto out;
}
} else {
if (found_count == 1) {
rv = KC_ERR_INSTALL;
goto out;
}
} else {
/*
* Found a second entry with #keystore_name.
* This should not happen. The kmf.conf file
* is corrupted. Give a warning and skip
* this entry.
*/
"(Warning) Found an additional reserved "
"entry for %s.\n"), keystore_name);
}
}
}
if (found_count == 0) {
/*
* This entry was not in package before, append it to the
* end of the temp file.
*/
if (option_str == NULL)
else
"failed to write to %s: %s\n"), tmpfile_name,
rv = KC_ERR_INSTALL;
goto out;
}
}
out:
(void) unlink(tmpfile_name);
"failed to update the configuration - %s"),
return (KC_ERR_INSTALL);
}
if (chmod(_PATH_KMF_CONF,
"failed to update the configuration - %s\n"),
return (KC_ERR_INSTALL);
}
}
return (rv);
}