From 0688503f7092a87d31b961eb43e2ff6282bc8930 Mon Sep 17 00:00:00 2001 From: Daniel Stefan Haischt Date: Mon, 22 Jan 2007 00:24:04 +0000 Subject: * allow NFS options per export * split NFS daemon options and export options into two different tabs * allow NFS related daemons to bind to a particular IP address --- packages/freenas/pkg/freenas_guiconfig.inc | 1 + packages/freenas/pkg/freenas_services.inc | 64 +- packages/freenas/www/services_nfs.php | 703 ++------------------- packages/freenas/www/services_samba.php | 2 - packages/freenas/www/services_samba_share.php | 8 +- packages/freenas/www/services_samba_share_edit.php | 5 +- 6 files changed, 105 insertions(+), 678 deletions(-) (limited to 'packages/freenas') diff --git a/packages/freenas/pkg/freenas_guiconfig.inc b/packages/freenas/pkg/freenas_guiconfig.inc index 1464b147..2dec5a42 100644 --- a/packages/freenas/pkg/freenas_guiconfig.inc +++ b/packages/freenas/pkg/freenas_guiconfig.inc @@ -36,6 +36,7 @@ $d_raidconfdirty_path = $g['varrun_path'] . "/raid.conf.dirty"; $d_userconfdirty_path = $g['varrun_path'] . "/user.conf.dirty"; $d_groupconfdirty_path = $g['varrun_path'] . "/group.conf.dirty"; $d_smbshareconfdirty_path = $g['varrun_path'] . "/smbshare.conf.dirty"; +$d_nfsexportconfdirty_path = $g['varrun_path'] . "/nfsexport.conf.dirty"; $d_upnpconfdirty_path = $g['varrun_path'] . "/upnp.conf.dirty"; /* ============================================================================= */ diff --git a/packages/freenas/pkg/freenas_services.inc b/packages/freenas/pkg/freenas_services.inc index 1bd9b980..e32ff24f 100644 --- a/packages/freenas/pkg/freenas_services.inc +++ b/packages/freenas/pkg/freenas_services.inc @@ -399,6 +399,9 @@ function services_nfs_configure() { if (isset($freenas_config['nfs']['enable'])) { if ($g['booting']) { echo "Starting NFS... "; } + + $nfsconf = ""; + $a_nfsconf = array(); /* If no share configured, exit */ if (!is_array($freenas_config['mounts']['mount'])) { return 1; } @@ -412,47 +415,44 @@ function services_nfs_configure() { } $a_mount = &$freenas_config['mounts']['mount']; - - /* TODO: ATM network authorization does not work on a per mount basis */ - if (is_array($freenas_config['nfs']['nfsnetwork'])) { - $a_nfsnetworks = array(); - $pfnetworks = array(); - - foreach ($freenas_config['nfs']['nfsnetwork'] as $netel) { - list($network,$subnet) = - explode('/', $netel); - $subnet = gen_subnet_mask($subnet); - $a_nfsnetworks[] = "-network {$network} -mask {$subnet}"; - $pfnetworks[] = $network; - } - - $nfsnetworks_str = implode(' ', $a_nfsnetworks); - services_setup_transparency_for("nfs", implode(" ", $pfnetworks)); - } - foreach ($a_mount as $mount) { /* -mapall and -maproot mutually exclusive */ - $mapping = $freenas_config['nfs']['mapall'] == "yes" ? "-mapall=root" : "-maproot=root"; + $mapping = $mount['nfs']['mapall'] == "yes" ? "-mapall=root" : "-maproot=root"; + $networks = isset($mount['nfs']['networks']) ? $mount['nfs']['networks'] : ""; - $nfsconf .= << "") { + $pfnetworks = array(); + + foreach (explode(",", $networks) as $netel) { + list($network,$subnet) = + explode('/', $netel); + + $subnet = gen_subnet_mask($subnet); + $pfnetworks[] = $network; + + $tmp_nfsconf .= "{$nfsconf} -network {$network} -mask {$subnet}\n"; + } + + $nfsconf = $tmp_nfsconf; + } else { + $nfsconf .= "\n"; + } + } - fwrite($fd, $nfsconf); fclose($fd); + $nfsdbindto = $freenas_config['nfs']['bindto'] = "(ANY)" ? " -a" : " -h {$freenas_config['nfs']['bindto']}"; + $rpcbbindto = $freenas_config['nfs']['bindto'] = "(ANY)" ? "" : " -h {$freenas_config['nfs']['bindto']}"; + $servetcp = isset($freenas_config['nfs']['servetcp']) ? " -t" : ""; + $serveudp = isset($freenas_config['nfs']['serveudp']) ? " -u" : ""; + /* run rpcbind, nfsd and mountd */ - mwexec("/usr/sbin/rpcbind -h {$freenas_config['nfs']['bindto']}"); - mwexec("/usr/sbin/nfsd -h {$freenas_config['nfs']['bindto']} -u -t -n 4"); + mwexec("/usr/sbin/rpcbind{$rpcbbindto}"); + mwexec("/usr/sbin/nfsd{$nfsdbindto}{$serveudp}{$servetcp} -n 4"); mwexec("/usr/sbin/mountd -r {$g['varetc_path']}/exports"); mwexec("/usr/sbin/rpc.lockd"); mwexec("/usr/sbin/rpc.statd"); diff --git a/packages/freenas/www/services_nfs.php b/packages/freenas/www/services_nfs.php index ea5bbf92..7b4b9a18 100644 --- a/packages/freenas/www/services_nfs.php +++ b/packages/freenas/www/services_nfs.php @@ -54,8 +54,9 @@ if (!is_array($freenas_config['nfs'])) } $pconfig['enable'] = isset($freenas_config['nfs']['enable']); -$pconfig['mapall'] = $freenas_config['nfs']['mapall']; $pconfig['bindto'] = $freenas_config['nfs']['bindto']; +$pconfig['serveudp'] = isset($freenas_config['nfs']['serveudp']); +$pconfig['servetcp'] = isset($freenas_config['nfs']['servetcp']); if (! empty($_POST)) { @@ -66,29 +67,11 @@ if (! empty($_POST)) $pconfig = $_POST; /* input validation */ - $reqdfields = explode(" ", "authnetworks bindto"); - $reqdfieldsn = explode(",", "Destination network, IP address to bind to"); + $reqdfields = explode(" ", "bindto"); + $reqdfieldsn = explode(",", "IP address to bind to"); do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); - if (isset($_POST['authnetworks']) && is_array($_POST['authnetworks'])) { - foreach ($_POST['authnetworks'] as $netel) { - list($_POST['network'], $_POST['network_subnet']) = explode('/', $netel); - - if (($_POST['network'] && !is_ipaddr($_POST['network']))) { - $error_bucket[] = array("error" => gettext("A valid network must be specified."), - "field" => "network"); - } - - if (($_POST['network_subnet'] && !is_numeric($_POST['network_subnet']))) { - $error_bucket[] = array("error" => gettext("A valid network bit count must be specified."), - "field" => "network_subnet"); - } - - $osn['nfsnetwork'][] = gen_subnet($_POST['network'], $_POST['network_subnet']) . "/" . $_POST['network_subnet']; - } - } - if (is_array($error_bucket)) foreach($error_bucket as $elem) $input_errors[] =& $elem["error"]; @@ -101,10 +84,19 @@ if (! empty($_POST)) if (!$input_errors) { - $freenas_config['nfs'] = $osn; $freenas_config['nfs']['enable'] = $_POST['enable'] ? true : false; - $freenas_config['nfs']['mapall'] = $_POST['mapall']; $freenas_config['nfs']['bindto'] = $_POST['bindto']; + if (isset($_POST['servetcp'])) { + $freenas_config['nfs']['servetcp'] = $_POST['servetcp']; + } else { + unset($freenas_config['nfs']['servetcp']); + } + if (isset($_POST['serveudp'])) { + $freenas_config['nfs']['serveudp'] = $_POST['serveudp']; + } else { + unset($freenas_config['nfs']['serveudp']); + } + write_config(); $retval = 0; @@ -127,548 +119,22 @@ include("head.inc"); /* put your custom HTML head content here */ /* using some of the $pfSenseHead function calls */ -$addressTransString = gettext("Address"); -$plusimgDescTransString = gettext("add to network list"); -$minusimgDescTransString = gettext("remove from network list"); -$currentnetTransString = gettext("Current networks"); -$networksTypehintTransString = gettext("Network that is authorised to access NFS shares"); - -$networkCount = count($freenas_config['nfs']['nfsnetwork']); -$generatedWANSubnet = gen_subnet($config['interfaces']['wan']['ipaddr'], - $config['interfaces']['wan']['subnet']); -$generatedLANSubnet = gen_subnet($config['interfaces']['lan']['ipaddr'], - $config['interfaces']['lan']['subnet']); - $jscriptstr = << @@ -683,11 +149,25 @@ echo $pfSenseHead->getHTML(); "> +
-
- - +
+
+ + + + + + +
+ +
+
+ - - - - - + - - - -
@@ -700,16 +180,19 @@ echo $pfSenseHead->getHTML();
- -
- -
- - - - - -
: - -
+

+ /> + +

+

+ /> + +

+

+ : + + + +

  - - " onmousedown="selectnetel();" onkeydown="selectnetel();" /> -
  - - : - -
-
    -
  • - - - -
  • -
  • - - - -
  • -
  • - - - -
  • -
+ " />
- +
+
+ diff --git a/packages/freenas/www/services_samba.php b/packages/freenas/www/services_samba.php index 06a0291d..afd90a08 100644 --- a/packages/freenas/www/services_samba.php +++ b/packages/freenas/www/services_samba.php @@ -234,8 +234,6 @@ echo $pfSenseHead->getHTML();
- - - - - + + + diff --git a/packages/freenas/www/services_samba_share_edit.php b/packages/freenas/www/services_samba_share_edit.php index 02efc98d..d417fa4c 100644 --- a/packages/freenas/www/services_samba_share_edit.php +++ b/packages/freenas/www/services_samba_share_edit.php @@ -81,7 +81,8 @@ if (! empty($_POST)) if (!$input_errors) { - if(!$_POST['browseable']) { + /* TODO: This logic needs to be tested! */ + if($_POST['browseable'] == gettext("No")) { $freenas_config['samba']['hidemount'] = array_merge($freenas_config['samba']['hidemount'],array($freenas_config['mounts']['mount'][$id]['sharename'])); } else { if(is_array($freenas_config['samba']['hidemount']) && in_array($freenas_config['mounts']['mount'][$id]['sharename'],$freenas_config['samba']['hidemount'])) { @@ -109,7 +110,7 @@ echo $pfSenseHead->getHTML();
- +
diff --git a/packages/freenas/www/services_samba_share.php b/packages/freenas/www/services_samba_share.php index 95f1fe0b..1545df97 100644 --- a/packages/freenas/www/services_samba_share.php +++ b/packages/freenas/www/services_samba_share.php @@ -143,11 +143,11 @@ echo $pfSenseHead->getHTML();
   - "); ?>
-- cgit v1.2.3