Solaris_NFSShareSecurity.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "Solaris_NFSShareSecurity.h"
#include "nfs_keys.h"
#include "nfs_provider_names.h"
#include "nfs_providers_msgstrings.h"
#include "messageStrings.h"
#include "util.h"
#include "libfsmgt.h"
#include "createprop_methods.h"
#include <string.h>
#include <errno.h>
/*
* Constants
*/
#define SECMODES 5
#define DEFAULT_MAXLIFE 30000
#define MAXSIZE 256
/*
* Private variables
*/
/*
* Private method declarations
*/
static CCIMInstanceList *enumerate_sharesecurity();
static void populate_Solaris_NFSShareSecurity_property_Values(
char *path,
char *secmode_opts, int *err);
/*
* Public methods
*/
/*
* Instance provider methods
*/
/*
* Solaris_NFSShareSecurity provider
*
* It is important to note that all memory allocated by these functions
* and passed to the CIMOM, is freed by the CIMOM as the caller.
*/
/*
* Name: cp_enumInstances_Solaris_NFSShareSecurity
*
* Description: Returns a list of instances if found.
*
* Parameters:
* shareOP - An CCIMObjectPath * which contains the information on
* the class for which to find the instance.
* Returns:
* CCIMInstanceList * if matched instance is found. Otherwise, NULL.
*/
/* ARGSUSED */
int err = 0;
cim_logDebug("cp_enumInstances_Solaris_NFSShareSecurity",
"Just entering...");
/*
* Check object path for NULL value
*/
"SOLARIS_NFSSHARESECURITY::ENUM_INSTANCES",
return ((CCIMInstanceList *)NULL);
}
cim_logDebug("cp_enumInstances_Solaris_NFSShareSecurity",
"Call to enumerate_sharesecurity returned NULL");
"SOLARIS_NFSSHARESECURITY::ENUM_INSTANCES",
return ((CCIMObjectPathList *)NULL);
}
cim_logDebug("cp_enumInstances_Solaris_NFSShareSecurity",
"Returning Solaris_NFSShareSecurity instance");
return (instList);
}
/*
* Name: cp_enumInstanceNames_Solaris_NFSShareSecurity
*
* Description: Enumerates all of the security modes and options for all
* of the nfs shares on the host.
*
* Parameters:
* shareOP - An CCIMObjectPath * which contains the information on
* the class for which to find the instance.
* Returns:
* CCIMObjectPathList * if matched instance is found. Otherwise, NULL.
*/
/* ARGUSED */
int err = 0;
"SOLARIS_NFSSHARESECURITY::ENUM_INSTANCES",
return ((CCIMObjectPathList *)NULL);
}
ex = cim_getLastError();
"SOLARIS_NFSSHARESECURITY::ENUM_INSTANCENAMES",
return ((CCIMInstanceList *)NULL);
}
return (OPList);
}
/*
* Name: cp_getInstance_Solaris_NFSShareSecurity
*
* Description: Returns an instance which matches the passed in object path
* if found.
*
* Parameters:
* shareOP - An CCIMObjectPath * which contains the information on
* the class for which to find the instance.
* Returns:
* CCIMInstance * if matched instance is found. Otherwise, NULL.
*/
int err = 0;
"SOLARIS_NFSSHARESECURITY::GET_INSTANCE",
return ((CCIMInstance *)NULL);
}
ex = cim_getLastError();
util_handleError("SOLARIS_NFSSHARESECURITY::GET_INSTANCE",
return ((CCIMInstance *)NULL);
}
cim_logDebug("cp_getInstance_Solaris_NFSShareSecurity",
"Returning instance");
return (inst);
}
/*
* cp_setInstance not supported
*/
/* ARGSUSED */
int err = 0;
util_handleError("SOLARIS_NFSSHARESECURITY::SET_INSTANCE",
return (cim_false);
} /* cp_setInstance_Solaris_NFSShareSecurity */
/*
* cp_setInstanceWithList not supported
*/
/* ARGSUSED */
int err = 0;
util_handleError("SOLARIS_NFSSHARESECURITY::SET_INSTANCEWITHLIST",
return (cim_false);
}
/*
* cp_invokeMethod not supported
*/
/* ARGSUSED */
int err = 0;
util_handleError("SOLARIS_NFSSHARESECURITY::INVOKE_METHOD",
return ((CCIMProperty *)NULL);
} /* cp_invokeMethod_Solaris_NFSShareSecurity */
/*
* cp_setProperty not supported
*/
/* ARGSUSED */
CCIMProperty *pProp) {
int err = 0;
util_handleError("SOLARIS_NFSSHARESECURITY::SET_PROPERTY",
return (cim_false);
}
/*
* cp_createInstance not supported
*/
/* ARGSUSED */
int err = 0;
util_handleError("SOLARIS_NFSSHARESECURITY::CREATE_INSTANCE",
return ((CCIMObjectPath *)NULL);
}
/*
* cp_deleteInstance not supported
*/
/* ARGSUSED */
int err = 0;
util_handleError("SOLARIS_NFSSHARESECURITY::DELETE_INSTANCE",
return (cim_false);
}
/*
* Name: cp_execQuery_Solaris_NFSShareSecurity
*
* Description: Builds a list of all instances, prepends the list with an
* empty instance, and returns the instance list. The CIMOM
* interprets the initial empty instance to mean that it has
* to do the filtering. The caller is responsible for freeing
* the memory allocated for the returned object.
*
* Parameters:
* CCIMObjectPath *shareOP - An objectpath which represents the class to
* work on
* char *electClause - The select clause
* char *nonJoinExp - The non join expression
* char *queryExp - The query Expression
* char *queryLang - The Query Language used (s/b "WQL")
*
* Returns:
* Returns the prepended instance list. On error NULL is returned.
*/
/* ARGSUSED */
int err = 0;
if (shareSecInstList == NULL) {
ex = cim_getLastError();
util_handleError("SOLARIS_NFSSHARESECURITY::EXEC_QUERY",
return ((CCIMInstanceList *)NULL);
}
ex = cim_getLastError();
util_handleError("SOLARIS_NFSSHARESECURITY::EXEC_QUERY",
return ((CCIMInstanceList *)NULL);
}
if (resultInstList == NULL) {
util_handleError("SOLARIS_NFSSHARESECURITY::EXEC_QUERY",
}
return (resultInstList);
} /* cp_execQuery_Solaris_NFSShareSecurity */
/*
* Private Methods
*/
/*
* create_nfsShareSec_InstList
*
* Creates the Solaris_NFSShareSecurity instance list from information
* gathered from the shares on the system. The instance list is returned.
*/
static CCIMInstanceList *
char **sec_modes;
int count;
/*
* At this point, one or more nfs shares were found on the
* system, create the instance list from the nfs_sharesec_list.
*/
if (nfsShareSecInstList == NULL) {
ex = cim_getLastError();
"SOLARIS_NFSSHARESECURITY::CREATE_INST_LIST ",
return ((CCIMInstanceList *)NULL);
}
/*
* Loop through the security modes for the nfs shares to
* retrieve their security properties and create an
* instance list containing all the security modes and
* their properties for each share.
*/
int i;
/*
* Parse the the share options list for multiple
* security modes. An array of strings is returned
* that will be used to create the instances for each
* share.
*/
"SOLARIS_NFSSHARESECURITY::CREATE_INST_LIST ",
return ((CCIMInstanceList *)NULL);
}
for (i = 0; i < count; i++) {
/*
* Create the Solaris_NFSShareSecurity
* CCIMInstance
*/
if (solaris_NFSShareSec_instance == NULL) {
ex = cim_getLastError();
util_handleError("SOLARIS_NFSSHARESECURITY:" \
":CREATE_INST_LIST", CIM_ERR_FAILED,
return ((CCIMInstanceList *)NULL);
}
currentShare, sec_modes[i]);
if (solaris_NFSShareSec_prop_list == NULL) {
/*
* populatePropertyList already logged
* this error so there is no need to
* log it here.
*/
return ((CCIMInstanceList *)NULL);
}
/*
* Add the property list to the instance
*/
if (solaris_NFSShareSec_instance == NULL) {
ex = cim_getLastError();
util_handleError("SOLARIS_NFSSHARESECURITY:" \
":CREATE_INST_LIST", CIM_ERR_FAILED,
return ((CCIMInstanceList *)NULL);
}
/*
* Add the instance to the instance list
*/
if (nfsShareSecInstList == NULL) {
ex = cim_getLastError();
util_handleError("SOLARIS_NFSSHARESECURITY:" \
":CREATE_INST_LIST", CIM_ERR_FAILED,
return ((CCIMInstanceList *)NULL);
}
} /* for (int i; i < count; i++) */
} /* for (currentShare = nfs_sharesec_list; ...) */
return (nfsShareSecInstList);
} /* create_nfsShareSec_InstList */
/*
* enumerate_sharesecurity
* Enumerate the nfs sharesecurity modes for each share by using the
* fs_shares fs_get_share_list method to get the security modes from
* the option string.
*/
static CCIMInstanceList *
int err;
if (nfs_sharesec_list == NULL) {
/*
* Check whether an error was returned or if we simply don't
* have any nfs shares on the system. If err is not
* equal to 0, an error was encountered.
*/
if (err != 0) {
/*
* Determine the error and log it.
*/
"SOLARIS_NFSSHARESECURITY:" \
":ENUM_SHARESECURITY ",
return ((CCIMInstanceList *)NULL);
} else {
/*
* If any other errors were encountered it
* can be handled as a general error. We may
* not know exactly what the error is.
*/
"SOLARIS_NFSSHARESECURITY:" \
":ENUM_SHARESECURITY ",
return ((CCIMInstanceList *)NULL);
}
}
/*
* There are no nfs shares on the host.
*/
return ((CCIMInstanceList *)NULL);
} else {
return (nfsShareSecInstList);
}
} /* enumerate_sharesecurity */
/*
* populate_Solaris_NFSShareSecurity_property_list
* Populates the property list with that share information for each
* instance in the instance list.
*/
static CCIMPropertyList *
int i, err = 0;
cim_logDebug("populate_Solaris_NFSShareSecurity_property_list",
"Just entering...");
if (nfsShareSecPropList == NULL) {
ex = cim_getLastError();
"SOLARIS_NFSSHARESECURITY::POPULATE_PROPLIST",
goto out;
}
/*
* Create the CCIMProperties for this instance
*/
if (err != 0) {
} else {
for (i = 0; i < PROPCOUNT; i++) {
"populate_Solaris_NFSShareSecurity_property_list",
"propValues[%d] = %s", i, propValues[i]);
if (nfsShareSecPropList == NULL) {
goto out;
}
}
}
out:
cim_logDebug("populate_Solaris_NFSShareSecurity_property_list",
"Returning property list");
return (nfsShareSecPropList);
} /* populate_Solaris_NFSShareSecurity_property_list */
/*
* populate_Solaris_NFSShareSecurity_property_Values
* Populates the property array for use in the populate_property_list function
*/
static void
int defaultValue = B_FALSE;
int count = 0;
char **access_list;
char *optValue;
cim_logDebug("populate_Solaris_NFSShareSecurity_property_Values",
"Just entering...");
/*
* Check for security mode option in option string.
* Key - Mode
*/
} else {
/*
* The default security mode is set only if no security
* mode is set in the option string.
*/
}
cim_logDebug("populate_Solaris_NFSShareSecurity_property_Values",
/*
* MaxLife
* only used with sec mode of "dh"
*/
optValue =
"populate_Solaris_NFSShareSecurity_property_Values",
} else {
}
/*
* Path
*/
path);
"populate_Solaris_NFSShareSecurity_property_Values",
} else {
"populate_Solaris_NFSShareSecurity_property_Values",
}
/*
* ReadOnly
*/
"populate_Solaris_NFSShareSecurity_property_Values",
/*
* Read Write List
*/
if (propString == NULL) {
return;
}
return;
}
} else {
}
cim_logDebug("populate_Solaris_NFSShareSecurity_property_Values",
count = 0;
/*
* Read Only List
*/
if (propString == NULL) {
return;
}
return;
}
} else {
}
cim_logDebug("populate_Solaris_NFSShareSecurity_property_Values",
count = 0;
/*
* root server list
*/
if (propString == NULL) {
return;
}
return;
}
} else {
}
cim_logDebug("populate_Solaris_NFSShareSecurity_property_Values",
cim_logDebug("populate_Solaris_NFSShareSecurity_property_Values",
"Returning");
} /* populate_Solaris_NFSShareSecurity_property_Values */