Skip to content

Commit

Permalink
special case permissions when creating /opt
Browse files Browse the repository at this point in the history
or any other toplevel directory. Closes #4187
  • Loading branch information
rolandwalker committed May 7, 2014
1 parent e1ee7b1 commit 1fe644f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/cask.rb
Expand Up @@ -55,9 +55,19 @@ def self.init
if caskroom.parent.writable?
system '/bin/mkdir', caskroom
else
toplevel_dir = caskroom
toplevel_dir = toplevel_dir.parent until toplevel_dir.parent.root?
unless toplevel_dir.directory?
# If a toplevel dir such as '/opt' must be created, enforce standard permissions.
# sudo in system is rude.
system '/usr/bin/sudo', '--', '/bin/mkdir', '--', toplevel_dir
system '/usr/bin/sudo', '--', '/bin/chmod', '--', '0775', toplevel_dir
end
# sudo in system is rude.
system '/usr/bin/sudo', '--', '/bin/mkdir', '-p', '--', caskroom
system '/usr/bin/sudo', '--', '/usr/sbin/chown', '-R', '--', "#{current_user}:staff", caskroom.parent
unless caskroom.parent == toplevel_dir
system '/usr/bin/sudo', '--', '/usr/sbin/chown', '-R', '--', "#{current_user}:staff", caskroom.parent
end
end
end
end
Expand Down

0 comments on commit 1fe644f

Please sign in to comment.