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 2010 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  * Copyright 2012 Milan Jurik. All rights reserved.
  26  */
  27 
  28 #include <sys/types.h>
  29 #include <sys/stat.h>
  30 #include <fcntl.h>
  31 #include <stdlib.h>
  32 #include <stdio.h>
  33 #include <string.h>
  34 #include <ctype.h>
  35 #include <unistd.h>
  36 #include <getopt.h>
  37 #include <utmpx.h>
  38 #include <pwd.h>
  39 #include <auth_attr.h>
  40 #include <secdb.h>
  41 #include <sys/param.h>
  42 #include <sys/stat.h>
  43 #include <errno.h>
  44 
  45 #include <libshare.h>
 
 
2149                 if (description != NULL)
2150                         sa_free_share_description(description);
2151         } else {
2152                 (void) printf("\t  %s", sharepath);
2153                 if (properties)
2154                         show_properties(share, proto, "\t");
2155         }
2156         (void) printf("\n");
2157 }
2158 
2159 /*
2160  * show_group(group, verbose, properties, proto, subgroup)
2161  *
2162  * helper function to show the contents of a group.
2163  */
2164 
2165 static void
2166 show_group(sa_group_t group, int verbose, int properties, char *proto,
2167     char *subgroup)
2168 {
2169         sa_share_t share;
2170         char *groupname;
2171         char *zfs = NULL;
2172         int iszfs = 0;
2173         char *sharepath;
2174 
2175         groupname = sa_get_group_attr(group, "name");
2176         if (groupname != NULL) {
2177                 if (proto != NULL && !has_protocol(group, proto)) {
2178                         sa_free_attr_string(groupname);
2179                         return;
2180                 }
2181                 /*
2182                  * check to see if the group is managed by ZFS. If
2183                  * there is an attribute, then it is. A non-NULL zfs
2184                  * variable will trigger the different way to display
2185                  * and will remove the transient property indicator
2186                  * from the output.
2187                  */
2188                 zfs = sa_get_group_attr(group, "zfs");
2189                 if (zfs != NULL) {
2190                         iszfs = 1;
2191                         sa_free_attr_string(zfs);
2192                 }
2193                 share = sa_get_share(group, NULL);
2194                 if (subgroup == NULL)
2195                         (void) printf("%s", groupname);
2196                 else
2197                         (void) printf("    %s/%s", subgroup, groupname);
2198                 if (properties)
2199                         show_properties(group, proto, "");
2200                 (void) printf("\n");
2201                 if (strcmp(groupname, "zfs") == 0) {
2202                         sa_group_t zgroup;
2203 
2204                         for (zgroup = sa_get_sub_group(group);
2205                             zgroup != NULL;
2206                             zgroup = sa_get_next_group(zgroup)) {
2207                                 show_group(zgroup, verbose, properties, proto,
2208                                     "zfs");
2209                         }
2210                         sa_free_attr_string(groupname);
2211                         return;
2212                 }
2213                 /*
 
 | 
 
 
   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 2010 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 /*
  28  * Copyright 2012 Milan Jurik. All rights reserved.
  29  * Copyright 2018 Nexenta Systems, Inc.
  30  */
  31 
  32 #include <sys/types.h>
  33 #include <sys/stat.h>
  34 #include <fcntl.h>
  35 #include <stdlib.h>
  36 #include <stdio.h>
  37 #include <string.h>
  38 #include <ctype.h>
  39 #include <unistd.h>
  40 #include <getopt.h>
  41 #include <utmpx.h>
  42 #include <pwd.h>
  43 #include <auth_attr.h>
  44 #include <secdb.h>
  45 #include <sys/param.h>
  46 #include <sys/stat.h>
  47 #include <errno.h>
  48 
  49 #include <libshare.h>
 
 
2153                 if (description != NULL)
2154                         sa_free_share_description(description);
2155         } else {
2156                 (void) printf("\t  %s", sharepath);
2157                 if (properties)
2158                         show_properties(share, proto, "\t");
2159         }
2160         (void) printf("\n");
2161 }
2162 
2163 /*
2164  * show_group(group, verbose, properties, proto, subgroup)
2165  *
2166  * helper function to show the contents of a group.
2167  */
2168 
2169 static void
2170 show_group(sa_group_t group, int verbose, int properties, char *proto,
2171     char *subgroup)
2172 {
2173         char *groupname;
2174         char *zfs = NULL;
2175         int iszfs = 0;
2176         char *sharepath;
2177 
2178         groupname = sa_get_group_attr(group, "name");
2179         if (groupname != NULL) {
2180                 sa_share_t share;
2181 
2182                 if (proto != NULL && !has_protocol(group, proto)) {
2183                         sa_free_attr_string(groupname);
2184                         return;
2185                 }
2186                 /*
2187                  * check to see if the group is managed by ZFS. If
2188                  * there is an attribute, then it is. A non-NULL zfs
2189                  * variable will trigger the different way to display
2190                  * and will remove the transient property indicator
2191                  * from the output.
2192                  */
2193                 zfs = sa_get_group_attr(group, "zfs");
2194                 if (zfs != NULL) {
2195                         iszfs = 1;
2196                         sa_free_attr_string(zfs);
2197                 }
2198 
2199                 if (subgroup == NULL)
2200                         (void) printf("%s", groupname);
2201                 else
2202                         (void) printf("    %s/%s", subgroup, groupname);
2203                 if (properties)
2204                         show_properties(group, proto, "");
2205                 (void) printf("\n");
2206                 if (strcmp(groupname, "zfs") == 0) {
2207                         sa_group_t zgroup;
2208 
2209                         for (zgroup = sa_get_sub_group(group);
2210                             zgroup != NULL;
2211                             zgroup = sa_get_next_group(zgroup)) {
2212                                 show_group(zgroup, verbose, properties, proto,
2213                                     "zfs");
2214                         }
2215                         sa_free_attr_string(groupname);
2216                         return;
2217                 }
2218                 /*
 
 |