diff options
author | Evan Layton <evan.layton@nexenta.com> | 2018-03-05 20:41:49 -0800 |
---|---|---|
committer | Dan McDonald <danmcd@joyent.com> | 2020-02-07 12:52:15 -0500 |
commit | 0dfe541e13279d277d838d6a27e55188b9486cb1 (patch) | |
tree | 829622e0bbae74d30f6154c7355b9dffa88bb8d0 /usr/src/lib/libshare/nfs/libshare_nfs.c | |
parent | d8ab6e129d75d7c3f21a7909bf811a3de65faea8 (diff) | |
download | illumos-joyent-0dfe541e13279d277d838d6a27e55188b9486cb1.tar.gz |
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>
Approved by: Garrett D'Amore <garrett@damore.org>
Diffstat (limited to 'usr/src/lib/libshare/nfs/libshare_nfs.c')
-rw-r--r-- | usr/src/lib/libshare/nfs/libshare_nfs.c | 78 |
1 files changed, 11 insertions, 67 deletions
diff --git a/usr/src/lib/libshare/nfs/libshare_nfs.c b/usr/src/lib/libshare/nfs/libshare_nfs.c index 484244e6ba..9f6acce19f 100644 --- a/usr/src/lib/libshare/nfs/libshare_nfs.c +++ b/usr/src/lib/libshare/nfs/libshare_nfs.c @@ -21,19 +21,19 @@ /* * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright 2016 Nexenta Systems, Inc. * Copyright (c) 2014, 2016 by Delphix. All rights reserved. + * Copyright 2018 Nexenta Systems, Inc. */ /* * NFS specific functions */ + #include <stdio.h> #include <string.h> #include <ctype.h> #include <stdlib.h> #include <unistd.h> -#include <zone.h> #include <errno.h> #include <locale.h> #include <signal.h> @@ -1905,12 +1905,7 @@ nfs_enable_share(sa_share_t share) sa_free_attr_string(sectype); } } - /* - * when we get here, we can do the exportfs system call and - * initiate things. We probably want to enable the - * svc:/network/nfs/server service first if it isn't running. - */ - /* check svc:/network/nfs/server status and start if needed */ + /* now add the share to the internal tables */ printarg(path, &export); /* @@ -1920,52 +1915,17 @@ nfs_enable_share(sa_share_t share) if (iszfs) { struct exportfs_args ea; share_t sh; - char *str; - priv_set_t *priv_effective; - int privileged; - - /* - * If we aren't a privileged user - * and NFS server service isn't running - * then print out an error message - * and return EPERM - */ - priv_effective = priv_allocset(); - (void) getppriv(PRIV_EFFECTIVE, priv_effective); - - privileged = (priv_isfullset(priv_effective) == B_TRUE); - priv_freeset(priv_effective); - - if (!privileged && - (str = smf_get_state(NFS_SERVER_SVC)) != NULL) { - err = 0; - if (strcmp(str, SCF_STATE_STRING_ONLINE) != 0) { - (void) printf(dgettext(TEXT_DOMAIN, - "NFS: Cannot share remote " - "filesystem: %s\n"), path); - (void) printf(dgettext(TEXT_DOMAIN, - "NFS: Service needs to be enabled " - "by a privileged user\n")); - err = SA_SYSTEM_ERR; - errno = EPERM; - } - free(str); - } - - if (err == 0) { - ea.dname = path; - ea.uex = &export; + ea.dname = path; + ea.uex = &export; - (void) sa_sharetab_fill_zfs(share, &sh, "nfs"); - err = sa_share_zfs(share, NULL, path, &sh, - &ea, ZFS_SHARE_NFS); - if (err != SA_OK) { - errno = err; - err = -1; - } - sa_emptyshare(&sh); + (void) sa_sharetab_fill_zfs(share, &sh, "nfs"); + err = sa_share_zfs(share, NULL, path, &sh, &ea, ZFS_SHARE_NFS); + if (err != SA_OK) { + errno = err; + err = -1; } + sa_emptyshare(&sh); } else { err = exportfs(path, &export); } @@ -1973,20 +1933,7 @@ nfs_enable_share(sa_share_t share) if (err < 0) { err = SA_SYSTEM_ERR; switch (errno) { - case EREMOTE: - (void) printf(dgettext(TEXT_DOMAIN, - "NFS: Cannot share filesystems " - "in non-global zones: %s\n"), path); - err = SA_NOT_SUPPORTED; - break; case EPERM: - if (getzoneid() != GLOBAL_ZONEID) { - (void) printf(dgettext(TEXT_DOMAIN, - "NFS: Cannot share file systems " - "in non-global zones: %s\n"), path); - err = SA_NOT_SUPPORTED; - break; - } err = SA_NO_PERMISSION; break; case EEXIST: @@ -2098,9 +2045,6 @@ nfs_disable_share(sa_share_t share, char *path) case EPERM: case EACCES: ret = SA_NO_PERMISSION; - if (getzoneid() != GLOBAL_ZONEID) { - ret = SA_NOT_SUPPORTED; - } break; case EINVAL: case ENOENT: |