From 86e3fc8c75ca6c86ca7c83ce46bd5a740081e47e Mon Sep 17 00:00:00 2001
From: Mike Hibler <hibler@cs.utah.edu>
Date: Tue, 29 Nov 2022 07:45:31 -0700
Subject: [PATCH] Clean up ambiguity involving WITHZFS and ZFS_NOEXPORT.

The latter should have no meaning without the former, but in one
place we treated it as a fatal error and in another we acted as
though it was a legit combo.
---
 account/accountsetup.in       | 4 ++--
 db/User.pm.in                 | 2 +-
 tbsetup/exports_setup.in      | 4 ++--
 tbsetup/nfsmfs_setup.proxy.in | 5 +++--
 4 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/account/accountsetup.in b/account/accountsetup.in
index 8036828021..1df4a2c6f3 100644
--- a/account/accountsetup.in
+++ b/account/accountsetup.in
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 #
-# Copyright (c) 2010-2021 University of Utah and the Flux Group.
+# Copyright (c) 2010-2022 University of Utah and the Flux Group.
 # 
 # {{{GENIPUBLIC-LICENSE
 # 
@@ -906,7 +906,7 @@ sub MakeDir($$)
     # If ZFS_NOEXPORT is set, then our caller will do the HUPing and waiting.
     #
     my $waitforit = 0;
-    if (!$ZFS_NOEXPORT) {
+    if ($WITHZFS && !$ZFS_NOEXPORT) {
 	#
 	# Note that "waiting for mountd" involves a Utah hack to mountd to
 	# make it record a timestamp in a file when it is done. If there is
diff --git a/db/User.pm.in b/db/User.pm.in
index 1f6277e274..809fbb5691 100644
--- a/db/User.pm.in
+++ b/db/User.pm.in
@@ -2397,7 +2397,7 @@ sub UpdateExports($)
 	
     if (!defined($last_activity) ||
 	time() - $last_activity > ((($exports_limit * 24) - 12) * 3600)) {
-	if ($ZFS_NOEXPORT) {
+	if ($WITHZFS && $ZFS_NOEXPORT) {
 	    mysystem($EXPORTS_SETUP);
 	}
 	elsif (!$WITHAMD) {
diff --git a/tbsetup/exports_setup.in b/tbsetup/exports_setup.in
index e157316d97..64f48e5de4 100644
--- a/tbsetup/exports_setup.in
+++ b/tbsetup/exports_setup.in
@@ -1,6 +1,6 @@
 #!/usr/bin/perl -w
 #
-# Copyright (c) 2000-2021 University of Utah and the Flux Group.
+# Copyright (c) 2000-2022 University of Utah and the Flux Group.
 # 
 # {{{EMULAB-LICENSE
 # 
@@ -123,7 +123,7 @@ if ($TOSTDOUT) {
 
 # ZFS_NOEXPORT requires WITHZFS
 if ($ZFS_NOEXPORT && !$WITHZFS) {
-    fatal("ZFS_NOEXPORT requires WITHZFS, reconfigure\n");
+    $ZFS_NOEXPORT = 0;
 }
 
 # Note no -n option. We redirect stdin from the new exports file below.
diff --git a/tbsetup/nfsmfs_setup.proxy.in b/tbsetup/nfsmfs_setup.proxy.in
index ac36eb8300..2fc603303e 100644
--- a/tbsetup/nfsmfs_setup.proxy.in
+++ b/tbsetup/nfsmfs_setup.proxy.in
@@ -1,7 +1,7 @@
 #!/usr/bin/perl -wT
 
 #
-# Copyright (c) 2000-2017 University of Utah and the Flux Group.
+# Copyright (c) 2000-2022 University of Utah and the Flux Group.
 # 
 # {{{EMULAB-LICENSE
 # 
@@ -46,6 +46,7 @@ my $force = 0;
 # Configure variables
 #
 my $TBOPS       = "@TBOPSEMAIL@";
+my $WITHZFS     = @WITHZFS@;
 my $ZFSROOT	= "@ZFS_ROOT@";
 my $ZFSNOEXPORT	= "@ZFS_NOEXPORT@";
 
@@ -86,7 +87,7 @@ if ($UID != 0) {
     die("Must be root!");
 }
 
-if (! -x "$ZFS") {
+if (! $WITHZFS || ! -x "$ZFS") {
     fatal("Can only be used with ZFS right now!");
 }
 
-- 
GitLab