smb_scfutil.c revision dc20a3024900c47dd2ee44b9707e6df38f7d62a5
/*
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/* helper functions for using libscf with CIFS */
#include <libscf.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
#include <errno.h>
#include <libintl.h>
#include <assert.h>
#include <strings.h>
/*
* smb_smf_scf_log_error(msg)
* Logs error messages from scf API's
*/
static void
smb_smf_scf_log_error(char *msg)
{
if (!msg) {
scf_strerror(scf_error()));
} else { /*LINTED E_SEC_PRINTF_E_VAR_FMT*/
}
}
/*
* smb_smf_create_service_pgroup(handle, pgroup)
*
* create a new property group at service level.
*/
int
{
int ret = SMBD_SMF_OK;
int err;
return (SMBD_SMF_SYSTEM_ERR);
}
/*
* only create a handle if it doesn't exist. It is ok to exist
* since the pg handle will be set as a side effect.
*/
/*
* if the pgroup exists, we are done. If it doesn't, then we
* need to actually add one to the service instance.
*/
/* doesn't exist so create one */
if (err != SCF_ERROR_NONE)
switch (err) {
break;
default:
break;
}
}
}
return (ret);
}
/*
* Start transaction on current pg in handle.
* The pg could be service or instance level.
* Must be called after pg handle is obtained
* from create or get.
*/
int
{
int ret = SMBD_SMF_OK;
return (SMBD_SMF_SYSTEM_ERR);
/*
* lookup the property group and create it if it doesn't already
* exist.
*/
if (ret == SMBD_SMF_OK) {
}
} else {
}
}
}
if (ret == SMBD_SMF_SYSTEM_ERR &&
return (ret);
}
/*
* smb_smf_end_transaction(handle)
*
* Commit the changes that were added to the transaction in the
* handle. Do all necessary cleanup.
*/
int
{
int ret = SMBD_SMF_OK;
return (SMBD_SMF_SYSTEM_ERR);
} else {
smb_smf_scf_log_error("Failed to commit "
"transaction: %s");
}
}
return (ret);
}
/*
* Sets string property in current pg
*/
int
{
int ret = SMBD_SMF_OK;
return (SMBD_SMF_SYSTEM_ERR);
/*
* properties must be set in transactions and don't take
*/
propname, SCF_TYPE_ASTRING) == 0 ||
propname, SCF_TYPE_ASTRING) == 0) {
}
/* the value is in the transaction */
} else {
/* value couldn't be constructed */
}
/* the entry is in the transaction */
} else {
}
} else {
}
if (ret == SMBD_SMF_SYSTEM_ERR) {
switch (scf_error()) {
break;
}
}
/*
* cleanup if there were any errors that didn't leave these
* values where they would be cleaned up later.
*/
return (ret);
}
/*
* Gets string property value.upto sz size.
* Caller is responsible to have enough memory allocated.
*/
int
{
int ret = SMBD_SMF_OK;
return (SMBD_SMF_SYSTEM_ERR);
}
} else {
}
} else {
}
return (ret);
}
/*
* Set integer value of property.
* The value is returned as int64_t value
* Caller ensures appropriate translation.
*/
int
{
int ret = SMBD_SMF_OK;
return (SMBD_SMF_SYSTEM_ERR);
/*
* properties must be set in transactions and don't take
*/
propname, SCF_TYPE_INTEGER) == 0 ||
propname, SCF_TYPE_INTEGER) == 0) {
}
/* the value is in the transaction */
}
/* the entry is in the transaction */
} else {
}
if (ret == SMBD_SMF_SYSTEM_ERR) {
switch (scf_error()) {
break;
}
}
/*
* cleanup if there were any errors that didn't leave these
* values where they would be cleaned up later.
*/
return (ret);
}
/*
* Gets integer property value.
* Caller is responsible to have enough memory allocated.
*/
int
{
int ret = SMBD_SMF_OK;
return (SMBD_SMF_SYSTEM_ERR);
valint) != 0) {
}
} else {
}
} else {
}
return (ret);
}
/*
* Set boolean value of property.
* The value is returned as int64_t value
* Caller ensures appropriate translation.
*/
int
{
int ret = SMBD_SMF_OK;
return (SMBD_SMF_SYSTEM_ERR);
/*
* properties must be set in transactions and don't take
*/
propname, SCF_TYPE_BOOLEAN) == 0 ||
propname, SCF_TYPE_BOOLEAN) == 0) {
}
/* the value is in the transaction */
}
/* the entry is in the transaction */
} else {
}
if (ret == SMBD_SMF_SYSTEM_ERR) {
switch (scf_error()) {
break;
}
}
/*
* cleanup if there were any errors that didn't leave these
* values where they would be cleaned up later.
*/
return (ret);
}
/*
* Gets boolean property value.
* Caller is responsible to have enough memory allocated.
*/
int
{
int ret = SMBD_SMF_OK;
return (SMBD_SMF_SYSTEM_ERR);
valbool) != 0) {
}
} else {
}
} else {
}
return (ret);
}
/*
* Sets a blob property value.
*/
int
{
int ret = SMBD_SMF_OK;
return (SMBD_SMF_SYSTEM_ERR);
/*
* properties must be set in transactions and don't take
*/
propname, SCF_TYPE_OPAQUE) == 0 ||
propname, SCF_TYPE_OPAQUE) == 0) {
}
/* the value is in the transaction */
} else {
/* value couldn't be constructed */
}
/* the entry is in the transaction */
} else {
}
} else {
}
if (ret == SMBD_SMF_SYSTEM_ERR) {
switch (scf_error()) {
break;
}
}
/*
* cleanup if there were any errors that didn't leave these
* values where they would be cleaned up later.
*/
return (ret);
}
/*
* Gets a blob property value.
* Caller is responsible to have enough memory allocated.
*/
int
{
int ret = SMBD_SMF_OK;
return (SMBD_SMF_SYSTEM_ERR);
}
} else {
}
} else {
}
return (ret);
}
/*
* smb_smf_scf_init()
*
* must be called before using any of the SCF functions.
* Returns smb_scfhandle_t pointer if success.
*/
smb_smf_scf_init(char *svc_name)
{
goto err;
!= SCF_SUCCESS) {
goto err;
}
} else {
goto err;
}
} else {
smb_smf_scf_log_error("Could not access SMF "
"repository: %s\n");
}
}
return (handle);
err:
(void) smb_smf_scf_fini(handle);
(void) smb_smf_scf_log_error("SMF initialization problem: %s\n");
return (NULL);
}
/*
* smb_smf_scf_fini(handle)
*
* must be called when done. Called with the handle allocated in
* smb_smf_scf_init(), it cleans up the state and frees any SCF resources
* still in use.
*/
void
{
int unbind = 0;
unbind = 1;
if (unbind)
}
}