1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22/* 23 * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27#pragma ident "%Z%%M% %I% %E% SMI" 28 29#include "Solaris_NFSShareSecurity.h" 30#include "nfs_keys.h" 31#include "nfs_provider_names.h" 32#include "nfs_providers_msgstrings.h" 33#include "messageStrings.h" 34#include "util.h" 35#include "libfsmgt.h" 36#include "createprop_methods.h" 37#include <string.h> 38#include <errno.h> 39#include <sys/utsname.h> 40 41/* 42 * Constants 43 */ 44#define SECMODES 5 45#define DEFAULT_MAXLIFE 30000 46#define MAXSIZE 256 47 48 49/* 50 * Private variables 51 */ 52 53/* 54 * Private method declarations 55 */ 56 57static CCIMInstanceList *create_nfsShareSec_InstList( 58 fs_sharelist_t *nfs_sharesec_list, int *err); 59static CCIMInstanceList *enumerate_sharesecurity(); 60static CCIMPropertyList *populate_Solaris_NFSShareSecurity_property_list( 61 fs_sharelist_t *nfs_share, char *secmode_opts); 62static void populate_Solaris_NFSShareSecurity_property_Values( 63 char *path, 64 cimchar propValues[PROPCOUNT][MAXSIZE], 65 char *secmode_opts, int *err); 66 67/* 68 * Public methods 69 */ 70 71/* 72 * Instance provider methods 73 */ 74 75/* 76 * Solaris_NFSShareSecurity provider 77 * 78 * It is important to note that all memory allocated by these functions 79 * and passed to the CIMOM, is freed by the CIMOM as the caller. 80 */ 81 82/* 83 * Name: cp_enumInstances_Solaris_NFSShareSecurity 84 * 85 * Description: Returns a list of instances if found. 86 * 87 * Parameters: 88 * shareOP - An CCIMObjectPath * which contains the information on 89 * the class for which to find the instance. 90 * Returns: 91 * CCIMInstanceList * if matched instance is found. Otherwise, NULL. 92 */ 93 94/* ARGSUSED */ 95CCIMInstanceList * 96cp_enumInstances_Solaris_NFSShareSecurity(CCIMObjectPath* shareOP) { 97 CCIMInstanceList *instList; 98 int err = 0; 99 100 cim_logDebug("cp_enumInstances_Solaris_NFSShareSecurity", 101 "Just entering..."); 102 /* 103 * Check object path for NULL value 104 */ 105 if (shareOP == NULL) { 106 util_handleError( 107 "SOLARIS_NFSSHARESECURITY::ENUM_INSTANCES", 108 CIM_ERR_INVALID_PARAMETER, NULL, 109 NULL, &err); 110 return ((CCIMInstanceList *)NULL); 111 } 112 113 instList = enumerate_sharesecurity(); 114 if (instList == NULL) { 115 cim_logDebug("cp_enumInstances_Solaris_NFSShareSecurity", 116 "Call to enumerate_sharesecurity returned NULL"); 117 util_handleError( 118 "SOLARIS_NFSSHARESECURITY::ENUM_INSTANCES", 119 CIM_ERR_FAILED, CIMOM_ENUM_INST_FAILURE, 120 NULL, &err); 121 return ((CCIMObjectPathList *)NULL); 122 } 123 124 cim_logDebug("cp_enumInstances_Solaris_NFSShareSecurity", 125 "Returning Solaris_NFSShareSecurity instance"); 126 return (instList); 127} 128 129/* 130 * Name: cp_enumInstanceNames_Solaris_NFSShareSecurity 131 * 132 * Description: Enumerates all of the security modes and options for all 133 * of the nfs shares on the host. 134 * 135 * Parameters: 136 * shareOP - An CCIMObjectPath * which contains the information on 137 * the class for which to find the instance. 138 * Returns: 139 * CCIMObjectPathList * if matched instance is found. Otherwise, NULL. 140 */ 141 142/* ARGUSED */ 143CCIMObjectPathList * 144cp_enumInstanceNames_Solaris_NFSShareSecurity(CCIMObjectPath* shareOP) { 145 CCIMInstanceList *instList; 146 CCIMObjectPathList *OPList; 147 CCIMException *ex; 148 int err = 0; 149 150 instList = cp_enumInstances_Solaris_NFSShareSecurity(shareOP); 151 if (instList == NULL) { 152 util_handleError( 153 "SOLARIS_NFSSHARESECURITY::ENUM_INSTANCES", 154 CIM_ERR_FAILED, CIMOM_ENUM_INSTNAMES_FAILURE, 155 NULL, &err); 156 return ((CCIMObjectPathList *)NULL); 157 } 158 159 OPList = cim_createObjectPathList(instList); 160 if (OPList == NULL) { 161 ex = cim_getLastError(); 162 util_handleError( 163 "SOLARIS_NFSSHARESECURITY::ENUM_INSTANCENAMES", 164 CIM_ERR_FAILED, CREATE_OBJECT_LIST_FAILURE, ex, &err); 165 cim_freeCIMException(ex); 166 cim_freeInstanceList(instList); 167 return ((CCIMInstanceList *)NULL); 168 } 169 cim_freeInstanceList(instList); 170 return (OPList); 171} 172 173/* 174 * Name: cp_getInstance_Solaris_NFSShareSecurity 175 * 176 * Description: Returns an instance which matches the passed in object path 177 * if found. 178 * 179 * Parameters: 180 * shareOP - An CCIMObjectPath * which contains the information on 181 * the class for which to find the instance. 182 * Returns: 183 * CCIMInstance * if matched instance is found. Otherwise, NULL. 184 */ 185 186CCIMInstance * 187cp_getInstance_Solaris_NFSShareSecurity(CCIMObjectPath* shareOP) { 188 CCIMInstanceList *instList; 189 CCIMInstance *inst; 190 CCIMException *ex; 191 int err = 0; 192 193 instList = cp_enumInstances_Solaris_NFSShareSecurity(shareOP); 194 if (instList == NULL) { 195 util_handleError( 196 "SOLARIS_NFSSHARESECURITY::GET_INSTANCE", 197 CIM_ERR_FAILED, CIMOM_ENUM_INST_FAILURE, 198 NULL, &err); 199 return ((CCIMInstance *)NULL); 200 } 201 202 inst = cim_getInstance(instList, shareOP); 203 if (inst == NULL) { 204 ex = cim_getLastError(); 205 util_handleError("SOLARIS_NFSSHARESECURITY::GET_INSTANCE", 206 CIM_ERR_INVALID_CLASS, GET_INSTANCE_FAILURE, ex, &err); 207 cim_freeInstanceList(instList); 208 return ((CCIMInstance *)NULL); 209 } 210 211 cim_freeInstanceList(instList); 212 cim_logDebug("cp_getInstance_Solaris_NFSShareSecurity", 213 "Returning instance"); 214 215 return (inst); 216} 217 218/* 219 * cp_setInstance not supported 220 */ 221/* ARGSUSED */ 222CIMBool 223cp_setInstance_Solaris_NFSShareSecurity(CCIMObjectPath *shareOP, 224 CCIMInstance *shareInst, 225 char **props, int num_props) { 226 int err = 0; 227 228 util_handleError("SOLARIS_NFSSHARESECURITY::SET_INSTANCE", 229 CIM_ERR_NOT_SUPPORTED, NULL, NULL, &err); 230 return (cim_false); 231} /* cp_setInstance_Solaris_NFSShareSecurity */ 232 233/* 234 * cp_setInstanceWithList not supported 235 */ 236/* ARGSUSED */ 237CIMBool 238cp_setInstanceWithList_Solaris_NFSShareSecurity(CCIMObjectPath *shareOP, 239 CCIMInstance *shareInst, 240 char **props, int num_props) { 241 int err = 0; 242 243 util_handleError("SOLARIS_NFSSHARESECURITY::SET_INSTANCEWITHLIST", 244 CIM_ERR_NOT_SUPPORTED, NULL, NULL, &err); 245 return (cim_false); 246} 247 248/* 249 * cp_invokeMethod not supported 250 */ 251/* ARGSUSED */ 252CCIMProperty * 253cp_invokeMethod_Solaris_NFSShareSecurity( 254 CCIMObjectPath *pOP, 255 cimchar *functionName, 256 CCIMPropertyList *inParams, 257 CCIMPropertyList *outParams) { 258 259 int err = 0; 260 util_handleError("SOLARIS_NFSSHARESECURITY::INVOKE_METHOD", 261 CIM_ERR_NOT_SUPPORTED, NULL, NULL, &err); 262 return ((CCIMProperty *)NULL); 263} /* cp_invokeMethod_Solaris_NFSShareSecurity */ 264 265 266/* 267 * cp_setProperty not supported 268 */ 269/* ARGSUSED */ 270CIMBool 271cp_setProperty_Solaris_NFSShareSecurity(CCIMObjectPath *pOP, 272 CCIMProperty *pProp) { 273 int err = 0; 274 util_handleError("SOLARIS_NFSSHARESECURITY::SET_PROPERTY", 275 CIM_ERR_NOT_SUPPORTED, NULL, NULL, &err); 276 return (cim_false); 277} 278 279/* 280 * cp_createInstance not supported 281 */ 282/* ARGSUSED */ 283CCIMObjectPath * 284cp_createInstance_Solaris_NFSShareSecurity(CCIMObjectPath *shareOP, 285 CCIMInstance *shareInst) { 286 287 int err = 0; 288 289 util_handleError("SOLARIS_NFSSHARESECURITY::CREATE_INSTANCE", 290 CIM_ERR_NOT_SUPPORTED, NULL, NULL, &err); 291 return ((CCIMObjectPath *)NULL); 292} 293 294/* 295 * cp_deleteInstance not supported 296 */ 297/* ARGSUSED */ 298CIMBool 299cp_deleteInstance_Solaris_NFSShareSecurity(CCIMObjectPath *shareOP) { 300 301 int err = 0; 302 303 util_handleError("SOLARIS_NFSSHARESECURITY::DELETE_INSTANCE", 304 CIM_ERR_NOT_SUPPORTED, NULL, NULL, &err); 305 return (cim_false); 306} 307 308/* 309 * Name: cp_execQuery_Solaris_NFSShareSecurity 310 * 311 * Description: Builds a list of all instances, prepends the list with an 312 * empty instance, and returns the instance list. The CIMOM 313 * interprets the initial empty instance to mean that it has 314 * to do the filtering. The caller is responsible for freeing 315 * the memory allocated for the returned object. 316 * 317 * Parameters: 318 * CCIMObjectPath *shareOP - An objectpath which represents the class to 319 * work on 320 * char *electClause - The select clause 321 * char *nonJoinExp - The non join expression 322 * char *queryExp - The query Expression 323 * char *queryLang - The Query Language used (s/b "WQL") 324 * 325 * Returns: 326 * Returns the prepended instance list. On error NULL is returned. 327 */ 328/* ARGSUSED */ 329CCIMInstanceList* 330cp_execQuery_Solaris_NFSShareSecurity(CCIMObjectPath *shareOP, 331 char *selectClause, char *nonJoinExp, char *queryExp, char *queryLang) { 332 333 CCIMInstance *emptyInst; 334 CCIMInstanceList *shareSecInstList; 335 CCIMInstanceList *resultInstList; 336 CCIMException *ex; 337 int err = 0; 338 339 shareSecInstList = cp_enumInstances_Solaris_NFSShareSecurity(shareOP); 340 if (shareSecInstList == NULL) { 341 ex = cim_getLastError(); 342 util_handleError("SOLARIS_NFSSHARESECURITY::EXEC_QUERY", 343 CIM_ERR_FAILED, CIMOM_ENUM_INST_FAILURE, ex, &err); 344 return ((CCIMInstanceList *)NULL); 345 } 346 347 emptyInst = cim_createInstance(""); 348 if (emptyInst == NULL) { 349 ex = cim_getLastError(); 350 util_handleError("SOLARIS_NFSSHARESECURITY::EXEC_QUERY", 351 CIM_ERR_FAILED, CREATE_INSTANCE_FAILURE, ex, &err); 352 cim_freeCIMException(ex); 353 cim_freeInstanceList(shareSecInstList); 354 return ((CCIMInstanceList *)NULL); 355 } 356 357 resultInstList = cim_prependInstance(shareSecInstList, emptyInst); 358 if (resultInstList == NULL) { 359 util_handleError("SOLARIS_NFSSHARESECURITY::EXEC_QUERY", 360 CIM_ERR_FAILED, PREPEND_INSTANCE_FAILURE, ex, &err); 361 cim_freeInstanceList(shareSecInstList); 362 cim_freeInstance(emptyInst); 363 } 364 return (resultInstList); 365 366} /* cp_execQuery_Solaris_NFSShareSecurity */ 367 368 369/* 370 * Private Methods 371 */ 372 373/* 374 * create_nfsShareSec_InstList 375 * 376 * Creates the Solaris_NFSShareSecurity instance list from information 377 * gathered from the shares on the system. The instance list is returned. 378 */ 379static CCIMInstanceList * 380create_nfsShareSec_InstList(fs_sharelist_t *nfs_sharesec_list, int *err) { 381 fs_sharelist_t *currentShare; 382 CCIMInstanceList *nfsShareSecInstList; 383 CCIMException *ex; 384 char **sec_modes; 385 int count; 386 387 cim_logDebug("create_nfsShareSec_InstList", "Just entering..."); 388 /* 389 * At this point, one or more nfs shares were found on the 390 * system, create the instance list from the nfs_sharesec_list. 391 */ 392 nfsShareSecInstList = cim_createInstanceList(); 393 if (nfsShareSecInstList == NULL) { 394 ex = cim_getLastError(); 395 util_handleError( 396 "SOLARIS_NFSSHARESECURITY::CREATE_INST_LIST ", 397 CIM_ERR_FAILED, CREATE_INSTANCE_LIST_FAILURE, 398 ex, err); 399 return ((CCIMInstanceList *)NULL); 400 } 401 402 /* 403 * Loop through the security modes for the nfs shares to 404 * retrieve their security properties and create an 405 * instance list containing all the security modes and 406 * their properties for each share. 407 */ 408 for (currentShare = nfs_sharesec_list; currentShare != NULL; 409 currentShare = currentShare->next) { 410 int i; 411 CCIMInstance *solaris_NFSShareSec_instance; 412 CCIMPropertyList *solaris_NFSShareSec_prop_list; 413 414 /* 415 * Parse the the share options list for multiple 416 * security modes. An array of strings is returned 417 * that will be used to create the instances for each 418 * share. 419 */ 420 sec_modes = fs_parse_opts_for_sec_modes( 421 currentShare->options, &count, err); 422 if (sec_modes == NULL) { 423 util_handleError( 424 "SOLARIS_NFSSHARESECURITY::CREATE_INST_LIST ", 425 CIM_ERR_INVALID_PARAMETER, NULL, NULL, err); 426 return ((CCIMInstanceList *)NULL); 427 } 428 for (i = 0; i < count; i++) { 429 /* 430 * Create the Solaris_NFSShareSecurity 431 * CCIMInstance 432 */ 433 solaris_NFSShareSec_instance = 434 cim_createInstance(SOLARIS_NFSSHARESECURITY); 435 if (solaris_NFSShareSec_instance == NULL) { 436 ex = cim_getLastError(); 437 util_handleError("SOLARIS_NFSSHARESECURITY:" \ 438 ":CREATE_INST_LIST", CIM_ERR_FAILED, 439 CREATE_INSTANCE_FAILURE, ex, err); 440 cim_freeInstanceList(nfsShareSecInstList); 441 fileutil_free_string_array(sec_modes, count); 442 return ((CCIMInstanceList *)NULL); 443 } 444 445 solaris_NFSShareSec_prop_list = 446 populate_Solaris_NFSShareSecurity_property_list( 447 currentShare, sec_modes[i]); 448 if (solaris_NFSShareSec_prop_list == NULL) { 449 /* 450 * populatePropertyList already logged 451 * this error so there is no need to 452 * log it here. 453 */ 454 cim_freeInstance(solaris_NFSShareSec_instance); 455 cim_freeInstanceList(nfsShareSecInstList); 456 fileutil_free_string_array(sec_modes, count); 457 return ((CCIMInstanceList *)NULL); 458 } 459 460 /* 461 * Add the property list to the instance 462 */ 463 solaris_NFSShareSec_instance = 464 cim_addPropertyListToInstance( 465 solaris_NFSShareSec_instance, 466 solaris_NFSShareSec_prop_list); 467 if (solaris_NFSShareSec_instance == NULL) { 468 ex = cim_getLastError(); 469 util_handleError("SOLARIS_NFSSHARESECURITY:" \ 470 ":CREATE_INST_LIST", CIM_ERR_FAILED, 471 PROPLIST_TO_INSTANCE_FAILURE, ex, err); 472 cim_freePropertyList( 473 solaris_NFSShareSec_prop_list); 474 cim_freeInstanceList(nfsShareSecInstList); 475 fileutil_free_string_array(sec_modes, count); 476 return ((CCIMInstanceList *)NULL); 477 } 478 479 /* 480 * Add the instance to the instance list 481 */ 482 nfsShareSecInstList = 483 cim_addInstance(nfsShareSecInstList, 484 solaris_NFSShareSec_instance); 485 if (nfsShareSecInstList == NULL) { 486 ex = cim_getLastError(); 487 util_handleError("SOLARIS_NFSSHARESECURITY:" \ 488 ":CREATE_INST_LIST", CIM_ERR_FAILED, 489 ADD_INSTANCE_FAILURE, ex, err); 490 cim_freeInstance(solaris_NFSShareSec_instance); 491 fileutil_free_string_array(sec_modes, count); 492 return ((CCIMInstanceList *)NULL); 493 } 494 } /* for (int i; i < count; i++) */ 495 496 } /* for (currentShare = nfs_sharesec_list; ...) */ 497 498 fileutil_free_string_array(sec_modes, count); 499 500 cim_logDebug("create_nfsShareSec_InstList", "Returning instance list"); 501 return (nfsShareSecInstList); 502 503} /* create_nfsShareSec_InstList */ 504 505/* 506 * enumerate_sharesecurity 507 * Enumerate the nfs sharesecurity modes for each share by using the 508 * fs_shares fs_get_share_list method to get the security modes from 509 * the option string. 510 */ 511static CCIMInstanceList * 512enumerate_sharesecurity() { 513 514 int err; 515 fs_sharelist_t *nfs_sharesec_list; 516 517 cim_logDebug("enumerate_sharesecurity", "Just entering..."); 518 nfs_sharesec_list = fs_get_share_list(&err); 519 if (nfs_sharesec_list == NULL) { 520 /* 521 * Check whether an error was returned or if we simply don't 522 * have any nfs shares on the system. If err is not 523 * equal to 0, an error was encountered. 524 */ 525 if (err != 0) { 526 /* 527 * Determine the error and log it. 528 */ 529 if (err == ENOMEM || err == EAGAIN) { 530 util_handleError( 531 "SOLARIS_NFSSHARESECURITY:" \ 532 ":ENUM_SHARESECURITY ", 533 CIM_ERR_LOW_ON_MEMORY, 534 NULL, NULL, &err); 535 return ((CCIMInstanceList *)NULL); 536 } else { 537 538 /* 539 * If any other errors were encountered it 540 * can be handled as a general error. We may 541 * not know exactly what the error is. 542 */ 543 util_handleError( 544 "SOLARIS_NFSSHARESECURITY:" \ 545 ":ENUM_SHARESECURITY ", 546 CIM_ERR_FAILED, 547 strerror(err), NULL, &err); 548 return ((CCIMInstanceList *)NULL); 549 } 550 } 551 /* 552 * There are no nfs shares on the host. 553 */ 554 cim_logDebug("enumerate_sharesecurity", "No shares on system"); 555 return ((CCIMInstanceList *)NULL); 556 557 } else { 558 559 CCIMInstanceList *nfsShareSecInstList; 560 561 nfsShareSecInstList = 562 create_nfsShareSec_InstList(nfs_sharesec_list, &err); 563 564 fs_free_share_list(nfs_sharesec_list); 565 566 return (nfsShareSecInstList); 567 } 568} /* enumerate_sharesecurity */ 569 570/* 571 * populate_Solaris_NFSShareSecurity_property_list 572 * Populates the property list with that share information for each 573 * instance in the instance list. 574 */ 575static CCIMPropertyList * 576populate_Solaris_NFSShareSecurity_property_list( 577 fs_sharelist_t *nfs_share, char *secmode_opts) { 578 579 CCIMException *ex; 580 CCIMPropertyList *nfsShareSecPropList; 581 char propValues[PROPCOUNT][MAXSIZE]; 582 int i, err = 0; 583 584 cim_logDebug("populate_Solaris_NFSShareSecurity_property_list", 585 "Just entering..."); 586 587 nfsShareSecPropList = cim_createPropertyList(); 588 if (nfsShareSecPropList == NULL) { 589 ex = cim_getLastError(); 590 util_handleError( 591 "SOLARIS_NFSSHARESECURITY::POPULATE_PROPLIST", 592 CIM_ERR_FAILED, CREATE_PROPLIST_FAILURE, ex, &err); 593 cim_freeCIMException(ex); 594 goto out; 595 } 596 597 /* 598 * Create the CCIMProperties for this instance 599 */ 600 populate_Solaris_NFSShareSecurity_property_Values( 601 nfs_share->path, propValues, secmode_opts, &err); 602 if (err != 0) { 603 cim_freePropertyList(nfsShareSecPropList); 604 nfsShareSecPropList = NULL; 605 } else { 606 for (i = 0; i < PROPCOUNT; i++) { 607 cim_logDebug( 608 "populate_Solaris_NFSShareSecurity_property_list", 609 "propValues[%d] = %s", i, propValues[i]); 610 nfsShareSecPropList = 611 add_property_to_list(nfsShareSecProps[i].name, 612 nfsShareSecProps[i].type, propValues[i], NULL, 613 nfsShareSecProps[i].isKey, nfsShareSecPropList); 614 if (nfsShareSecPropList == NULL) { 615 goto out; 616 } 617 } 618 } 619out: 620 cim_logDebug("populate_Solaris_NFSShareSecurity_property_list", 621 "Returning property list"); 622 return (nfsShareSecPropList); 623 624} /* populate_Solaris_NFSShareSecurity_property_list */ 625 626/* 627 * populate_Solaris_NFSShareSecurity_property_Values 628 * Populates the property array for use in the populate_property_list function 629 */ 630static void 631populate_Solaris_NFSShareSecurity_property_Values(char *path, 632 cimchar propValues[PROPCOUNT][MAXSIZE], char *secmode_opts, int *err) { 633 634 boolean_t hasEquals; 635 int defaultValue = B_FALSE; 636 int count = 0; 637 char **access_list; 638 char *optValue; 639 cimchar *propString; 640 641 642 cim_logDebug("populate_Solaris_NFSShareSecurity_property_Values", 643 "Just entering..."); 644 /* 645 * Check for security mode option in option string. 646 * Key - Mode 647 */ 648 hasEquals = B_TRUE; 649 defaultValue = B_FALSE; 650 651 optValue = get_property_from_opt_string(secmode_opts, 652 "sec=", hasEquals, defaultValue); 653 if (strcmp(optValue, "0") != 0) { 654 (void) snprintf(propValues[SEC_MODE], MAXSIZE, "%s", optValue); 655 } else { 656 /* 657 * The default security mode is set only if no security 658 * mode is set in the option string. 659 */ 660 (void) snprintf(propValues[SEC_MODE], MAXSIZE, "%s", "sys"); 661 } 662 cim_logDebug("populate_Solaris_NFSShareSecurity_property_Values", 663 "%s = %s", nfsShareSecProps[SEC_MODE].name, propValues[SEC_MODE]); 664 free(optValue); 665 666 /* 667 * MaxLife 668 * only used with sec mode of "dh" 669 */ 670 if (strcmp(propValues[SEC_MODE], "dh") == 0) { 671 hasEquals = B_TRUE; 672 defaultValue = DEFAULT_MAXLIFE; 673 optValue = 674 get_property_from_opt_string(secmode_opts, 675 "window=", hasEquals, defaultValue); 676 (void) snprintf(propValues[MAXLIFE], MAXSIZE, "%s", optValue); 677 cim_logDebug( 678 "populate_Solaris_NFSShareSecurity_property_Values", 679 "%s = %s", nfsShareSecProps[MAXLIFE].name, 680 propValues[MAXLIFE]); 681 } else { 682 (void) snprintf(propValues[MAXLIFE], MAXSIZE, "\0"); 683 } 684 free(optValue); 685 686 /* 687 * Path 688 */ 689 if (path != NULL) { 690 (void) snprintf(propValues[PATH], MAXSIZE, "%s", 691 path); 692 cim_logDebug( 693 "populate_Solaris_NFSShareSecurity_property_Values", 694 "%s = %s", nfsShareSecProps[PATH].name, propValues[PATH]); 695 } else { 696 (void) snprintf(propValues[PATH], MAXSIZE, "\0"); 697 cim_logDebug( 698 "populate_Solaris_NFSShareSecurity_property_Values", 699 "%s = %s", nfsShareSecProps[PATH].name, "null"); 700 } 701 702 /* 703 * ReadOnly 704 */ 705 hasEquals = B_FALSE; 706 defaultValue = B_FALSE; 707 optValue = get_property_from_opt_string(secmode_opts, 708 "ro", hasEquals, defaultValue); 709 (void) snprintf(propValues[READONLY], MAXSIZE, "%s", optValue); 710 cim_logDebug( 711 "populate_Solaris_NFSShareSecurity_property_Values", 712 "%s = %s", nfsShareSecProps[READONLY].name, propValues[READONLY]); 713 free(optValue); 714 715 /* 716 * Read Write List 717 */ 718 hasEquals = B_TRUE; 719 defaultValue = B_FALSE; 720 optValue = get_property_from_opt_string(secmode_opts, "rw=", 721 hasEquals, defaultValue); 722 if (strcmp(optValue, "0") != 0) { 723 access_list = 724 fs_create_array_from_accesslist(optValue, 725 &count, err); 726 propString = cim_encodeStringArray(access_list, count); 727 if (propString == NULL) { 728 *err = ENOMEM; 729 return; 730 } 731 free(optValue); 732 optValue = strdup(propString); 733 if (optValue == NULL) { 734 *err = ENOMEM; 735 return; 736 } 737 free(propString); 738 fileutil_free_string_array(access_list, count); 739 } else { 740 optValue = strdup("\0"); 741 } 742 (void) snprintf(propValues[READWRITELIST], MAXSIZE, "%s", optValue); 743 cim_logDebug("populate_Solaris_NFSShareSecurity_property_Values", 744 "%s = %s", nfsShareSecProps[READWRITELIST].name, 745 propValues[READWRITELIST]); 746 free(optValue); 747 count = 0; 748 749 /* 750 * Read Only List 751 */ 752 hasEquals = B_TRUE; 753 defaultValue = B_FALSE; 754 optValue = get_property_from_opt_string(secmode_opts, "ro=", 755 hasEquals, defaultValue); 756 757 if (strcmp(optValue, "0") != 0) { 758 access_list = 759 fs_create_array_from_accesslist(optValue, 760 &count, err); 761 propString = cim_encodeStringArray(access_list, count); 762 if (propString == NULL) { 763 *err = ENOMEM; 764 return; 765 } 766 free(optValue); 767 optValue = strdup(propString); 768 if (optValue == NULL) { 769 *err = ENOMEM; 770 return; 771 } 772 free(propString); 773 fileutil_free_string_array(access_list, count); 774 } else { 775 optValue = strdup("\0"); 776 } 777 (void) snprintf(propValues[READONLYLIST], MAXSIZE, "%s", optValue); 778 cim_logDebug("populate_Solaris_NFSShareSecurity_property_Values", 779 "%s = %s", nfsShareSecProps[READONLYLIST].name, 780 propValues[READONLYLIST]); 781 free(optValue); 782 count = 0; 783 784 /* 785 * root server list 786 */ 787 hasEquals = B_TRUE; 788 defaultValue = B_FALSE; 789 optValue = get_property_from_opt_string(secmode_opts, 790 "root=", hasEquals, defaultValue); 791 if (strcmp(optValue, "0") != 0) { 792 access_list = 793 fs_create_array_from_accesslist(optValue, 794 &count, err); 795 propString = cim_encodeStringArray(access_list, count); 796 if (propString == NULL) { 797 *err = ENOMEM; 798 return; 799 } 800 free(optValue); 801 optValue = strdup(propString); 802 if (optValue == NULL) { 803 *err = ENOMEM; 804 return; 805 } 806 free(propString); 807 fileutil_free_string_array(access_list, count); 808 } else { 809 optValue = strdup("\0"); 810 } 811 (void) snprintf(propValues[ROOTSERVERS], MAXSIZE, "%s", optValue); 812 cim_logDebug("populate_Solaris_NFSShareSecurity_property_Values", 813 "%s = %s", nfsShareSecProps[ROOTSERVERS].name, 814 propValues[ROOTSERVERS]); 815 free(optValue); 816 817 cim_logDebug("populate_Solaris_NFSShareSecurity_property_Values", 818 "Returning"); 819 820} /* populate_Solaris_NFSShareSecurity_property_Values */ 821