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 (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _MGMT_SCF_H 28 #define _MGMT_SCF_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #ifdef _cplusplus 33 extern "C" { 34 #endif 35 36 #include <libscf.h> 37 #include <iscsitgt_impl.h> 38 #include <ucred.h> 39 40 #define SA_TARGET_SVC_NAME "system/iscsitgt" 41 #define SA_TARGET_SVC_INSTANCE_FMRI "svc:/system/iscsitgt:default" 42 43 #define ISCSI_READ_AUTHNAME "read_authorization" 44 #define ISCSI_MODIFY_AUTHNAME "modify_authorization" 45 #define ISCSI_VALUE_AUTHNAME "value_authorization" 46 47 #define ISCSI_AUTH_READ "solaris.smf.read.iscsitgt" 48 #define ISCSI_AUTH_MANAGE "solaris.smf.manage.iscsitgt" 49 #define ISCSI_AUTH_MODIFY "solaris.smf.modify.iscsitgt" 50 #define ISCSI_AUTH_VALUE "solaris.smf.value.iscsitgt" 51 52 typedef enum { 53 CONVERT_OK = 0, 54 CONVERT_INIT_NEW, 55 CONVERT_FAIL 56 } convert_ret_t; 57 58 typedef struct { 59 scf_handle_t *t_handle; 60 scf_scope_t *t_scope; 61 scf_service_t *t_service; 62 scf_propertygroup_t *t_pg; 63 scf_instance_t *t_instance; 64 scf_transaction_t *t_trans; 65 } targ_scf_t; 66 67 typedef struct secret_list { 68 char *name; 69 char *secret; 70 struct secret_list *next; 71 } secret_list_t; 72 73 Boolean_t mgmt_scf_init(); 74 void mgmt_scf_fini(); 75 76 targ_scf_t *mgmt_handle_init(void); 77 Boolean_t mgmt_transaction_start(targ_scf_t *h, char *pg, char *prop); 78 Boolean_t mgmt_transaction_end(targ_scf_t *h); 79 void mgmt_transaction_abort(targ_scf_t *h); 80 81 Boolean_t mgmt_get_main_config(tgt_node_t **node); 82 Boolean_t mgmt_config_save2scf(); 83 84 Boolean_t mgmt_param_save2scf(tgt_node_t *node, char *target_name, int lun); 85 Boolean_t mgmt_get_param(tgt_node_t **node, char *target_name, int lun); 86 Boolean_t mgmt_param_remove(char *target_name, int lun); 87 convert_ret_t mgmt_convert_conf(); 88 89 Boolean_t check_auth_modify(ucred_t *cred); 90 Boolean_t check_auth_addremove(ucred_t *cred); 91 92 int get_zfs_shareiscsi(char *, tgt_node_t **, uint64_t *, ucred_t *); 93 int put_zfs_shareiscsi(char *, tgt_node_t *); 94 #define ZFS_PROP_SIZE (2 * 1024) 95 96 97 #ifdef __cplusplus 98 } 99 #endif 100 101 #endif /* _MGMT_SCF_H */ 102