Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NFS exports pruning of other users. Issue 9070. #13112

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/vagrant/util/string_block_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ def keys
end
end

# This returns the keys (or ids) that are in the string regarding current user only (fix for issue 9070).
#
# @return [<Array<String>]
def cur_user_keys
regexp = /^#\s*VAGRANT-BEGIN:\s*(#{Process.uid}\s.+?)$\r?\n?(.*)$\r?\n?^#\s*VAGRANT-END:\s(\1)$/m
@value.scan(regexp).map do |match|
match[0]
end
end

# This deletes the block with the given key if it exists.
def delete(key)
key = Regexp.quote(key)
Expand Down
5 changes: 4 additions & 1 deletion plugins/hosts/linux/cap/nfs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ def self.nfs_prune(environment, ui, valid_ids)
composite_ids = valid_ids.map do |v_id|
"#{user} #{v_id}"
end
remove_ids = editor.keys - composite_ids

#Fix for issue 9070, pruning other users' NFS exports
#remove_ids = editor.keys - composite_ids
remove_ids = editor.cur_user_keys - composite_ids

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