Print this page
11083 support NFS server in zone
Portions contributed by: Dan Kruchinin <dan.kruchinin@nexenta.com>
Portions contributed by: Stepan Zastupov <stepan.zastupov@gmail.com>
Portions contributed by: Joyce McIntosh <joyce.mcintosh@nexenta.com>
Portions contributed by: Mike Zeller <mike@mikezeller.net>
Portions contributed by: Dan McDonald <danmcd@joyent.com>
Portions contributed by: Gordon Ross <gordon.w.ross@gmail.com>
Portions contributed by: Vitaliy Gusev <gusev.vitaliy@gmail.com>
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>
Reviewed by: Rob Gittins <rob.gittins@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Jason King <jbk@joyent.com>
Reviewed by: C Fraire <cfraire@me.com>
Change-Id: I22f289d357503f9b48a0bc2482cc4328a6d43d16


   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  * Copyright 2019, Joyent, Inc.
  27  */
  28 
  29 #include <sys/types.h>
  30 #include <sys/stat.h>
  31 #include <fcntl.h>
  32 #include <stdlib.h>
  33 #include <stdio.h>
  34 #include <string.h>
  35 #include <ctype.h>
  36 #include <unistd.h>
  37 #include <getopt.h>
  38 #include <utmpx.h>
  39 #include <pwd.h>
  40 #include <auth_attr.h>
  41 #include <secdb.h>
  42 #include <sys/param.h>
  43 #include <sys/stat.h>
  44 #include <errno.h>
  45 


2150                 if (description != NULL)
2151                         sa_free_share_description(description);
2152         } else {
2153                 (void) printf("\t  %s", sharepath);
2154                 if (properties)
2155                         show_properties(share, proto, "\t");
2156         }
2157         (void) printf("\n");
2158 }
2159 
2160 /*
2161  * show_group(group, verbose, properties, proto, subgroup)
2162  *
2163  * helper function to show the contents of a group.
2164  */
2165 
2166 static void
2167 show_group(sa_group_t group, int verbose, int properties, char *proto,
2168     char *subgroup)
2169 {
2170         sa_share_t share;
2171         char *groupname;
2172         char *zfs = NULL;
2173         int iszfs = 0;
2174         char *sharepath;
2175 
2176         groupname = sa_get_group_attr(group, "name");
2177         if (groupname != NULL) {


2178                 if (proto != NULL && !has_protocol(group, proto)) {
2179                         sa_free_attr_string(groupname);
2180                         return;
2181                 }
2182                 /*
2183                  * check to see if the group is managed by ZFS. If
2184                  * there is an attribute, then it is. A non-NULL zfs
2185                  * variable will trigger the different way to display
2186                  * and will remove the transient property indicator
2187                  * from the output.
2188                  */
2189                 zfs = sa_get_group_attr(group, "zfs");
2190                 if (zfs != NULL) {
2191                         iszfs = 1;
2192                         sa_free_attr_string(zfs);
2193                 }
2194                 share = sa_get_share(group, NULL);
2195                 if (subgroup == NULL)
2196                         (void) printf("%s", groupname);
2197                 else
2198                         (void) printf("    %s/%s", subgroup, groupname);
2199                 if (properties)
2200                         show_properties(group, proto, "");
2201                 (void) printf("\n");
2202                 if (strcmp(groupname, "zfs") == 0) {
2203                         sa_group_t zgroup;
2204 
2205                         for (zgroup = sa_get_sub_group(group);
2206                             zgroup != NULL;
2207                             zgroup = sa_get_next_group(zgroup)) {
2208                                 show_group(zgroup, verbose, properties, proto,
2209                                     "zfs");
2210                         }
2211                         sa_free_attr_string(groupname);
2212                         return;
2213                 }
2214                 /*




   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  * Copyright 2019, Joyent, Inc.
  31  */
  32 
  33 #include <sys/types.h>
  34 #include <sys/stat.h>
  35 #include <fcntl.h>
  36 #include <stdlib.h>
  37 #include <stdio.h>
  38 #include <string.h>
  39 #include <ctype.h>
  40 #include <unistd.h>
  41 #include <getopt.h>
  42 #include <utmpx.h>
  43 #include <pwd.h>
  44 #include <auth_attr.h>
  45 #include <secdb.h>
  46 #include <sys/param.h>
  47 #include <sys/stat.h>
  48 #include <errno.h>
  49 


2154                 if (description != NULL)
2155                         sa_free_share_description(description);
2156         } else {
2157                 (void) printf("\t  %s", sharepath);
2158                 if (properties)
2159                         show_properties(share, proto, "\t");
2160         }
2161         (void) printf("\n");
2162 }
2163 
2164 /*
2165  * show_group(group, verbose, properties, proto, subgroup)
2166  *
2167  * helper function to show the contents of a group.
2168  */
2169 
2170 static void
2171 show_group(sa_group_t group, int verbose, int properties, char *proto,
2172     char *subgroup)
2173 {

2174         char *groupname;
2175         char *zfs = NULL;
2176         int iszfs = 0;
2177         char *sharepath;
2178 
2179         groupname = sa_get_group_attr(group, "name");
2180         if (groupname != NULL) {
2181                 sa_share_t share;
2182 
2183                 if (proto != NULL && !has_protocol(group, proto)) {
2184                         sa_free_attr_string(groupname);
2185                         return;
2186                 }
2187                 /*
2188                  * check to see if the group is managed by ZFS. If
2189                  * there is an attribute, then it is. A non-NULL zfs
2190                  * variable will trigger the different way to display
2191                  * and will remove the transient property indicator
2192                  * from the output.
2193                  */
2194                 zfs = sa_get_group_attr(group, "zfs");
2195                 if (zfs != NULL) {
2196                         iszfs = 1;
2197                         sa_free_attr_string(zfs);
2198                 }
2199 
2200                 if (subgroup == NULL)
2201                         (void) printf("%s", groupname);
2202                 else
2203                         (void) printf("    %s/%s", subgroup, groupname);
2204                 if (properties)
2205                         show_properties(group, proto, "");
2206                 (void) printf("\n");
2207                 if (strcmp(groupname, "zfs") == 0) {
2208                         sa_group_t zgroup;
2209 
2210                         for (zgroup = sa_get_sub_group(group);
2211                             zgroup != NULL;
2212                             zgroup = sa_get_next_group(zgroup)) {
2213                                 show_group(zgroup, verbose, properties, proto,
2214                                     "zfs");
2215                         }
2216                         sa_free_attr_string(groupname);
2217                         return;
2218                 }
2219                 /*