summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAdam Wanninger <ajwann@ajwann.codes>2018-01-14 10:38:57 -0500
committerAdam Wanninger <ajwann@ajwann.codes>2018-01-25 10:01:13 -0500
commit2a21e5e3ac377e87a81b7ddd910d7a85bf256dd6 (patch)
treefc3af485158ed9c39ad8adacd440b9c6909ae41c /lib
parentb1fd32c2f34512525253a5da2882e3e4612967b1 (diff)
downloadbundler-2a21e5e3ac377e87a81b7ddd910d7a85bf256dd6.tar.gz
warn user if a file is not R/W and owned by another user
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/cli/doctor.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/bundler/cli/doctor.rb b/lib/bundler/cli/doctor.rb
index 6fd9f177bb..3e0898ff8a 100644
--- a/lib/bundler/cli/doctor.rb
+++ b/lib/bundler/cli/doctor.rb
@@ -98,10 +98,15 @@ module Bundler
def check_home_permissions
require "find"
files_not_readable_or_writable = []
+ files_not_rw_and_owned_by_different_user = []
files_not_owned_by_current_user_but_still_rw = []
Find.find(Bundler.home.to_s).each do |f|
if !File.writable?(f) || !File.readable?(f)
- files_not_readable_or_writable << f
+ if File.stat(f).uid != Process.uid
+ files_not_rw_and_owned_by_different_user << f
+ else
+ files_not_readable_or_writable << f
+ end
elsif File.stat(f).uid != Process.uid
files_not_owned_by_current_user_but_still_rw << f
end
@@ -115,6 +120,13 @@ module Bundler
ok = false
end
+ if files_not_rw_and_owned_by_different_user.any?
+ Bundler.ui.warn "Files exist in the Bundler home that are owned by another " \
+ "user, and are not readable/writable. These files are:\n - #{files_not_rw_and_owned_by_different_user.join("\n - ")}"
+
+ ok = false
+ end
+
if files_not_readable_or_writable.any?
Bundler.ui.warn "Files exist in the Bundler home that are not " \
"readable/writable by the current user. These files are:\n - #{files_not_readable_or_writable.join("\n - ")}"