Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
bundler already does validations on $HOME
Browse files Browse the repository at this point in the history
  • Loading branch information
ajwann committed Aug 20, 2017
1 parent b5414c7 commit e5be03a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 29 deletions.
12 changes: 0 additions & 12 deletions lib/bundler/compact_index_client/updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ def update(local_path, remote_path, retrying = nil)
headers = {}

Bundler::SharedHelpers.filesystem_access(Dir.tmpdir, :write) do
validate_permissions_on_home

Dir.mktmpdir("bundler-compact-index-") do |local_temp_dir|
local_temp_path = Pathname.new(local_temp_dir).join(local_path.basename)

Expand Down Expand Up @@ -106,16 +104,6 @@ def checksum_for_file(path)
Digest::MD5.hexdigest(IO.read(path))
end
end

private

def validate_permissions_on_home
return if File.stat(ENV["HOME"]).writable?
raise Bundler::PermissionError,
"Bundler does not have write access to $HOME. Bundler must " \
"have write access to $HOME to function properly. " \
"$HOME is currently #{ENV["HOME"]}"
end
end
end
end
17 changes: 0 additions & 17 deletions spec/bundler/compact_index_client/updater_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,4 @@
end.to raise_error(Bundler::PermissionError)
end
end

context "when bundler doesn't have permissions on $HOME" do
let(:response) { double(:response, :body => "") }
let(:local_path) { Pathname("/tmp/localpath") }
let(:remote_path) { double(:remote_path) }
let(:home_file_stat) { File::Stat.new("/") }

it "Bundler::PermissionError is raised" do
allow(Dir).to receive(:tmpdir) { "/tmp" }
allow(File).to receive(:stat).with(anything) { home_file_stat }
allow(home_file_stat).to receive(:writable?) { false }

expect do
updater.update(local_path, remote_path)
end.to raise_error(Bundler::PermissionError)
end
end
end

0 comments on commit e5be03a

Please sign in to comment.