hosts/bsd: check for exports file issues prior to exporting NFS

This commit is contained in:
Mitchell Hashimoto 2013-12-13 22:14:13 -08:00
parent c1141dded3
commit 2bebf188d6
4 changed files with 21 additions and 0 deletions

View File

@ -2,6 +2,7 @@
IMPROVEMENTS:
- hosts/bsd: check NFS exports file for issues prior to exporting
- provisioners/docker: Add support for using the provisioner with RedHat
based guests [GH-2649]
- provisioners/docker: Remove "Docker" prefix from Client and Installer

View File

@ -364,6 +364,10 @@ module Vagrant
error_key(:not_found, "vagrant.actions.vm.host_only_network")
end
class NFSBadExports < VagrantError
error_key(:nfs_bad_exports)
end
class NFSCantReadExports < VagrantError
error_key(:nfs_cant_read_exports)
end

View File

@ -2,6 +2,7 @@ require 'log4r'
require "vagrant"
require 'vagrant/util/platform'
require "vagrant/util/subprocess"
module VagrantPlugins
module HostBSD
@ -35,6 +36,8 @@ module VagrantPlugins
end
def nfs_export(id, ips, folders)
nfs_checkexports!
# We need to build up mapping of directories that are enclosed
# within each other because the exports file has to have subdirectories
# of an exported directory on the same line. e.g.:
@ -162,6 +165,13 @@ module VagrantPlugins
protected
def nfs_checkexports!
r = Subprocess.execute("nfsd", "checkexports")
if r.exit_code != 0
raise Vagrant::Errors::NFSBadExports, output: r.stderr
end
end
def nfs_cleanup(id)
return if !File.exist?("/etc/exports")

View File

@ -429,6 +429,12 @@ en:
A multi-vm environment is required for name specification to this command.
multi_vm_target_required: |-
This command requires a specific VM name to target in a multi-VM environment.
nfs_bad_exports: |-
NFS is reporting that your exports file is invalid. Vagrant does
this check before making any changes to the file. Please correct
the issues below and execute "vagrant reload":
%{output}
nfs_cant_read_exports: |-
Vagrant can't read your current NFS exports! The exports file should be
readable by any user. This is usually caused by invalid permissions