Skip to content

Commit a243fd8

Browse files
committed
Fix NFS exports pruning of other users. Issue 9070.
1 parent 216835c commit a243fd8

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/vagrant/util/string_block_editor.rb

+10
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ def keys
4545
end
4646
end
4747

48+
# This returns the keys (or ids) that are in the string regarding current user only (fix for issue 9070).
49+
#
50+
# @return [<Array<String>]
51+
def cur_user_keys
52+
regexp = /^#\s*VAGRANT-BEGIN:\s*(#{Process.uid}\s.+?)$\r?\n?(.*)$\r?\n?^#\s*VAGRANT-END:\s(\1)$/m
53+
@value.scan(regexp).map do |match|
54+
match[0]
55+
end
56+
end
57+
4858
# This deletes the block with the given key if it exists.
4959
def delete(key)
5060
key = Regexp.quote(key)

plugins/hosts/linux/cap/nfs.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,10 @@ def self.nfs_prune(environment, ui, valid_ids)
117117
composite_ids = valid_ids.map do |v_id|
118118
"#{user} #{v_id}"
119119
end
120-
remove_ids = editor.keys - composite_ids
120+
121+
#Fix for issue 9070, pruning other users' NFS exports
122+
#remove_ids = editor.keys - composite_ids
123+
remove_ids = editor.cur_user_keys - composite_ids
121124

122125
logger.debug("Known valid NFS export IDs: #{valid_ids}")
123126
logger.debug("Composite valid NFS export IDs with user: #{composite_ids}")

0 commit comments

Comments
 (0)