/*
* 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 <stdlib.h>
#include <string.h>
#include <strings.h>
#include <libscf.h>
#include <syslog.h>
#include <libintl.h>
#include "fedfs_impl.h"
/*
*
* On success, returns an allocated string with the name, which the
* caller must free. On failure, returns NULL.
*/
static char *
{
int sz;
char *s, *buf;
return (NULL);
if (*s == '.' || *s == ',' || *s == '=')
*s = '_';
#ifdef DEBUG
#endif
return (buf);
}
/*
* fedfs_smf_lookup() - look up the distinguished name (user),
*
* On success, returns a pointer to an allocated nsdb_info_t structure
* which must be freed by the caller. On failure, returns NULL.
*/
{
char *p, *pgname;
return (NULL);
return (NULL);
}
if (!prop) {
"FedFS failed to find binddn property in pg %s:%s\n",
return (NULL);
}
#ifdef DEBUG
#endif
if (!prop) {
"FedFS failed to find bindpw property in pg %s:%s\n",
return (NULL);
}
#ifdef DEBUG
#endif
else if (prompt_pw) {
int len;
/* LINTED */
else
#ifdef DEBUG
#endif
} else
if (!prop) {
"FedFS failed to find sectype property in pg %s:%s\n",
return (NULL);
}
#ifdef DEBUG
#endif
else
if (!prop) {
"FedFS failed to find certpath property in pg %s:%s\n",
return (NULL);
}
#ifdef DEBUG
#endif
else
if (!prop) {
"FedFS failed to find nce property in pg %s:%s\n",
return (NULL);
}
#ifdef DEBUG
#endif
return (info);
}
void
{
return;
}
/*
* get_pg_value() - from property group, get a named astring value.
*/
static char *
{
char *valbuf;
return (NULL);
return (NULL);
return (NULL);
return (NULL);
}
#ifdef DEBUG
#endif
}
/*
* fedfs_smf_list() - enumerate all nsdbparams entried
*
* Returns the number of entries in the allocated array of nsdb_list_t
* entries to which the passed argument points on success. The array
* must be freed by the caller. On failure, the return is zero.
*/
int
{
int num = 0;
scf_handle_t *h = NULL;
char *namebuf;
char *valbuf;
scf_handle_bind(h) != 0 ||
goto cleanup;
}
goto cleanup;
goto cleanup;
goto cleanup;
goto cleanup;
for (;;) {
break;
break;
#ifdef DEBUG
#endif
continue;
num = 0;
break;
}
}
if (num > 0)
else
#ifdef DEBUG
#endif
if (h) {
(void) scf_handle_unbind(h);
}
return (num);
}
/*
*
* Returns 0 on success and -1 on failure, usually setting scf_error.
* A caller may print error diagnosis with scf_strerror().
*/
int
{
char *pgname;
scf_handle_t *h = NULL;
return (-1);
scf_handle_bind(h) != 0 ||
goto cleanup;
#ifdef DEBUG
#endif
if (err != 0)
"FedFS failed to delete pg %s:%s\n",
if (h) {
(void) scf_handle_unbind(h);
}
return (err);
}
/*
* set_pg_value() - write a value out to SMF
*
* Returns 0 on success and -1 on failure, usually setting scf_error.
* A caller may print error diagnosis with scf_strerror().
*/
static int
{
#ifdef DEBUG
#endif
do {
return (-1);
goto cleanup;
if (new) {
goto cleanup;
} else {
goto cleanup;
}
goto cleanup;
#ifdef DEBUG
#endif
if (ret == -1)
goto cleanup;
if (ret == 0) {
goto cleanup;
}
} while (ret == 0);
if (ret == 1)
ret = 0;
return (ret);
}
/*
* fedfs_smf_update() - update or create the SMF property group entry for
*
* Returns 0 on success and -1 on failure, while also setting scf_error.
* A caller may print error diagnosis with scf_strerror().
*/
int
{
scf_handle_t *h = NULL;
return (-1);
scf_handle_bind(h) != 0 ||
goto cleanup;
#ifdef DEBUG
#endif
if (scf_error() != SCF_ERROR_NOT_FOUND) {
#ifdef DEBUG
#endif
goto cleanup;
}
0, pg) != 0) {
#ifdef DEBUG
#endif
goto cleanup;
}
}
"solaris.smf.read.fedfs") != 0 ||
"solaris.smf.value.fedfs") != 0) {
#ifdef DEBUG
#endif
err = 1;
} else
err = 0;
(void) smf_refresh_instance(FEDFS_CLIENT);
if (err != 0)
"FedFS failed to add property to pg %s:%s\n",
if (h) {
(void) scf_handle_unbind(h);
}
return (err);
}
/*
* fedfs_get_default_host() - get a default host value from env or SMF.
*
* On success, returns an allocated string with the name, which the
* caller must free. On failure, returns NULL.
*/
char *
{
char *v = NULL;
v = getenv("FEDFS_NSDB_HOST");
if (v != NULL) {
#ifdef DEBUG
#endif
v = strdup(v);
goto out;
}
if (!prop)
goto out;
if (v != NULL) {
#ifdef DEBUG
#endif
v = strdup(v);
}
out:
#ifdef DEBUG
#endif
free(v);
v = strdup("localhost");
}
return (v);
}
/*
* fedfs_get_default_port() - get a default port value from env or SMF.
*
* On success, returns an allocated string with the name, which the
* caller must free. On failure, returns NULL.
*/
char *
{
char *v = NULL;
v = getenv("FEDFS_NSDB_PORT");
if (v != NULL) {
#ifdef DEBUG
#endif
v = strdup(v);
goto out;
}
if (!prop)
goto out;
#ifdef DEBUG
#endif
v = strdup(v);
}
out:
#ifdef DEBUG
#endif
free(v);
v = strdup("389");
}
return (v);
}
/*
* fedfs_use_loopback() - query SMF "force_loopback" property
*
* Returns:
* -1: inconclusive (likely no such property or FMRI)
* 0: force_loopback is false
* 1: force_loopback is true
*/
int
{
"force_loopback");
if (!prop) {
"FedFS failed to find force_loopback property:%s\n",
scf_strerror(scf_error()));
return (retval);
}
return (retval);
}
/*
* fedfs_set_default() - update the SMF default property; properties
* are hostname and port.
*
* Returns 0 on success and -1 on failure, while also setting scf_error.
* A caller may print error diagnosis with scf_strerror().
*/
int
{
scf_handle_t *h = NULL;
scf_handle_bind(h) != 0 ||
goto cleanup;
#ifdef DEBUG
#endif
goto cleanup;
}
#ifdef DEBUG
#endif
err = 0;
#ifdef DEBUG
if (err < 0)
#endif
(void) smf_refresh_instance(FEDFS_CLIENT);
if (h) {
(void) scf_handle_unbind(h);
}
if (err != 0)
"FedFS failed to update default pg: %s\n",
scf_strerror(scf_error()));
return (err);
}
/*
* fedfs_set_loopback() - update the SMF default/force_loopback property
*
* Returns 0 on success and -1 on failure, while also setting scf_error.
* A caller may print error diagnosis with scf_strerror().
*/
int
{
scf_handle_t *h = NULL;
scf_handle_bind(h) != 0 ||
goto cleanup;
#ifdef DEBUG
#endif
goto cleanup;
}
do {
#ifdef DEBUG
#endif
goto cleanup;
}
#ifdef DEBUG
#endif
goto cleanup;
}
#ifdef DEBUG
#endif
goto cleanup;
}
#ifdef DEBUG
#endif
goto cleanup;
}
#ifdef DEBUG
#endif
if (ret == -1)
goto cleanup;
if (ret == 0) {
#ifdef DEBUG
#endif
ret = -1;
goto cleanup;
}
}
} while (ret == 0);
if (ret == 1)
ret = 0;
if (ret != 0)
"FedFS failed to write force_loopback property:%s\n",
scf_strerror(scf_error()));
if (h) {
(void) scf_handle_unbind(h);
}
return (ret);
}
int
{
return (FEDFS_SEC_TLS);
return (FEDFS_SEC_NONE);
else
return (-1);
}