/*
* 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 <libscf.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include "ksslcfg.h"
void
{
if (do_print)
" -f pkcs11 [-d softtoken_directory] -T <token_label>"
" -C <certificate_label> -x <proxy_port>"
" [-h <ca_certchain_file>]"
" [options] [<server_address>] <server_port>\n");
" -f pkcs12 -i <cert_and_key_pk12file> -x <proxy_port>"
" [options] [<server_address>] <server_port>\n");
" -f pem -i <cert_and_key_pemfile> -x <proxy_port>"
" [options] [<server_address>] <server_port>\n");
"\t[-p <password_file>]\n"
"\t[-t <ssl_session_cache_timeout>]\n"
"\t[-u <username>]\n"
"\t[-z <ssl_session_cache_size>]\n"
"\t[-v]\n");
}
static scf_propertygroup_t *
{
KSSL_DEBUG("scf_pg_create failed: %s\n",
scf_strerror(scf_error()));
"Unexpected fatal libscf error: %s. Exiting.\n"),
scf_strerror(scf_error()));
return (NULL);
}
KSSL_DEBUG("ERROR: scf_instance_add_pg failed: %s\n",
scf_strerror(scf_error()));
if (scf_error() == SCF_ERROR_EXISTS)
"Error: another process is modifying this instance."
" Exiting.\n"));
else
"Unexpected fatal libscf error: %s. Exiting.\n"),
scf_strerror(scf_error()));
return (NULL);
} else {
KSSL_DEBUG("property group created\n");
}
return (pg);
}
static int
{
KSSL_DEBUG("scf_entry_create failed: %s\n",
scf_strerror(scf_error()));
goto out;
}
KSSL_DEBUG("scf_entry_create succeeded\n");
goto out;
}
KSSL_DEBUG("scf_value_create succeeded\n");
goto out;
}
KSSL_DEBUG("scf_transaction_property_new succeeded\n");
goto out;
}
"scf_entry_add_value failed: %s\n",
scf_strerror(scf_error()));
goto out;
}
KSSL_DEBUG("scf_entry_add_value succeeded\n");
out:
"Unexpected fatal libscf error: %s. Exiting.\n"),
scf_strerror(scf_error()));
return (status);
}
static int
const char *value_str)
{
return (FAILURE);
return (SUCCESS);
}
static int
const char *value_str)
{
char *command;
const char *base_command;
/* flag is false to suppress duplicate error messages */
goto out0;
}
KSSL_DEBUG("scf_transaction_create failed: %s\n",
scf_strerror(scf_error()));
goto out0;
}
KSSL_DEBUG("scf_transaction_create succeeded\n");
do {
KSSL_DEBUG("scf_transaction_start failed: %s\n",
scf_strerror(scf_error()));
if (scf_error() == SCF_ERROR_PERMISSION_DENIED) {
"Error: Permission denied.\n"));
} else if (scf_error() == SCF_ERROR_DELETED) {
"Error: property group %s has"
" been deleted.\n"), pg_name);
} else
goto out1;
}
KSSL_DEBUG("scf_transaction_start succeeded\n");
base_command = "/usr/lib/kssladm delete";
else
base_command = "/usr/lib/kssladm create";
goto out2;
}
goto out2;
}
goto out2;
goto out2;
switch (rv) {
case 1:
KSSL_DEBUG("scf_transaction_commit succeeded\n");
goto out2;
case 0:
goto out2;
}
break;
case -1:
default:
KSSL_DEBUG("ERROR: scf_transaction_commit failed: %s\n",
scf_strerror(scf_error()));
if (scf_error() == SCF_ERROR_PERMISSION_DENIED) {
"Error: Permission denied.\n"));
} else {
}
goto out2;
}
} while (rv == 0);
out2:
out1:
out0:
if (errflag)
"Unexpected fatal libscf error: %s. Exiting.\n"),
scf_strerror(scf_error()));
return (status);
}
static int
const char *username, char *inaddr_any_name)
{
char *buf;
KSSL_DEBUG("scf_instance_create failed: %s\n",
scf_strerror(scf_error()));
goto out;
}
KSSL_DEBUG("scf_instance_create succeeded\n");
/* Let the caller deal with the duplicate instance */
goto out;
}
if (scf_error() == SCF_ERROR_EXISTS) {
/* Let the caller deal with the duplicate instance */
goto out;
}
KSSL_DEBUG("scf_service_add_instance failed: %s\n",
scf_strerror(scf_error()));
goto out;
}
KSSL_DEBUG("scf_service_add_instance succeeded\n");
return (status);
}
/* enabling the instance */
goto out;
if (smf_enable_instance(buf, 0) != 0) {
"smf_enable_instance failed: %s\n",
scf_strerror(scf_error()));
goto out;
}
}
out:
if (errflag)
"Unexpected fatal libscf error: %s. Exiting.\n"),
scf_strerror(scf_error()));
return (status);
}
static int
{
KSSL_DEBUG("scf_handle_create failed: %s\n",
scf_strerror(scf_error()));
goto out1;
}
KSSL_DEBUG("scf_handle_create succeeded\n");
KSSL_DEBUG("scf_handle_bind failed: %s\n",
scf_strerror(scf_error()));
goto out1;
}
KSSL_DEBUG("scf_handle_bind succeeded\n");
KSSL_DEBUG("scf_scope_create failed: %s\n",
scf_strerror(scf_error()));
goto out2;
}
KSSL_DEBUG("scf_scope_create succeeded\n");
KSSL_DEBUG("scf_service_create failed: %s\n",
scf_strerror(scf_error()));
goto out3;
}
KSSL_DEBUG("scf_service_create succeeded\n");
KSSL_DEBUG("scf_handle_decode_fmri failed: %s\n",
scf_strerror(scf_error()));
if (scf_error() == SCF_ERROR_NOT_FOUND) {
"service %s not found in the repository."
" Exiting.\n"), SERVICE_NAME);
}
goto out4;
}
out4:
out3:
out2:
(void) scf_handle_unbind(handle);
out1:
"Unexpected fatal libscf error: %s. Exiting.\n"),
scf_strerror(scf_error()));
return (status);
}
int
{
char c;
argc -= 1;
argv += 1;
/*
* Many of these arguments are passed on to kssladm command
* in the start method of the SMF instance created. So, we do only
* the basic usage checks here and let kssladm check the validity
* of the arguments. This is the reason we ignore optarg
* for some of the cases below.
*/
switch (c) {
case 'd':
break;
case 'c':
break;
case 'C':
break;
case 'f':
break;
case 'h':
break;
case 'i':
break;
case 'T':
break;
case 'p':
break;
case 't':
break;
case 'u':
break;
case 'x':
proxy_port = optarg;
break;
case 'v':
break;
case 'z':
break;
default:
goto err;
}
}
goto err;
}
gettext("Error: Invalid proxy port value %s\n"),
goto err;
}
goto err;
}
goto err;
}
} else {
goto err;
}
if (pcnt == 1) {
} else {
"argument too long -- %s\n"),
return (FAILURE);
}
} else if (pcnt == 2) {
} else {
"arguments too long -- %s %s\n"),
return (FAILURE);
}
} else {
goto err;
}
/*
* We need to create the kssladm command line in
* the SMF instance from the current arguments.
*
* Construct a buffer with all the arguments except
* the -u argument. We have to quote the string arguments,
* -T and -C, as they can contain white space.
*/
len = 0;
for (i = 1; i < optind; i++) {
}
return (FAILURE);
}
for (i = 1; i < optind; i++) {
i++;
continue;
}
if (quote_next) {
arglen += 2;
} else {
}
}
return (FAILURE);
}
username = "root";
if (status == INSTANCE_ANY_EXISTS &&
/*
* The following could result in a misconfiguration.
* Better bail out with an error.
*/
gettext("Error: INADDR_ANY instance exists."
" Can not create a new instance %s.\n"),
return (status);
}
/*
* Delete the existing instance and create a new instance
* with the supplied arguments.
*/
KSSL_DEBUG("Deleting duplicate instance\n");
"Error: Can not delete existing instance %s.\n"),
} else {
"Note: reconfiguring the existing instance %s.\n"),
}
}
/*
* network/ssl/proxy depends on network/socket-filter:kssl;
* enable that service now.
*/
if (smf_enable_instance(KSSL_FILTER_SVC_NAME, 0) != 0) {
"smf_enable_instance failed: %s\n" KSSL_FILTER_SVC_NAME);
"Unable to enable required service \"%s\". Error: %s"),
}
return (status);
err:
return (ERROR_USAGE);
}