Print this page
4095 minor cleanup up libshare

@@ -19,10 +19,11 @@
  * CDDL HEADER END
  */
 
 /*
  * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013 RackTop Systems.
  */
 
 /*
  * Share control API
  */

@@ -63,23 +64,23 @@
 
 extern struct sa_proto_plugin *sap_proto_list;
 
 /* current SMF/SVC repository handle */
 extern void getlegacyconfig(sa_handle_t, char *, xmlNodePtr *);
-extern int gettransients(sa_handle_impl_t, xmlNodePtr *);
+extern int gettransients(sa_handle_t, xmlNodePtr *);
 extern char *sa_fstype(char *);
-extern int sa_is_share(void *);
-extern int sa_is_resource(void *);
+extern boolean_t sa_is_share(void *);
+extern boolean_t sa_is_resource(void *);
 extern ssize_t scf_max_name_len; /* defined in scfutil during initialization */
-extern int sa_group_is_zfs(sa_group_t);
-extern int sa_path_is_zfs(char *);
+extern boolean_t sa_group_is_zfs(sa_group_t);
+extern boolean_t sa_path_is_zfs(char *);
 extern int sa_zfs_set_sharenfs(sa_group_t, char *, int);
 extern int sa_zfs_set_sharesmb(sa_group_t, char *, int);
 extern void update_legacy_config(sa_handle_t);
 extern int issubdir(char *, char *);
-extern int sa_zfs_init(sa_handle_impl_t);
-extern void sa_zfs_fini(sa_handle_impl_t);
+extern int sa_zfs_init(sa_handle_t);
+extern void sa_zfs_fini(sa_handle_t);
 extern void sablocksigs(sigset_t *);
 extern void saunblocksigs(sigset_t *);
 static sa_group_t sa_get_optionset_parent(sa_optionset_t);
 static char *get_node_attr(void *, char *);
 extern void sa_update_sharetab_ts(sa_handle_t);

@@ -93,11 +94,11 @@
  */
 mutex_t sa_global_lock;
 struct doc2handle {
         struct doc2handle       *next;
         xmlNodePtr              root;
-        sa_handle_impl_t        handle;
+        sa_handle_t             handle;
 };
 
 mutex_t sa_dfstab_lock;
 
 /* definitions used in a couple of property functions */

@@ -237,11 +238,11 @@
  * used internally. A mutex is used to prevent access while the list
  * is changing. In general, the list will be relatively short - one
  * item per thread that has called sa_init().
  */
 
-sa_handle_impl_t
+sa_handle_t
 get_handle_for_root(xmlNodePtr root)
 {
         struct doc2handle *item;
 
         (void) mutex_lock(&sa_global_lock);

@@ -254,11 +255,11 @@
                 return (item->handle);
         return (NULL);
 }
 
 static int
-add_handle_for_root(xmlNodePtr root, sa_handle_impl_t handle)
+add_handle_for_root(xmlNodePtr root, sa_handle_t handle)
 {
         struct doc2handle *item;
         int ret = SA_NO_MEMORY;
 
         item = (struct doc2handle *)calloc(sizeof (struct doc2handle), 1);

@@ -317,11 +318,11 @@
         sa_handle_t handle;
 
         while (node != NULL) {
                 if (strcmp((char *)(node->name), "sharecfg") == 0) {
                         /* have the root so get the handle */
-                        handle = (sa_handle_t)get_handle_for_root(node);
+                        handle = get_handle_for_root(node);
                         return (handle);
                 }
                 node = node->parent;
         }
         return (NULL);

@@ -338,11 +339,11 @@
 static void
 set_legacy_timestamp(xmlNodePtr root, char *path, uint64_t tval)
 {
         xmlNodePtr node;
         xmlChar *lpath = NULL;
-        sa_handle_impl_t handle;
+        sa_handle_t handle;
 
         /* Have to have a handle or else we weren't initialized. */
         handle = get_handle_for_root(root);
         if (handle == NULL)
                 return;

@@ -598,27 +599,27 @@
  *
  * "group" can be either an sa_group_t or an sa_share_t. (void *)
  * works since both thse types are also void *.
  * If the share is a ZFS share, mark it as persistent.
  */
-int
+boolean_t
 sa_is_persistent(void *group)
 {
         char *type;
-        int persist = 1;
+        boolean_t persist = B_TRUE;
         sa_group_t grp;
 
         type = sa_get_group_attr((sa_group_t)group, "type");
         if (type != NULL) {
                 if (strcmp(type, "transient") == 0)
-                        persist = 0;
+                        persist = B_FALSE;
                 sa_free_attr_string(type);
         }
 
         grp = (sa_is_share(group)) ? sa_get_parent_group(group) : group;
         if (sa_group_is_zfs(grp))
-                persist = 1;
+                persist = B_TRUE;
 
         return (persist);
 }
 
 /*

@@ -831,14 +832,14 @@
         uint64_t tval = 0;
         int lockfd;
         sigset_t old;
         int updatelegacy = B_FALSE;
         scf_simple_prop_t *prop;
-        sa_handle_impl_t handle;
+        sa_handle_t handle;
         int err;
 
-        handle = calloc(sizeof (struct sa_handle_impl), 1);
+        handle = calloc(sizeof (struct sa_handle), 1);
 
         if (handle != NULL) {
                 /*
                  * Get protocol specific structures, but only if this
                  * is the only handle.

@@ -987,11 +988,11 @@
                                         verifydefgroupopts(handle);
                                 }
 
                                 if (updatelegacy == B_TRUE) {
                                         sablocksigs(&old);
-                                        getlegacyconfig((sa_handle_t)handle,
+                                        getlegacyconfig(handle,
                                             SA_LEGACY_DFSTAB, &handle->tree);
                                         if (stat(SA_LEGACY_DFSTAB, &st) >= 0)
                                                 set_legacy_timestamp(
                                                     handle->tree,
                                                     SA_LEGACY_DFSTAB,

@@ -1004,11 +1005,11 @@
                                         (void) mutex_unlock(&sa_dfstab_lock);
                                         (void) lockf(lockfd, F_ULOCK, 0);
                                         (void) close(lockfd);
                                 }
                                 /* Get sharetab timestamp */
-                                sa_update_sharetab_ts((sa_handle_t)handle);
+                                sa_update_sharetab_ts(handle);
 
                                 /* Get lastupdate (transaction) timestamp */
                                 prop = scf_simple_prop_get(
                                     handle->scfhandle->handle,
                                     (const char *)SA_SVC_FMRI_BASE ":default",

@@ -1027,11 +1028,11 @@
                                 legacy |= sa_get_zfs_shares(handle, "zfs");
                                 legacy |= gettransients(handle, &handle->tree);
                         }
                 }
         }
-        return ((sa_handle_t)handle);
+        return (handle);
 }
 
 /*
  * sa_fini(handle)
  *      Uninitialize the API structures including the configuration

@@ -1039,22 +1040,20 @@
  */
 
 void
 sa_fini(sa_handle_t handle)
 {
-        sa_handle_impl_t impl_handle = (sa_handle_impl_t)handle;
-
-        if (impl_handle != NULL) {
+        if (handle != NULL) {
                 /*
                  * Free the config trees and any other data structures
                  * used in the handle.
                  */
-                if (impl_handle->doc != NULL)
-                        xmlFreeDoc(impl_handle->doc);
+                if (handle->doc != NULL)
+                        xmlFreeDoc(handle->doc);
 
                 /* Remove and free the entry in the global list. */
-                remove_handle_for_root(impl_handle->tree);
+                remove_handle_for_root(handle->tree);
 
                 /*
                  * If this was the last handle to release, unload the
                  * plugins that were loaded. Use a mutex in case
                  * another thread is reinitializing.

@@ -1062,15 +1061,15 @@
                 (void) mutex_lock(&sa_global_lock);
                 if (sa_global_handles == NULL)
                         (void) proto_plugin_fini();
                 (void) mutex_unlock(&sa_global_lock);
 
-                sa_scf_fini(impl_handle->scfhandle);
-                sa_zfs_fini(impl_handle);
+                sa_scf_fini(handle->scfhandle);
+                sa_zfs_fini(handle);
 
                 /* Make sure we free the handle */
-                free(impl_handle);
+                free(handle);
 
         }
 }
 
 /*

@@ -1153,13 +1152,12 @@
 sa_get_group(sa_handle_t handle, char *groupname)
 {
         xmlNodePtr node = NULL;
         char *subgroup = NULL;
         char *group = NULL;
-        sa_handle_impl_t impl_handle = (sa_handle_impl_t)handle;
 
-        if (impl_handle != NULL && impl_handle->tree != NULL) {
+        if (handle != NULL && handle->tree != NULL) {
                 if (groupname != NULL) {
                         group = strdup(groupname);
                         if (group != NULL) {
                                 subgroup = strchr(group, '/');
                                 if (subgroup != NULL)

@@ -1172,19 +1170,19 @@
                  * NULL, we only do the find if groupname is also
                  * NULL. This allows lookup of the "first" group in
                  * the internal list.
                  */
                 if (group != NULL || groupname == NULL)
-                        node = find_group_by_name(impl_handle->tree,
+                        node = find_group_by_name(handle->tree,
                             (xmlChar *)group);
 
                 /* if a subgroup, find it before returning */
                 if (subgroup != NULL && node != NULL)
                         node = find_group_by_name(node, (xmlChar *)subgroup);
         }
         if (node != NULL && (char *)group != NULL)
-                (void) sa_get_instance(impl_handle->scfhandle, (char *)group);
+                (void) sa_get_instance(handle->scfhandle, (char *)group);
         if (group != NULL)
                 free(group);
         return ((sa_group_t)(node));
 }
 

@@ -1500,15 +1498,13 @@
                         if (sa_get_optionset(group, "nfs") != NULL)
                                 err = sa_zfs_set_sharenfs(group, sharepath, 1);
                         else if (sa_get_optionset(group, "smb") != NULL)
                                 err = sa_zfs_set_sharesmb(group, sharepath, 1);
                 } else {
-                        sa_handle_impl_t impl_handle;
-                        impl_handle =
-                            (sa_handle_impl_t)sa_find_group_handle(group);
-                        if (impl_handle != NULL) {
-                                err = sa_commit_share(impl_handle->scfhandle,
+                        sa_handle_t handle = sa_find_group_handle(group);
+                        if (handle != NULL) {
+                                err = sa_commit_share(handle->scfhandle,
                                     group, (sa_share_t)node);
                         } else {
                                 err = SA_SYSTEM_ERR;
                         }
                 }

@@ -1739,16 +1735,15 @@
         if (!transient || zfs != NULL) {
                 /* remove from legacy dfstab as well as possible SMF */
                 ret = sa_delete_legacy(share, NULL);
                 if (ret == SA_OK) {
                         if (!sa_group_is_zfs(group)) {
-                                sa_handle_impl_t impl_handle;
-                                impl_handle = (sa_handle_impl_t)
+                                sa_handle_t handle =
                                     sa_find_group_handle(group);
-                                if (impl_handle != NULL) {
+                                if (handle != NULL) {
                                         ret = sa_delete_share(
-                                            impl_handle->scfhandle, group,
+                                            handle->scfhandle, group,
                                             share);
                                 } else {
                                         ret = SA_SYSTEM_ERR;
                                 }
                         } else {

@@ -1787,30 +1782,30 @@
 
         /* remove the node from its group then free the memory */
 
         oldgroup = sa_get_parent_group(share);
         if (oldgroup != group) {
-                sa_handle_impl_t impl_handle;
+                sa_handle_t handle;
                 xmlUnlinkNode((xmlNodePtr)share);
                 /*
                  * now that the share isn't in its old group, add to
                  * the new one
                  */
                 (void) xmlAddChild((xmlNodePtr)group, (xmlNodePtr)share);
                 /* need to deal with SMF */
-                impl_handle = (sa_handle_impl_t)sa_find_group_handle(group);
-                if (impl_handle != NULL) {
+                handle = sa_find_group_handle(group);
+                if (handle != NULL) {
                         /*
                          * need to remove from old group first and then add to
                          * new group. Ideally, we would do the other order but
                          * need to avoid having the share in two groups at the
                          * same time.
                          */
-                        ret = sa_delete_share(impl_handle->scfhandle, oldgroup,
+                        ret = sa_delete_share(handle->scfhandle, oldgroup,
                             share);
                         if (ret == SA_OK)
-                                ret = sa_commit_share(impl_handle->scfhandle,
+                                ret = sa_commit_share(handle->scfhandle,
                                     group, share);
                 } else {
                         ret = SA_SYSTEM_ERR;
                 }
         }

@@ -1841,23 +1836,23 @@
         }
         return ((sa_group_t)node);
 }
 
 /*
- * _sa_create_group(impl_handle, groupname)
+ * _sa_create_group(handle, groupname)
  *
  * Create a group in the document. The caller will need to deal with
  * configuration store and activation.
  */
 
 sa_group_t
-_sa_create_group(sa_handle_impl_t impl_handle, char *groupname)
+_sa_create_group(sa_handle_t handle, char *groupname)
 {
         xmlNodePtr node = NULL;
 
         if (sa_valid_group_name(groupname)) {
-                node = xmlNewChild(impl_handle->tree, NULL, (xmlChar *)"group",
+                node = xmlNewChild(handle->tree, NULL, (xmlChar *)"group",
                     NULL);
                 if (node != NULL) {
                         (void) xmlSetProp(node, (xmlChar *)"name",
                             (xmlChar *)groupname);
                         (void) xmlSetProp(node, (xmlChar *)"state",

@@ -1904,82 +1899,81 @@
 {
         xmlNodePtr node = NULL;
         sa_group_t group;
         int ret;
         char rbacstr[SA_STRSIZE];
-        sa_handle_impl_t impl_handle = (sa_handle_impl_t)handle;
 
         ret = SA_OK;
 
-        if (impl_handle == NULL || impl_handle->scfhandle == NULL) {
+        if (handle == NULL || handle->scfhandle == NULL) {
                 ret = SA_SYSTEM_ERR;
                 goto err;
         }
 
         group = sa_get_group(handle, groupname);
         if (group != NULL) {
                 ret = SA_DUPLICATE_NAME;
         } else {
                 if (sa_valid_group_name(groupname)) {
-                        node = xmlNewChild(impl_handle->tree, NULL,
+                        node = xmlNewChild(handle->tree, NULL,
                             (xmlChar *)"group", NULL);
                         if (node != NULL) {
                                 (void) xmlSetProp(node, (xmlChar *)"name",
                                     (xmlChar *)groupname);
                                 /* default to the group being enabled */
                                 (void) xmlSetProp(node, (xmlChar *)"state",
                                     (xmlChar *)"enabled");
-                                ret = sa_create_instance(impl_handle->scfhandle,
+                                ret = sa_create_instance(handle->scfhandle,
                                     groupname);
                                 if (ret == SA_OK) {
                                         ret = sa_start_transaction(
-                                            impl_handle->scfhandle,
+                                            handle->scfhandle,
                                             "operation");
                                 }
                                 if (ret == SA_OK) {
                                         ret = sa_set_property(
-                                            impl_handle->scfhandle,
+                                            handle->scfhandle,
                                             "state", "enabled");
                                         if (ret == SA_OK) {
                                                 ret = sa_end_transaction(
-                                                    impl_handle->scfhandle,
-                                                    impl_handle);
+                                                    handle->scfhandle,
+                                                    handle);
                                         } else {
                                                 sa_abort_transaction(
-                                                    impl_handle->scfhandle);
+                                                    handle->scfhandle);
                                         }
                                 }
                                 if (ret == SA_OK) {
                                         /* initialize the RBAC strings */
                                         ret = sa_start_transaction(
-                                            impl_handle->scfhandle,
+                                            handle->scfhandle,
                                             "general");
                                         if (ret == SA_OK) {
                                                 (void) snprintf(rbacstr,
                                                     sizeof (rbacstr), "%s.%s",
                                                     SA_RBAC_MANAGE, groupname);
                                                 ret = sa_set_property(
-                                                    impl_handle->scfhandle,
+                                                    handle->scfhandle,
                                                     "action_authorization",
                                                     rbacstr);
                                         }
                                         if (ret == SA_OK) {
                                                 (void) snprintf(rbacstr,
                                                     sizeof (rbacstr), "%s.%s",
                                                     SA_RBAC_VALUE, groupname);
                                                 ret = sa_set_property(
-                                                    impl_handle->scfhandle,
+                                                    handle->scfhandle,
                                                     "value_authorization",
                                                     rbacstr);
                                         }
                                         if (ret == SA_OK) {
                                                 ret = sa_end_transaction(
-                                                    impl_handle->scfhandle,
-                                                    impl_handle);
+                                                    handle->scfhandle,
+                                                    handle);
                                         } else {
                                                 sa_abort_transaction(
-                                                    impl_handle->scfhandle);
+                                                    handle->scfhandle);
                                         }
                                 }
                                 if (ret != SA_OK) {
                                         /*
                                          * Couldn't commit the group

@@ -2013,17 +2007,17 @@
 int
 sa_remove_group(sa_group_t group)
 {
         char *name;
         int ret = SA_OK;
-        sa_handle_impl_t impl_handle;
+        sa_handle_t handle;
 
-        impl_handle = (sa_handle_impl_t)sa_find_group_handle(group);
-        if (impl_handle != NULL) {
+        handle = sa_find_group_handle(group);
+        if (handle != NULL) {
                 name = sa_get_group_attr(group, "name");
                 if (name != NULL) {
-                        ret = sa_delete_instance(impl_handle->scfhandle, name);
+                        ret = sa_delete_instance(handle->scfhandle, name);
                         sa_free_attr_string(name);
                 }
                 xmlUnlinkNode((xmlNodePtr)group); /* make sure unlinked */
                 xmlFreeNode((xmlNodePtr)group);   /* now it is gone */
         } else {

@@ -2116,38 +2110,38 @@
 int
 sa_set_group_attr(sa_group_t group, char *tag, char *value)
 {
         int ret;
         char *groupname;
-        sa_handle_impl_t impl_handle;
+        sa_handle_t handle;
 
         /*
          * ZFS group/subgroup doesn't need the handle so shortcut.
          */
         if (sa_group_is_zfs(group)) {
                 set_node_attr((void *)group, tag, value);
                 return (SA_OK);
         }
 
-        impl_handle = (sa_handle_impl_t)sa_find_group_handle(group);
-        if (impl_handle != NULL) {
+        handle = sa_find_group_handle(group);
+        if (handle != NULL) {
                 groupname = sa_get_group_attr(group, "name");
-                ret = sa_get_instance(impl_handle->scfhandle, groupname);
+                ret = sa_get_instance(handle->scfhandle, groupname);
                 if (ret == SA_OK) {
                         set_node_attr((void *)group, tag, value);
-                        ret = sa_start_transaction(impl_handle->scfhandle,
+                        ret = sa_start_transaction(handle->scfhandle,
                             "operation");
                         if (ret == SA_OK) {
-                                ret = sa_set_property(impl_handle->scfhandle,
+                                ret = sa_set_property(handle->scfhandle,
                                     tag, value);
                                 if (ret == SA_OK)
                                         ret = sa_end_transaction(
-                                            impl_handle->scfhandle,
-                                            impl_handle);
+                                            handle->scfhandle,
+                                            handle);
                                 else
                                         sa_abort_transaction(
-                                            impl_handle->scfhandle);
+                                            handle->scfhandle);
                         }
                         if (ret == SA_SYSTEM_ERR)
                                 ret = SA_NO_PERMISSION;
                 }
                 if (groupname != NULL)

@@ -2224,17 +2218,15 @@
                 if (group != NULL) {
                         char *type;
                         /* we can probably optimize this some */
                         type = sa_get_share_attr(share, "type");
                         if (type == NULL || strcmp(type, "transient") != 0) {
-                                sa_handle_impl_t impl_handle;
-                                impl_handle =
-                                    (sa_handle_impl_t)sa_find_group_handle(
+                                sa_handle_t handle = sa_find_group_handle(
                                     group);
-                                if (impl_handle != NULL) {
+                                if (handle != NULL) {
                                         ret = sa_commit_share(
-                                            impl_handle->scfhandle, group,
+                                            handle->scfhandle, group,
                                             share);
                                 } else {
                                         ret = SA_SYSTEM_ERR;
                                 }
                         }

@@ -2525,14 +2517,13 @@
                 xmlFreeNode(node);
         }
         group = sa_get_parent_group(share);
         if (group != NULL &&
             sa_is_persistent(share) && (!sa_group_is_zfs(group))) {
-                sa_handle_impl_t impl_handle;
-                impl_handle = (sa_handle_impl_t)sa_find_group_handle(group);
-                if (impl_handle != NULL) {
-                        ret = sa_commit_share(impl_handle->scfhandle, group,
+                sa_handle_t handle = sa_find_group_handle(group);
+                if (handle != NULL) {
+                        ret = sa_commit_share(handle->scfhandle, group,
                             share);
                 } else {
                         ret = SA_SYSTEM_ERR;
                 }
         }

@@ -2671,20 +2662,18 @@
 
                         (void) sa_optionset_name(optionset, oname,
                             sizeof (oname), id);
                         groupname = sa_get_group_attr(parent, "name");
                         if (groupname != NULL && sa_is_persistent(group)) {
-                                sa_handle_impl_t impl_handle;
-                                impl_handle =
-                                    (sa_handle_impl_t)sa_find_group_handle(
+                                sa_handle_t handle = sa_find_group_handle(
                                     group);
-                                assert(impl_handle != NULL);
-                                if (impl_handle != NULL) {
+                                assert(handle != NULL);
+                                if (handle != NULL) {
                                         (void) sa_get_instance(
-                                            impl_handle->scfhandle, groupname);
+                                            handle->scfhandle, groupname);
                                         (void) sa_create_pgroup(
-                                            impl_handle->scfhandle, oname);
+                                            handle->scfhandle, oname);
                                 }
                         }
                         if (groupname != NULL)
                                 sa_free_attr_string(groupname);
                 }

@@ -2779,11 +2768,11 @@
         sa_group_t group;
         sa_group_t parent;
         int zfs = 0;
         int needsupdate = 0;
         int ret = SA_OK;
-        sa_handle_impl_t impl_handle;
+        sa_handle_t handle;
 
         group = sa_get_optionset_parent(optionset);
         if (group != NULL && (sa_is_share(group) || is_zfs_group(group))) {
                 /* only update ZFS if on a share */
                 parent = sa_get_parent_group(group);

@@ -2795,18 +2784,18 @@
         }
         if (zfs) {
                 if (!clear && needsupdate)
                         ret = sa_zfs_update((sa_share_t)group);
         } else {
-                impl_handle = (sa_handle_impl_t)sa_find_group_handle(group);
-                if (impl_handle != NULL) {
+                handle = sa_find_group_handle(group);
+                if (handle != NULL) {
                         if (clear) {
                                 (void) sa_abort_transaction(
-                                    impl_handle->scfhandle);
+                                    handle->scfhandle);
                         } else {
                                 ret = sa_end_transaction(
-                                    impl_handle->scfhandle, impl_handle);
+                                    handle->scfhandle, handle);
                         }
                 } else {
                         ret = SA_SYSTEM_ERR;
                 }
         }

@@ -2842,16 +2831,15 @@
                         id = sa_get_share_attr((sa_share_t)group, "id");
                 }
                 ispersist = sa_is_persistent(group);
         }
         if (ispersist) {
-                sa_handle_impl_t impl_handle;
+                sa_handle_t handle = sa_find_group_handle(group);
                 len = sa_optionset_name(optionset, name, sizeof (name), id);
-                impl_handle = (sa_handle_impl_t)sa_find_group_handle(group);
-                if (impl_handle != NULL) {
+                if (handle != NULL) {
                         if (len > 0) {
-                                ret = sa_delete_pgroup(impl_handle->scfhandle,
+                                ret = sa_delete_pgroup(handle->scfhandle,
                                     name);
                         }
                 } else {
                         ret = SA_SYSTEM_ERR;
                 }

@@ -2911,19 +2899,17 @@
 
                         sa_set_security_attr(security, "sectype", sectype);
                         (void) sa_security_name(security, oname,
                             sizeof (oname), id);
                         if (groupname != NULL && sa_is_persistent(group)) {
-                                sa_handle_impl_t impl_handle;
-                                impl_handle =
-                                    (sa_handle_impl_t)sa_find_group_handle(
+                                sa_handle_t handle = sa_find_group_handle(
                                     group);
-                                if (impl_handle != NULL) {
+                                if (handle != NULL) {
                                         (void) sa_get_instance(
-                                            impl_handle->scfhandle, groupname);
+                                            handle->scfhandle, groupname);
                                         (void) sa_create_pgroup(
-                                            impl_handle->scfhandle, oname);
+                                            handle->scfhandle, oname);
                                 }
                         }
                 }
         }
         if (id != NULL)

@@ -2962,15 +2948,13 @@
                 id = sa_get_share_attr((sa_share_t)group, "id");
         }
         if (ispersist) {
                 len = sa_security_name(security, name, sizeof (name), id);
                 if (!iszfs && len > 0) {
-                        sa_handle_impl_t impl_handle;
-                        impl_handle =
-                            (sa_handle_impl_t)sa_find_group_handle(group);
-                        if (impl_handle != NULL) {
-                                ret = sa_delete_pgroup(impl_handle->scfhandle,
+                        sa_handle_t handle = sa_find_group_handle(group);
+                        if (handle != NULL) {
+                                ret = sa_delete_pgroup(handle->scfhandle,
                                     name);
                         } else {
                                 ret = SA_SYSTEM_ERR;
                         }
                 }

@@ -3075,24 +3059,24 @@
         int opttype; /* 1 == optionset, 0 == security */
         char *id = NULL;
         int iszfs = 0;
         sa_group_t parent = NULL;
         sa_share_t share = NULL;
-        sa_handle_impl_t impl_handle;
+        sa_handle_t handle;
         scfutilhandle_t  *scf_handle;
 
         if (!sa_is_persistent(group)) {
                 /*
                  * if the group/share is not persistent we don't need
                  * to do anything here
                  */
                 return (SA_OK);
         }
-        impl_handle = (sa_handle_impl_t)sa_find_group_handle(group);
-        if (impl_handle == NULL || impl_handle->scfhandle == NULL)
+        handle = sa_find_group_handle(group);
+        if (handle == NULL || handle->scfhandle == NULL)
                 return (SA_SYSTEM_ERR);
-        scf_handle = impl_handle->scfhandle;
+        scf_handle = handle->scfhandle;
         name = sa_get_property_attr(prop, "type");
         valstr = sa_get_property_attr(prop, "value");
         entry = scf_entry_create(scf_handle->handle);
         opttype = is_nodetype((void *)optionset, "optionset");
 

@@ -3286,20 +3270,19 @@
         } else {
                 char oname[SA_STRSIZE];
 
                 if (!is_zfs_group(group)) {
                         char *id = NULL;
-                        sa_handle_impl_t impl_handle;
+                        sa_handle_t handle;
                         scfutilhandle_t  *scf_handle;
 
-                        impl_handle = (sa_handle_impl_t)sa_find_group_handle(
-                            group);
-                        if (impl_handle == NULL ||
-                            impl_handle->scfhandle == NULL)
+                        handle = sa_find_group_handle(group);
+                        if (handle == NULL ||
+                            handle->scfhandle == NULL)
                                 ret = SA_SYSTEM_ERR;
                         if (ret == SA_OK) {
-                                scf_handle = impl_handle->scfhandle;
+                                scf_handle = handle->scfhandle;
                                 if (sa_is_share((sa_group_t)parent)) {
                                         id = sa_get_share_attr(
                                             (sa_share_t)parent, "id");
                                 }
                                 if (scf_handle->trans == NULL) {

@@ -3794,18 +3777,17 @@
                                 if (!sa_is_persistent((sa_group_t)share))
                                         goto done;
 
                                 if (!sa_group_is_zfs(group)) {
                                         /* ZFS doesn't use resource names */
-                                        sa_handle_impl_t ihandle;
+                                        sa_handle_t handle;
 
-                                        ihandle = (sa_handle_impl_t)
-                                            sa_find_group_handle(
+                                        handle = sa_find_group_handle(
                                             group);
-                                        if (ihandle != NULL)
+                                        if (handle != NULL)
                                                 err = sa_commit_share(
-                                                    ihandle->scfhandle, group,
+                                                    handle->scfhandle, group,
                                                     share);
                                         else
                                                 err = SA_SYSTEM_ERR;
                                 } else {
                                         err = sa_zfs_update((sa_share_t)group);

@@ -3862,14 +3844,13 @@
         /* only do SMF action if permanent and not ZFS */
         if (transient)
                 return (ret);
 
         if (!sa_group_is_zfs(group)) {
-                sa_handle_impl_t ihandle;
-                ihandle = (sa_handle_impl_t)sa_find_group_handle(group);
-                if (ihandle != NULL)
-                        ret = sa_commit_share(ihandle->scfhandle, group, share);
+                sa_handle_t handle = sa_find_group_handle(group);
+                if (handle != NULL)
+                        ret = sa_commit_share(handle->scfhandle, group, share);
                 else
                         ret = SA_SYSTEM_ERR;
         } else {
                 ret = sa_zfs_update((sa_share_t)group);
         }

@@ -3928,11 +3909,11 @@
 
         group = sa_get_parent_group(share);
         if (group == NULL)
                 return (ret);
 
-        handle = (sa_handle_impl_t)sa_find_group_handle(group);
+        handle = sa_find_group_handle(group);
         if (handle == NULL)
                 return (ret);
 
         target = sa_find_resource(handle, newname);
         if (target != NULL) {

@@ -3948,12 +3929,11 @@
 
                 if (!sa_is_persistent((sa_group_t)share))
                         return (ret);
 
                 if (!sa_group_is_zfs(group)) {
-                        sa_handle_impl_t ihandle = (sa_handle_impl_t)handle;
-                        ret = sa_commit_share(ihandle->scfhandle, group,
+                        ret = sa_commit_share(handle->scfhandle, group,
                             share);
                 } else {
                         ret = sa_zfs_update((sa_share_t)group);
                 }
         }

@@ -4362,14 +4342,13 @@
 
         share = sa_get_resource_parent(resource);
         group = sa_get_parent_group(share);
         if (group != NULL &&
             sa_is_persistent(share) && (!sa_group_is_zfs(group))) {
-                sa_handle_impl_t impl_handle;
-                impl_handle = (sa_handle_impl_t)sa_find_group_handle(group);
-                if (impl_handle != NULL)
-                        ret = sa_commit_share(impl_handle->scfhandle,
+                sa_handle_t handle = sa_find_group_handle(group);
+                if (handle != NULL)
+                        ret = sa_commit_share(handle->scfhandle,
                             group, share);
                 else
                         ret = SA_SYSTEM_ERR;
         }
         return (ret);