Skip to content

Commit

Permalink
Merge pull request #4244 from rolandwalker/toplevel_dir_permissions
Browse files Browse the repository at this point in the history
special case permissions when creating `/opt`
  • Loading branch information
rolandwalker committed May 8, 2014
2 parents 4f82dda + 1fe644f commit dd5d767
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/cask.rb
Expand Up @@ -56,9 +56,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 dd5d767

Please sign in to comment.