Skip to content

Commit

Permalink
Being able to edit a file does not mean you can write in its parent d…
Browse files Browse the repository at this point in the history
…irectory

Interactive `sed` needs write permission on the file itself. However, it
may create a backup file, which leads to the fact that the directory
where the file is located must be writable as well. That is a side
effect because this directory does not need to be writable.

This patch fixes this side effect by editing the file in `/tmp`, and
replaces it right after.
  • Loading branch information
willdurand committed Jun 1, 2015
1 parent f7894d9 commit 6ff15fb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion plugins/hosts/linux/cap/nfs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def self.nfs_cleanup(id)

# Use sed to just strip out the block of code which was inserted
# by Vagrant
system("#{sudo_command}sed -r -e '\\\x01^# VAGRANT-BEGIN:( #{user})? #{id}\x01,\\\x01^# VAGRANT-END:( #{user})? #{id}\x01 d' -ibak /etc/exports")
system("cp /etc/exports $TMPDIR && #{sudo_command}sed -r -e '\\\x01^# VAGRANT-BEGIN:( #{user})? #{id}\x01,\\\x01^# VAGRANT-END:( #{user})? #{id}\x01 d' -ibak $TMPDIR/exports ; cp $TMPDIR/exports /etc/exports")
end

def self.nfs_opts_setup(folders)
Expand Down

0 comments on commit 6ff15fb

Please sign in to comment.